Class: SDN::Message::ILT2::SetLockStatus

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

Overview

Command that applies or clears an ILT2 lock target.

Constant Summary collapse

MSG =

Protocol message number

0x5B
PARAMS_LENGTH =

Number of protocol parameter bytes expected

3
TARGET_TYPE =

Mapping from symbolic lock targets to SDN parameter values.

{
  current: 0,
  up_limit: 1,
  down_limit: 2,
  ip: 4,
  unlock: 5
}.freeze

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, target_type = :unlock, target = nil, priority = 1, **kwargs) ⇒ SetLockStatus

Creates an ILT2 lock status write command.

Parameters:

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

    destination address

  • target_type (Symbol) (defaults to: :unlock)

    lock target selector

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

    target value

  • priority (Integer) (defaults to: 1)

    lock priority

  • kwargs (Hash)

    additional message options



58
59
60
61
62
63
64
# File 'lib/sdn/message/ilt2/set.rb', line 58

def initialize(dest = nil, target_type = :unlock, target = nil, priority = 1, **kwargs)
  kwargs[:dest] ||= dest
  super(**kwargs)
  self.target_type = target_type
  self.target = target
  self.priority = priority
end

Instance Attribute Details

#priorityInteger

Returns:

  • (Integer)


49
50
51
# File 'lib/sdn/message/ilt2/set.rb', line 49

def priority
  @priority
end

#targetInteger?

Returns:

  • (Integer, nil)


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

def target
  @target
end

#target_type:current, ...

when target_type is down_limit, target is number of 10ms intervals it's still allowed to roll up Requested ILT2 lock target selector.

Returns:

  • (:current, :up_limit, :down_limit, :ip, :unlock)


43
44
45
# File 'lib/sdn/message/ilt2/set.rb', line 43

def target_type
  @target_type
end

Instance Method Details

#params<Integer>

Returns the protocol-specific payload bytes for this message.

Returns:

  • (<Integer>)


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

def params
  transform_param(TARGET_TYPE[target_type]) + transform_param(target) + transform_param(priority)
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:



67
68
69
70
71
72
# File 'lib/sdn/message/ilt2/set.rb', line 67

def parse(params)
  super
  self.target_type = TARGET_TYPE.invert[to_number(params[0])]
  self.target = to_number(params[1])
  self.priority = to_number(params[2])
end