Class: SDN::Message::SetGroupAddr

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

Overview

Command that assigns a motor to a group slot.

Constant Summary collapse

MSG =

Protocol message number

0x51
PARAMS_LENGTH =

Number of protocol parameter bytes expected

4

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dest = nil, group_index = 1, group_address = nil, **kwargs) ⇒ SetGroupAddr

Creates a group assignment command.

Parameters:

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

    destination address

  • group_index (Integer) (defaults to: 1)

    group slot

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

    group address

  • kwargs (Hash)

    additional message options



84
85
86
87
88
89
# File 'lib/sdn/message/set.rb', line 84

def initialize(dest = nil, group_index = 1, group_address = nil, **kwargs)
  kwargs[:dest] ||= dest
  super(**kwargs)
  self.group_index = group_index
  self.group_address = group_address
end

Instance Attribute Details

#group_address(Integer, Integer, Integer)?

Returns:

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


69
70
71
# File 'lib/sdn/message/set.rb', line 69

def group_address
  @group_address
end

#group_indexInteger

Group slot to assign the address to in the range 1..16.

Returns:

  • (Integer)


76
77
78
# File 'lib/sdn/message/set.rb', line 76

def group_index
  @group_index
end

Instance Method Details

#class_inspectString?

Returns the protocol-specific portion of the inspection string.

Returns:

  • (String, nil)


110
111
112
# File 'lib/sdn/message/set.rb', line 110

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>)


105
106
107
# File 'lib/sdn/message/set.rb', line 105

def params
  transform_param(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:



92
93
94
95
96
# File 'lib/sdn/message/set.rb', line 92

def parse(params)
  super
  self.group_index = to_number(params[0]) + 1
  self.group_address = transform_param(params[1..3])
end