altosui: Don't display missing sensor data
authorKeith Packard <keithp@keithp.com>
Tue, 2 Apr 2013 23:47:07 +0000 (16:47 -0700)
committerKeith Packard <keithp@keithp.com>
Tue, 2 Apr 2013 23:47:07 +0000 (16:47 -0700)
For devices without sensors, don't display temperature, barometric and
accelerometer-derived values.

Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/AltosState.java
altosui/AltosInfoTable.java
altosui/AltosPad.java

index 5598a60353b9af204dd78634de0200c25d7eeb1c..f18bf368c22e3314962cfa3c329cef2c190c12d1 100644 (file)
@@ -99,19 +99,27 @@ public class AltosState {
 
                altitude = data.altitude();
 
 
                altitude = data.altitude();
 
+               height = AltosRecord.MISSING;
                if (data.kalman_height != AltosRecord.MISSING)
                        height = data.kalman_height;
                else {
                if (data.kalman_height != AltosRecord.MISSING)
                        height = data.kalman_height;
                else {
-                       if (prev_state != null)
-                               height = (prev_state.height * 15 + altitude - ground_altitude) / 16.0;
+                       if (prev_state != null && altitude != AltosRecord.MISSING && ground_altitude != AltosRecord.MISSING) {
+                               double  cur_height = altitude - ground_altitude;
+                               if (prev_state.height == AltosRecord.MISSING)
+                                       height = cur_height;
+                               else
+                                       height = (prev_state.height * 15 + cur_height) / 16.0;
+                       }
                }
 
                report_time = System.currentTimeMillis();
 
                if (data.kalman_acceleration != AltosRecord.MISSING)
                        acceleration = data.kalman_acceleration;
                }
 
                report_time = System.currentTimeMillis();
 
                if (data.kalman_acceleration != AltosRecord.MISSING)
                        acceleration = data.kalman_acceleration;
-               else
+               else {
                        acceleration = data.acceleration();
                        acceleration = data.acceleration();
+                       System.out.printf ("data acceleration %g\n", acceleration);
+               }
                temperature = data.temperature();
                drogue_sense = data.drogue_voltage();
                main_sense = data.main_voltage();
                temperature = data.temperature();
                drogue_sense = data.drogue_voltage();
                main_sense = data.main_voltage();
@@ -169,16 +177,18 @@ public class AltosState {
                        npad = 0;
                        ngps = 0;
                        gps = null;
                        npad = 0;
                        ngps = 0;
                        gps = null;
-                       baro_speed = 0;
-                       accel_speed = 0;
+                       baro_speed = AltosRecord.MISSING;
+                       accel_speed = AltosRecord.MISSING;
+                       max_baro_speed = AltosRecord.MISSING;
+                       max_accel_speed = AltosRecord.MISSING;
+                       max_height = AltosRecord.MISSING;
+                       max_acceleration = AltosRecord.MISSING;
                        time_change = 0;
                        time_change = 0;
-                       if (acceleration == AltosRecord.MISSING)
-                               acceleration = 0;
                }
 
                time = tick / 100.0;
 
                }
 
                time = tick / 100.0;
 
