altoslib: Hook up idle monitoring data again
authorKeith Packard <keithp@keithp.com>
Mon, 12 Jun 2017 05:49:46 +0000 (22:49 -0700)
committerKeith Packard <keithp@keithp.com>
Mon, 12 Jun 2017 05:54:22 +0000 (22:54 -0700)
The API for idle monitoring changed, but these modules hadn't been
fixed.

Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/AltosIdleFetch.java
altoslib/AltosMs5607.java
altoslib/AltosSensorEMini.java
altoslib/AltosSensorMega.java
altoslib/AltosSensorMetrum.java
altoslib/AltosSensorTGPS.java
altoslib/AltosSensorTMini2.java
altoslib/AltosSensorTMini3.java

index 43eb980..cfd6866 100644 (file)
@@ -31,15 +31,17 @@ class AltosIdler {
        static final int        idle_imu = 1;
        static final int        idle_mag = 2;
        static final int        idle_mma655x = 4;
+       static final int        idle_ms5607 = 5;
 
 
        static final int        idle_sensor_tm = 10;
        static final int        idle_sensor_metrum = 11;
        static final int        idle_sensor_mega = 12;
-       static final int        idle_sensor_emini = 13;
-       static final int        idle_sensor_tmini2 = 14;
-       static final int        idle_sensor_tgps = 15;
-       static final int        idle_sensor_tmini3 = 16;
+       static final int        idle_sensor_emini1 = 13;
+       static final int        idle_sensor_emini2 = 14;
+       static final int        idle_sensor_tmini2 = 15;
+       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 {
                for (int idler : idlers) {
@@ -56,7 +58,10 @@ class AltosIdler {
                        case idle_mma655x:
                                AltosMma655x.provide_data(listener, link, cal_data);
                                break;
-/*                     case idle_sensor_tm:
+                       case idle_ms5607:
+                               AltosMs5607.provide_data(listener, link, cal_data);
+                               break;
+                       case idle_sensor_tm:
                                AltosSensorTM.provide_data(listener, link, cal_data);
                                break;
                        case idle_sensor_metrum:
@@ -65,8 +70,11 @@ class AltosIdler {
                        case idle_sensor_mega:
                                AltosSensorMega.provide_data(listener, link, cal_data);
                                break;
-                       case idle_sensor_emini:
-                               AltosSensorEMini.provide_data(listener, link, cal_data);
+                       case idle_sensor_emini1:
+                               AltosSensorEMini.provide_data(listener, link, cal_data, 1);
+                               break;
+                       case idle_sensor_emini2:
+                               AltosSensorEMini.provide_data(listener, link, cal_data, 2);
                                break;
                        case idle_sensor_tmini2:
                                AltosSensorTMini2.provide_data(listener, link, cal_data);
@@ -77,7 +85,6 @@ class AltosIdler {
                        case idle_sensor_tmini3:
                                AltosSensorTMini3.provide_data(listener, link, cal_data);
                                break;
-*/
                        }
                }
        }
@@ -97,16 +104,23 @@ public class AltosIdleFetch implements AltosDataProvider {
 
        static final AltosIdler[] idlers = {
 
-               new AltosIdler("EasyMini",
-                              AltosIdler.idle_sensor_emini),
+               new AltosIdler("EasyMini-v1",
+                              AltosIdler.idle_ms5607,
+                              AltosIdler.idle_sensor_emini1),
+
+               new AltosIdler("EasyMini-v2",
+                              AltosIdler.idle_ms5607,
+                              AltosIdler.idle_sensor_emini2),
 
                new AltosIdler("TeleMini-v1",
                               AltosIdler.idle_sensor_tm),
 
                new AltosIdler("TeleMini-v2",
+                              AltosIdler.idle_ms5607,
                               AltosIdler.idle_sensor_tmini2),
 
                new AltosIdler("TeleMini-v3",
+                              AltosIdler.idle_ms5607,
                               AltosIdler.idle_sensor_tmini3),
 
                new AltosIdler("TeleMetrum-v1",
@@ -116,15 +130,18 @@ public class AltosIdleFetch implements AltosDataProvider {
                new AltosIdler("TeleMetrum-v2",
                               AltosIdler.idle_gps,
                               AltosIdler.idle_mma655x,
+                              AltosIdler.idle_ms5607,
                               AltosIdler.idle_sensor_metrum),
 
                new AltosIdler("TeleMega",
                               AltosIdler.idle_gps,
                               AltosIdler.idle_mma655x,
+                              AltosIdler.idle_ms5607,
                               AltosIdler.idle_imu, AltosIdler.idle_mag,
                               AltosIdler.idle_sensor_mega),
                new AltosIdler("EasyMega",
                               AltosIdler.idle_mma655x,
+                              AltosIdler.idle_ms5607,
                               AltosIdler.idle_imu, AltosIdler.idle_mag,
                               AltosIdler.idle_sensor_mega),
                new AltosIdler("TeleGPS",
index bb6ce4c..399de83 100644 (file)
@@ -133,6 +133,19 @@ public class AltosMs5607 {
                crc = old.crc;
        }
 
+       static public void provide_data(AltosDataListener listener, AltosLink link, AltosCalData cal_data) throws InterruptedException {
+               try {
+                       AltosMs5607     ms5607 = cal_data.ms5607;
+
+                       if (ms5607 != null) {
+                               AltosPresTemp   pt = ms5607.pres_temp(link);
+                               listener.set_temperature(pt.temp);
+                               listener.set_pressure(pt.pres);
+                       }
+               } catch (TimeoutException te) {
+               }
+       }
+
        public AltosMs5607(AltosConfigData config_data) {
                this(config_data.ms5607());
        }
index 2581685..2d7bab8 100644 (file)
@@ -26,15 +26,24 @@ public class AltosSensorEMini {
        public int      main;
        public int      batt;
 
-       static public void update_state(AltosState state, AltosLink link, AltosConfigData config_data) throws InterruptedException {
+       static public void provide_data(AltosDataListener listener, AltosLink link, AltosCalData cal_data, int version) throws InterruptedException {
                try {
                        AltosSensorEMini        sensor_emini = new AltosSensorEMini(link);
 
                        if (sensor_emini == null)
                                return;
-                       state.set_battery_voltage(AltosConvert.easy_mini_voltage(sensor_emini.batt, config_data.serial));
-                       state.set_apogee_voltage(AltosConvert.easy_mini_voltage(sensor_emini.apogee, config_data.serial));
-                       state.set_main_voltage(AltosConvert.easy_mini_voltage(sensor_emini.main, config_data.serial));
+                       switch (version) {
+                       case 1:
+                               listener.set_battery_voltage(AltosConvert.easy_mini_1_voltage(sensor_emini.batt, cal_data.serial));
+                               listener.set_apogee_voltage(AltosConvert.easy_mini_1_voltage(sensor_emini.apogee, cal_data.serial));
+                               listener.set_main_voltage(AltosConvert.easy_mini_1_voltage(sensor_emini.main, cal_data.serial));
+                               break;
+                       case 2:
+                               listener.set_battery_voltage(AltosConvert.easy_mini_2_voltage(sensor_emini.batt));
+                               listener.set_apogee_voltage(AltosConvert.easy_mini_2_voltage(sensor_emini.apogee));
+                               listener.set_main_voltage(AltosConvert.easy_mini_2_voltage(sensor_emini.main));
+                               break;
+                       }
 
                } catch (TimeoutException te) {
                }
index 8269603..1ef40a2 100644 (file)
@@ -89,18 +89,18 @@ class AltosSensorMega {
                }
        }
 
-       static public void update_state(AltosState state, AltosLink link, AltosConfigData config_data) throws InterruptedException {
+       static public void provide_data(AltosDataListener listener, AltosLink link, AltosCalData cal_data) throws InterruptedException {
                try {
                        AltosSensorMega sensor_mega = new AltosSensorMega(link);
 
-                       state.set_battery_voltage(AltosConvert.mega_battery_voltage(sensor_mega.v_batt));
-                       state.set_apogee_voltage(AltosConvert.mega_pyro_voltage(sensor_mega.sense[4]));
-                       state.set_main_voltage(AltosConvert.mega_pyro_voltage(sensor_mega.sense[5]));
+                       listener.set_battery_voltage(AltosConvert.mega_battery_voltage(sensor_mega.v_batt));
+                       listener.set_apogee_voltage(AltosConvert.mega_pyro_voltage(sensor_mega.sense[4]));
+                       listener.set_main_voltage(AltosConvert.mega_pyro_voltage(sensor_mega.sense[5]));
 
                        double[]        igniter_voltage = new double[4];
                        for (int i = 0; i < 4; i++)
                                igniter_voltage[i] = AltosConvert.mega_pyro_voltage(sensor_mega.sense[i]);
-                       state.set_igniter_voltage(igniter_voltage);
+                       listener.set_igniter_voltage(igniter_voltage);
 
                } catch (TimeoutException te) {
                }
index cb16391..1b025d1 100644 (file)
@@ -53,12 +53,12 @@ class AltosSensorMetrum {
                }
        }
 
-       static public void update_state(AltosState state, AltosLink link, AltosConfigData config_data) throws InterruptedException {
+       static public void provide_data(AltosDataListener listener, AltosLink link, AltosCalData cal_data) throws InterruptedException {
                try {
                        AltosSensorMetrum       sensor_metrum = new AltosSensorMetrum(link);
-                       state.set_battery_voltage(AltosConvert.mega_battery_voltage(sensor_metrum.v_batt));
-                       state.set_apogee_voltage(AltosConvert.mega_pyro_voltage(sensor_metrum.sense_a));
-                       state.set_main_voltage(AltosConvert.mega_pyro_voltage(sensor_metrum.sense_m));
+                       listener.set_battery_voltage(AltosConvert.mega_battery_voltage(sensor_metrum.v_batt));
+                       listener.set_apogee_voltage(AltosConvert.mega_pyro_voltage(sensor_metrum.sense_a));
+                       listener.set_main_voltage(AltosConvert.mega_pyro_voltage(sensor_metrum.sense_m));
                } catch (TimeoutException te) {
                }
        }
index 9c2bcb1..7534cf4 100644 (file)
@@ -24,13 +24,13 @@ public class AltosSensorTGPS {
        public int      tick;
        public int      batt;
 
-       static public void update_state(AltosState state, AltosLink link, AltosConfigData config_data) throws InterruptedException {
+       static public void provide_data(AltosDataListener listener, AltosLink link, AltosCalData cal_data) throws InterruptedException {
                try {
                        AltosSensorTGPS sensor_tgps = new AltosSensorTGPS(link);
 
                        if (sensor_tgps == null)
                                return;
-                       state.set_battery_voltage(AltosConvert.tele_gps_voltage(sensor_tgps.batt));
+                       listener.set_battery_voltage(AltosConvert.tele_gps_voltage(sensor_tgps.batt));
 
                } catch (TimeoutException te) {
                }
index 7e00abd..c347a3a 100644 (file)
@@ -26,15 +26,15 @@ public class AltosSensorTMini2 {
        public int      main;
        public int      batt;
 
-       static public void update_state(AltosState state, AltosLink link, AltosConfigData config_data) throws InterruptedException {
+       static public void provide_data(AltosDataListener listener, AltosLink link, AltosCalData cal_data) throws InterruptedException {
                try {
                        AltosSensorTMini2       sensor_tmini = new AltosSensorTMini2(link);
 
                        if (sensor_tmini == null)
                                return;
-                       state.set_battery_voltage(AltosConvert.tele_mini_2_voltage(sensor_tmini.batt));
-                       state.set_apogee_voltage(AltosConvert.tele_mini_2_voltage(sensor_tmini.apogee));
-                       state.set_main_voltage(AltosConvert.tele_mini_2_voltage(sensor_tmini.main));
+                       listener.set_battery_voltage(AltosConvert.tele_mini_2_voltage(sensor_tmini.batt));
+                       listener.set_apogee_voltage(AltosConvert.tele_mini_2_voltage(sensor_tmini.apogee));
+                       listener.set_main_voltage(AltosConvert.tele_mini_2_voltage(sensor_tmini.main));
 
                } catch (TimeoutException te) {
                }
index 19d514d..e88566c 100644 (file)
@@ -26,15 +26,15 @@ public class AltosSensorTMini3 {
        public int      main;
        public int      batt;
 
-       static public void update_state(AltosState state, AltosLink link, AltosConfigData config_data) throws InterruptedException {
+       static public void provide_data(AltosDataListener listener, AltosLink link, AltosCalData cal_data) throws InterruptedException {
                try {
                        AltosSensorTMini3       sensor_tmini = new AltosSensorTMini3(link);
 
                        if (sensor_tmini == null)
                                return;
-                       state.set_battery_voltage(AltosConvert.tele_mini_3_battery_voltage(sensor_tmini.batt));
-                       state.set_apogee_voltage(AltosConvert.tele_mini_3_pyro_voltage(sensor_tmini.apogee));
-                       state.set_main_voltage(AltosConvert.tele_mini_3_pyro_voltage(sensor_tmini.main));
+                       listener.set_battery_voltage(AltosConvert.tele_mini_3_battery_voltage(sensor_tmini.batt));
+                       listener.set_apogee_voltage(AltosConvert.tele_mini_3_pyro_voltage(sensor_tmini.apogee));
+                       listener.set_main_voltage(AltosConvert.tele_mini_3_pyro_voltage(sensor_tmini.main));
 
                } catch (TimeoutException te) {
                }