Class: SDN::Message::Lock
- Inherits:
-
SDN::Message
- Object
- SDN::Message
- SDN::Message::Lock
- Defined in:
- lib/sdn/message/control.rb
Constant Summary collapse
- MSG =
0x06- PARAMS_LENGTH =
5- TARGET_TYPE =
{ current: 0, up_limit: 1, down_limit: 2, ip: 4, unlock: 5, position_percent: 7 }.freeze
Instance Attribute Summary collapse
-
#priority ⇒ Object
Returns the value of attribute priority.
-
#target ⇒ Object
Returns the value of attribute target.
-
#target_type ⇒ Object
Returns the value of attribute target_type.
Attributes inherited from SDN::Message
#ack_requested, #dest, #node_type, #src
Instance Method Summary collapse
-
#initialize(dest = nil, target_type = :unlock, target = nil, priority = 1, **kwargs) ⇒ Lock
constructor
A new instance of Lock.
- #params ⇒ Object
- #parse(params) ⇒ Object
Methods inherited from SDN::Message
#==, #class_inspect, expected_response?, inherited, #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) ⇒ Lock
Returns a new instance of Lock.
12 13 14 15 16 17 18 |
# File 'lib/sdn/message/control.rb', line 12 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
#priority ⇒ Object
Returns the value of attribute priority.
10 11 12 |
# File 'lib/sdn/message/control.rb', line 10 def priority @priority end |
#target ⇒ Object
Returns the value of attribute target.
10 11 12 |
# File 'lib/sdn/message/control.rb', line 10 def target @target end |
#target_type ⇒ Object
Returns the value of attribute target_type.
10 11 12 |
# File 'lib/sdn/message/control.rb', line 10 def target_type @target_type end |
Instance Method Details
#params ⇒ Object
45 46 47 48 |
# File 'lib/sdn/message/control.rb', line 45 def params transform_param(TARGET_TYPE[target_type]) + from_number(target, 2) + transform_param(priority) + transform_param(0) end |
#parse(params) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/sdn/message/control.rb', line 37 def parse(params) super self.target_type = TARGET_TYPE.invert[to_number(params[0])] target = to_number(params[1..2], nillable: true) self.target = target self.priority = to_number(params[3]) end |