Class: SDN::Message::PostMotorLimits

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

Overview

Response carrying a motor's upper and lower travel limits.

Constant Summary collapse

MSG =

Protocol message number

0x31
PARAMS_LENGTH =

Number of protocol parameter bytes expected

4

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(up_limit = nil, down_limit = nil) ⇒ PostMotorLimits

Creates a motor limits response message.

Parameters:

  • up_limit (Integer, nil) (defaults to: nil)

    upper limit in pulses

  • down_limit (Integer, nil) (defaults to: nil)

    lower limit in pulses



133
134
135
136
137
# File 'lib/sdn/message/post.rb', line 133

def initialize(up_limit = nil, down_limit = nil, **)
  super(**)
  self.up_limit = up_limit
  self.down_limit = down_limit
end

Instance Attribute Details

#down_limitInteger?

Returns:

  • (Integer, nil)


127
128
129
# File 'lib/sdn/message/post.rb', line 127

def down_limit
  @down_limit
end

#up_limitInteger?

Returns:

  • (Integer, nil)


124
125
126
# File 'lib/sdn/message/post.rb', line 124

def up_limit
  @up_limit
end

Instance Method Details

#params<Integer>

Returns the protocol-specific payload bytes for this message.

Returns:

  • (<Integer>)


147
148
149
# File 'lib/sdn/message/post.rb', line 147

def params
  from_number(up_limit, 2) + from_number(down_limit, 2)
end

#parse(params) ⇒ void

This method returns an undefined value.

Parses protocol-specific parameter bytes into this message instance.

Parameters:

  • params (<Integer>)

    raw parameter bytes

Raises:



140
141
142
143
144
# File 'lib/sdn/message/post.rb', line 140

def parse(params)
  super
  self.up_limit = to_number(params[0..1], nillable: true)
  self.down_limit = to_number(params[2..3], nillable: true)
end