Package trclib.timer
Class TrcIntervalTimer
java.lang.Object
trclib.timer.TrcIntervalTimer
This class implements a low cost interval timer that will expire at the specified interval. This is different
from TrcTimer in that it doesn't signal any event, thus no monitoring task. The caller is responsible for calling
the hasExpired() method periodically to check if the interval timer has expired. Once expired, the interval timer
is re-armed at the next interval from the time hasExpired() is called.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTrcIntervalTimer
(String instanceName, double interval) Constructor: Creates an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptionboolean
This method is called periodically to check if the interval timer has expired.toString()
This method returns the instance name.
-
Field Details
-
instanceName
-
interval
private final double interval -
expirationTime
private double expirationTime
-
-
Constructor Details
-
TrcIntervalTimer
Constructor: Creates an instance of the object.- Parameters:
instanceName
- specifies the name to identify this instance of the timer.interval
- specifies the interval of the timer in seconds.
-
-
Method Details
-
toString
This method returns the instance name. -
hasExpired
public boolean hasExpired()This method is called periodically to check if the interval timer has expired. If so, it will re-arm the timer to expire at the next interval from the time this is called.- Returns:
- true if interval timer has expired, false otherwise.
-