WPILibC++ 2023.4.3-108-ge5452e3
frc::PowerDistribution Class Reference

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>

Inheritance diagram for frc::PowerDistribution:
wpi::Sendable wpi::SendableHelper< PowerDistribution >

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
 
PowerDistributionoperator= (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)
 
SendableHelperoperator= (const SendableHelper &rhs)=default
 
SendableHelperoperator= (SendableHelper &&rhs)
 

Static Public Attributes

static constexpr int kDefaultModule = -1
 

Additional Inherited Members

- Protected Member Functions inherited from wpi::SendableHelper< PowerDistribution >
 SendableHelper ()=default
 
 ~SendableHelper ()
 

Detailed Description

Class for getting voltage, current, temperature, power and energy from the CTRE Power Distribution Panel (PDP) or REV Power Distribution Hub (PDH).

Member Enumeration Documentation

◆ ModuleType

Enumerator
kCTRE 
kRev 

Constructor & Destructor Documentation

◆ PowerDistribution() [1/3]

frc::PowerDistribution::PowerDistribution ( )

Constructs a PowerDistribution object.

Detects the connected PDP/PDH using the default CAN ID (0 for CTRE and 1 for REV).

◆ PowerDistribution() [2/3]

frc::PowerDistribution::PowerDistribution ( int  module,
ModuleType  moduleType 
)

Constructs a PowerDistribution object.

Parameters
moduleThe CAN ID of the PDP/PDH
moduleTypeThe type of module

◆ ~PowerDistribution()

frc::PowerDistribution::~PowerDistribution ( )
override

◆ PowerDistribution() [3/3]

frc::PowerDistribution::PowerDistribution ( PowerDistribution &&  )
default

Member Function Documentation

◆ ClearStickyFaults()

void frc::PowerDistribution::ClearStickyFaults ( )

Remove all of the fault flags on the PDP/PDH.

◆ GetCurrent()

double frc::PowerDistribution::GetCurrent ( int  channel) const

Query the current of a single channel of the PDP/PDH.

Parameters
channelthe channel to query (0-15 for PDP, 0-23 for PDH)
Returns
The current of the channel in Amperes

◆ GetFaults()

Faults frc::PowerDistribution::GetFaults ( ) const

◆ GetModule()

int frc::PowerDistribution::GetModule ( ) const

Gets module number (CAN ID).

◆ GetStickyFaults()

StickyFaults frc::PowerDistribution::GetStickyFaults ( ) const

◆ GetSwitchableChannel()

bool frc::PowerDistribution::GetSwitchableChannel ( ) const

Gets whether the PDH switchable channel is turned on or off.

Returns false with the CTRE PDP.

Returns
The output state of the PDH switchable channel

◆ GetTemperature()

double frc::PowerDistribution::GetTemperature ( ) const

Query the temperature of the PDP/PDH.

Returns
The temperature in degrees Celsius

◆ GetTotalCurrent()

double frc::PowerDistribution::GetTotalCurrent ( ) const

Query the total current of all monitored PDP/PDH channels.

Returns
The total current drawn from all channels in Amperes

◆ GetTotalEnergy()

double frc::PowerDistribution::GetTotalEnergy ( ) const

Query the total energy drawn from the monitored PDP/PDH channels.

Returns
The total energy drawn in Joules

◆ GetTotalPower()

double frc::PowerDistribution::GetTotalPower ( ) const

Query the total power drawn from all monitored PDP/PDH channels.

Returns
The total power drawn in Watts

◆ GetType()

ModuleType frc::PowerDistribution::GetType ( ) const

Gets module type.

◆ GetVersion()

Version frc::PowerDistribution::GetVersion ( ) const

◆ GetVoltage()

double frc::PowerDistribution::GetVoltage ( ) const

Query the input voltage of the PDP/PDH.

Returns
The input voltage in volts

◆ InitSendable()

void frc::PowerDistribution::InitSendable ( wpi::SendableBuilder builder)
overridevirtual

Initializes this Sendable object.

Parameters
buildersendable builder

Implements wpi::Sendable.

◆ operator=()

PowerDistribution & frc::PowerDistribution::operator= ( PowerDistribution &&  )
default

◆ ResetTotalEnergy()

void frc::PowerDistribution::ResetTotalEnergy ( )

Reset the total energy drawn from the PDP/PDH.

See also
PowerDistribution::GetTotalEnergy

◆ SetSwitchableChannel()

void frc::PowerDistribution::SetSwitchableChannel ( bool  enabled)

Sets the PDH switchable channel on or off.

Does nothing with the CTRE PDP.

Parameters
enabledWhether to turn the PDH switchable channel on or off

Member Data Documentation

◆ kDefaultModule

constexpr int frc::PowerDistribution::kDefaultModule = -1
staticconstexpr

The documentation for this class was generated from the following file: