X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=telegps%2FTeleGPS.java;h=0250a38ee3ef1b4d6ba031e874292574c0f05eac;hb=debian;hp=5e500e0259a74623e6d934d2e85b876bc0107d2a;hpb=855a7d243a5a85728a7b23fdfe9485d4ecaf71cf;p=fw%2Faltos diff --git a/telegps/TeleGPS.java b/telegps/TeleGPS.java index 5e500e02..77ed0da7 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_14.*; +import org.altusmetrum.altosuilib_14.*; public class TeleGPS extends AltosUIFrame - implements AltosFlightDisplay, AltosFontListener, AltosUnitsListener, ActionListener + implements AltosFlightDisplay, AltosFontListener, AltosUnitsListener, ActionListener, AltosEepromGrapher { static String[] telegps_icon_names = { @@ -280,7 +280,7 @@ public class TeleGPS } void download(){ - new AltosEepromManage(this, AltosLib.product_telegps); + new AltosEepromManage(this, this, AltosLib.product_telegps); } void configure() { @@ -301,18 +301,21 @@ public class TeleGPS if (set == null) return; AltosFlightSeries series = make_series(set); - new AltosCSVUI(this, series, series.cal_data, chooser.file()); + new AltosCSVUI(this, series, chooser.file()); } void graph() { AltosDataChooser chooser = new AltosDataChooser(this); AltosRecordSet set = chooser.runDialog(); - if (set == null) - return; - try { - new TeleGPSGraphUI(set, chooser.file()); - } catch (InterruptedException ie) { - } catch (IOException ie) { + 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); + } } } @@ -620,21 +623,10 @@ public class TeleGPS } static AltosRecordSet record_set(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 { - return new AltosEepromFile(new FileReader(file)); - } catch (Exception e) { - System.out.printf("Failed to open file '%s'\n", file); - } + try { + return AltosLib.record_set(file); + } catch (IOException ie) { + System.out.printf("%s\n", ie.getMessage()); } return null; } @@ -646,18 +638,32 @@ public class TeleGPS return new AltosReplayReader(set, file); } - static boolean process_graph(File file) { - AltosRecordSet set = record_set(file); + 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(set, file); - } catch (Exception e) { + } catch (IOException e) { + System.out.printf("Exception %s\n", e.toString()); + } catch (InterruptedException e) { + System.out.printf("Exception %s\n", e.toString()); 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)