Class: SDN::Message::SetMotorLimits

Inherits:
SDN::Message show all
Defined in:
lib/sdn/message/set.rb

Constant Summary collapse

MSG =
0x11
PARAMS_LENGTH =
4
TYPE =
{ delete: 0x00, current_position: 0x01, specified_position: 0x02, jog_ms: 0x04, jog_pulses: 0x05 }.freeze
TARGET =
{ down: 0x00, up: 0x01 }.freeze

Instance Attribute Summary collapse

Attributes inherited from SDN::Message

#ack_requested, #dest, #node_type, #src

Instance Method Summary collapse

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, type = :delete, target = :up, value = nil, **kwargs) ⇒ SetMotorLimits

Returns a new instance of SetMotorLimits.



168
169
170
171
172
173
174
# File 'lib/sdn/message/set.rb', line 168

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

#targetObject

Returns the value of attribute target.



166
167
168
# File 'lib/sdn/message/set.rb', line 166

def target
  @target
end

#typeObject

Returns the value of attribute type.



166
167
168
# File 'lib/sdn/message/set.rb', line 166

def type
  @type
end

#valueObject

Returns the value of attribute value.



166
167
168
# File 'lib/sdn/message/set.rb', line 166

def value
  @value
end

Instance Method Details

#paramsObject



202
203
204
205
206
# File 'lib/sdn/message/set.rb', line 202

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) ⇒ Object



176
177
178
179
180
181
# File 'lib/sdn/message/set.rb', line 176

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