Class: SDN::Message::PostMotorPosition
- Inherits:
-
Message
- Object
- Message
- SDN::Message::PostMotorPosition
- Defined in:
- lib/sdn/message/post.rb
Overview
Response carrying a motor's current position and active intermediate position.
Constant Summary collapse
- MSG =
Protocol message number
0x0d- PARAMS_LENGTH =
Number of protocol parameter bytes expected
5
Instance Attribute Summary collapse
-
#ip ⇒ Integer?
Reported active intermediate position slot.
- #position_percent ⇒ Integer?
- #position_pulses ⇒ Integer?
Instance Method Summary collapse
-
#initialize(position_pulses = nil, position_percent = nil, ip = nil) ⇒ PostMotorPosition
constructor
Creates a motor position response message.
-
#params ⇒ <Integer>
Returns the protocol-specific payload bytes for this message.
-
#parse(params) ⇒ void
Parses protocol-specific parameter bytes into this message instance.
Constructor Details
#initialize(position_pulses = nil, position_percent = nil, ip = nil) ⇒ PostMotorPosition
Creates a motor position response message.
175 176 177 178 179 180 |
# File 'lib/sdn/message/post.rb', line 175 def initialize(position_pulses = nil, position_percent = nil, ip = nil, **) super(**) self.position_pulses = position_pulses self.position_percent = position_percent self.ip = ip end |
Instance Attribute Details
#ip ⇒ Integer?
Reported active intermediate position slot.
168 169 170 |
# File 'lib/sdn/message/post.rb', line 168 def ip @ip end |
#position_percent ⇒ Integer?
163 164 165 |
# File 'lib/sdn/message/post.rb', line 163 def position_percent @position_percent end |
#position_pulses ⇒ Integer?
160 161 162 |
# File 'lib/sdn/message/post.rb', line 160 def position_pulses @position_pulses end |
Instance Method Details
#params ⇒ <Integer>
Returns the protocol-specific payload bytes for this message.
191 192 193 |
# File 'lib/sdn/message/post.rb', line 191 def params from_number(position_pulses, 2) + from_number(position_percent) + from_number(0) + from_number(ip) end |
#parse(params) ⇒ void
This method returns an undefined value.
Parses protocol-specific parameter bytes into this message instance.
183 184 185 186 187 188 |
# File 'lib/sdn/message/post.rb', line 183 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 |