- static final int MIN_PAD_SAMPLES = 10;
-
- public void show(AltosState state) {
- flightStatusModel.set(state);
-
- info_reset();
- if (state.npad >= MIN_PAD_SAMPLES)
- info_add_row(0, "Ground state", "%s", "ready");
- else
- info_add_row(0, "Ground state", "wait (%d)",
- MIN_PAD_SAMPLES - state.npad);
- 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, "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);
- info_add_row(0, "Max acceleration", "%8.1f m/s²", state.max_acceleration);
- info_add_row(0, "Speed", "%8.1f m/s", state.ascent ? state.speed : state.baro_speed);
- info_add_row(0, "Max Speed", "%8.1f m/s", state.max_speed);
- info_add_row(0, "Temperature", "%9.2f °C", state.temperature);
- info_add_row(0, "Battery", "%9.2f V", state.battery);
- info_add_row(0, "Drogue", "%9.2f V", state.drogue_sense);
- info_add_row(0, "Main", "%9.2f V", state.main_sense);
- info_add_row(0, "Pad altitude", "%6.0f m", state.ground_altitude);
- if (state.gps == null) {
- info_add_row(1, "GPS", "not available");
- } else {
- if (state.data.gps.gps_locked)
- info_add_row(1, "GPS", " locked");
- else if (state.data.gps.gps_connected)
- info_add_row(1, "GPS", " unlocked");
+ public void run () {
+
+ reported_landing = 0;
+ state = null;
+ report_interval = 10000;
+ try {
+ for (;;) {
+ set_report_time();
+ for (;;) {
+ voice.drain();
+ synchronized (this) {
+ long sleep_time = report_time - now();
+ if (sleep_time <= 0)
+ break;
+ wait(sleep_time);
+ }
+ }
+ report(false);
+ }
+ } catch (InterruptedException ie) {
+ try {
+ voice.drain();
+ } catch (InterruptedException iie) { }
+ }
+ }
+
+ public synchronized void notice(AltosState new_state, boolean spoken) {
+ AltosState old_state = state;
+ state = new_state;
+ if (!started && state.state > Altos.ao_flight_pad) {
+ started = true;
+ start();
+ }
+
+ if (state.state < Altos.ao_flight_drogue)
+ report_interval = 10000;