From 8463ffcaca6bcd31e645aba71c171f548dce96d8 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 13 Nov 2010 15:19:14 -0800 Subject: altosui: Eliminate unncessary import altosui lines Java appears to automatically import every module from the current package. Signed-off-by: Keith Packard --- ao-tools/altosui/AltosCSVUI.java | 3 --- ao-tools/altosui/AltosConfig.java | 14 -------------- ao-tools/altosui/AltosConfigUI.java | 13 ------------- ao-tools/altosui/AltosDataPointReader.java | 5 ----- ao-tools/altosui/AltosDebug.java | 2 -- ao-tools/altosui/AltosDeviceDialog.java | 1 - ao-tools/altosui/AltosEepromDownload.java | 12 ------------ ao-tools/altosui/AltosEepromIterable.java | 8 -------- ao-tools/altosui/AltosEepromMonitor.java | 10 ---------- ao-tools/altosui/AltosEepromRecord.java | 11 ----------- ao-tools/altosui/AltosFile.java | 2 -- ao-tools/altosui/AltosFlash.java | 2 -- ao-tools/altosui/AltosFlashUI.java | 3 --- ao-tools/altosui/AltosGPS.java | 2 -- ao-tools/altosui/AltosGraph.java | 2 -- ao-tools/altosui/AltosGraphDataChooser.java | 5 ----- ao-tools/altosui/AltosGraphTime.java | 3 --- ao-tools/altosui/AltosGraphUI.java | 3 --- ao-tools/altosui/AltosGreatCircle.java | 2 -- ao-tools/altosui/AltosInfoTable.java | 3 --- ao-tools/altosui/AltosLog.java | 3 --- ao-tools/altosui/AltosParse.java | 2 -- ao-tools/altosui/AltosReader.java | 2 -- ao-tools/altosui/AltosRecord.java | 2 -- ao-tools/altosui/AltosRecordIterable.java | 8 -------- ao-tools/altosui/AltosRomconfig.java | 1 - ao-tools/altosui/AltosRomconfigUI.java | 2 -- ao-tools/altosui/AltosSerial.java | 9 ++------- ao-tools/altosui/AltosState.java | 3 --- ao-tools/altosui/AltosStatusTable.java | 3 --- ao-tools/altosui/AltosTelemetry.java | 4 ---- ao-tools/altosui/AltosTelemetryIterable.java | 1 - ao-tools/altosui/AltosUI.java | 19 ------------------- 33 files changed, 2 insertions(+), 163 deletions(-) diff --git a/ao-tools/altosui/AltosCSVUI.java b/ao-tools/altosui/AltosCSVUI.java index eb620ba8..16f25338 100644 --- a/ao-tools/altosui/AltosCSVUI.java +++ b/ao-tools/altosui/AltosCSVUI.java @@ -28,9 +28,6 @@ import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; -import altosui.AltosLogfileChooser; -import altosui.AltosCSV; - public class AltosCSVUI extends JDialog implements Runnable, ActionListener diff --git a/ao-tools/altosui/AltosConfig.java b/ao-tools/altosui/AltosConfig.java index b7474f3b..30f7d541 100644 --- a/ao-tools/altosui/AltosConfig.java +++ b/ao-tools/altosui/AltosConfig.java @@ -28,20 +28,6 @@ import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; -import altosui.Altos; -import altosui.AltosSerial; -import altosui.AltosSerialMonitor; -import altosui.AltosRecord; -import altosui.AltosTelemetry; -import altosui.AltosState; -import altosui.AltosDeviceDialog; -import altosui.AltosPreferences; -import altosui.AltosLog; -import altosui.AltosVoice; -import altosui.AltosFlightStatusTableModel; -import altosui.AltosFlightInfoTableModel; -import altosui.AltosConfigUI; - import libaltosJNI.*; public class AltosConfig implements Runnable, ActionListener { diff --git a/ao-tools/altosui/AltosConfigUI.java b/ao-tools/altosui/AltosConfigUI.java index 37128573..9e3856b0 100644 --- a/ao-tools/altosui/AltosConfigUI.java +++ b/ao-tools/altosui/AltosConfigUI.java @@ -29,19 +29,6 @@ import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; -import altosui.Altos; -import altosui.AltosSerial; -import altosui.AltosSerialMonitor; -import altosui.AltosRecord; -import altosui.AltosTelemetry; -import altosui.AltosState; -import altosui.AltosDeviceDialog; -import altosui.AltosPreferences; -import altosui.AltosLog; -import altosui.AltosVoice; -import altosui.AltosFlightStatusTableModel; -import altosui.AltosFlightInfoTableModel; - import libaltosJNI.*; public class AltosConfigUI diff --git a/ao-tools/altosui/AltosDataPointReader.java b/ao-tools/altosui/AltosDataPointReader.java index 4d7831e4..7704310b 100644 --- a/ao-tools/altosui/AltosDataPointReader.java +++ b/ao-tools/altosui/AltosDataPointReader.java @@ -10,11 +10,6 @@ import java.lang.UnsupportedOperationException; import java.util.NoSuchElementException; import java.util.Iterator; -import altosui.AltosDataPoint; -import altosui.AltosRecordIterable; -import altosui.AltosRecord; -import altosui.AltosState; - class AltosDataPointReader implements Iterable { Iterator iter; AltosState state; diff --git a/ao-tools/altosui/AltosDebug.java b/ao-tools/altosui/AltosDebug.java index 3f469d48..9c10129d 100644 --- a/ao-tools/altosui/AltosDebug.java +++ b/ao-tools/altosui/AltosDebug.java @@ -22,8 +22,6 @@ import java.io.*; import java.util.concurrent.LinkedBlockingQueue; import java.util.LinkedList; import java.util.Iterator; -import altosui.AltosSerial; -import altosui.AltosRomconfig; public class AltosDebug extends AltosSerial { diff --git a/ao-tools/altosui/AltosDeviceDialog.java b/ao-tools/altosui/AltosDeviceDialog.java index ec78e288..2966ad1e 100644 --- a/ao-tools/altosui/AltosDeviceDialog.java +++ b/ao-tools/altosui/AltosDeviceDialog.java @@ -26,7 +26,6 @@ import libaltosJNI.libaltos; import libaltosJNI.altos_device; import libaltosJNI.SWIGTYPE_p_altos_file; import libaltosJNI.SWIGTYPE_p_altos_list; -import altosui.AltosDevice; public class AltosDeviceDialog extends JDialog implements ActionListener { diff --git a/ao-tools/altosui/AltosEepromDownload.java b/ao-tools/altosui/AltosEepromDownload.java index 8efc94d2..bd9e4b48 100644 --- a/ao-tools/altosui/AltosEepromDownload.java +++ b/ao-tools/altosui/AltosEepromDownload.java @@ -28,18 +28,6 @@ import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; -import altosui.Altos; -import altosui.AltosSerial; -import altosui.AltosSerialMonitor; -import altosui.AltosRecord; -import altosui.AltosTelemetry; -import altosui.AltosState; -import altosui.AltosDeviceDialog; -import altosui.AltosPreferences; -import altosui.AltosLog; -import altosui.AltosVoice; -import altosui.AltosEepromMonitor; - import libaltosJNI.*; public class AltosEepromDownload implements Runnable { diff --git a/ao-tools/altosui/AltosEepromIterable.java b/ao-tools/altosui/AltosEepromIterable.java index 2f1e7e90..fc683321 100644 --- a/ao-tools/altosui/AltosEepromIterable.java +++ b/ao-tools/altosui/AltosEepromIterable.java @@ -28,14 +28,6 @@ import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; -import altosui.AltosRecord; -import altosui.AltosState; -import altosui.AltosDeviceDialog; -import altosui.AltosPreferences; -import altosui.AltosLog; -import altosui.AltosVoice; -import altosui.AltosEepromMonitor; - /* * AltosRecords with an index field so they can be sorted by tick while preserving * the original ordering for elements with matching ticks diff --git a/ao-tools/altosui/AltosEepromMonitor.java b/ao-tools/altosui/AltosEepromMonitor.java index b88fdd29..7ff00ead 100644 --- a/ao-tools/altosui/AltosEepromMonitor.java +++ b/ao-tools/altosui/AltosEepromMonitor.java @@ -28,16 +28,6 @@ import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; -import altosui.AltosSerial; -import altosui.AltosSerialMonitor; -import altosui.AltosRecord; -import altosui.AltosTelemetry; -import altosui.AltosState; -import altosui.AltosDeviceDialog; -import altosui.AltosPreferences; -import altosui.AltosLog; -import altosui.AltosVoice; - public class AltosEepromMonitor extends JDialog { Container pane; diff --git a/ao-tools/altosui/AltosEepromRecord.java b/ao-tools/altosui/AltosEepromRecord.java index 95cbe015..5a673817 100644 --- a/ao-tools/altosui/AltosEepromRecord.java +++ b/ao-tools/altosui/AltosEepromRecord.java @@ -28,17 +28,6 @@ import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; -import altosui.AltosSerial; -import altosui.AltosSerialMonitor; -import altosui.AltosRecord; -import altosui.AltosTelemetry; -import altosui.AltosState; -import altosui.AltosDeviceDialog; -import altosui.AltosPreferences; -import altosui.AltosLog; -import altosui.AltosVoice; -import altosui.AltosEepromMonitor; - public class AltosEepromRecord { public int cmd; public int tick; diff --git a/ao-tools/altosui/AltosFile.java b/ao-tools/altosui/AltosFile.java index 7f65381f..06360572 100644 --- a/ao-tools/altosui/AltosFile.java +++ b/ao-tools/altosui/AltosFile.java @@ -20,8 +20,6 @@ package altosui; import java.lang.*; import java.io.File; import java.util.*; -import altosui.AltosTelemetry; -import altosui.AltosPreferences; class AltosFile extends File { diff --git a/ao-tools/altosui/AltosFlash.java b/ao-tools/altosui/AltosFlash.java index a3e431cd..25b4a06e 100644 --- a/ao-tools/altosui/AltosFlash.java +++ b/ao-tools/altosui/AltosFlash.java @@ -28,8 +28,6 @@ import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; -import altosui.AltosHexfile; - public class AltosFlash { File file; FileInputStream input; diff --git a/ao-tools/altosui/AltosFlashUI.java b/ao-tools/altosui/AltosFlashUI.java index 86f57a5f..70c8c549 100644 --- a/ao-tools/altosui/AltosFlashUI.java +++ b/ao-tools/altosui/AltosFlashUI.java @@ -28,9 +28,6 @@ import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; -import altosui.AltosHexfile; -import altosui.AltosFlash; - public class AltosFlashUI extends JDialog implements Runnable, ActionListener diff --git a/ao-tools/altosui/AltosGPS.java b/ao-tools/altosui/AltosGPS.java index acb6fb2c..83821842 100644 --- a/ao-tools/altosui/AltosGPS.java +++ b/ao-tools/altosui/AltosGPS.java @@ -19,8 +19,6 @@ package altosui; import java.lang.*; import java.text.*; -import altosui.AltosParse; - public class AltosGPS { public class AltosGPSSat { diff --git a/ao-tools/altosui/AltosGraph.java b/ao-tools/altosui/AltosGraph.java index fa3b87c1..58c27979 100644 --- a/ao-tools/altosui/AltosGraph.java +++ b/ao-tools/altosui/AltosGraph.java @@ -9,8 +9,6 @@ import java.io.*; import org.jfree.chart.JFreeChart; import org.jfree.chart.ChartUtilities; -import altosui.AltosDataPoint; - abstract class AltosGraph { public String filename; public abstract void addData(AltosDataPoint d); diff --git a/ao-tools/altosui/AltosGraphDataChooser.java b/ao-tools/altosui/AltosGraphDataChooser.java index caa14118..d128f4d5 100644 --- a/ao-tools/altosui/AltosGraphDataChooser.java +++ b/ao-tools/altosui/AltosGraphDataChooser.java @@ -27,11 +27,6 @@ import java.util.*; import java.text.*; import java.util.prefs.*; -import altosui.AltosPreferences; -import altosui.AltosDataPointReader; -import altosui.AltosEepromIterable; -import altosui.AltosTelemetryIterable; - public class AltosGraphDataChooser extends JFileChooser { JFrame frame; String filename; diff --git a/ao-tools/altosui/AltosGraphTime.java b/ao-tools/altosui/AltosGraphTime.java index ab01b888..a5451280 100644 --- a/ao-tools/altosui/AltosGraphTime.java +++ b/ao-tools/altosui/AltosGraphTime.java @@ -24,9 +24,6 @@ import org.jfree.data.xy.XYSeriesCollection; import org.jfree.ui.RectangleAnchor; import org.jfree.ui.TextAnchor; -import altosui.AltosDataPoint; -import altosui.AltosGraph; - class AltosGraphTime extends AltosGraph { static interface Element { void attachGraph(AltosGraphTime g); diff --git a/ao-tools/altosui/AltosGraphUI.java b/ao-tools/altosui/AltosGraphUI.java index 25643c76..908aa3b4 100644 --- a/ao-tools/altosui/AltosGraphUI.java +++ b/ao-tools/altosui/AltosGraphUI.java @@ -17,9 +17,6 @@ import org.jfree.chart.axis.AxisLocation; import org.jfree.ui.ApplicationFrame; import org.jfree.ui.RefineryUtilities; -import altosui.AltosDataPoint; -import altosui.AltosGraphTime; - public class AltosGraphUI extends JFrame { static final private Color red = new Color(194,31,31); diff --git a/ao-tools/altosui/AltosGreatCircle.java b/ao-tools/altosui/AltosGreatCircle.java index aa6ae3b9..fb1b6ab3 100644 --- a/ao-tools/altosui/AltosGreatCircle.java +++ b/ao-tools/altosui/AltosGreatCircle.java @@ -17,8 +17,6 @@ package altosui; -import altosui.AltosGPS; - import java.lang.Math; public class AltosGreatCircle { diff --git a/ao-tools/altosui/AltosInfoTable.java b/ao-tools/altosui/AltosInfoTable.java index 2f326e07..28924410 100644 --- a/ao-tools/altosui/AltosInfoTable.java +++ b/ao-tools/altosui/AltosInfoTable.java @@ -28,9 +28,6 @@ import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; -import altosui.AltosFlightInfoTableModel; -import altosui.AltosState; - public class AltosInfoTable { private Box box; private JTable table[]; diff --git a/ao-tools/altosui/AltosLog.java b/ao-tools/altosui/AltosLog.java index fed96c28..137147d5 100644 --- a/ao-tools/altosui/AltosLog.java +++ b/ao-tools/altosui/AltosLog.java @@ -22,9 +22,6 @@ import java.lang.*; import java.util.*; import java.text.ParseException; import java.util.concurrent.LinkedBlockingQueue; -import altosui.AltosSerial; -import altosui.AltosFile; -import altosui.AltosLine; /* * This creates a thread to capture telemetry data and write it to diff --git a/ao-tools/altosui/AltosParse.java b/ao-tools/altosui/AltosParse.java index 4d82de78..fbfcaaee 100644 --- a/ao-tools/altosui/AltosParse.java +++ b/ao-tools/altosui/AltosParse.java @@ -20,8 +20,6 @@ package altosui; import java.text.*; import java.lang.*; -import altosui.Altos; - public class AltosParse { static boolean isdigit(char c) { return '0' <= c && c <= '9'; diff --git a/ao-tools/altosui/AltosReader.java b/ao-tools/altosui/AltosReader.java index 5be8795d..b9280a0c 100644 --- a/ao-tools/altosui/AltosReader.java +++ b/ao-tools/altosui/AltosReader.java @@ -21,8 +21,6 @@ import java.io.*; import java.util.*; import java.text.*; -import altosui.AltosRecord; - public class AltosReader { public AltosRecord read() throws IOException, ParseException { return null; } public void close() { } diff --git a/ao-tools/altosui/AltosRecord.java b/ao-tools/altosui/AltosRecord.java index 00484767..1160a273 100644 --- a/ao-tools/altosui/AltosRecord.java +++ b/ao-tools/altosui/AltosRecord.java @@ -21,8 +21,6 @@ import java.lang.*; import java.text.*; import java.util.HashMap; import java.io.*; -import altosui.AltosConvert; -import altosui.AltosGPS; public class AltosRecord { int version; diff --git a/ao-tools/altosui/AltosRecordIterable.java b/ao-tools/altosui/AltosRecordIterable.java index 147ecc14..a7df92d1 100644 --- a/ao-tools/altosui/AltosRecordIterable.java +++ b/ao-tools/altosui/AltosRecordIterable.java @@ -28,14 +28,6 @@ import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; -import altosui.AltosRecord; -import altosui.AltosState; -import altosui.AltosDeviceDialog; -import altosui.AltosPreferences; -import altosui.AltosLog; -import altosui.AltosVoice; -import altosui.AltosEepromMonitor; - public abstract class AltosRecordIterable implements Iterable { public abstract Iterator iterator(); public void write_comments(PrintStream out) { } diff --git a/ao-tools/altosui/AltosRomconfig.java b/ao-tools/altosui/AltosRomconfig.java index 22d2dbd3..55056b5e 100644 --- a/ao-tools/altosui/AltosRomconfig.java +++ b/ao-tools/altosui/AltosRomconfig.java @@ -17,7 +17,6 @@ package altosui; import java.io.*; -import altosui.AltosHexfile; public class AltosRomconfig { public boolean valid; diff --git a/ao-tools/altosui/AltosRomconfigUI.java b/ao-tools/altosui/AltosRomconfigUI.java index 2134975d..e1dc974e 100644 --- a/ao-tools/altosui/AltosRomconfigUI.java +++ b/ao-tools/altosui/AltosRomconfigUI.java @@ -28,8 +28,6 @@ import java.util.*; import java.text.*; import java.util.prefs.*; -import altosui.AltosRomconfig; - public class AltosRomconfigUI extends JDialog implements ActionListener diff --git a/ao-tools/altosui/AltosSerial.java b/ao-tools/altosui/AltosSerial.java index d6848e57..6787e0c8 100644 --- a/ao-tools/altosui/AltosSerial.java +++ b/ao-tools/altosui/AltosSerial.java @@ -26,13 +26,8 @@ import java.io.*; import java.util.concurrent.LinkedBlockingQueue; import java.util.LinkedList; import java.util.Iterator; -import altosui.AltosSerialMonitor; -import altosui.AltosLine; -import libaltosJNI.libaltos; -import libaltosJNI.altos_device; -import libaltosJNI.SWIGTYPE_p_altos_file; -import libaltosJNI.SWIGTYPE_p_altos_list; -import libaltosJNI.libaltosConstants; + +import libaltosJNI.*; /* * This class reads from the serial port and places each received diff --git a/ao-tools/altosui/AltosState.java b/ao-tools/altosui/AltosState.java index 86eb636a..ec499d5a 100644 --- a/ao-tools/altosui/AltosState.java +++ b/ao-tools/altosui/AltosState.java @@ -21,9 +21,6 @@ package altosui; -import altosui.AltosRecord; -import altosui.AltosGPS; - public class AltosState { AltosRecord data; diff --git a/ao-tools/altosui/AltosStatusTable.java b/ao-tools/altosui/AltosStatusTable.java index 0d3a5d14..02c6232f 100644 --- a/ao-tools/altosui/AltosStatusTable.java +++ b/ao-tools/altosui/AltosStatusTable.java @@ -28,9 +28,6 @@ import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; -import altosui.AltosFlightStatusTableModel; -import altosui.AltosFlightInfoTableModel; - public class AltosStatusTable extends JTable { private AltosFlightStatusTableModel flightStatusModel; diff --git a/ao-tools/altosui/AltosTelemetry.java b/ao-tools/altosui/AltosTelemetry.java index be22dac6..bdb6466a 100644 --- a/ao-tools/altosui/AltosTelemetry.java +++ b/ao-tools/altosui/AltosTelemetry.java @@ -20,10 +20,6 @@ package altosui; import java.lang.*; import java.text.*; import java.util.HashMap; -import altosui.AltosConvert; -import altosui.AltosRecord; -import altosui.AltosGPS; -import altosui.AltosCRCException; /* * Telemetry data contents diff --git a/ao-tools/altosui/AltosTelemetryIterable.java b/ao-tools/altosui/AltosTelemetryIterable.java index 0a125c98..a71ab872 100644 --- a/ao-tools/altosui/AltosTelemetryIterable.java +++ b/ao-tools/altosui/AltosTelemetryIterable.java @@ -20,7 +20,6 @@ package altosui; import java.io.*; import java.util.*; import java.text.*; -import altosui.AltosTelemetry; public class AltosTelemetryIterable extends AltosRecordIterable { LinkedList records; diff --git a/ao-tools/altosui/AltosUI.java b/ao-tools/altosui/AltosUI.java index 2861444d..9ab451de 100644 --- a/ao-tools/altosui/AltosUI.java +++ b/ao-tools/altosui/AltosUI.java @@ -28,25 +28,6 @@ import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; -import altosui.Altos; -import altosui.AltosSerial; -import altosui.AltosSerialMonitor; -import altosui.AltosRecord; -import altosui.AltosTelemetry; -import altosui.AltosState; -import altosui.AltosDeviceDialog; -import altosui.AltosPreferences; -import altosui.AltosLog; -import altosui.AltosVoice; -import altosui.AltosFlightInfoTableModel; -import altosui.AltosFlashUI; -import altosui.AltosLogfileChooser; -import altosui.AltosCSVUI; -import altosui.AltosLine; -import altosui.AltosStatusTable; -import altosui.AltosInfoTable; -import altosui.AltosDisplayThread; - import libaltosJNI.*; public class AltosUI extends JFrame { -- cgit v1.2.3 From dcfa56498d1b65a213b8aba9cbd6c4806532383c Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 13 Nov 2010 16:07:04 -0800 Subject: altosui: Open serial device at 'new' time. Prohibit duplicate opens. With the per-serial UI, there's never a reason to create a serial device without opening it right away. This eliminates the bug caused by not opening the serial device for telemetry reception. Serial devices can now be opened only once; this eliminates errors when trying to reflash or configure devices while receiving telemetry. Signed-off-by: Keith Packard --- ao-tools/altosui/AltosConfig.java | 9 +++++++-- ao-tools/altosui/AltosDebug.java | 11 ++++++++--- ao-tools/altosui/AltosEepromDownload.java | 9 +++++++-- ao-tools/altosui/AltosFlash.java | 13 +++++-------- ao-tools/altosui/AltosFlashUI.java | 11 ++++++++--- ao-tools/altosui/AltosSerial.java | 28 +++++++++++++++++----------- ao-tools/altosui/AltosTelemetryReader.java | 5 +++-- ao-tools/altosui/AltosUI.java | 6 ++++++ ao-tools/altosui/Makefile.am | 1 + 9 files changed, 62 insertions(+), 31 deletions(-) diff --git a/ao-tools/altosui/AltosConfig.java b/ao-tools/altosui/AltosConfig.java index 30f7d541..09e204a9 100644 --- a/ao-tools/altosui/AltosConfig.java +++ b/ao-tools/altosui/AltosConfig.java @@ -231,10 +231,9 @@ public class AltosConfig implements Runnable, ActionListener { product = new string_ref("unknown"); device = AltosDeviceDialog.show(owner, AltosDevice.product_any); - serial_line = new AltosSerial(); if (device != null) { try { - serial_line.open(device); + serial_line = new AltosSerial(device); if (!device.matchProduct(AltosDevice.product_telemetrum)) remote = true; config_thread = new Thread(this); @@ -245,6 +244,12 @@ public class AltosConfig implements Runnable, ActionListener { device.getPath()), "Cannot open target device", JOptionPane.ERROR_MESSAGE); + } catch (AltosSerialInUseException si) { + JOptionPane.showMessageDialog(owner, + String.format("Device \"%s\" already in use", + device.getPath()), + "Device in use", + JOptionPane.ERROR_MESSAGE); } catch (IOException ee) { JOptionPane.showMessageDialog(owner, device.getPath(), diff --git a/ao-tools/altosui/AltosDebug.java b/ao-tools/altosui/AltosDebug.java index 9c10129d..9aa35d3f 100644 --- a/ao-tools/altosui/AltosDebug.java +++ b/ao-tools/altosui/AltosDebug.java @@ -19,9 +19,10 @@ package altosui; import java.lang.*; import java.io.*; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.LinkedList; -import java.util.Iterator; +import java.util.concurrent.*; +import java.util.*; + +import libaltosJNI.*; public class AltosDebug extends AltosSerial { @@ -259,4 +260,8 @@ public class AltosDebug extends AltosSerial { public void reset() { printf ("R\n"); } + + public AltosDebug (altos_device in_device) throws FileNotFoundException, AltosSerialInUseException { + super(in_device); + } } \ No newline at end of file diff --git a/ao-tools/altosui/AltosEepromDownload.java b/ao-tools/altosui/AltosEepromDownload.java index bd9e4b48..8996b924 100644 --- a/ao-tools/altosui/AltosEepromDownload.java +++ b/ao-tools/altosui/AltosEepromDownload.java @@ -244,12 +244,11 @@ public class AltosEepromDownload implements Runnable { frame = given_frame; device = AltosDeviceDialog.show(frame, AltosDevice.product_any); - serial_line = new AltosSerial(); remote = false; if (device != null) { try { - serial_line.open(device); + serial_line = new AltosSerial(device); if (!device.matchProduct(AltosDevice.product_telemetrum)) remote = true; eeprom_thread = new Thread(this); @@ -260,6 +259,12 @@ public class AltosEepromDownload implements Runnable { device.getPath()), "Cannot open target device", JOptionPane.ERROR_MESSAGE); + } catch (AltosSerialInUseException si) { + JOptionPane.showMessageDialog(frame, + String.format("Device \"%s\" already in use", + device.getPath()), + "Device in use", + JOptionPane.ERROR_MESSAGE); } catch (IOException ee) { JOptionPane.showMessageDialog(frame, device.getPath(), diff --git a/ao-tools/altosui/AltosFlash.java b/ao-tools/altosui/AltosFlash.java index 25b4a06e..fa2465d3 100644 --- a/ao-tools/altosui/AltosFlash.java +++ b/ao-tools/altosui/AltosFlash.java @@ -329,17 +329,14 @@ public class AltosFlash { return rom_config; } - public void open() throws IOException, FileNotFoundException, InterruptedException { + public AltosFlash(File in_file, AltosDevice in_debug_dongle) + throws IOException, FileNotFoundException, AltosSerialInUseException, InterruptedException { + file = in_file; + debug_dongle = in_debug_dongle; + debug = new AltosDebug(in_debug_dongle); input = new FileInputStream(file); image = new AltosHexfile(input); - debug.open(debug_dongle); if (!debug.check_connection()) throw new IOException("Debug port not connected"); } - - public AltosFlash(File in_file, AltosDevice in_debug_dongle) { - file = in_file; - debug_dongle = in_debug_dongle; - debug = new AltosDebug(); - } } \ No newline at end of file diff --git a/ao-tools/altosui/AltosFlashUI.java b/ao-tools/altosui/AltosFlashUI.java index 70c8c549..b09cb594 100644 --- a/ao-tools/altosui/AltosFlashUI.java +++ b/ao-tools/altosui/AltosFlashUI.java @@ -65,10 +65,9 @@ public class AltosFlashUI } public void run() { - flash = new AltosFlash(file, debug_dongle); - flash.addActionListener(this); try { - flash.open(); + flash = new AltosFlash(file, debug_dongle); + flash.addActionListener(this); AltosRomconfigUI romconfig_ui = new AltosRomconfigUI (frame); romconfig_ui.set(flash.romconfig()); @@ -88,6 +87,12 @@ public class AltosFlashUI "Cannot open image", file.toString(), JOptionPane.ERROR_MESSAGE); + } catch (AltosSerialInUseException si) { + JOptionPane.showMessageDialog(frame, + String.format("Device \"%s\" already in use", + debug_dongle.getPath()), + "Device in use", + JOptionPane.ERROR_MESSAGE); } catch (IOException e) { JOptionPane.showMessageDialog(frame, e.getMessage(), diff --git a/ao-tools/altosui/AltosSerial.java b/ao-tools/altosui/AltosSerial.java index 6787e0c8..99a92fdb 100644 --- a/ao-tools/altosui/AltosSerial.java +++ b/ao-tools/altosui/AltosSerial.java @@ -23,9 +23,8 @@ package altosui; import java.lang.*; import java.io.*; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.LinkedList; -import java.util.Iterator; +import java.util.concurrent.*; +import java.util.*; import libaltosJNI.*; @@ -37,6 +36,9 @@ import libaltosJNI.*; public class AltosSerial implements Runnable { + static List devices_opened = Collections.synchronizedList(new LinkedList()); + + altos_device device; SWIGTYPE_p_altos_file altos; LinkedList> monitors; LinkedBlockingQueue reply_queue; @@ -141,10 +143,6 @@ public class AltosSerial implements Runnable { set_monitor(false); } - public boolean opened() { - return altos != null; - } - public void close() { if (altos != null) { libaltos.altos_close(altos); @@ -161,6 +159,9 @@ public class AltosSerial implements Runnable { libaltos.altos_free(altos); altos = null; } + synchronized (devices_opened) { + devices_opened.remove(device.getPath()); + } } public void putc(char c) { @@ -178,7 +179,12 @@ public class AltosSerial implements Runnable { print(String.format(format, arguments)); } - public void open(altos_device device) throws FileNotFoundException { + private void open() throws FileNotFoundException, AltosSerialInUseException { + synchronized (devices_opened) { + if (devices_opened.contains(device.getPath())) + throw new AltosSerialInUseException(device); + devices_opened.add(device.getPath()); + } close(); altos = libaltos.altos_open(device); if (altos == null) @@ -220,12 +226,12 @@ public class AltosSerial implements Runnable { } } - public AltosSerial() { - altos = null; - input_thread = null; + public AltosSerial(altos_device in_device) throws FileNotFoundException, AltosSerialInUseException { + device = in_device; line = ""; monitor_mode = false; monitors = new LinkedList> (); reply_queue = new LinkedBlockingQueue (); + open(); } } diff --git a/ao-tools/altosui/AltosTelemetryReader.java b/ao-tools/altosui/AltosTelemetryReader.java index 0b5509eb..ff02c722 100644 --- a/ao-tools/altosui/AltosTelemetryReader.java +++ b/ao-tools/altosui/AltosTelemetryReader.java @@ -50,9 +50,10 @@ class AltosTelemetryReader extends AltosFlightReader { serial.set_callsign(callsign); } - public AltosTelemetryReader (AltosDevice in_device) throws FileNotFoundException, IOException { + public AltosTelemetryReader (AltosDevice in_device) + throws FileNotFoundException, AltosSerialInUseException, IOException { device = in_device; - serial = new AltosSerial(); + serial = new AltosSerial(device); log = new AltosLog(serial); name = device.getPath(); diff --git a/ao-tools/altosui/AltosUI.java b/ao-tools/altosui/AltosUI.java index 9ab451de..0d8f0e8d 100644 --- a/ao-tools/altosui/AltosUI.java +++ b/ao-tools/altosui/AltosUI.java @@ -56,6 +56,12 @@ public class AltosUI extends JFrame { device.getPath()), "Cannot open target device", JOptionPane.ERROR_MESSAGE); + } catch (AltosSerialInUseException si) { + JOptionPane.showMessageDialog(AltosUI.this, + String.format("Device \"%s\" already in use", + device.getPath()), + "Device in use", + JOptionPane.ERROR_MESSAGE); } catch (IOException ee) { JOptionPane.showMessageDialog(AltosUI.this, device.getPath(), diff --git a/ao-tools/altosui/Makefile.am b/ao-tools/altosui/Makefile.am index 267bae63..f4c743df 100644 --- a/ao-tools/altosui/Makefile.am +++ b/ao-tools/altosui/Makefile.am @@ -58,6 +58,7 @@ altosui_JAVA = \ AltosRomconfig.java \ AltosRomconfigUI.java \ AltosSerial.java \ + AltosSerialInUseException.java \ AltosSerialMonitor.java \ AltosState.java \ AltosStatusTable.java \ -- cgit v1.2.3 From 11c95f687b1f68d35fa1a0af2c4e7982b8bb226a Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 13 Nov 2010 17:09:51 -0800 Subject: altosui: Replace flight status table with labels, fix resize. There's no reason to use a table for the flight status data, replace that with a selection of widgets instead. Also, set all of the grid bag constraints for the various flight status displays so that resize does something sensible. Adds a scrollbar to the table display so that it can shrink. Signed-off-by: Keith Packard --- ao-tools/altosui/AltosAscent.java | 13 ++- ao-tools/altosui/AltosDescent.java | 78 +++++++++------- ao-tools/altosui/AltosFlightStatus.java | 157 ++++++++++++++++++++++++++++++++ ao-tools/altosui/AltosFlightUI.java | 10 +- ao-tools/altosui/AltosLanded.java | 6 +- ao-tools/altosui/AltosPad.java | 20 ++-- ao-tools/altosui/AltosStatusTable.java | 67 -------------- ao-tools/altosui/Makefile.am | 3 +- 8 files changed, 237 insertions(+), 117 deletions(-) create mode 100644 ao-tools/altosui/AltosFlightStatus.java delete mode 100644 ao-tools/altosui/AltosStatusTable.java diff --git a/ao-tools/altosui/AltosAscent.java b/ao-tools/altosui/AltosAscent.java index 51fa1a89..7525b655 100644 --- a/ao-tools/altosui/AltosAscent.java +++ b/ao-tools/altosui/AltosAscent.java @@ -43,6 +43,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { } public AscentValue (GridBagLayout layout, int y, String text) { GridBagConstraints c = new GridBagConstraints(); + c.weighty = 1; label = new JLabel(text); label.setFont(label_font); @@ -50,6 +51,8 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { c.gridx = 0; c.gridy = y; c.insets = new Insets(10, 10, 10, 10); c.anchor = GridBagConstraints.WEST; + c.fill = GridBagConstraints.VERTICAL; + c.weightx = 0; layout.setConstraints(label, c); add(label); @@ -58,8 +61,9 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { value.setHorizontalAlignment(SwingConstants.RIGHT); c.gridx = 1; c.gridy = y; c.anchor = GridBagConstraints.WEST; - c.fill = GridBagConstraints.HORIZONTAL; + c.fill = GridBagConstraints.BOTH; c.gridwidth = 2; + c.weightx = 1; layout.setConstraints(value, c); add(value); } @@ -88,6 +92,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { } public AscentValueHold (GridBagLayout layout, int y, String text) { GridBagConstraints c = new GridBagConstraints(); + c.weighty = 1; label = new JLabel(text); label.setFont(label_font); @@ -95,6 +100,8 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { c.gridx = 0; c.gridy = y; c.insets = new Insets(10, 10, 10, 10); c.anchor = GridBagConstraints.WEST; + c.fill = GridBagConstraints.VERTICAL; + c.weightx = 0; layout.setConstraints(label, c); add(label); @@ -103,6 +110,8 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { value.setHorizontalAlignment(SwingConstants.RIGHT); c.gridx = 1; c.gridy = y; c.anchor = GridBagConstraints.EAST; + c.fill = GridBagConstraints.BOTH; + c.weightx = 1; layout.setConstraints(value, c); add(value); @@ -111,6 +120,8 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { max_value.setHorizontalAlignment(SwingConstants.RIGHT); c.gridx = 2; c.gridy = y; c.anchor = GridBagConstraints.EAST; + c.fill = GridBagConstraints.BOTH; + c.weightx = 1; layout.setConstraints(max_value, c); add(max_value); } diff --git a/ao-tools/altosui/AltosDescent.java b/ao-tools/altosui/AltosDescent.java index 56d3e4fe..b69e36b6 100644 --- a/ao-tools/altosui/AltosDescent.java +++ b/ao-tools/altosui/AltosDescent.java @@ -48,6 +48,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { public DescentValue (GridBagLayout layout, int y, String text) { GridBagConstraints c = new GridBagConstraints(); + c.weighty = 1; label = new JLabel(text); label.setFont(label_font); @@ -55,6 +56,8 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { c.gridx = 0; c.gridy = y; c.insets = new Insets(10, 10, 10, 10); c.anchor = GridBagConstraints.WEST; + c.fill = GridBagConstraints.VERTICAL; + c.weightx = 0; layout.setConstraints(label, c); add(label); @@ -64,7 +67,8 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { c.gridx = 1; c.gridy = y; c.gridwidth = 2; c.anchor = GridBagConstraints.WEST; - c.fill = GridBagConstraints.HORIZONTAL; + c.fill = GridBagConstraints.BOTH; + c.weightx = 1; layout.setConstraints(value, c); add(value); } @@ -138,50 +142,54 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { JLabel label; JTextField value; JTextField value_deg; - void reset () { + void reset () { value.setText(""); value_deg.setText(""); - } + } void show (AltosState state, int crc_errors) { if (state.from_pad != null) { - value.setText(state.from_pad.bearing_words( - AltosGreatCircle.BEARING_LONG)); + value.setText(state.from_pad.bearing_words( + AltosGreatCircle.BEARING_LONG)); value_deg.setText(String.format("%3.0f°", state.from_pad.bearing)); } else { value.setText("???"); value_deg.setText("???"); - } + } } public Bearing (GridBagLayout layout, int y) { - GridBagConstraints c = new GridBagConstraints(); - - label = new JLabel("Bearing"); - label.setFont(label_font); - label.setHorizontalAlignment(SwingConstants.LEFT); - c.gridx = 0; c.gridy = y; - c.insets = new Insets(10, 10, 10, 10); - c.anchor = GridBagConstraints.WEST; - layout.setConstraints(label, c); - add(label); - - value = new JTextField(30); - value.setFont(value_font); - value.setHorizontalAlignment(SwingConstants.RIGHT); - c.gridx = 1; c.gridy = y; - c.anchor = GridBagConstraints.EAST; - c.fill = GridBagConstraints.HORIZONTAL; - layout.setConstraints(value, c); - add(value); - - value_deg = new JTextField(5); - value_deg.setFont(value_font); - value_deg.setHorizontalAlignment(SwingConstants.RIGHT); - c.gridx = 2; c.gridy = y; - c.anchor = GridBagConstraints.EAST; - c.fill = GridBagConstraints.HORIZONTAL; - - layout.setConstraints(value_deg, c); - add(value_deg); + GridBagConstraints c = new GridBagConstraints(); + c.weighty = 1; + + label = new JLabel("Bearing"); + label.setFont(label_font); + label.setHorizontalAlignment(SwingConstants.LEFT); + c.gridx = 0; c.gridy = y; + c.insets = new Insets(10, 10, 10, 10); + c.anchor = GridBagConstraints.WEST; + c.weightx = 0; + c.fill = GridBagConstraints.VERTICAL; + layout.setConstraints(label, c); + add(label); + + value = new JTextField(30); + value.setFont(value_font); + value.setHorizontalAlignment(SwingConstants.RIGHT); + c.gridx = 1; c.gridy = y; + c.anchor = GridBagConstraints.EAST; + c.weightx = 1; + c.fill = GridBagConstraints.BOTH; + layout.setConstraints(value, c); + add(value); + + value_deg = new JTextField(5); + value_deg.setFont(value_font); + value_deg.setHorizontalAlignment(SwingConstants.RIGHT); + c.gridx = 2; c.gridy = y; + c.anchor = GridBagConstraints.EAST; + c.weightx = 1; + c.fill = GridBagConstraints.BOTH; + layout.setConstraints(value_deg, c); + add(value_deg); } } diff --git a/ao-tools/altosui/AltosFlightStatus.java b/ao-tools/altosui/AltosFlightStatus.java new file mode 100644 index 00000000..b99a5325 --- /dev/null +++ b/ao-tools/altosui/AltosFlightStatus.java @@ -0,0 +1,157 @@ +/* + * Copyright © 2010 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package altosui; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.table.*; +import java.io.*; +import java.util.*; +import java.text.*; +import java.util.prefs.*; +import java.util.concurrent.LinkedBlockingQueue; + +public class AltosFlightStatus extends JComponent implements AltosFlightDisplay { + GridBagLayout layout; + + private Font status_font; + + public class FlightValue { + JLabel label; + JTextField value; + + void show(AltosState state, int crc_errors) {} + + void reset() { + value.setText(""); + } + public FlightValue (GridBagLayout layout, int x, String text) { + GridBagConstraints c = new GridBagConstraints(); + c.insets = new Insets(5, 5, 5, 5); + c.anchor = GridBagConstraints.CENTER; + c.fill = GridBagConstraints.BOTH; + c.weightx = 1; + c.weighty = 1; + + label = new JLabel(text); + label.setFont(status_font); + label.setHorizontalAlignment(SwingConstants.CENTER); + c.gridx = x; c.gridy = 0; + layout.setConstraints(label, c); + add(label); + + value = new JTextField(""); + value.setFont(status_font); + value.setHorizontalAlignment(SwingConstants.CENTER); + c.gridx = x; c.gridy = 1; + layout.setConstraints(value, c); + add(value); + } + } + + class Call extends FlightValue { + void show(AltosState state, int crc_errors) { + value.setText(state.data.callsign); + } + public Call (GridBagLayout layout, int x) { + super (layout, x, "Callsign"); + } + } + + Call call; + + class Serial extends FlightValue { + void show(AltosState state, int crc_errors) { + value.setText(String.format("%d", state.data.serial)); + } + public Serial (GridBagLayout layout, int x) { + super (layout, x, "Serial"); + } + } + + Serial serial; + + class Flight extends FlightValue { + void show(AltosState state, int crc_errors) { + value.setText(String.format("%d", state.data.flight)); + } + public Flight (GridBagLayout layout, int x) { + super (layout, x, "Flight"); + } + } + + Flight flight; + + class FlightState extends FlightValue { + void show(AltosState state, int crc_errors) { + value.setText(state.data.state()); + } + public FlightState (GridBagLayout layout, int x) { + super (layout, x, "State"); + } + } + + FlightState flight_state; + + class RSSI extends FlightValue { + void show(AltosState state, int crc_errors) { + value.setText(String.format("%d", state.data.rssi)); + } + public RSSI (GridBagLayout layout, int x) { + super (layout, x, "RSSI (dBm)"); + } + } + + RSSI rssi; + + public void reset () { + call.reset(); + serial.reset(); + flight.reset(); + flight_state.reset(); + rssi.reset(); + } + + public void show (AltosState state, int crc_errors) { + call.show(state, crc_errors); + serial.show(state, crc_errors); + flight.show(state, crc_errors); + flight_state.show(state, crc_errors); + rssi.show(state, crc_errors); + } + + public int height() { + Dimension d = layout.preferredLayoutSize(this); + return d.height; + } + + public AltosFlightStatus() { + layout = new GridBagLayout(); + + status_font = new Font("SansSerif", Font.BOLD, 24); + setLayout(layout); + + call = new Call(layout, 0); + serial = new Serial(layout, 1); + flight = new Flight(layout, 2); + flight_state = new FlightState(layout, 3); + rssi = new RSSI(layout, 4); + } +} diff --git a/ao-tools/altosui/AltosFlightUI.java b/ao-tools/altosui/AltosFlightUI.java index 3581c54c..ae31048d 100644 --- a/ao-tools/altosui/AltosFlightUI.java +++ b/ao-tools/altosui/AltosFlightUI.java @@ -45,7 +45,8 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay { AltosDescent descent; AltosLanded landed; - private AltosStatusTable flightStatus; + private AltosFlightStatus flightStatus; + private JScrollPane flightInfoPane; private AltosInfoTable flightInfo; static final int tab_pad = 1; @@ -117,7 +118,7 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay { } cur_tab = tab; } - flightStatus.set(state); + flightStatus.show(state, crc_errors); flightInfo.show(state, crc_errors); } @@ -133,7 +134,7 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay { setTitle(String.format("AltOS %s", reader.name)); - flightStatus = new AltosStatusTable(); + flightStatus = new AltosFlightStatus(); vbox = new Box (BoxLayout.Y_AXIS); vbox.add(flightStatus); @@ -153,7 +154,8 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay { pane.add("Landed", landed); flightInfo = new AltosInfoTable(); - pane.add("Table", flightInfo.box()); + flightInfoPane = new JScrollPane(flightInfo.box()); + pane.add("Table", flightInfoPane); vbox.add(pane); diff --git a/ao-tools/altosui/AltosLanded.java b/ao-tools/altosui/AltosLanded.java index d170ccad..465c9dce 100644 --- a/ao-tools/altosui/AltosLanded.java +++ b/ao-tools/altosui/AltosLanded.java @@ -48,6 +48,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay { public LandedValue (GridBagLayout layout, int y, String text) { GridBagConstraints c = new GridBagConstraints(); + c.weighty = 1; label = new JLabel(text); label.setFont(label_font); @@ -55,6 +56,8 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay { c.gridx = 0; c.gridy = y; c.insets = new Insets(10, 10, 10, 10); c.anchor = GridBagConstraints.WEST; + c.weightx = 0; + c.fill = GridBagConstraints.VERTICAL; layout.setConstraints(label, c); add(label); @@ -63,7 +66,8 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay { value.setHorizontalAlignment(SwingConstants.RIGHT); c.gridx = 1; c.gridy = y; c.anchor = GridBagConstraints.WEST; - c.fill = GridBagConstraints.HORIZONTAL; + c.weightx = 1; + c.fill = GridBagConstraints.BOTH; layout.setConstraints(value, c); add(value); } diff --git a/ao-tools/altosui/AltosPad.java b/ao-tools/altosui/AltosPad.java index da047072..650ed012 100644 --- a/ao-tools/altosui/AltosPad.java +++ b/ao-tools/altosui/AltosPad.java @@ -46,11 +46,13 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { public LaunchStatus (GridBagLayout layout, int y, String text) { GridBagConstraints c = new GridBagConstraints(); + c.weighty = 1; lights = new AltosLights(); c.gridx = 0; c.gridy = y; c.anchor = GridBagConstraints.CENTER; - c.fill = GridBagConstraints.CENTER; + c.fill = GridBagConstraints.VERTICAL; + c.weightx = 0; layout.setConstraints(lights, c); add(lights); @@ -60,7 +62,8 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { c.gridx = 1; c.gridy = y; c.insets = new Insets(10, 10, 10, 10); c.anchor = GridBagConstraints.WEST; - c.fill = GridBagConstraints.WEST; + c.fill = GridBagConstraints.VERTICAL; + c.weightx = 0; layout.setConstraints(label, c); add(label); @@ -69,6 +72,8 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { value.setHorizontalAlignment(SwingConstants.RIGHT); c.gridx = 2; c.gridy = y; c.anchor = GridBagConstraints.WEST; + c.fill = GridBagConstraints.BOTH; + c.weightx = 1; layout.setConstraints(value, c); add(value); @@ -85,13 +90,16 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { } public LaunchValue (GridBagLayout layout, int y, String text) { GridBagConstraints c = new GridBagConstraints(); + c.insets = new Insets(10, 10, 10, 10); + c.weighty = 1; label = new JLabel(text); label.setFont(label_font); label.setHorizontalAlignment(SwingConstants.LEFT); c.gridx = 1; c.gridy = y; - c.insets = new Insets(10, 10, 10, 10); c.anchor = GridBagConstraints.WEST; + c.fill = GridBagConstraints.VERTICAL; + c.weightx = 0; layout.setConstraints(label, c); add(label); @@ -100,7 +108,8 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { value.setHorizontalAlignment(SwingConstants.RIGHT); c.gridx = 2; c.gridy = y; c.anchor = GridBagConstraints.EAST; - c.fill = GridBagConstraints.HORIZONTAL; + c.fill = GridBagConstraints.BOTH; + c.weightx = 1; layout.setConstraints(value, c); add(value); } @@ -221,13 +230,10 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { public AltosPad() { layout = new GridBagLayout(); - GridBagConstraints c; - label_font = new Font("Dialog", Font.PLAIN, 24); value_font = new Font("Monospaced", Font.PLAIN, 24); setLayout(layout); - c = new GridBagConstraints(); /* Elements in pad display: * * Battery voltage diff --git a/ao-tools/altosui/AltosStatusTable.java b/ao-tools/altosui/AltosStatusTable.java deleted file mode 100644 index 02c6232f..00000000 --- a/ao-tools/altosui/AltosStatusTable.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright © 2010 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -package altosui; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.filechooser.FileNameExtensionFilter; -import javax.swing.table.*; -import java.io.*; -import java.util.*; -import java.text.*; -import java.util.prefs.*; -import java.util.concurrent.LinkedBlockingQueue; - -public class AltosStatusTable extends JTable { - private AltosFlightStatusTableModel flightStatusModel; - - private Font statusFont = new Font("SansSerif", Font.BOLD, 24); - - public AltosStatusTable() { - super((TableModel) new AltosFlightStatusTableModel()); - flightStatusModel = (AltosFlightStatusTableModel) getModel(); - - setFont(statusFont); - - TableColumnModel tcm = getColumnModel(); - - for (int i = 0; i < flightStatusModel.getColumnCount(); i++) { - DefaultTableCellRenderer r = new DefaultTableCellRenderer(); - r.setFont(statusFont); - r.setHorizontalAlignment(SwingConstants.CENTER); - tcm.getColumn(i).setCellRenderer(r); - } - - setRowHeight(rowHeight()); - setShowGrid(false); - } - - public int rowHeight() { - FontMetrics statusMetrics = getFontMetrics(statusFont); - return (statusMetrics.getHeight() + statusMetrics.getLeading()) * 15 / 10; - } - - public int height() { - return rowHeight * 4; - } - - public void set(AltosState state) { - flightStatusModel.set(state); - } -} diff --git a/ao-tools/altosui/Makefile.am b/ao-tools/altosui/Makefile.am index f4c743df..d11ea3e2 100644 --- a/ao-tools/altosui/Makefile.am +++ b/ao-tools/altosui/Makefile.am @@ -33,7 +33,7 @@ altosui_JAVA = \ AltosFlightDisplay.java \ AltosFlightInfoTableModel.java \ AltosFlightReader.java \ - AltosFlightStatusTableModel.java \ + AltosFlightStatus.java \ AltosFlightUI.java \ AltosGPS.java \ AltosGreatCircle.java \ @@ -61,7 +61,6 @@ altosui_JAVA = \ AltosSerialInUseException.java \ AltosSerialMonitor.java \ AltosState.java \ - AltosStatusTable.java \ AltosTelemetry.java \ AltosTelemetryIterable.java \ AltosUI.java \ -- cgit v1.2.3 From 511903704f7e1b22e88dd3e3cc35fd3c0583820e Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 14 Nov 2010 03:26:57 -0800 Subject: altosui: With --replay option, exit when replay window is closed Otherwise, the application hangs around forever. Signed-off-by: Keith Packard --- ao-tools/altosui/AltosFlightUI.java | 10 ++++++++- ao-tools/altosui/AltosUI.java | 41 +++++++++++++++++++------------------ 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/ao-tools/altosui/AltosFlightUI.java b/ao-tools/altosui/AltosFlightUI.java index ae31048d..5134a24e 100644 --- a/ao-tools/altosui/AltosFlightUI.java +++ b/ao-tools/altosui/AltosFlightUI.java @@ -56,6 +56,8 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay { int cur_tab = 0; + boolean exit_on_close = false; + int which_tab(AltosState state) { if (state.state < Altos.ao_flight_boost) return tab_pad; @@ -122,8 +124,12 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay { flightInfo.show(state, crc_errors); } + public void set_exit_on_close() { + exit_on_close = true; + } + public AltosFlightUI(AltosVoice in_voice, AltosFlightReader in_reader, final int serial) { - AltosPreferences.init(this); + AltosPreferences.init(this); voice = in_voice; reader = in_reader; @@ -191,6 +197,8 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay { disconnect(); setVisible(false); dispose(); + if (exit_on_close) + System.exit(0); } }); diff --git a/ao-tools/altosui/AltosUI.java b/ao-tools/altosui/AltosUI.java index 0d8f0e8d..a2e416ba 100644 --- a/ao-tools/altosui/AltosUI.java +++ b/ao-tools/altosui/AltosUI.java @@ -443,26 +443,27 @@ public class AltosUI extends JFrame { public static void main(final String[] args) { int process = 0; /* Handle batch-mode */ - if (args.length == 2 && args[0].equals("--replay")) { - String filename = args[1]; - FileInputStream in; - try { - in = new FileInputStream(filename); - } catch (Exception e) { - System.out.printf("Failed to open file '%s'\n", filename); - return; - } - AltosRecordIterable recs; - AltosReplayReader reader; - if (filename.endsWith("eeprom")) { - recs = new AltosEepromIterable(in); - } else { - recs = new AltosTelemetryIterable(in); - } - reader = new AltosReplayReader(recs.iterator(), filename); - new AltosFlightUI(new AltosVoice(), reader); - return; - } else if (args.length > 0) { + if (args.length == 2 && args[0].equals("--replay")) { + String filename = args[1]; + FileInputStream in; + try { + in = new FileInputStream(filename); + } catch (Exception e) { + System.out.printf("Failed to open file '%s'\n", filename); + return; + } + AltosRecordIterable recs; + AltosReplayReader reader; + if (filename.endsWith("eeprom")) { + recs = new AltosEepromIterable(in); + } else { + recs = new AltosTelemetryIterable(in); + } + reader = new AltosReplayReader(recs.iterator(), filename); + AltosFlightUI flight_ui = new AltosFlightUI(new AltosVoice(), reader); + flight_ui.set_exit_on_close(); + return; + } else if (args.length > 0) { for (int i = 0; i < args.length; i++) { if (args[i].equals("--kml")) process |= process_kml; -- cgit v1.2.3 From 524644d8d8ce3f8a5a914ecfc7e2a8d474d89095 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 15 Nov 2010 22:04:44 +0800 Subject: altosui: oops, missed a file in the previous commit AltosSerialInUseException.java just defines a new exception, thanks to java for making this live in a separate file. Signed-off-by: Keith Packard --- ao-tools/altosui/AltosSerialInUseException.java | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 ao-tools/altosui/AltosSerialInUseException.java diff --git a/ao-tools/altosui/AltosSerialInUseException.java b/ao-tools/altosui/AltosSerialInUseException.java new file mode 100644 index 00000000..4b108c7c --- /dev/null +++ b/ao-tools/altosui/AltosSerialInUseException.java @@ -0,0 +1,28 @@ +/* + * Copyright © 2010 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package altosui; + +import libaltosJNI.*; + +public class AltosSerialInUseException extends Exception { + public altos_device device; + + public AltosSerialInUseException (altos_device in_device) { + device = in_device; + } +} -- cgit v1.2.3 From 257e97137325f5dbbd6aa034f20fd6937b67df90 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 15 Nov 2010 22:38:35 +0800 Subject: altosui: eliminate menu bar, moving elements to buttons. This adds a new 'configure AltosUI' dialog to set the log directory and voice preferences. Signed-off-by: Keith Packard --- ao-tools/altosui/AltosConfigureUI.java | 120 +++++++++++++++++++++++++ ao-tools/altosui/AltosUI.java | 158 +++++---------------------------- ao-tools/altosui/Makefile.am | 1 + 3 files changed, 144 insertions(+), 135 deletions(-) create mode 100644 ao-tools/altosui/AltosConfigureUI.java diff --git a/ao-tools/altosui/AltosConfigureUI.java b/ao-tools/altosui/AltosConfigureUI.java new file mode 100644 index 00000000..88c180f1 --- /dev/null +++ b/ao-tools/altosui/AltosConfigureUI.java @@ -0,0 +1,120 @@ +/* + * Copyright © 2010 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package altosui; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.table.*; +import java.io.*; +import java.util.*; +import java.text.*; +import java.util.prefs.*; +import java.util.concurrent.LinkedBlockingQueue; + +public class AltosConfigureUI extends JDialog { + JFrame owner; + AltosVoice voice; + Container pane; + + JRadioButton enable_voice; + JButton test_voice; + JButton close; + + JButton configure_log; + JTextField log_directory; + + public AltosConfigureUI(JFrame in_owner, AltosVoice in_voice) { + super(in_owner, "Configure AltosUI", false); + + GridBagConstraints c; + + Insets insets = new Insets(4, 4, 4, 4); + + owner = in_owner; + voice = in_voice; + pane = getContentPane(); + pane.setLayout(new GridBagLayout()); + + c = new GridBagConstraints(); + c.insets = insets; + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.CENTER; + + /* Enable Voice */ + c.gridx = 0; + c.gridy = 0; + enable_voice = new JRadioButton("Enable Voice", AltosPreferences.voice()); + enable_voice.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + JRadioButton item = (JRadioButton) e.getSource(); + boolean enabled = item.isSelected(); + AltosPreferences.set_voice(enabled); + if (enabled) + voice.speak_always("Enable voice."); + else + voice.speak_always("Disable voice."); + } + }); + pane.add(enable_voice, c); + c.gridx = 1; + c.gridy = 0; + test_voice = new JButton("Test Voice"); + test_voice.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + voice.speak("That's one small step for man; one giant leap for mankind."); + } + }); + pane.add(test_voice, c); + + close = new JButton("Close"); + close.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + setVisible(false); + } + }); + c.gridx = 0; + c.gridy = 3; + c.gridwidth = 2; + pane.add(close, c); + + configure_log = new JButton("Configure Log"); + configure_log.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + AltosPreferences.ConfigureLog(); + log_directory.setText(AltosPreferences.logdir().getPath()); + } + }); + c.gridwidth = 1; + + c.gridx = 0; + c.gridy = 2; + pane.add(configure_log, c); + + log_directory = new JTextField(AltosPreferences.logdir().getPath()); + c.gridx = 1; + c.gridy = 2; + c.fill = GridBagConstraints.BOTH; + pane.add(log_directory, c); + + pack(); + setLocationRelativeTo(owner); + setVisible(true); + } +} diff --git a/ao-tools/altosui/AltosUI.java b/ao-tools/altosui/AltosUI.java index a2e416ba..bedf2459 100644 --- a/ao-tools/altosui/AltosUI.java +++ b/ao-tools/altosui/AltosUI.java @@ -144,9 +144,28 @@ public class AltosUI extends JFrame { } }); - setTitle("AltOS"); + b = addButton(0, 2, "Configure AltosUI"); + b.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + ConfigureAltosUI(); + } + }); + + b = addButton(1, 2, "Flash Image"); + b.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + FlashImage(); + } + }); + + b = addButton(2, 2, "Quit"); + b.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + System.exit(0); + } + }); - createMenu(); + setTitle("AltOS"); pane.doLayout(); pane.validate(); @@ -232,139 +251,8 @@ public class AltosUI extends JFrame { new AltosGraphUI(AltosUI.this); } - /* Create the AltosUI menus - */ - private void createMenu() { - JMenuBar menubar = new JMenuBar(); - JMenu menu; - JMenuItem item; - JRadioButtonMenuItem radioitem; - - // File menu - { - menu = new JMenu("File"); - menu.setMnemonic(KeyEvent.VK_F); - menubar.add(menu); - - item = new JMenuItem("Flash Image",KeyEvent.VK_I); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - FlashImage(); - } - }); - menu.add(item); - - item = new JMenuItem("Export Data",KeyEvent.VK_E); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - ExportData(); - } - }); - menu.add(item); - - item = new JMenuItem("Graph Data",KeyEvent.VK_G); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - GraphData(); - } - }); - menu.add(item); - - item = new JMenuItem("Quit",KeyEvent.VK_Q); - item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, - ActionEvent.CTRL_MASK)); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - System.out.printf("exiting\n"); - System.exit(0); - } - }); - menu.add(item); - } - - // Device menu - if (false) { - menu = new JMenu("Device"); - menu.setMnemonic(KeyEvent.VK_D); - menubar.add(menu); - - item = new JMenuItem("Connect to Device",KeyEvent.VK_C); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - ConnectToDevice(); - } - }); - menu.add(item); - - menu.addSeparator(); - - item = new JMenuItem("Set Callsign",KeyEvent.VK_S); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - ConfigureCallsign(); - } - }); - - menu.add(item); - - item = new JMenuItem("Configure TeleMetrum device",KeyEvent.VK_T); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - ConfigureTeleMetrum(); - } - }); - - menu.add(item); - } - // Log menu - { - menu = new JMenu("Log"); - menu.setMnemonic(KeyEvent.VK_L); - menubar.add(menu); - - item = new JMenuItem("New Log",KeyEvent.VK_N); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - } - }); - menu.add(item); - - item = new JMenuItem("Configure Log",KeyEvent.VK_C); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - AltosPreferences.ConfigureLog(); - } - }); - menu.add(item); - } - // Voice menu - { - menu = new JMenu("Voice", true); - menu.setMnemonic(KeyEvent.VK_V); - menubar.add(menu); - - radioitem = new JRadioButtonMenuItem("Enable Voice", AltosPreferences.voice()); - radioitem.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - JRadioButtonMenuItem item = (JRadioButtonMenuItem) e.getSource(); - boolean enabled = item.isSelected(); - AltosPreferences.set_voice(enabled); - if (enabled) - voice.speak_always("Enable voice."); - else - voice.speak_always("Disable voice."); - } - }); - menu.add(radioitem); - item = new JMenuItem("Test Voice",KeyEvent.VK_T); - item.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - voice.speak("That's one small step for man; one giant leap for mankind."); - } - }); - menu.add(item); - } - this.setJMenuBar(menubar); + private void ConfigureAltosUI() { + new AltosConfigureUI(AltosUI.this, voice); } static AltosRecordIterable open_logfile(String filename) { diff --git a/ao-tools/altosui/Makefile.am b/ao-tools/altosui/Makefile.am index d11ea3e2..8d0fe16e 100644 --- a/ao-tools/altosui/Makefile.am +++ b/ao-tools/altosui/Makefile.am @@ -14,6 +14,7 @@ altosui_JAVA = \ AltosChannelMenu.java \ AltosConfig.java \ AltosConfigUI.java \ + AltosConfigureUI.java \ AltosConvert.java \ AltosCRCException.java \ AltosCSV.java \ -- cgit v1.2.3 From 39e371561469d8e5059638ffa4e7075f391de268 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 15 Nov 2010 23:14:51 +0800 Subject: altosui: add reboot button to telemetrum configuration UI This lets you reconfigure and reboot telemetrum, including over the radio link. Signed-off-by: Keith Packard --- ao-tools/altosui/AltosConfig.java | 20 +++++++-- ao-tools/altosui/AltosConfigUI.java | 90 +++++++++++++++++++++---------------- 2 files changed, 68 insertions(+), 42 deletions(-) diff --git a/ao-tools/altosui/AltosConfig.java b/ao-tools/altosui/AltosConfig.java index 09e204a9..a0fdb623 100644 --- a/ao-tools/altosui/AltosConfig.java +++ b/ao-tools/altosui/AltosConfig.java @@ -198,12 +198,26 @@ public class AltosConfig implements Runnable, ActionListener { public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); - if (cmd.equals("save")) { + if (cmd.equals("Save")) { save_data(); set_ui(); - } else if (cmd.equals("reset")) { + } else if (cmd.equals("Reset")) { set_ui(); - } else if (cmd.equals("close")) { + } else if (cmd.equals("Reboot")) { + if (serial_line != null) { + try { + start_serial(); + serial_line.printf("r eboot\n"); + } catch (InterruptedException ie) { + } finally { + try { + stop_serial(); + } catch (InterruptedException ie) { + } + } + serial_line.close(); + } + } else if (cmd.equals("Close")) { if (serial_line != null) serial_line.close(); } diff --git a/ao-tools/altosui/AltosConfigUI.java b/ao-tools/altosui/AltosConfigUI.java index 9e3856b0..e04933eb 100644 --- a/ao-tools/altosui/AltosConfigUI.java +++ b/ao-tools/altosui/AltosConfigUI.java @@ -61,6 +61,7 @@ public class AltosConfigUI JButton save; JButton reset; + JButton reboot; JButton close; ActionListener listener; @@ -92,7 +93,7 @@ public class AltosConfigUI public void windowClosing(WindowEvent e) { ui.actionPerformed(new ActionEvent(e.getSource(), ActionEvent.ACTION_PERFORMED, - "close")); + "Close")); } } @@ -112,7 +113,7 @@ public class AltosConfigUI /* Product */ c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; - c.gridwidth = 3; + c.gridwidth = 4; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; c.insets = il; @@ -120,8 +121,8 @@ public class AltosConfigUI pane.add(product_label, c); c = new GridBagConstraints(); - c.gridx = 3; c.gridy = 0; - c.gridwidth = 3; + c.gridx = 4; c.gridy = 0; + c.gridwidth = 4; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.anchor = GridBagConstraints.LINE_START; @@ -132,7 +133,7 @@ public class AltosConfigUI /* Version */ c = new GridBagConstraints(); c.gridx = 0; c.gridy = 1; - c.gridwidth = 3; + c.gridwidth = 4; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; c.insets = il; @@ -141,8 +142,8 @@ public class AltosConfigUI pane.add(version_label, c); c = new GridBagConstraints(); - c.gridx = 3; c.gridy = 1; - c.gridwidth = 3; + c.gridx = 4; c.gridy = 1; + c.gridwidth = 4; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.anchor = GridBagConstraints.LINE_START; @@ -154,7 +155,7 @@ public class AltosConfigUI /* Serial */ c = new GridBagConstraints(); c.gridx = 0; c.gridy = 2; - c.gridwidth = 3; + c.gridwidth = 4; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; c.insets = il; @@ -163,8 +164,8 @@ public class AltosConfigUI pane.add(serial_label, c); c = new GridBagConstraints(); - c.gridx = 3; c.gridy = 2; - c.gridwidth = 3; + c.gridx = 4; c.gridy = 2; + c.gridwidth = 4; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.anchor = GridBagConstraints.LINE_START; @@ -176,7 +177,7 @@ public class AltosConfigUI /* Main deploy */ c = new GridBagConstraints(); c.gridx = 0; c.gridy = 3; - c.gridwidth = 3; + c.gridwidth = 4; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; c.insets = il; @@ -185,8 +186,8 @@ public class AltosConfigUI pane.add(main_deploy_label, c); c = new GridBagConstraints(); - c.gridx = 3; c.gridy = 3; - c.gridwidth = 3; + c.gridx = 4; c.gridy = 3; + c.gridwidth = 4; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.anchor = GridBagConstraints.LINE_START; @@ -200,7 +201,7 @@ public class AltosConfigUI /* Apogee delay */ c = new GridBagConstraints(); c.gridx = 0; c.gridy = 4; - c.gridwidth = 3; + c.gridwidth = 4; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; c.insets = il; @@ -209,8 +210,8 @@ public class AltosConfigUI pane.add(apogee_delay_label, c); c = new GridBagConstraints(); - c.gridx = 3; c.gridy = 4; - c.gridwidth = 3; + c.gridx = 4; c.gridy = 4; + c.gridwidth = 4; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.anchor = GridBagConstraints.LINE_START; @@ -224,7 +225,7 @@ public class AltosConfigUI /* Radio channel */ c = new GridBagConstraints(); c.gridx = 0; c.gridy = 5; - c.gridwidth = 3; + c.gridwidth = 4; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; c.insets = il; @@ -233,8 +234,8 @@ public class AltosConfigUI pane.add(radio_channel_label, c); c = new GridBagConstraints(); - c.gridx = 3; c.gridy = 5; - c.gridwidth = 3; + c.gridx = 4; c.gridy = 5; + c.gridwidth = 4; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.anchor = GridBagConstraints.LINE_START; @@ -248,7 +249,7 @@ public class AltosConfigUI /* Radio Calibration */ c = new GridBagConstraints(); c.gridx = 0; c.gridy = 6; - c.gridwidth = 3; + c.gridwidth = 4; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; c.insets = il; @@ -257,8 +258,8 @@ public class AltosConfigUI pane.add(radio_calibration_label, c); c = new GridBagConstraints(); - c.gridx = 3; c.gridy = 6; - c.gridwidth = 3; + c.gridx = 4; c.gridy = 6; + c.gridwidth = 4; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.anchor = GridBagConstraints.LINE_START; @@ -271,7 +272,7 @@ public class AltosConfigUI /* Callsign */ c = new GridBagConstraints(); c.gridx = 0; c.gridy = 7; - c.gridwidth = 3; + c.gridwidth = 4; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; c.insets = il; @@ -280,8 +281,8 @@ public class AltosConfigUI pane.add(callsign_label, c); c = new GridBagConstraints(); - c.gridx = 3; c.gridy = 7; - c.gridwidth = 3; + c.gridx = 4; c.gridy = 7; + c.gridwidth = 4; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.anchor = GridBagConstraints.LINE_START; @@ -294,36 +295,47 @@ public class AltosConfigUI /* Buttons */ c = new GridBagConstraints(); c.gridx = 0; c.gridy = 8; - c.gridwidth = 6; + c.gridwidth = 2; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; c.insets = il; save = new JButton("Save"); pane.add(save, c); save.addActionListener(this); - save.setActionCommand("save"); + save.setActionCommand("Save"); c = new GridBagConstraints(); - c.gridx = 0; c.gridy = 8; - c.gridwidth = 6; + c.gridx = 2; c.gridy = 8; + c.gridwidth = 2; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.CENTER; c.insets = il; reset = new JButton("Reset"); pane.add(reset, c); reset.addActionListener(this); - reset.setActionCommand("reset"); + reset.setActionCommand("Reset"); c = new GridBagConstraints(); - c.gridx = 0; c.gridy = 8; - c.gridwidth = 6; + c.gridx = 4; c.gridy = 8; + c.gridwidth = 2; + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.CENTER; + c.insets = il; + reboot = new JButton("Reboot"); + pane.add(reboot, c); + reboot.addActionListener(this); + reboot.setActionCommand("Reboot"); + + c = new GridBagConstraints(); + c.gridx = 6; c.gridy = 8; + c.gridwidth = 2; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_END; c.insets = il; close = new JButton("Close"); pane.add(close, c); close.addActionListener(this); - close.setActionCommand("close"); + close.setActionCommand("Close"); addWindowListener(new ConfigListener(this)); } @@ -336,12 +348,12 @@ public class AltosConfigUI } /* If any values have been changed, confirm before closing */ - public boolean check_dirty() { + public boolean check_dirty(String operation) { if (dirty) { - Object[] options = { "Close anyway", "Keep editing" }; + Object[] options = { String.format("%s anyway", operation), "Keep editing" }; int i; i = JOptionPane.showOptionDialog(this, - "Configuration modified, close anyway?", + String.format("Configuration modified. %s anyway?", operation), "Configuration Modified", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, @@ -356,11 +368,11 @@ public class AltosConfigUI public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); - if (cmd.equals("close")) - if (!check_dirty()) + if (cmd.equals("Close") || cmd.equals("Reboot")) + if (!check_dirty(cmd)) return; listener.actionPerformed(e); - if (cmd.equals("close")) { + if (cmd.equals("Close") || cmd.equals("Reboot")) { setVisible(false); dispose(); } -- cgit v1.2.3 From fcca333cda64be35f0c9fb0109eef1be3709dddd Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 16 Nov 2010 21:49:59 +0800 Subject: altosui: Add callsign configuration in AltosUI configuration dialog This callsign is used during packet communication. Signed-off-by: Keith Packard --- ao-tools/altosui/AltosConfigUI.java | 2 +- ao-tools/altosui/AltosConfigureUI.java | 56 ++++++++++++++++++++++++++-------- 2 files changed, 45 insertions(+), 13 deletions(-) diff --git a/ao-tools/altosui/AltosConfigUI.java b/ao-tools/altosui/AltosConfigUI.java index e04933eb..ca89f58d 100644 --- a/ao-tools/altosui/AltosConfigUI.java +++ b/ao-tools/altosui/AltosConfigUI.java @@ -288,7 +288,7 @@ public class AltosConfigUI c.anchor = GridBagConstraints.LINE_START; c.insets = ir; c.ipady = 5; - callsign_value = new JTextField("N0CALL"); + callsign_value = new JTextField(AltosPreferences.callsign()); callsign_value.getDocument().addDocumentListener(this); pane.add(callsign_value, c); diff --git a/ao-tools/altosui/AltosConfigureUI.java b/ao-tools/altosui/AltosConfigureUI.java index 88c180f1..64c17eaf 100644 --- a/ao-tools/altosui/AltosConfigureUI.java +++ b/ao-tools/altosui/AltosConfigureUI.java @@ -22,13 +22,17 @@ import java.awt.event.*; import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.table.*; +import javax.swing.event.*; import java.io.*; import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; -public class AltosConfigureUI extends JDialog { +public class AltosConfigureUI + extends JDialog + implements DocumentListener +{ JFrame owner; AltosVoice voice; Container pane; @@ -40,6 +44,22 @@ public class AltosConfigureUI extends JDialog { JButton configure_log; JTextField log_directory; + JLabel callsign_label; + JTextField callsign_value; + + /* DocumentListener interface methods */ + public void changedUpdate(DocumentEvent e) { + AltosPreferences.set_callsign(callsign_value.getText()); + } + + public void insertUpdate(DocumentEvent e) { + changedUpdate(e); + } + + public void removeUpdate(DocumentEvent e) { + changedUpdate(e); + } + public AltosConfigureUI(JFrame in_owner, AltosVoice in_voice) { super(in_owner, "Configure AltosUI", false); @@ -83,17 +103,6 @@ public class AltosConfigureUI extends JDialog { }); pane.add(test_voice, c); - close = new JButton("Close"); - close.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - setVisible(false); - } - }); - c.gridx = 0; - c.gridy = 3; - c.gridwidth = 2; - pane.add(close, c); - configure_log = new JButton("Configure Log"); configure_log.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -113,6 +122,29 @@ public class AltosConfigureUI extends JDialog { c.fill = GridBagConstraints.BOTH; pane.add(log_directory, c); + callsign_label = new JLabel("Callsign"); + c.gridx = 0; + c.gridy = 3; + pane.add(callsign_label, c); + + callsign_value = new JTextField(AltosPreferences.callsign()); + callsign_value.getDocument().addDocumentListener(this); + c.gridx = 1; + c.gridy = 3; + pane.add(callsign_value, c); + + close = new JButton("Close"); + close.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + setVisible(false); + } + }); + c.gridx = 0; + c.gridy = 4; + c.gridwidth = 2; + c.fill = GridBagConstraints.NONE; + pane.add(close, c); + pack(); setLocationRelativeTo(owner); setVisible(true); -- cgit v1.2.3 From d0eb41619544ead6d9dab3a8d024a12936c9cdd0 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 16 Nov 2010 22:20:00 +0800 Subject: altosui: Cleanup flight UI layout Use common constants for fonts and insets Shrink fonts so that the window is < 600 pixels tall. Signed-off-by: Keith Packard --- ao-tools/altosui/Altos.java | 6 +++ ao-tools/altosui/AltosAscent.java | 24 +++++------- ao-tools/altosui/AltosDescent.java | 18 ++++----- ao-tools/altosui/AltosFlightInfoTableModel.java | 2 +- ao-tools/altosui/AltosFlightStatus.java | 7 +--- ao-tools/altosui/AltosFlightUI.java | 2 +- ao-tools/altosui/AltosLanded.java | 4 +- ao-tools/altosui/AltosPad.java | 50 +++++++++++++++++-------- 8 files changed, 64 insertions(+), 49 deletions(-) diff --git a/ao-tools/altosui/Altos.java b/ao-tools/altosui/Altos.java index 997550e0..197e98db 100644 --- a/ao-tools/altosui/Altos.java +++ b/ao-tools/altosui/Altos.java @@ -67,6 +67,12 @@ public class Altos { static boolean map_initialized = false; + static final int tab_elt_pad = 5; + + static final Font label_font = new Font("Dialog", Font.PLAIN, 22); + static final Font value_font = new Font("Monospaced", Font.PLAIN, 22); + static final Font status_font = new Font("SansSerif", Font.BOLD, 24); + static void initialize_map() { string_to_state.put("startup", ao_flight_startup); diff --git a/ao-tools/altosui/AltosAscent.java b/ao-tools/altosui/AltosAscent.java index 7525b655..8e1b6347 100644 --- a/ao-tools/altosui/AltosAscent.java +++ b/ao-tools/altosui/AltosAscent.java @@ -30,8 +30,6 @@ import java.util.concurrent.LinkedBlockingQueue; public class AltosAscent extends JComponent implements AltosFlightDisplay { GridBagLayout layout; - Font label_font; - Font value_font; public class AscentValue { JLabel label; @@ -46,10 +44,10 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { c.weighty = 1; label = new JLabel(text); - label.setFont(label_font); + label.setFont(Altos.label_font); label.setHorizontalAlignment(SwingConstants.LEFT); c.gridx = 0; c.gridy = y; - c.insets = new Insets(10, 10, 10, 10); + c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad); c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.VERTICAL; c.weightx = 0; @@ -57,7 +55,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { add(label); value = new JTextField(30); - value.setFont(value_font); + value.setFont(Altos.value_font); value.setHorizontalAlignment(SwingConstants.RIGHT); c.gridx = 1; c.gridy = y; c.anchor = GridBagConstraints.WEST; @@ -95,10 +93,10 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { c.weighty = 1; label = new JLabel(text); - label.setFont(label_font); + label.setFont(Altos.label_font); label.setHorizontalAlignment(SwingConstants.LEFT); c.gridx = 0; c.gridy = y; - c.insets = new Insets(10, 10, 10, 10); + c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad); c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.VERTICAL; c.weightx = 0; @@ -106,7 +104,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { add(label); value = new JTextField(15); - value.setFont(value_font); + value.setFont(Altos.value_font); value.setHorizontalAlignment(SwingConstants.RIGHT); c.gridx = 1; c.gridy = y; c.anchor = GridBagConstraints.EAST; @@ -116,7 +114,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { add(value); max_value = new JTextField(15); - max_value.setFont(value_font); + max_value.setFont(Altos.value_font); max_value.setHorizontalAlignment(SwingConstants.RIGHT); c.gridx = 2; c.gridy = y; c.anchor = GridBagConstraints.EAST; @@ -224,15 +222,15 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { JLabel cur, max; cur = new JLabel("Current"); - cur.setFont(label_font); + cur.setFont(Altos.label_font); c = new GridBagConstraints(); c.gridx = 1; c.gridy = y; - c.insets = new Insets(10, 10, 10, 10); + c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad); layout.setConstraints(cur, c); add(cur); max = new JLabel("Maximum"); - max.setFont(label_font); + max.setFont(Altos.label_font); c.gridx = 2; c.gridy = y; layout.setConstraints(max, c); add(max); @@ -241,8 +239,6 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { public AltosAscent() { layout = new GridBagLayout(); - label_font = new Font("Dialog", Font.PLAIN, 24); - value_font = new Font("Monospaced", Font.PLAIN, 24); setLayout(layout); /* Elements in ascent display: diff --git a/ao-tools/altosui/AltosDescent.java b/ao-tools/altosui/AltosDescent.java index b69e36b6..ceb78e57 100644 --- a/ao-tools/altosui/AltosDescent.java +++ b/ao-tools/altosui/AltosDescent.java @@ -30,8 +30,6 @@ import java.util.concurrent.LinkedBlockingQueue; public class AltosDescent extends JComponent implements AltosFlightDisplay { GridBagLayout layout; - Font label_font; - Font value_font; public class DescentValue { JLabel label; @@ -51,10 +49,10 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { c.weighty = 1; label = new JLabel(text); - label.setFont(label_font); + label.setFont(Altos.label_font); label.setHorizontalAlignment(SwingConstants.LEFT); c.gridx = 0; c.gridy = y; - c.insets = new Insets(10, 10, 10, 10); + c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad); c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.VERTICAL; c.weightx = 0; @@ -62,7 +60,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { add(label); value = new JTextField(30); - value.setFont(value_font); + value.setFont(Altos.value_font); value.setHorizontalAlignment(SwingConstants.RIGHT); c.gridx = 1; c.gridy = y; c.gridwidth = 2; @@ -161,10 +159,10 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { c.weighty = 1; label = new JLabel("Bearing"); - label.setFont(label_font); + label.setFont(Altos.label_font); label.setHorizontalAlignment(SwingConstants.LEFT); c.gridx = 0; c.gridy = y; - c.insets = new Insets(10, 10, 10, 10); + c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad); c.anchor = GridBagConstraints.WEST; c.weightx = 0; c.fill = GridBagConstraints.VERTICAL; @@ -172,7 +170,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { add(label); value = new JTextField(30); - value.setFont(value_font); + value.setFont(Altos.value_font); value.setHorizontalAlignment(SwingConstants.RIGHT); c.gridx = 1; c.gridy = y; c.anchor = GridBagConstraints.EAST; @@ -182,7 +180,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { add(value); value_deg = new JTextField(5); - value_deg.setFont(value_font); + value_deg.setFont(Altos.value_font); value_deg.setHorizontalAlignment(SwingConstants.RIGHT); c.gridx = 2; c.gridy = y; c.anchor = GridBagConstraints.EAST; @@ -243,8 +241,6 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { public AltosDescent() { layout = new GridBagLayout(); - label_font = new Font("Dialog", Font.PLAIN, 24); - value_font = new Font("Monospaced", Font.PLAIN, 24); setLayout(layout); /* Elements in descent display */ diff --git a/ao-tools/altosui/AltosFlightInfoTableModel.java b/ao-tools/altosui/AltosFlightInfoTableModel.java index 2a22e3e5..3355ff52 100644 --- a/ao-tools/altosui/AltosFlightInfoTableModel.java +++ b/ao-tools/altosui/AltosFlightInfoTableModel.java @@ -46,7 +46,7 @@ public class AltosFlightInfoTableModel extends AbstractTableModel { public int getColumnCount() { return columnNames.length; } public String getColumnName(int col) { return columnNames[col]; } - public int getRowCount() { return 20; } + public int getRowCount() { return 17; } int current_row = 0; int prev_num_rows = 0; diff --git a/ao-tools/altosui/AltosFlightStatus.java b/ao-tools/altosui/AltosFlightStatus.java index b99a5325..59c9e9db 100644 --- a/ao-tools/altosui/AltosFlightStatus.java +++ b/ao-tools/altosui/AltosFlightStatus.java @@ -31,8 +31,6 @@ import java.util.concurrent.LinkedBlockingQueue; public class AltosFlightStatus extends JComponent implements AltosFlightDisplay { GridBagLayout layout; - private Font status_font; - public class FlightValue { JLabel label; JTextField value; @@ -51,14 +49,14 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay c.weighty = 1; label = new JLabel(text); - label.setFont(status_font); + label.setFont(Altos.status_font); label.setHorizontalAlignment(SwingConstants.CENTER); c.gridx = x; c.gridy = 0; layout.setConstraints(label, c); add(label); value = new JTextField(""); - value.setFont(status_font); + value.setFont(Altos.status_font); value.setHorizontalAlignment(SwingConstants.CENTER); c.gridx = x; c.gridy = 1; layout.setConstraints(value, c); @@ -145,7 +143,6 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay public AltosFlightStatus() { layout = new GridBagLayout(); - status_font = new Font("SansSerif", Font.BOLD, 24); setLayout(layout); call = new Call(layout, 0); diff --git a/ao-tools/altosui/AltosFlightUI.java b/ao-tools/altosui/AltosFlightUI.java index 5134a24e..78b005c0 100644 --- a/ao-tools/altosui/AltosFlightUI.java +++ b/ao-tools/altosui/AltosFlightUI.java @@ -187,7 +187,7 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay { this.setJMenuBar(menubar); } - this.setSize(new Dimension (width(), height())); + this.setSize(this.getPreferredSize()); this.validate(); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); diff --git a/ao-tools/altosui/AltosLanded.java b/ao-tools/altosui/AltosLanded.java index 465c9dce..0656ea6c 100644 --- a/ao-tools/altosui/AltosLanded.java +++ b/ao-tools/altosui/AltosLanded.java @@ -196,8 +196,8 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay { public AltosLanded() { layout = new GridBagLayout(); - label_font = new Font("Dialog", Font.PLAIN, 24); - value_font = new Font("Monospaced", Font.PLAIN, 24); + label_font = new Font("Dialog", Font.PLAIN, 22); + value_font = new Font("Monospaced", Font.PLAIN, 22); setLayout(layout); /* Elements in descent display */ diff --git a/ao-tools/altosui/AltosPad.java b/ao-tools/altosui/AltosPad.java index 650ed012..8b258c7d 100644 --- a/ao-tools/altosui/AltosPad.java +++ b/ao-tools/altosui/AltosPad.java @@ -60,7 +60,7 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { label.setFont(label_font); label.setHorizontalAlignment(SwingConstants.LEFT); c.gridx = 1; c.gridy = y; - c.insets = new Insets(10, 10, 10, 10); + c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad); c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.VERTICAL; c.weightx = 0; @@ -90,7 +90,7 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { } public LaunchValue (GridBagLayout layout, int y, String text) { GridBagConstraints c = new GridBagConstraints(); - c.insets = new Insets(10, 10, 10, 10); + c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad); c.weighty = 1; label = new JLabel(text); @@ -151,17 +151,32 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { Main main; - class GPS extends LaunchStatus { + class GPSLocked extends LaunchStatus { void show (AltosState state, int crc_errors) { value.setText(String.format("%4d sats", state.gps.nsat)); + lights.set(state.gps.locked); + } + public GPSLocked (GridBagLayout layout, int y) { + super (layout, y, "GPS Locked"); + } + } + + GPSLocked gps_locked; + + class GPSReady extends LaunchStatus { + void show (AltosState state, int crc_errors) { + if (state.gps_ready) + value.setText("Ready"); + else + value.setText(String.format("Waiting %d", state.gps_waiting)); lights.set(state.gps_ready); } - public GPS (GridBagLayout layout, int y) { - super (layout, y, "GPS Status"); + public GPSReady (GridBagLayout layout, int y) { + super (layout, y, "GPS Ready"); } } - GPS gps; + GPSReady gps_ready; String pos(double p, String pos, String neg) { String h = pos; @@ -211,7 +226,8 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { battery.reset(); apogee.reset(); main.reset(); - gps.reset(); + gps_locked.reset(); + gps_ready.reset(); pad_lat.reset(); pad_lon.reset(); pad_alt.reset(); @@ -221,7 +237,8 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { battery.show(state, crc_errors); apogee.show(state, crc_errors); main.show(state, crc_errors); - gps.show(state, crc_errors); + gps_locked.show(state, crc_errors); + gps_ready.show(state, crc_errors); pad_lat.show(state, crc_errors); pad_lon.show(state, crc_errors); pad_alt.show(state, crc_errors); @@ -230,24 +247,27 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { public AltosPad() { layout = new GridBagLayout(); - label_font = new Font("Dialog", Font.PLAIN, 24); - value_font = new Font("Monospaced", Font.PLAIN, 24); + label_font = new Font("Dialog", Font.PLAIN, 22); + value_font = new Font("Monospaced", Font.PLAIN, 22); setLayout(layout); /* Elements in pad display: * * Battery voltage * Igniter continuity - * GPS lock status and location + * GPS lock status + * GPS ready status + * GPS location * Pad altitude * RSSI */ battery = new Battery(layout, 0); apogee = new Apogee(layout, 1); main = new Main(layout, 2); - gps = new GPS(layout, 3); - pad_lat = new PadLat(layout, 4); - pad_lon = new PadLon(layout, 5); - pad_alt = new PadAlt(layout, 6); + gps_locked = new GPSLocked(layout, 3); + gps_ready = new GPSReady(layout, 4); + pad_lat = new PadLat(layout, 5); + pad_lon = new PadLon(layout, 6); + pad_alt = new PadAlt(layout, 7); } } -- cgit v1.2.3 From 1a4b6e96f823035b113f01d1bdfd61afc1f33e25 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 16 Nov 2010 22:46:29 +0800 Subject: altosui: Add igniter status to ascent and descent tabs Monitor igniters during all phases of the flight. Signed-off-by: Keith Packard --- ao-tools/altosui/AltosAscent.java | 77 ++++++++++++++++++++++ ao-tools/altosui/AltosDescent.java | 130 +++++++++++++++++++++++++++++-------- ao-tools/altosui/AltosPad.java | 12 ++-- 3 files changed, 183 insertions(+), 36 deletions(-) diff --git a/ao-tools/altosui/AltosAscent.java b/ao-tools/altosui/AltosAscent.java index 8e1b6347..38ced95e 100644 --- a/ao-tools/altosui/AltosAscent.java +++ b/ao-tools/altosui/AltosAscent.java @@ -31,6 +31,53 @@ import java.util.concurrent.LinkedBlockingQueue; public class AltosAscent extends JComponent implements AltosFlightDisplay { GridBagLayout layout; + public class AscentStatus { + JLabel label; + JTextField value; + AltosLights lights; + + void show(AltosState state, int crc_errors) {} + void reset() { + value.setText(""); + lights.set(false); + } + + public AscentStatus (GridBagLayout layout, int y, String text) { + GridBagConstraints c = new GridBagConstraints(); + c.weighty = 1; + + lights = new AltosLights(); + c.gridx = 0; c.gridy = y; + c.anchor = GridBagConstraints.CENTER; + c.fill = GridBagConstraints.VERTICAL; + c.weightx = 0; + layout.setConstraints(lights, c); + add(lights); + + label = new JLabel(text); + label.setFont(Altos.label_font); + label.setHorizontalAlignment(SwingConstants.LEFT); + c.gridx = 1; c.gridy = y; + c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad); + c.anchor = GridBagConstraints.WEST; + c.fill = GridBagConstraints.VERTICAL; + c.weightx = 0; + layout.setConstraints(label, c); + add(label); + + value = new JTextField(15); + value.setFont(Altos.value_font); + value.setHorizontalAlignment(SwingConstants.RIGHT); + c.gridx = 2; c.gridy = y; + c.anchor = GridBagConstraints.WEST; + c.fill = GridBagConstraints.BOTH; + c.weightx = 1; + layout.setConstraints(value, c); + add(value); + + } + } + public class AscentValue { JLabel label; JTextField value; @@ -173,6 +220,30 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { return String.format("%s %4d° %9.6f", h, deg, min); } + class Apogee extends AscentStatus { + void show (AltosState state, int crc_errors) { + value.setText(String.format("%4.2f V", state.drogue_sense)); + lights.set(state.drogue_sense > 3.2); + } + public Apogee (GridBagLayout layout, int y) { + super(layout, y, "Apogee Igniter Voltage"); + } + } + + Apogee apogee; + + class Main extends AscentStatus { + void show (AltosState state, int crc_errors) { + value.setText(String.format("%4.2f V", state.main_sense)); + lights.set(state.main_sense > 3.2); + } + public Main (GridBagLayout layout, int y) { + super(layout, y, "Main Igniter Voltage"); + } + } + + Main main; + class Lat extends AscentValue { void show (AltosState state, int crc_errors) { if (state.gps != null) @@ -204,6 +275,8 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { public void reset() { lat.reset(); lon.reset(); + main.reset(); + apogee.reset(); height.reset(); speed.reset(); accel.reset(); @@ -213,6 +286,8 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { lat.show(state, crc_errors); lon.show(state, crc_errors); height.show(state, crc_errors); + main.show(state, crc_errors); + apogee.show(state, crc_errors); speed.show(state, crc_errors); accel.show(state, crc_errors); } @@ -253,5 +328,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { accel = new Accel(layout, 3); lat = new Lat(layout, 4); lon = new Lon(layout, 5); + apogee = new Apogee(layout, 6); + main = new Main(layout, 7); } } diff --git a/ao-tools/altosui/AltosDescent.java b/ao-tools/altosui/AltosDescent.java index ceb78e57..aacd2998 100644 --- a/ao-tools/altosui/AltosDescent.java +++ b/ao-tools/altosui/AltosDescent.java @@ -31,6 +31,52 @@ import java.util.concurrent.LinkedBlockingQueue; public class AltosDescent extends JComponent implements AltosFlightDisplay { GridBagLayout layout; + public class DescentStatus { + JLabel label; + JTextField value; + AltosLights lights; + + void show(AltosState state, int crc_errors) {} + void reset() { + value.setText(""); + lights.set(false); + } + + public DescentStatus (GridBagLayout layout, int y, String text) { + GridBagConstraints c = new GridBagConstraints(); + c.weighty = 1; + + lights = new AltosLights(); + c.gridx = 0; c.gridy = y; + c.anchor = GridBagConstraints.CENTER; + c.fill = GridBagConstraints.VERTICAL; + c.weightx = 0; + layout.setConstraints(lights, c); + add(lights); + + label = new JLabel(text); + label.setFont(Altos.label_font); + label.setHorizontalAlignment(SwingConstants.LEFT); + c.gridx = 1; c.gridy = y; + c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad); + c.anchor = GridBagConstraints.WEST; + c.fill = GridBagConstraints.VERTICAL; + c.weightx = 0; + layout.setConstraints(label, c); + add(label); + + value = new JTextField(15); + value.setFont(Altos.value_font); + value.setHorizontalAlignment(SwingConstants.RIGHT); + c.gridx = 2; c.gridy = y; + c.anchor = GridBagConstraints.WEST; + c.fill = GridBagConstraints.BOTH; + c.weightx = 1; + layout.setConstraints(value, c); + add(value); + + } + } public class DescentValue { JLabel label; JTextField value; @@ -44,14 +90,14 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { value.setText(String.format(format, v)); } - public DescentValue (GridBagLayout layout, int y, String text) { + public DescentValue (GridBagLayout layout, int x, int y, String text) { GridBagConstraints c = new GridBagConstraints(); c.weighty = 1; label = new JLabel(text); label.setFont(Altos.label_font); label.setHorizontalAlignment(SwingConstants.LEFT); - c.gridx = 0; c.gridy = y; + c.gridx = x + 0; c.gridy = y; c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad); c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.VERTICAL; @@ -59,11 +105,10 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { layout.setConstraints(label, c); add(label); - value = new JTextField(30); + value = new JTextField(17); value.setFont(Altos.value_font); value.setHorizontalAlignment(SwingConstants.RIGHT); - c.gridx = 1; c.gridy = y; - c.gridwidth = 2; + c.gridx = x + 1; c.gridy = y; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.BOTH; c.weightx = 1; @@ -76,8 +121,8 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { void show (AltosState state, int crc_errors) { show("%6.0f m", state.height); } - public Height (GridBagLayout layout, int y) { - super (layout, y, "Height"); + public Height (GridBagLayout layout, int x, int y) { + super (layout, x, y, "Height"); } } @@ -90,8 +135,8 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { speed = state.baro_speed; show("%6.0f m/s", speed); } - public Speed (GridBagLayout layout, int y) { - super (layout, y, "Speed"); + public Speed (GridBagLayout layout, int x, int y) { + super (layout, x, y, "Speed"); } } @@ -115,8 +160,8 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { else value.setText("???"); } - public Lat (GridBagLayout layout, int y) { - super (layout, y, "Latitude"); + public Lat (GridBagLayout layout, int x, int y) { + super (layout, x, y, "Latitude"); } } @@ -129,13 +174,37 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { else value.setText("???"); } - public Lon (GridBagLayout layout, int y) { - super (layout, y, "Longitude"); + public Lon (GridBagLayout layout, int x, int y) { + super (layout, x, y, "Longitude"); } } Lon lon; + class Apogee extends DescentStatus { + void show (AltosState state, int crc_errors) { + value.setText(String.format("%4.2f V", state.drogue_sense)); + lights.set(state.drogue_sense > 3.2); + } + public Apogee (GridBagLayout layout, int y) { + super(layout, y, "Apogee Igniter Voltage"); + } + } + + Apogee apogee; + + class Main extends DescentStatus { + void show (AltosState state, int crc_errors) { + value.setText(String.format("%4.2f V", state.main_sense)); + lights.set(state.main_sense > 3.2); + } + public Main (GridBagLayout layout, int y) { + super(layout, y, "Main Igniter Voltage"); + } + } + + Main main; + class Bearing { JLabel label; JTextField value; @@ -154,14 +223,14 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { value_deg.setText("???"); } } - public Bearing (GridBagLayout layout, int y) { + public Bearing (GridBagLayout layout, int x, int y) { GridBagConstraints c = new GridBagConstraints(); c.weighty = 1; label = new JLabel("Bearing"); label.setFont(Altos.label_font); label.setHorizontalAlignment(SwingConstants.LEFT); - c.gridx = 0; c.gridy = y; + c.gridx = x + 0; c.gridy = y; c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad); c.anchor = GridBagConstraints.WEST; c.weightx = 0; @@ -172,9 +241,10 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { value = new JTextField(30); value.setFont(Altos.value_font); value.setHorizontalAlignment(SwingConstants.RIGHT); - c.gridx = 1; c.gridy = y; + c.gridx = x + 1; c.gridy = y; c.anchor = GridBagConstraints.EAST; c.weightx = 1; + c.gridwidth = 2; c.fill = GridBagConstraints.BOTH; layout.setConstraints(value, c); add(value); @@ -182,7 +252,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { value_deg = new JTextField(5); value_deg.setFont(Altos.value_font); value_deg.setHorizontalAlignment(SwingConstants.RIGHT); - c.gridx = 2; c.gridy = y; + c.gridx = x + 3; c.gridy = y; c.anchor = GridBagConstraints.EAST; c.weightx = 1; c.fill = GridBagConstraints.BOTH; @@ -200,8 +270,8 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { else value.setText("???"); } - public Elevation (GridBagLayout layout, int y) { - super (layout, y, "Elevation"); + public Elevation (GridBagLayout layout, int x, int y) { + super (layout, x, y, "Elevation"); } } @@ -211,8 +281,8 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { void show (AltosState state, int crc_errors) { show("%6.0f m", state.range); } - public Range (GridBagLayout layout, int y) { - super (layout, y, "Range"); + public Range (GridBagLayout layout, int x, int y) { + super (layout, x, y, "Range"); } } @@ -226,6 +296,8 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { bearing.reset(); elevation.reset(); range.reset(); + main.reset(); + apogee.reset(); } public void show(AltosState state, int crc_errors) { @@ -236,6 +308,8 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { range.show(state, crc_errors); lat.show(state, crc_errors); lon.show(state, crc_errors); + main.show(state, crc_errors); + apogee.show(state, crc_errors); } public AltosDescent() { @@ -244,12 +318,12 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { setLayout(layout); /* Elements in descent display */ - speed = new Speed(layout, 0); - height = new Height(layout, 1); - bearing = new Bearing(layout, 2); - elevation = new Elevation(layout, 3); - range = new Range(layout, 4); - lat = new Lat(layout, 5); - lon = new Lon(layout, 6); + speed = new Speed(layout, 0, 0); height = new Height(layout, 2, 0); + elevation = new Elevation(layout, 0, 1); range = new Range(layout, 2, 1); + bearing = new Bearing(layout, 0, 2); + lat = new Lat(layout, 0, 3); + lon = new Lon(layout, 0, 4); + apogee = new Apogee(layout, 5); + main = new Main(layout, 6); } } diff --git a/ao-tools/altosui/AltosPad.java b/ao-tools/altosui/AltosPad.java index 8b258c7d..77289f89 100644 --- a/ao-tools/altosui/AltosPad.java +++ b/ao-tools/altosui/AltosPad.java @@ -30,8 +30,6 @@ import java.util.concurrent.LinkedBlockingQueue; public class AltosPad extends JComponent implements AltosFlightDisplay { GridBagLayout layout; - Font label_font; - Font value_font; public class LaunchStatus { JLabel label; @@ -57,7 +55,7 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { add(lights); label = new JLabel(text); - label.setFont(label_font); + label.setFont(Altos.label_font); label.setHorizontalAlignment(SwingConstants.LEFT); c.gridx = 1; c.gridy = y; c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad); @@ -68,7 +66,7 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { add(label); value = new JTextField(15); - value.setFont(value_font); + value.setFont(Altos.value_font); value.setHorizontalAlignment(SwingConstants.RIGHT); c.gridx = 2; c.gridy = y; c.anchor = GridBagConstraints.WEST; @@ -94,7 +92,7 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { c.weighty = 1; label = new JLabel(text); - label.setFont(label_font); + label.setFont(Altos.label_font); label.setHorizontalAlignment(SwingConstants.LEFT); c.gridx = 1; c.gridy = y; c.anchor = GridBagConstraints.WEST; @@ -104,7 +102,7 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { add(label); value = new JTextField(30); - value.setFont(value_font); + value.setFont(Altos.value_font); value.setHorizontalAlignment(SwingConstants.RIGHT); c.gridx = 2; c.gridy = y; c.anchor = GridBagConstraints.EAST; @@ -247,8 +245,6 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { public AltosPad() { layout = new GridBagLayout(); - label_font = new Font("Dialog", Font.PLAIN, 22); - value_font = new Font("Monospaced", Font.PLAIN, 22); setLayout(layout); /* Elements in pad display: -- cgit v1.2.3