green_eye_monitor 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +7 -1
- data/CHANGELOG.md +4 -0
- data/exe/green_eye_monitor +3 -3
- data/lib/green_eye_monitor/client.rb +13 -4
- data/lib/green_eye_monitor/errors.rb +1 -0
- data/lib/green_eye_monitor/packet/bin_net_base.rb +10 -12
- data/lib/green_eye_monitor/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: 7663ce5a7fac9acec62f26da6736257acd048c09
|
4
|
+
data.tar.gz: bdf2c0843106306a6fb8ea85750028fdf18a95f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d037172e610ae30773832c2a7d3d31da14e1765626a3d908ea3fab3187c8d931526323ce7f221d935c9fb1ab64a5ab5faa05d63617497072e01bfeab983af59
|
7
|
+
data.tar.gz: e7d7a2748ffbd88b8f94843da8007d71672ddf10d6b18476e277fc562d4e9cb7e7165dd1ddc52cf4b9240eda7348562011d1a28bc970e8f4a31f0e49cc4d21a4
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/exe/green_eye_monitor
CHANGED
@@ -10,7 +10,7 @@ require 'terminal-table'
|
|
10
10
|
|
11
11
|
opts = Slop.parse do |o|
|
12
12
|
o.bool '-d', '--debug', 'enable debug mode'
|
13
|
-
o.string '--port', 'serial port', default
|
13
|
+
o.string '--port', 'serial port', :default => '/dev/ttyUSB1'
|
14
14
|
o.on '--version', 'print the version' do
|
15
15
|
puts Slop::VERSION
|
16
16
|
exit
|
@@ -54,13 +54,13 @@ rows << ['ABS Watts'] + data.abs_watts
|
|
54
54
|
rows << ['VA'] + data.va
|
55
55
|
rows << ['Polarised Watts'] + data.polarised_watts
|
56
56
|
rows << ['Current'] + data.current
|
57
|
-
rows.each {|row| row.slice!(15..28)}
|
57
|
+
rows.each { |row| row.slice!(15..28) }
|
58
58
|
headings = [''] + (1..15).to_a + (30..32).to_a
|
59
59
|
puts Terminal::Table.new(:rows => rows, :headings => headings)
|
60
60
|
puts
|
61
61
|
|
62
62
|
puts "ABS Total: #{data.abs_watts.to_a[0..14].inject(:+)} vs #{data.abs_watts.to_a[28..31].inject(:+)}"
|
63
|
-
puts "
|
63
|
+
puts "Polar Total: #{data.polarised_watts.to_a[0..24].inject(:+)} vs #{data.polarised_watts.to_a[28..31].inject(:+)}"
|
64
64
|
puts "VA Total: #{data.va.to_a[0..14].inject(:+)} vs #{data.va.to_a[28..31].inject(:+)}"
|
65
65
|
puts "Current Total: #{data.current.to_a[0..14].inject(:+)} vs #{data.current.to_a[28..31].inject(:+)}"
|
66
66
|
|
@@ -192,7 +192,7 @@ module GreenEyeMonitor
|
|
192
192
|
read(:expect => /VAL.*END\r\n$/)
|
193
193
|
end
|
194
194
|
|
195
|
-
# rubocop:disable Metrics/
|
195
|
+
# rubocop:disable Metrics/CyclomaticComplexity,Metrics/MethodLength
|
196
196
|
def send_one_packet(old_packet = nil)
|
197
197
|
pf = packet_format
|
198
198
|
raise(Errors::NotImplemented, "Unimplemented packet format: #{pf}") unless IMPLEMENTED_FORMATS.include?(pf)
|
@@ -219,7 +219,7 @@ module GreenEyeMonitor
|
|
219
219
|
Packet::Bin32Abs.read(StringIO.new(packet), old_packet)
|
220
220
|
end
|
221
221
|
end
|
222
|
-
# rubocop:enable Metrics/
|
222
|
+
# rubocop:enable Metrics/CyclomaticComplexity,Metrics/MethodLength
|
223
223
|
|
224
224
|
private
|
225
225
|
|
@@ -248,7 +248,6 @@ module GreenEyeMonitor
|
|
248
248
|
def read(options = {})
|
249
249
|
wait if options[:wait]
|
250
250
|
|
251
|
-
# TODO: Make :expect an arg if w never need anything else
|
252
251
|
if options[:expect]
|
253
252
|
data = read_expect(options[:expect])
|
254
253
|
elsif options[:length]
|
@@ -267,7 +266,17 @@ module GreenEyeMonitor
|
|
267
266
|
end
|
268
267
|
|
269
268
|
def wait
|
270
|
-
|
269
|
+
iterations = 5 * 1_000 / @serial.read_timeout
|
270
|
+
|
271
|
+
i = 0
|
272
|
+
loop do
|
273
|
+
byte = @serial.getbyte
|
274
|
+
break if byte.nil?
|
275
|
+
|
276
|
+
i += 1
|
277
|
+
raise(Errors::Timeout, 'Waited too long for data') if i > iterations
|
278
|
+
end
|
279
|
+
|
271
280
|
@serial.ungetbyte(byte)
|
272
281
|
end
|
273
282
|
end
|
@@ -93,20 +93,18 @@ module GreenEyeMonitor
|
|
93
93
|
end
|
94
94
|
|
95
95
|
def derive_watts(prev_ws_values, curr_ws_values, prev_sec, cur_sec)
|
96
|
-
if prev_sec > cur_sec
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
end
|
96
|
+
sec_diff = if prev_sec > cur_sec
|
97
|
+
256 ^ 3 - prev_sec + cur_sec
|
98
|
+
else
|
99
|
+
cur_sec - prev_sec
|
100
|
+
end
|
102
101
|
|
103
102
|
prev_ws_values.zip(curr_ws_values).map do |prev_ws, curr_ws|
|
104
|
-
if prev_ws > curr_ws
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
end
|
103
|
+
ws_diff = if prev_ws > curr_ws
|
104
|
+
256 ^ 5 - prev_ws + curr_ws
|
105
|
+
else
|
106
|
+
curr_ws - prev_ws
|
107
|
+
end
|
110
108
|
|
111
109
|
watts = ws_diff / sec_diff
|
112
110
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: green_eye_monitor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Ferlito
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: serialport
|