altoslib: Make cal_data private in AltosDataListener
authorKeith Packard <keithp@keithp.com>
Tue, 20 Jun 2017 18:18:41 +0000 (11:18 -0700)
committerKeith Packard <keithp@keithp.com>
Tue, 20 Jun 2017 18:18:41 +0000 (11:18 -0700)
This way we can create it as needed.

Signed-off-by: Keith Packard <keithp@keithp.com>
51 files changed:
altoslib/AltosCSV.java
altoslib/AltosDataListener.java
altoslib/AltosDataProvider.java
altoslib/AltosEepromRecordTiny.java
altoslib/AltosFlightSeries.java
altoslib/AltosFlightStats.java
altoslib/AltosGPS.java
altoslib/AltosIMU.java
altoslib/AltosIdleFetch.java
altoslib/AltosIdleMonitor.java
altoslib/AltosIdleReader.java
altoslib/AltosKML.java
altoslib/AltosLog.java
altoslib/AltosMag.java
altoslib/AltosMma655x.java
altoslib/AltosMs5607.java
altoslib/AltosReplayReader.java
altoslib/AltosSensorEMini.java
altoslib/AltosSensorMega.java
altoslib/AltosSensorMetrum.java
altoslib/AltosSensorTGPS.java
altoslib/AltosSensorTM.java
altoslib/AltosSensorTMini2.java
altoslib/AltosSensorTMini3.java
altoslib/AltosState.java
altoslib/AltosTelemetry.java
altoslib/AltosTelemetryCompanion.java
altoslib/AltosTelemetryConfiguration.java
altoslib/AltosTelemetryFile.java
altoslib/AltosTelemetryLegacy.java
altoslib/AltosTelemetryLocation.java
altoslib/AltosTelemetryMegaData.java
altoslib/AltosTelemetryMegaSensor.java
altoslib/AltosTelemetryMetrumSensor.java
altoslib/AltosTelemetryMini2.java
altoslib/AltosTelemetryMini3.java
altoslib/AltosTelemetryRaw.java
altoslib/AltosTelemetryReader.java
altoslib/AltosTelemetrySatellite.java
altoslib/AltosTelemetrySensor.java
altoslib/AltosTelemetryStandard.java
altosui/AltosFlightStatus.java
altosui/AltosPad.java
altosui/AltosUI.java
altosuilib/AltosCSVUI.java
altosuilib/AltosGraph.java
altosuilib/AltosInfoTable.java
altosuilib/AltosScanUI.java
telegps/TeleGPS.java
telegps/TeleGPSState.java
telegps/TeleGPSStatus.java

