X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosui%2FAltosUI.java;h=3e5bcf434fc5b8b8276fe2074873e528d8032d74;hp=b2c5107e2ca6aee02ca3f4e55ed4c4fee43d31ae;hb=31e3255b6cbfaf95c0e97e2d1ec8de72f845994c;hpb=55be3db2e31fe97e7f351e3c490b8bc4cf7192b2 diff --git a/altosui/AltosUI.java b/altosui/AltosUI.java index b2c5107e..3e5bcf43 100644 --- a/altosui/AltosUI.java +++ b/altosui/AltosUI.java @@ -52,8 +52,7 @@ public class AltosUI extends JFrame { new AltosFlightUI(voice, reader, device.getSerial()); } catch (FileNotFoundException ee) { JOptionPane.showMessageDialog(AltosUI.this, - String.format("Cannot open device \"%s\"", - device.toShortString()), + ee.getMessage(), "Cannot open target device", JOptionPane.ERROR_MESSAGE); } catch (AltosSerialInUseException si) { @@ -123,50 +122,56 @@ public class AltosUI extends JFrame { ConnectToDevice(); } }); + b.setToolTipText("Connect to TeleDongle and monitor telemetry"); b = addButton(1, 0, "Save Flight Data"); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SaveFlightData(); } }); + b.setToolTipText("Download and/or delete flight data from an altimeter"); b = addButton(2, 0, "Replay Flight"); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Replay(); } }); + b.setToolTipText("Watch an old flight in real-time"); b = addButton(3, 0, "Graph Data"); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { GraphData(); } }); + b.setToolTipText("Present flight data in a graph and table of statistics"); b = addButton(4, 0, "Export Data"); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ExportData(); } }); + b.setToolTipText("Convert flight data for a spreadsheet or GoogleEarth"); b = addButton(0, 1, "Configure Altimeter"); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ConfigureTeleMetrum(); } }); - + b.setToolTipText("Set flight, storage and communication parameters"); b = addButton(1, 1, "Configure AltosUI"); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ConfigureAltosUI(); } }); - + b.setToolTipText("Global AltosUI settings"); b = addButton(2, 1, "Flash Image"); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { FlashImage(); } }); + b.setToolTipText("Replace the firmware in any AltusMetrum product"); b = addButton(3, 1, "Fire Igniter"); b.addActionListener(new ActionListener() { @@ -174,35 +179,42 @@ public class AltosUI extends JFrame { FireIgniter(); } }); - + b.setToolTipText("Remote control of igniters for deployment testing"); b = addButton(4, 1, "Quit"); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); - - + b.setToolTipText("Close all active windows and terminate AltosUI"); b = addButton(0, 2, "Scan Channels"); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ScanChannels(); } }); - + b.setToolTipText("Find what channel an altimeter is sending telemetry on"); b = addButton(1, 2, "Load Maps"); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { LoadMaps(); } }); - + b.setToolTipText("Download satellite images for off-line flight monitoring"); b = addButton(2, 2, "Monitor Idle"); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { IdleMonitor(); } }); + b.setToolTipText("Check flight readiness of altimeter in idle mode"); + + b = addButton(3, 2, "Launch Controller"); + b.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + LaunchController(); + } + }); setTitle("AltOS"); @@ -266,6 +278,10 @@ public class AltosUI extends JFrame { new AltosSiteMapPreload(AltosUI.this); } + void LaunchController() { + new AltosLaunchUI(AltosUI.this); + } + /* * Replay a flight from telemetry data */ @@ -311,7 +327,7 @@ public class AltosUI extends JFrame { if (record_reader == null) return; try { - new AltosGraphUI(record_reader); + new AltosGraphUI(record_reader, chooser.filename()); } catch (InterruptedException ie) { } catch (IOException ie) { } @@ -339,7 +355,7 @@ public class AltosUI extends JFrame { else return new AltosTelemetryIterable(in); } catch (FileNotFoundException fe) { - System.out.printf("Cannot open '%s'\n", filename); + System.out.printf("%s\n", fe.getMessage()); return null; } } @@ -349,7 +365,7 @@ public class AltosUI extends JFrame { try { return new AltosCSV(file); } catch (FileNotFoundException fe) { - System.out.printf("Cannot open '%s'\n", filename); + System.out.printf("%s\n", fe.getMessage()); return null; } } @@ -359,7 +375,7 @@ public class AltosUI extends JFrame { try { return new AltosKML(file); } catch (FileNotFoundException fe) { - System.out.printf("Cannot open '%s'\n", filename); + System.out.printf("%s\n", fe.getMessage()); return null; } } @@ -369,6 +385,7 @@ public class AltosUI extends JFrame { static final int process_kml = 2; static final int process_graph = 3; static final int process_replay = 4; + static final int process_summary = 5; static void process_csv(String input) { AltosRecordIterable iterable = open_logfile(input); @@ -406,13 +423,13 @@ public class AltosUI extends JFrame { } } - static void process_replay(String filename) { + static AltosRecordIterable record_iterable_file(String filename) { FileInputStream in; try { in = new FileInputStream(filename); } catch (Exception e) { System.out.printf("Failed to open file '%s'\n", filename); - return; + return null; } AltosRecordIterable recs; AltosReplayReader reader; @@ -421,32 +438,74 @@ public class AltosUI extends JFrame { } else { recs = new AltosTelemetryIterable(in); } - reader = new AltosReplayReader(recs.iterator(), new File(filename)); + return recs; + } + + static AltosReplayReader replay_file(String filename) { + AltosRecordIterable recs = record_iterable_file(filename); + if (recs == null) + return null; + return new AltosReplayReader(recs.iterator(), new File(filename)); + } + + static void process_replay(String filename) { + AltosReplayReader reader = replay_file(filename); AltosFlightUI flight_ui = new AltosFlightUI(new AltosVoice(), reader); flight_ui.set_exit_on_close(); } static void process_graph(String filename) { - FileInputStream in; - try { - in = new FileInputStream(filename); - } catch (Exception e) { - System.out.printf("Failed to open file '%s'\n", filename); + AltosRecordIterable recs = record_iterable_file(filename); + if (recs == null) return; - } - AltosRecordIterable recs; - if (filename.endsWith("eeprom")) { - recs = new AltosEepromIterable(in); - } else { - recs = new AltosTelemetryIterable(in); - } try { - new AltosGraphUI(recs); + new AltosGraphUI(recs, filename); } catch (InterruptedException ie) { } catch (IOException ie) { } } + static void process_summary(String filename) { + AltosReplayReader reader = replay_file(filename); + try { + AltosFlightStats stats = new AltosFlightStats(reader); + if (stats.serial > 0) + System.out.printf("Serial: %5d\n", stats.serial); + if (stats.flight > 0) + System.out.printf("Flight: %5d\n", stats.flight); + if (stats.year > 0) + System.out.printf("Date: %04d-%02d-%02d\n", + stats.year, stats.month, stats.day); + if (stats.hour > 0) + System.out.printf("Time: %02d:%02d:%02d UTC\n", + stats.hour, stats.minute, stats.second); + System.out.printf("Max height: %6.0f m %6.0f ft\n", + stats.max_height, + AltosConvert.meters_to_feet(stats.max_height)); + System.out.printf("Max speed: %6.0f m/s %6.0f ft/s %6.4f Mach\n", + stats.max_speed, + AltosConvert.meters_to_feet(stats.max_speed), + AltosConvert.meters_to_mach(stats.max_speed)); + if (stats.max_acceleration != AltosRecord.MISSING) { + System.out.printf("Max accel: %6.0f m/s² %6.0f ft/s² %6.2f g\n", + stats.max_acceleration, + AltosConvert.meters_to_feet(stats.max_acceleration), + AltosConvert.meters_to_g(stats.max_acceleration)); + } + System.out.printf("Drogue rate: %6.0f m/s %6.0f ft/s\n", + stats.state_baro_speed[Altos.ao_flight_drogue], + AltosConvert.meters_to_feet(stats.state_baro_speed[Altos.ao_flight_drogue])); + System.out.printf("Main rate: %6.0f m/s %6.0f ft/s\n", + stats.state_baro_speed[Altos.ao_flight_main], + AltosConvert.meters_to_feet(stats.state_baro_speed[Altos.ao_flight_main])); + System.out.printf("Flight time: %6.0f s\n", + stats.state_end[Altos.ao_flight_main] - + stats.state_start[Altos.ao_flight_boost]); + } catch (InterruptedException ie) { + } catch (IOException ie) { + } + } + public static void help(int code) { System.out.printf("Usage: altosui [OPTION]... [FILE]...\n"); System.out.printf(" Options:\n"); @@ -459,6 +518,10 @@ public class AltosUI extends JFrame { } public static void main(final String[] args) { + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } catch (Exception e) { + } /* Handle batch-mode */ if (args.length == 0) { AltosUI altosui = new AltosUI(); @@ -489,6 +552,8 @@ public class AltosUI extends JFrame { process = process_csv; else if (args[i].equals("--graph")) process = process_graph; + else if (args[i].equals("--summary")) + process = process_summary; else if (args[i].startsWith("--")) help(1); else { @@ -506,6 +571,9 @@ public class AltosUI extends JFrame { case process_csv: process_csv(args[i]); break; + case process_summary: + process_summary(args[i]); + break; } } }