Class: SDN::Message::SetMotorLimits
- Inherits:
-
Message
- Object
- Message
- SDN::Message::SetMotorLimits
- Defined in:
- lib/sdn/message/set.rb
Overview
Command that modifies a motor's travel limits.
Constant Summary collapse
- MSG =
Protocol message number
0x11- PARAMS_LENGTH =
Number of protocol parameter bytes expected
4- TYPE =
Mapping from symbolic limit write modes to SDN parameter values.
{ delete: 0x00, current_position: 0x01, specified_position: 0x02, jog_ms: 0x04, jog_pulses: 0x05 }.freeze
- TARGET =
Mapping from symbolic limit targets to SDN parameter values.
{ down: 0x00, up: 0x01 }.freeze
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#initialize(dest = nil, type = :delete, target = :up, value = nil, **kwargs) ⇒ SetMotorLimits
constructor
Creates a limit write 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, type = :delete, target = :up, value = nil, **kwargs) ⇒ SetMotorLimits
Creates a limit write command.
274 275 276 277 278 279 280 |
# File 'lib/sdn/message/set.rb', line 274 def initialize(dest = nil, type = :delete, target = :up, value = nil, **kwargs) kwargs[:dest] ||= dest super(**kwargs) self.type = type self.target = target self.value = value end |
Instance Attribute Details
#target ⇒ :up, :down
260 261 262 |
# File 'lib/sdn/message/set.rb', line 260 def target @target end |
#type ⇒ :delete, ...
255 256 257 |
# File 'lib/sdn/message/set.rb', line 255 def type @type end |
#value ⇒ Integer?
265 266 267 |
# File 'lib/sdn/message/set.rb', line 265 def value @value end |
Instance Method Details
#params ⇒ <Integer>
Returns the protocol-specific payload bytes for this message.
310 311 312 313 314 |
# File 'lib/sdn/message/set.rb', line 310 def params param = value || 0 param /= 10 if target == :jog_ms transform_param(TYPE[type]) + transform_param(TARGET[target]) + from_number(param, 2) end |
#parse(params) ⇒ void
This method returns an undefined value.
Parses protocol-specific parameter bytes into this message instance.
283 284 285 286 287 288 |
# File 'lib/sdn/message/set.rb', line 283 def parse(params) super self.type = TYPE.invert[to_number(params[0])] self.target = TARGET.invert[to_number(params[1])] self.value = to_number(params[2..3]) end |