Class AlarmClock
java.lang.Object
org.episteme.social.history.clock.Clock
org.episteme.social.history.clock.AlarmClock
- All Implemented Interfaces:
Serializable, EventListener, TimeListener
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 Summary
ConstructorsModifierConstructorDescriptionprotectedAlarmClock(TimeServer timeServer) Creates a new AlarmClock associated with a time server. -
Method Summary
Modifier and TypeMethodDescriptionabstract voidHook method called when the alarm condition is met.Returns the target alarm time.getTime()Returns the current time held by the clock.voidsetAlarmTime(ModernTime alarmTime) Sets the target alarm time.voidsetTime(ModernTime time) Updates the internal clock time.voidsetTolerance(double seconds) Sets the firing tolerance.voidstart()Starts the underlying time server updates.voidstop()Stops the underlying time server updates.voidtimeChanged(TimeEvent event) Invoked when a time change occurs on the monitoredTimeServer.Methods inherited from class Clock
getTimeServer, toString
-
Constructor Details
-
AlarmClock
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
-
setAlarmTime
Sets the target alarm time. Resets the triggered flag.- Parameters:
alarmTime- the target time
-
getTime
Returns the current time held by the clock. -
setTime
Updates the internal clock time.- Parameters:
time- the new time state- Throws:
NullPointerException- if time is null
-
timeChanged
Description copied from interface:TimeListenerInvoked when a time change occurs on the monitoredTimeServer.- 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
-