Class: SDN::Message::SetMotorDirection
- Inherits:
-
Message
- Object
- Message
- SDN::Message::SetMotorDirection
- Defined in:
- lib/sdn/message/set.rb
Overview
Command that sets a motor's rotation direction.
Constant Summary collapse
- MSG =
Protocol message number
0x12- PARAMS_LENGTH =
Number of protocol parameter bytes expected
1- DIRECTION =
Mapping from symbolic directions to SDN parameter values.
{ standard: 0x00, reversed: 0x01 }.freeze
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#initialize(dest = nil, direction = :standard, **kwargs) ⇒ SetMotorDirection
constructor
Creates a motor direction 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, direction = :standard, **kwargs) ⇒ SetMotorDirection
Creates a motor direction command.
134 135 136 137 138 |
# File 'lib/sdn/message/set.rb', line 134 def initialize(dest = nil, direction = :standard, **kwargs) kwargs[:dest] ||= dest super(**kwargs) self.direction = direction end |
Instance Attribute Details
#direction ⇒ :standard, :reversed
127 128 129 |
# File 'lib/sdn/message/set.rb', line 127 def direction @direction end |
Instance Method Details
#params ⇒ <Integer>
Returns the protocol-specific payload bytes for this message.
153 154 155 |
# File 'lib/sdn/message/set.rb', line 153 def params transform_param(DIRECTION[direction]) end |
#parse(params) ⇒ void
This method returns an undefined value.
Parses protocol-specific parameter bytes into this message instance.
141 142 143 144 |
# File 'lib/sdn/message/set.rb', line 141 def parse(params) super self.direction = DIRECTION.invert[to_number(params[0])] end |