Class PDPSim
java.lang.Object
org.wpilib.simulation.PDPSim
Class to control a simulated Power Distribution Panel (PDP).
-
Constructor Summary
ConstructorsConstructorDescriptionPDPSim()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 TypeMethodDescriptiondoublegetCurrent(int channel) Read the current in one of the PDP channels.booleanCheck whether the PDP has been initialized.doubleCheck the temperature of the PDP.doubleCheck the PDP voltage.registerCurrentCallback(int channel, NotifyCallback callback, boolean initialNotify) Register a callback to be run whenever the current of a specific channel changes.registerInitializedCallback(NotifyCallback callback, boolean initialNotify) Register a callback to be run when the PDP is initialized.registerTemperatureCallback(NotifyCallback callback, boolean initialNotify) Register a callback to be run whenever the PDP temperature changes.registerVoltageCallback(NotifyCallback callback, boolean initialNotify) Register a callback to be run whenever the PDP voltage changes.voidReset all PDP simulation data.voidsetCurrent(int channel, double current) Change the current in the given channel.voidsetInitialized(boolean initialized) Define whether the PDP has been initialized.voidsetTemperature(double temperature) Define the PDP temperature.voidsetVoltage(double voltage) Set the PDP voltage.
-
Constructor Details
-
PDPSim
public PDPSim()Constructs for the default PDP. -
PDPSim
public PDPSim(int module) Constructs from a PDP module number (CAN ID).- Parameters:
module- module number
-
PDPSim
Constructs from a PowerDistribution object.- Parameters:
pdp- PowerDistribution to simulate
-
-
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
CallbackStoreobject associated with this callback.
-
getInitialized
public boolean getInitialized()Check whether the PDP has been initialized.- Returns:
- true if initialized
-
setInitialized
public void setInitialized(boolean initialized) 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
CallbackStoreobject associated with this callback.
-
getTemperature
public double getTemperature()Check the temperature of the PDP.- Returns:
- the PDP temperature
-
setTemperature
public void setTemperature(double temperature) 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
CallbackStoreobject associated with this callback.
-
getVoltage
public double getVoltage()Check the PDP voltage.- Returns:
- the PDP voltage.
-
setVoltage
public void setVoltage(double voltage) 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
CallbackStoreobject associated with this callback.
-
getCurrent
public double getCurrent(int channel) Read the current in one of the PDP channels.- Parameters:
channel- the channel to check- Returns:
- the current in the given channel
-
setCurrent
public void setCurrent(int channel, double current) Change the current in the given channel.- Parameters:
channel- the channel to editcurrent- the new current for the channel
-
resetData
public void resetData()Reset all PDP simulation data.
-