phaserunner 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a2f46afec661bbb08bb41df2e8e68328fde4dc81
4
- data.tar.gz: c3510f359bd9f0056cd60f952ae5034c8ba986f0
3
+ metadata.gz: 69d1fcab82cbcf7376f98edd6a0845f2c3b02333
4
+ data.tar.gz: cdc9c3378edd95be4303cb389263b6d726a5439c
5
5
  SHA512:
6
- metadata.gz: 5c8b871c2747b949df465c823aa289e76bf33b941bea4833b8d1b503016bc10ddafeb3164b94e328c483437a66bac426300f02de424d1cb30dc1638cca68869a
7
- data.tar.gz: a23c73c8500f3d30cec1708264629376d06ac14508a7c57f2bfcc0503004abc7ed8a4f5810ad5c296fd60cc1d76b888a2172863e19b7e2222ef57a2e478e5de7
6
+ metadata.gz: 0ef9f48828d7fd8925b55bd3498a495574f9b43bddf56741615115fa056463bcc45f70fa31f696dd1c8655623ddc79903d17029f2f6f1eaf1f31f29d0b2c0ae2
7
+ data.tar.gz: 9d28ca30e219a5db6786ef134c2a0696beb24182b7fecd35ae8591f867d2d4770b4cb805ca22f9e11ae275f2d2786d1a48469d2c421be8343b8aba0e67e3e91e
data/README.md CHANGED
@@ -114,12 +114,12 @@ gem install phaserunner
114
114
 
115
115
  ## Contributing
116
116
 
117
- Bug reports and pull requests are welcome on GitHub at https://github.com/rberger/rmodbus_cli.
117
+ Bug reports and pull requests are welcome on GitHub at https://github.com/rberger/phaserunner.
118
118
 
119
119
 
120
120
  ### Code of Conduct in Contriubing
121
121
 
122
- This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Code of Conduct](CODE_OF_CONDUCT.md).
122
+ This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Code of Conduct](CODE-OF-CONDUCT.md).
123
123
 
124
124
  ## Versioning
125
125
 
@@ -2,6 +2,14 @@ require 'rmodbus'
2
2
  require 'json'
3
3
  require 'asi_bod'
4
4
 
5
+ # Add mechanism to convert Integers from modbus into signed integers
6
+ class Integer
7
+ def to_signed(bits)
8
+ mask = (1 << (bits - 1))
9
+ (self & ~mask) - (self & mask)
10
+ end
11
+ end
12
+
5
13
  module Phaserunner
6
14
  # Methods for communicating with the Modbus interface to the Phaserunner
7
15
  class Modbus
@@ -28,10 +36,7 @@ module Phaserunner
28
36
  dictionary_file: default_file_path,
29
37
  loop_count: :forever,
30
38
  quiet: false,
31
- register_list: register_list,
32
- registers_start_address: 258,
33
- registers_count: 15,
34
- registers_misc: [276, 277, 334]
39
+ register_list: register_list
35
40
  }
36
41
 
37
42
  attr_reader :tty
@@ -92,10 +97,36 @@ module Phaserunner
92
97
  end
93
98
  end
94
99
 
100
+ def read_scaled_range(start_address, count)
101
+ data = read_raw_range(start_address, count)
102
+ data.map.with_index do |val, index|
103
+ address = index + start_address
104
+ if dict[address][:type] == "independent"
105
+ value = val.to_signed(16) / dict[address][:scale]
106
+ value
107
+ elsif dict[address][:type].downcase == "bit vector"
108
+ value = val.to_s(2)
109
+ else
110
+ value = val
111
+ end
112
+ value
113
+ end
114
+
115
+ end
95
116
  def range_address_header(start_address, count)
96
117
  end_address = start_address + count
97
118
  (start_address...end_address).map do |address|
98
- "#{dict[address][:name]} (#{dict[address][:units]})"
119
+ units = case dict[address][:type].downcase
120
+ when "bit vector"
121
+ "Flags"
122
+ when "enum"
123
+ "enum"
124
+ when "dependent"
125
+ "Unscaled #{dict[address][:units]}"
126
+ else
127
+ dict[address][:units]
128
+ end
129
+ "#{dict[address][:name]} (#{units})"
99
130
  end
100
131
  end
101
132
 
@@ -116,8 +147,8 @@ module Phaserunner
116
147
  # @return [Array<Integer>] List of the register values in the order requested
117
148
  def bulk_log_data(registers = register_list)
118
149
  registers.map do |reg|
119
- read_raw_range(reg.start, reg.count)
120
- end
150
+ read_scaled_range(reg.start, reg.count)
151
+ end.flatten
121
152
  end
122
153
 
123
154
  # Get the headers for the bulk_log data
@@ -126,7 +157,7 @@ module Phaserunner
126
157
  def bulk_log_header(registers = register_list)
127
158
  registers.map do |reg|
128
159
  range_address_header(reg.start, reg.count)
129
- end
160
+ end.flatten
130
161
  end
131
162
  end
132
163
  end
@@ -1,3 +1,3 @@
1
1
  module Phaserunner
2
- VERSION = '0.2.2'
2
+ VERSION = '0.2.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phaserunner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
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-05-07 00:00:00.000000000 Z
11
+ date: 2018-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gli