X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altosui%2FAltosUI.java;h=75a12ecef1b6d0f174e37281098ae49d76e7ebd6;hb=cf1e95810559584705d0b8a787375938c68e07c6;hp=0317f569d53239439a3484a0dfc5cdecdf5ba256;hpb=4e2fd7ae76c23aa8da1390ebcbd8f45276cd7a32;p=fw%2Faltos diff --git a/altosui/AltosUI.java b/altosui/AltosUI.java index 0317f569..75a12ece 100644 --- a/altosui/AltosUI.java +++ b/altosui/AltosUI.java @@ -30,7 +30,7 @@ import java.util.concurrent.*; import libaltosJNI.*; -public class AltosUI extends JFrame { +public class AltosUI extends AltosFrame { public AltosVoice voice = new AltosVoice(); public static boolean load_library(Frame frame) { @@ -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,86 +122,108 @@ 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 = addButton(2, 1, "Configure Ground Station"); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - FlashImage(); + ConfigureTeleDongle(); } }); - b = addButton(3, 1, "Fire Igniter"); + b = addButton(3, 1, "Flash Image"); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - FireIgniter(); + FlashImage(); } }); + b.setToolTipText("Replace the firmware in any AltusMetrum product"); - b = addButton(4, 1, "Quit"); + b = addButton(4, 1, "Fire Igniter"); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - System.exit(0); + FireIgniter(); } }); - - + b.setToolTipText("Remote control of igniters for deployment testing"); 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(); + } + }); + + b = addButton(4, 2, "Quit"); + b.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + System.exit(0); + } + }); + b.setToolTipText("Close all active windows and terminate AltosUI"); setTitle("AltOS"); @@ -250,6 +271,10 @@ public class AltosUI extends JFrame { new AltosConfig(AltosUI.this); } + void ConfigureTeleDongle() { + new AltosConfigTD(AltosUI.this); + } + void FlashImage() { AltosFlashUI.show(AltosUI.this); } @@ -266,6 +291,10 @@ public class AltosUI extends JFrame { new AltosSiteMapPreload(AltosUI.this); } + void LaunchController() { + new AltosLaunchUI(AltosUI.this); + } + /* * Replay a flight from telemetry data */ @@ -339,7 +368,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 +378,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 +388,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 +398,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,47 +436,93 @@ public class AltosUI extends JFrame { } } - static void process_replay(String filename) { + static AltosRecordIterable record_iterable(File file) { FileInputStream in; try { - in = new FileInputStream(filename); + in = new FileInputStream(file); } catch (Exception e) { - System.out.printf("Failed to open file '%s'\n", filename); - return; + System.out.printf("Failed to open file '%s'\n", file); + return null; } AltosRecordIterable recs; AltosReplayReader reader; - if (filename.endsWith("eeprom")) { + if (file.getName().endsWith("eeprom")) { recs = new AltosEepromIterable(in); } else { recs = new AltosTelemetryIterable(in); } - reader = new AltosReplayReader(recs.iterator(), new File(filename)); + return recs; + } + + static AltosRecordIterable record_iterable_file(String filename) { + return record_iterable (new File(filename)); + } + + 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) { + AltosRecordIterable iterable = record_iterable_file(filename); + try { + AltosFlightStats stats = new AltosFlightStats(iterable); + 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 +535,10 @@ public class AltosUI extends JFrame { } public static void main(final String[] args) { + try { + UIManager.setLookAndFeel(AltosPreferences.look_and_feel()); + } catch (Exception e) { + } /* Handle batch-mode */ if (args.length == 0) { AltosUI altosui = new AltosUI(); @@ -489,6 +569,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 +588,9 @@ public class AltosUI extends JFrame { case process_csv: process_csv(args[i]); break; + case process_summary: + process_summary(args[i]); + break; } } }