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 a 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 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 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
CallbackStore
object 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
CallbackStore
object 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
CallbackStore
object 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
CallbackStore
object 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
CallbackStore
object 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.
-