From 230fa2d1688c1e5b359da527c70ce24fa7efd978 Mon Sep 17 00:00:00 2001 From: Joe Ross Date: Mon, 29 Dec 2014 21:10:21 -0800 Subject: [PATCH] Add PDP LiveWindow code Change-Id: Ia3f4d8118d9068d021994fd2e5aca676d7dfa979 --- .../first/wpilibj/PowerDistributionPanel.java | 65 ++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/PowerDistributionPanel.java b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/PowerDistributionPanel.java index b546d59394..a522c5368e 100644 --- a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/PowerDistributionPanel.java +++ b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/PowerDistributionPanel.java @@ -12,13 +12,15 @@ import java.nio.ByteOrder; import edu.wpi.first.wpilibj.hal.PDPJNI; import edu.wpi.first.wpilibj.hal.HALUtil; +import edu.wpi.first.wpilibj.livewindow.LiveWindow; import edu.wpi.first.wpilibj.livewindow.LiveWindowSendable; +import edu.wpi.first.wpilibj.tables.ITable; /** * Class for getting voltage, current, and temperature from the CAN PDP * @author Thomas Clark */ -public class PowerDistributionPanel extends SensorBase { +public class PowerDistributionPanel extends SensorBase implements LiveWindowSendable { public PowerDistributionPanel() { } @@ -122,5 +124,66 @@ public class PowerDistributionPanel extends SensorBase { PDPJNI.clearPDPStickyFaults(status.asIntBuffer()); } + + public String getSmartDashboardType() { + return "PowerDistributionPanel"; + } + /* + * Live Window code, only does anything if live window is activated. + */ + private ITable m_table; + + /** + * {@inheritDoc} + */ + public void initTable(ITable subtable) { + m_table = subtable; + updateTable(); + } + + /** + * {@inheritDoc} + */ + public ITable getTable() { + return m_table; + } + + /** + * {@inheritDoc} + */ + public void 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()); + } + } + + /** + * PDP doesn't have to do anything special when entering the LiveWindow. + * {@inheritDoc} + */ + public void startLiveWindowMode() {} + + /** + * PDP doesn't have to do anything special when exiting the LiveWindow. + * {@inheritDoc} + */ + public void stopLiveWindowMode() {} }