Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
[fw/altos] / altoslib / AltosTelemetryFile.java
index 0b0e6a484c18a077a0bcdecc95b3c425c1acd5a9..e51455f8bb8c00cd4dabb62aa134276942e2e5f9 100644 (file)
@@ -16,7 +16,7 @@
  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  */
 
-package org.altusmetrum.altoslib_11;
+package org.altusmetrum.altoslib_12;
 
 import java.io.*;
 import java.util.*;
@@ -46,12 +46,14 @@ class AltosTelemetryNullListener extends AltosDataListener {
        public void set_accel(double along, double across, double through) { }
        public void set_mag(double along, double across, double through) { }
        public void set_pyro_voltage(double volts) { }
-       public void set_ignitor_voltage(double[] voltage) { }
+       public void set_igniter_voltage(double[] voltage) { }
        public void set_pyro_fired(int pyro_mask) { }
        public void set_companion(AltosCompanion companion) { }
 
        public boolean cal_data_complete() {
                /* All telemetry packets */
+               AltosCalData cal_data = cal_data();
+
                if (cal_data.serial == AltosLib.MISSING)
                        return false;
 
@@ -78,7 +80,7 @@ class AltosTelemetryNullListener extends AltosDataListener {
                /*
                 * TelemetryLocation
                 */
-               if (AltosLib.has_gps(cal_data.device_type) && cal_data.gps_ground_altitude == AltosLib.MISSING)
+               if (AltosLib.has_gps(cal_data.device_type) && cal_data.gps_pad == null)
                        return false;
 
                return true;
@@ -107,11 +109,10 @@ public class AltosTelemetryFile implements AltosRecordSet {
                        AltosTelemetryNullListener l = new AltosTelemetryNullListener(cal_data);
 
                        for (AltosTelemetry telem : telems) {
-                               telem.provide_data(l, cal_data);
+                               telem.provide_data(l);
                                if (l.cal_data_complete())
                                        break;
                        }
-                       System.out.printf("Telemetry boost tick %d\n", cal_data.boost_tick);
                }
                return cal_data;
        }
@@ -119,15 +120,21 @@ 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)
-                               telem.provide_data(listener, cal_data);
+
+                       /* Try to pick up at least one pre-boost value */
+                       if (cal_data.time() >= -2)
+                               telem.provide_data(listener);
+                       if (listener.state() == AltosLib.ao_flight_landed)
+                               break;
                }
+               listener.finish();
        }
 
-       public AltosTelemetryFile(FileInputStream input) {
+       public AltosTelemetryFile(FileInputStream input) throws IOException {
                telems = new AltosTelemetryIterable(input);
        }
 }