Merge remote-tracking branch 'mjb/altoslib_mjb'
authorKeith Packard <keithp@keithp.com>
Sun, 9 Sep 2012 20:03:47 +0000 (13:03 -0700)
committerKeith Packard <keithp@keithp.com>
Sun, 9 Sep 2012 20:03:47 +0000 (13:03 -0700)
38 files changed:
altoslib/AltosConfigData.java
altoslib/AltosEepromChunk.java
altoslib/AltosEepromIterable.java
altoslib/AltosEepromLog.java
altoslib/AltosEepromMega.java
altoslib/AltosEepromMegaIterable.java
altoslib/AltosEepromRecord.java
altoslib/AltosEepromTeleScience.java
altoslib/AltosFile.java
altoslib/AltosFlightReader.java
altoslib/AltosFrequency.java
altoslib/AltosGPS.java
altoslib/AltosGPSQuery.java [new file with mode: 0644]
altoslib/AltosIMUQuery.java [new file with mode: 0644]
altoslib/AltosIdleMonitor.java
altoslib/AltosIdleMonitorListener.java
altoslib/AltosIdleRecordTM.java [deleted file]
altoslib/AltosIgnite.java
altoslib/AltosLib.java
altoslib/AltosLink.java
altoslib/AltosLog.java
altoslib/AltosMs5607.java
altoslib/AltosMs5607Query.java [new file with mode: 0644]
altoslib/AltosOrderedMegaRecord.java [new file with mode: 0644]
altoslib/AltosOrderedRecord.java [new file with mode: 0644]
altoslib/AltosParse.java
altoslib/AltosPreferences.java
altoslib/AltosRecord.java
altoslib/AltosReplayReader.java
altoslib/AltosSensorMM.java [new file with mode: 0644]
altoslib/AltosSensorTM.java [new file with mode: 0644]
altoslib/AltosState.java
altoslib/AltosTelemetry.java
altoslib/AltosTelemetryMap.java
altoslib/AltosTelemetryReader.java
altoslib/AltosTelemetryRecordGeneral.java
altoslib/AltosTelemetryRecordLegacy.java
altoslib/AltosTelemetryRecordRaw.java

index c143036..6f34363 100644 (file)
 
 package org.altusmetrum.AltosLib;
 
-import java.io.*;
 import java.util.*;
 import java.text.*;
-import java.util.prefs.*;
 import java.util.concurrent.*;
