Package edu.wpi.first.wpilibj.simulation
Class PDPSim
java.lang.Object
edu.wpi.first.wpilibj.simulation.PDPSim
public class PDPSim extends Object
Class to control a simulated Power Distribution Panel (PDP).
-
Constructor Summary
Constructors Constructor Description PDPSim()
Constructs for the default PDP.PDPSim(int module)
Constructs from a PDP module number (CAN ID).PDPSim(PowerDistribution pdp)
Constructs from a PowerDistribution object. -
Method Summary
Modifier and Type Method Description double
getCurrent(int channel)
Read the current in one of the PDP channels.boolean
getInitialized()
Check whether the PDP has been initialized.double
getTemperature()
Check the temperature of the PDP.double
getVoltage()
Check the PDP voltage.CallbackStore
registerCurrentCallback(int channel, NotifyCallback callback, boolean initialNotify)
Register a callback to be run whenever the current of a specific channel changes.CallbackStore
registerInitializedCallback(NotifyCallback callback, boolean initialNotify)
Register a callback to be run when the PDP is initialized.CallbackStore
registerTemperatureCallback(NotifyCallback callback, boolean initialNotify)
Register a callback to be run whenever the PDP temperature changes.CallbackStore
registerVoltageCallback(NotifyCallback callback, boolean initialNotify)
Register a callback to be run whenever the PDP voltage changes.void
resetData()
Reset all PDP simulation data.void
setCurrent(int channel, double current)
Change the current in the given channel.void
setInitialized(boolean initialized)
Define whether the PDP has been initialized.void
setTemperature(double temperature)
Define the PDP temperature.void
setVoltage(double voltage)
Set the PDP voltage.
-
Constructor Details
-
Method Details
-
registerInitializedCallback
Register a callback to be run when the PDP 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 PDP has been initialized.- Returns:
- true if initialized
-
setInitialized
Define whether the PDP has been initialized.- Parameters:
initialized
- whether this object is initialized
-
registerTemperatureCallback
Register a callback to be run whenever the PDP temperature 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.
-
getTemperature
Check the temperature of the PDP.- Returns:
- the PDP temperature
-
setTemperature
Define the PDP temperature.- Parameters:
temperature
- the new PDP temperature
-
registerVoltageCallback
Register a callback to be run whenever the PDP voltage 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.
-
getVoltage
Check the PDP voltage.- Returns:
- the PDP voltage.
-
setVoltage
Set the PDP voltage.- Parameters:
voltage
- the new PDP voltage
-
registerCurrentCallback
public CallbackStore registerCurrentCallback(int channel, NotifyCallback callback, boolean initialNotify)Register a callback to be run whenever the current of a specific channel changes.- Parameters:
channel
- the channelcallback
- 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.
-
getCurrent
Read the current in one of the PDP channels.- Parameters:
channel
- the channel to check- Returns:
- the current in the given channel
-
setCurrent
Change the current in the given channel.- Parameters:
channel
- the channel to editcurrent
- the new current for the channel
-
resetData
Reset all PDP simulation data.
-