mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-01 02:41:48 +00:00
Add PDP to LiveWindow for C++
Change-Id: I45967739b81090e809b9e8f1c31ad7ff58554ec1
This commit is contained in:
@@ -9,12 +9,13 @@
|
||||
#define __WPILIB_POWER_DISTRIBUTION_PANEL_H__
|
||||
|
||||
#include "SensorBase.h"
|
||||
#include "LiveWindow/LiveWindowSendable.h"
|
||||
|
||||
/**
|
||||
* Class for getting voltage, current, and temperature from the CAN PDP
|
||||
* @author Thomas Clark
|
||||
*/
|
||||
class PowerDistributionPanel : public SensorBase {
|
||||
class PowerDistributionPanel : public SensorBase, public LiveWindowSendable {
|
||||
public:
|
||||
PowerDistributionPanel();
|
||||
|
||||
@@ -26,6 +27,16 @@ class PowerDistributionPanel : public SensorBase {
|
||||
double GetTotalEnergy();
|
||||
void ResetTotalEnergy();
|
||||
void ClearStickyFaults();
|
||||
|
||||
void UpdateTable();
|
||||
void StartLiveWindowMode();
|
||||
void StopLiveWindowMode();
|
||||
std::string GetSmartDashboardType();
|
||||
void InitTable(ITable *subTable);
|
||||
ITable * GetTable();
|
||||
|
||||
private:
|
||||
ITable *m_table;
|
||||
};
|
||||
|
||||
#endif /* __WPILIB_POWER_DISTRIBUTION_PANEL_H__ */
|
||||
|
||||
@@ -7,11 +7,13 @@
|
||||
#include "PowerDistributionPanel.h"
|
||||
#include "WPIErrors.h"
|
||||
#include "HAL/PDP.hpp"
|
||||
#include "LiveWindow/LiveWindow.h"
|
||||
|
||||
/**
|
||||
* Initialize the PDP.
|
||||
*/
|
||||
PowerDistributionPanel::PowerDistributionPanel() {
|
||||
m_table=NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,3 +154,44 @@ PowerDistributionPanel::ClearStickyFaults() {
|
||||
}
|
||||
}
|
||||
|
||||
void PowerDistributionPanel::UpdateTable() {
|
||||
if (m_table != NULL) {
|
||||
m_table->PutNumber("Chan0", GetCurrent(0));
|
||||
m_table->PutNumber("Chan1", GetCurrent(1));
|
||||
m_table->PutNumber("Chan2", GetCurrent(2));
|
||||
m_table->PutNumber("Chan3", GetCurrent(3));
|
||||
m_table->PutNumber("Chan4", GetCurrent(4));
|
||||
m_table->PutNumber("Chan5", GetCurrent(5));
|
||||
m_table->PutNumber("Chan6", GetCurrent(6));
|
||||
m_table->PutNumber("Chan7", GetCurrent(7));
|
||||
m_table->PutNumber("Chan8", GetCurrent(8));
|
||||
m_table->PutNumber("Chan9", GetCurrent(9));
|
||||
m_table->PutNumber("Chan10", GetCurrent(10));
|
||||
m_table->PutNumber("Chan11", GetCurrent(11));
|
||||
m_table->PutNumber("Chan12", GetCurrent(12));
|
||||
m_table->PutNumber("Chan13", GetCurrent(13));
|
||||
m_table->PutNumber("Chan14", GetCurrent(14));
|
||||
m_table->PutNumber("Chan15", GetCurrent(15));
|
||||
m_table->PutNumber("Voltage", GetVoltage());
|
||||
m_table->PutNumber("TotalCurrent", GetTotalCurrent());
|
||||
}
|
||||
}
|
||||
|
||||
void PowerDistributionPanel::StartLiveWindowMode() {
|
||||
}
|
||||
|
||||
void PowerDistributionPanel::StopLiveWindowMode() {
|
||||
}
|
||||
|
||||
std::string PowerDistributionPanel::GetSmartDashboardType() {
|
||||
return "PowerDistributionPanel";
|
||||
}
|
||||
|
||||
void PowerDistributionPanel::InitTable(ITable *subTable) {
|
||||
m_table = subTable;
|
||||
UpdateTable();
|
||||
}
|
||||
|
||||
ITable * PowerDistributionPanel::GetTable() {
|
||||
return m_table;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user