Class: SDN::Message::ILT2::SetMotorIP

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

Overview

Command that writes an ILT2 intermediate position slot.

Constant Summary collapse

MSG =

Protocol message number

0x53
PARAMS_LENGTH =

Number of protocol parameter bytes expected

3

Instance Attribute Summary collapse

Attributes inherited from SDN::Message

#ack_requested, #dest, #node_type, #src

Instance Method Summary collapse

Methods inherited from SDN::Message

#==, expected_response?, #inspect, parse, #serialize

Methods included from Helpers

#checksum, #from_number, #from_string, #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(dest = nil, ip = 1, value = nil, **kwargs) ⇒ SetMotorIP

Creates an ILT2 intermediate position write command.

Parameters:

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

    destination address

  • ip (Integer) (defaults to: 1)

    intermediate position slot

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

    stored value

  • kwargs (Hash)

    additional message options



122
123
124
125
126
127
# File 'lib/sdn/message/ilt2/set.rb', line 122

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

Instance Attribute Details

#ipInteger?

Requested ILT2 intermediate position slot in the range 1..16.

Returns:

  • (Integer, nil)


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

def ip
  @ip
end

#valueInteger?

Returns:

  • (Integer, nil)


114
115
116
# File 'lib/sdn/message/ilt2/set.rb', line 114

def value
  @value
end

Instance Method Details

#params<Integer>

Returns the protocol-specific payload bytes for this message.

Returns:

  • (<Integer>)


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

def params
  transform_param(ip - 1) + from_number(value, 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:



130
131
132
133
134
# File 'lib/sdn/message/ilt2/set.rb', line 130

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