summaryrefslogtreecommitdiff
path: root/smartdashboard/src/edu
diff options
context:
space:
mode:
authorJoe Ross <git@rossesmail.com>2014-12-29 21:14:14 -0800
committerJoe Ross <git@rossesmail.com>2014-12-29 21:14:14 -0800
commit323ed0e5dce074774007d1c03f79c34fd55459f0 (patch)
tree965c9f9496f5e0a8f8984d81d7f788c8b3dff923 /smartdashboard/src/edu
parent1837ad8fb133d0e27841d8a07a3f62c1704ded63 (diff)
Add LiveWindow widget for PDP.
Change-Id: Ic31f3e15a48c9b0c6586085d0fdfa2d8d1609bb7
Diffstat (limited to 'smartdashboard/src/edu')
-rw-r--r--smartdashboard/src/edu/wpi/first/smartdashboard/livewindow/elements/LiveWindowWidgetRegistrar.java1
-rw-r--r--smartdashboard/src/edu/wpi/first/smartdashboard/livewindow/elements/PowerDistributionPanel.java91
-rw-r--r--smartdashboard/src/edu/wpi/first/smartdashboard/types/named/PowerDistributionPanelType.java31
3 files changed, 123 insertions, 0 deletions
diff --git a/smartdashboard/src/edu/wpi/first/smartdashboard/livewindow/elements/LiveWindowWidgetRegistrar.java b/smartdashboard/src/edu/wpi/first/smartdashboard/livewindow/elements/LiveWindowWidgetRegistrar.java
index 261360b..d6b660f 100644
--- a/smartdashboard/src/edu/wpi/first/smartdashboard/livewindow/elements/LiveWindowWidgetRegistrar.java
+++ b/smartdashboard/src/edu/wpi/first/smartdashboard/livewindow/elements/LiveWindowWidgetRegistrar.java
@@ -21,6 +21,7 @@ public class LiveWindowWidgetRegistrar {
DisplayElementRegistry.registerWidget(GyroDisplay.class);
DisplayElementRegistry.registerWidget(EncoderDisplay.class);
DisplayElementRegistry.registerWidget(ServoController.class);
+ DisplayElementRegistry.registerWidget(PowerDistributionPanel.class);
}
}
diff --git a/smartdashboard/src/edu/wpi/first/smartdashboard/livewindow/elements/PowerDistributionPanel.java b/smartdashboard/src/edu/wpi/first/smartdashboard/livewindow/elements/PowerDistributionPanel.java
new file mode 100644
index 0000000..123d33a
--- /dev/null
+++ b/smartdashboard/src/edu/wpi/first/smartdashboard/livewindow/elements/PowerDistributionPanel.java
@@ -0,0 +1,91 @@
+package edu.wpi.first.smartdashboard.livewindow.elements;
+
+import edu.wpi.first.smartdashboard.gui.elements.bindings.AbstractTableWidget;
+import edu.wpi.first.smartdashboard.properties.Property;
+import edu.wpi.first.smartdashboard.types.DataType;
+import edu.wpi.first.smartdashboard.types.named.PowerDistributionPanelType;
+import edu.wpi.first.wpilibj.tables.ITableListener;
+import java.awt.Dimension;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import javax.swing.BoxLayout;
+import javax.swing.JLabel;
+
+
+/**
+ * Displays the current and voltage from the PDP
+ */
+public class PowerDistributionPanel extends AbstractTableWidget implements ITableListener {
+
+ public static final DataType[] TYPES = {PowerDistributionPanelType.get()};
+
+ private final UneditableNumberField voltage = new UneditableNumberField();
+ private final UneditableNumberField totCurrent = new UneditableNumberField();
+ private final UneditableNumberField current[] = new UneditableNumberField[16];
+ private final JLabel[] curLabel = new JLabel[16];
+ private JLabel totCurLabel;
+ private JLabel voltageLabel;
+
+ /**
+ * @inheritdoc
+ */
+ public void init() {
+ setLayout(new GridBagLayout());
+ GridBagConstraints c = new GridBagConstraints();
+
+ nameTag = new NameTag(getFieldName());
+ add(nameTag);
+ for (int i=0; i<8; i++) {
+ c.gridx=0;
+ c.gridy = i+1;
+ curLabel[i] = new JLabel("Chan" + i);
+ curLabel[i].setHorizontalAlignment(JLabel.RIGHT);
+ add(curLabel[i],c);
+ c.gridx=1;
+ current[i]=new UneditableNumberField();
+ setNumberBinding("Chan" + i, current[i]);
+ current[i].setColumns(6);
+ add(current[i],c);
+ }
+ for (int i=8; i<16; i++) {
+ c.gridx=2;
+ c.gridy = 16-i;
+ curLabel[i] = new JLabel("Chan" + i);
+ curLabel[i].setHorizontalAlignment(JLabel.RIGHT);
+ add(curLabel[i],c);
+ c.gridx=3;
+ current[i]=new UneditableNumberField();
+ setNumberBinding("Chan" + i, current[i]);
+ current[i].setColumns(6);
+ add(current[i],c);
+ }
+
+ c.gridy=9;
+ c.gridx=0;
+ voltageLabel = new JLabel("Voltage");
+ add(voltageLabel, c);
+ c.gridx=1;
+ voltage.setFocusable(false);
+ setNumberBinding("Voltage", voltage);
+ voltage.setColumns(5);
+ add(voltage,c);
+
+ c.gridx=2;
+ totCurLabel = new JLabel("TotalCurrent");
+ add(totCurLabel,c);
+ c.gridx=3;
+ setNumberBinding("TotalCurrent", totCurrent);
+ totCurrent.setColumns(7);
+ add(totCurrent,c);
+
+ setMaximumSize(new Dimension(Integer.MAX_VALUE, getPreferredSize().height));
+
+ revalidate();
+ repaint();
+ }
+
+ @Override
+ public void propertyChanged(Property property) {
+ }
+
+}
diff --git a/smartdashboard/src/edu/wpi/first/smartdashboard/types/named/PowerDistributionPanelType.java b/smartdashboard/src/edu/wpi/first/smartdashboard/types/named/PowerDistributionPanelType.java
new file mode 100644
index 0000000..d185e3c
--- /dev/null
+++ b/smartdashboard/src/edu/wpi/first/smartdashboard/types/named/PowerDistributionPanelType.java
@@ -0,0 +1,31 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package edu.wpi.first.smartdashboard.types.named;
+
+import edu.wpi.first.smartdashboard.livewindow.elements.PowerDistributionPanel;
+import edu.wpi.first.smartdashboard.livewindow.elements.SingleNumberDisplay;
+import edu.wpi.first.smartdashboard.types.NamedDataType;
+
+/**
+ *
+ * @author Sam
+ */
+public class PowerDistributionPanelType extends NamedDataType {
+
+ public static final String LABEL = "PowerDistributionPanel";
+
+ private PowerDistributionPanelType() {
+ super(LABEL, PowerDistributionPanel.class);
+ }
+
+ public static NamedDataType get() {
+ if (NamedDataType.get(LABEL) != null) {
+ return NamedDataType.get(LABEL);
+ } else {
+ return new PowerDistributionPanelType();
+ }
+ }
+
+} \ No newline at end of file