import java.util.*;
import java.text.ParseException;
import java.util.concurrent.LinkedBlockingQueue;
-import altosui.AltosSerial;
-import altosui.AltosFile;
-import altosui.AltosLine;
/*
* This creates a thread to capture telemetry data and write it to
FileWriter log_file;
Thread log_thread;
- void close() throws IOException {
- if (log_file != null)
- log_file.close();
+ private void close_log_file() {
+ if (log_file != null) {
+ try {
+ log_file.close();
+ } catch (IOException io) {
+ }
+ log_file = null;
+ }
+ }
+
+ void close() {
+ close_log_file();
+ if (log_thread != null) {
+ log_thread.interrupt();
+ log_thread = null;
+ }
}
boolean open (AltosTelemetry telem) throws IOException {
try {
AltosTelemetry telem = new AltosTelemetry(line.line);
if (telem.serial != serial || telem.flight != flight || log_file == null) {
- close();
+ close_log_file();
serial = telem.serial;
flight = telem.flight;
open(telem);
} catch (InterruptedException ie) {
} catch (IOException ie) {
}
- try {
- close();
- } catch (IOException ie) {
- }
+ close();
}
public AltosLog (AltosSerial s) {