altosui: Make sure packet mode is turned off when the connection fails
[fw/altos] / ao-tools / altosui / AltosUI.java
index 5e9566f076ab6e994cf581ae00007be8f3a1185a..94c4dd2aa4b10bb2ae6424268344f0c9ace981f6 100644 (file)
@@ -53,18 +53,18 @@ public class AltosUI extends JFrame {
                } catch (FileNotFoundException ee) {
                        JOptionPane.showMessageDialog(AltosUI.this,
                                                      String.format("Cannot open device \"%s\"",
-                                                                   device.getPath()),
+                                                                   device.toShortString()),
                                                      "Cannot open target device",
                                                      JOptionPane.ERROR_MESSAGE);
                } catch (AltosSerialInUseException si) {
                        JOptionPane.showMessageDialog(AltosUI.this,
                                                      String.format("Device \"%s\" already in use",
-                                                                   device.getPath()),
+                                                                   device.toShortString()),
                                                      "Device in use",
                                                      JOptionPane.ERROR_MESSAGE);
                } catch (IOException ee) {
                        JOptionPane.showMessageDialog(AltosUI.this,
-                                                     device.getPath(),
+                                                     device.toShortString(),
                                                      "Unkonwn I/O error",
                                                      JOptionPane.ERROR_MESSAGE);
                }
@@ -230,8 +230,9 @@ public class AltosUI extends JFrame {
         * Replay a flight from telemetry data
         */
        private void Replay() {
-               AltosLogfileChooser chooser = new AltosLogfileChooser(
+               AltosDataChooser chooser = new AltosDataChooser(
                        AltosUI.this);
+
                AltosRecordIterable iterable = chooser.runDialog();
                if (iterable != null) {
                        AltosFlightReader reader = new AltosReplayReader(iterable.iterator(),
@@ -252,14 +253,24 @@ public class AltosUI extends JFrame {
         */
 
        private void ExportData() {
-               new AltosCSVUI(AltosUI.this);
+               AltosDataChooser chooser;
+               chooser = new AltosDataChooser(this);
+               AltosRecordIterable record_reader = chooser.runDialog();
+               if (record_reader == null)
+                       return;
+               new AltosCSVUI(AltosUI.this, record_reader, chooser.file());
        }
 
        /* Load a flight log CSV file and display a pretty graph.
         */
 
        private void GraphData() {
-               new AltosGraphUI(AltosUI.this);
+               AltosDataChooser chooser;
+               chooser = new AltosDataChooser(this);
+               AltosRecordIterable record_reader = chooser.runDialog();
+               if (record_reader == null)
+                       return;
+               new AltosGraphUI(record_reader);
        }
 
        private void ConfigureAltosUI() {
@@ -342,7 +353,18 @@ 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")) {
+        if (args.length == 1 && args[0].equals("--help")) {
+               System.out.printf("Usage: altosui [OPTION]... [FILE]...\n");
+               System.out.printf("  Options:\n");
+               System.out.printf("    --fetchmaps <lat> <lon>\tpre-fetch maps for site map view\n");
+               System.out.printf("    --replay <filename>\t\trelive the glory of past flights \n");
+               System.out.printf("    --csv\tgenerate comma separated output for spreadsheets, etc\n");
+               System.out.printf("    --kml\tgenerate KML output for use with Google Earth\n");
+        } else if (args.length == 3 && args[0].equals("--fetchmaps")) {
+            double lat = Double.parseDouble(args[1]);
+            double lon = Double.parseDouble(args[2]);
+            AltosSiteMap.prefetchMaps(lat, lon, 5, 5);
+        } else if (args.length == 2 && args[0].equals("--replay")) {
                        String filename = args[1];
                        FileInputStream in;
                        try {