altoslib: Reset transient AltosCalData values before processing data
authorKeith Packard <keithp@keithp.com>
Sun, 28 May 2017 22:52:17 +0000 (15:52 -0700)
committerKeith Packard <keithp@keithp.com>
Sun, 28 May 2017 22:52:17 +0000 (15:52 -0700)
Values in cal_data which are used to hold intermediate results need to
get reset back to their initial values before processing a series of
flight data again.

Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/AltosCalData.java
altoslib/AltosEepromRecordSet.java
altoslib/AltosTelemetryFile.java
altoslib/AltosTelemetryRecordSet.java

index 408d8d7e5f78738e7298fda27c06543f9cdef4a1..cb58e4929c3056ada5af4db3b6249d53a9e16932 100644 (file)
@@ -65,8 +65,11 @@ public class AltosCalData {
        public int              device_type = AltosLib.MISSING;
 
        public void set_device_type(int device_type) {
-               if (device_type != AltosLib.MISSING)
+               if (device_type != AltosLib.MISSING) {
                        this.device_type = device_type;
+                       if (product == null)
+                               set_product(AltosLib.product_name(device_type));
+               }
        }
 
        public int              config_major = AltosLib.MISSING;
@@ -179,6 +182,18 @@ public class AltosCalData {
                }
        }
 
+       /* Reset all values which change during flight
+        */
+       public void reset() {
+               state = AltosLib.MISSING;
+               tick = AltosLib.MISSING;
+               prev_tick = AltosLib.MISSING;
+               temp_gps = null;
+               prev_gps = null;
+               temp_gps_sat_tick = AltosLib.MISSING;
+               accel = AltosLib.MISSING;
+       }
+
        public int              boost_tick = AltosLib.MISSING;
 
        public void set_boost_tick() {
index c019a092bbeb0c44d3652e1768e8fbea6de50c09..7b111ed3d18d9d0cfa86df3eeb21d1321eba6001 100644 (file)
@@ -42,6 +42,8 @@ public class AltosEepromRecordSet implements AltosRecordSet {
 
        public void capture_series(AltosDataListener listener) {
                AltosCalData    cal_data = cal_data();
+
+               cal_data.reset();
                for (AltosEepromRecord record : ordered) {
                        record.provide_data(listener, cal_data);
                }
index 077ef9c6336560084fee5b37232939467b8c55a1..a4792f118938b4d0283954d7bd1d8ae8919bb158 100644 (file)
@@ -118,10 +118,13 @@ public class AltosTelemetryFile implements AltosRecordSet {
        public void capture_series(AltosDataListener listener) {
                AltosCalData    cal_data = cal_data();
 
+               cal_data.reset();
                for (AltosTelemetry telem : telems) {
                        int tick = telem.tick();
                        cal_data.set_tick(tick);
-                       if (cal_data.time() >= -1)
+
+                       /* Try to pick up at least one pre-boost value */
+                       if (cal_data.time() >= -2)
                                telem.provide_data(listener, cal_data);
                        if (listener.state == AltosLib.ao_flight_landed)
                                break;
index 0323c25e7fcb96ca41a28fb29f597242dfdaa321..a31911007ac9b68f017b77a6ee635ab91919d584 100644 (file)
@@ -22,6 +22,7 @@ public class AltosTelemetryRecordSet implements AltosRecordSet {
        TreeSet<AltosTelemetryRecord>   ordered;
 
        public void capture_series(AltosDataListener listener) {
+               listener.cal_data.reset();
                for (AltosTelemetryRecord record : ordered) {
                        record.update_state(listener);
                }