X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=telegps%2FTeleGPS.java;h=7f34c763428b1cc750de4303620773e1a1398af7;hp=ca1e68bbe74631bf663cb0490d78b2e5295145d1;hb=13f84be8d1568a3fc2ed5eef5dcc2093c149285e;hpb=a7fd31842a602a8ac803d0e09efb4ffabf7a289b diff --git a/telegps/TeleGPS.java b/telegps/TeleGPS.java index ca1e68bb..7f34c763 100644 --- a/telegps/TeleGPS.java +++ b/telegps/TeleGPS.java @@ -53,6 +53,7 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo JTabbedPane pane; AltosSiteMap sitemap; + TeleGPSInfo gps_info; boolean has_map; JMenuBar menu_bar; @@ -88,21 +89,19 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo /* Device menu */ final static String download_command = "download"; - final static String configure_command = "configure"; final static String export_command = "export"; final static String graph_command = "graph"; + final static String configure_command = "configure"; + final static String flash_command = "flash"; static final String[][] device_menu_entries = new String[][] { { "Download Data", download_command }, { "Configure Device", configure_command }, { "Export Data", export_command }, { "Graph Data", graph_command }, + { "Flash Device", flash_command }, }; -// private AltosInfoTable flightInfo; - - boolean exit_on_close = false; - void stop_display() { if (thread != null && thread.isAlive()) { thread.interrupt(); @@ -115,10 +114,12 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo public void reset() { sitemap.reset(); + gps_info.reset(); } public void set_font() { sitemap.set_font(); + gps_info.set_font(); } public void font_size_changed(int font_size) { @@ -135,6 +136,7 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo state = new AltosState(); sitemap.show(state, listener_state); + gps_info.show(state, listener_state); telegps_status.show(state, listener_state); } @@ -151,17 +153,20 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo } void preferences() { + new TeleGPSPreferences(this, voice()); } void load_maps() { new AltosSiteMapPreload(this); } - void monitor() { - AltosDevice device = AltosDeviceUIDialog.show(this, - AltosLib.product_basestation); - if (device == null) - return; + void disconnect() { + setTitle("TeleGPS"); + stop_display(); + remove_frequency_menu(); + } + + void connect(AltosDevice device) { if (reader != null) disconnect(); try { @@ -197,16 +202,24 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo } } - void disconnect() { - setTitle("TeleGPS"); - stop_display(); - remove_frequency_menu(); + void monitor() { + AltosDevice device = AltosDeviceUIDialog.show(this, + AltosLib.product_basestation); + if (device == null) + return; + connect(device); + } + + public void scan_device_selected(AltosDevice device) { + connect(device); } void scan() { + new AltosScanUI(this, false); } void download(){ + new AltosEepromManage(this, AltosLib.product_telegps); } void configure() { @@ -214,11 +227,21 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo } void export() { + AltosDataChooser chooser; + chooser = new AltosDataChooser(this); + AltosStateIterable states = chooser.runDialog(); + if (states == null) + return; + new AltosCSVUI(this, states, chooser.file()); } void graph() { } + void flash() { + AltosFlashUI.show(this); + } + public void actionPerformed(ActionEvent ev) { /* File menu */ @@ -272,6 +295,10 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo graph(); return; } + if (flash_command.equals(ev.getActionCommand())) { + flash(); + return; + } } void add_frequency_menu(int serial, final AltosFlightReader reader) { @@ -383,6 +410,9 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo sitemap = new AltosSiteMap(); pane.add("Site Map", sitemap); + gps_info = new TeleGPSInfo(); + pane.add("Info", gps_info); + setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); AltosUIPreferences.register_font_listener(this); @@ -409,6 +439,11 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo set_reader(reader); } + public TeleGPS(AltosDevice device) { + this(); + connect(device); + } + static AltosStateIterable record_iterable(File file) { FileInputStream in; try { @@ -538,7 +573,15 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo } if (errors != 0) System.exit(errors); - if (!any_created) - new TeleGPS(); + if (!any_created) { + java.util.List devices = AltosUSBDevice.list(AltosLib.product_basestation); + if (devices != null) + for (AltosDevice device : devices) { + new TeleGPS(device); + any_created = true; + } + if (!any_created) + new TeleGPS(); + } } }