Package edu.wpi.first.wpilibj.simulation
Class DIOSim
java.lang.Object
edu.wpi.first.wpilibj.simulation.DIOSim
Class to control a simulated digital input or output.
-
Constructor Summary
ConstructorDescriptionDIOSim
(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 TypeMethodDescriptionint
Read the filter index.boolean
Check whether this DIO has been initialized.boolean
Check whether this DIO port is currently an Input.double
Read the pulse length.boolean
getValue()
Read the value of the DIO port.registerFilterIndexCallback
(NotifyCallback callback, boolean initialNotify) Register a callback to be run whenever the filter index changes.registerInitializedCallback
(NotifyCallback callback, boolean initialNotify) Register a callback to be run when this DIO is initialized.registerIsInputCallback
(NotifyCallback callback, boolean initialNotify) Register a callback to be run whenever this DIO changes to be an input.registerPulseLengthCallback
(NotifyCallback callback, boolean initialNotify) Register a callback to be run whenever the pulse length changes.registerValueCallback
(NotifyCallback callback, boolean initialNotify) Register a callback to be run whenever the DIO value changes.void
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
-
DIOSim
Constructs from a DigitalInput object.- Parameters:
input
- DigitalInput to simulate
-
DIOSim
Constructs from a DigitalOutput object.- Parameters:
output
- DigitalOutput to simulate
-
DIOSim
Constructs from a digital I/O channel number.- Parameters:
channel
- Channel number
-
-
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.
-
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.
-
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.
-
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.
-
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.
-
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.
-