WPILibC++ 2023.4.3
|
Class for getting voltage, current, temperature, power and energy from the CTRE Power Distribution Panel (PDP) or REV Power Distribution Hub (PDH). More...
#include <frc/PowerDistribution.h>
Classes | |
struct | Faults |
struct | StickyFaults |
struct | Version |
Public Types | |
enum class | ModuleType { kCTRE = 1 , kRev = 2 } |
Public Member Functions | |
PowerDistribution () | |
Constructs a PowerDistribution object. More... | |
PowerDistribution (int module, ModuleType moduleType) | |
Constructs a PowerDistribution object. More... | |
~PowerDistribution () override | |
PowerDistribution (PowerDistribution &&)=default | |
PowerDistribution & | operator= (PowerDistribution &&)=default |
double | GetVoltage () const |
Query the input voltage of the PDP/PDH. More... | |
double | GetTemperature () const |
Query the temperature of the PDP/PDH. More... | |
double | GetCurrent (int channel) const |
Query the current of a single channel of the PDP/PDH. More... | |
double | GetTotalCurrent () const |
Query the total current of all monitored PDP/PDH channels. More... | |
double | GetTotalPower () const |
Query the total power drawn from all monitored PDP/PDH channels. More... | |
double | GetTotalEnergy () const |
Query the total energy drawn from the monitored PDP/PDH channels. More... | |
void | ResetTotalEnergy () |
Reset the total energy drawn from the PDP/PDH. More... | |
void | ClearStickyFaults () |
Remove all of the fault flags on the PDP/PDH. More... | |
int | GetModule () const |
Gets module number (CAN ID). More... | |
ModuleType | GetType () const |
Gets module type. More... | |
bool | GetSwitchableChannel () const |
Gets whether the PDH switchable channel is turned on or off. More... | |
void | SetSwitchableChannel (bool enabled) |
Sets the PDH switchable channel on or off. More... | |
Version | GetVersion () const |
Faults | GetFaults () const |
StickyFaults | GetStickyFaults () const |
void | InitSendable (wpi::SendableBuilder &builder) override |
Initializes this Sendable object. More... | |
Public Member Functions inherited from wpi::Sendable | |
virtual | ~Sendable ()=default |
virtual void | InitSendable (SendableBuilder &builder)=0 |
Initializes this Sendable object. More... | |
Public Member Functions inherited from wpi::SendableHelper< PowerDistribution > | |
SendableHelper (const SendableHelper &rhs)=default | |
SendableHelper (SendableHelper &&rhs) | |
SendableHelper & | operator= (const SendableHelper &rhs)=default |
SendableHelper & | operator= (SendableHelper &&rhs) |
Static Public Attributes | |
static constexpr int | kDefaultModule = -1 |
Additional Inherited Members | |
Protected Member Functions inherited from wpi::SendableHelper< PowerDistribution > | |
SendableHelper ()=default | |
~SendableHelper () | |
Class for getting voltage, current, temperature, power and energy from the CTRE Power Distribution Panel (PDP) or REV Power Distribution Hub (PDH).
|
strong |
frc::PowerDistribution::PowerDistribution | ( | ) |
Constructs a PowerDistribution object.
Detects the connected PDP/PDH using the default CAN ID (0 for CTRE and 1 for REV).
frc::PowerDistribution::PowerDistribution | ( | int | module, |
ModuleType | moduleType | ||
) |
Constructs a PowerDistribution object.
module | The CAN ID of the PDP/PDH |
moduleType | The type of module |
|
override |
|
default |
void frc::PowerDistribution::ClearStickyFaults | ( | ) |
Remove all of the fault flags on the PDP/PDH.
double frc::PowerDistribution::GetCurrent | ( | int | channel | ) | const |
Query the current of a single channel of the PDP/PDH.
channel | the channel to query (0-15 for PDP, 0-23 for PDH) |
Faults frc::PowerDistribution::GetFaults | ( | ) | const |
int frc::PowerDistribution::GetModule | ( | ) | const |
Gets module number (CAN ID).
StickyFaults frc::PowerDistribution::GetStickyFaults | ( | ) | const |
bool frc::PowerDistribution::GetSwitchableChannel | ( | ) | const |
Gets whether the PDH switchable channel is turned on or off.
Returns false with the CTRE PDP.
double frc::PowerDistribution::GetTemperature | ( | ) | const |
Query the temperature of the PDP/PDH.
double frc::PowerDistribution::GetTotalCurrent | ( | ) | const |
Query the total current of all monitored PDP/PDH channels.
double frc::PowerDistribution::GetTotalEnergy | ( | ) | const |
Query the total energy drawn from the monitored PDP/PDH channels.
double frc::PowerDistribution::GetTotalPower | ( | ) | const |
Query the total power drawn from all monitored PDP/PDH channels.
ModuleType frc::PowerDistribution::GetType | ( | ) | const |
Gets module type.
Version frc::PowerDistribution::GetVersion | ( | ) | const |
double frc::PowerDistribution::GetVoltage | ( | ) | const |
Query the input voltage of the PDP/PDH.
|
overridevirtual |
|
default |
void frc::PowerDistribution::ResetTotalEnergy | ( | ) |
Reset the total energy drawn from the PDP/PDH.
void frc::PowerDistribution::SetSwitchableChannel | ( | bool | enabled | ) |
Sets the PDH switchable channel on or off.
Does nothing with the CTRE PDP.
enabled | Whether to turn the PDH switchable channel on or off |
|
staticconstexpr |