X-Git-Url: https://git.gag.com/?a=blobdiff_plain;ds=sidebyside;f=telegps%2FTeleGPS.java;h=5e500e0259a74623e6d934d2e85b876bc0107d2a;hb=855a7d243a5a85728a7b23fdfe9485d4ecaf71cf;hp=2897e06a321cf6e0ac7a547e36c65a1e59985dc0;hpb=0d966b74f756e88e5dffa92400b105f540429262;p=fw%2Faltos diff --git a/telegps/TeleGPS.java b/telegps/TeleGPS.java index 2897e06a..5e500e02 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 @@ -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) { @@ -286,23 +287,30 @@ public class TeleGPS 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, series.cal_data, 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) { } @@ -611,33 +619,39 @@ public class TeleGPS connect(device); } - static AltosStateIterable record_iterable(File file) { + static AltosRecordSet record_set(File file) { FileInputStream in; - 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); + if (file.getName().endsWith("telem")) { + try { + in = new FileInputStream(file); + return new AltosTelemetryFile(in); + } catch (Exception e) { + System.out.printf("Failed to open file '%s'\n", file); + } + } else { + + try { + return new AltosEepromFile(new FileReader(file)); + } catch (Exception e) { + System.out.printf("Failed to open file '%s'\n", file); + } + } + 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; }