Class: SDN::Message::SetGroupAddr
- Inherits:
-
Message
- Object
- Message
- SDN::Message::SetGroupAddr
- Defined in:
- lib/sdn/message/set.rb
Overview
Command that assigns a motor to a group slot.
Constant Summary collapse
- MSG =
Protocol message number
0x51- PARAMS_LENGTH =
Number of protocol parameter bytes expected
4
Instance Attribute Summary collapse
- #group_address ⇒ (Integer, Integer, Integer)?
-
#group_index ⇒ Integer
Group slot to assign the address to in the range 1..16.
Instance Method Summary collapse
-
#class_inspect ⇒ String?
Returns the protocol-specific portion of the inspection string.
-
#initialize(dest = nil, group_index = 1, group_address = nil, **kwargs) ⇒ SetGroupAddr
constructor
Creates a group assignment command.
-
#params ⇒ <Integer>
Returns the protocol-specific payload bytes for this message.
-
#parse(params) ⇒ void
Parses protocol-specific parameter bytes into this message instance.
Constructor Details
#initialize(dest = nil, group_index = 1, group_address = nil, **kwargs) ⇒ SetGroupAddr
Creates a group assignment command.
84 85 86 87 88 89 |
# File 'lib/sdn/message/set.rb', line 84 def initialize(dest = nil, group_index = 1, group_address = nil, **kwargs) kwargs[:dest] ||= dest super(**kwargs) self.group_index = group_index self.group_address = group_address end |
Instance Attribute Details
#group_address ⇒ (Integer, Integer, Integer)?
69 70 71 |
# File 'lib/sdn/message/set.rb', line 69 def group_address @group_address end |
#group_index ⇒ Integer
Group slot to assign the address to in the range 1..16.
76 77 78 |
# File 'lib/sdn/message/set.rb', line 76 def group_index @group_index end |
Instance Method Details
#class_inspect ⇒ String?
Returns the protocol-specific portion of the inspection string.
110 111 112 |
# File 'lib/sdn/message/set.rb', line 110 def class_inspect ", group_index=#{group_index.inspect}, group_address=#{group_address ? print_address(group_address) : "nil"}" end |
#params ⇒ <Integer>
Returns the protocol-specific payload bytes for this message.
105 106 107 |
# File 'lib/sdn/message/set.rb', line 105 def params transform_param(group_index - 1) + transform_param(group_address || [0, 0, 0]) end |
#parse(params) ⇒ void
This method returns an undefined value.
Parses protocol-specific parameter bytes into this message instance.
92 93 94 95 96 |
# File 'lib/sdn/message/set.rb', line 92 def parse(params) super self.group_index = to_number(params[0]) + 1 self.group_address = transform_param(params[1..3]) end |