Class AlarmClock

java.lang.Object
org.episteme.social.history.clock.Clock
org.episteme.social.history.clock.AlarmClock
All Implemented Interfaces:
Serializable, EventListener, TimeListener

public abstract class AlarmClock extends Clock
An abstract alarm clock that triggers an action when a specified target time is reached. Monitors standard ModernTime updates from a TimeServer.
Since:
1.0
Version:
1.1
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
See Also:
  • Constructor Details

    • AlarmClock

      protected AlarmClock(TimeServer timeServer)
      Creates a new AlarmClock associated with a time server.
      Parameters:
      timeServer - the time server to monitor
  • Method Details

    • start

      public void start()
      Starts the underlying time server updates.
    • stop

      public void stop()
      Stops the underlying time server updates.
    • getAlarmTime

      public ModernTime getAlarmTime()
      Returns the target alarm time.
      Returns:
      alarm time
    • setAlarmTime

      public void setAlarmTime(ModernTime alarmTime)
      Sets the target alarm time. Resets the triggered flag.
      Parameters:
      alarmTime - the target time
    • getTime

      public ModernTime getTime()
      Returns the current time held by the clock.
      Specified by:
      getTime in class Clock
      Returns:
      current time
    • setTime

      public void setTime(ModernTime time)
      Updates the internal clock time.
      Parameters:
      time - the new time state
      Throws:
      NullPointerException - if time is null
    • timeChanged

      public void timeChanged(TimeEvent event)
      Description copied from interface: TimeListener
      Invoked when a time change occurs on the monitored TimeServer.
      Parameters:
      event - the event containing the new time state
    • fireAlarm

      public abstract void fireAlarm()
      Hook method called when the alarm condition is met.
    • setTolerance

      public void setTolerance(double seconds)
      Sets the firing tolerance.
      Parameters:
      seconds - tolerance in seconds