Package trclib.timer

Class TrcIntervalTimer

java.lang.Object
trclib.timer.TrcIntervalTimer

public class TrcIntervalTimer extends Object
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 Details

    • instanceName

      private final String instanceName
    • interval

      private final double interval
    • expirationTime

      private double expirationTime
  • Constructor Details

    • TrcIntervalTimer

      public TrcIntervalTimer(String instanceName, double interval)
      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

      public String toString()
      This method returns the instance name.
      Overrides:
      toString in class Object
      Returns:
      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.