summaryrefslogtreecommitdiff
path: root/altosui/AltosFlightStatus.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-04-09 00:28:05 -0700
committerKeith Packard <keithp@keithp.com>2013-04-09 00:30:36 -0700
commit398c02b945a58634c8932f07df2c2be8438da7d1 (patch)
tree2741e99555d58e9509271da719d039516e16819f /altosui/AltosFlightStatus.java
parent08eb1e3e1abb1aa4f5ea92b781a2ff8f480006c5 (diff)
altoslib/altosui: Carry receiver status around in AltosListenerState
This moves the crc_errors into the new structure and adds a receiver battery voltage value there as well. Now the receiver status can be monitored separately from the flight status. That also means that code receiving state updates should be prepared to accept missing listener or flight state values. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altosui/AltosFlightStatus.java')
-rw-r--r--altosui/AltosFlightStatus.java38
1 files changed, 22 insertions, 16 deletions
diff --git a/altosui/AltosFlightStatus.java b/altosui/AltosFlightStatus.java
index 20539a9f..d2910414 100644
--- a/altosui/AltosFlightStatus.java
+++ b/altosui/AltosFlightStatus.java
@@ -28,7 +28,7 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
JLabel label;
JTextField value;
- void show(AltosState state, int crc_errors) {}
+ void show(AltosState state, AltosListenerState listener_state) {}
void reset() {
value.setText("");
@@ -64,7 +64,7 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
}
class Call extends FlightValue {
- void show(AltosState state, int crc_errors) {
+ void show(AltosState state, AltosListenerState listener_state) {
value.setText(state.data.callsign);
}
public Call (GridBagLayout layout, int x) {
@@ -75,8 +75,11 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
Call call;
class Serial extends FlightValue {
- void show(AltosState state, int crc_errors) {
- value.setText(String.format("%d", state.data.serial));
+ void show(AltosState state, AltosListenerState listener_state) {
+ if (state.data.serial == AltosRecord.MISSING)
+ value.setText("none");
+ else
+ value.setText(String.format("%d", state.data.serial));
}
public Serial (GridBagLayout layout, int x) {
super (layout, x, "Serial");
@@ -86,8 +89,11 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
Serial serial;
class Flight extends FlightValue {
- void show(AltosState state, int crc_errors) {
- value.setText(String.format("%d", state.data.flight));
+ void show(AltosState state, AltosListenerState listener_state) {
+ if (state.data.flight == AltosRecord.MISSING)
+ value.setText("none");
+ else
+ value.setText(String.format("%d", state.data.flight));
}
public Flight (GridBagLayout layout, int x) {
super (layout, x, "Flight");
@@ -97,7 +103,7 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
Flight flight;
class FlightState extends FlightValue {
- void show(AltosState state, int crc_errors) {
+ void show(AltosState state, AltosListenerState listener_state) {
value.setText(state.data.state());
}
public FlightState (GridBagLayout layout, int x) {
@@ -108,7 +114,7 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
FlightState flight_state;
class RSSI extends FlightValue {
- void show(AltosState state, int crc_errors) {
+ void show(AltosState state, AltosListenerState listener_state) {
value.setText(String.format("%d", state.data.rssi));
}
public RSSI (GridBagLayout layout, int x) {
@@ -119,7 +125,7 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
RSSI rssi;
class LastPacket extends FlightValue {
- void show(AltosState state, int crc_errors) {
+ void show(AltosState state, AltosListenerState listener_state) {
long secs = (System.currentTimeMillis() - state.report_time + 500) / 1000;
value.setText(String.format("%d", secs));
}
@@ -148,13 +154,13 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
last_packet.set_font();
}
- public void show (AltosState state, int crc_errors) {
- call.show(state, crc_errors);
- serial.show(state, crc_errors);
- flight.show(state, crc_errors);
- flight_state.show(state, crc_errors);
- rssi.show(state, crc_errors);
- last_packet.show(state, crc_errors);
+ public void show (AltosState state, AltosListenerState listener_state) {
+ call.show(state, listener_state);
+ serial.show(state, listener_state);
+ flight.show(state, listener_state);
+ flight_state.show(state, listener_state);
+ rssi.show(state, listener_state);
+ last_packet.show(state, listener_state);
}
public int height() {