Class: SDN::Message::ILT2::MasterControl

Inherits:
Object
  • Object
show all
Extended by:
Helpers
Defined in:
lib/sdn/message/ilt2/master_control.rb

Direct Known Subclasses

Down, Stop, Up

Defined Under Namespace

Classes: Down, Stop, Up

Class Method Summary collapse

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

Class Method Details

.parse(data) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/sdn/message/ilt2/master_control.rb', line 10

def parse(data)
  return unless data.length >= 5
  return unless checksum(data[0..2]) == data[3..4]
  # no clue what's special about these
  return unless data[0..1] == [0xfa, 0x7a]

  klass = case data[2]
          when 0x00 then Down
          when 0xfa then Up
          when 0xff then Stop
          end
  return unless klass

  [klass.new, 5]
end