Class: SDN::Message::SetMotorLimits

Inherits:
SDN::Message show all
Defined in:
lib/sdn/messages/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, #reserved, #src

Instance Method Summary collapse

Methods inherited from SDN::Message

#class_inspect, #inspect, parse, readpartial, #serialize

Methods included from Helpers

#checksum, #from_number, #from_string, #is_group_address?, #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.



11
12
13
14
15
16
17
# File 'lib/sdn/messages/set.rb', line 11

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.



9
10
11
# File 'lib/sdn/messages/set.rb', line 9

def target
  @target
end

#typeObject

Returns the value of attribute type.



9
10
11
# File 'lib/sdn/messages/set.rb', line 9

def type
  @type
end

#valueObject

Returns the value of attribute value.



9
10
11
# File 'lib/sdn/messages/set.rb', line 9

def value
  @value
end

Instance Method Details

#paramsObject



40
41
42
43
44
# File 'lib/sdn/messages/set.rb', line 40

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



19
20
21
22
23
24
# File 'lib/sdn/messages/set.rb', line 19

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