Class: McProtocolE::Frame3e::BatchReadInMultiple
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- McProtocolE::Frame3e::BatchReadInMultiple
- Defined in:
- lib/mc_protocol_e/frame_3e/batch_read_in_multiple.rb
Overview
This class shows a command to batch read in word.
Constant Summary collapse
- COMMAND =
"\x06\x04\x00\x00".b
Instance Method Summary collapse
-
#initialize(device_ranges:) ⇒ BatchReadInMultiple
constructor
Constructor.
-
#parse(res) ⇒ Object
Returns array of word.
-
#to_b ⇒ String
Returns binary string.
Constructor Details
#initialize(device_ranges:) ⇒ BatchReadInMultiple
Constructor.
14 15 16 17 |
# File 'lib/mc_protocol_e/frame_3e/batch_read_in_multiple.rb', line 14 def initialize(device_ranges:) super(COMMAND) @device_ranges = device_ranges end |
Instance Method Details
#parse(res) ⇒ Object
Returns array of word. @return array of word
22 23 24 25 26 |
# File 'lib/mc_protocol_e/frame_3e/batch_read_in_multiple.rb', line 22 def parse(res) super(res) res.data&.each_char&.each_slice(2)&.map(&:join) end |
#to_b ⇒ String
Returns binary string.
30 31 32 33 34 35 36 |
# File 'lib/mc_protocol_e/frame_3e/batch_read_in_multiple.rb', line 30 def to_b @to_b ||= command + [word_block_num].pack("v")[0] + [bit_block_num].pack("v")[0] + device_ranges.map(&:to_b).join end |