Class DIOSim

java.lang.Object
edu.wpi.first.wpilibj.simulation.DIOSim

public class DIOSim
extends Object
Class to control a simulated digital input or output.
  • Constructor Details

    • DIOSim

      public DIOSim​(DigitalInput input)
      Constructs from a DigitalInput object.
      Parameters:
      input - DigitalInput to simulate
    • DIOSim

      public DIOSim​(DigitalOutput output)
      Constructs from a DigitalOutput object.
      Parameters:
      output - DigitalOutput to simulate
    • DIOSim

      public DIOSim​(int channel)
      Constructs from a digital I/O channel number.
      Parameters:
      channel - Channel number
  • Method Details

    • registerInitializedCallback

      public CallbackStore registerInitializedCallback​(NotifyCallback callback, boolean initialNotify)
      Register a callback to be run when this DIO is initialized.
      Parameters:
      callback - the callback
      initialNotify - whether to run the callback with the initial state
      Returns:
      the CallbackStore object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
    • getInitialized

      public boolean getInitialized()
      Check whether this DIO has been initialized.
      Returns:
      true if initialized
    • setInitialized

      public void setInitialized​(boolean initialized)
      Define whether this DIO has been initialized.
      Parameters:
      initialized - whether this object is initialized
    • registerValueCallback

      public CallbackStore registerValueCallback​(NotifyCallback callback, boolean initialNotify)
      Register a callback to be run whenever the DIO value changes.
      Parameters:
      callback - the callback
      initialNotify - whether the callback should be called with the initial value
      Returns:
      the CallbackStore object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
    • getValue

      public boolean getValue()
      Read the value of the DIO port.
      Returns:
      the DIO value
    • setValue

      public void setValue​(boolean value)
      Change the DIO value.
      Parameters:
      value - the new value
    • registerPulseLengthCallback

      public CallbackStore registerPulseLengthCallback​(NotifyCallback callback, boolean initialNotify)
      Register a callback to be run whenever the pulse length changes.
      Parameters:
      callback - the callback
      initialNotify - whether to call the callback with the initial state
      Returns:
      the CallbackStore object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
    • getPulseLength

      public double getPulseLength()
      Read the pulse length.
      Returns:
      the pulse length of this DIO port
    • setPulseLength

      public void setPulseLength​(double pulseLength)
      Change the pulse length of this DIO port.
      Parameters:
      pulseLength - the new pulse length
    • registerIsInputCallback

      public CallbackStore registerIsInputCallback​(NotifyCallback callback, boolean initialNotify)
      Register a callback to be run whenever this DIO changes to be an input.
      Parameters:
      callback - the callback
      initialNotify - whether the callback should be called with the initial state
      Returns:
      the CallbackStore object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
    • getIsInput

      public boolean getIsInput()
      Check whether this DIO port is currently an Input.
      Returns:
      true if Input
    • setIsInput

      public void setIsInput​(boolean isInput)
      Define whether this DIO port is an Input.
      Parameters:
      isInput - whether this DIO should be an Input
    • registerFilterIndexCallback

      public CallbackStore registerFilterIndexCallback​(NotifyCallback callback, boolean initialNotify)
      Register a callback to be run whenever the filter index changes.
      Parameters:
      callback - the callback
      initialNotify - whether the callback should be called with the initial value
      Returns:
      the CallbackStore object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
    • getFilterIndex

      public int getFilterIndex()
      Read the filter index.
      Returns:
      the filter index of this DIO port
    • setFilterIndex

      public void setFilterIndex​(int filterIndex)
      Change the filter index of this DIO port.
      Parameters:
      filterIndex - the new filter index
    • resetData

      public void resetData()
      Reset all simulation data of this object.