- private void makeLogdir() {
- setLogdir();
- if (!logdir.exists()) {
- if (!logdir.mkdirs())
- JOptionPane.showMessageDialog(AltosUI.this,
- logdir.getName(),
- "Cannot create directory",
- JOptionPane.ERROR_MESSAGE);
- } else if (!logdir.isDirectory()) {
- JOptionPane.showMessageDialog(AltosUI.this,
- logdir.getName(),
- "Is not a directory",
- JOptionPane.ERROR_MESSAGE);
+ private void tell(AltosState state, AltosState old_state) {
+ if (old_state == null || old_state.state != state.state) {
+ voice.speak(state.data.state);
+ switch (state.state) {
+ case AltosTelemetry.ao_flight_fast:
+ voice.speak("max speed %d meters per second",
+ (int) (state.max_speed + 0.5));
+ break;
+ case AltosTelemetry.ao_flight_drogue:
+ voice.speak("max height %d meters",
+ (int) (state.max_height + 0.5));
+ break;
+ }
+ }
+ old_state = state;
+ }
+
+ class DisplayThread extends Thread {
+ String read() throws InterruptedException { return null; }
+
+ void close() { }
+
+ void update(AltosState state) throws InterruptedException { }
+
+ public void run() {
+ String line;
+ AltosState state = null;
+ AltosState old_state = null;
+ IdleThread idle_thread = new IdleThread();
+
+ info_reset();
+ info_finish();
+ idle_thread.start();
+ try {
+ while ((line = read()) != null) {
+ try {
+ AltosTelemetry t = new AltosTelemetry(line);
+ old_state = state;
+ state = new AltosState(t, state);
+ update(state);
+ show(state);
+ tell(state, old_state);
+ idle_thread.notice(state);
+ } catch (ParseException pp) {
+ System.out.printf("Parse error on %s\n", line);
+ System.out.println("exception " + pp);
+ }
+ }
+ } catch (InterruptedException ee) {
+ } finally {
+ close();
+ idle_thread.interrupt();
+ }