int flight;
FileWriter log_file;
Thread log_thread;
+ AltosFile file;
private void close_log_file() {
if (log_file != null) {
}
}
- 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()) {
}
}
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) {
}