- altosui_preferences.flush();
- } catch (BackingStoreException ee) {
- JOptionPane.showMessageDialog(AltosUI.this,
- altosui_preferences.absolutePath(),
- "Cannot save prefernces",
- JOptionPane.ERROR_MESSAGE);
+ for (;;) {
+ Thread.sleep(10000);
+ if (state == null)
+ continue;
+
+ /* reset the landing count once we hear about a new flight */
+ if (state.state < AltosTelemetry.ao_flight_drogue)
+ reported_landing = 0;
+
+ /* Shut up once the rocket is on the ground */
+ if (reported_landing > 2)
+ continue;
+
+ /* If the rocket isn't on the pad, then report height */
+ if (state.state > AltosTelemetry.ao_flight_pad) {
+ voice.speak(String.format("%d meters", (int) (state.height + 0.5)));
+ }
+
+ /* If the rocket is coming down, check to see if it has landed;
+ * either we've got a landed report or we haven't heard from it in
+ * a long time
+ */
+ if (!state.ascent &&
+ (System.currentTimeMillis() - state.report_time > 10000 ||
+ state.state == AltosTelemetry.ao_flight_landed))
+ {
+ if (Math.abs(state.baro_speed) < 20 && state.height < 100)
+ voice.speak("rocket landed safely");
+ else
+ voice.speak("rocket may have crashed");
+ if (state.gps != null)
+ voice.speak(String.format("bearing %d degrees, range %d meters",
+ (int) (state.from_pad.bearing + 0.5),
+ (int) (state.from_pad.distance + 0.5)));
+ ++reported_landing;
+ }
+ }
+ } catch (InterruptedException ie) {