altoslib/altosui: Carry receiver status around in AltosListenerState
authorKeith Packard <keithp@keithp.com>
Tue, 9 Apr 2013 07:28:05 +0000 (00:28 -0700)
committerKeith Packard <keithp@keithp.com>
Tue, 9 Apr 2013 07:30:36 +0000 (00:30 -0700)
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>
29 files changed:
altoslib/AltosConfigData.java
altoslib/AltosFlightReader.java
altoslib/AltosGPS.java
altoslib/AltosIdleMonitor.java
altoslib/AltosLink.java
altoslib/AltosListenerState.java [new file with mode: 0644]
altoslib/AltosRecord.java
altoslib/AltosSensorMM.java
altoslib/AltosSensorTM.java
altoslib/AltosState.java
altoslib/AltosTelemetryReader.java
altoslib/Makefile.am
altosui/AltosAscent.java
altosui/AltosCompanionInfo.java
altosui/AltosDescent.java
altosui/AltosDisplayThread.java
altosui/AltosFlightDisplay.java
altosui/AltosFlightStatus.java
altosui/AltosFlightStatusUpdate.java
altosui/AltosFlightUI.java
altosui/AltosGraphUI.java
altosui/AltosIdleMonitorUI.java
altosui/AltosInfoTable.java
altosui/AltosLanded.java
altosui/AltosPad.java
altosui/AltosSiteMap.java
altosui/AltosSiteMapTile.java
src/core/ao.h
src/stm/ao_timer.c

index 45b95646dabfd4ab7687a67973544135d49ed0f5..5760560762bebdca7082dd1493a48697a955d338 100644 (file)
@@ -135,6 +135,12 @@ public class AltosConfigData implements Iterable<String> {
                }
        }
 