-import org.altusmetrum.AltosLib.*;
 
 public class AltosConfigData implements Iterable<String> {
 
index 6d88972..77b22fe 100644 (file)
@@ -17,8 +17,6 @@
 
 package org.altusmetrum.AltosLib;
 
-import java.io.*;
-import java.util.*;
 import java.text.*;
 import java.util.concurrent.*;
 
index f8acdc1..1aa816e 100644 (file)
@@ -20,50 +20,6 @@ package org.altusmetrum.AltosLib;
 import java.io.*;
 import java.util.*;
 import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.LinkedBlockingQueue;
-
-/*
- * AltosRecords with an index field so they can be sorted by tick while preserving
- * the original ordering for elements with matching ticks
- */
-class AltosOrderedRecord extends AltosEepromRecord implements Comparable<AltosOrderedRecord> {
-
-       public int      index;
-
-       public AltosOrderedRecord(String line, int in_index, int prev_tick, boolean prev_tick_valid)
-               throws ParseException {
-               super(line);
-               if (prev_tick_valid) {
-                       tick |= (prev_tick & ~0xffff);
-                       if (tick < prev_tick) {
-                               if (prev_tick - tick > 0x8000)
-                                       tick += 0x10000;
-                       } else {
-                               if (tick - prev_tick > 0x8000)
-                                       tick -= 0x10000;
-                       }
-               }
-               index = in_index;
-       }
-
-       public AltosOrderedRecord(int in_cmd, int in_tick, int in_a, int in_b, int in_index) {
-               super(in_cmd, in_tick, in_a, in_b);
-               index = in_index;
-       }
-
-       public String toString() {
-               return String.format("%d.%d %04x %04x %04x",
-                                    cmd, index, tick, a, b);
-       }
-
-       public int compareTo(AltosOrderedRecord o) {
-               int     tick_diff = tick - o.tick;
-               if (tick_diff != 0)
-                       return tick_diff;
-               return index - o.index;
-       }
-}
 
 public class AltosEepromIterable extends AltosRecordIterable {
 
@@ -238,7 +194,7 @@ public class AltosEepromIterable extends AltosRecordIterable {
                Iterator<AltosOrderedRecord>    iterator = records.iterator();
                AltosOrderedRecord              record = null;
                AltosRecordTM                   state = new AltosRecordTM();
-               boolean                         last_reported = false;
+               //boolean                               last_reported = false;
                EepromState                     eeprom = new EepromState();
 
                state.state = AltosLib.ao_flight_pad;
@@ -403,8 +359,6 @@ public class AltosEepromIterable extends AltosRecordIterable {
                                if (line == null)
                                        break;
                                AltosOrderedRecord record = new AltosOrderedRecord(line, index++, prev_tick, prev_tick_valid);
-                               if (record == null)
-                                       break;
                                if (record.cmd == AltosLib.AO_LOG_INVALID)
                                        continue;
                                prev_tick = record.tick;
index 7fca4bd..211fd70 100644 (file)
 
 package org.altusmetrum.AltosLib;
 
-import java.io.*;
-import java.util.*;
 import java.text.*;
-import java.util.prefs.*;
 import java.util.concurrent.*;
 
 /*
@@ -75,7 +72,7 @@ public class AltosEepromLog {
                        for (block = in_start_block; block < in_end_block; block++) {
                                AltosEepromChunk eechunk = new AltosEepromChunk(link, block, block == in_start_block);
 
-                               for (int i = 0; i < eechunk.chunk_size; i += AltosEepromRecord.record_length) {
+                               for (int i = 0; i < AltosEepromChunk.chunk_size; i += AltosEepromRecord.record_length) {
                                        try {
                                                AltosEepromRecord r = new AltosEepromRecord(eechunk, i);
 
index 2628279..26bacf8 100644 (file)
 
 package org.altusmetrum.AltosLib;
 
-import java.io.*;
-import java.util.*;
 import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.*;
 
 public class AltosEepromMega {
        public int      cmd;
index f62cc45..1ab2fcc 100644 (file)
@@ -20,52 +20,6 @@ package org.altusmetrum.AltosLib;
 import java.io.*;
 import java.util.*;
 import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.LinkedBlockingQueue;
-
-/*
- * AltosRecords with an index field so they can be sorted by tick while preserving
- * the original ordering for elements with matching ticks
- */
-class AltosOrderedMegaRecord extends AltosEepromMega implements Comparable<AltosOrderedMegaRecord> {
-
-       public int      index;
-
-       public AltosOrderedMegaRecord(String line, int in_index, int prev_tick, boolean prev_tick_valid)
-               throws ParseException {
-               super(line);
-               if (prev_tick_valid) {
-                       tick |= (prev_tick & ~0xffff);
-                       if (tick < prev_tick) {
-                               if (prev_tick - tick > 0x8000)
-                                       tick += 0x10000;
-                       } else {
-                               if (tick - prev_tick > 0x8000)
-                                       tick -= 0x10000;
-                       }
-               }
-               index = in_index;
-       }
-
-       public AltosOrderedMegaRecord(int in_cmd, int in_tick, int in_a, int in_b, int in_index) {
-               super(in_cmd, in_tick);
-               a = in_a;
-               b = in_b;
-               index = in_index;
-       }
-
-       public String toString() {
-               return String.format("%d.%d %04x %04x %04x",
-                                    cmd, index, tick, a, b);
-       }
-
-       public int compareTo(AltosOrderedMegaRecord o) {
-               int     tick_diff = tick - o.tick;
-               if (tick_diff != 0)
-                       return tick_diff;
-               return index - o.index;
-       }
-}
 
 public class AltosEepromMegaIterable extends AltosRecordIterable {
 
@@ -285,7 +239,7 @@ public class AltosEepromMegaIterable extends AltosRecordIterable {
                Iterator<AltosOrderedMegaRecord>        iterator = records.iterator();
                AltosOrderedMegaRecord          record = null;
                AltosRecordMM                   state = new AltosRecordMM();
-               boolean                         last_reported = false;
+               //boolean                               last_reported = false;
                EepromState                     eeprom = new EepromState();
 
                state.state = AltosLib.ao_flight_pad;
@@ -452,8 +406,6 @@ public class AltosEepromMegaIterable extends AltosRecordIterable {
                                if (line == null)
                                        break;
                                AltosOrderedMegaRecord record = new AltosOrderedMegaRecord(line, index++, prev_tick, prev_tick_valid);
-                               if (record == null)
-                                       break;
                                if (record.cmd == AltosLib.AO_LOG_INVALID)
                                        continue;
                                prev_tick = record.tick;
index 1e845f4..c7ced6a 100644 (file)
 
 package org.altusmetrum.AltosLib;
 
-import java.io.*;
-import java.util.*;
 import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.*;
 
 public class AltosEepromRecord {
        public int      cmd;
index 1758fa3..02ce455 100644 (file)
 
 package org.altusmetrum.AltosLib;
 
-import java.io.*;
-import java.util.*;
 import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.*;
 
 public class AltosEepromTeleScience {
        public int      type;
index d2e4f2f..1ab00b3 100644 (file)
@@ -17,7 +17,6 @@
 
 package org.altusmetrum.AltosLib; 
 
-import java.lang.*;
 import java.io.File;
 import java.util.*;
 
index 3fdea46..cbd6415 100644 (file)
@@ -17,7 +17,6 @@
 
 package org.altusmetrum.AltosLib;
 
-import java.lang.*;
 import java.text.*;
 import java.io.*;
 import java.util.concurrent.*;
index f08ff11..e20f03b 100644 (file)
 
 package org.altusmetrum.AltosLib;
 
-import java.io.*;
-import java.util.*;
-import java.text.*;
-
 public class AltosFrequency {
        public double   frequency;
        public String   description;
index f078a46..ea0949e 100644 (file)
@@ -17,7 +17,6 @@
 
 package org.altusmetrum.AltosLib;
 
-import java.lang.*;
 import java.text.*;
 
 public class AltosGPS {
@@ -175,24 +174,26 @@ public class AltosGPS {
                lon = in_lon / 10.0e7;
        }
 
-       public void set_time(int hour, int minute, int second) {
-               hour = hour;
-               minute = minute;
-               second = second;
+       public void set_time(int in_hour, int in_minute, int in_second) {
+               hour = in_hour;
+               minute = in_minute;
+               second = in_second;
        }
 
-       public void set_date(int year, int month, int day) {
-               year = year;
-               month = month;
-               day = day;
+       public void set_date(int in_year, int in_month, int in_day) {
+               year = in_year;
+               month = in_month;
+               day = in_day;
        }
 
-       public void set_flags(int flags) {
-               flags = flags;
+       /*
+       public void set_flags(int in_flags) {
+               flags = in_flags;
        }
+       */
 
-       public void set_altitude(int altitude) {
-               altitude = altitude;
+       public void set_altitude(int in_altitude) {
+               alt = in_altitude;
        }
 
        public void add_sat(int svid, int c_n0) {
diff --git a/altoslib/AltosGPSQuery.java b/altoslib/AltosGPSQuery.java
new file mode 100644 (file)
index 0000000..e93af25
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * Copyright © 2012 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package org.altusmetrum.AltosLib;
+
+import java.util.concurrent.*;
+
+class AltosGPSQuery extends AltosGPS {
+       public AltosGPSQuery (AltosLink link, AltosConfigData config_data)
+               throws TimeoutException, InterruptedException {
+               boolean says_done = config_data.compare_version("1.0") >= 0;
+               link.printf("g\n");
+               for (;;) {
+                       String line = link.get_reply_no_dialog(5000);
+                       if (line == null)
+                               throw new TimeoutException();
+                       String[] bits = line.split("\\s+");
+                       if (bits.length == 0)
+                               continue;
+                       if (line.startsWith("Date:")) {
+                               if (bits.length < 2)
+                                       continue;
+                               String[] d = bits[1].split(":");
+                               if (d.length < 3)
+                                       continue;
+                               year = Integer.parseInt(d[0]) + 2000;
+                               month = Integer.parseInt(d[1]);
+                               day = Integer.parseInt(d[2]);
+                               continue;
+                       }
+                       if (line.startsWith("Time:")) {
+                               if (bits.length < 2)
+                                       continue;
+                               String[] d = bits[1].split("/");
+                               if (d.length < 3)
+                                       continue;
+                               hour = Integer.parseInt(d[0]);
+                               minute = Integer.parseInt(d[1]);
+                               second = Integer.parseInt(d[2]);
+                               continue;
+                       }
+                       if (line.startsWith("Lat/Lon:")) {
+                               if (bits.length < 3)
+                                       continue;
+                               lat = Integer.parseInt(bits[1]) * 1.0e-7;
+                               lon = Integer.parseInt(bits[2]) * 1.0e-7;
+                               continue;
+                       }
+                       if (line.startsWith("Alt:")) {
+                               if (bits.length < 2)
+                                       continue;
+                               alt = Integer.parseInt(bits[1]);
+                               continue;
+                       }
+                       if (line.startsWith("Flags:")) {
+                               if (bits.length < 2)
+                                       continue;
+                               int status = Integer.decode(bits[1]);
+                               connected = (status & AltosLib.AO_GPS_RUNNING) != 0;
+                               locked = (status & AltosLib.AO_GPS_VALID) != 0;
+                               if (!says_done)
+                                       break;
+                               continue;
+                       }
+                       if (line.startsWith("Sats:")) {
+                               if (bits.length < 2)
+                                       continue;
+                               nsat = Integer.parseInt(bits[1]);
+                               cc_gps_sat = new AltosGPSSat[nsat];
+                               for (int i = 0; i < nsat; i++) {
+                                       int     svid = Integer.parseInt(bits[2+i*2]);
+                                       int     cc_n0 = Integer.parseInt(bits[3+i*2]);
+                                       cc_gps_sat[i] = new AltosGPSSat(svid, cc_n0);
+                               }
+                       }
+                       if (line.startsWith("done"))
+                               break;
+                       if (line.startsWith("Syntax error"))
+                               break;
+               }
+       }
+}
+
diff --git a/altoslib/AltosIMUQuery.java b/altoslib/AltosIMUQuery.java
new file mode 100644 (file)
index 0000000..0965fa3
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright © 2012 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package org.altusmetrum.AltosLib;
+
+import java.util.concurrent.TimeoutException;
+
+class AltosIMUQuery extends AltosIMU {
+
+       public AltosIMUQuery (AltosLink link) throws InterruptedException, TimeoutException {
+               link.printf("I\n");
+               for (;;) {
+                       String line = link.get_reply_no_dialog(5000);
+                       if (line == null) {
+                               throw new TimeoutException();
+                       }
+                       if (!line.startsWith("Accel:"))
+                               continue;
+                       String[] items = line.split("\\s+");
+                       if (items.length >= 8) {
+                               accel_x = Integer.parseInt(items[1]);
+                               accel_y = Integer.parseInt(items[2]);
+                               accel_z = Integer.parseInt(items[3]);
+                               gyro_x = Integer.parseInt(items[5]);
+                               gyro_y = Integer.parseInt(items[6]);
+                               gyro_z = Integer.parseInt(items[7]);
+                       }
+                       break;
+               }
+       }
+}
+
index 27ea3a2..ae3b7b0 100644 (file)
 package org.altusmetrum.AltosLib;
 
 import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
 import java.util.concurrent.*;
 
-class AltosSensorTM extends AltosRecordTM {
-
-       public AltosSensorTM(AltosLink link, AltosConfigData config_data) throws InterruptedException, TimeoutException {
-               super();
-               link.printf("a\n");
-               for (;;) {
-                       String line = link.get_reply_no_dialog(5000);
-                       if (line == null) {
-                               throw new TimeoutException();
-                       }
-                       if (!line.startsWith("tick:"))
-                               continue;
-                       String[] items = line.split("\\s+");
-                       for (int i = 0; i < items.length;) {
-                               if (items[i].equals("tick:")) {
-                                       tick = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("accel:")) {
-                                       accel = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("pres:")) {
-                                       pres = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("temp:")) {
-                                       temp = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("batt:")) {
-                                       batt = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("drogue:")) {
-                                       drogue = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("main:")) {
-                                       main = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               i++;
-                       }
-                       break;
-               }
-               ground_accel = config_data.accel_cal_plus;
-               ground_pres = pres;
-               accel_plus_g = config_data.accel_cal_plus;
-               accel_minus_g = config_data.accel_cal_minus;
-       }
-}
-
-class AltosSensorMM {
-       int             tick;
-       int             sense[];
-       int             v_batt;
-       int             v_pyro;
-       int             accel;
-       int             accel_ref;
-
-       public AltosSensorMM(AltosLink link) throws InterruptedException, TimeoutException {
-               link.printf("a\n");
-               for (;;) {
-                       String line = link.get_reply_no_dialog(5000);
-                       if (line == null) {
-                               throw new TimeoutException();
-                       }
-                       if (!line.startsWith("tick:"))
-                               continue;
-                       String[] items = line.split("\\s+");
-                       sense = new int[6];
-                       for (int i = 0; i < items.length;) {
-                               if (items[i].equals("tick:")) {
-                                       tick = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("0:")) {
-                                       sense[0] = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("1:")) {
-                                       sense[1] = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("2:")) {
-                                       sense[2] = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("3:")) {
-                                       sense[3] = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("4:")) {
-                                       sense[4] = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("5:")) {
-                                       sense[5] = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("6:")) {
-                                       v_batt = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("7:")) {
-                                       v_pyro = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("8:")) {
-                                       accel = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("9:")) {
-                                       accel_ref = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               i++;
-                       }
-                       break;
-               }
-       }
-}
-
-class AltosIMUQuery extends AltosIMU {
-
-       public AltosIMUQuery (AltosLink link) throws InterruptedException, TimeoutException {
-               link.printf("I\n");
-               for (;;) {
-                       String line = link.get_reply_no_dialog(5000);
-                       if (line == null) {
-                               throw new TimeoutException();
-                       }
-                       if (!line.startsWith("Accel:"))
-                               continue;
-                       String[] items = line.split("\\s+");
-                       if (items.length >= 8) {
-                               accel_x = Integer.parseInt(items[1]);
-                               accel_y = Integer.parseInt(items[2]);
-                               accel_z = Integer.parseInt(items[3]);
-                               gyro_x = Integer.parseInt(items[5]);
-                               gyro_y = Integer.parseInt(items[6]);
-                               gyro_z = Integer.parseInt(items[7]);
-                       }
-                       break;
-               }
-       }
-}
-
-class AltosMs5607Query extends AltosMs5607 {
-       public AltosMs5607Query (AltosLink link) throws InterruptedException, TimeoutException {
-               link.printf("v\nB\n");
-               for (;;) {
-                       String line = link.get_reply_no_dialog(5000);
-                       if (line == null) {
-                               throw new TimeoutException();
-                       }
-                       String[] items = line.split("\\s+");
-                       if (line.startsWith("Pressure:")) {
-                               if (items.length >= 2)
-                                       raw_pres = Integer.parseInt(items[1]);
-                       } else if (line.startsWith("Temperature:")) {
-                               if (items.length >= 2)
-                                       raw_temp = Integer.parseInt(items[1]);
-                       } else if (line.startsWith("ms5607 reserved:")) {
-                               if (items.length >= 3)
-                                       reserved = Integer.parseInt(items[2]);
-                       } else if (line.startsWith("ms5607 sens:")) {
-                               if (items.length >= 3)
-                                       sens = Integer.parseInt(items[2]);
-                       } else if (line.startsWith("ms5607 off:")) {
-                               if (items.length >= 3)
-                                       off = Integer.parseInt(items[2]);
-                       } else if (line.startsWith("ms5607 tcs:")) {
-                               if (items.length >= 3)
-                                       tcs = Integer.parseInt(items[2]);
-                       } else if (line.startsWith("ms5607 tco:")) {
-                               if (items.length >= 3)
-                                       tco = Integer.parseInt(items[2]);
-                       } else if (line.startsWith("ms5607 tref:")) {
-                               if (items.length >= 3)
-                                       tref = Integer.parseInt(items[2]);
-                       } else if (line.startsWith("ms5607 tempsens:")) {
-                               if (items.length >= 3)
-                                       tempsens = Integer.parseInt(items[2]);
-                       } else if (line.startsWith("ms5607 crc:")) {
-                               if (items.length >= 3)
-                                       crc = Integer.parseInt(items[2]);
-                       } else if (line.startsWith("Altitude"))
-                               break;
-               }
-               convert();
-       }
-}
-
-class AltosGPSQuery extends AltosGPS {
-       public AltosGPSQuery (AltosLink link, AltosConfigData config_data)
-               throws TimeoutException, InterruptedException {
-               boolean says_done = config_data.compare_version("1.0") >= 0;
-               link.printf("g\n");
-               for (;;) {
-                       String line = link.get_reply_no_dialog(5000);
-                       if (line == null)
-                               throw new TimeoutException();
-                       String[] bits = line.split("\\s+");
-                       if (bits.length == 0)
-                               continue;
-                       if (line.startsWith("Date:")) {
-                               if (bits.length < 2)
-                                       continue;
-                               String[] d = bits[1].split("/");
-                               if (d.length < 3)
-                                       continue;
-                               year = Integer.parseInt(d[0]) + 2000;
-                               month = Integer.parseInt(d[1]);
-                               day = Integer.parseInt(d[2]);
-                               continue;
-                       }
-                       if (line.startsWith("Time:")) {
-                               if (bits.length < 2)
-                                       continue;
-                               String[] d = bits[1].split(":");
-                               if (d.length < 3)
-                                       continue;
-                               hour = Integer.parseInt(d[0]);
-                               minute = Integer.parseInt(d[1]);
-                               second = Integer.parseInt(d[2]);
-                               continue;
-                       }
-                       if (line.startsWith("Lat/Lon:")) {
-                               if (bits.length < 3)
-                                       continue;
-                               lat = Integer.parseInt(bits[1]) * 1.0e-7;
-                               lon = Integer.parseInt(bits[2]) * 1.0e-7;
-                               continue;
-                       }
-                       if (line.startsWith("Alt:")) {
-                               if (bits.length < 2)
-                                       continue;
-                               alt = Integer.parseInt(bits[1]);
-                               continue;
-                       }
-                       if (line.startsWith("Flags:")) {
-                               if (bits.length < 2)
-                                       continue;
-                               int status = Integer.decode(bits[1]);
-                               connected = (status & AltosLib.AO_GPS_RUNNING) != 0;
-                               locked = (status & AltosLib.AO_GPS_VALID) != 0;
-                               if (!says_done)
-                                       break;
-                               continue;
-                       }
-                       if (line.startsWith("Sats:")) {
-                               if (bits.length < 2)
-                                       continue;
-                               nsat = Integer.parseInt(bits[1]);
-                               cc_gps_sat = new AltosGPSSat[nsat];
-                               for (int i = 0; i < nsat; i++) {
-                                       int     svid = Integer.parseInt(bits[2+i*2]);
-                                       int     cc_n0 = Integer.parseInt(bits[3+i*2]);
-                                       cc_gps_sat[i] = new AltosGPSSat(svid, cc_n0);
-                               }
-                       }
-                       if (line.startsWith("done"))
-                               break;
-                       if (line.startsWith("Syntax error"))
-                               break;
-               }
-       }
-}
 
 public class AltosIdleMonitor extends Thread {
        AltosLink               link;
index 3c18bfa..9f9abab 100644 (file)
 
 package org.altusmetrum.AltosLib;
 
-import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.*;
-
 public interface AltosIdleMonitorListener {
        public void update(AltosState state);
 }
\ No newline at end of file
diff --git a/altoslib/AltosIdleRecordTM.java b/altoslib/AltosIdleRecordTM.java
deleted file mode 100644 (file)
index 112b847..0000000
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * Copyright © 2012 Keith Packard <keithp@keithp.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-
-package org.altusmetrum.AltosLib;
-
-import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.*;
-
-class AltosADCTM {
-       int     tick;
-       int     accel;
-       int     pres;
-       int     temp;
-       int     batt;
-       int     drogue;
-       int     main;
-
-       public AltosADCTM(AltosLink link) throws InterruptedException, TimeoutException {
-               link.printf("a\n");
-               for (;;) {
-                       String line = link.get_reply_no_dialog(5000);
-                       if (line == null) {
-                               throw new TimeoutException();
-                       }
-                       if (!line.startsWith("tick:"))
-                               continue;
-                       String[] items = line.split("\\s+");
-                       for (int i = 0; i < items.length;) {
-                               if (items[i].equals("tick:")) {
-                                       tick = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("accel:")) {
-                                       accel = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("pres:")) {
-                                       pres = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("temp:")) {
-                                       temp = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("batt:")) {
-                                       batt = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("drogue:")) {
-                                       drogue = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               if (items[i].equals("main:")) {
-                                       main = Integer.parseInt(items[i+1]);
-                                       i += 2;
-                                       continue;
-                               }
-                               i++;
-                       }
-                       break;
-               }
-       }
-}
-
-class AltosGPSQuery extends AltosGPS {
-       public AltosGPSQuery (AltosLink link, AltosConfigData config_data)
-               throws TimeoutException, InterruptedException {
-               boolean says_done = config_data.compare_version("1.0") >= 0;
-               link.printf("g\n");
-               for (;;) {
-                       String line = link.get_reply_no_dialog(5000);
-                       if (line == null)
-                               throw new TimeoutException();
-                       String[] bits = line.split("\\s+");
-                       if (bits.length == 0)
-                               continue;
-                       if (line.startsWith("Date:")) {
-                               if (bits.length < 2)
-                                       continue;
-                               String[] d = bits[1].split(":");
-                               if (d.length < 3)
-                                       continue;
-                               year = Integer.parseInt(d[0]) + 2000;
-                               month = Integer.parseInt(d[1]);
-                               day = Integer.parseInt(d[2]);
-                               continue;
-                       }
-                       if (line.startsWith("Time:")) {
-                               if (bits.length < 2)
-                                       continue;
-                               String[] d = bits[1].split("/");
-                               if (d.length < 3)
-                                       continue;
-                               hour = Integer.parseInt(d[0]);
-                               minute = Integer.parseInt(d[1]);
-                               second = Integer.parseInt(d[2]);
-                               continue;
-                       }
-                       if (line.startsWith("Lat/Lon:")) {
-                               if (bits.length < 3)
-                                       continue;
-                               lat = Integer.parseInt(bits[1]) * 1.0e-7;
-                               lon = Integer.parseInt(bits[2]) * 1.0e-7;
-                               continue;
-                       }
-                       if (line.startsWith("Alt:")) {
-                               if (bits.length < 2)
-                                       continue;
-                               alt = Integer.parseInt(bits[1]);
-                               continue;
-                       }
-                       if (line.startsWith("Flags:")) {
-                               if (bits.length < 2)
-                                       continue;
-                               int status = Integer.decode(bits[1]);
-                               connected = (status & AltosLib.AO_GPS_RUNNING) != 0;
-                               locked = (status & AltosLib.AO_GPS_VALID) != 0;
-                               if (!says_done)
-                                       break;
-                               continue;
-                       }
-                       if (line.startsWith("Sats:")) {
-                               if (bits.length < 2)
-                                       continue;
-                               nsat = Integer.parseInt(bits[1]);
-                               cc_gps_sat = new AltosGPSSat[nsat];
-                               for (int i = 0; i < nsat; i++) {
-                                       int     svid = Integer.parseInt(bits[2+i*2]);
-                                       int     cc_n0 = Integer.parseInt(bits[3+i*2]);
-                                       cc_gps_sat[i] = new AltosGPSSat(svid, cc_n0);
-                               }
-                       }
-                       if (line.startsWith("done"))
-                               break;
-                       if (line.startsWith("Syntax error"))
-                               break;
-               }
-       }
-}
-
-public class AltosIdleMonitor extends Thread {
-       AltosLink               link;
-       AltosIdleMonitorListener        listener;
-       AltosState              state;
-       boolean                 remote;
-       double                  frequency;
-       AltosState              previous_state;
-       AltosConfigData         config_data;
-       AltosADC                adc;
-       AltosGPS                gps;
-
-       int AltosRSSI() throws TimeoutException, InterruptedException {
-               link.printf("s\n");
-               String line = link.get_reply_no_dialog(5000);
-               if (line == null)
-                       throw new TimeoutException();
-               String[] items = line.split("\\s+");
-               if (items.length < 2)
-                       return 0;
-               if (!items[0].equals("RSSI:"))
-                       return 0;
-               int rssi = Integer.parseInt(items[1]);
-               return rssi;
-       }
-
-       void update_state() throws InterruptedException, TimeoutException {
-               AltosRecordTM   record = new AltosRecordTM();
-               int             rssi;
-
-               try {
-                       if (remote) {
-                               link.set_radio_frequency(frequency);
-                               link.start_remote();
-                       } else
-                               link.flush_input();
-                       config_data = new AltosConfigData(link);
-                       adc = new AltosADC(link);
-                       gps = new AltosGPSQuery(link, config_data);
-               } finally {
-                       if (remote) {
-                               link.stop_remote();
-                               rssi = AltosRSSI();
-                       } else
-                               rssi = 0;
-               }
-
-               record.version = 0;
-               record.callsign = config_data.callsign;
-               record.serial = config_data.serial;
-               record.flight = config_data.log_available() > 0 ? 255 : 0;
-               record.rssi = rssi;
-               record.status = 0;
-               record.state = AltosLib.ao_flight_idle;
-
-               record.tick = adc.tick;
-
-               record.accel = adc.accel;
-               record.pres = adc.pres;
-               record.batt = adc.batt;
-               record.temp = adc.temp;
-               record.drogue = adc.drogue;
-               record.main = adc.main;
-
-               record.ground_accel = record.accel;
-               record.ground_pres = record.pres;
-               record.accel_plus_g = config_data.accel_cal_plus;
-               record.accel_minus_g = config_data.accel_cal_minus;
-               record.acceleration = 0;
-               record.speed = 0;
-               record.height = 0;
-               record.gps = gps;
-               state = new AltosState (record, state);
-       }
-
-       public void set_frequency(double in_frequency) {
-               frequency = in_frequency;
-       }
-
-       public void post_state() {
-               listener.update(state);
-       }
-
-       public void run() {
-               try {
-                       for (;;) {
-                               try {
-                                       update_state();
-                                       post_state();
-                               } catch (TimeoutException te) {
-                               }
-                               Thread.sleep(1000);
-                       }
-               } catch (InterruptedException ie) {
-                       link.close();
-               }
-       }
-
-       public AltosIdleMonitor(AltosIdleMonitorListener in_listener, AltosLink in_link, boolean in_remote)
-               throws FileNotFoundException, InterruptedException, TimeoutException {
-               listener = in_listener;
-               link = in_link;
-               remote = in_remote;
-               state = null;
-       }
-}
index cc81433..a48d0b6 100644 (file)
@@ -64,6 +64,7 @@ public class AltosIgnite {
                }
        }
 
+       /*
        private boolean get_string(String line, String label, string_ref s) {
                if (line.startsWith(label)) {
                        String  quoted = line.substring(label.length()).trim();
@@ -78,6 +79,7 @@ public class AltosIgnite {
                        return false;
                }
        }
+       */
 
        private int status(String status_name) {
                if (status_name.equals("unknown"))
@@ -95,7 +97,7 @@ public class AltosIgnite {
                int status = Unknown;
                if (link == null)
                        return status;
-               string_ref status_name = new string_ref();
+               //string_ref status_name = new string_ref();
                try {
                        start_link();
                        link.printf("t\n");
index d36b2ff..192c445 100644 (file)
@@ -17,9 +17,7 @@
 
 package org.altusmetrum.AltosLib;
 
-import java.awt.*;
 import java.util.*;
-import java.text.*;
 import java.io.*;
 import java.nio.charset.Charset;
 
index 415c3c6..6d51056 100644 (file)
 
 package org.altusmetrum.AltosLib;
 
-import java.lang.*;
 import java.io.*;
 import java.util.concurrent.*;
 import java.util.*;
-import java.text.*;
 
 public abstract class AltosLink implements Runnable {
 
index 55a25bb..3c12470 100644 (file)
@@ -18,8 +18,6 @@
 package org.altusmetrum.AltosLib;
 
 import java.io.*;
-import java.lang.*;
-import java.util.*;
 import java.text.ParseException;
 import java.util.concurrent.LinkedBlockingQueue;
 
index 5fd997d..268e89f 100644 (file)
@@ -37,7 +37,7 @@ public class AltosMs5607 {
                int TEMP;
                long OFF;
                long SENS;
-               int P;
+               //int P;
 
                dT = raw_temp - ((int) tref << 8);
        
diff --git a/altoslib/AltosMs5607Query.java b/altoslib/AltosMs5607Query.java
new file mode 100644 (file)
index 0000000..3c74679
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright © 2012 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package org.altusmetrum.AltosLib;
+
+import java.util.concurrent.TimeoutException;
+
+class AltosMs5607Query extends AltosMs5607 {
+       public AltosMs5607Query (AltosLink link) throws InterruptedException, TimeoutException {
+               link.printf("v\nB\n");
+               for (;;) {
+                       String line = link.get_reply_no_dialog(5000);
+                       if (line == null) {
+                               throw new TimeoutException();
+                       }
+                       String[] items = line.split("\\s+");
+                       if (line.startsWith("Pressure:")) {
+                               if (items.length >= 2)
+                                       raw_pres = Integer.parseInt(items[1]);
+                       } else if (line.startsWith("Temperature:")) {
+                               if (items.length >= 2)
+                                       raw_temp = Integer.parseInt(items[1]);
+                       } else if (line.startsWith("ms5607 reserved:")) {
+                               if (items.length >= 3)
+                                       reserved = Integer.parseInt(items[2]);
+                       } else if (line.startsWith("ms5607 sens:")) {
+                               if (items.length >= 3)
+                                       sens = Integer.parseInt(items[2]);
+                       } else if (line.startsWith("ms5607 off:")) {
+                               if (items.length >= 3)
+                                       off = Integer.parseInt(items[2]);
+                       } else if (line.startsWith("ms5607 tcs:")) {
+                               if (items.length >= 3)
+                                       tcs = Integer.parseInt(items[2]);
+                       } else if (line.startsWith("ms5607 tco:")) {
+                               if (items.length >= 3)
+                                       tco = Integer.parseInt(items[2]);
+                       } else if (line.startsWith("ms5607 tref:")) {
+                               if (items.length >= 3)
+                                       tref = Integer.parseInt(items[2]);
+                       } else if (line.startsWith("ms5607 tempsens:")) {
+                               if (items.length >= 3)
+                                       tempsens = Integer.parseInt(items[2]);
+                       } else if (line.startsWith("ms5607 crc:")) {
+                               if (items.length >= 3)
+                                       crc = Integer.parseInt(items[2]);
+                       } else if (line.startsWith("Altitude"))
+                               break;
+               }
+               convert();
+       }
+}
+
diff --git a/altoslib/AltosOrderedMegaRecord.java b/altoslib/AltosOrderedMegaRecord.java
new file mode 100644 (file)
index 0000000..05423dd
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright © 2010 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package org.altusmetrum.AltosLib;
+
+import java.text.ParseException;
+
+/*
+ * AltosRecords with an index field so they can be sorted by tick while preserving
+ * the original ordering for elements with matching ticks
+ */
+class AltosOrderedMegaRecord extends AltosEepromMega implements Comparable<AltosOrderedMegaRecord> {
+
+       public int      index;
+
+       public AltosOrderedMegaRecord(String line, int in_index, int prev_tick, boolean prev_tick_valid)
+               throws ParseException {
+               super(line);
+               if (prev_tick_valid) {
+                       tick |= (prev_tick & ~0xffff);
+                       if (tick < prev_tick) {
+                               if (prev_tick - tick > 0x8000)
+                                       tick += 0x10000;
+                       } else {
+                               if (tick - prev_tick > 0x8000)
+                                       tick -= 0x10000;
+                       }
+               }
+               index = in_index;
+       }
+
+       public AltosOrderedMegaRecord(int in_cmd, int in_tick, int in_a, int in_b, int in_index) {
+               super(in_cmd, in_tick);
+               a = in_a;
+               b = in_b;
+               index = in_index;
+       }
+
+       public String toString() {
+               return String.format("%d.%d %04x %04x %04x",
+                                    cmd, index, tick, a, b);
+       }
+
+       public int compareTo(AltosOrderedMegaRecord o) {
+               int     tick_diff = tick - o.tick;
+               if (tick_diff != 0)
+                       return tick_diff;
+               return index - o.index;
+       }
+}
diff --git a/altoslib/AltosOrderedRecord.java b/altoslib/AltosOrderedRecord.java
new file mode 100644 (file)
index 0000000..b4cfd8f
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright © 2010 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package org.altusmetrum.AltosLib;
+
+import java.text.ParseException;
+
+/*
+ * AltosRecords with an index field so they can be sorted by tick while preserving
+ * the original ordering for elements with matching ticks
+ */
+class AltosOrderedRecord extends AltosEepromRecord implements Comparable<AltosOrderedRecord> {
+
+       public int      index;
+
+       public AltosOrderedRecord(String line, int in_index, int prev_tick, boolean prev_tick_valid)
+               throws ParseException {
+               super(line);
+               if (prev_tick_valid) {
+                       tick |= (prev_tick & ~0xffff);
+                       if (tick < prev_tick) {
+                               if (prev_tick - tick > 0x8000)
+                                       tick += 0x10000;
+                       } else {
+                               if (tick - prev_tick > 0x8000)
+                                       tick -= 0x10000;
+                       }
+               }
+               index = in_index;
+       }
+
+       public AltosOrderedRecord(int in_cmd, int in_tick, int in_a, int in_b, int in_index) {
+               super(in_cmd, in_tick, in_a, in_b);
+               index = in_index;
+       }
+
+       public String toString() {
+               return String.format("%d.%d %04x %04x %04x",
+                                    cmd, index, tick, a, b);
+       }
+
+       public int compareTo(AltosOrderedRecord o) {
+               int     tick_diff = tick - o.tick;
+               if (tick_diff != 0)
+                       return tick_diff;
+               return index - o.index;
+       }
+}
+
index 7d832f1..e938a17 100644 (file)
@@ -18,7 +18,6 @@
 package org.altusmetrum.AltosLib;
 
 import java.text.*;
-import java.lang.*;
 
 public class AltosParse {
        public static boolean isdigit(char c) {
index 9ab80cf..13fee46 100644 (file)
@@ -19,11 +19,7 @@ package org.altusmetrum.AltosLib;
 
 import java.io.*;
 import java.util.*;
-import java.text.*;
 import java.util.prefs.*;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.awt.Component;
-import javax.swing.*;
 import javax.swing.filechooser.FileSystemView;
 
 public class AltosPreferences {
index 8722bc0..dd74171 100644 (file)
 
 package org.altusmetrum.AltosLib;
 
-import java.lang.*;
-import java.text.*;
-import java.util.HashMap;
-import java.io.*;
-
 public class AltosRecord implements Comparable <AltosRecord>, Cloneable {
 
        public static final int seen_flight = 1;
index 1585f9e..50bef07 100644 (file)
@@ -19,9 +19,6 @@ package org.altusmetrum.AltosLib;
 
 import java.io.*;
 import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.LinkedBlockingQueue;
 
 /*
  * Open an existing telemetry file and replay it in realtime
diff --git a/altoslib/AltosSensorMM.java b/altoslib/AltosSensorMM.java
new file mode 100644 (file)
index 0000000..b6f21ef
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * Copyright © 2012 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package org.altusmetrum.AltosLib;
+
+import java.util.concurrent.TimeoutException;
+
+class AltosSensorMM {
+       int             tick;
+       int             sense[];
+       int             v_batt;
+       int             v_pyro;
+       int             accel;
+       int             accel_ref;
+
+       public AltosSensorMM(AltosLink link) throws InterruptedException, TimeoutException {
+               link.printf("a\n");
+               for (;;) {
+                       String line = link.get_reply_no_dialog(5000);
+                       if (line == null) {
+                               throw new TimeoutException();
+                       }
+                       if (!line.startsWith("tick:"))
+                               continue;
+                       String[] items = line.split("\\s+");
+                       sense = new int[6];
+                       for (int i = 0; i < items.length;) {
+                               if (items[i].equals("tick:")) {
+                                       tick = Integer.parseInt(items[i+1]);
+                                       i += 2;
+                                       continue;
+                               }
+                               if (items[i].equals("0:")) {
+                                       sense[0] = Integer.parseInt(items[i+1]);
+                                       i += 2;
+                                       continue;
+                               }
+                               if (items[i].equals("1:")) {
+                                       sense[1] = Integer.parseInt(items[i+1]);
+                                       i += 2;
+                                       continue;
+                               }
+                               if (items[i].equals("2:")) {
+                                       sense[2] = Integer.parseInt(items[i+1]);
+                                       i += 2;
+                                       continue;
+                               }
+                               if (items[i].equals("3:")) {
+                                       sense[3] = Integer.parseInt(items[i+1]);
+                                       i += 2;
+                                       continue;
+                               }
+                               if (items[i].equals("4:")) {
+                                       sense[4] = Integer.parseInt(items[i+1]);
+                                       i += 2;
+                                       continue;
+                               }
+                               if (items[i].equals("5:")) {
+                                       sense[5] = Integer.parseInt(items[i+1]);
+                                       i += 2;
+                                       continue;
+                               }
+                               if (items[i].equals("6:")) {
+                                       v_batt = Integer.parseInt(items[i+1]);
+                                       i += 2;
+                                       continue;
+                               }
+                               if (items[i].equals("7:")) {
+                                       v_pyro = Integer.parseInt(items[i+1]);
+                                       i += 2;
+                                       continue;
+                               }
+                               if (items[i].equals("8:")) {
+                                       accel = Integer.parseInt(items[i+1]);
+                                       i += 2;
+                                       continue;
+                               }
+                               if (items[i].equals("9:")) {
+                                       accel_ref = Integer.parseInt(items[i+1]);
+                                       i += 2;
+                                       continue;
+                               }
+                               i++;
+                       }
+                       break;
+               }
+       }
+}
+
diff --git a/altoslib/AltosSensorTM.java b/altoslib/AltosSensorTM.java
new file mode 100644 (file)
index 0000000..75158cb
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Copyright © 2012 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package org.altusmetrum.AltosLib;
+
+import java.util.concurrent.TimeoutException;
+
+class AltosSensorTM extends AltosRecordTM {
+
+       public AltosSensorTM(AltosLink link, AltosConfigData config_data) throws InterruptedException, TimeoutException {
+               super();
+               link.printf("a\n");
+               for (;;) {
+                       String line = link.get_reply_no_dialog(5000);
+                       if (line == null) {
+                               throw new TimeoutException();
+                       }
+                       if (!line.startsWith("tick:"))
+                               continue;
+                       String[] items = line.split("\\s+");
+                       for (int i = 0; i < items.length;) {
+                               if (items[i].equals("tick:")) {
+                                       tick = Integer.parseInt(items[i+1]);
+                                       i += 2;
+                                       continue;
+                               }
+                               if (items[i].equals("accel:")) {
+                                       accel = Integer.parseInt(items[i+1]);
+                                       i += 2;
+                                       continue;
+                               }
+                               if (items[i].equals("pres:")) {
+                                       pres = Integer.parseInt(items[i+1]);
+                                       i += 2;
+                                       continue;
+                               }
+                               if (items[i].equals("temp:")) {
+                                       temp = Integer.parseInt(items[i+1]);
+                                       i += 2;
+                                       continue;
+                               }
+                               if (items[i].equals("batt:")) {
+                                       batt = Integer.parseInt(items[i+1]);
+                                       i += 2;
+                                       continue;
+                               }
+                               if (items[i].equals("drogue:")) {
+                                       drogue = Integer.parseInt(items[i+1]);
+                                       i += 2;
+                                       continue;
+                               }
+                               if (items[i].equals("main:")) {
+                                       main = Integer.parseInt(items[i+1]);
+                                       i += 2;
+                                       continue;
+                               }
+                               i++;
+                       }
+                       break;
+               }
+               ground_accel = config_data.accel_cal_plus;
+               ground_pres = pres;
+               accel_plus_g = config_data.accel_cal_plus;
+               accel_minus_g = config_data.accel_cal_minus;
+       }
+}
+
index 3b37a3d..2806812 100644 (file)
@@ -77,8 +77,8 @@ public class AltosState {
        public double   speak_altitude;
 
        public void init (AltosRecord cur, AltosState prev_state) {
-               int             i;
-               AltosRecord prev;
+               //int           i;
+               //AltosRecord prev;
 
                data = cur;
 
index ee24482..1553415 100644 (file)
@@ -17,9 +17,7 @@
 
 package org.altusmetrum.AltosLib;
 
-import java.lang.*;
 import java.text.*;
-import java.util.HashMap;
 
 /*
  * Telemetry data contents
index 003cb6a..bc1486d 100644 (file)
@@ -16,7 +16,6 @@
  */
 
 package org.altusmetrum.AltosLib;
-import java.lang.*;
 import java.text.*;
 import java.util.HashMap;
 
index bdb44ee..94fa560 100644 (file)
@@ -17,7 +17,6 @@
 
 package org.altusmetrum.AltosLib;
 
-import java.lang.*;
 import java.text.*;
 import java.io.*;
 import java.util.concurrent.*;
index 5e157a5..a53280c 100644 (file)
@@ -17,9 +17,7 @@
 
 package org.altusmetrum.AltosLib;
 
-import java.lang.*;
 import java.text.*;
-import java.util.HashMap;
 
 public class AltosTelemetryRecordGeneral {
 
index 3976a07..2117606 100644 (file)
@@ -17,9 +17,7 @@
 
 package org.altusmetrum.AltosLib;
 
-import java.lang.*;
 import java.text.*;
-import java.util.HashMap;
 
 /*
  * Telemetry data contents
@@ -394,9 +392,11 @@ public class AltosTelemetryRecordLegacy extends AltosTelemetryRecord {
        int[]   bytes;
        int     adjust;
 
+       /*
        private int int8(int i) {
                return AltosLib.int8(bytes, i + 1 + adjust);
        }
+       */
        private int uint8(int i) {
                return AltosLib.uint8(bytes, i + 1 + adjust);
        }
@@ -478,7 +478,7 @@ public class AltosTelemetryRecordLegacy extends AltosTelemetryRecord {
                        record.gps = new AltosGPS();
                        record.new_gps = true;
 
-                       record.seen |= record.seen_gps_time | record.seen_gps_lat | record.seen_gps_lon;
+                       record.seen |= AltosRecord.seen_gps_time | AltosRecord.seen_gps_lat | AltosRecord.seen_gps_lon;
                        record.gps.nsat = (gps_flags & AO_GPS_NUM_SAT_MASK);
                        record.gps.locked = (gps_flags & AO_GPS_VALID) != 0;
                        record.gps.connected = true;
index dc1b894..fbb373d 100644 (file)
 
 package org.altusmetrum.AltosLib;
 
-import java.lang.*;
-import java.text.*;
-import java.util.HashMap;
-
 public class AltosTelemetryRecordRaw extends AltosTelemetryRecord {
        int[]   bytes;
        int     serial;