X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosui%2FAltosFlightStatus.java;h=b467bbdee4d8b2154dc7f134e4cb58354ecafea5;hp=20539a9f6c2d98c4621cd088526bae2d1d133415;hb=238ddde1ffdb8521d06519306cfb76271ae552b9;hpb=bf88c5f829ea5d32043431945e862a9f6c96740a diff --git a/altosui/AltosFlightStatus.java b/altosui/AltosFlightStatus.java index 20539a9f..b467bbde 100644 --- a/altosui/AltosFlightStatus.java +++ b/altosui/AltosFlightStatus.java @@ -19,7 +19,7 @@ package altosui; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altoslib_3.*; public class AltosFlightStatus extends JComponent implements AltosFlightDisplay { GridBagLayout layout; @@ -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(""); @@ -39,6 +39,11 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay value.setFont(Altos.status_font); } + void setVisible(boolean visible) { + label.setVisible(visible); + value.setVisible(visible); + } + public FlightValue (GridBagLayout layout, int x, String text) { GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(5, 5, 5, 5); @@ -64,8 +69,12 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay } class Call extends FlightValue { - void show(AltosState state, int crc_errors) { - value.setText(state.data.callsign); + void show(AltosState state, AltosListenerState listener_state) { + value.setText(state.callsign); + if (state.callsign == null) + setVisible(false); + else + setVisible(true); } public Call (GridBagLayout layout, int x) { super (layout, x, "Callsign"); @@ -75,8 +84,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.serial == AltosLib.MISSING) + value.setText("none"); + else + value.setText(String.format("%d", state.serial)); } public Serial (GridBagLayout layout, int x) { super (layout, x, "Serial"); @@ -86,8 +98,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.flight == AltosLib.MISSING) + value.setText("none"); + else + value.setText(String.format("%d", state.flight)); } public Flight (GridBagLayout layout, int x) { super (layout, x, "Flight"); @@ -97,8 +112,8 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay Flight flight; class FlightState extends FlightValue { - void show(AltosState state, int crc_errors) { - value.setText(state.data.state()); + void show(AltosState state, AltosListenerState listener_state) { + value.setText(state.state_name()); } public FlightState (GridBagLayout layout, int x) { super (layout, x, "State"); @@ -108,8 +123,12 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay FlightState flight_state; class RSSI extends FlightValue { - void show(AltosState state, int crc_errors) { - value.setText(String.format("%d", state.data.rssi)); + void show(AltosState state, AltosListenerState listener_state) { + value.setText(String.format("%d", state.rssi())); + if (state.rssi == AltosLib.MISSING) + setVisible(false); + else + setVisible(true); } public RSSI (GridBagLayout layout, int x) { super (layout, x, "RSSI"); @@ -119,8 +138,8 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay RSSI rssi; class LastPacket extends FlightValue { - void show(AltosState state, int crc_errors) { - long secs = (System.currentTimeMillis() - state.report_time + 500) / 1000; + void show(AltosState state, AltosListenerState listener_state) { + long secs = (System.currentTimeMillis() - state.received_time + 500) / 1000; value.setText(String.format("%d", secs)); } public LastPacket(GridBagLayout layout, int x) { @@ -148,13 +167,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() {