Class: SDN::Message::PostGroupAddr

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

Overview

Response carrying a motor's group address for a specific slot.

Constant Summary collapse

MSG =

Protocol message number

0x61
PARAMS_LENGTH =

Number of protocol parameter bytes expected

4

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(group_index = nil, group_address = nil) ⇒ PostGroupAddr

Creates a group address response message.

Parameters:

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

    group slot number

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

    group address bytes



16
17
18
19
20
# File 'lib/sdn/message/post.rb', line 16

def initialize(group_index = nil, group_address = nil, **)
  super(**)
  self.group_index = group_index
  self.group_address = group_address
end

Instance Attribute Details

#group_address(Integer, Integer, Integer)?

Reported group address for the slot.

Returns:

  • ((Integer, Integer, Integer), nil)


30
31
32
# File 'lib/sdn/message/post.rb', line 30

def group_address
  @group_address
end

#group_indexInteger?

Reported group slot number.

Returns:

  • (Integer, nil)


25
26
27
# File 'lib/sdn/message/post.rb', line 25

def group_index
  @group_index
end

Instance Method Details

#class_inspectString?

Returns the protocol-specific portion of the inspection string.

Returns:

  • (String, nil)


46
47
48
# File 'lib/sdn/message/post.rb', line 46

def class_inspect
  ", group_index=#{group_index.inspect}, group_address=#{group_address ? print_address(group_address) : "nil"}"
end

#params<Integer>

Returns the protocol-specific payload bytes for this message.

Returns:

  • (<Integer>)


41
42
43
# File 'lib/sdn/message/post.rb', line 41

def params
  from_number(group_index - 1) + transform_param(group_address || [0, 0, 0])
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:



33
34
35
36
37
38
# File 'lib/sdn/message/post.rb', line 33

def parse(params)
  super
  self.group_index = to_number(params[0]) + 1
  self.group_address = transform_param(params[1..3])
  self.group_address = nil if [[0, 0, 0], [0x01, 0x01, 0xff]].include?(group_address)
end