Class: BWA::Messages::ToggleItem
Constant Summary
collapse
- MESSAGE_TYPE =
"\xbf\x11".b
- MESSAGE_LENGTH =
2
- ITEMS =
{
normal_operation: 0x01,
clear_notification: 0x03,
pump1: 0x04,
pump2: 0x05,
pump3: 0x06,
pump4: 0x07,
pump5: 0x08,
pump6: 0x09,
blower: 0x0c,
mister: 0x0e,
light1: 0x11,
light2: 0x12,
aux1: 0x16,
aux2: 0x17,
soak: 0x1d,
hold: 0x3c,
temperature_range: 0x50,
heating_mode: 0x51
}.freeze
Instance Attribute Summary collapse
Attributes inherited from BWA::Message
#raw_data, #src
Instance Method Summary
collapse
format_duration, format_time, inherited, parse
Constructor Details
#initialize(item = nil) ⇒ ToggleItem
Returns a new instance of ToggleItem.
31
32
33
34
|
# File 'lib/bwa/messages/toggle_item.rb', line 31
def initialize(item = nil)
super()
self.item = item
end
|
Instance Attribute Details
#item ⇒ Object
Returns the value of attribute item.
29
30
31
|
# File 'lib/bwa/messages/toggle_item.rb', line 29
def item
@item
end
|
Instance Method Details
#inspect ⇒ Object
59
60
61
|
# File 'lib/bwa/messages/toggle_item.rb', line 59
def inspect
"#<BWA::Messages::ToggleItem #{item}>"
end
|
#log? ⇒ Boolean
36
37
38
39
40
41
42
43
|
# File 'lib/bwa/messages/toggle_item.rb', line 36
def log?
return true if BWA.verbosity >= 2
return false if item == 0
true
end
|
#parse(data) ⇒ Object
45
46
47
|
# File 'lib/bwa/messages/toggle_item.rb', line 45
def parse(data)
self.item = ITEMS.invert[data[0].ord] || data[0].ord
end
|
#serialize ⇒ Object
49
50
51
52
53
54
55
56
57
|
# File 'lib/bwa/messages/toggle_item.rb', line 49
def serialize
data = +"\x00\x00"
data[0] = if item.is_a?(Integer)
item.chr
else
ITEMS[item].chr
end
super(data)
end
|