Package edu.wpi.first.wpilibj.simulation
Class PWMSim
java.lang.Object
edu.wpi.first.wpilibj.simulation.PWMSim
public class PWMSim extends Object
Class to control a simulated PWM output.
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description booleangetInitialized()Check whether the PWM has been initialized.intgetPeriodScale()Get the PWM period scale.doublegetPosition()Get the PWM position.intgetRawValue()Get the PWM raw value.doublegetSpeed()Get the PWM speed.booleangetZeroLatch()Check whether the PWM is zero latched.CallbackStoreregisterInitializedCallback(NotifyCallback callback, boolean initialNotify)Register a callback to be run when the PWM is initialized.CallbackStoreregisterPeriodScaleCallback(NotifyCallback callback, boolean initialNotify)Register a callback to be run when the PWM period scale changes.CallbackStoreregisterPositionCallback(NotifyCallback callback, boolean initialNotify)Register a callback to be run when the PWM position changes.CallbackStoreregisterRawValueCallback(NotifyCallback callback, boolean initialNotify)Register a callback to be run when the PWM raw value changes.CallbackStoreregisterSpeedCallback(NotifyCallback callback, boolean initialNotify)Register a callback to be run when the PWM speed changes.CallbackStoreregisterZeroLatchCallback(NotifyCallback callback, boolean initialNotify)Register a callback to be run when the PWM zero latch state changes.voidresetData()Reset all simulation data.voidsetInitialized(boolean initialized)Define whether the PWM has been initialized.voidsetPeriodScale(int periodScale)Set the PWM period scale.voidsetPosition(double position)Set the PWM position.voidsetRawValue(int rawValue)Set the PWM raw value.voidsetSpeed(double speed)Set the PWM speed.voidsetZeroLatch(boolean zeroLatch)Define whether the PWM has been zero latched.
-
Constructor Details
-
Method Details
-
registerInitializedCallback
Register a callback to be run when the PWM 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 the PWM has been initialized.- Returns:
- true if initialized
-
setInitialized
Define whether the PWM has been initialized.- Parameters:
initialized- whether this object is initialized
-
registerRawValueCallback
Register a callback to be run when the PWM raw value changes.- Parameters:
callback- the callbackinitialNotify- whether to run the callback with the initial value- Returns:
- the
CallbackStoreobject associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
getRawValue
Get the PWM raw value.- Returns:
- the PWM raw value
-
setRawValue
Set the PWM raw value.- Parameters:
rawValue- the PWM raw value
-
registerSpeedCallback
Register a callback to be run when the PWM speed changes.- Parameters:
callback- the callbackinitialNotify- whether to run the callback with the initial value- Returns:
- the
CallbackStoreobject associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
getSpeed
Get the PWM speed.- Returns:
- the PWM speed (-1.0 to 1.0)
-
setSpeed
Set the PWM speed.- Parameters:
speed- the PWM speed (-1.0 to 1.0)
-
registerPositionCallback
Register a callback to be run when the PWM position changes.- Parameters:
callback- the callbackinitialNotify- whether to run the callback with the initial value- Returns:
- the
CallbackStoreobject associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
getPosition
Get the PWM position.- Returns:
- the PWM position (0.0 to 1.0)
-
setPosition
Set the PWM position.- Parameters:
position- the PWM position (0.0 to 1.0)
-
registerPeriodScaleCallback
Register a callback to be run when the PWM period scale changes.- Parameters:
callback- the callbackinitialNotify- whether to run the callback with the initial value- Returns:
- the
CallbackStoreobject associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
getPeriodScale
Get the PWM period scale.- Returns:
- the PWM period scale
-
setPeriodScale
Set the PWM period scale.- Parameters:
periodScale- the PWM period scale
-
registerZeroLatchCallback
Register a callback to be run when the PWM zero latch state changes.- 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.
-
getZeroLatch
Check whether the PWM is zero latched.- Returns:
- true if zero latched
-
setZeroLatch
Define whether the PWM has been zero latched.- Parameters:
zeroLatch- true to indicate zero latched
-
resetData
Reset all simulation data.
-