class IdleThread extends Thread {
+ boolean started;
private AltosState state;
int reported_landing;
public void notice(AltosState new_state) {
AltosState old_state = state;
state = new_state;
+ if (!started && state.state > Altos.ao_flight_pad) {
+ started = true;
+ start();
+ }
if (old_state != null && old_state.state != state.state)
report(false);
}
AltosRecord read() throws InterruptedException, ParseException, AltosCRCException, IOException { return null; }
- void close() { }
+ void close(boolean interrupted) { }
void update(AltosState state) throws InterruptedException { }
public void run() {
+ boolean interrupted = false;
String line;
AltosState state = null;
AltosState old_state = null;
info_reset();
info_finish();
- idle_thread.start();
try {
for (;;) {
try {
}
}
} catch (InterruptedException ee) {
+ interrupted = true;
} catch (IOException ie) {
JOptionPane.showMessageDialog(AltosUI.this,
String.format("Error reading from \"%s\"", name),
"Telemetry Read Error",
JOptionPane.ERROR_MESSAGE);
} finally {
- close();
+ close(interrupted);
idle_thread.interrupt();
+ try {
+ idle_thread.join();
+ } catch (InterruptedException ie) {}
}
}
return new AltosTelemetry(l.line);
}
- void close() {
+ void close(boolean interrupted) {
serial.close();
serial.remove_monitor(telem);
}
return null;
}
- public void close () {
- report();
+ public void close (boolean interrupted) {
+ if (!interrupted)
+ report();
}
public ReplayThread(AltosReader in_reader, String in_name) {