X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=telegps%2FTeleGPS.java;h=24cc379fcec9a1879068d5154de8fcfc60c3c4fb;hp=d347fe4180be80c419a24aefc6934e79e97ee34e;hb=338372b97d441c30d2a23df540163a66a7f8d8c0;hpb=1ea855f95772a8a394407e0070be1ed9cc0f6650 diff --git a/telegps/TeleGPS.java b/telegps/TeleGPS.java index d347fe41..24cc379f 100644 --- a/telegps/TeleGPS.java +++ b/telegps/TeleGPS.java @@ -3,7 +3,8 @@ * * 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. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of @@ -24,12 +25,12 @@ import java.io.*; import java.util.concurrent.*; import java.util.*; import java.text.*; -import org.altusmetrum.altoslib_11.*; -import org.altusmetrum.altosuilib_11.*; +import org.altusmetrum.altoslib_13.*; +import org.altusmetrum.altosuilib_13.*; public class TeleGPS extends AltosUIFrame - implements AltosFlightDisplay, AltosFontListener, AltosUnitsListener, ActionListener + implements AltosFlightDisplay, AltosFontListener, AltosUnitsListener, ActionListener, AltosEepromGrapher { static String[] telegps_icon_names = { @@ -72,7 +73,7 @@ public class TeleGPS JTabbedPane pane; - AltosUIMapNew map; + AltosUIMap map; TeleGPSInfo gps_info; TeleGPSState gps_state; AltosInfoTable info_table; @@ -151,7 +152,7 @@ public class TeleGPS status_update.saved_listener_state = listener_state; if (state == null) - state = new AltosState(); + state = new AltosState(new AltosCalData()); int i = 0; for (AltosFlightDisplay display : displays) { @@ -174,7 +175,7 @@ public class TeleGPS } void load_maps() { - new AltosUIMapPreloadNew(this); + new AltosUIMapPreload(this); } void disconnect() { @@ -279,35 +280,57 @@ public class TeleGPS } void download(){ - new AltosEepromManage(this, AltosLib.product_telegps); + new AltosEepromManage(this, this, AltosLib.product_telegps); } void configure() { new TeleGPSConfig(this); } + private static AltosFlightSeries make_series(AltosRecordSet set) { + AltosFlightSeries series = new AltosFlightSeries(set.cal_data()); + set.capture_series(series); + series.finish(); + return series; + } + void export() { - AltosDataChooser chooser; - chooser = new AltosDataChooser(this); - AltosStateIterable states = chooser.runDialog(); - if (states == null) + AltosDataChooser chooser = new AltosDataChooser(this); + + AltosRecordSet set = chooser.runDialog(); + if (set == null) return; - new AltosCSVUI(this, states, chooser.file()); + AltosFlightSeries series = make_series(set); + new AltosCSVUI(this, series, chooser.file()); } void graph() { - AltosDataChooser chooser; - chooser = new AltosDataChooser(this); - AltosStateIterable states = chooser.runDialog(); - if (states == null) + AltosDataChooser chooser = new AltosDataChooser(this); + AltosRecordSet set = chooser.runDialog(); + if (set == null) return; try { - new TeleGPSGraphUI(states, chooser.file()); + new TeleGPSGraphUI(set, chooser.file()); } catch (InterruptedException ie) { } catch (IOException ie) { } } + public void graph_flights(AltosEepromList list) { + for (AltosEepromLog log : list) { + if (log.file != null) { + AltosRecordSet set = record_set(log.file); + if (set != null) { + try { + new TeleGPSGraphUI(set, log.file); + } catch (InterruptedException ie) { + } catch (IOException ie) { + } + } + } + } + } + void flash() { AltosFlashUI.show(this); } @@ -567,7 +590,7 @@ public class TeleGPS /* Make the tabbed pane use the rest of the window space */ bag.add(pane, constraints(0, 3, GridBagConstraints.BOTH)); - map = new AltosUIMapNew(); + map = new AltosUIMap(); pane.add(map.getName(), map); displays.add(map); @@ -611,33 +634,28 @@ public class TeleGPS connect(device); } - static AltosStateIterable record_iterable(File file) { - FileInputStream in; + static AltosRecordSet record_set(File file) { try { - in = new FileInputStream(file); - } catch (Exception e) { - System.out.printf("Failed to open file '%s'\n", file); - return null; - } - if (file.getName().endsWith("telem")) - return new AltosTelemetryFile(in); - else - return new AltosEepromFile(in); + return AltosLib.record_set(file); + } catch (IOException ie) { + System.out.printf("%s\n", ie.getMessage()); + } + return null; } static AltosReplayReader replay_file(File file) { - AltosStateIterable states = record_iterable(file); - if (states == null) + AltosRecordSet set = record_set(file); + if (set == null) return null; - return new AltosReplayReader(states.iterator(), file); + return new AltosReplayReader(set, file); } static boolean process_graph(File file) { - AltosStateIterable states = record_iterable(file); - if (states == null) + AltosRecordSet set = record_set(file); + if (set == null) return false; try { - new TeleGPSGraphUI(states, file); + new TeleGPSGraphUI(set, file); } catch (Exception e) { return false; }