+       public boolean has_monitor_battery() {
+               if (product.startsWith("TeleBT"))
+                       return true;
+               return false;
+       }
+
        int[] parse_version(String v) {
                String[] parts = v.split("\\.");
                int r[] = new int[parts.length];
index 3039b4dcbaf22b018ee1ecf057a81224ebdf844b..345266588f5b16e75ff5d73b9b93761ececbf9d5 100644 (file)
@@ -45,4 +45,8 @@ public class AltosFlightReader {
        public boolean supports_telemetry(int telemetry) { return false; }
 
        public File backing_file() { return null; }
+
+       public boolean has_monitor_battery() { return false; }
+
+       public double monitor_battery() { return AltosRecord.MISSING; }
 }
index 068d8c9c75f5dd2c9315c456fcc2ba63b3c64d17..f23842f3d947c09b135bbfabef197111a1ab9a71 100644 (file)
@@ -217,33 +217,38 @@ public class AltosGPS {
        }
 
        public AltosGPS(AltosGPS old) {
-               nsat = old.nsat;
-               locked = old.locked;
-               connected = old.connected;
-               lat = old.lat;          /* degrees (+N -S) */
-               lon = old.lon;          /* degrees (+E -W) */
-               alt = old.alt;          /* m */
-               year = old.year;
-               month = old.month;
-               day = old.day;
-               hour = old.hour;
-               minute = old.minute;
-               second = old.second;
-
-               ground_speed = old.ground_speed;        /* m/s */
-               course = old.course;            /* degrees */
-               climb_rate = old.climb_rate;    /* m/s */
-               hdop = old.hdop;                /* unitless? */
-               h_error = old.h_error;  /* m */
-               v_error = old.v_error;  /* m */
-
-               if (old.cc_gps_sat != null) {
-                       cc_gps_sat = new AltosGPSSat[old.cc_gps_sat.length];
-                       for (int i = 0; i < old.cc_gps_sat.length; i++) {
-                               cc_gps_sat[i] = new AltosGPSSat();
-                               cc_gps_sat[i].svid = old.cc_gps_sat[i].svid;
-                               cc_gps_sat[i].c_n0 = old.cc_gps_sat[i].c_n0;
+               if (old != null) {
+                       nsat = old.nsat;
+                       locked = old.locked;
+                       connected = old.connected;
+                       lat = old.lat;          /* degrees (+N -S) */
+                       lon = old.lon;          /* degrees (+E -W) */
+                       alt = old.alt;          /* m */
+                       year = old.year;
+                       month = old.month;
+                       day = old.day;
+                       hour = old.hour;
+                       minute = old.minute;
+                       second = old.second;
+
+                       ground_speed = old.ground_speed;        /* m/s */
+                       course = old.course;            /* degrees */
+                       climb_rate = old.climb_rate;    /* m/s */
+                       hdop = old.hdop;                /* unitless? */
+                       h_error = old.h_error;  /* m */
+                       v_error = old.v_error;  /* m */
+
+                       if (old.cc_gps_sat != null) {
+                               cc_gps_sat = new AltosGPSSat[old.cc_gps_sat.length];
+                               for (int i = 0; i < old.cc_gps_sat.length; i++) {
+                                       cc_gps_sat[i] = new AltosGPSSat();
+                                       cc_gps_sat[i].svid = old.cc_gps_sat[i].svid;
+                                       cc_gps_sat[i].c_n0 = old.cc_gps_sat[i].c_n0;
+                               }
                        }
+               } else {
+                       ClearGPSTime();
+                       cc_gps_sat = null;
                }
        }
 }
index f2f75bbb60f80dc21cf388a70459e7c239c76b37..ec51b9c1906ecb63f63dad3b1555650db5a2dcca 100644 (file)
@@ -116,8 +116,10 @@ public class AltosIdleMonitor extends Thread {
                } finally {
                        if (remote) {
                                link.stop_remote();
-                               if (record != null)
-                                       record.rssi = AltosRSSI();
+                               if (record != null) {
+                                       record.rssi = link.rssi();
+                                       record.monitor_battery = link.monitor_battery();
+                               }
                        } else {
                                if (record != null)
                                        record.rssi = 0;
index 9eb25ce0ac47b53092e706606e88be0104d15f20..159ebfe19c234b34b423a6619e56d18f7ca6f433 100644 (file)
@@ -364,6 +364,63 @@ public abstract class AltosLink implements Runnable {
                remote = false;
        }
 
+       public int rssi() throws TimeoutException, InterruptedException {
+               if (remote)
+                       return 0;
+               printf("s\n");
+               String line = get_reply_no_dialog(5000);
+               if (line == null)
+                       throw new TimeoutException();
+               String[] items = line.split("\\s+");
+               if (items.length < 2)
+                       return 0;
+               if (!items[0].equals("RSSI:"))
+                       return 0;
+               int rssi = Integer.parseInt(items[1]);
+               return rssi;
+       }
+
+       public String[] adc() throws TimeoutException, InterruptedException {
+               printf("a\n");
+               for (;;) {
+                       String line = get_reply_no_dialog(5000);
+                       if (line == null) {
+                               throw new TimeoutException();
+                       }
+                       if (!line.startsWith("tick:"))
+                               continue;
+                       String[] items = line.split("\\s+");
+                       return items;
+               }
+       }
+
+       public boolean has_monitor_battery() {
+               return config_data.has_monitor_battery();
+       }
+
+       public double monitor_battery() {
+               int monitor_batt = AltosRecord.MISSING;
+
+               if (config_data.has_monitor_battery()) {
+                       try {
+                       String[] items = adc();
+                       for (int i = 0; i < items.length;) {
+                               if (items[i].equals("batt")) {
+                                       monitor_batt = Integer.parseInt(items[i+1]);
+                                       i += 2;
+                                       continue;
+                               }
+                               i++;
+                       }
+                       } catch (InterruptedException ie) {
+                       } catch (TimeoutException te) {
+                       }
+               }
+               if (monitor_batt == AltosRecord.MISSING)
+                       return AltosRecord.MISSING;
+               return AltosConvert.cc_battery_to_voltage(monitor_batt);
+       }
+
        public AltosLink() {
                callsign = "";
        }
diff --git a/altoslib/AltosListenerState.java b/altoslib/AltosListenerState.java
new file mode 100644 (file)
index 0000000..2fb4673
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright © 2013 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package org.altusmetrum.altoslib_1;
+
+public class AltosListenerState {
+       public int      crc_errors;
+       public double   battery;
+
+       public AltosListenerState() {
+               crc_errors = 0;
+               battery = AltosRecord.MISSING;
+       }
+}
index f8c44cc5a06a9f2f5092bd7eef316eb334d6b9d3..7046b9f10106c34b397e7f088dae0a6bb58b8022 100644 (file)
@@ -17,7 +17,7 @@
 
 package org.altusmetrum.altoslib_1;
 
-public abstract class AltosRecord implements Comparable <AltosRecord>, Cloneable {
+public class AltosRecord implements Comparable <AltosRecord>, Cloneable {
 
        public static final int seen_flight = 1;
        public static final int seen_sensor = 2;
@@ -75,15 +75,17 @@ public abstract class AltosRecord implements Comparable <AltosRecord>, Cloneable
         *      temperature:    °C
         */
 
-       abstract public double pressure();
-       abstract public double ground_pressure();
-       abstract public double acceleration();
+       public double pressure() { return MISSING; }
+       public double ground_pressure() { return MISSING; }
+       public double acceleration() { return MISSING; }
 
        public double altitude() {
                double  p = pressure();
 
-               if (p == MISSING)
+               if (p == MISSING) {
+                       System.out.printf ("altitude missing\n");
                        return MISSING;
+               }
                return AltosConvert.pressure_to_altitude(p);
        }
 
@@ -126,7 +128,11 @@ public abstract class AltosRecord implements Comparable <AltosRecord>, Cloneable
                return tick - o.tick;
        }
 
-       abstract public AltosRecord clone();
+       public AltosRecord clone() {
+               AltosRecord n = new AltosRecord();
+               n.copy(this);
+               return n;
+       }
 
        public void copy(AltosRecord old) {
                seen = old.seen;
@@ -150,13 +156,13 @@ public abstract class AltosRecord implements Comparable <AltosRecord>, Cloneable
                seen = 0;
                version = 0;
                callsign = "N0CALL";
-               serial = 0;
-               flight = 0;
+               serial = MISSING;
+               flight = MISSING;
                rssi = 0;
                status = 0;
                state = AltosLib.ao_flight_startup;
                tick = 0;
-               gps = new AltosGPS();
+               gps = null;
                new_gps = false;
                companion = null;
 
index 8372d0477ffdc3c827c91e956f9e7adfe9bca55f..6d1b61c079fa3d9305a661f871da2122651ffe1d 100644 (file)
@@ -28,75 +28,65 @@ class AltosSensorMM {
        int             accel_ref;
 
        public AltosSensorMM(AltosLink link) throws InterruptedException, TimeoutException {
-               link.printf("a\n");
-               for (;;) {
-                       String line = link.get_reply_no_dialog(5000);
-                       if (line == null) {
-                               throw new TimeoutException();
+               String[] items = link.adc();
+               sense = new int[6];
+               for (int i = 0; i < items.length;) {
+                       if (items[i].equals("tick:")) {
+                               tick = Integer.parseInt(items[i+1]);
+                               i += 2;
+                               continue;
+                       }
+                       if (items[i].equals("0:")) {
+                               sense[0] = Integer.parseInt(items[i+1]);
+                               i += 2;
+                               continue;
+                       }
+                       if (items[i].equals("1:")) {
+                               sense[1] = Integer.parseInt(items[i+1]);
+                               i += 2;
+                               continue;
+                       }
+                       if (items[i].equals("2:")) {
+                               sense[2] = Integer.parseInt(items[i+1]);
+                               i += 2;
+                               continue;
+                       }
+                       if (items[i].equals("3:")) {
+                               sense[3] = Integer.parseInt(items[i+1]);
+                               i += 2;
+                               continue;
+                       }
+                       if (items[i].equals("4:")) {
+                               sense[4] = Integer.parseInt(items[i+1]);
+                               i += 2;
+                               continue;
+                       }
+                       if (items[i].equals("5:")) {
+                               sense[5] = Integer.parseInt(items[i+1]);
+                               i += 2;
+                               continue;
+                       }
+                       if (items[i].equals("6:")) {
+                               v_batt = Integer.parseInt(items[i+1]);
+                               i += 2;
+                               continue;
+                       }
+                       if (items[i].equals("7:")) {
+                               v_pyro = Integer.parseInt(items[i+1]);
+                               i += 2;
+                               continue;
+                       }
+                       if (items[i].equals("8:")) {
+                               accel = Integer.parseInt(items[i+1]);
+                               i += 2;
+                               continue;
                        }
-                       if (!line.startsWith("tick:"))
+                       if (items[i].equals("9:")) {
+                               accel_ref = Integer.parseInt(items[i+1]);
+                               i += 2;
                                continue;
-                       String[] items = line.split("\\s+");
-                       sense = new int[6];
-                       for (int i = 0; i < items.length;) {
-                               if (items[i].equals("tick:")) {
-                                       tick = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("0:")) {
-                                       sense[0] = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("1:")) {
-                                       sense[1] = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("2:")) {
-                                       sense[2] = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("3:")) {
-                                       sense[3] = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("4:")) {
-                                       sense[4] = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("5:")) {
-                                       sense[5] = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("6:")) {
-                                       v_batt = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("7:")) {
-                                       v_pyro = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("8:")) {
-                                       accel = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("9:")) {
-                                       accel_ref = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               i++;
                        }
-                       break;
+                       i++;
                }
        }
 }
index f5fa83a595a94a6cc7196d3159f1d9ab0234ebfa..754dc5bbbc85cec8d762a5ec8fc5be1da31b9fde 100644 (file)
@@ -23,54 +23,44 @@ class AltosSensorTM extends AltosRecordTM {
 
        public AltosSensorTM(AltosLink link, AltosConfigData config_data) throws InterruptedException, TimeoutException {
                super();
-               link.printf("a\n");
-               for (;;) {
-                       String line = link.get_reply_no_dialog(5000);
-                       if (line == null) {
-                               throw new TimeoutException();
+               String[] items = link.adc();
+               for (int i = 0; i < items.length;) {
+                       if (items[i].equals("tick:")) {
+                               tick = Integer.parseInt(items[i+1]);
+                               i += 2;
+                               continue;
+                       }
+                       if (items[i].equals("accel:")) {
+                               accel = Integer.parseInt(items[i+1]);
+                               i += 2;
+                               continue;
+                       }
+                       if (items[i].equals("pres:")) {
+                               pres = Integer.parseInt(items[i+1]);
+                               i += 2;
+                               continue;
+                       }
+                       if (items[i].equals("temp:")) {
+                               temp = Integer.parseInt(items[i+1]);
+                               i += 2;
+                               continue;
+                       }
+                       if (items[i].equals("batt:")) {
+                               batt = Integer.parseInt(items[i+1]);
+                               i += 2;
+                               continue;
+                       }
+                       if (items[i].equals("drogue:")) {
+                               drogue = Integer.parseInt(items[i+1]);
+                               i += 2;
+                               continue;
                        }
-                       if (!line.startsWith("tick:"))
+                       if (items[i].equals("main:")) {
+                               main = Integer.parseInt(items[i+1]);
+                               i += 2;
                                continue;
-                       String[] items = line.split("\\s+");
-                       for (int i = 0; i < items.length;) {
-                               if (items[i].equals("tick:")) {
-                                       tick = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("accel:")) {
-                                       accel = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("pres:")) {
-                                       pres = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("temp:")) {
-                                       temp = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("batt:")) {
-                                       batt = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("drogue:")) {
-                                       drogue = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("main:")) {
-                                       main = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               i++;
                        }
-                       break;
+                       i++;
                }
                ground_accel = config_data.accel_cal_plus;
                ground_pres = pres;
index 8a3bbd4cee31d039d00caedd15c0a0499eb80780..f1bcb1c1a67a7e87ee5a3ef4cc70e1ce29c44351 100644 (file)
@@ -155,30 +155,41 @@ public class AltosState {
                                /* compute barometric speed */
 
                                double height_change = height - prev_state.height;
+
+                               double prev_baro_speed = prev_state.baro_speed;
+                               if (prev_baro_speed == AltosRecord.MISSING)
+                                       prev_baro_speed = 0;
+
                                if (time_change > 0)
-                                       baro_speed = (prev_state.baro_speed * 3 + (height_change / time_change)) / 4.0;
+                                       baro_speed = (prev_baro_speed * 3 + (height_change / time_change)) / 4.0;
                                else
                                        baro_speed = prev_state.baro_speed;
 
+                               double prev_accel_speed = prev_state.accel_speed;
+
+                               if (prev_accel_speed == AltosRecord.MISSING)
+                                       prev_accel_speed = 0;
+
                                if (acceleration == AltosRecord.MISSING) {
                                        /* Fill in mising acceleration value */
                                        accel_speed = baro_speed;
-                                       if (time_change > 0)
-                                               acceleration = (accel_speed - prev_state.accel_speed) / time_change;
+
+                                       if (time_change > 0 && accel_speed != AltosRecord.MISSING)
+                                               acceleration = (accel_speed - prev_accel_speed) / time_change;
                                        else
                                                acceleration = prev_state.acceleration;
                                } else {
                                        /* compute accelerometer speed */
-                                       accel_speed = prev_state.accel_speed + acceleration * time_change;
+                                       accel_speed = prev_accel_speed + acceleration * time_change;
                                }
                        }
-
                } else {
                        npad = 0;
                        ngps = 0;
                        gps = null;
                        baro_speed = AltosRecord.MISSING;
                        accel_speed = AltosRecord.MISSING;
+                       pad_alt = AltosRecord.MISSING;
                        max_baro_speed = 0;
                        max_accel_speed = 0;
                        max_height = 0;
index f365b82118eb320e6fd8421d804517db95818af6..b4293c7349d2d9fda70bd03942aa91c37e0ac031 100644 (file)
@@ -107,6 +107,14 @@ public class AltosTelemetryReader extends AltosFlightReader {
                return log.file();
        }
 
+       public boolean has_monitor_battery() {
+               return link.has_monitor_battery();
+       }
+
+       public double monitor_battery() {
+               return link.monitor_battery();
+       }
+
        public AltosTelemetryReader (AltosLink in_link)
                throws IOException, InterruptedException, TimeoutException {
                link = in_link;
index 8e5701ad59fe169a76198a92d2d995a182d91601..30a9d95473f860a97cd922b30e9cfa3a95cdf526 100644 (file)
@@ -37,6 +37,7 @@ altoslib_JAVA = \
        AltosIMUQuery.java \
        AltosLine.java \
        AltosLink.java \
+       AltosListenerState.java \
        AltosLog.java \
        AltosMs5607.java \
        AltosMs5607Query.java \
index 80a5b759212475b4dbe87ceb75ab770b63308d08..4da4d591d70edaf06a2921a734cb9af616d8b40f 100644 (file)
@@ -42,7 +42,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
                        label.setVisible(false);
                }
 
-               void show(AltosState state, int crc_errors) {}
+               void show(AltosState state, AltosListenerState listener_state) {}
 
                void show(String s) {
                        show();
@@ -107,7 +107,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
        public class AscentValue {
                JLabel          label;
                JTextField      value;
-               void show(AltosState state, int crc_errors) {}
+               void show(AltosState state, AltosListenerState listener_state) {}
 
                void reset() {
                        value.setText("");
@@ -174,7 +174,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
                JTextField      max_value;
                double          max;
 
-               void show(AltosState state, int crc_errors) {}
+               void show(AltosState state, AltosListenerState listener_state) {}
 
                void reset() {
                        value.setText("");
@@ -239,7 +239,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
 
 
        class Height extends AscentValueHold {
-               void show (AltosState state, int crc_errors) {
+               void show (AltosState state, AltosListenerState listener_state) {
                        show(AltosConvert.height, state.height);
                }
                public Height (GridBagLayout layout, int y) {
@@ -250,7 +250,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
        Height  height;
 
        class Speed extends AscentValueHold {
-               void show (AltosState state, int crc_errors) {
+               void show (AltosState state, AltosListenerState listener_state) {
                        double speed = state.accel_speed;
                        if (!state.ascent)
                                speed = state.baro_speed;
@@ -264,7 +264,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
        Speed   speed;
 
        class Accel extends AscentValueHold {
-               void show (AltosState state, int crc_errors) {
+               void show (AltosState state, AltosListenerState listener_state) {
                        show(AltosConvert.accel, state.acceleration);
                }
                public Accel (GridBagLayout layout, int y) {
@@ -286,7 +286,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
        }
 
        class Apogee extends AscentStatus {
-               void show (AltosState state, int crc_errors) {
+               void show (AltosState state, AltosListenerState listener_state) {
                        show("%4.2f V", state.drogue_sense);
                        lights.set(state.drogue_sense > 3.2);
                }
@@ -298,7 +298,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
        Apogee apogee;
 
        class Main extends AscentStatus {
-               void show (AltosState state, int crc_errors) {
+               void show (AltosState state, AltosListenerState listener_state) {
                        show("%4.2f V", state.main_sense);
                        lights.set(state.main_sense > 3.2);
                }
@@ -310,7 +310,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
        Main main;
 
        class Lat extends AscentValue {
-               void show (AltosState state, int crc_errors) {
+               void show (AltosState state, AltosListenerState listener_state) {
                        if (state.gps != null)
                                show(pos(state.gps.lat,"N", "S"));
                        else
@@ -324,7 +324,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
        Lat lat;
 
        class Lon extends AscentValue {
-               void show (AltosState state, int crc_errors) {
+               void show (AltosState state, AltosListenerState listener_state) {
                        if (state.gps != null)
                                show(pos(state.gps.lon,"E", "W"));
                        else
@@ -359,25 +359,25 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
                accel.set_font();
        }
 
-       public void show(AltosState state, int crc_errors) {
+       public void show(AltosState state, AltosListenerState listener_state) {
                if (state.gps != null && state.gps.connected) {
-                       lat.show(state, crc_errors);
-                       lon.show(state, crc_errors);
+                       lat.show(state, listener_state);
+                       lon.show(state, listener_state);
                } else {
                        lat.hide();
                        lon.hide();
                }
-               height.show(state, crc_errors);
+               height.show(state, listener_state);
                if (state.main_sense != AltosRecord.MISSING)
-                       main.show(state, crc_errors);
+                       main.show(state, listener_state);
                else
                        main.hide();
                if (state.drogue_sense != AltosRecord.MISSING)
-                       apogee.show(state, crc_errors);
+                       apogee.show(state, listener_state);
                else
                        apogee.hide();
-               speed.show(state, crc_errors);
-               accel.show(state, crc_errors);
+               speed.show(state, listener_state);
+               accel.show(state, listener_state);
        }
 
        public void labels(GridBagLayout layout, int y) {
index 7dd36aec08ecbf2835e9a6dfd9ea874d38f02c2d..ebe1d1f9826612cf004d23d224010da50d515aef 100644 (file)
@@ -83,7 +83,7 @@ public class AltosCompanionInfo extends JTable {
                }
        }
        
-       public void show(AltosState state, int crc_errors) {
+       public void show(AltosState state, AltosListenerState listener_state) {
                if (state == null)
                        return;
                if (state.data.companion != null)
index 9838f46b722f07d3c416e7ce7c82d75b72f8f6ee..29d33ddc9afac6085b9426bb8b37928274892987 100644 (file)
@@ -29,7 +29,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
                JTextField      value;
                AltosLights     lights;
 
-               abstract void show(AltosState state, int crc_errors);
+               abstract void show(AltosState state, AltosListenerState listener_state);
 
                void show() {
                        label.setVisible(true);
@@ -108,7 +108,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
                        value.setText("");
                }
 
-               abstract void show(AltosState state, int crc_errors);
+               abstract void show(AltosState state, AltosListenerState listener_state);
 
                void show() {
                        label.setVisible(true);
@@ -192,7 +192,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
                        value2.setFont(Altos.value_font);
                }
 
-               abstract void show(AltosState state, int crc_errors);
+               abstract void show(AltosState state, AltosListenerState listener_state);
 
                void show(String v1, String v2) {
                        show();
@@ -244,7 +244,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
        }
 
        class Height extends DescentValue {
-               void show (AltosState state, int crc_errors) {
+               void show (AltosState state, AltosListenerState listener_state) {
                        show(AltosConvert.height, state.height);
                }
                public Height (GridBagLayout layout, int x, int y) {
@@ -255,7 +255,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
        Height  height;
 
        class Speed extends DescentValue {
-               void show (AltosState state, int crc_errors) {
+               void show (AltosState state, AltosListenerState listener_state) {
                        double speed = state.accel_speed;
                        if (!state.ascent)
                                speed = state.baro_speed;
@@ -280,7 +280,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
        }
 
        class Lat extends DescentValue {
-               void show (AltosState state, int crc_errors) {
+               void show (AltosState state, AltosListenerState listener_state) {
                        if (state.gps != null && state.gps.connected)
                                show(pos(state.gps.lat,"N", "S"));
                        else
@@ -294,7 +294,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
        Lat lat;
 
        class Lon extends DescentValue {
-               void show (AltosState state, int crc_errors) {
+               void show (AltosState state, AltosListenerState listener_state) {
                        if (state.gps != null && state.gps.connected)
                                show(pos(state.gps.lon,"W", "E"));
                        else
@@ -308,7 +308,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
        Lon lon;
 
        class Distance extends DescentValue {
-               void show(AltosState state, int crc_errors) {
+               void show(AltosState state, AltosListenerState listener_state) {
                        if (state.from_pad != null)
                                show(AltosConvert.distance, state.from_pad.distance);
                        else
@@ -324,7 +324,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
                
 
        class Apogee extends DescentStatus {
-               void show (AltosState state, int crc_errors) {
+               void show (AltosState state, AltosListenerState listener_state) {
                        show("%4.2f V", state.drogue_sense);
                        lights.set(state.drogue_sense > 3.2);
                }
@@ -336,7 +336,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
        Apogee apogee;
 
        class Main extends DescentStatus {
-               void show (AltosState state, int crc_errors) {
+               void show (AltosState state, AltosListenerState listener_state) {
                        show("%4.2f V", state.main_sense);
                        lights.set(state.main_sense > 3.2);
                }
@@ -348,7 +348,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
        Main main;
 
        class Bearing extends DescentDualValue {
-               void show (AltosState state, int crc_errors) {
+               void show (AltosState state, AltosListenerState listener_state) {
                        if (state.from_pad != null) {
                                show( String.format("%3.0f°", state.from_pad.bearing),
                                      state.from_pad.bearing_words(
@@ -365,7 +365,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
        Bearing bearing;
 
        class Range extends DescentValue {
-               void show (AltosState state, int crc_errors) {
+               void show (AltosState state, AltosListenerState listener_state) {
                        show(AltosConvert.distance, state.range);
                }
                public Range (GridBagLayout layout, int x, int y) {
@@ -376,7 +376,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
        Range range;
 
        class Elevation extends DescentValue {
-               void show (AltosState state, int crc_errors) {
+               void show (AltosState state, AltosListenerState listener_state) {
                        show("%3.0f°", state.elevation);
                }
                public Elevation (GridBagLayout layout, int x, int y) {
@@ -412,16 +412,16 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
                apogee.set_font();
        }
 
-       public void show(AltosState state, int crc_errors) {
-               height.show(state, crc_errors);
-               speed.show(state, crc_errors);
+       public void show(AltosState state, AltosListenerState listener_state) {
+               height.show(state, listener_state);
+               speed.show(state, listener_state);
                if (state.gps != null && state.gps.connected) {
-                       bearing.show(state, crc_errors);
-                       range.show(state, crc_errors);
-                       distance.show(state, crc_errors);
-                       elevation.show(state, crc_errors);
-                       lat.show(state, crc_errors);
-                       lon.show(state, crc_errors);
+                       bearing.show(state, listener_state);
+                       range.show(state, listener_state);
+                       distance.show(state, listener_state);
+                       elevation.show(state, listener_state);
+                       lat.show(state, listener_state);
+                       lon.show(state, listener_state);
                } else {
                        bearing.hide();
                        range.hide();
@@ -431,11 +431,11 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
                        lon.hide();
                }
                if (state.main_sense != AltosRecord.MISSING)
-                       main.show(state, crc_errors);
+                       main.show(state, listener_state);
                else
                        main.hide();
                if (state.drogue_sense != AltosRecord.MISSING)
-                       apogee.show(state, crc_errors);
+                       apogee.show(state, listener_state);
                else
                        apogee.hide();
        }
index 6f8aa9ee3293556caba705c9bbb3aa55e7ca6f94..095bed992c08c524d5718e21066ece2b20ad5df6 100644 (file)
@@ -29,21 +29,17 @@ public class AltosDisplayThread extends Thread {
        IdleThread              idle_thread;
        AltosVoice              voice;
        AltosFlightReader       reader;
-       int                     crc_errors;
+       AltosState              old_state, state;
+       AltosListenerState      listener_state;
        AltosFlightDisplay      display;
 
-       void show_internal(AltosState state, int crc_errors) {
-               if (state != null)
-                       display.show(state, crc_errors);
-       }
-
-       void show_safely(AltosState in_state, int in_crc_errors) {
-               final AltosState state = in_state;
-               final int crc_errors = in_crc_errors;
+       synchronized void show_safely() {
+               final AltosState my_state = state;
+               final AltosListenerState my_listener_state = listener_state;
                Runnable r = new Runnable() {
                                public void run() {
                                        try {
-                                               show_internal(state, crc_errors);
+                                               display.show(my_state, my_listener_state);
                                        } catch (Exception ex) {
                                        }
                                }
@@ -73,7 +69,6 @@ public class AltosDisplayThread extends Thread {
        class IdleThread extends Thread {
 
                boolean started;
-               private AltosState state;
                int     reported_landing;
                int     report_interval;
                long    report_time;
@@ -129,7 +124,7 @@ public class AltosDisplayThread extends Thread {
                                ++reported_landing;
                                if (state.state != Altos.ao_flight_landed) {
                                        state.state = Altos.ao_flight_landed;
-                                       show_safely(state, 0);
+                                       show_safely();
                                }
                        }
                }
@@ -145,6 +140,10 @@ public class AltosDisplayThread extends Thread {
                public void run () {
                        try {
                                for (;;) {
+                                       if (reader.has_monitor_battery()) {
+                                               listener_state.battery = reader.monitor_battery();
+                                               show_safely();
+                                       }
                                        set_report_time();
                                        for (;;) {
                                                voice.drain();
@@ -155,6 +154,7 @@ public class AltosDisplayThread extends Thread {
                                                        wait(sleep_time);
                                                }
                                        }
+                                       
                                        report(false);
                                }
                        } catch (InterruptedException ie) {
@@ -164,18 +164,7 @@ public class AltosDisplayThread extends Thread {
                        }
                }
 
-               public synchronized void notice(AltosState new_state, boolean spoken) {
-                       AltosState old_state = state;
-                       state = new_state;
-                       if (!started && state.state > Altos.ao_flight_pad) {
-                               started = true;
-                               start();
-                       }
-
-                       if (state.state < Altos.ao_flight_drogue)
-                               report_interval = 10000;
-                       else
-                               report_interval = 20000;
+               public synchronized void notice(boolean spoken) {
                        if (old_state != null && old_state.state != state.state) {
                                report_time = now();
                                this.notify();
@@ -184,13 +173,12 @@ public class AltosDisplayThread extends Thread {
                }
 
                public IdleThread() {
-                       state = null;
                        reported_landing = 0;
                        report_interval = 10000;
                }
        }
 
-       boolean tell(AltosState state, AltosState old_state) {
+       synchronized boolean tell() {
                boolean ret = false;
                if (old_state == null || old_state.state != state.state) {
                        voice.speak(state.data.state());
@@ -222,12 +210,10 @@ public class AltosDisplayThread extends Thread {
 
        public void run() {
                boolean         interrupted = false;
-               //String                line;
-               AltosState      state = null;
-               AltosState      old_state = null;
                boolean         told;
 
                idle_thread = new IdleThread();
+               idle_thread.start();
 
                try {
                        for (;;) {
@@ -238,14 +224,14 @@ public class AltosDisplayThread extends Thread {
                                        old_state = state;
                                        state = new AltosState(record, state);
                                        reader.update(state);
-                                       show_safely(state, crc_errors);
-                                       told = tell(state, old_state);
-                                       idle_thread.notice(state, told);
+                                       show_safely();
+                                       told = tell();
+                                       idle_thread.notice(told);
                                } catch (ParseException pp) {
                                        System.out.printf("Parse error: %d \"%s\"\n", pp.getErrorOffset(), pp.getMessage());
                                } catch (AltosCRCException ce) {
-                                       ++crc_errors;
-                                       show_safely(state, crc_errors);
+                                       ++listener_state.crc_errors;
+                                       show_safely();
                                }
                        }
                } catch (InterruptedException ee) {
@@ -264,6 +250,7 @@ public class AltosDisplayThread extends Thread {
        }
 
        public AltosDisplayThread(Frame in_parent, AltosVoice in_voice, AltosFlightDisplay in_display, AltosFlightReader in_reader) {
+               listener_state = new AltosListenerState();
                parent = in_parent;
                voice = in_voice;
                display = in_display;
index d1ed7d2faf4139da8e27cd2674484eeefd6a7f47..4f4c158e8e08aad3105165ca36b5865cde53163a 100644 (file)
@@ -22,7 +22,7 @@ import org.altusmetrum.altoslib_1.*;
 public interface AltosFlightDisplay {
        void reset();
 
-       void show(AltosState state, int crc_errors);
+       void show(AltosState state, AltosListenerState listener_state);
 
        void set_font();
 }
index 20539a9f6c2d98c4621cd088526bae2d1d133415..d2910414dec132af46e4fecb4e168052068073af 100644 (file)
@@ -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() {
index bf679b857cc4abfccd28d21f256acdbc84d52248..962a08f7821d3b88df57130eebd4679983ef9d6e 100644 (file)
@@ -22,12 +22,16 @@ import org.altusmetrum.altoslib_1.*;
 
 public class AltosFlightStatusUpdate implements ActionListener {
 
-       public AltosState       saved_state;
-       AltosFlightStatus       flightStatus;
+       public AltosState               saved_state;
+       public AltosListenerState       saved_listener_state;
+       AltosFlightStatus               flightStatus;
 
        public void actionPerformed (ActionEvent e) {
-               if (saved_state != null)
-                       flightStatus.show(saved_state, 0);
+               if (saved_state != null) {
+                       if (saved_listener_state == null)
+                               saved_listener_state = new AltosListenerState();
+                       flightStatus.show(saved_state, saved_listener_state);
+               }
        }
 
        public AltosFlightStatusUpdate (AltosFlightStatus in_flightStatus) {
index c04a4357f6f898bb5a54882abf7a9366cbeee76c..6b258f2e7eb31f0a1ec0b748b69e565e2004fe3c 100644 (file)
@@ -98,11 +98,15 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay, A
 
        AltosFlightStatusUpdate status_update;
 
-       public void show(AltosState state, int crc_errors) {
+       public void show(AltosState state, AltosListenerState listener_state) {
                status_update.saved_state = state;
-               JComponent tab = which_tab(state);
-               try {
-               pad.show(state, crc_errors);
+
+               if (state == null) {
+                       System.out.printf ("no state provided\n");
+                       state = new AltosState(new AltosRecord());
+               }
+
+               pad.show(state, listener_state);
 
                if (state.state != Altos.ao_flight_startup) {
                        if (!has_state) {
@@ -114,25 +118,26 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay, A
                        }
                }
 
-               ascent.show(state, crc_errors);
-               descent.show(state, crc_errors);
-               landed.show(state, crc_errors);
+               ascent.show(state, listener_state);
+               descent.show(state, listener_state);
+               landed.show(state, listener_state);
 
+               JComponent tab = which_tab(state);
                if (tab != cur_tab) {
                        if (cur_tab == pane.getSelectedComponent()) {
                                pane.setSelectedComponent(tab);
                        }
                        cur_tab = tab;
                }
-               flightStatus.show(state, crc_errors);
-               flightInfo.show(state, crc_errors);
+               flightStatus.show(state, listener_state);
+               flightInfo.show(state, listener_state);
 
                if (state.data.companion != null) {
                        if (!has_companion) {
                                pane.add("Companion", companion);
                                has_companion= true;
                        }
-                       companion.show(state, crc_errors);
+                       companion.show(state, listener_state);
                } else {
                        if (has_companion) {
                                pane.remove(companion);
@@ -144,17 +149,13 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay, A
                                pane.add("Site Map", sitemap);
                                has_map = true;
                        }
-                       sitemap.show(state, crc_errors);
+                       sitemap.show(state, listener_state);
                } else {
                        if (has_map) {
                                pane.remove(sitemap);
                                has_map = false;
                        }
                }
-               } catch (Exception e) {
-                       System.out.print("Show exception " + e + "\n");
-                       e.printStackTrace();
-               }
        }
 
        public void set_exit_on_close() {
index f6e57e7ec7c119308ed310d5b31772f413b4be4f..d8b8f6dd282d41b1bbce8b4724f7dac3212714a5 100644 (file)
@@ -35,7 +35,7 @@ public class AltosGraphUI extends AltosUIFrame
                        if (state.gps != null && state.gps.locked && state.gps.nsat >= 4) {
                                if (map == null)
                                        map = new AltosSiteMap();
-                               map.show(state, 0);
+                               map.show(state, null);
                                has_gps = true;
                        }
                }
index 8c883eebfc0cd8a5fdda2cf44d9e8095824c96e3..1ef30f0a29a17dcd7db0a7e70932b9d305ca989b 100644 (file)
@@ -63,12 +63,12 @@ public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDispl
 
        AltosFlightStatusUpdate status_update;
 
-       public void show(AltosState state, int crc_errors) {
+       public void show(AltosState state, AltosListenerState listener_state) {
                status_update.saved_state = state;
                try {
-                       pad.show(state, crc_errors);
-                       flightStatus.show(state, crc_errors);
-                       flightInfo.show(state, crc_errors);
+                       pad.show(state, listener_state);
+                       flightStatus.show(state, listener_state);
+                       flightInfo.show(state, listener_state);
                } catch (Exception e) {
                        System.out.print("Show exception" + e);
                }
@@ -77,7 +77,7 @@ public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDispl
        public void update(final AltosState state) {
                Runnable r = new Runnable() {
                                public void run() {
-                                       show(state, 0);
+                                       show(state, null);
                                }
                        };
                SwingUtilities.invokeLater(r);
index 1dce6dafbc216493726469b081a4676360359e35..3d16faf2cbf369f368563f8ce64dbd006015ccb5 100644 (file)
@@ -104,111 +104,118 @@ public class AltosInfoTable extends JTable {
                model.clear();
        }
 
-       public void show(AltosState state, int crc_errors) {
-               if (state == null)
-                       return;
+       public void show(AltosState state, AltosListenerState listener_state) {
                info_reset();
-               if (state.altitude != AltosRecord.MISSING)
-                       info_add_row(0, "Altitude", "%6.0f    m", state.altitude);
-               if (state.ground_altitude != AltosRecord.MISSING)
-                       info_add_row(0, "Pad altitude", "%6.0f    m", state.ground_altitude);
-               if (state.height != AltosRecord.MISSING)
-                       info_add_row(0, "Height", "%6.0f    m", state.height);
-               if (state.max_height != AltosRecord.MISSING)
-                       info_add_row(0, "Max height", "%6.0f    m", state.max_height);
-               if (state.acceleration != AltosRecord.MISSING)
-                       info_add_row(0, "Acceleration", "%8.1f  m/s²", state.acceleration);
-               if (state.max_acceleration != AltosRecord.MISSING)
-                       info_add_row(0, "Max acceleration", "%8.1f  m/s²", state.max_acceleration);
-               if (state.speed() != AltosRecord.MISSING)
-                       info_add_row(0, "Speed", "%8.1f  m/s", state.speed());
-               if (state.max_speed() != AltosRecord.MISSING)
-                       info_add_row(0, "Max Speed", "%8.1f  m/s", state.max_accel_speed);
-               if (state.temperature != AltosRecord.MISSING)
-                       info_add_row(0, "Temperature", "%9.2f °C", state.temperature);
-               if (state.battery != AltosRecord.MISSING)
-                       info_add_row(0, "Battery", "%9.2f V", state.battery);
-               if (state.drogue_sense != AltosRecord.MISSING)
-                       info_add_row(0, "Drogue", "%9.2f V", state.drogue_sense);
-               if (state.main_sense != AltosRecord.MISSING)
-                       info_add_row(0, "Main", "%9.2f V", state.main_sense);
-               info_add_row(0, "CRC Errors", "%6d", crc_errors);
-
-               if (state.gps == null || !state.gps.connected) {
-                       info_add_row(1, "GPS", "not available");
-               } else {
-                       if (state.gps_ready)
-                               info_add_row(1, "GPS state", "%s", "ready");
-                       else
-                               info_add_row(1, "GPS state", "wait (%d)",
-                                            state.gps_waiting);
-                       if (state.data.gps.locked)
-                               info_add_row(1, "GPS", "   locked");
-                       else if (state.data.gps.connected)
-                               info_add_row(1, "GPS", " unlocked");
-                       else
-                               info_add_row(1, "GPS", "  missing");
-                       info_add_row(1, "Satellites", "%6d", state.data.gps.nsat);
-                       info_add_deg(1, "Latitude", state.gps.lat, 'N', 'S');
-                       info_add_deg(1, "Longitude", state.gps.lon, 'E', 'W');
-                       info_add_row(1, "GPS altitude", "%6d", state.gps.alt);
-                       info_add_row(1, "GPS height", "%6.0f", state.gps_height);
-
-                       /* The SkyTraq GPS doesn't report these values */
-                       /*
-                       if (false) {
-                               info_add_row(1, "GPS ground speed", "%8.1f m/s %3d°",
-                                            state.gps.ground_speed,
-                                            state.gps.course);
-                               info_add_row(1, "GPS climb rate", "%8.1f m/s",
-                                            state.gps.climb_rate);
-                               info_add_row(1, "GPS error", "%6d m(h)%3d m(v)",
-                                            state.gps.h_error, state.gps.v_error);
-                       }
-                       */
-
-                       info_add_row(1, "GPS hdop", "%8.1f", state.gps.hdop);
-
-                       if (state.npad > 0) {
-                               if (state.from_pad != null) {
-                                       info_add_row(1, "Distance from pad", "%6d m",
-                                                    (int) (state.from_pad.distance + 0.5));
-                                       info_add_row(1, "Direction from pad", "%6d°",
-                                                    (int) (state.from_pad.bearing + 0.5));
-                                       info_add_row(1, "Elevation from pad", "%6d°",
-                                                    (int) (state.elevation + 0.5));
-                                       info_add_row(1, "Range from pad", "%6d m",
-                                                    (int) (state.range + 0.5));
-                               } else {
-                                       info_add_row(1, "Distance from pad", "unknown");
-                                       info_add_row(1, "Direction from pad", "unknown");
-                                       info_add_row(1, "Elevation from pad", "unknown");
-                                       info_add_row(1, "Range from pad", "unknown");
+               if (state != null) {
+                       if (state.altitude != AltosRecord.MISSING)
+                               info_add_row(0, "Altitude", "%6.0f    m", state.altitude);
+                       if (state.ground_altitude != AltosRecord.MISSING)
+                               info_add_row(0, "Pad altitude", "%6.0f    m", state.ground_altitude);
+                       if (state.height != AltosRecord.MISSING)
+                               info_add_row(0, "Height", "%6.0f    m", state.height);
+                       if (state.height != AltosRecord.MISSING)
+                               info_add_row(0, "Max height", "%6.0f    m", state.max_height);
+                       if (state.acceleration != AltosRecord.MISSING)
+                               info_add_row(0, "Acceleration", "%8.1f  m/s²", state.acceleration);
+                       if (state.acceleration != AltosRecord.MISSING)
+                               info_add_row(0, "Max acceleration", "%8.1f  m/s²", state.max_acceleration);
+                       if (state.speed() != AltosRecord.MISSING)
+                               info_add_row(0, "Speed", "%8.1f  m/s", state.speed());
+                       if (state.speed() != AltosRecord.MISSING)
+                               info_add_row(0, "Max Speed", "%8.1f  m/s", state.max_accel_speed);
+                       if (state.temperature != AltosRecord.MISSING)
+                               info_add_row(0, "Temperature", "%9.2f °C", state.temperature);
+                       if (state.battery != AltosRecord.MISSING)
+                               info_add_row(0, "Battery", "%9.2f V", state.battery);
+                       if (state.drogue_sense != AltosRecord.MISSING)
+                               info_add_row(0, "Drogue", "%9.2f V", state.drogue_sense);
+                       if (state.main_sense != AltosRecord.MISSING)
+                               info_add_row(0, "Main", "%9.2f V", state.main_sense);
+               }
+               if (listener_state != null) {
+                       info_add_row(0, "CRC Errors", "%6d", listener_state.crc_errors);
+
+                       if (listener_state.battery != AltosRecord.MISSING)
+                               info_add_row(0, "Receiver Battery", "%9.2f", listener_state.battery);
+               }
+
+               if (state != null) {
+                       if (state.gps == null || !state.gps.connected) {
+                               info_add_row(1, "GPS", "not available");
+                       } else {
+                               if (state.gps_ready)
+                                       info_add_row(1, "GPS state", "%s", "ready");
+                               else
+                                       info_add_row(1, "GPS state", "wait (%d)",
+                                                    state.gps_waiting);
+                               if (state.data.gps.locked)
+                                       info_add_row(1, "GPS", "   locked");
+                               else if (state.data.gps.connected)
+                                       info_add_row(1, "GPS", " unlocked");
+                               else
+                                       info_add_row(1, "GPS", "  missing");
+                               info_add_row(1, "Satellites", "%6d", state.data.gps.nsat);
+                               info_add_deg(1, "Latitude", state.gps.lat, 'N', 'S');
+                               info_add_deg(1, "Longitude", state.gps.lon, 'E', 'W');
+                               info_add_row(1, "GPS altitude", "%6d", state.gps.alt);
+                               info_add_row(1, "GPS height", "%6.0f", state.gps_height);
+
+                               /* The SkyTraq GPS doesn't report these values */
+                               /*
+                                 if (false) {
+                                 info_add_row(1, "GPS ground speed", "%8.1f m/s %3d°",
+                                 state.gps.ground_speed,
+                                 state.gps.course);
+                                 info_add_row(1, "GPS climb rate", "%8.1f m/s",
+                                 state.gps.climb_rate);
+                                 info_add_row(1, "GPS error", "%6d m(h)%3d m(v)",
+                                 state.gps.h_error, state.gps.v_error);
+                                 }
+                               */
+
+                               info_add_row(1, "GPS hdop", "%8.1f", state.gps.hdop);
+
+                               if (state.npad > 0) {
+                                       if (state.from_pad != null) {
+                                               info_add_row(1, "Distance from pad", "%6d m",
+                                                            (int) (state.from_pad.distance + 0.5));
+                                               info_add_row(1, "Direction from pad", "%6d°",
+                                                            (int) (state.from_pad.bearing + 0.5));
+                                               info_add_row(1, "Elevation from pad", "%6d°",
+                                                            (int) (state.elevation + 0.5));
+                                               info_add_row(1, "Range from pad", "%6d m",
+                                                            (int) (state.range + 0.5));
+                                       } else {
+                                               info_add_row(1, "Distance from pad", "unknown");
+                                               info_add_row(1, "Direction from pad", "unknown");
+                                               info_add_row(1, "Elevation from pad", "unknown");
+                                               info_add_row(1, "Range from pad", "unknown");
+                                       }
+                                       info_add_deg(1, "Pad latitude", state.pad_lat, 'N', 'S');
+                                       info_add_deg(1, "Pad longitude", state.pad_lon, 'E', 'W');
+                                       info_add_row(1, "Pad GPS alt", "%6.0f m", state.pad_alt);
                                }
-                               info_add_deg(1, "Pad latitude", state.pad_lat, 'N', 'S');
-                               info_add_deg(1, "Pad longitude", state.pad_lon, 'E', 'W');
-                               info_add_row(1, "Pad GPS alt", "%6.0f m", state.pad_alt);
-                       }
-                       info_add_row(1, "GPS date", "%04d-%02d-%02d",
-                                      state.gps.year,
-                                      state.gps.month,
-                                      state.gps.day);
-                       info_add_row(1, "GPS time", "  %02d:%02d:%02d",
-                                      state.gps.hour,
-                                      state.gps.minute,
-                                      state.gps.second);
-                       //int   nsat_vis = 0;
-                       int     c;
-
-                       if (state.gps.cc_gps_sat == null)
-                               info_add_row(2, "Satellites Visible", "%4d", 0);
-                       else {
-                               info_add_row(2, "Satellites Visible", "%4d", state.gps.cc_gps_sat.length);
-                               for (c = 0; c < state.gps.cc_gps_sat.length; c++) {
-                                       info_add_row(2, "Satellite id,C/N0",
-                                                    "%4d, %4d",
-                                                    state.gps.cc_gps_sat[c].svid,
-                                                    state.gps.cc_gps_sat[c].c_n0);
+                               info_add_row(1, "GPS date", "%04d-%02d-%02d",
+                                            state.gps.year,
+                                            state.gps.month,
+                                            state.gps.day);
+                               info_add_row(1, "GPS time", "  %02d:%02d:%02d",
+                                            state.gps.hour,
+                                            state.gps.minute,
+                                            state.gps.second);
+                               //int   nsat_vis = 0;
+                               int     c;
+
+                               if (state.gps.cc_gps_sat == null)
+                                       info_add_row(2, "Satellites Visible", "%4d", 0);
+                               else {
+                                       info_add_row(2, "Satellites Visible", "%4d", state.gps.cc_gps_sat.length);
+                                       for (c = 0; c < state.gps.cc_gps_sat.length; c++) {
+                                               info_add_row(2, "Satellite id,C/N0",
+                                                            "%4d, %4d",
+                                                            state.gps.cc_gps_sat[c].svid,
+                                                            state.gps.cc_gps_sat[c].c_n0);
+                                       }
                                }
                        }
                }
index a245dde39299c919fedca84de97e3861de3e0ae2..1d209bda8ccaa493371d104126efb2d1c6ca21c2 100644 (file)
@@ -29,7 +29,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
        public class LandedValue {
                JLabel          label;
                JTextField      value;
-               void show(AltosState state, int crc_errors) {}
+               void show(AltosState state, AltosListenerState listener_state) {}
 
                void reset() {
                        value.setText("");
@@ -102,7 +102,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
        }
 
        class Lat extends LandedValue {
-               void show (AltosState state, int crc_errors) {
+               void show (AltosState state, AltosListenerState listener_state) {
                        if (state.gps != null && state.gps.connected)
                                show(pos(state.gps.lat,"N", "S"));
                        else
@@ -116,7 +116,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
        Lat lat;
 
        class Lon extends LandedValue {
-               void show (AltosState state, int crc_errors) {
+               void show (AltosState state, AltosListenerState listener_state) {
                        show();
                        if (state.gps != null && state.gps.connected)
                                show(pos(state.gps.lon,"E", "W"));
@@ -131,7 +131,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
        Lon lon;
 
        class Bearing extends LandedValue {
-               void show (AltosState state, int crc_errors) {
+               void show (AltosState state, AltosListenerState listener_state) {
                        show();
                        if (state.from_pad != null)
                                show("%3.0f°", state.from_pad.bearing);
@@ -146,7 +146,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
        Bearing bearing;
 
        class Distance extends LandedValue {
-               void show (AltosState state, int crc_errors) {
+               void show (AltosState state, AltosListenerState listener_state) {
                        show();
                        if (state.from_pad != null)
                                show(AltosConvert.distance, state.from_pad.distance);
@@ -161,7 +161,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
        Distance distance;
 
        class Height extends LandedValue {
-               void show (AltosState state, int crc_errors) {
+               void show (AltosState state, AltosListenerState listener_state) {
                        show(AltosConvert.height, state.max_height);
                }
                public Height (GridBagLayout layout, int y) {
@@ -172,7 +172,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
        Height  height;
 
        class Speed extends LandedValue {
-               void show (AltosState state, int crc_errors) {
+               void show (AltosState state, AltosListenerState listener_state) {
                        show(AltosConvert.speed, state.max_speed());
                }
                public Speed (GridBagLayout layout, int y) {
@@ -183,7 +183,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
        Speed   speed;
 
        class Accel extends LandedValue {
-               void show (AltosState state, int crc_errors) {
+               void show (AltosState state, AltosListenerState listener_state) {
                        show(AltosConvert.accel, state.max_acceleration);
                }
                public Accel (GridBagLayout layout, int y) {
@@ -213,21 +213,21 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
                accel.set_font();
        }
 
-       public void show(AltosState state, int crc_errors) {
+       public void show(AltosState state, AltosListenerState listener_state) {
                if (state.gps != null && state.gps.connected) {
-                       bearing.show(state, crc_errors);
-                       distance.show(state, crc_errors);
-                       lat.show(state, crc_errors);
-                       lon.show(state, crc_errors);
+                       bearing.show(state, listener_state);
+                       distance.show(state, listener_state);
+                       lat.show(state, listener_state);
+                       lon.show(state, listener_state);
                } else {
                        bearing.hide();
                        distance.hide();
                        lat.hide();
                        lon.hide();
                }
-               height.show(state, crc_errors);
-               speed.show(state, crc_errors);
-               accel.show(state, crc_errors);
+               height.show(state, listener_state);
+               speed.show(state, listener_state);
+               accel.show(state, listener_state);
                if (reader.backing_file() != null)
                        graph.setEnabled(true);
        }
index eb08525cff68775ef462eebf7e9ebe4c43c7b1fc..e2316a13c813a26fd248f5bb0737040391dbde0e 100644 (file)
@@ -29,7 +29,7 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
                JTextField      value;
                AltosLights     lights;
 
-               void show(AltosState state, int crc_errors) {}
+               void show(AltosState state, AltosListenerState listener_state) {}
 
                void reset() {
                        value.setText("");
@@ -109,7 +109,7 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
        public class LaunchValue {
                JLabel          label;
                JTextField      value;
-               void show(AltosState state, int crc_errors) {}
+               void show(AltosState state, AltosListenerState listener_state) {}
 
                void show() {
                        label.setVisible(true);
@@ -175,8 +175,8 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
        }
 
        class Battery extends LaunchStatus {
-               void show (AltosState state, int crc_errors) {
-                       if (state.battery == AltosRecord.MISSING)
+               void show (AltosState state, AltosListenerState listener_state) {
+                       if (state == null || state.battery == AltosRecord.MISSING)
                                hide();
                        else {
                                show("%4.2f V", state.battery);
@@ -191,9 +191,13 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
        Battery battery;
 
        class Apogee extends LaunchStatus {
-               void show (AltosState state, int crc_errors) {
-                       show("%4.2f V", state.drogue_sense);
-                       lights.set(state.drogue_sense > 3.2);
+               void show (AltosState state, AltosListenerState listener_state) {
+                       if (state == null || state.drogue_sense == AltosRecord.MISSING)
+                               hide();
+                       else {
+                               show("%4.2f V", state.drogue_sense);
+                               lights.set(state.drogue_sense > 3.2);
+                       }
                }
                public Apogee (GridBagLayout layout, int y) {
                        super(layout, y, "Apogee Igniter Voltage");
@@ -203,9 +207,13 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
        Apogee apogee;
 
        class Main extends LaunchStatus {
-               void show (AltosState state, int crc_errors) {
-                       show("%4.2f V", state.main_sense);
-                       lights.set(state.main_sense > 3.2);
+               void show (AltosState state, AltosListenerState listener_state) {
+                       if (state == null || state.main_sense == AltosRecord.MISSING)
+                               hide();
+                       else {
+                               show("%4.2f V", state.main_sense);
+                               lights.set(state.main_sense > 3.2);
+                       }
                }
                public Main (GridBagLayout layout, int y) {
                        super(layout, y, "Main Igniter Voltage");
@@ -215,18 +223,21 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
        Main main;
 
        class LoggingReady extends LaunchStatus {
-               void show (AltosState state, int crc_errors) {
-                       if (state.data.flight != 0) {
-                               if (state.data.state <= Altos.ao_flight_pad)
-                                       show("Ready to record");
-                               else if (state.data.state < Altos.ao_flight_landed)
-                                       show("Recording data");
-                               else
-                                       show("Recorded data");
+               void show (AltosState state, AltosListenerState listener_state) {
+                       if (state == null || state.data.flight == AltosRecord.MISSING) {
+                               hide();
+                       } else {
+                               if (state.data.flight != 0) {
+                                       if (state.data.state <= Altos.ao_flight_pad)
+                                               show("Ready to record");
+                                       else if (state.data.state < Altos.ao_flight_landed)
+                                               show("Recording data");
+                                       else
+                                               show("Recorded data");
+                               } else
+                                       show("Storage full");
+                               lights.set(state.data.flight != 0);
                        }
-                       else
-                               show("Storage full");
-                       lights.set(state.data.flight != 0);
                }
                public LoggingReady (GridBagLayout layout, int y) {
                        super(layout, y, "On-board Data Logging");
@@ -236,9 +247,13 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
        LoggingReady logging_ready;
 
        class GPSLocked extends LaunchStatus {
-               void show (AltosState state, int crc_errors) {
-                       show("%4d sats", state.gps.nsat);
-                       lights.set(state.gps.locked && state.gps.nsat >= 4);
+               void show (AltosState state, AltosListenerState listener_state) {
+                       if (state == null || state.gps == null)
+                               hide();
+                       else {
+                               show("%4d sats", state.gps.nsat);
+                               lights.set(state.gps.locked && state.gps.nsat >= 4);
+                       }
                }
                public GPSLocked (GridBagLayout layout, int y) {
                        super (layout, y, "GPS Locked");
@@ -248,12 +263,16 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
        GPSLocked gps_locked;
 
        class GPSReady extends LaunchStatus {
-               void show (AltosState state, int crc_errors) {
-                       if (state.gps_ready)
-                               show("Ready");
-                       else
-                               show("Waiting %d", state.gps_waiting);
-                       lights.set(state.gps_ready);
+               void show (AltosState state, AltosListenerState listener_state) {
+                       if (state == null || state.gps == null)
+                               hide();
+                       else {
+                               if (state.gps_ready)
+                                       show("Ready");
+                               else
+                                       show("Waiting %d", state.gps_waiting);
+                               lights.set(state.gps_ready);
+                       }
                }
                public GPSReady (GridBagLayout layout, int y) {
                        super (layout, y, "GPS Ready");
@@ -262,6 +281,22 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
 
        GPSReady gps_ready;
 
+       class ReceiverBattery extends LaunchStatus {
+               void show (AltosState state, AltosListenerState listener_state) {
+                       if (listener_state == null || listener_state.battery == AltosRecord.MISSING)
+                               hide();
+                       else {
+                               show("%4.2f V", listener_state.battery);
+                               lights.set(listener_state.battery > 3.7);
+                       }
+               }
+               public ReceiverBattery (GridBagLayout layout, int y) {
+                       super(layout, y, "Receiver Battery");
+               }
+       }
+
+       ReceiverBattery receiver_battery;
+
        String pos(double p, String pos, String neg) {
                String  h = pos;
                if (p < 0) {
@@ -274,13 +309,17 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
        }
 
        class PadLat extends LaunchValue {
-               void show (AltosState state, int crc_errors) {
-                       if (state.state < AltosLib.ao_flight_pad && state.gps != null) {
-                               show(pos(state.gps.lat,"N", "S"));
-                               set_label("Latitude");
-                       } else { 
-                               show(pos(state.pad_lat,"N", "S"));
-                               set_label("Pad Latitude");
+               void show (AltosState state, AltosListenerState listener_state) {
+                       if (state == null || state.gps == null) {
+                               hide();
+                       } else {
+                               if (state.state < AltosLib.ao_flight_pad) {
+                                       show(pos(state.gps.lat,"N", "S"));
+                                       set_label("Latitude");
+                               } else { 
+                                       show(pos(state.pad_lat,"N", "S"));
+                                       set_label("Pad Latitude");
+                               }
                        }
                }
                public PadLat (GridBagLayout layout, int y) {
@@ -291,13 +330,17 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
        PadLat pad_lat;
 
        class PadLon extends LaunchValue {
-               void show (AltosState state, int crc_errors) {
-                       if (state.state < AltosLib.ao_flight_pad && state.gps != null) {
-                               show(pos(state.gps.lon,"E", "W"));
-                               set_label("Longitude");
-                       } else { 
-                               show(pos(state.pad_lon,"E", "W"));
-                               set_label("Pad Longitude");
+               void show (AltosState state, AltosListenerState listener_state) {
+                       if (state == null || state.gps == null) {
+                               hide();
+                       } else {
+                               if (state.state < AltosLib.ao_flight_pad) {
+                                       show(pos(state.gps.lon,"E", "W"));
+                                       set_label("Longitude");
+                               } else { 
+                                       show(pos(state.pad_lon,"E", "W"));
+                                       set_label("Pad Longitude");
+                               }
                        }
                }
                public PadLon (GridBagLayout layout, int y) {
@@ -308,16 +351,20 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
        PadLon pad_lon;
 
        class PadAlt extends LaunchValue {
-               void show (AltosState state, int crc_errors) {
-                       if (state.state < AltosLib.ao_flight_pad && state.gps != null) {
-                               show("%4.0f m", state.gps.alt);
-                               set_label("Altitude");
-                       } else {
-                               if (state.pad_alt == AltosRecord.MISSING)
-                                       hide();
-                               else {
-                                       show("%4.0f m", state.pad_alt);
-                                       set_label("Pad Altitude");
+               void show (AltosState state, AltosListenerState listener_state) {
+                       if (state == null)
+                               hide();
+                       else {
+                               if (state.state < AltosLib.ao_flight_pad && state.gps != null) {
+                                       show("%4.0f m", state.gps.alt);
+                                       set_label("Altitude");
+                               } else {
+                                       if (state.pad_alt == AltosRecord.MISSING)
+                                               hide();
+                                       else {
+                                               show("%4.0f m", state.pad_alt);
+                                               set_label("Pad Altitude");
+                                       }
                                }
                        }
                }
@@ -335,6 +382,7 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
                logging_ready.reset();
                gps_locked.reset();
                gps_ready.reset();
+               receiver_battery.reset();
                pad_lat.reset();
                pad_lon.reset();
                pad_alt.reset();
@@ -347,34 +395,23 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
                logging_ready.set_font();
                gps_locked.set_font();
                gps_ready.set_font();
+               receiver_battery.set_font();
                pad_lat.set_font();
                pad_lon.set_font();
                pad_alt.set_font();
        }
        
-       public void show(AltosState state, int crc_errors) {
-               battery.show(state, crc_errors);
-               if (state.drogue_sense == AltosRecord.MISSING)
-                       apogee.hide();
-               else
-                       apogee.show(state, crc_errors);
-               if (state.main_sense == AltosRecord.MISSING)
-                       main.hide();
-               else
-                       main.show(state, crc_errors);
-               logging_ready.show(state, crc_errors);
-               pad_alt.show(state, crc_errors);
-               if (state.gps != null && state.gps.connected) {
-                       gps_locked.show(state, crc_errors);
-                       gps_ready.show(state, crc_errors);
-                       pad_lat.show(state, crc_errors);
-                       pad_lon.show(state, crc_errors);
-               } else {
-                       gps_locked.hide();
-                       gps_ready.hide();
-                       pad_lat.hide();
-                       pad_lon.hide();
-               }
+       public void show(AltosState state, AltosListenerState listener_state) {
+               battery.show(state, listener_state);
+               apogee.show(state, listener_state);
+               main.show(state, listener_state);
+               logging_ready.show(state, listener_state);
+               pad_alt.show(state, listener_state);
+               receiver_battery.show(state, listener_state);
+               gps_locked.show(state, listener_state);
+               gps_ready.show(state, listener_state);
+               pad_lat.show(state, listener_state);
+               pad_lon.show(state, listener_state);
        }
 
        public AltosPad() {
@@ -398,8 +435,10 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
                logging_ready = new LoggingReady(layout, 3);
                gps_locked = new GPSLocked(layout, 4);
                gps_ready = new GPSReady(layout, 5);
-               pad_lat = new PadLat(layout, 6);
-               pad_lon = new PadLon(layout, 7);
-               pad_alt = new PadAlt(layout, 8);
+               receiver_battery = new ReceiverBattery(layout, 6);
+               pad_lat = new PadLat(layout, 7);
+               pad_lon = new PadLon(layout, 8);
+               pad_alt = new PadAlt(layout, 9);
+               show(null, null);
        }
 }
index f614eae65fc526370b1508b45a6477cd9ccd077d..5bf02e546179fbf936cdfb05c263617bb4054b84 100644 (file)
@@ -264,7 +264,7 @@ public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay {
                initMaps(lat, lon);
                scrollRocketToVisible(pt(lat, lon));
        }
-       public void show(final AltosState state, final int crc_errors) {
+       public void show(final AltosState state, final AltosListenerState listener_state) {
                // if insufficient gps data, nothing to update
                if (!state.gps.locked && state.gps.nsat < 4)
                        return;
@@ -294,7 +294,7 @@ public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay {
                        Point2D.Double ref, lref;
                        ref = translatePoint(pt, tileCoordOffset(offset));
                        lref = translatePoint(last_pt, tileCoordOffset(offset));
-                       tile.show(state, crc_errors, lref, ref);
+                       tile.show(state, listener_state, lref, ref);
                        if (0 <= ref.x && ref.x < px_size)
                                if (0 <= ref.y && ref.y < px_size)
                                        in_any = true;
@@ -307,7 +307,7 @@ public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay {
                        lref = translatePoint(last_pt, tileCoordOffset(offset));
 
                        AltosSiteMapTile tile = createTile(offset);
-                       tile.show(state, crc_errors, lref, ref);
+                       tile.show(state, listener_state, lref, ref);
                        initMap(offset);
                        finishTileLater(tile, offset);
                }
index 10e65bcda81ed5410d9056fc1434572528a1a47a..365e4b6c3c36846a96e9fdc91ffed0fec6e072af 100644 (file)
@@ -56,7 +56,7 @@ public class AltosSiteMapTile extends JLayeredPane {
 
        private boolean drawn_landed_circle = false;
        private boolean drawn_boost_circle = false;
-       public synchronized void show(AltosState state, int crc_errors,
+       public synchronized void show(AltosState state, AltosListenerState listener_state,
                                      Point2D.Double last_pt, Point2D.Double pt)
        {
                if (0 <= state.state && state.state < stateColors.length) {
index 6c790f69046cf7fefb94ac37224a9c6fccca2195..977e10b87d2716d5a2817b4d51dcbd3215f8bd14 100644 (file)
@@ -94,7 +94,7 @@ extern volatile __data AO_TICK_TYPE ao_tick_count;
 #define AO_SEC_TO_TICKS(s)     ((s) * AO_HERTZ)
 
 /* Returns the current time in ticks */
-uint16_t
+AO_TICK_TYPE
 ao_time(void);
 
 /* Suspend the current task until ticks time has passed */
index e07625d8d7d1e809db29f18c5f6deaae388f0869..8b7c2327ff2bdd34f93e7f93a8351f0c3ff63a4f 100644 (file)
 #include "ao.h"
 #include <ao_task.h>
 
-volatile __data AO_TICK_TYPE ao_tick_count;
+volatile AO_TICK_TYPE ao_tick_count;
 
-uint16_t ao_time(void)
+AO_TICK_TYPE
+ao_time(void)
 {
-       uint16_t        v;
-       ao_arch_critical(
-               v = ao_tick_count;
-               );
-       return v;
+       return ao_tick_count;
 }
 
 #if AO_DATA_ALL