cycle_analyst_logger 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.rdoc +7 -7
- data/lib/cycle_analyst_logger/cli.rb +10 -1
- data/lib/cycle_analyst_logger/cycle_analyst.rb +32 -0
- data/lib/cycle_analyst_logger/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 271a460b2211a9d5021cc3994a43ed5380cbeb43
|
4
|
+
data.tar.gz: 3ad2cd453f30f2f6809864578967d0f6cbe3f368
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a49ee57ab3196de2b29bcfad840a932ad17640490da5434cff0ee52ca85b3e4e7e262b29033709deb15803f01c01c25d04e8fcf6724b7b7438f25b77b26745d4
|
7
|
+
data.tar.gz: 59882320fe416ab40be3170d398c38598025ff454565d463d49b30f797138f0bcf2a2dbe0fc8f3fcbfb79b2a54f3f3abf73d7af6405e4d38251b0e3aab62ce44
|
data/.gitignore
CHANGED
data/README.rdoc
CHANGED
@@ -97,28 +97,28 @@ There is a working systemd service unit file
|
|
97
97
|
+resources/cycle_analyst_logger.service+. You can copy it into
|
98
98
|
+/lib/systemd/system+ and do a
|
99
99
|
|
100
|
-
|
100
|
+
<tt>systemctl daemon-reload</tt> to load it into systemd
|
101
101
|
|
102
102
|
* If you want it to start when the system is booted say:
|
103
103
|
|
104
|
-
|
104
|
+
<tt>systemctl enable cycle_analyst_logger.service</tt>
|
105
105
|
|
106
106
|
* To disable:
|
107
107
|
|
108
|
-
|
108
|
+
<tt>systemctl disable cycle_analyst_logger.service</tt>
|
109
109
|
|
110
110
|
* To start it manually (have to do this also the first time you do an enable and
|
111
111
|
want it to run then):
|
112
112
|
|
113
|
-
|
113
|
+
<tt>systemctl start cycle_analyst_logger.service</tt>
|
114
114
|
|
115
115
|
* You can check the status:
|
116
116
|
|
117
|
-
|
117
|
+
<tt>systemctl status cycle_analyst_logger.service</tt>
|
118
118
|
|
119
119
|
* To see the logs:
|
120
120
|
|
121
|
-
|
121
|
+
<tt>journalctl -u cycle_analyst_logger.service</tt>
|
122
122
|
|
123
123
|
This file assumed that rvm was installed in my home directory and an rvm wrapper
|
124
124
|
was created so it the service unit file could just exec it. I am currently using
|
@@ -126,7 +126,7 @@ Ruby 2.4.1.
|
|
126
126
|
|
127
127
|
The command used to create the wrapper was run as my normal user:
|
128
128
|
|
129
|
-
|
129
|
+
<tt>rvm alias create cycle_analyst_logger 2.4.1</tt>
|
130
130
|
|
131
131
|
== License and Copyright
|
132
132
|
|
@@ -80,7 +80,16 @@ module CycleAnalystLogger
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
-
|
83
|
+
desc 'Transform logs to CA format'
|
84
|
+
arg_name 'log_filename'
|
85
|
+
command :to_ca_file do |to_ca_file|
|
86
|
+
to_ca_file.action do |global_options, options, args|
|
87
|
+
log_filename = args[0]
|
88
|
+
CycleAnalyst.log_to_ca_file(log_filename)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
pre do |global,command,options,args|
|
84
93
|
# Pre logic here
|
85
94
|
# Return true to proceed; false to abort and not call the
|
86
95
|
# chosen command
|
@@ -49,6 +49,9 @@ module CycleAnalystLogger
|
|
49
49
|
13 => { address: 12, name: "Limit Flags", units: "bit flags", scale: 1}
|
50
50
|
}
|
51
51
|
|
52
|
+
# CA_STD_HEADER
|
53
|
+
CA_STD_HEADER = %w(Ah V A S D Deg RPM HW Nm ThI ThO AuxA AuxD Flgs)
|
54
|
+
|
52
55
|
# CycleAnalyst New
|
53
56
|
def initialize(opts)
|
54
57
|
@baudrate = opts[:baud_ca]
|
@@ -136,5 +139,34 @@ module CycleAnalystLogger
|
|
136
139
|
break if idx >= loop_count
|
137
140
|
end
|
138
141
|
end
|
142
|
+
|
143
|
+
def self.valid_timestamp(input)
|
144
|
+
begin
|
145
|
+
Time.parse(input)
|
146
|
+
rescue ArgumentError
|
147
|
+
nil
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def self.log_to_ca_file(log_filename)
|
152
|
+
output_filename = log_filename.sub(
|
153
|
+
/cycle_analyst\.(\d\d\d\d\-\d\d\-\d\d_\d\d\-\d\d\-\d\d).csv/,
|
154
|
+
'CALog_\1.txt'
|
155
|
+
)
|
156
|
+
out_fd = File.open(output_filename, 'w')
|
157
|
+
|
158
|
+
File.readlines(log_filename).each.with_index do |log_line, idx|
|
159
|
+
log_record = log_line.split(',')
|
160
|
+
if idx == 0
|
161
|
+
out_fd.puts CA_STD_HEADER.join("\t")
|
162
|
+
next
|
163
|
+
end
|
164
|
+
|
165
|
+
# Check that the line has a valid timestamp, skip this line if it isn't
|
166
|
+
next unless (timestamp = valid_timestamp log_record[0])
|
167
|
+
|
168
|
+
out_fd.puts log_record[1..CA_STD_HEADER.length].join("\t")
|
169
|
+
end
|
170
|
+
end
|
139
171
|
end
|
140
172
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cycle_analyst_logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert J. Berger
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gli
|