Package edu.wpi.first.wpilibj.simulation
Class CTREPCMSim
java.lang.Object
edu.wpi.first.wpilibj.simulation.CTREPCMSim
public class CTREPCMSim extends Object
Class to control a simulated Pneumatic Control Module (PCM).
-
Constructor Summary
Constructors Constructor Description CTREPCMSim()
Constructs for the default PCM.CTREPCMSim(int module)
Constructs from a PCM module number (CAN ID).CTREPCMSim(PneumaticsBase module)
Constructs from a Compressor object. -
Method Summary
Modifier and Type Method Description boolean
getClosedLoopEnabled()
Check whether the closed loop compressor control is active.double
getCompressorCurrent()
Read the compressor current.boolean
getCompressorOn()
Check if the compressor is on.boolean
getInitialized()
Check whether the compressor has been initialized.boolean
getPressureSwitch()
Check the value of the pressure switch.boolean
getSolenoidOutput(int channel)
Check the solenoid output on a specific channel.CallbackStore
registerClosedLoopEnabledCallback(NotifyCallback callback, boolean initialNotify)
Register a callback to be run whenever the closed loop state changes.CallbackStore
registerCompressorCurrentCallback(NotifyCallback callback, boolean initialNotify)
Register a callback to be run whenever the compressor current changes.CallbackStore
registerCompressorOnCallback(NotifyCallback callback, boolean initialNotify)
Register a callback to be run when the compressor activates.CallbackStore
registerInitializedCallback(NotifyCallback callback, boolean initialNotify)
Register a callback to be run when the compressor is initialized.CallbackStore
registerPressureSwitchCallback(NotifyCallback callback, boolean initialNotify)
Register a callback to be run whenever the pressure switch value changes.CallbackStore
registerSolenoidOutputCallback(int channel, NotifyCallback callback, boolean initialNotify)
Register a callback to be run when the solenoid output on a channel changes.void
resetData()
Reset all simulation data for this object.void
setClosedLoopEnabled(boolean closedLoopEnabled)
Turn on/off the closed loop control of the compressor.void
setCompressorCurrent(double compressorCurrent)
Set the compressor current.void
setCompressorOn(boolean compressorOn)
Set whether the compressor is active.void
setInitialized(boolean initialized)
Define whether the compressor has been initialized.void
setPressureSwitch(boolean pressureSwitch)
Set the value of the pressure switch.void
setSolenoidOutput(int channel, boolean solenoidOutput)
Change the solenoid output on a specific channel.
-
Constructor Details
-
CTREPCMSim
public CTREPCMSim()Constructs for the default PCM. -
CTREPCMSim
Constructs from a PCM module number (CAN ID).- Parameters:
module
- module number
-
CTREPCMSim
Constructs from a Compressor object.- Parameters:
module
- PCM module to simulate
-
-
Method Details
-
registerSolenoidOutputCallback
public CallbackStore registerSolenoidOutputCallback(int channel, NotifyCallback callback, boolean initialNotify)Register a callback to be run when the solenoid output on a channel changes.- Parameters:
channel
- the channel to monitorcallback
- the callbackinitialNotify
- should the callback be run 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.
-
getSolenoidOutput
Check the solenoid output on a specific channel.- Parameters:
channel
- the channel to check- Returns:
- the solenoid output
-
setSolenoidOutput
Change the solenoid output on a specific channel.- Parameters:
channel
- the channel to checksolenoidOutput
- the new solenoid output
-
registerInitializedCallback
Register a callback to be run when the compressor 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 the compressor has been initialized.- Returns:
- true if initialized
-
setInitialized
Define whether the compressor has been initialized.- Parameters:
initialized
- whether the compressor is initialized
-
registerCompressorOnCallback
Register a callback to be run when the compressor activates.- 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.
-
getCompressorOn
Check if the compressor is on.- Returns:
- true if the compressor is active
-
setCompressorOn
Set whether the compressor is active.- Parameters:
compressorOn
- the new value
-
registerClosedLoopEnabledCallback
public CallbackStore registerClosedLoopEnabledCallback(NotifyCallback callback, boolean initialNotify)Register a callback to be run whenever the closed loop state 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.
-
getClosedLoopEnabled
Check whether the closed loop compressor control is active.- Returns:
- true if active
-
setClosedLoopEnabled
Turn on/off the closed loop control of the compressor.- Parameters:
closedLoopEnabled
- whether the control loop is active
-
registerPressureSwitchCallback
public CallbackStore registerPressureSwitchCallback(NotifyCallback callback, boolean initialNotify)Register a callback to be run whenever the pressure switch 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.
-
getPressureSwitch
Check the value of the pressure switch.- Returns:
- the pressure switch value
-
setPressureSwitch
Set the value of the pressure switch.- Parameters:
pressureSwitch
- the new value
-
registerCompressorCurrentCallback
public CallbackStore registerCompressorCurrentCallback(NotifyCallback callback, boolean initialNotify)Register a callback to be run whenever the compressor current 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.
-
getCompressorCurrent
Read the compressor current.- Returns:
- the current of the compressor connected to this module
-
setCompressorCurrent
Set the compressor current.- Parameters:
compressorCurrent
- the new compressor current
-
resetData
Reset all simulation data for this object.
-