Class: SDN::Message::PostMotorPosition

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

Constant Summary collapse

MSG =
0x0d
PARAMS_LENGTH =
5

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(position_pulses = nil, position_percent = nil, ip = nil, **kwargs) ⇒ PostMotorPosition

Returns a new instance of PostMotorPosition.



98
99
100
101
102
103
# File 'lib/sdn/message/post.rb', line 98

def initialize(position_pulses = nil, position_percent = nil, ip = nil, **kwargs)
  super(**kwargs)
  self.position_pulses = position_pulses
  self.position_percent = position_percent
  self.ip = ip
end

Instance Attribute Details

#ipObject

Returns the value of attribute ip.



96
97
98
# File 'lib/sdn/message/post.rb', line 96

def ip
  @ip
end

#position_percentObject

Returns the value of attribute position_percent.



96
97
98
# File 'lib/sdn/message/post.rb', line 96

def position_percent
  @position_percent
end

#position_pulsesObject

Returns the value of attribute position_pulses.



96
97
98
# File 'lib/sdn/message/post.rb', line 96

def position_pulses
  @position_pulses
end

Instance Method Details

#paramsObject



112
113
114
# File 'lib/sdn/message/post.rb', line 112

def params
  from_number(position_pulses, 2) + from_number(position_percent) + from_number(ip)
end

#parse(params) ⇒ Object



105
106
107
108
109
110
# File 'lib/sdn/message/post.rb', line 105

def parse(params)
  super
  self.position_pulses = to_number(params[0..1], nillable: true)
  self.position_percent = to_number(params[2], nillable: true)
  self.ip = to_number(params[4], nillable: true)
end