diff options
author | Keith Packard <keithp@keithp.com> | 2015-02-07 14:43:11 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2015-02-07 14:43:11 -0800 |
commit | e70f3dca01b15b75b0b8795eb71bd12817af4800 (patch) | |
tree | 7958f178d7456fc4d66f196ac1f31f7c0f4d106e /telegps/TeleGPSStatus.java | |
parent | 08f07d0af123e1c307bc4c0c973da07fae8246b1 (diff) |
altoslib: Mark listener as 'not running' on EOF.
This adds a 'running' member to the AltosListenerState class, and when
the replay reader reaches EOF, marks the listener as no longer
running.
AltosUI and TeleGPS now display 'done' in the 'Age' field when this
occurs, to let the user know that the replay is over.
Also make sure that the display timers are stopped when this happens,
or when the window is closed.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'telegps/TeleGPSStatus.java')
-rw-r--r-- | telegps/TeleGPSStatus.java | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/telegps/TeleGPSStatus.java b/telegps/TeleGPSStatus.java index 1d4415d6..1eeb7ed5 100644 --- a/telegps/TeleGPSStatus.java +++ b/telegps/TeleGPSStatus.java @@ -179,11 +179,15 @@ public class TeleGPSStatus extends JComponent implements AltosFlightDisplay { long last_secs = -1; void show(AltosState state, AltosListenerState listener_state) { - long secs = (System.currentTimeMillis() - state.received_time + 500) / 1000; - - if (secs != last_secs) { - value.setText(String.format("%d", secs)); - last_secs = secs; + if (listener_state.running) { + long secs = (System.currentTimeMillis() - state.received_time + 500) / 1000; + + if (secs != last_secs) { + value.setText(String.format("%d", secs)); + last_secs = secs; + } + } else { + value.setText("done"); } } @@ -232,6 +236,8 @@ public class TeleGPSStatus extends JComponent implements AltosFlightDisplay { flight.show(state, listener_state); rssi.show(state, listener_state); last_packet.show(state, listener_state); + if (!listener_state.running) + stop(); } public int height() { @@ -239,6 +245,22 @@ public class TeleGPSStatus extends JComponent implements AltosFlightDisplay { return d.height; } + TeleGPSStatusUpdate status_update; + javax.swing.Timer timer; + + public void start(TeleGPSStatusUpdate status_update) { + this.status_update = status_update; + timer = new javax.swing.Timer(100, status_update); + timer.start(); + } + + public void stop() { + if (timer != null) { + timer.stop(); + timer = null; + } + } + public TeleGPSStatus() { layout = new GridBagLayout(); |