Package edu.wpi.first.wpilibj.simulation
Class PneumaticsBaseSim
java.lang.Object
edu.wpi.first.wpilibj.simulation.PneumaticsBaseSim
- Direct Known Subclasses:
CTREPCMSim
,REVPHSim
public abstract class PneumaticsBaseSim extends Object
Common base class for pneumatics module simulation classes.
-
Field Summary
Fields Modifier and Type Field Description protected int
m_index
PneumaticsBase index. -
Constructor Summary
Constructors Modifier Constructor Description protected
PneumaticsBaseSim(int index)
Constructs a PneumaticsBaseSim with the given index.protected
PneumaticsBaseSim(PneumaticsBase module)
Constructs a PneumaticsBaseSim for the given module. -
Method Summary
Modifier and Type Method Description abstract double
getCompressorCurrent()
Read the compressor current.abstract boolean
getCompressorOn()
Check if the compressor is on.static PneumaticsBaseSim
getForType(int module, PneumaticsModuleType type)
Get a module sim for a specific type.abstract boolean
getInitialized()
Check whether the PCM/PH has been initialized.abstract boolean
getPressureSwitch()
Check the value of the pressure switch.abstract boolean
getSolenoidOutput(int channel)
Check the solenoid output on a specific channel.abstract CallbackStore
registerCompressorCurrentCallback(NotifyCallback callback, boolean initialNotify)
Register a callback to be run whenever the compressor current changes.abstract CallbackStore
registerCompressorOnCallback(NotifyCallback callback, boolean initialNotify)
Register a callback to be run when the compressor activates.abstract CallbackStore
registerInitializedCallback(NotifyCallback callback, boolean initialNotify)
Register a callback to be run when the PCM/PH is initialized.abstract CallbackStore
registerPressureSwitchCallback(NotifyCallback callback, boolean initialNotify)
Register a callback to be run whenever the pressure switch value changes.abstract CallbackStore
registerSolenoidOutputCallback(int channel, NotifyCallback callback, boolean initialNotify)
Register a callback to be run when the solenoid output on a channel changes.abstract void
resetData()
Reset all simulation data for this object.abstract void
setCompressorCurrent(double compressorCurrent)
Set the compressor current.abstract void
setCompressorOn(boolean compressorOn)
Set whether the compressor is active.abstract void
setInitialized(boolean initialized)
Define whether the PCM/PH has been initialized.abstract void
setPressureSwitch(boolean pressureSwitch)
Set the value of the pressure switch.abstract void
setSolenoidOutput(int channel, boolean solenoidOutput)
Change the solenoid output on a specific channel.
-
Field Details
-
m_index
PneumaticsBase index.
-
-
Constructor Details
-
PneumaticsBaseSim
Constructs a PneumaticsBaseSim with the given index.- Parameters:
index
- The index.
-
PneumaticsBaseSim
Constructs a PneumaticsBaseSim for the given module.- Parameters:
module
- The module.
-
-
Method Details
-
getForType
Get a module sim for a specific type.- Parameters:
module
- the module number / CAN ID.type
- the module type.- Returns:
- the module object.
-
getInitialized
Check whether the PCM/PH has been initialized.- Returns:
- true if initialized
-
setInitialized
Define whether the PCM/PH has been initialized.- Parameters:
initialized
- true for initialized
-
registerInitializedCallback
public abstract CallbackStore registerInitializedCallback(NotifyCallback callback, boolean initialNotify)Register a callback to be run when the PCM/PH 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.
-
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
-
registerCompressorOnCallback
public abstract CallbackStore registerCompressorOnCallback(NotifyCallback callback, boolean initialNotify)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.
-
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
-
registerSolenoidOutputCallback
public abstract 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.
-
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
-
registerPressureSwitchCallback
public abstract 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.
-
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
-
registerCompressorCurrentCallback
public abstract 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.
-
resetData
Reset all simulation data for this object.
-