Class WaitableDigitalInputDevice

All Implemented Interfaces:
DigitalInputDeviceInterface, InputEventListener<DigitalInputEvent>, java.io.Closeable, java.lang.AutoCloseable
Direct Known Subclasses:
DebouncedDigitalInputDevice, SmoothedInputDevice

public class WaitableDigitalInputDevice
extends DigitalInputDevice
Represents a digital input device with distinct waitable states (active / inactive).
  • Constructor Details

  • Method Details

    • disableDeviceListener

      protected void disableDeviceListener()
      Overrides:
      disableDeviceListener in class AbstractDigitalInputDevice
    • valueChanged

      public void valueChanged​(DigitalInputEvent event)
      Specified by:
      valueChanged in interface InputEventListener<DigitalInputEvent>
      Overrides:
      valueChanged in class AbstractDigitalInputDevice
    • waitForActive

      public boolean waitForActive() throws java.lang.InterruptedException
      Wait indefinitely for the device state to go active.
      Returns:
      False if timed out waiting for the specified value, otherwise true.
      Throws:
      java.lang.InterruptedException - If interrupted while waiting.-
    • waitForActive

      public boolean waitForActive​(int timeout) throws java.lang.InterruptedException
      Wait the specified time period for the device state to go active.
      Parameters:
      timeout - Timeout value if milliseconds, <= 0 is indefinite.
      Returns:
      False if timed out waiting for the specified value, otherwise true.
      Throws:
      java.lang.InterruptedException - If interrupted while waiting.-
    • waitForInactive

      public boolean waitForInactive() throws java.lang.InterruptedException
      Wait indefinitely for the device state to go inactive.
      Returns:
      False if timed out waiting for the specified value, otherwise true.
      Throws:
      java.lang.InterruptedException - If interrupted while waiting.-
    • waitForInactive

      public boolean waitForInactive​(int timeout) throws java.lang.InterruptedException
      Wait the specified time period for the device state to go inactive.
      Parameters:
      timeout - Timeout value if milliseconds, <= 0 is indefinite.
      Returns:
      False if timed out waiting for the specified value, otherwise true.
      Throws:
      java.lang.InterruptedException - If interrupted while waiting.-
    • waitForValue

      public boolean waitForValue​(boolean value, int timeout) throws java.lang.InterruptedException
      Wait the specified time period for the device state to switch to value.
      Parameters:
      value - The desired device state to wait for.
      timeout - Timeout value if milliseconds, <= 0 is indefinite.
      Returns:
      False if timed out waiting for the specified value, otherwise true.
      Throws:
      java.lang.InterruptedException - If interrupted while waiting.-