axpert_rs232 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/axpert_commands.rb +9 -9
- data/lib/voltronic_device_operation.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a55f87bf3885c55d1f3d8765a6692ad24cb23b6f
|
4
|
+
data.tar.gz: a428611424453e3d2822bf6a063ef5896551ac54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61875ef2d1849dfb505269808f3451e4632e84f9abeaafb53acf4571c98eaebd0cb3f7a1d1a9e701861deeda3013ab3e8cdb6323a05945cd7d9580378a60133f
|
7
|
+
data.tar.gz: 001c759d71bb3b6ab3a286204ba7a97bfa672868bba935b664c636c371e5399e2f906df17f8863e330ff077a947daaacbb8cb7ba2f2a316569e49cf475ca68d7
|
data/lib/axpert_commands.rb
CHANGED
@@ -275,9 +275,9 @@ module AxpertCommands
|
|
275
275
|
# Returns:
|
276
276
|
# # A Hash containing parallel device status information
|
277
277
|
# { grid_voltage: 230.5, grid_current: 11.2, .. }
|
278
|
-
PARALLEL_DEVICE_STATUS = OP.new(command: lambda { |i = 0| "QPGS#{Integer(i
|
278
|
+
PARALLEL_DEVICE_STATUS = OP.new(command: lambda { |i = 0| "QPGS#{Integer(i)}" }, parser: lambda do |r|
|
279
279
|
r = r.data[1..-1].split(' ')
|
280
|
-
status = r[19].chars
|
280
|
+
status = r[19].chars.to_a
|
281
281
|
{ parallel_number_exists: Boolean(r[0]),
|
282
282
|
serial_number: r[1],
|
283
283
|
device_mode: CONS::DEVICE_MODE[r[2]],
|
@@ -329,7 +329,7 @@ module AxpertCommands
|
|
329
329
|
# Returns:
|
330
330
|
# # A Boolean indicating if the frequency was set succesfully
|
331
331
|
# true # Example
|
332
|
-
SET_OUTPUT_FREQUENCY = OP.new(command: lambda { |input| "F#{Integer(input
|
332
|
+
SET_OUTPUT_FREQUENCY = OP.new(command: lambda { |input| "F#{Integer(input).to_s.rjust(2, '0')}" }, error_on_nak: false, parser: lambda { |r| (r.data == '(ACK') })
|
333
333
|
|
334
334
|
##
|
335
335
|
# Set device output source priority
|
@@ -380,7 +380,7 @@ module AxpertCommands
|
|
380
380
|
# true # Example
|
381
381
|
SET_CHARGER_SOURCE_PRIORITY = OP.new(command: lambda do |mode, parallel_machine_number = nil|
|
382
382
|
if parallel_machine_number.nil?
|
383
|
-
"PPCP#{Integer(parallel_machine_number
|
383
|
+
"PPCP#{Integer(parallel_machine_number).to_s}#{CONS::CHARGER_SOURCE_PRIORITY.key(mode).to_s.rjust(2, '0')}"
|
384
384
|
else
|
385
385
|
"PCP#{CONS::CHARGER_SOURCE_PRIORITY.key(mode).to_s.rjust(2, '0')}"
|
386
386
|
end
|
@@ -481,11 +481,11 @@ module AxpertCommands
|
|
481
481
|
# # A Boolean indicating if the maximum charging current was set successfully
|
482
482
|
# true # Example
|
483
483
|
SET_MAXIMUM_CHARGING_CURRENT = OP.new(command: lambda do |current, parallel_machine_number = 0|
|
484
|
-
current = Integer(current
|
484
|
+
current = Integer(current)
|
485
485
|
if (current >= 100)
|
486
|
-
"MNCHGC#{Integer(parallel_machine_number
|
486
|
+
"MNCHGC#{Integer(parallel_machine_number).to_s}#{current.to_s.rjust(3, '0')}"
|
487
487
|
else
|
488
|
-
"MCHGC#{Integer(parallel_machine_number
|
488
|
+
"MCHGC#{Integer(parallel_machine_number).to_s}#{current.to_s.rjust(2, '0')}"
|
489
489
|
end
|
490
490
|
end, error_on_nak: false, parser: lambda { |r| (r.data == '(ACK') })
|
491
491
|
|
@@ -503,7 +503,7 @@ module AxpertCommands
|
|
503
503
|
# # A Boolean indicating if the maximum charging current for utility was set successfully
|
504
504
|
# true # Example
|
505
505
|
SET_MAXIMUM_UTILITY_CHARGING_CURRENT = OP.new(command: lambda do |current, parallel_machine_number = 0|
|
506
|
-
"MUCHGC#{Integer(parallel_machine_number
|
506
|
+
"MUCHGC#{Integer(parallel_machine_number).to_s}#{Integer(current).to_s.rjust(2, '0')}"
|
507
507
|
end, error_on_nak: false, parser: lambda { |r| (r.data == '(ACK') })
|
508
508
|
|
509
509
|
##
|
@@ -520,7 +520,7 @@ module AxpertCommands
|
|
520
520
|
# # A Boolean indicating if the parallel output mode was set successfully
|
521
521
|
# true # Example
|
522
522
|
SET_OUTPUT_MODE = OP.new(command: lambda do |mode, parallel_machine_number = 0|
|
523
|
-
"POPM#{CONS::OUTPUT_MODE.key(mode)}#{Integer(parallel_machine_number
|
523
|
+
"POPM#{CONS::OUTPUT_MODE.key(mode)}#{Integer(parallel_machine_number).to_s}"
|
524
524
|
end, error_on_nak: false, parser: lambda { |r| (r.data == '(ACK') })
|
525
525
|
|
526
526
|
require 'axpert_constants'
|
@@ -42,7 +42,7 @@ class VoltronicDeviceOperation
|
|
42
42
|
##
|
43
43
|
# Issue a command to the device and parse the output result
|
44
44
|
def issue_command(serial, *args)
|
45
|
-
serial.read_timeout = -1 # Prevent locking on serial
|
45
|
+
serial.read_timeout = -1 rescue nil # Prevent locking on serial
|
46
46
|
|
47
47
|
serial.write(command(*args).bytes)
|
48
48
|
result = begin
|
@@ -51,12 +51,12 @@ class VoltronicDeviceOperation
|
|
51
51
|
while(true)
|
52
52
|
ch = serial.getc # Retrieve a single character from Serial port
|
53
53
|
if ch.nil?
|
54
|
+
raise ::IOError.new("IO read timeout reached, giving up") if (Time.now.to_i > read_timeout)
|
54
55
|
sleep 0.1 # 100ms pause before polling again
|
55
56
|
next
|
56
57
|
end
|
57
58
|
parse += ch
|
58
59
|
break if (@termination_character == ch)
|
59
|
-
raise ::IOError.new("IO read timeout reached, giving up") if (Time.now.to_i > read_timeout)
|
60
60
|
end
|
61
61
|
parse
|
62
62
|
end
|