Class: McProtocolE::Frame1e::BatchWriteInWord
- Inherits:
-
Object
- Object
- McProtocolE::Frame1e::BatchWriteInWord
- Extended by:
- Forwardable
- Defined in:
- lib/mc_protocol_e/frame_1e/batch_write_in_word.rb
Overview
This class shows a command to batch read in word.
Constant Summary collapse
- REQUEST_HEADER =
"\x03".b
- RESPONSE_HEADER =
"\x83".b
Instance Attribute Summary collapse
-
#request_header ⇒ Object
readonly
Returns the value of attribute request_header.
Instance Method Summary collapse
-
#initialize(device_range:, values:) ⇒ BatchWriteInWord
constructor
Constructor.
-
#parse(res) ⇒ Object
Returns array of word.
-
#to_b ⇒ String
Returns binary string.
Constructor Details
#initialize(device_range:, values:) ⇒ BatchWriteInWord
Constructor.
20 21 22 23 24 25 26 |
# File 'lib/mc_protocol_e/frame_1e/batch_write_in_word.rb', line 20 def initialize(device_range:, values:) @request_header = REQUEST_HEADER @device_range = device_range @values = values validate end |
Instance Attribute Details
#request_header ⇒ Object (readonly)
Returns the value of attribute request_header.
14 15 16 |
# File 'lib/mc_protocol_e/frame_1e/batch_write_in_word.rb', line 14 def request_header @request_header end |
Instance Method Details
#parse(res) ⇒ Object
Returns array of word. @return array of word
31 32 33 |
# File 'lib/mc_protocol_e/frame_1e/batch_write_in_word.rb', line 31 def parse(res) res.data&.each_char&.each_slice(2)&.map(&:join) end |
#to_b ⇒ String
Returns binary string.
37 38 39 |
# File 'lib/mc_protocol_e/frame_1e/batch_write_in_word.rb', line 37 def to_b @to_b ||= device_range.to_b + values.pack("v*") end |