From ceccd950840a7e93b48afe051c2463907d0edec5 Mon Sep 17 00:00:00 2001 From: Joe Ross Date: Tue, 30 Dec 2014 12:02:13 -0800 Subject: [PATCH] Add PDP to LiveWindow for C++ Change-Id: I45967739b81090e809b9e8f1c31ad7ff58554ec1 --- .../include/PowerDistributionPanel.h | 13 +++++- .../src/PowerDistributionPanel.cpp | 43 +++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/wpilibc/wpilibC++Devices/include/PowerDistributionPanel.h b/wpilibc/wpilibC++Devices/include/PowerDistributionPanel.h index 31e228ca06..ef89b3fdfe 100644 --- a/wpilibc/wpilibC++Devices/include/PowerDistributionPanel.h +++ b/wpilibc/wpilibC++Devices/include/PowerDistributionPanel.h @@ -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__ */ diff --git a/wpilibc/wpilibC++Devices/src/PowerDistributionPanel.cpp b/wpilibc/wpilibC++Devices/src/PowerDistributionPanel.cpp index b124536a3f..330e6954a6 100644 --- a/wpilibc/wpilibC++Devices/src/PowerDistributionPanel.cpp +++ b/wpilibc/wpilibC++Devices/src/PowerDistributionPanel.cpp @@ -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; +}