X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=telegps%2FTeleGPS.java;h=af6d01b427126c1071a3d4c95beee4d536011401;hb=ee7a54b3215ffa1eb38f16a151c0740b14b60857;hp=cf2cbd4fefce4e114fb8605cbdda3a2a5ff535cb;hpb=238e56e0f6ab2f623e0faf25298b38dc3a4aff74;p=fw%2Faltos diff --git a/telegps/TeleGPS.java b/telegps/TeleGPS.java index cf2cbd4f..af6d01b4 100644 --- a/telegps/TeleGPS.java +++ b/telegps/TeleGPS.java @@ -25,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 = { @@ -152,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) { @@ -280,32 +280,42 @@ 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) - return; - try { - new TeleGPSGraphUI(states, chooser.file()); - } catch (InterruptedException ie) { - } catch (IOException ie) { + AltosDataChooser chooser = new AltosDataChooser(this); + AltosRecordSet set = chooser.runDialog(); + graph_file(this, set, chooser.file()); + } + + public void graph_flights(AltosEepromList list) { + for (AltosEepromLog log : list) { + if (log.file != null) { + AltosRecordSet set = record_set(log.file); + graph_file(this, set, log.file); + } } } @@ -612,46 +622,45 @@ public class TeleGPS connect(device); } - static AltosStateIterable record_iterable(File file) { - FileInputStream 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 { - AltosEepromFile f = new AltosEepromFile(new FileReader(file)); - return f; - } catch (Exception e) { - System.out.printf("Failed to open file '%s'\n", file); - } + static AltosRecordSet record_set(File file) { + try { + 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) + private static boolean graph_file(TeleGPS telegps, AltosRecordSet set, File file) { + if (set == null) + return false; + if (!set.valid()) { + JOptionPane.showMessageDialog(telegps, + String.format("Failed to parse file %s", file), + "Graph Failed", + JOptionPane.ERROR_MESSAGE); return false; + } try { - new TeleGPSGraphUI(states, file); + new TeleGPSGraphUI(set, file); } catch (Exception e) { return false; } return true; } + static boolean process_graph(File file) { + AltosRecordSet set = record_set(file); + return graph_file(null, set, file); + } + static boolean process_replay(File file) { AltosReplayReader new_reader = replay_file(file); if (new_reader == null)