Package edu.wpi.first.wpilibj
Class PowerDistribution
java.lang.Object
edu.wpi.first.wpilibj.PowerDistribution
- All Implemented Interfaces:
Sendable
,AutoCloseable
public class PowerDistribution extends Object implements Sendable, AutoCloseable
Class for getting voltage, current, temperature, power and energy from the Power Distribution
Panel over CAN.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PowerDistribution.ModuleType
-
Field Summary
Fields Modifier and Type Field Description static int
kDefaultModule
-
Constructor Summary
Constructors Constructor Description PowerDistribution()
Constructs a PowerDistribution.PowerDistribution(int module, PowerDistribution.ModuleType moduleType)
Constructs a PowerDistribution. -
Method Summary
Modifier and Type Method Description void
clearStickyFaults()
Clear all PDP sticky faults.void
close()
double
getCurrent(int channel)
Query the current of a single channel of the PDP.int
getModule()
Gets module number (CAN ID).int
getNumChannels()
Gets the number of channel for this power distribution.boolean
getSwitchableChannel()
double
getTemperature()
Query the temperature of the PDP.double
getTotalCurrent()
Query the current of all monitored PDP channels (0-15).double
getTotalEnergy()
Query the total energy drawn from the monitored PDP channels.double
getTotalPower()
Query the total power drawn from the monitored PDP channels.double
getVoltage()
Query the input voltage of the PDP.void
initSendable(SendableBuilder builder)
Initializes thisSendable
object.void
resetTotalEnergy()
Reset the total energy to 0.void
setSwitchableChannel(boolean enabled)
-
Field Details
-
kDefaultModule
- See Also:
- Constant Field Values
-
-
Constructor Details
-
PowerDistribution
Constructs a PowerDistribution.- Parameters:
module
- The CAN ID of the PDP.moduleType
- Module type (CTRE or REV).
-
PowerDistribution
public PowerDistribution()Constructs a PowerDistribution.Uses the default CAN ID (0 for CTRE and 1 for REV).
-
-
Method Details
-
close
- Specified by:
close
in interfaceAutoCloseable
-
getNumChannels
Gets the number of channel for this power distribution.- Returns:
- Number of output channels.
-
getVoltage
Query the input voltage of the PDP.- Returns:
- The voltage of the PDP in volts
-
getTemperature
Query the temperature of the PDP.- Returns:
- The temperature of the PDP in degrees Celsius
-
getCurrent
Query the current of a single channel of the PDP.- Parameters:
channel
- The PDP channel to query.- Returns:
- The current of one of the PDP channels (channels 0-15) in Amperes
-
getTotalCurrent
Query the current of all monitored PDP channels (0-15).- Returns:
- The current of all the channels in Amperes
-
getTotalPower
Query the total power drawn from the monitored PDP channels.- Returns:
- the total power in Watts
-
getTotalEnergy
Query the total energy drawn from the monitored PDP channels.- Returns:
- the total energy in Joules
-
resetTotalEnergy
Reset the total energy to 0. -
clearStickyFaults
Clear all PDP sticky faults. -
getModule
Gets module number (CAN ID).- Returns:
- The module number (CAN ID).
-
getSwitchableChannel
-
setSwitchableChannel
-
initSendable
Description copied from interface:Sendable
Initializes thisSendable
object.- Specified by:
initSendable
in interfaceSendable
- Parameters:
builder
- sendable builder
-