Class: TimexDatalinkClient::Protocol6::PagerOptions

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations, Helpers::CrcPacketsWrapper
Defined in:
lib/timex_datalink_client/protocol_6/pager_options.rb

Constant Summary collapse

CPACKET_PAGER =
0x73
ALERT_SOUND_SILENT =
6

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(auto_on_off: false, on_hour: 0, on_minute: 0, off_hour: 0, off_minute: 0, alert_sound: 0) ⇒ PagerOptions

Create a PagerOptions instance.

Parameters:

  • auto_on_off (Boolean) (defaults to: false)

    Toggle turning pager on and off every day.

  • on_hour (Integer) (defaults to: 0)

    Hour to turn pager on at.

  • on_minute (Integer) (defaults to: 0)

    Minute to turn pager on at.

  • off_hour (Integer) (defaults to: 0)

    Hour to turn pager off at.

  • off_minute (Integer) (defaults to: 0)

    Minute to turn pager off at.

  • alert_sound (Integer, nil) (defaults to: 0)

    Pager alert sound (0 to 5 or nil for silent).



51
52
53
54
55
56
57
58
# File 'lib/timex_datalink_client/protocol_6/pager_options.rb', line 51

def initialize(auto_on_off: false, on_hour: 0, on_minute: 0, off_hour: 0, off_minute: 0, alert_sound: 0)
  @auto_on_off = auto_on_off
  @on_hour = on_hour
  @on_minute = on_minute
  @off_hour = off_hour
  @off_minute = off_minute
  @alert_sound = alert_sound
end

Instance Attribute Details

#alert_soundObject

Returns the value of attribute alert_sound.



40
41
42
# File 'lib/timex_datalink_client/protocol_6/pager_options.rb', line 40

def alert_sound
  @alert_sound
end

#auto_on_offObject

Returns the value of attribute auto_on_off.



40
41
42
# File 'lib/timex_datalink_client/protocol_6/pager_options.rb', line 40

def auto_on_off
  @auto_on_off
end

#off_hourObject

Returns the value of attribute off_hour.



40
41
42
# File 'lib/timex_datalink_client/protocol_6/pager_options.rb', line 40

def off_hour
  @off_hour
end

#off_minuteObject

Returns the value of attribute off_minute.



40
41
42
# File 'lib/timex_datalink_client/protocol_6/pager_options.rb', line 40

def off_minute
  @off_minute
end

#on_hourObject

Returns the value of attribute on_hour.



40
41
42
# File 'lib/timex_datalink_client/protocol_6/pager_options.rb', line 40

def on_hour
  @on_hour
end

#on_minuteObject

Returns the value of attribute on_minute.



40
41
42
# File 'lib/timex_datalink_client/protocol_6/pager_options.rb', line 40

def on_minute
  @on_minute
end

Instance Method Details

#alert_sound_formattedObject



84
85
86
# File 'lib/timex_datalink_client/protocol_6/pager_options.rb', line 84

def alert_sound_formatted
  alert_sound || ALERT_SOUND_SILENT
end

#auto_on_off_formattedObject



80
81
82
# File 'lib/timex_datalink_client/protocol_6/pager_options.rb', line 80

def auto_on_off_formatted
  auto_on_off ? 1 : 0
end

#packetsArray<Array<Integer>>

Compile packets for pager options.

Returns:

  • (Array<Array<Integer>>)

    Two-dimensional array of integers that represent bytes.

Raises:

  • (ActiveModel::ValidationError)

    One or more model values are invalid.



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/timex_datalink_client/protocol_6/pager_options.rb', line 64

def packets
  validate!

  [
    [
      CPACKET_PAGER,
      auto_on_off_formatted,
      on_hour,
      on_minute,
      off_hour,
      off_minute,
      alert_sound_formatted
    ]
  ]
end