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 }
TARGET =
{ down: 0x00, up: 0x01 }

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, #is_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.



148
149
150
151
152
153
154
# File 'lib/sdn/message/set.rb', line 148

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.



146
147
148
# File 'lib/sdn/message/set.rb', line 146

def target
  @target
end

#typeObject

Returns the value of attribute type.



146
147
148
# File 'lib/sdn/message/set.rb', line 146

def type
  @type
end

#valueObject

Returns the value of attribute value.



146
147
148
# File 'lib/sdn/message/set.rb', line 146

def value
  @value
end

Instance Method Details

#paramsObject



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

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



156
157
158
159
160
161
# File 'lib/sdn/message/set.rb', line 156

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