X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altosui%2FAltosLog.java;h=a5f1830d89d0986149cf1bc88781dcc82296cb77;hb=e268798dc260311f5f0167909481b41c9d27fc1c;hp=dd147d21adb960818ff3d26423f7c5e48816ba36;hpb=3fbefb3eea981d34a09496cf8abf0119de2e35bf;p=fw%2Faltos diff --git a/altosui/AltosLog.java b/altosui/AltosLog.java index dd147d21..a5f1830d 100644 --- a/altosui/AltosLog.java +++ b/altosui/AltosLog.java @@ -35,6 +35,7 @@ class AltosLog implements Runnable { int flight; FileWriter log_file; Thread log_thread; + AltosFile file; private void close_log_file() { if (log_file != null) { @@ -54,9 +55,14 @@ class AltosLog implements Runnable { } } - boolean open (AltosTelemetry telem) throws IOException { + File file() { + return file; + } + + boolean open (AltosRecord telem) throws IOException { AltosFile a = new AltosFile(telem); + System.out.printf("open %s\n", a.toString()); log_file = new FileWriter(a, true); if (log_file != null) { while (!pending_queue.isEmpty()) { @@ -68,24 +74,29 @@ class AltosLog implements Runnable { } } log_file.flush(); + file = a; } return log_file != null; } public void run () { try { + AltosRecord previous = null; for (;;) { AltosLine line = input_queue.take(); if (line.line == null) continue; try { - AltosTelemetry telem = new AltosTelemetry(line.line); - if (telem.serial != serial || telem.flight != flight || log_file == null) { + AltosRecord telem = AltosTelemetry.parse(line.line, previous); + if (telem.serial != 0 && telem.flight != 0 && + (telem.serial != serial || telem.flight != flight || log_file == null)) + { close_log_file(); serial = telem.serial; flight = telem.flight; open(telem); } + previous = telem; } catch (ParseException pe) { } catch (AltosCRCException ce) { }