flightInfoModel[i].finish();
}
- public void show(AltosState state) {
+ public void show(AltosState state, int crc_errors) {
flightStatusModel.set(state);
info_reset();
- if (state.gps_ready)
- info_add_row(0, "Ground state", "%s", "ready");
- else
- info_add_row(0, "Ground state", "wait (%d)",
- state.gps_waiting);
info_add_row(0, "Rocket state", "%s", state.data.state());
info_add_row(0, "Callsign", "%s", state.data.callsign);
info_add_row(0, "Rocket serial", "%6d", state.data.serial);
info_add_row(0, "Rocket flight", "%6d", state.data.flight);
info_add_row(0, "RSSI", "%6d dBm", state.data.rssi);
+ info_add_row(0, "CRC Errors", "%6d", crc_errors);
info_add_row(0, "Height", "%6.0f m", state.height);
info_add_row(0, "Max height", "%6.0f m", state.max_height);
info_add_row(0, "Acceleration", "%8.1f m/s²", state.acceleration);
if (state.gps == null) {
info_add_row(1, "GPS", "not available");
} else {
+ if (state.gps_ready)
+ info_add_row(1, "GPS state", "%s", "ready");
+ else
+ info_add_row(1, "GPS state", "wait (%d)",
+ state.gps_waiting);
if (state.data.gps.locked)
info_add_row(1, "GPS", " locked");
else if (state.data.gps.connected)
private AltosState state;
int reported_landing;
- public void report(boolean last) {
+ public synchronized void report(boolean last) {
if (state == null)
return;
}
/* If the rocket isn't on the pad, then report height */
- if (state.state > Altos.ao_flight_pad) {
+ if (Altos.ao_flight_drogue <= state.state &&
+ state.state < Altos.ao_flight_landed &&
+ state.range >= 0)
+ {
+ voice.speak("Height %d, bearing %d, elevation %d, range %d.\n",
+ (int) (state.height + 0.5),
+ (int) (state.from_pad.bearing + 0.5),
+ (int) (state.elevation + 0.5),
+ (int) (state.range + 0.5));
+ } else if (state.state > Altos.ao_flight_pad) {
voice.speak("%d meters", (int) (state.height + 0.5));
} else {
reported_landing = 0;
* either we've got a landed report or we haven't heard from it in
* a long time
*/
- if (!state.ascent &&
+ if (state.state >= Altos.ao_flight_drogue &&
(last ||
System.currentTimeMillis() - state.report_time >= 15000 ||
state.state == Altos.ao_flight_landed))
else
voice.speak("rocket may have crashed");
if (state.from_pad != null)
- voice.speak("bearing %d degrees, range %d meters",
+ voice.speak("Bearing %d degrees, range %d meters.",
(int) (state.from_pad.bearing + 0.5),
(int) (state.from_pad.distance + 0.5));
++reported_landing;
state = null;
try {
for (;;) {
- Thread.sleep(10000);
+ Thread.sleep(20000);
report(false);
}
} catch (InterruptedException ie) {
}
public void notice(AltosState new_state) {
+ AltosState old_state = state;
state = new_state;
+ if (old_state != null && old_state.state != state.state)
+ report(false);
}
}
String name;
- AltosRecord read() throws InterruptedException, ParseException { return null; }
+ int crc_errors;
+
+ void init() { }
+
+ AltosRecord read() throws InterruptedException, ParseException, AltosCRCException { return null; }
void close() { }
old_state = state;
state = new AltosState(record, state);
update(state);
- show(state);
+ show(state, crc_errors);
tell(state, old_state);
idle_thread.notice(state);
} catch (ParseException pp) {
System.out.printf("Parse error: %d \"%s\"\n", pp.getErrorOffset(), pp.getMessage());
+ } catch (AltosCRCException ce) {
+ ++crc_errors;
+ show(state, crc_errors);
}
}
} catch (InterruptedException ee) {
AltosSerial serial;
LinkedBlockingQueue<String> telem;
- AltosRecord read() throws InterruptedException, ParseException {
+ AltosRecord read() throws InterruptedException, ParseException, AltosCRCException {
return new AltosTelemetry(telem.take());
}
if (device != null) {
try {
+ stop_display();
serial_line.open(device);
DeviceThread thread = new DeviceThread(serial_line);
serial_line.set_channel(AltosPreferences.channel());
Thread display_thread;
private void stop_display() {
- if (display_thread != null && display_thread.isAlive())
+ if (display_thread != null && display_thread.isAlive()) {
display_thread.interrupt();
+ try {
+ display_thread.join();
+ } catch (InterruptedException ie) {}
+ }
display_thread = null;
}