2020-12-26 14:12:05 -08:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
2014-05-30 14:04:05 -04:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2018-10-29 12:49:17 -07:00
|
|
|
#include <hal/Types.h>
|
2018-09-24 00:08:25 -07:00
|
|
|
|
2019-09-14 15:22:54 -05:00
|
|
|
#include "frc/smartdashboard/Sendable.h"
|
|
|
|
|
#include "frc/smartdashboard/SendableHelper.h"
|
2014-05-30 14:04:05 -04:00
|
|
|
|
2016-11-01 22:33:12 -07:00
|
|
|
namespace frc {
|
|
|
|
|
|
2019-09-14 15:22:54 -05:00
|
|
|
class SendableBuilder;
|
|
|
|
|
|
2014-05-30 14:04:05 -04:00
|
|
|
/**
|
2015-06-25 15:07:55 -04:00
|
|
|
* Class for getting voltage, current, temperature, power and energy from the
|
|
|
|
|
* CAN PDP.
|
2014-05-30 14:04:05 -04:00
|
|
|
*/
|
2021-04-18 20:35:29 -07:00
|
|
|
class PowerDistributionPanel : public Sendable,
|
2019-09-14 15:22:54 -05:00
|
|
|
public SendableHelper<PowerDistributionPanel> {
|
2015-06-25 15:07:55 -04:00
|
|
|
public:
|
2021-06-10 00:02:51 -07:00
|
|
|
/**
|
|
|
|
|
* Constructs a PowerDistributionPanel.
|
|
|
|
|
*
|
|
|
|
|
* Uses the default CAN ID (0).
|
|
|
|
|
*/
|
2015-06-25 15:07:55 -04:00
|
|
|
PowerDistributionPanel();
|
2021-06-10 00:02:51 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructs a PowerDistributionPanel.
|
|
|
|
|
*
|
|
|
|
|
* @param module The CAN ID of the PDP
|
|
|
|
|
*/
|
2016-09-06 00:01:45 -07:00
|
|
|
explicit PowerDistributionPanel(int module);
|
2015-06-25 15:07:55 -04:00
|
|
|
|
2018-09-24 00:08:25 -07:00
|
|
|
PowerDistributionPanel(PowerDistributionPanel&&) = default;
|
|
|
|
|
PowerDistributionPanel& operator=(PowerDistributionPanel&&) = default;
|
|
|
|
|
|
2018-05-31 20:47:15 -07:00
|
|
|
/**
|
|
|
|
|
* Query the input voltage of the PDP.
|
|
|
|
|
*
|
|
|
|
|
* @return The voltage of the PDP in volts
|
|
|
|
|
*/
|
2016-11-20 07:25:03 -08:00
|
|
|
double GetVoltage() const;
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Query the temperature of the PDP.
|
|
|
|
|
*
|
|
|
|
|
* @return The temperature of the PDP in degrees Celsius
|
|
|
|
|
*/
|
2016-11-20 07:25:03 -08:00
|
|
|
double GetTemperature() const;
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Query the current of a single channel of the PDP.
|
|
|
|
|
*
|
|
|
|
|
* @return The current of one of the PDP channels (channels 0-15) in Amperes
|
|
|
|
|
*/
|
2016-11-20 07:25:03 -08:00
|
|
|
double GetCurrent(int channel) const;
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Query the total current of all monitored PDP channels (0-15).
|
|
|
|
|
*
|
|
|
|
|
* @return The the total current drawn from the PDP channels in Amperes
|
|
|
|
|
*/
|
2016-11-20 07:25:03 -08:00
|
|
|
double GetTotalCurrent() const;
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Query the total power drawn from the monitored PDP channels.
|
|
|
|
|
*
|
|
|
|
|
* @return The the total power drawn from the PDP channels in Watts
|
|
|
|
|
*/
|
2016-11-20 07:25:03 -08:00
|
|
|
double GetTotalPower() const;
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Query the total energy drawn from the monitored PDP channels.
|
|
|
|
|
*
|
|
|
|
|
* @return The the total energy drawn from the PDP channels in Joules
|
|
|
|
|
*/
|
2016-11-20 07:25:03 -08:00
|
|
|
double GetTotalEnergy() const;
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Reset the total energy drawn from the PDP.
|
|
|
|
|
*
|
|
|
|
|
* @see PowerDistributionPanel#GetTotalEnergy
|
|
|
|
|
*/
|
2015-06-25 15:07:55 -04:00
|
|
|
void ResetTotalEnergy();
|
2018-05-31 20:47:15 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Remove all of the fault flags on the PDP.
|
|
|
|
|
*/
|
2015-06-25 15:07:55 -04:00
|
|
|
void ClearStickyFaults();
|
2014-12-30 12:02:13 -08:00
|
|
|
|
2020-07-04 10:10:43 -07:00
|
|
|
/**
|
|
|
|
|
* Gets module number (CAN ID).
|
|
|
|
|
*/
|
|
|
|
|
int GetModule() const;
|
|
|
|
|
|
2017-12-04 23:28:33 -08:00
|
|
|
void InitSendable(SendableBuilder& builder) override;
|
2014-12-30 12:02:13 -08:00
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
private:
|
2019-08-25 18:42:00 -07:00
|
|
|
hal::Handle<HAL_PDPHandle> m_handle;
|
2020-07-04 10:10:43 -07:00
|
|
|
int m_module;
|
2014-05-30 14:04:05 -04:00
|
|
|
};
|
2016-11-01 22:33:12 -07:00
|
|
|
|
|
|
|
|
} // namespace frc
|