Package edu.wpi.first.wpilibj.simulation
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 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
Modifier and Type Method Description intgetFilterIndex()Read the filter index.booleangetInitialized()Check whether this DIO has been initialized.booleangetIsInput()Check whether this DIO port is currently an Input.doublegetPulseLength()Read the pulse length.booleangetValue()Read the value of the DIO port.CallbackStoreregisterFilterIndexCallback(NotifyCallback callback, boolean initialNotify)Register a callback to be run whenever the filter index changes.CallbackStoreregisterInitializedCallback(NotifyCallback callback, boolean initialNotify)Register a callback to be run when this DIO is initialized.CallbackStoreregisterIsInputCallback(NotifyCallback callback, boolean initialNotify)Register a callback to be run whenever this DIO changes to be an input.CallbackStoreregisterPulseLengthCallback(NotifyCallback callback, boolean initialNotify)Register a callback to be run whenever the pulse length changes.CallbackStoreregisterValueCallback(NotifyCallback callback, boolean initialNotify)Register a callback to be run whenever the DIO value changes.voidresetData()Reset all simulation data of this object.voidsetFilterIndex(int filterIndex)Change the filter index of this DIO port.voidsetInitialized(boolean initialized)Define whether this DIO has been initialized.voidsetIsInput(boolean isInput)Define whether this DIO port is an Input.voidsetPulseLength(double pulseLength)Change the pulse length of this DIO port.voidsetValue(boolean value)Change the DIO value.
-
Constructor Details
-
Method Details
-
registerInitializedCallback
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
CallbackStoreobject associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
getInitialized
Check whether this DIO has been initialized.- Returns:
- true if initialized
-
setInitialized
Define whether this DIO has been initialized.- Parameters:
initialized- whether this object is initialized
-
registerValueCallback
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
CallbackStoreobject associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
getValue
Read the value of the DIO port.- Returns:
- the DIO value
-
setValue
Change the DIO value.- Parameters:
value- the new value
-
registerPulseLengthCallback
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
CallbackStoreobject associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
getPulseLength
Read the pulse length.- Returns:
- the pulse length of this DIO port
-
setPulseLength
Change the pulse length of this DIO port.- Parameters:
pulseLength- the new pulse length
-
registerIsInputCallback
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
CallbackStoreobject associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
getIsInput
Check whether this DIO port is currently an Input.- Returns:
- true if Input
-
setIsInput
Define whether this DIO port is an Input.- Parameters:
isInput- whether this DIO should be an Input
-
registerFilterIndexCallback
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
CallbackStoreobject associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
getFilterIndex
Read the filter index.- Returns:
- the filter index of this DIO port
-
setFilterIndex
Change the filter index of this DIO port.- Parameters:
filterIndex- the new filter index
-
resetData
Reset all simulation data of this object.
-