Package edu.wpi.first.wpilibj.simulation
Class DIOSim
- java.lang.Object
-
- edu.wpi.first.wpilibj.simulation.DIOSim
-
-
Constructor Summary
Constructors Constructor Description DIOSim(int channel)
Constructs from an digital I/O channel number.DIOSim(DigitalInput input)
Constructs from a DigitalInput object.DIOSim(DigitalOutput output)
Constructs from a DigitalOutput object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getFilterIndex()
Read the filter index.boolean
getInitialized()
Check whether this DIO has been initialized.boolean
getIsInput()
Check whether this DIO port is currently an Input.double
getPulseLength()
Read the pulse length.boolean
getValue()
Read the value of the DIO port.CallbackStore
registerFilterIndexCallback(NotifyCallback callback, boolean initialNotify)
Register a callback to be run whenever the filter index changes.CallbackStore
registerInitializedCallback(NotifyCallback callback, boolean initialNotify)
Register a callback to be run when this DIO is initialized.CallbackStore
registerIsInputCallback(NotifyCallback callback, boolean initialNotify)
Register a callback to be run whenever this DIO changes to be an input.CallbackStore
registerPulseLengthCallback(NotifyCallback callback, boolean initialNotify)
Register a callback to be run whenever the pulse length changes.CallbackStore
registerValueCallback(NotifyCallback callback, boolean initialNotify)
Register a callback to be run whenever the DIO value changes.void
resetData()
Reset all simulation data of this object.void
setFilterIndex(int filterIndex)
Change the filter index of this DIO port.void
setInitialized(boolean initialized)
Define whether this DIO has been initialized.void
setIsInput(boolean isInput)
Define whether this DIO port is an Input.void
setPulseLength(double pulseLength)
Change the pulse length of this DIO port.void
setValue(boolean value)
Change the DIO value.
-
-
-
Constructor Detail
-
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 an digital I/O channel number.- Parameters:
channel
- Channel number
-
-
Method Detail
-
registerInitializedCallback
public CallbackStore registerInitializedCallback(NotifyCallback callback, boolean initialNotify)
Register a callback to be run when this DIO is initialized.- Parameters:
callback
- the callbackinitialNotify
- 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 callbackinitialNotify
- 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 callbackinitialNotify
- 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 callbackinitialNotify
- 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 callbackinitialNotify
- 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.
-
-