-               if (cur.new_gps && (state == AltosLib.ao_flight_pad || state == AltosLib.ao_flight_idle)) {
+               if (cur.new_gps && (state < AltosLib.ao_flight_boost)) {
 
                        /* Track consecutive 'good' gps reports, waiting for 10 of them */
                        if (data.gps != null && data.gps.locked && data.gps.nsat >= 4)
 
                        /* Track consecutive 'good' gps reports, waiting for 10 of them */
                        if (data.gps != null && data.gps.locked && data.gps.nsat >= 4)
@@ -188,7 +198,7 @@ public class AltosState {
 
                        /* Average GPS data while on the pad */
                        if (data.gps != null && data.gps.locked && data.gps.nsat >= 4) {
 
                        /* Average GPS data while on the pad */
                        if (data.gps != null && data.gps.locked && data.gps.nsat >= 4) {
-                               if (ngps > 1) {
+                               if (ngps > 1 && state == AltosLib.ao_flight_pad) {
                                        /* filter pad position */
                                        pad_lat = (pad_lat * 31.0 + data.gps.lat) / 32.0;
                                        pad_lon = (pad_lon * 31.0 + data.gps.lon) / 32.0;
                                        /* filter pad position */
                                        pad_lat = (pad_lat * 31.0 + data.gps.lat) / 32.0;
                                        pad_lon = (pad_lon * 31.0 + data.gps.lon) / 32.0;
@@ -201,7 +211,7 @@ public class AltosState {
                                ngps++;
                        }
                } else {
                                ngps++;
                        }
                } else {
-                       if (ngps == 0)
+                       if (ngps == 0 && ground_altitude != AltosRecord.MISSING)
                                pad_alt = ground_altitude;
                }
 
                                pad_alt = ground_altitude;
                }
 
@@ -218,14 +228,14 @@ public class AltosState {
                boost = (AltosLib.ao_flight_boost == state);
 
                /* Only look at accelerometer data under boost */
                boost = (AltosLib.ao_flight_boost == state);
 
                /* Only look at accelerometer data under boost */
-               if (boost && acceleration > max_acceleration && acceleration != AltosRecord.MISSING)
+               if (boost && acceleration != AltosRecord.MISSING && (max_acceleration == AltosRecord.MISSING || acceleration > max_acceleration))
                        max_acceleration = acceleration;
                        max_acceleration = acceleration;
-               if (boost && accel_speed > max_accel_speed && accel_speed != AltosRecord.MISSING)
+               if (boost && accel_speed != AltosRecord.MISSING && (max_accel_speed == AltosRecord.MISSING || accel_speed > max_accel_speed))
                        max_accel_speed = accel_speed;
                        max_accel_speed = accel_speed;
-               if (boost && baro_speed > max_baro_speed && baro_speed != AltosRecord.MISSING)
+               if (boost && baro_speed != AltosRecord.MISSING && (max_baro_speed == AltosRecord.MISSING || baro_speed > max_baro_speed))
                        max_baro_speed = baro_speed;
 
                        max_baro_speed = baro_speed;
 
-               if (height > max_height && height != AltosRecord.MISSING)
+               if (height != AltosRecord.MISSING || (max_height == AltosRecord.MISSING || height > max_height))
                        max_height = height;
                if (data.gps != null) {
                        if (gps == null || !gps.locked || data.gps.locked)
                        max_height = height;
                if (data.gps != null) {
                        if (gps == null || !gps.locked || data.gps.locked)
index 2facf38ae21f76f95a6a9005804840f846eae321..1dce6dafbc216493726469b081a4676360359e35 100644 (file)
@@ -108,16 +108,26 @@ public class AltosInfoTable extends JTable {
                if (state == null)
                        return;
                info_reset();
                if (state == null)
                        return;
                info_reset();
-               info_add_row(0, "Altitude", "%6.0f    m", state.altitude);
-               info_add_row(0, "Pad altitude", "%6.0f    m", state.ground_altitude);
-               info_add_row(0, "Height", "%6.0f    m", state.height);
-               info_add_row(0, "Max height", "%6.0f    m", state.max_height);
-               info_add_row(0, "Acceleration", "%8.1f  m/s²", state.acceleration);
-               info_add_row(0, "Max acceleration", "%8.1f  m/s²", state.max_acceleration);
-               info_add_row(0, "Speed", "%8.1f  m/s", state.speed());
-               info_add_row(0, "Max Speed", "%8.1f  m/s", state.max_accel_speed);
-               info_add_row(0, "Temperature", "%9.2f °C", state.temperature);
-               info_add_row(0, "Battery", "%9.2f V", state.battery);
+               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)
                if (state.drogue_sense != AltosRecord.MISSING)
                        info_add_row(0, "Drogue", "%9.2f V", state.drogue_sense);
                if (state.main_sense != AltosRecord.MISSING)
index d13f69458c4705470cfc6cf398af73aee44f7d45..66cb4cfca83f3409d72763d05703a796f07b1515 100644 (file)
@@ -168,8 +168,12 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
 
        class Battery extends LaunchStatus {
                void show (AltosState state, int crc_errors) {
 
        class Battery extends LaunchStatus {
                void show (AltosState state, int crc_errors) {
-                       show("%4.2f V", state.battery);
-                       lights.set(state.battery > 3.7);
+                       if (state.battery == AltosRecord.MISSING)
+                               hide();
+                       else {
+                               show("%4.2f V", state.battery);
+                               lights.set(state.battery > 3.7);
+                       }
                }
                public Battery (GridBagLayout layout, int y) {
                        super(layout, y, "Battery Voltage");
                }
                public Battery (GridBagLayout layout, int y) {
                        super(layout, y, "Battery Voltage");
@@ -285,7 +289,10 @@ public class AltosPad extends JComponent implements AltosFlightDisplay {
 
        class PadAlt extends LaunchValue {
                void show (AltosState state, int crc_errors) {
 
        class PadAlt extends LaunchValue {
                void show (AltosState state, int crc_errors) {
-                       show("%4.0f m", state.pad_alt);
+                       if (state.pad_alt == AltosRecord.MISSING)
+                               hide();
+                       else
+                               show("%4.0f m", state.pad_alt);
                }
                public PadAlt (GridBagLayout layout, int y) {
                        super (layout, y, "Pad Altitude");
                }
                public PadAlt (GridBagLayout layout, int y) {
                        super (layout, y, "Pad Altitude");