Class: BWA::Messages::FilterCycles
- Inherits:
-
BWA::Message
- Object
- BWA::Message
- BWA::Messages::FilterCycles
- Defined in:
- lib/bwa/messages/filter_cycles.rb
Constant Summary collapse
- MESSAGE_TYPE =
"\xbf\x23".b
- MESSAGE_LENGTH =
8
Instance Attribute Summary collapse
-
#cycle1_duration ⇒ Object
Returns the value of attribute cycle1_duration.
-
#cycle1_start_hour ⇒ Object
Returns the value of attribute cycle1_start_hour.
-
#cycle1_start_minute ⇒ Object
Returns the value of attribute cycle1_start_minute.
-
#cycle2_duration ⇒ Object
Returns the value of attribute cycle2_duration.
-
#cycle2_enabled ⇒ Object
(also: #cycle2_enabled?)
Returns the value of attribute cycle2_enabled.
-
#cycle2_start_hour ⇒ Object
Returns the value of attribute cycle2_start_hour.
-
#cycle2_start_minute ⇒ Object
Returns the value of attribute cycle2_start_minute.
Attributes inherited from BWA::Message
Instance Method Summary collapse
Methods inherited from BWA::Message
format_duration, format_time, inherited, #initialize, #log?, parse
Constructor Details
This class inherits a constructor from BWA::Message
Instance Attribute Details
#cycle1_duration ⇒ Object
Returns the value of attribute cycle1_duration.
6 7 8 |
# File 'lib/bwa/messages/filter_cycles.rb', line 6 def cycle1_duration @cycle1_duration end |
#cycle1_start_hour ⇒ Object
Returns the value of attribute cycle1_start_hour.
6 7 8 |
# File 'lib/bwa/messages/filter_cycles.rb', line 6 def cycle1_start_hour @cycle1_start_hour end |
#cycle1_start_minute ⇒ Object
Returns the value of attribute cycle1_start_minute.
6 7 8 |
# File 'lib/bwa/messages/filter_cycles.rb', line 6 def cycle1_start_minute @cycle1_start_minute end |
#cycle2_duration ⇒ Object
Returns the value of attribute cycle2_duration.
6 7 8 |
# File 'lib/bwa/messages/filter_cycles.rb', line 6 def cycle2_duration @cycle2_duration end |
#cycle2_enabled ⇒ Object Also known as: cycle2_enabled?
Returns the value of attribute cycle2_enabled.
6 7 8 |
# File 'lib/bwa/messages/filter_cycles.rb', line 6 def cycle2_enabled @cycle2_enabled end |
#cycle2_start_hour ⇒ Object
Returns the value of attribute cycle2_start_hour.
6 7 8 |
# File 'lib/bwa/messages/filter_cycles.rb', line 6 def cycle2_start_hour @cycle2_start_hour end |
#cycle2_start_minute ⇒ Object
Returns the value of attribute cycle2_start_minute.
6 7 8 |
# File 'lib/bwa/messages/filter_cycles.rb', line 6 def cycle2_start_minute @cycle2_start_minute end |
Instance Method Details
#inspect ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/bwa/messages/filter_cycles.rb', line 58 def inspect result = +"#<BWA::Messages::FilterCycles " result << "cycle1 " result << self.class.format_duration(cycle1_duration) result << "@" result << self.class.format_time(cycle1_start_hour, cycle1_start_minute) result << " cycle2(#{@cycle2_enabled ? "enabled" : "disabled"}) " result << self.class.format_duration(cycle2_duration) result << "@" result << self.class.format_time(cycle2_start_hour, cycle2_start_minute) result << ">" end |
#parse(data) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/bwa/messages/filter_cycles.rb', line 18 def parse(data) self.cycle1_start_hour = data[0].ord self.cycle1_start_minute = data[1].ord hours = data[2].ord minutes = data[3].ord self.cycle1_duration = (hours * 60) + minutes c2_hour = data[4].ord self.cycle2_enabled = !!(c2_hour & 0x80 == 0x80) self.cycle2_start_hour = c2_hour & 0x7f self.cycle2_start_minute = data[5].ord hours = data[6].ord minutes = data[7].ord self.cycle2_duration = (hours * 60) + minutes end |
#serialize ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/bwa/messages/filter_cycles.rb', line 34 def serialize data = cycle1_start_hour.chr data += cycle1_start_minute.chr data += (cycle1_duration / 60).chr data += (cycle1_duration % 60).chr # The cycle2 start hour is merged with the cycle2 enable. # The high order bit of the byte is a flag to indicate this so we have # to do a bit of different processing to set that. # Get the filter 2 start hour start_hour = cycle2_start_hour # Check to see if we want filter 2 enabled (either because it changed or from the current configuration) start_hour |= 0x80 if cycle2_enabled data += start_hour.chr data += cycle2_start_minute.chr data += (cycle2_duration / 60).chr data += (cycle2_duration % 60).chr super(data) end |