Package edu.wpi.first.wpilibj.simulation
Class PWMSim
- java.lang.Object
-
- edu.wpi.first.wpilibj.simulation.PWMSim
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
getInitialized()
Check whether the PWM has been initialized.int
getPeriodScale()
Get the PWM period scale.double
getPosition()
Get the PWM position.int
getRawValue()
Get the PWM raw value.double
getSpeed()
Get the PWM speed.boolean
getZeroLatch()
Check whether the PWM is zero latched.CallbackStore
registerInitializedCallback(NotifyCallback callback, boolean initialNotify)
Register a callback to be run when the PWM is initialized.CallbackStore
registerPeriodScaleCallback(NotifyCallback callback, boolean initialNotify)
Register a callback to be run when the PWM period scale changes.CallbackStore
registerPositionCallback(NotifyCallback callback, boolean initialNotify)
Register a callback to be run when the PWM position changes.CallbackStore
registerRawValueCallback(NotifyCallback callback, boolean initialNotify)
Register a callback to be run when the PWM raw value changes.CallbackStore
registerSpeedCallback(NotifyCallback callback, boolean initialNotify)
Register a callback to be run when the PWM speed changes.CallbackStore
registerZeroLatchCallback(NotifyCallback callback, boolean initialNotify)
Register a callback to be run when the PWM zero latch state changes.void
resetData()
Reset all simulation data.void
setInitialized(boolean initialized)
Define whether the PWM has been initialized.void
setPeriodScale(int periodScale)
Set the PWM period scale.void
setPosition(double position)
Set the PWM position.void
setRawValue(int rawValue)
Set the PWM raw value.void
setSpeed(double speed)
Set the PWM speed.void
setZeroLatch(boolean zeroLatch)
Define whether the PWM has been zero latched.
-
-
-
Method Detail
-
registerInitializedCallback
public CallbackStore registerInitializedCallback(NotifyCallback callback, boolean initialNotify)
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
CallbackStore
object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
getInitialized
public boolean getInitialized()
Check whether the PWM has been initialized.- Returns:
- true if initialized
-
setInitialized
public void setInitialized(boolean initialized)
Define whether the PWM has been initialized.- Parameters:
initialized
- whether this object is initialized
-
registerRawValueCallback
public CallbackStore registerRawValueCallback(NotifyCallback callback, boolean initialNotify)
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
CallbackStore
object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
getRawValue
public int getRawValue()
Get the PWM raw value.- Returns:
- the PWM raw value
-
setRawValue
public void setRawValue(int rawValue)
Set the PWM raw value.- Parameters:
rawValue
- the PWM raw value
-
registerSpeedCallback
public CallbackStore registerSpeedCallback(NotifyCallback callback, boolean initialNotify)
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
CallbackStore
object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
getSpeed
public double getSpeed()
Get the PWM speed.- Returns:
- the PWM speed (-1.0 to 1.0)
-
setSpeed
public void setSpeed(double speed)
Set the PWM speed.- Parameters:
speed
- the PWM speed (-1.0 to 1.0)
-
registerPositionCallback
public CallbackStore registerPositionCallback(NotifyCallback callback, boolean initialNotify)
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
CallbackStore
object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
getPosition
public double getPosition()
Get the PWM position.- Returns:
- the PWM position (0.0 to 1.0)
-
setPosition
public void setPosition(double position)
Set the PWM position.- Parameters:
position
- the PWM position (0.0 to 1.0)
-
registerPeriodScaleCallback
public CallbackStore registerPeriodScaleCallback(NotifyCallback callback, boolean initialNotify)
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
CallbackStore
object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
getPeriodScale
public int getPeriodScale()
Get the PWM period scale.- Returns:
- the PWM period scale
-
setPeriodScale
public void setPeriodScale(int periodScale)
Set the PWM period scale.- Parameters:
periodScale
- the PWM period scale
-
registerZeroLatchCallback
public CallbackStore registerZeroLatchCallback(NotifyCallback callback, boolean initialNotify)
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
CallbackStore
object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
getZeroLatch
public boolean getZeroLatch()
Check whether the PWM is zero latched.- Returns:
- true if zero latched
-
setZeroLatch
public void setZeroLatch(boolean zeroLatch)
Define whether the PWM has been zero latched.- Parameters:
zeroLatch
- true to indicate zero latched
-
resetData
public void resetData()
Reset all simulation data.
-
-