Class: TimexDatalinkClient::Protocol9::Timer

Inherits:
Object
  • Object
show all
Includes:
Helpers::CharEncoders, Helpers::CrcPacketsWrapper
Defined in:
lib/timex_datalink_client/protocol_9/timer.rb

Constant Summary collapse

CPACKET_TIMER =
[0x43]

Constants included from Helpers::CharEncoders

Helpers::CharEncoders::CHARS, Helpers::CharEncoders::EEPROM_CHARS, Helpers::CharEncoders::EEPROM_TERMINATOR, Helpers::CharEncoders::INVALID_CHAR, Helpers::CharEncoders::PHONE_CHARS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers::CharEncoders

#chars_for, #eeprom_chars_for, #phone_chars_for

Constructor Details

#initialize(number:, label:, time:, action_at_end:) ⇒ Timer

Create a Timer instance.

Parameters:

  • number (Integer)

    Entry number for timer.

  • label (String)

    Label for timer.

  • time (Time)

    Time of timer.

  • action_at_end (Integer)

    Action at end of timer.



23
24
25
26
27
28
# File 'lib/timex_datalink_client/protocol_9/timer.rb', line 23

def initialize(number:, label:, time:, action_at_end:)
  @number = number
  @label = label
  @time = time
  @action_at_end = action_at_end
end

Instance Attribute Details

#action_at_endObject

Returns the value of attribute action_at_end.



14
15
16
# File 'lib/timex_datalink_client/protocol_9/timer.rb', line 14

def action_at_end
  @action_at_end
end

#labelObject

Returns the value of attribute label.



14
15
16
# File 'lib/timex_datalink_client/protocol_9/timer.rb', line 14

def label
  @label
end

#numberObject

Returns the value of attribute number.



14
15
16
# File 'lib/timex_datalink_client/protocol_9/timer.rb', line 14

def number
  @number
end

#timeObject

Returns the value of attribute time.



14
15
16
# File 'lib/timex_datalink_client/protocol_9/timer.rb', line 14

def time
  @time
end

Instance Method Details

#packetsArray<Array<Integer>>

Compile packets for a timer.

Returns:

  • (Array<Array<Integer>>)

    Two-dimensional array of integers that represent bytes.



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/timex_datalink_client/protocol_9/timer.rb', line 33

def packets
  [
    [
      CPACKET_TIMER,
      number,
      time.hour,
      time.min,
      time.sec,
      action_at_end,
      label_characters
    ].flatten
  ]
end