Class TimeStableValidator

java.lang.Object
xbot.common.logic.TimeStableValidator

public class TimeStableValidator extends Object
Checks that a value is stable for a given amount of time.
  • Constructor Details

    • TimeStableValidator

      public TimeStableValidator(double stableWindow)
      Creates a new TimeStableValidator using a constant value.
      Parameters:
      stableWindow - The time window, in seconds.
    • TimeStableValidator

      public TimeStableValidator(DoubleSupplier stableWindowProvider)
      Creates a new TimeStableValidator using a window from a supplier.
      Parameters:
      stableWindowProvider - A supplier that provides a time window, in seconds.
  • Method Details

    • setStableWindowProvider

      public void setStableWindowProvider(DoubleSupplier stableWindowProvider)
      Update the stable window using a supplier.
      Parameters:
      stableWindowProvider - A supplier that provides a time window, in seconds.
    • setStableWindow

      public void setStableWindow(double stableWindow)
      Update the stable window using a constant value.
      Parameters:
      stableWindow - The time window, in seconds.
    • checkStable

      public boolean checkStable(boolean value)
      Checks if the value has been stable for the entire stable window duration.
      Parameters:
      value - The value to test.
      Returns:
      True if the value has been stable for the entire window duration.
    • peekStable

      public boolean peekStable()
      Checks if the value has been stable for the entire stable window duration, but without updating the internal state of the validator. (Example usage: the validator is updated in a regular periodic call, but there are many listeners who are interested in the result.)
      Returns:
      True if the last checkStable() call returned true.
    • setStable

      public void setStable()
      Used if you want the validator to start in a stable state.