public class Watchdog extends Object
When the timer expires, a message is printed to the console and an optional user-provided callback is invoked.
The watchdog is initialized disabled, so the user needs to call enable() before use.
Constructor and Description |
---|
Watchdog(double timeout)
Watchdog constructor.
|
Watchdog(double timeout,
Runnable callback)
Watchdog constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addEpoch(String epochName)
Adds time since last epoch to the list printed by printEpochs().
|
void |
disable()
Disable the watchdog.
|
void |
enable()
Enables the watchdog timer.
|
double |
getTime()
Get the time in seconds since the watchdog was last fed.
|
boolean |
isExpired()
Returns true if the watchdog timer has expired.
|
void |
printEpochs()
Prints list of epochs added so far and their times.
|
void |
reset()
Resets the watchdog timer.
|
public Watchdog(double timeout)
timeout
- The watchdog's timeout in seconds.public Watchdog(double timeout, Runnable callback)
timeout
- The watchdog's timeout in seconds.callback
- This function is called when the timeout expires.public double getTime()
public boolean isExpired()
public void addEpoch(String epochName)
epochName
- The name to associate with the epoch.public void printEpochs()
public void reset()
This also enables the timer if it was previously disabled.
public void enable()
public void disable()