Class: SDN::Message::MoveOf
- Inherits:
-
SDN::Message
- Object
- SDN::Message
- SDN::Message::MoveOf
- Defined in:
- lib/sdn/message/control.rb
Overview
Move relative to current position
Constant Summary collapse
- MSG =
0x04- PARAMS_LENGTH =
4- TARGET_TYPE =
{ next_ip: 0x00, previous_ip: 0x01, jog_down_pulses: 0x02, jog_up_pulses: 0x03, jog_down_ms: 0x04, jog_up_ms: 0x05 }.freeze
Instance Attribute Summary collapse
-
#target ⇒ Object
Returns the value of attribute target.
-
#target_type ⇒ Object
Returns the value of attribute target_type.
Attributes inherited from SDN::Message
#ack_requested, #dest, #node_type, #src
Instance Method Summary collapse
-
#initialize(dest = nil, target_type = nil, target = nil, **kwargs) ⇒ MoveOf
constructor
A new instance of MoveOf.
- #params ⇒ Object
- #parse(params) ⇒ Object
Methods inherited from SDN::Message
#==, #class_inspect, expected_response?, inherited, #inspect, parse, #serialize
Methods included from Helpers
#checksum, #from_number, #from_string, #group_address?, #node_type_from_number, #node_type_to_number, #node_type_to_string, #parse_address, #print_address, #to_number, #to_string, #transform_param
Constructor Details
#initialize(dest = nil, target_type = nil, target = nil, **kwargs) ⇒ MoveOf
Returns a new instance of MoveOf.
121 122 123 124 125 126 |
# File 'lib/sdn/message/control.rb', line 121 def initialize(dest = nil, target_type = nil, target = nil, **kwargs) kwargs[:dest] ||= dest super(**kwargs) self.target_type = target_type self.target = target end |
Instance Attribute Details
#target ⇒ Object
Returns the value of attribute target.
119 120 121 |
# File 'lib/sdn/message/control.rb', line 119 def target @target end |
#target_type ⇒ Object
Returns the value of attribute target_type.
119 120 121 |
# File 'lib/sdn/message/control.rb', line 119 def target_type @target_type end |
Instance Method Details
#params ⇒ Object
150 151 152 153 154 |
# File 'lib/sdn/message/control.rb', line 150 def params param = target || 0xffff param /= 10 if %I[jog_down_ms jog_up_ms].include?(target_type) transform_param(TARGET_TYPE[target_type]) + from_number(param, 2) + transform_param(0) end |
#parse(params) ⇒ Object
128 129 130 131 132 133 134 |
# File 'lib/sdn/message/control.rb', line 128 def parse(params) super self.target_type = TARGET_TYPE.invert[to_number(params[0])] target = to_number(params[1..2], nillable: true) target *= 10 if %I[jog_down_ms jog_up_ms].include?(target_type) self.target = target end |