Class: BWA::Messages::ControlConfiguration2

Inherits:
BWA::Message show all
Defined in:
lib/bwa/messages/control_configuration.rb

Constant Summary collapse

MESSAGE_TYPE =
"\xbf\x2e".b
MESSAGE_LENGTH =
6

Instance Attribute Summary collapse

Attributes inherited from BWA::Message

#raw_data, #src

Instance Method Summary collapse

Methods inherited from BWA::Message

format_duration, format_time, inherited, #log?, parse, #serialize

Constructor Details

#initializeControlConfiguration2

Returns a new instance of ControlConfiguration2.



33
34
35
36
37
38
39
40
41
42
# File 'lib/bwa/messages/control_configuration.rb', line 33

def initialize
  super

  self.pumps = Array.new(6, 0)
  self.lights = Array.new(2, false)
  self.circulation_pump = false
  self.blower = 0
  self.mister = false
  self.aux = Array.new(2, false)
end

Instance Attribute Details

#auxObject

Returns the value of attribute aux.



31
32
33
# File 'lib/bwa/messages/control_configuration.rb', line 31

def aux
  @aux
end

#blowerObject

Returns the value of attribute blower.



31
32
33
# File 'lib/bwa/messages/control_configuration.rb', line 31

def blower
  @blower
end

#circulation_pumpObject

Returns the value of attribute circulation_pump.



31
32
33
# File 'lib/bwa/messages/control_configuration.rb', line 31

def circulation_pump
  @circulation_pump
end

#lightsObject

Returns the value of attribute lights.



31
32
33
# File 'lib/bwa/messages/control_configuration.rb', line 31

def lights
  @lights
end

#misterObject

Returns the value of attribute mister.



31
32
33
# File 'lib/bwa/messages/control_configuration.rb', line 31

def mister
  @mister
end

#pumpsObject

Returns the value of attribute pumps.



31
32
33
# File 'lib/bwa/messages/control_configuration.rb', line 31

def pumps
  @pumps
end

Instance Method Details

#inspectObject



65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/bwa/messages/control_configuration.rb', line 65

def inspect
  items = []

  items << "pumps=#{pumps.inspect}"
  items << "lights=#{lights.inspect}"
  items << "circulation_pump" if circulation_pump
  items << "blower=#{blower}" if blower != 0
  items << "mister" if mister
  items << "aux=#{aux.inspect}"

  "#<BWA::Messages::ControlConfiguration2 #{items.join(" ")}>"
end

#parse(data) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/bwa/messages/control_configuration.rb', line 44

def parse(data)
  flags = data[0].ord
  pumps[0] = flags & 0x03
  pumps[1] = (flags >> 2) & 0x03
  pumps[2] = (flags >> 4) & 0x03
  pumps[3] = (flags >> 6) & 0x03
  flags = data[1].ord
  pumps[4] = flags & 0x03
  pumps[5] = (flags >> 6) & 0x03
  flags = data[2].ord
  lights[0] = (flags & 0x03 != 0)
  lights[1] = ((flags >> 6) & 0x03 != 0)
  flags = data[3].ord
  self.blower = flags & 0x03
  self.circulation_pump = ((flags >> 6) & 0x03 != 0)
  flags = data[4].ord
  self.mister = (flags & 0x30 != 0)
  aux[0] = (flags & 0x01 != 0)
  aux[1] = (flags & 0x02 != 0)
end