Class: TimexDatalinkClient::Protocol6::Alarm
- Inherits:
-
Object
- Object
- TimexDatalinkClient::Protocol6::Alarm
- Includes:
- ActiveModel::Validations, Helpers::CharEncoders, Helpers::CrcPacketsWrapper
- Defined in:
- lib/timex_datalink_client/protocol_6/alarm.rb
Constant Summary collapse
- CPACKET_ALARM =
0x51
- VALID_DAYS_IN_MONTH =
{ 1 => 1..31, 2 => 1..29, 3 => 1..31, 4 => 1..30, 5 => 1..31, 6 => 1..30, 7 => 1..31, 8 => 1..31, 9 => 1..30, 10 => 1..31, 11 => 1..30, 12 => 1..31 }.freeze
- ALARM_STATUS_MAP =
{ disarmed: 0, armed: 1, unused: 2 }.freeze
- DEFAULT_TIME =
Time.new(0, 1, 1, 6, 0)
Constants included from Helpers::CharEncoders
Helpers::CharEncoders::CHARS, Helpers::CharEncoders::CHARS_PROTOCOL_6, Helpers::CharEncoders::EEPROM_CHARS, Helpers::CharEncoders::EEPROM_TERMINATOR, Helpers::CharEncoders::INVALID_CHAR, Helpers::CharEncoders::PHONE_CHARS
Instance Attribute Summary collapse
-
#day ⇒ Object
Returns the value of attribute day.
-
#message ⇒ Object
Returns the value of attribute message.
-
#month ⇒ Object
Returns the value of attribute month.
-
#number ⇒ Object
Returns the value of attribute number.
-
#status ⇒ Object
Returns the value of attribute status.
-
#time ⇒ Object
Returns the value of attribute time.
Instance Method Summary collapse
-
#initialize(number:, status:, time: DEFAULT_TIME, message: "", month: nil, day: nil) ⇒ Alarm
constructor
Create an Alarm instance.
-
#packets ⇒ Array<Array<Integer>>
Compile packets for an alarm.
Methods included from Helpers::CharEncoders
#chars_for, #eeprom_chars_for, #phone_chars_for, #protocol_6_chars_for
Constructor Details
#initialize(number:, status:, time: DEFAULT_TIME, message: "", month: nil, day: nil) ⇒ Alarm
Create an Alarm instance.
83 84 85 86 87 88 89 90 |
# File 'lib/timex_datalink_client/protocol_6/alarm.rb', line 83 def initialize(number:, status:, time: DEFAULT_TIME, message: "", month: nil, day: nil) @number = number @status = status @time = time @message = @month = month @day = day end |
Instance Attribute Details
#day ⇒ Object
Returns the value of attribute day.
40 41 42 |
# File 'lib/timex_datalink_client/protocol_6/alarm.rb', line 40 def day @day end |
#message ⇒ Object
Returns the value of attribute message.
40 41 42 |
# File 'lib/timex_datalink_client/protocol_6/alarm.rb', line 40 def @message end |
#month ⇒ Object
Returns the value of attribute month.
40 41 42 |
# File 'lib/timex_datalink_client/protocol_6/alarm.rb', line 40 def month @month end |
#number ⇒ Object
Returns the value of attribute number.
40 41 42 |
# File 'lib/timex_datalink_client/protocol_6/alarm.rb', line 40 def number @number end |
#status ⇒ Object
Returns the value of attribute status.
40 41 42 |
# File 'lib/timex_datalink_client/protocol_6/alarm.rb', line 40 def status @status end |
#time ⇒ Object
Returns the value of attribute time.
40 41 42 |
# File 'lib/timex_datalink_client/protocol_6/alarm.rb', line 40 def time @time end |
Instance Method Details
#packets ⇒ Array<Array<Integer>>
Compile packets for an alarm.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/timex_datalink_client/protocol_6/alarm.rb', line 96 def packets validate! [ [ CPACKET_ALARM, number, time.hour, time.min, month.to_i, day.to_i, status_formatted, , ].flatten ] end |