Package edu.wpi.first.wpilibj.simulation
Class DutyCycleSim
java.lang.Object
edu.wpi.first.wpilibj.simulation.DutyCycleSim
Class to control a simulated duty cycle digital input.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic DutyCycleSim
createForChannel
(int channel) Creates a DutyCycleSim for a digital input channel.static DutyCycleSim
createForIndex
(int index) Creates a DutyCycleSim for a simulated index.int
Measure the frequency.boolean
Check whether this duty cycle input has been initialized.double
Measure the output from this duty cycle port.registerFrequencyCallback
(NotifyCallback callback, boolean initialNotify) Register a callback to be run whenever the frequency changes.registerInitializedCallback
(NotifyCallback callback, boolean initialNotify) Register a callback to be run when this duty cycle input is initialized.registerOutputCallback
(NotifyCallback callback, boolean initialNotify) Register a callback to be run whenever the output changes.void
Reset all simulation data for the duty cycle output.void
setFrequency
(int frequency) Change the duty cycle frequency.void
setInitialized
(boolean initialized) Define whether this duty cycle input has been initialized.void
setOutput
(double output) Change the duty cycle output.
-
Constructor Details
-
DutyCycleSim
Constructs from a DutyCycle object.- Parameters:
dutyCycle
- DutyCycle to simulate
-
-
Method Details
-
createForChannel
Creates a DutyCycleSim for a digital input channel.- Parameters:
channel
- digital input channel- Returns:
- Simulated object
- Throws:
NoSuchElementException
- if no DutyCycle is configured for that channel
-
createForIndex
Creates a DutyCycleSim for a simulated index. The index is incremented for each simulated DutyCycle.- Parameters:
index
- simulator index- Returns:
- Simulated object
-
registerInitializedCallback
Register a callback to be run when this duty cycle input 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 duty cycle input has been initialized.- Returns:
- true if initialized
-
setInitialized
Define whether this duty cycle input has been initialized.- Parameters:
initialized
- whether this object is initialized
-
registerFrequencyCallback
Register a callback to be run whenever the frequency changes.- Parameters:
callback
- the callbackinitialNotify
- whether to call the callback with the initial state- Returns:
- the
CallbackStore
object associated with this callback.
-
getFrequency
Measure the frequency.- Returns:
- the duty cycle frequency
-
setFrequency
Change the duty cycle frequency.- Parameters:
frequency
- the new frequency
-
registerOutputCallback
Register a callback to be run whenever the output changes.- Parameters:
callback
- the callbackinitialNotify
- whether to call the callback with the initial state- Returns:
- the
CallbackStore
object associated with this callback.
-
getOutput
Measure the output from this duty cycle port.- Returns:
- the output value
-
setOutput
Change the duty cycle output.- Parameters:
output
- the new output value
-
resetData
Reset all simulation data for the duty cycle output.
-