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 c143036c1a9e13ecc05837631ebb66d7b42a2966..6f343639e72680120b6c064f4e82db4fa188ae28 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 6d889723c4f29240a87056be1d152aab4d470a2b..77b22fe274bf9210e8749732af227507f40bbd54 100644 (file)
@@ -17,8 +17,6 @@
 
 package org.altusmetrum.AltosLib;
 
-import java.io.*;
-import java.util.*;
 import java.text.*;
 import java.util.concurrent.*;
 
index f8acdc1685b45db38b71ef2fccfc1261d46c3761..1aa816e1aa6908e5e8f8af05399b6acd54471623 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 7fca4bd9feed0423737cf5bd570a9f7d9350adb2..211fd70607852ab611b17a6fbbc6159a1d0d9a5f 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 2628279e05e07ee8fac68df04911ae5ed946f210..26bacf8d854e33474457c4c8ef1a485e47232918 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 f62cc45bac38ed3bec280b9cef1d3cd58b9058ef..1ab2fcc8b473aee35e45a4306c5f32d481e19d89 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 1e845f4642119f76cb5102b7044897d736586ec5..c7ced6a3d0cd18db6e75cc645b8adc7d15be4be2 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 1758fa34ba09af769cbf1ab318cc565c6bc0fb97..02ce4553773abcdf7ac5f4defe39208259db26ce 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 d2e4f2f716cf9d877ce2793b3cdfae03f937a4ba..1ab00b381443b8c99fa96d3f9a026ddc58cd7bfc 100644 (file)
@@ -17,7 +17,6 @@
 
 package org.altusmetrum.AltosLib; 
 
-import java.lang.*;
 import java.io.File;
 import java.util.*;
 
index 3fdea4696649c40d9c7d5f91270144e6e6067669..cbd641532630cf4d176f50ffabde3f51a1ae01bb 100644 (file)
@@ -17,7 +17,6 @@
 
 package org.altusmetrum.AltosLib;
 
-import java.lang.*;
 import java.text.*;
 import java.io.*;
 import java.util.concurrent.*;
index f08ff1168a1d509dca587de0574b56ba8a19f05f..e20f03b7237079136329b3b8479009ba998e9870 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 f078a469a344ce850be94834e67ba7f20d9a47b1..ea0949ec7db58246a1c6c711db97871a7cde99c4 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 27ea3a2bcfa21ad94b6913f1246004a2aeaabd3c..ae3b7b06b94748aa7c3862d3688baecb8c13d2a0 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 3c18bfaa5f957ffa3af1e4d33f3136bb2c7e8347..9f9ababfbbdfc647993f8d89138d1ef90e6129fc 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 cc814337d1510ad4e225e40c3de67986c3233d5c..a48d0b69121e007912015bc65904bc98bf3ed3cd 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 d36b2ff789a313499c7655b5175ab1318548e09f..192c445e0c42dabe2b9e3c42a209fe8843e9269c 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 415c3c64c466daa80bbe5bd6f233a3aa2e821d8e..6d510563c5d32622bfbc3cfb854da885c21b4f27 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 55a25bb46b7e1ac563eed538bd998d717dbe76b7..3c12470045935abe9c9297db3c73d3569224e51f 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 5fd997d8ab73f8d64393c7cdc353ba1199a22738..268e89f6fd85fa0908945b431ccc633138f00a35 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 7d832f1ab2e6ce15bdfa8d079b10c1c348490fb9..e938a177e6b3967926e3f5ffd756cc1200653974 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 9ab80cf523809cf5bb97e8e5f12e11725fd2b73f..13fee46de129d8c6e7f909790890e5b21bb194f8 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 8722bc050bac011f183248301012d27b1d46e5c0..dd741716a884d2c2d191a3cb530b638886c77a06 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 1585f9eb4f3c4a61509f34df1c7b08c5641f13a1..50bef07a9599d7684646aae4d17d1c17383e801e 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 3b37a3d4b498fc90a8ba4e47cd1d6a03fd5681d8..2806812e4fc9f992b2fd7447eb2913eedf6b1670 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 ee2448246db8348b0d1272315ad8b8045357cc77..155341583bd2430d413b5bc6db6f10356b8eb724 100644 (file)
@@ -17,9 +17,7 @@
 
 package org.altusmetrum.AltosLib;
 
-import java.lang.*;
 import java.text.*;
-import java.util.HashMap;
 
 /*
  * Telemetry data contents
index 003cb6a9339376467122d04bd9cd4e0c39346a90..bc1486d87eaf7565053bde77e1c8d7766be24631 100644 (file)
@@ -16,7 +16,6 @@
  */
 
 package org.altusmetrum.AltosLib;
-import java.lang.*;
 import java.text.*;
 import java.util.HashMap;
 
index bdb44eefb369edb940027aec7bd38fe191a8e22c..94fa560b77fce450af0a7a55b9ce573234175342 100644 (file)
@@ -17,7 +17,6 @@
 
 package org.altusmetrum.AltosLib;
 
-import java.lang.*;
 import java.text.*;
 import java.io.*;
 import java.util.concurrent.*;
index 5e157a548cc581246756c6c9f8f7ab7449a26ee1..a53280cf79286c6674e446bb7d9efc7f78824dda 100644 (file)
@@ -17,9 +17,7 @@
 
 package org.altusmetrum.AltosLib;
 
-import java.lang.*;
 import java.text.*;
-import java.util.HashMap;
 
 public class AltosTelemetryRecordGeneral {
 
index 3976a07a93744b8f65bd6873c461e741dc3fbb89..211760691e23668b3b52a0eda839861e10cbb61d 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 dc1b8947d4ff665f074967293e04a7519dc41336..fbb373d54dcdfb9beaba3e3610150b255cd47ac2 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;