index aed1872..f55b478 100644 (file)
@@ -133,8 +133,8 @@ public class AltosCSV implements AltosWriter {
        void write_general() {
                double time = time();
                out.printf("%s, %d, %d, %s, %8.2f, %8.2f, %4d, %3d",
-                          ALTOS_CSV_VERSION, series.cal_data.serial,
-                          series.cal_data.flight, series.cal_data.callsign,
+                          ALTOS_CSV_VERSION, series.cal_data().serial,
+                          series.cal_data().flight, series.cal_data().callsign,
                           time, time,
                           rssi(), status() & 0x7f);
        }
@@ -220,8 +220,8 @@ public class AltosCSV implements AltosWriter {
 
                AltosGreatCircle from_pad;
 
-               if (series.cal_data.gps_pad != null && gps != null)
-                       from_pad = new AltosGreatCircle(series.cal_data.gps_pad, gps);
+               if (series.cal_data().gps_pad != null && gps != null)
+                       from_pad = new AltosGreatCircle(series.cal_data().gps_pad, gps);
                else
                        from_pad = new AltosGreatCircle();
 
index 7f5dfda..5f89b3e 100644 (file)
@@ -16,24 +16,45 @@ package org.altusmetrum.altoslib_12;
 
 public abstract class AltosDataListener {
 
-       public AltosCalData     cal_data = null;
+       private AltosCalData    cal_data = null;
+
        public double           time = AltosLib.MISSING;
        public int              state = AltosLib.MISSING;
 
+       public void set_tick(int tick) {
+               cal_data.set_tick(tick);
+               set_time(cal_data.time());
+       }
+
+       public AltosCalData cal_data() {
+               if (cal_data == null)
+                       cal_data = new AltosCalData();
+               return cal_data;
+       }
+
        public void set_time(double time) {
                if (time != AltosLib.MISSING)
                        this.time = time;
        }
 
+       public void set_serial(int serial) {
+               cal_data().set_serial(serial);
+       }
+
        public double time() {
                return time;
        }
 
        public void set_state(int state) {
+               cal_data().set_state(state);
                if (state != AltosLib.MISSING)
                        this.state = state;
        }
 
+       public void set_flight(int flight) {
+               cal_data().set_flight(flight);
+       }
+
        /* Called after all records are captured */
        public void finish() {
        }
index f977aee..9589a8e 100644 (file)
@@ -19,5 +19,5 @@
 package org.altusmetrum.altoslib_12;
 
 public interface AltosDataProvider {
-       public void     provide_data(AltosDataListener listener, AltosCalData cal_data) throws InterruptedException, AltosUnknownProduct;
+       public void     provide_data(AltosDataListener listener) throws InterruptedException, AltosUnknownProduct;
 }
index 4d44ddd..06ee9d5 100644 (file)
@@ -50,16 +50,15 @@ public class AltosEepromRecordTiny extends AltosEepromRecord implements AltosDat
                return tick;
        }
 
-       public void provide_data(AltosDataListener listener, AltosCalData cal_data) {
+       public void provide_data(AltosDataListener listener) {
                int value = data16(-header_length);
 
-               cal_data.set_tick(tick());
-               listener.set_time(cal_data.time());
+               listener.set_tick(tick());
                switch (cmd()) {
                case AltosLib.AO_LOG_FLIGHT:
                        listener.set_state(AltosLib.ao_flight_pad);
-                       cal_data.set_flight(value);
-                       cal_data.set_boost_tick();
+                       listener.cal_data().set_flight(value);
+                       listener.cal_data().set_boost_tick();
                        break;
                case AltosLib.AO_LOG_STATE:
                        listener.set_state(value & 0x7fff);
index fc7a9f1..45d3b45 100644 (file)
@@ -232,23 +232,23 @@ public class AltosFlightSeries extends AltosDataListener {
                if (altitude_series == null)
                        altitude_series = add_series(altitude_name, AltosConvert.height);
 
-               if (cal_data.ground_pressure == AltosLib.MISSING)
-                       cal_data.set_ground_pressure(pa);
+               if (cal_data().ground_pressure == AltosLib.MISSING)
+                       cal_data().set_ground_pressure(pa);
 
                double altitude = AltosConvert.pressure_to_altitude(pa);
                altitude_series.add(time(), altitude);
        }
 
        private void compute_height() {
-               double ground_altitude = cal_data.ground_altitude;
+               double ground_altitude = cal_data().ground_altitude;
                if (height_series == null && ground_altitude != AltosLib.MISSING && altitude_series != null) {
                        height_series = add_series(height_name, AltosConvert.height);
                        for (AltosTimeValue alt : altitude_series)
                                height_series.add(alt.time, alt.value - ground_altitude);
                }
 
-               if (gps_height == null && cal_data.gps_pad != null && cal_data.gps_pad.alt != AltosLib.MISSING && gps_altitude != null) {
-                       double gps_ground_altitude = cal_data.gps_pad.alt;
+               if (gps_height == null && cal_data().gps_pad != null && cal_data().gps_pad.alt != AltosLib.MISSING && gps_altitude != null) {
+                       double gps_ground_altitude = cal_data().gps_pad.alt;
                        gps_height = add_series(gps_height_name, AltosConvert.height);
                        for (AltosTimeValue gps_alt : gps_altitude)
                                gps_height.add(gps_alt.time, gps_alt.value - gps_ground_altitude);
@@ -343,16 +343,16 @@ public class AltosFlightSeries extends AltosDataListener {
                if (accel_ground_across == AltosLib.MISSING)
                        return;
 
-               if (cal_data.pad_orientation == AltosLib.MISSING)
+               if (cal_data().pad_orientation == AltosLib.MISSING)
                        return;
 
-               if (cal_data.accel_zero_across == AltosLib.MISSING)
+               if (cal_data().accel_zero_across == AltosLib.MISSING)
                        return;
 
-               AltosRotation rotation = new AltosRotation(AltosIMU.convert_accel(accel_ground_across - cal_data.accel_zero_across),
-                                                          AltosIMU.convert_accel(accel_ground_through - cal_data.accel_zero_through),
-                                                          AltosIMU.convert_accel(accel_ground_along - cal_data.accel_zero_along),
-                                                          cal_data.pad_orientation);
+               AltosRotation rotation = new AltosRotation(AltosIMU.convert_accel(accel_ground_across - cal_data().accel_zero_across),
+                                                          AltosIMU.convert_accel(accel_ground_through - cal_data().accel_zero_through),
+                                                          AltosIMU.convert_accel(accel_ground_along - cal_data().accel_zero_along),
+                                                          cal_data().pad_orientation);
                double prev_time = ground_time;
 
                orient_series = add_series(orient_name, AltosConvert.orient);
index a2c5d46..2b6530c 100644 (file)
@@ -128,7 +128,7 @@ public class AltosFlightStats {
 
 
        public AltosFlightStats(AltosFlightSeries series) {
-               AltosCalData    cal_data = series.cal_data;
+               AltosCalData    cal_data = series.cal_data();
 
                series.finish();
 
@@ -204,7 +204,7 @@ public class AltosFlightStats {
                has_rssi = series.rssi_series != null;
                has_flight_data = series.pressure_series != null;
 
-               AltosGPS gps = series.cal_data.gps_pad;
+               AltosGPS gps = series.cal_data().gps_pad;
 
                if (gps != null) {
                        year = gps.year;
index 7898fb9..b6ca357 100644 (file)
@@ -383,7 +383,7 @@ public class AltosGPS implements Cloneable {
                }
        }
 
-       static public void provide_data(AltosDataListener listener, AltosLink link, AltosCalData cal_data) throws InterruptedException {
+       static public void provide_data(AltosDataListener listener, AltosLink link) throws InterruptedException {
                try {
                        AltosGPS gps = new AltosGPS(link, link.config_data());
                        if (gps != null)
index 87d3ec9..dee28a9 100644 (file)
@@ -74,9 +74,10 @@ public class AltosIMU implements Cloneable {
                return n;
        }
 
-       static public void provide_data(AltosDataListener listener, AltosLink link, AltosCalData cal_data) throws InterruptedException {
+       static public void provide_data(AltosDataListener listener, AltosLink link) throws InterruptedException {
                try {
                        AltosIMU        imu = new AltosIMU(link);
+                       AltosCalData    cal_data = listener.cal_data();
 
                        if (imu != null) {
                                listener.set_gyro(cal_data.gyro_roll(imu.gyro_y),
index 7980ae6..058df0a 100644 (file)
@@ -43,47 +43,47 @@ class AltosIdler {
        static final int        idle_sensor_tgps = 16;
        static final int        idle_sensor_tmini3 = 17;
 
-       public void provide_data(AltosDataListener listener, AltosLink link, AltosCalData cal_data) throws InterruptedException, TimeoutException, AltosUnknownProduct {
+       public void provide_data(AltosDataListener listener, AltosLink link) throws InterruptedException, TimeoutException, AltosUnknownProduct {
                for (int idler : idlers) {
                        switch (idler) {
                        case idle_gps:
-                               AltosGPS.provide_data(listener, link, cal_data);
+                               AltosGPS.provide_data(listener, link);
                                break;
                        case idle_imu:
-                               AltosIMU.provide_data(listener, link, cal_data);
+                               AltosIMU.provide_data(listener, link);
                                break;
                        case idle_mag:
-                               AltosMag.provide_data(listener, link, cal_data);
+                               AltosMag.provide_data(listener, link);
                                break;
                        case idle_mma655x:
-                               AltosMma655x.provide_data(listener, link, cal_data);
+                               AltosMma655x.provide_data(listener, link);
                                break;
                        case idle_ms5607:
-                               AltosMs5607.provide_data(listener, link, cal_data);
+                               AltosMs5607.provide_data(listener, link);
                                break;
                        case idle_sensor_tm:
-                               AltosSensorTM.provide_data(listener, link, cal_data);
+                               AltosSensorTM.provide_data(listener, link);
                                break;
                        case idle_sensor_metrum:
-                               AltosSensorMetrum.provide_data(listener, link, cal_data);
+                               AltosSensorMetrum.provide_data(listener, link);
                                break;
                        case idle_sensor_mega:
-                               AltosSensorMega.provide_data(listener, link, cal_data);
+                               AltosSensorMega.provide_data(listener, link);
                                break;
                        case idle_sensor_emini1:
-                               AltosSensorEMini.provide_data(listener, link, cal_data, 1);
+                               AltosSensorEMini.provide_data(listener, link, 1);
                                break;
                        case idle_sensor_emini2:
-                               AltosSensorEMini.provide_data(listener, link, cal_data, 2);
+                               AltosSensorEMini.provide_data(listener, link, 2);
                                break;
                        case idle_sensor_tmini2:
-                               AltosSensorTMini2.provide_data(listener, link, cal_data);
+                               AltosSensorTMini2.provide_data(listener, link);
                                break;
                        case idle_sensor_tgps:
-                               AltosSensorTGPS.provide_data(listener, link, cal_data);
+                               AltosSensorTGPS.provide_data(listener, link);
                                break;
                        case idle_sensor_tmini3:
-                               AltosSensorTMini3.provide_data(listener, link, cal_data);
+                               AltosSensorTMini3.provide_data(listener, link);
                                break;
                        }
                }
@@ -151,7 +151,7 @@ public class AltosIdleFetch implements AltosDataProvider {
 
        AltosLink               link;
 
-       public void provide_data(AltosDataListener listener, AltosCalData cal_data) throws InterruptedException, AltosUnknownProduct {
+       public void provide_data(AltosDataListener listener) throws InterruptedException, AltosUnknownProduct {
                try {
                        boolean matched = false;
                        /* Fetch config data from remote */
@@ -159,7 +159,7 @@ public class AltosIdleFetch implements AltosDataProvider {
                        listener.set_state(AltosLib.ao_flight_stateless);
                        for (AltosIdler idler : idlers) {
                                if (idler.matches(config_data)) {
-                                       idler.provide_data(listener, link, cal_data);
+                                       idler.provide_data(listener, link);
                                        matched = true;
                                        break;
                                }
index cc6b854..fc5d4cc 100644 (file)
@@ -55,11 +55,10 @@ public class AltosIdleMonitor extends Thread {
        boolean provide_data(AltosDataListener listener) throws InterruptedException, TimeoutException, AltosUnknownProduct {
                boolean         worked = false;
                boolean         aborted = false;
-               AltosCalData    cal_data = new AltosCalData(link.config_data());
 
                try {
                        start_link();
-                       fetch.provide_data(listener, cal_data);
+                       fetch.provide_data(listener);
                        if (!link.has_error && !link.reply_abort)
                                worked = true;
                } finally {
index 5f9ceca..d15e217 100644 (file)
@@ -72,7 +72,7 @@ public class AltosIdleReader extends AltosFlightReader {
                                start_link();
                                if (state == null)
                                        state = new AltosState(cal_data());
-                               fetch.provide_data(state, state.cal_data);
+                               fetch.provide_data(state);
                                if (!link.has_error && !link.reply_abort)
                                        worked = true;
                        } catch (TimeoutException te) {
index ccdd081..1c025ef 100644 (file)
@@ -189,9 +189,9 @@ public class AltosKML implements AltosWriter {
 
        public void write(AltosFlightSeries series) {
                stats = new AltosFlightStats(series);
-               start(series.cal_data);
+               start(series.cal_data());
                for (AltosGPSTimeValue gtv : series.gps_series)
-                       write(gtv, series.cal_data, state(series, gtv.time), height(series, gtv.time));
+                       write(gtv, series.cal_data(), state(series, gtv.time), height(series, gtv.time));
        }
 
        public AltosKML(File in_name) throws FileNotFoundException {
index ab0d398..44bea64 100644 (file)
@@ -92,7 +92,7 @@ public class AltosLog implements Runnable {
                                        AltosTelemetry  telem = AltosTelemetry.parse(line.line);
                                        if (state == null)
                                                state = new AltosState(cal_data);
-                                       telem.provide_data(state, cal_data);
+                                       telem.provide_data(state);
 
                                        if (cal_data.serial != serial ||
                                            cal_data.flight != flight ||
index 3cf8313..0d8ec69 100644 (file)
@@ -62,9 +62,10 @@ public class AltosMag implements Cloneable {
                y = AltosLib.MISSING;
        }
 
-       static public void provide_data(AltosDataListener listener, AltosLink link, AltosCalData cal_data) throws InterruptedException {
+       static public void provide_data(AltosDataListener listener, AltosLink link) throws InterruptedException {
                try {
                        AltosMag        mag = new AltosMag(link);
+                       AltosCalData    cal_data = listener.cal_data();
 
                        if (mag != null)
                                listener.set_mag(cal_data.mag_along(mag.y),
index f69b571..0f6022a 100644 (file)
@@ -46,9 +46,10 @@ public class AltosMma655x implements Cloneable {
                return n;
        }
 
-       static public void provide_data(AltosDataListener listener, AltosLink link, AltosCalData cal_data) throws InterruptedException, AltosUnknownProduct {
+       static public void provide_data(AltosDataListener listener, AltosLink link) throws InterruptedException, AltosUnknownProduct {
                try {
                        AltosMma655x    mma655x = new AltosMma655x(link);
+                       AltosCalData    cal_data = listener.cal_data();
 
                        if (mma655x != null) {
                                int accel = mma655x.accel;
index 6888bda..5b3ba65 100644 (file)
@@ -133,8 +133,9 @@ public class AltosMs5607 {
                crc = old.crc;
        }
 
-       static public void provide_data(AltosDataListener listener, AltosLink link, AltosCalData cal_data) throws InterruptedException {
+       static public void provide_data(AltosDataListener listener, AltosLink link) throws InterruptedException {
                try {
+                       AltosCalData    cal_data = listener.cal_data();
                        AltosMs5607     ms5607 = cal_data.ms5607;
 
                        if (ms5607 != null) {
index 3847cab..24b425b 100644 (file)
@@ -108,7 +108,7 @@ public class AltosReplayReader extends AltosFlightReader {
        int             reads;
 
        public AltosCalData cal_data() {
-               return replay.state.cal_data;
+               return replay.state.cal_data();
        }
 
        public AltosState read() {
index a144ec7..1bdbb60 100644 (file)
@@ -26,9 +26,10 @@ public class AltosSensorEMini {
        public int      main;
        public int      batt;
 
-       static public void provide_data(AltosDataListener listener, AltosLink link, AltosCalData cal_data, int version) throws InterruptedException {
+       static public void provide_data(AltosDataListener listener, AltosLink link, int version) throws InterruptedException {
                try {
                        AltosSensorEMini        sensor_emini = new AltosSensorEMini(link);
+                       AltosCalData            cal_data = listener.cal_data();
 
                        if (sensor_emini == null)
                                return;
index c47ee4b..e58b03a 100644 (file)
@@ -89,7 +89,7 @@ class AltosSensorMega {
                }
        }
 
-       static public void provide_data(AltosDataListener listener, AltosLink link, AltosCalData cal_data) throws InterruptedException {
+       static public void provide_data(AltosDataListener listener, AltosLink link) throws InterruptedException {
                try {
                        AltosSensorMega sensor_mega = new AltosSensorMega(link);
 
index 6d64b6b..e01d57c 100644 (file)
@@ -53,7 +53,7 @@ class AltosSensorMetrum {
                }
        }
 
-       static public void provide_data(AltosDataListener listener, AltosLink link, AltosCalData cal_data) throws InterruptedException {
+       static public void provide_data(AltosDataListener listener, AltosLink link) throws InterruptedException {
                try {
                        AltosSensorMetrum       sensor_metrum = new AltosSensorMetrum(link);
                        listener.set_battery_voltage(AltosConvert.mega_battery_voltage(sensor_metrum.v_batt));
index 5f39e59..1451441 100644 (file)
@@ -24,7 +24,7 @@ public class AltosSensorTGPS {
        public int      tick;
        public int      batt;
 
-       static public void provide_data(AltosDataListener listener, AltosLink link, AltosCalData cal_data) throws InterruptedException {
+       static public void provide_data(AltosDataListener listener, AltosLink link) throws InterruptedException {
                try {
                        AltosSensorTGPS sensor_tgps = new AltosSensorTGPS(link);
 
index 76bf8a7..bdedaa9 100644 (file)
@@ -29,9 +29,10 @@ public class AltosSensorTM {
        public int      drogue;
        public int      main;
 
-       static public void provide_data(AltosDataListener listener, AltosLink link, AltosCalData cal_data) throws InterruptedException {
+       static public void provide_data(AltosDataListener listener, AltosLink link) throws InterruptedException {
                try {
                        AltosSensorTM   sensor_tm = new AltosSensorTM(link);
+                       AltosCalData    cal_data = listener.cal_data();
 
                        if (sensor_tm == null)
                                return;
index 8d95c7f..9b5a185 100644 (file)
@@ -26,7 +26,7 @@ public class AltosSensorTMini2 {
        public int      main;
        public int      batt;
 
-       static public void provide_data(AltosDataListener listener, AltosLink link, AltosCalData cal_data) throws InterruptedException {
+       static public void provide_data(AltosDataListener listener, AltosLink link) throws InterruptedException {
                try {
                        AltosSensorTMini2       sensor_tmini = new AltosSensorTMini2(link);
 
index bb7fcd7..b92def0 100644 (file)
@@ -26,7 +26,7 @@ public class AltosSensorTMini3 {
        public int      main;
        public int      batt;
 
-       static public void provide_data(AltosDataListener listener, AltosLink link, AltosCalData cal_data) throws InterruptedException {
+       static public void provide_data(AltosDataListener listener, AltosLink link) throws InterruptedException {
                try {
                        AltosSensorTMini3       sensor_tmini = new AltosSensorTMini3(link);
 
index 6f29365..cfee819 100644 (file)
@@ -909,11 +909,11 @@ public class AltosState extends AltosDataListener {
        public double   accel_ground_along, accel_ground_across, accel_ground_through;
 
        void update_pad_rotation() {
-               if (cal_data.pad_orientation != AltosLib.MISSING && accel_ground_along != AltosLib.MISSING) {
-                       rotation = new AltosRotation(AltosIMU.convert_accel(accel_ground_across - cal_data.accel_zero_across),
-                                                    AltosIMU.convert_accel(accel_ground_through - cal_data.accel_zero_through),
-                                                    AltosIMU.convert_accel(accel_ground_along - cal_data.accel_zero_along),
-                                                    cal_data.pad_orientation);
+               if (cal_data().pad_orientation != AltosLib.MISSING && accel_ground_along != AltosLib.MISSING) {
+                       rotation = new AltosRotation(AltosIMU.convert_accel(accel_ground_across - cal_data().accel_zero_across),
+                                                    AltosIMU.convert_accel(accel_ground_through - cal_data().accel_zero_through),
+                                                    AltosIMU.convert_accel(accel_ground_along - cal_data().accel_zero_along),
+                                                    cal_data().pad_orientation);
                        orient.set_computed(rotation.tilt(), time);
                }
        }
@@ -1066,8 +1066,6 @@ public class AltosState extends AltosDataListener {
 
        public AltosState (AltosCalData cal_data) {
                super(cal_data);
-               if (cal_data == null)
-                       Thread.dumpStack();
                init();
        }
 }
index e93e660..7d57694 100644 (file)
@@ -46,12 +46,11 @@ public abstract class AltosTelemetry implements AltosDataProvider {
                return sum == bytes[bytes.length - 1];
        }
 
-       public void provide_data(AltosDataListener listener, AltosCalData cal_data) {
-               cal_data.set_serial(serial());
+       public void provide_data(AltosDataListener listener) {
+               listener.set_serial(serial());
                if (listener.state == AltosLib.ao_flight_invalid)
                        listener.set_state(AltosLib.ao_flight_startup);
-               cal_data.set_tick(tick());
-               listener.set_time(cal_data.time());
+               listener.set_tick(tick());
                listener.set_rssi(rssi(), status());
                listener.set_received_time(received_time);
        }
index 6f91d7c..c6dfe3e 100644 (file)
@@ -49,8 +49,8 @@ public class AltosTelemetryCompanion extends AltosTelemetryStandard {
                super(bytes);
        }
 
-       public void provide_data(AltosDataListener listener, AltosCalData cal_data) {
-               super.provide_data(listener, cal_data);
+       public void provide_data(AltosDataListener listener) {
+               super.provide_data(listener);
                listener.set_companion(companion());
        }
 }
index b5f0eb4..ea30744 100644 (file)
@@ -35,8 +35,11 @@ public class AltosTelemetryConfiguration extends AltosTelemetryStandard {
                super(bytes);
        }
 
-       public void provide_data(AltosDataListener listener, AltosCalData cal_data) {
-               super.provide_data(listener, cal_data);
+       public void provide_data(AltosDataListener listener) {
+               super.provide_data(listener);
+
+               AltosCalData cal_data = listener.cal_data();
+
                cal_data.set_device_type(device_type());
                cal_data.set_flight(flight());
                cal_data.set_config(config_major(), config_minor(), flight_log_max());
index 037a6c8..135b028 100644 (file)
@@ -52,6 +52,8 @@ class AltosTelemetryNullListener extends AltosDataListener {
 
        public boolean cal_data_complete() {
                /* All telemetry packets */
+               AltosCalData cal_data = cal_data();
+
                if (cal_data.serial == AltosLib.MISSING)
                        return false;
 
@@ -107,7 +109,7 @@ 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;
                        }
@@ -125,7 +127,7 @@ public class AltosTelemetryFile implements AltosRecordSet {
 
                        /* Try to pick up at least one pre-boost value */
                        if (cal_data.time() >= -2)
-                               telem.provide_data(listener, cal_data);
+                               telem.provide_data(listener);
                        if (listener.state == AltosLib.ao_flight_landed)
                                break;
                }
index 7f3f2ec..027f601 100644 (file)
@@ -548,16 +548,17 @@ public class AltosTelemetryLegacy extends AltosTelemetry {
                }
        }
 
-       public void provide_data(AltosDataListener listener, AltosCalData cal_data) {
-               cal_data.set_tick(tick);
-               listener.set_time(cal_data.time());
+       public void provide_data(AltosDataListener listener) {
+               listener.set_serial(serial);
+               listener.set_tick(tick);
                listener.set_state(this.state);
-               cal_data.set_state(this.state);
-               cal_data.set_flight(flight);
-               cal_data.set_serial(serial);
+               listener.set_flight(flight);
                listener.set_rssi(rssi, status);
 
                listener.set_pressure(AltosConvert.barometer_to_pressure(pres));
+
+               AltosCalData cal_data = listener.cal_data();
+
                cal_data.set_accel_plus_minus(accel_plus_g, accel_minus_g);
                listener.set_acceleration(cal_data.acceleration(accel));
                if (kalman_height != AltosLib.MISSING)
index 6819fec..f4366e3 100644 (file)
@@ -49,8 +49,10 @@ public class AltosTelemetryLocation extends AltosTelemetryStandard {
                super(bytes);
        }
 
-       public void provide_data(AltosDataListener listener, AltosCalData cal_data) {
-               super.provide_data(listener, cal_data);
+       public void provide_data(AltosDataListener listener) {
+               super.provide_data(listener);
+
+               AltosCalData    cal_data = listener.cal_data();
 
                AltosGPS        gps = cal_data.make_temp_gps(tick(), false);
 
index 29baee8..7ef9c63 100644 (file)
@@ -39,11 +39,10 @@ public class AltosTelemetryMegaData extends AltosTelemetryStandard {
                super(bytes);
        }
 
-       public void provide_data(AltosDataListener listener, AltosCalData cal_data) {
-               super.provide_data(listener, cal_data);
+       public void provide_data(AltosDataListener listener) {
+               super.provide_data(listener);
 
                listener.set_state(state());
-               cal_data.set_state(state());
 
                listener.set_battery_voltage(AltosConvert.mega_battery_voltage(v_batt()));
                listener.set_pyro_voltage(AltosConvert.mega_pyro_voltage(v_pyro()));
@@ -57,6 +56,8 @@ public class AltosTelemetryMegaData extends AltosTelemetryStandard {
 
                listener.set_igniter_voltage(voltages);
 
+               AltosCalData cal_data = listener.cal_data();
+
                cal_data.set_ground_accel(ground_accel());
                cal_data.set_ground_pressure(ground_pres());
                cal_data.set_accel_plus_minus(accel_plus_g(), accel_minus_g());
index efcc3cc..4c64b55 100644 (file)
@@ -41,8 +41,10 @@ public class AltosTelemetryMegaSensor extends AltosTelemetryStandard {
                super(bytes);
        }
 
-       public void provide_data(AltosDataListener listener, AltosCalData cal_data) {
-               super.provide_data(listener, cal_data);
+       public void provide_data(AltosDataListener listener) {
+               super.provide_data(listener);
+
+               AltosCalData cal_data = listener.cal_data();
 
                listener.set_acceleration(cal_data.acceleration(accel()));
                listener.set_pressure(pres());
index 211f9c6..79d3a49 100644 (file)
@@ -38,13 +38,12 @@ public class AltosTelemetryMetrumSensor extends AltosTelemetryStandard {
                super(bytes);
        }
 
-       public void provide_data(AltosDataListener listener, AltosCalData cal_data) {
-               super.provide_data(listener, cal_data);
+       public void provide_data(AltosDataListener listener) {
+               super.provide_data(listener);
 
                listener.set_state(state());
-               cal_data.set_state(state());
 
-               listener.set_acceleration(cal_data.acceleration(accel()));
+               listener.set_acceleration(listener.cal_data().acceleration(accel()));
                listener.set_pressure(pres());
                listener.set_temperature(temp()/100.0);
 
index 59a4d50..3ea287a 100644 (file)
@@ -40,16 +40,17 @@ public class AltosTelemetryMini2 extends AltosTelemetryStandard {
                super(bytes);
        }
 
-       public void provide_data(AltosDataListener listener, AltosCalData cal_data) {
-               super.provide_data(listener, cal_data);
+       public void provide_data(AltosDataListener listener) {
+               super.provide_data(listener);
 
                listener.set_state(state());
-               cal_data.set_state(state());
 
                listener.set_battery_voltage(AltosConvert.tele_mini_2_voltage(v_batt()));
                listener.set_apogee_voltage(AltosConvert.tele_mini_2_voltage(sense_a()));
                listener.set_main_voltage(AltosConvert.tele_mini_2_voltage(sense_m()));
 
+               AltosCalData    cal_data = listener.cal_data();
+
                cal_data.set_ground_pressure(ground_pres());
 
                listener.set_pressure(pres());
index 13c2ea4..c66f8e6 100644 (file)
@@ -40,19 +40,18 @@ public class AltosTelemetryMini3 extends AltosTelemetryStandard {
                super(bytes);
        }
 
-       public void provide_data(AltosDataListener listener, AltosCalData cal_data) {
-               super.provide_data(listener, cal_data);
-
-               cal_data.set_ground_pressure(ground_pres());
+       public void provide_data(AltosDataListener listener) {
+               super.provide_data(listener);
 
                listener.set_state(state());
-               cal_data.set_state(state());
 
                listener.set_battery_voltage(AltosConvert.tele_mini_3_battery_voltage(v_batt()));
 
                listener.set_apogee_voltage(AltosConvert.tele_mini_3_pyro_voltage(sense_a()));
                listener.set_main_voltage(AltosConvert.tele_mini_3_pyro_voltage(sense_m()));
 
+               listener.cal_data().set_ground_pressure(ground_pres());
+
                listener.set_pressure(pres());
                listener.set_temperature(temp()/100.0);
 
index f2d73ae..f2108d6 100644 (file)
@@ -23,7 +23,7 @@ public class AltosTelemetryRaw extends AltosTelemetryStandard {
                super(bytes);
        }
 
-       public void provide_data(AltosDataListener listener, AltosCalData cal_data) {
-               super.provide_data(listener, cal_data);
+       public void provide_data(AltosDataListener listener) {
+               super.provide_data(listener);
        }
 }
index 7b51853..26fe4f2 100644 (file)
@@ -45,7 +45,7 @@ public class AltosTelemetryReader extends AltosFlightReader {
                        System.out.printf("Make state\n");
                        state = new AltosState(cal_data());
                }
-               telem.provide_data(state, state.cal_data);
+               telem.provide_data(state);
                return state;
        }
 
index 012d0c4..60bc4a5 100644 (file)
@@ -44,8 +44,10 @@ public class AltosTelemetrySatellite extends AltosTelemetryStandard {
                super(bytes);
        }
 
-       public void provide_data(AltosDataListener listener, AltosCalData cal_data) {
-               super.provide_data(listener, cal_data);
+       public void provide_data(AltosDataListener listener) {
+               super.provide_data(listener);
+
+               AltosCalData    cal_data = listener.cal_data();
 
                AltosGPS        gps = cal_data.make_temp_gps(tick(), true);
 
index 6bbe4ec..dc8efa9 100644 (file)
@@ -41,11 +41,12 @@ public class AltosTelemetrySensor extends AltosTelemetryStandard {
                super(bytes);
        }
 
-       public void provide_data(AltosDataListener listener, AltosCalData cal_data) {
-               super.provide_data(listener, cal_data);
+       public void provide_data(AltosDataListener listener) {
+               super.provide_data(listener);
 
                listener.set_state(state());
-               cal_data.set_state(state());
+
+               AltosCalData    cal_data = listener.cal_data();
 
                if (type() == packet_type_TM_sensor) {
                        cal_data.set_ground_accel(ground_accel());
index 5638156..2a1c936 100644 (file)
@@ -104,7 +104,7 @@ public abstract class AltosTelemetryStandard extends AltosTelemetry {
                super(bytes);
        }
 
-       public void provide_data(AltosDataListener listener, AltosCalData cal_data) {
-               super.provide_data(listener, cal_data);
+       public void provide_data(AltosDataListener listener) {
+               super.provide_data(listener);
        }
 }
index b46cbc8..a5e5a4e 100644 (file)
@@ -93,14 +93,14 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
                }
 
                void show(AltosState state, AltosListenerState listener_state) {
-                       if (!same_call(state.cal_data.callsign)) {
+                       if (!same_call(state.cal_data().callsign)) {
                                show();
-                               value.setText(state.cal_data.callsign);
-                               if (state.cal_data.callsign == null)
+                               value.setText(state.cal_data().callsign);
+                               if (state.cal_data().callsign == null)
                                        setVisible(false);
                                else
                                        setVisible(true);
-                               last_call = state.cal_data.callsign;
+                               last_call = state.cal_data().callsign;
                        }
                }
 
@@ -120,7 +120,7 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
 
                int     last_serial = -1;
                void show(AltosState state, AltosListenerState listener_state) {
-                       AltosCalData    cal_data = state.cal_data;
+                       AltosCalData    cal_data = state.cal_data();
                        if (cal_data.serial != last_serial) {
                                show();
                                if (cal_data.serial == AltosLib.MISSING)
@@ -148,7 +148,7 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay
                int     last_flight = -1;
 
                void show(AltosState state, AltosListenerState listener_state) {
-                       AltosCalData cal_data = state.cal_data;
+                       AltosCalData cal_data = state.cal_data();
                        if (cal_data.flight != last_flight) {
                                show();
                                if (cal_data.flight == AltosLib.MISSING)
index 331b58e..0aeef8e 100644 (file)
@@ -46,10 +46,11 @@ public class AltosPad extends AltosUIFlightTab {
 
        class LoggingReady extends AltosUIIndicator {
                public void show (AltosState state, AltosListenerState listener_state) {
-                       if (state == null || state.cal_data.flight == AltosLib.MISSING) {
+                       AltosCalData    cal_data = state.cal_data();
+                       if (state == null || cal_data.flight == AltosLib.MISSING) {
                                hide();
                        } else {
-                               if (state.cal_data.flight != 0) {
+                               if (cal_data.flight != 0) {
                                        if (state.state() <= Altos.ao_flight_pad)
                                                show("Ready to record");
                                        else if (state.state() < Altos.ao_flight_landed ||
@@ -59,7 +60,7 @@ public class AltosPad extends AltosUIFlightTab {
                                                show("Recorded data");
                                } else
                                        show("Storage full");
-                               set_lights(state.cal_data.flight != 0);
+                               set_lights(cal_data.flight != 0);
                        }
                }
                public LoggingReady (AltosUIFlightTab container, int y) {
index 3ec25cf..2659173 100644 (file)
@@ -342,7 +342,7 @@ public class AltosUI extends AltosUIFrame {
                if (set == null)
                        return;
                AltosFlightSeries series = make_series(set);
-               new AltosCSVUI(AltosUI.this, series, series.cal_data, chooser.file());
+               new AltosCSVUI(AltosUI.this, series, chooser.file());
        }
 
        /* Load a flight log CSV file and display a pretty graph.
index 821b842..442e3de 100644 (file)
@@ -56,9 +56,9 @@ public class AltosCSVUI
                        set_default_file();
        }
 
-       public AltosCSVUI(JFrame frame, AltosFlightSeries series, AltosCalData cal_data, File source_file) {
+       public AltosCSVUI(JFrame frame, AltosFlightSeries series, File source_file) {
                this.series = series;
-               this.cal_data = cal_data;
+               this.cal_data = series.cal_data();
                csv_chooser = new JFileChooser(source_file);
 
                accessory = new JPanel();
index 8125e5e..31042ab 100644 (file)
@@ -84,7 +84,7 @@ public class AltosGraph extends AltosUIGraph {
        AltosUIFlightSeries flight_series;
 
        AltosUITimeSeries[] setup(AltosFlightStats stats, AltosUIFlightSeries flight_series) {
-               AltosCalData    cal_data = flight_series.cal_data;
+               AltosCalData    cal_data = flight_series.cal_data();
 
                AltosUIAxis     height_axis, speed_axis, accel_axis, voltage_axis, temperature_axis, nsat_axis, dbm_axis;
                AltosUIAxis     distance_axis, pressure_axis, thrust_axis;
index 41614cf..9e528b1 100644 (file)
@@ -128,7 +128,7 @@ public class AltosInfoTable extends JTable implements AltosFlightDisplay, Hierar
 
        public void show(AltosState state, AltosListenerState listener_state) {
 
-               AltosCalData    cal_data = state.cal_data;
+               AltosCalData    cal_data = state.cal_data();
 
                if (!isShowing()) {
                        last_state = state;
index 1280ba6..c63f027 100644 (file)
@@ -213,7 +213,7 @@ public class AltosScanUI
                                                if (state == null)
                                                        continue;
                                                packet_count++;
-                                               AltosCalData    cal_data = state.cal_data;
+                                               AltosCalData    cal_data = state.cal_data();
                                                if (cal_data.flight != AltosLib.MISSING) {
                                                        final AltosScanResult   result = new AltosScanResult(cal_data.callsign,
                                                                                                             cal_data.serial,
index c6cd2bd..3646f00 100644 (file)
@@ -301,7 +301,7 @@ public class TeleGPS
                if (set == null)
                        return;
                AltosFlightSeries series = make_series(set);
-               new AltosCSVUI(this, series, series.cal_data, chooser.file());
+               new AltosCSVUI(this, series, chooser.file());
        }
 
        void graph() {
index 19fd369..2117339 100644 (file)
@@ -124,10 +124,11 @@ public class TeleGPSState extends AltosUIFlightTab {
 
        class FirmwareVersion extends AltosUIIndicator {
                public void show(AltosState state, AltosListenerState listener_state) {
-                       if (state.cal_data.firmware_version == null)
+                       AltosCalData cal_data = state.cal_data();
+                       if (cal_data.firmware_version == null)
                                show("Missing");
                        else
-                               show(state.cal_data.firmware_version);
+                               show(cal_data.firmware_version);
                }
 
                public FirmwareVersion(Container container, int y) {
@@ -137,7 +138,8 @@ public class TeleGPSState extends AltosUIFlightTab {
 
        class FlightLogMax extends AltosUIIndicator {
                public void show(AltosState state, AltosListenerState listener_state) {
-                       int storage = state.cal_data.flight_log_max;
+                       AltosCalData cal_data = state.cal_data();
+                       int storage = cal_data.flight_log_max;
                        if (storage == AltosLib.MISSING)
                                show("Missing");
                        else
index 15292fe..e1be69a 100644 (file)
@@ -75,13 +75,14 @@ public class TeleGPSStatus extends JComponent implements AltosFlightDisplay {
                String  call;
 
                void show(AltosState state, AltosListenerState listener_state) {
-                       if (state.cal_data == null)
+                       AltosCalData cal_data = state.cal_data();
+                       if (cal_data == null)
                                System.out.printf("null cal data?\n");
-                       if (state.cal_data.callsign != call) {
-                               value.setText(state.cal_data.callsign);
-                               call = state.cal_data.callsign;
+                       if (cal_data.callsign != call) {
+                               value.setText(cal_data.callsign);
+                               call = cal_data.callsign;
                        }
-                       if (state.cal_data.callsign == null)
+                       if (cal_data.callsign == null)
                                setVisible(false);
                        else
                                setVisible(true);
@@ -102,12 +103,13 @@ public class TeleGPSStatus extends JComponent implements AltosFlightDisplay {
        class Serial extends Value {
                int     serial = -1;
                void show(AltosState state, AltosListenerState listener_state) {
-                       if (state.cal_data.serial != serial) {
-                               if (state.cal_data.serial == AltosLib.MISSING)
+                       AltosCalData cal_data = state.cal_data();
+                       if (cal_data.serial != serial) {
+                               if (cal_data.serial == AltosLib.MISSING)
                                        value.setText("none");
                                else
-                                       value.setText(String.format("%d", state.cal_data.serial));
-                               serial = state.cal_data.serial;
+                                       value.setText(String.format("%d", cal_data.serial));
+                               serial = cal_data.serial;
                        }
                }
 
@@ -128,12 +130,13 @@ public class TeleGPSStatus extends JComponent implements AltosFlightDisplay {
                int     last_flight = -1;
 
                void show(AltosState state, AltosListenerState listener_state) {
-                       if (state.cal_data.flight != last_flight) {
-                               if (state.cal_data.flight == AltosLib.MISSING)
+                       AltosCalData cal_data = state.cal_data();
+                       if (cal_data.flight != last_flight) {
+                               if (cal_data.flight == AltosLib.MISSING)
                                        value.setText("none");
                                else
-                                       value.setText(String.format("%d", state.cal_data.flight));
-                               last_flight = state.cal_data.flight;
+                                       value.setText(String.format("%d", cal_data.flight));
+                               last_flight = cal_data.flight;
                        }
                }