From 69e6df07976a56b49e07c242cd6e5b2cbd2a578d Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 23 Feb 2012 17:00:48 +1300 Subject: Move altoslib sources to top dir No sense having them live deep in the file system. Signed-off-by: Keith Packard --- altoslib/AltosTelemetry.java | 241 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 241 insertions(+) create mode 100644 altoslib/AltosTelemetry.java (limited to 'altoslib/AltosTelemetry.java') diff --git a/altoslib/AltosTelemetry.java b/altoslib/AltosTelemetry.java new file mode 100644 index 00000000..04abb1f3 --- /dev/null +++ b/altoslib/AltosTelemetry.java @@ -0,0 +1,241 @@ +/* + * Copyright © 2010 Keith Packard + * + * 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.lang.*; +import java.text.*; +import java.util.HashMap; + +/* + * Telemetry data contents + */ + + +/* + * The packet format is a simple hex dump of the raw telemetry frame. + * It starts with 'TELEM', then contains hex digits with a checksum as the last + * byte on the line. + * + * Version 4 is a replacement with consistent syntax. Each telemetry line + * contains a sequence of space-separated names and values, the values are + * either integers or strings. The names are all unique. All values are + * optional + * + * VERSION 4 c KD7SQG n 236 f 18 r -25 s pad t 513 r_a 15756 r_b 26444 r_t 20944 + * r_v 26640 r_d 512 r_m 208 c_a 15775 c_b 26439 c_p 15749 c_m 16281 a_a 15764 + * a_s 0 a_b 26439 g_s u g_n 0 s_n 0 + * + * VERSION 4 c KD7SQG n 19 f 0 r -23 s pad t 513 r_b 26372 r_t 21292 r_v 26788 + * r_d 136 r_m 140 c_b 26370 k_h 0 k_s 0 k_a 0 + * + * General header fields + * + * Name Value + * + * VERSION Telemetry version number (4 or more). Must be first. + * c Callsign (string, no spaces allowed) + * n Flight unit serial number (integer) + * f Flight number (integer) + * r Packet RSSI value (integer) + * s Flight computer state (string, no spaces allowed) + * t Flight computer clock (integer in centiseconds) + * + * Version 3 is Version 2 with fixed RSSI numbers -- the radio reports + * in 1/2dB increments while this protocol provides only integers. So, + * the syntax didn't change just the interpretation of the RSSI + * values. + * + * Version 2 of the telemetry data stream is a bit of a mess, with no + * consistent formatting. In particular, the GPS data is formatted for + * viewing instead of parsing. However, the key feature is that every + * telemetry line contains all of the information necessary to + * describe the current rocket state, including the calibration values + * for accelerometer and barometer. + * + * GPS unlocked: + * + * VERSION 2 CALL KB0G SERIAL 51 FLIGHT 2 RSSI -68 STATUS ff STATE pad 1001 \ + * a: 16032 p: 21232 t: 20284 v: 25160 d: 204 m: 204 fa: 16038 ga: 16032 fv: 0 \ + * fp: 21232 gp: 21230 a+: 16049 a-: 16304 GPS 0 sat unlocked SAT 1 15 30 + * + * GPS locked: + * + * VERSION 2 CALL KB0G SERIAL 51 FLIGHT 2 RSSI -71 STATUS ff STATE pad 2504 \ + * a: 16028 p: 21220 t: 20360 v: 25004 d: 208 m: 200 fa: 16031 ga: 16032 fv: 330 \ + * fp: 21231 gp: 21230 a+: 16049 a-: 16304 \ + * GPS 9 sat 2010-02-13 17:16:51 35°20.0803'N 106°45.2235'W 1790m \ + * 0.00m/s(H) 0° 0.00m/s(V) 1.0(hdop) 0(herr) 0(verr) \ + * SAT 10 29 30 24 28 5 25 21 20 15 33 1 23 30 24 18 26 10 29 2 26 + * + */ + +public class AltosTelemetry extends AltosRecord { + + /* + * General header fields + * + * Name Value + * + * VERSION Telemetry version number (4 or more). Must be first. + * c Callsign (string, no spaces allowed) + * n Flight unit serial number (integer) + * f Flight number (integer) + * r Packet RSSI value (integer) + * s Flight computer state (string, no spaces allowed) + * t Flight computer clock (integer in centiseconds) + */ + + final static String AO_TELEM_VERSION = "VERSION"; + final static String AO_TELEM_CALL = "c"; + final static String AO_TELEM_SERIAL = "n"; + final static String AO_TELEM_FLIGHT = "f"; + final static String AO_TELEM_RSSI = "r"; + final static String AO_TELEM_STATE = "s"; + final static String AO_TELEM_TICK = "t"; + + /* + * Raw sensor values + * + * Name Value + * r_a Accelerometer reading (integer) + * r_b Barometer reading (integer) + * r_t Thermometer reading (integer) + * r_v Battery reading (integer) + * r_d Drogue continuity (integer) + * r_m Main continuity (integer) + */ + + final static String AO_TELEM_RAW_ACCEL = "r_a"; + final static String AO_TELEM_RAW_BARO = "r_b"; + final static String AO_TELEM_RAW_THERMO = "r_t"; + final static String AO_TELEM_RAW_BATT = "r_v"; + final static String AO_TELEM_RAW_DROGUE = "r_d"; + final static String AO_TELEM_RAW_MAIN = "r_m"; + + /* + * Sensor calibration values + * + * Name Value + * c_a Ground accelerometer reading (integer) + * c_b Ground barometer reading (integer) + * c_p Accelerometer reading for +1g + * c_m Accelerometer reading for -1g + */ + + final static String AO_TELEM_CAL_ACCEL_GROUND = "c_a"; + final static String AO_TELEM_CAL_BARO_GROUND = "c_b"; + final static String AO_TELEM_CAL_ACCEL_PLUS = "c_p"; + final static String AO_TELEM_CAL_ACCEL_MINUS = "c_m"; + + /* + * Kalman state values + * + * Name Value + * k_h Height above pad (integer, meters) + * k_s Vertical speeed (integer, m/s * 16) + * k_a Vertical acceleration (integer, m/s² * 16) + */ + + final static String AO_TELEM_KALMAN_HEIGHT = "k_h"; + final static String AO_TELEM_KALMAN_SPEED = "k_s"; + final static String AO_TELEM_KALMAN_ACCEL = "k_a"; + + /* + * Ad-hoc flight values + * + * Name Value + * a_a Acceleration (integer, sensor units) + * a_s Speed (integer, integrated acceleration value) + * a_b Barometer reading (integer, sensor units) + */ + + final static String AO_TELEM_ADHOC_ACCEL = "a_a"; + final static String AO_TELEM_ADHOC_SPEED = "a_s"; + final static String AO_TELEM_ADHOC_BARO = "a_b"; + + /* + * GPS values + * + * Name Value + * g_s GPS state (string): + * l locked + * u unlocked + * e error (missing or broken) + * g_n Number of sats used in solution + * g_ns Latitude (degrees * 10e7) + * g_ew Longitude (degrees * 10e7) + * g_a Altitude (integer meters) + * g_Y GPS year (integer) + * g_M GPS month (integer - 1-12) + * g_D GPS day (integer - 1-31) + * g_h GPS hour (integer - 0-23) + * g_m GPS minute (integer - 0-59) + * g_s GPS second (integer - 0-59) + * g_v GPS vertical speed (integer, cm/sec) + * g_s GPS horizontal speed (integer, cm/sec) + * g_c GPS course (integer, 0-359) + * g_hd GPS hdop (integer * 10) + * g_vd GPS vdop (integer * 10) + * g_he GPS h error (integer) + * g_ve GPS v error (integer) + */ + + final static String AO_TELEM_GPS_STATE = "g"; + final static String AO_TELEM_GPS_STATE_LOCKED = "l"; + final static String AO_TELEM_GPS_STATE_UNLOCKED = "u"; + final static String AO_TELEM_GPS_STATE_ERROR = "e"; + final static String AO_TELEM_GPS_NUM_SAT = "g_n"; + final static String AO_TELEM_GPS_LATITUDE = "g_ns"; + final static String AO_TELEM_GPS_LONGITUDE = "g_ew"; + final static String AO_TELEM_GPS_ALTITUDE = "g_a"; + final static String AO_TELEM_GPS_YEAR = "g_Y"; + final static String AO_TELEM_GPS_MONTH = "g_M"; + final static String AO_TELEM_GPS_DAY = "g_D"; + final static String AO_TELEM_GPS_HOUR = "g_h"; + final static String AO_TELEM_GPS_MINUTE = "g_m"; + final static String AO_TELEM_GPS_SECOND = "g_s"; + final static String AO_TELEM_GPS_VERTICAL_SPEED = "g_v"; + final static String AO_TELEM_GPS_HORIZONTAL_SPEED = "g_g"; + final static String AO_TELEM_GPS_COURSE = "g_c"; + final static String AO_TELEM_GPS_HDOP = "g_hd"; + final static String AO_TELEM_GPS_VDOP = "g_vd"; + final static String AO_TELEM_GPS_HERROR = "g_he"; + final static String AO_TELEM_GPS_VERROR = "g_ve"; + + /* + * GPS satellite values + * + * Name Value + * s_n Number of satellites reported (integer) + * s_v0 Space vehicle ID (integer) for report 0 + * s_c0 C/N0 number (integer) for report 0 + * s_v1 Space vehicle ID (integer) for report 1 + * s_c1 C/N0 number (integer) for report 1 + * ... + */ + + final static String AO_TELEM_SAT_NUM = "s_n"; + final static String AO_TELEM_SAT_SVID = "s_v"; + final static String AO_TELEM_SAT_C_N_0 = "s_c"; + + static public AltosRecord parse(String line, AltosRecord previous) throws ParseException, AltosCRCException { + AltosTelemetryRecord r = AltosTelemetryRecord.parse(line); + + return r.update_state(previous); + } +} -- cgit v1.2.3 From 6f421818fd7062f03bfaf9e606d6a4cfdcb13b49 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 21 Jun 2012 09:50:18 -0700 Subject: altosui: Support MM telemetry packets Required restructuring the whole telemetry system to provide abstract interfaces to flight data. Signed-off-by: Keith Packard --- altoslib/AltosEepromIterable.java | 10 +- altoslib/AltosEepromMegaIterable.java | 32 ++-- altoslib/AltosLib.java | 20 +++ altoslib/AltosMs5607.java | 7 + altoslib/AltosRecord.java | 225 +++++++-------------------- altoslib/AltosRecordMM.java | 186 ++++++++++++++++++++++ altoslib/AltosRecordTM.java | 199 +++++++++++++++++++++++ altoslib/AltosTelemetry.java | 2 +- altoslib/AltosTelemetryIterable.java | 6 +- altoslib/AltosTelemetryRecord.java | 8 +- altoslib/AltosTelemetryRecordLegacy.java | 8 +- altoslib/AltosTelemetryRecordMegaData.java | 96 ++++++++++++ altoslib/AltosTelemetryRecordMegaSensor.java | 98 ++++++++++++ altoslib/AltosTelemetryRecordRaw.java | 6 +- altoslib/AltosTelemetryRecordSensor.java | 10 +- altoslib/Makefile.am | 4 + altosui/AltosCSV.java | 8 +- altosui/AltosIdleMonitorUI.java | 23 +-- 18 files changed, 735 insertions(+), 213 deletions(-) create mode 100644 altoslib/AltosRecordMM.java create mode 100644 altoslib/AltosRecordTM.java create mode 100644 altoslib/AltosTelemetryRecordMegaData.java create mode 100644 altoslib/AltosTelemetryRecordMegaSensor.java (limited to 'altoslib/AltosTelemetry.java') diff --git a/altoslib/AltosEepromIterable.java b/altoslib/AltosEepromIterable.java index a923d63b..f8acdc16 100644 --- a/altoslib/AltosEepromIterable.java +++ b/altoslib/AltosEepromIterable.java @@ -104,7 +104,7 @@ public class AltosEepromIterable extends AltosRecordIterable { } } - void update_state(AltosRecord state, AltosEepromRecord record, EepromState eeprom) { + void update_state(AltosRecordTM state, AltosEepromRecord record, EepromState eeprom) { state.tick = record.tick; switch (record.cmd) { case AltosLib.AO_LOG_FLIGHT: @@ -237,7 +237,7 @@ public class AltosEepromIterable extends AltosRecordIterable { LinkedList list = new LinkedList(); Iterator iterator = records.iterator(); AltosOrderedRecord record = null; - AltosRecord state = new AltosRecord(); + AltosRecordTM state = new AltosRecordTM(); boolean last_reported = false; EepromState eeprom = new EepromState(); @@ -254,13 +254,13 @@ public class AltosEepromIterable extends AltosRecordIterable { while (iterator.hasNext()) { record = iterator.next(); if ((eeprom.seen & seen_basic) == seen_basic && record.tick != state.tick) { - AltosRecord r = new AltosRecord(state); + AltosRecordTM r = state.clone(); r.time = (r.tick - eeprom.boost_tick) / 100.0; list.add(r); } update_state(state, record, eeprom); } - AltosRecord r = new AltosRecord(state); + AltosRecordTM r = state.clone(); r.time = (r.tick - eeprom.boost_tick) / 100.0; list.add(r); return list; @@ -399,7 +399,7 @@ public class AltosEepromIterable extends AltosRecordIterable { try { for (;;) { - String line = AltosRecord.gets(input); + String line = AltosLib.gets(input); if (line == null) break; AltosOrderedRecord record = new AltosOrderedRecord(line, index++, prev_tick, prev_tick_valid); diff --git a/altoslib/AltosEepromMegaIterable.java b/altoslib/AltosEepromMegaIterable.java index 28a298b3..f62cc45b 100644 --- a/altoslib/AltosEepromMegaIterable.java +++ b/altoslib/AltosEepromMegaIterable.java @@ -108,7 +108,7 @@ public class AltosEepromMegaIterable extends AltosRecordIterable { } } - void update_state(AltosRecord state, AltosEepromMega record, EepromState eeprom) { + void update_state(AltosRecordMM state, AltosEepromMega record, EepromState eeprom) { state.tick = record.tick; switch (record.cmd) { case AltosLib.AO_LOG_FLIGHT: @@ -122,7 +122,8 @@ public class AltosEepromMegaIterable extends AltosRecordIterable { break; case AltosLib.AO_LOG_SENSOR: state.accel = record.accel(); - state.pres = baro.set(record.pres(), record.temp()); + baro.set(record.pres(), record.temp()); + state.pres = baro.pa; state.temp = baro.cc; state.imu = new AltosIMU(); state.imu.accel_x = record.accel_x(); @@ -161,15 +162,20 @@ public class AltosEepromMegaIterable extends AltosRecordIterable { eeprom.seen |= seen_sensor; break; case AltosLib.AO_LOG_TEMP_VOLT: - state.batt = record.v_batt(); + state.v_batt = record.v_batt(); + state.v_pyro = record.v_pbatt(); + for (int i = 0; i < AltosRecordMM.num_sense; i++) + state.sense[i] = record.sense(i); eeprom.seen |= seen_temp_volt; break; - case AltosLib.AO_LOG_DEPLOY: - state.drogue = record.a; - state.main = record.b; - eeprom.seen |= seen_deploy; - has_ignite = true; - break; +// +// case AltosLib.AO_LOG_DEPLOY: +// state.drogue = record.a; +// state.main = record.b; +// eeprom.seen |= seen_deploy; +// has_ignite = true; +// break; + case AltosLib.AO_LOG_STATE: state.state = record.state(); break; @@ -278,7 +284,7 @@ public class AltosEepromMegaIterable extends AltosRecordIterable { LinkedList list = new LinkedList(); Iterator iterator = records.iterator(); AltosOrderedMegaRecord record = null; - AltosRecord state = new AltosRecord(); + AltosRecordMM state = new AltosRecordMM(); boolean last_reported = false; EepromState eeprom = new EepromState(); @@ -295,13 +301,13 @@ public class AltosEepromMegaIterable extends AltosRecordIterable { while (iterator.hasNext()) { record = iterator.next(); if ((eeprom.seen & seen_basic) == seen_basic && record.tick != state.tick) { - AltosRecord r = new AltosRecord(state); + AltosRecordMM r = state.clone(); r.time = (r.tick - eeprom.boost_tick) / 100.0; list.add(r); } update_state(state, record, eeprom); } - AltosRecord r = new AltosRecord(state); + AltosRecordMM r = state.clone(); r.time = (r.tick - eeprom.boost_tick) / 100.0; list.add(r); return list; @@ -442,7 +448,7 @@ public class AltosEepromMegaIterable extends AltosRecordIterable { try { for (;;) { - String line = AltosRecord.gets(input); + String line = AltosLib.gets(input); if (line == null) break; AltosOrderedMegaRecord record = new AltosOrderedMegaRecord(line, index++, prev_tick, prev_tick_valid); diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java index 4a779c55..2402331e 100644 --- a/altoslib/AltosLib.java +++ b/altoslib/AltosLib.java @@ -20,6 +20,7 @@ package org.altusmetrum.AltosLib; import java.awt.*; import java.util.*; import java.text.*; +import java.io.*; import java.nio.charset.Charset; public class AltosLib { @@ -304,6 +305,10 @@ public class AltosLib { (bytes[i+3] << 24); } + public static int int32(int[] bytes, int i) { + return (int) uint32(bytes, i); + } + public static final Charset unicode_set = Charset.forName("UTF-8"); public static String string(int[] bytes, int s, int l) { @@ -375,6 +380,21 @@ public class AltosLib { return v * sign; } + public static String gets(FileInputStream s) throws IOException { + int c; + String line = ""; + + while ((c = s.read()) != -1) { + if (c == '\r') + continue; + if (c == '\n') { + return line; + } + line = line + (char) c; + } + return null; + } + public static String replace_extension(String input, String extension) { int dot = input.lastIndexOf("."); if (dot > 0) diff --git a/altoslib/AltosMs5607.java b/altoslib/AltosMs5607.java index a7b902e2..5fd997d8 100644 --- a/altoslib/AltosMs5607.java +++ b/altoslib/AltosMs5607.java @@ -73,4 +73,11 @@ public class AltosMs5607 { convert(); return pa; } + + public AltosMs5607() { + raw_pres = AltosRecord.MISSING; + raw_temp = AltosRecord.MISSING; + pa = AltosRecord.MISSING; + cc = AltosRecord.MISSING; + } } diff --git a/altoslib/AltosRecord.java b/altoslib/AltosRecord.java index 10ef3061..e468f84b 100644 --- a/altoslib/AltosRecord.java +++ b/altoslib/AltosRecord.java @@ -22,8 +22,7 @@ import java.text.*; import java.util.HashMap; import java.io.*; -public class AltosRecord implements Comparable { - public final static int MISSING = 0x7fffffff; +public class AltosRecord implements Comparable , Cloneable { public static final int seen_flight = 1; public static final int seen_sensor = 2; @@ -33,8 +32,13 @@ public class AltosRecord implements Comparable { public static final int seen_gps_lat = 32; public static final int seen_gps_lon = 64; public static final int seen_companion = 128; - public int seen; + public int seen; + + public final static int MISSING = 0x7fffffff; + + /* Every AltosRecord implementation provides these fields */ + public int version; public String callsign; public int serial; @@ -44,31 +48,13 @@ public class AltosRecord implements Comparable { public int state; public int tick; - public int accel; - public int pres; - public int temp; - public int batt; - public int drogue; - public int main; - - public int ground_accel; - public int ground_pres; - public int accel_plus_g; - public int accel_minus_g; - - public double acceleration; - public double speed; - public double height; - - public int flight_accel; - public int flight_vel; - public int flight_pres; + /* Current flight dynamic state */ + public double acceleration; /* m/s² */ + public double speed; /* m/s */ + public double height; /* m */ public AltosGPS gps; - public boolean new_gps; - - public AltosIMU imu; - public AltosMag mag; + public boolean new_gps; public double time; /* seconds since boost */ @@ -83,45 +69,42 @@ public class AltosRecord implements Comparable { public AltosRecordCompanion companion; /* - * Values for our MP3H6115A pressure sensor - * - * From the data sheet: + * Abstract methods that convert record data + * to standard units: * - * Pressure range: 15-115 kPa - * Voltage at 115kPa: 2.82 - * Output scale: 27mV/kPa - * - * - * 27 mV/kPa * 2047 / 3300 counts/mV = 16.75 counts/kPa - * 2.82V * 2047 / 3.3 counts/V = 1749 counts/115 kPa + * pressure: Pa + * voltage: V + * acceleration: m/s² + * speed: m/s + * height: m + * temperature: °C */ - public static final double counts_per_kPa = 27 * 2047 / 3300; - public static final double counts_at_101_3kPa = 1674.0; + public double raw_pressure() { return MISSING; } - public static double - barometer_to_pressure(double count) - { - return ((count / 16.0) / 2047.0 + 0.095) / 0.009 * 1000.0; - } + public double filtered_pressure() { return MISSING; } - public double raw_pressure() { - if (pres == MISSING) - return MISSING; - return barometer_to_pressure(pres); - } + public double ground_pressure() { return MISSING; } - public double filtered_pressure() { - if (flight_pres == MISSING) - return MISSING; - return barometer_to_pressure(flight_pres); - } + public double battery_voltage() { return MISSING; } - public double ground_pressure() { - if (ground_pres == MISSING) - return MISSING; - return barometer_to_pressure(ground_pres); - } + public double main_voltage() { return MISSING; } + + public double drogue_voltage() { return MISSING; } + + public double temperature() { return MISSING; } + + public double acceleration() { return MISSING; } + + public double accel_speed() { return MISSING; } + + public AltosIMU imu() { return null; } + + public AltosMag mag() { return null; } + + /* + * Convert various pressure values to altitude + */ public double raw_altitude() { double p = raw_pressure(); @@ -138,8 +121,9 @@ public class AltosRecord implements Comparable { } public double filtered_altitude() { - if (height != MISSING && ground_pres != MISSING) - return height + ground_altitude(); + double ga = ground_altitude(); + if (height != MISSING && ga != MISSING) + return height + ga; double p = filtered_pressure(); if (p == MISSING) @@ -167,94 +151,17 @@ public class AltosRecord implements Comparable { return r - g; } - public double battery_voltage() { - if (batt == MISSING) - return MISSING; - return AltosConvert.cc_battery_to_voltage(batt); - } - - public double main_voltage() { - if (main == MISSING) - return MISSING; - return AltosConvert.cc_ignitor_to_voltage(main); - } - - public double drogue_voltage() { - if (drogue == MISSING) - return MISSING; - return AltosConvert.cc_ignitor_to_voltage(drogue); - } - - /* Value for the CC1111 built-in temperature sensor - * Output voltage at 0°C = 0.755V - * Coefficient = 0.00247V/°C - * Reference voltage = 1.25V - * - * temp = ((value / 32767) * 1.25 - 0.755) / 0.00247 - * = (value - 19791.268) / 32768 * 1.25 / 0.00247 - */ - - public static double - thermometer_to_temperature(double thermo) - { - return (thermo - 19791.268) / 32728.0 * 1.25 / 0.00247; - } - - public double temperature() { - if (temp == MISSING) - return MISSING; - return thermometer_to_temperature(temp); - } - - public double accel_counts_per_mss() { - double counts_per_g = Math.abs(accel_minus_g - accel_plus_g) / 2; - - return counts_per_g / 9.80665; - } - - public double acceleration() { - if (acceleration != MISSING) - return acceleration; - - if (ground_accel == MISSING || accel == MISSING) - return MISSING; - return (ground_accel - accel) / accel_counts_per_mss(); - } - - public double accel_speed() { - if (speed != MISSING) - return speed; - if (flight_vel == MISSING) - return MISSING; - return flight_vel / (accel_counts_per_mss() * 100.0); - } - public String state() { return AltosLib.state_name(state); } - public static String gets(FileInputStream s) throws IOException { - int c; - String line = ""; - - while ((c = s.read()) != -1) { - if (c == '\r') - continue; - if (c == '\n') { - return line; - } - line = line + (char) c; - } - return null; - } - public int compareTo(AltosRecord o) { return tick - o.tick; } - public AltosRecord(AltosRecord old) { - version = old.version; + public void copy(AltosRecord old) { seen = old.seen; + version = old.version; callsign = old.callsign; serial = old.serial; flight = old.flight; @@ -262,32 +169,27 @@ public class AltosRecord implements Comparable { status = old.status; state = old.state; tick = old.tick; - accel = old.accel; - pres = old.pres; - temp = old.temp; - batt = old.batt; - drogue = old.drogue; - main = old.main; - flight_accel = old.flight_accel; - ground_accel = old.ground_accel; - flight_vel = old.flight_vel; - flight_pres = old.flight_pres; - ground_pres = old.ground_pres; - accel_plus_g = old.accel_plus_g; - accel_minus_g = old.accel_minus_g; acceleration = old.acceleration; speed = old.speed; height = old.height; gps = new AltosGPS(old.gps); new_gps = false; companion = old.companion; - imu = old.imu; - mag = old.mag; + } + + public AltosRecord clone() { + try { + AltosRecord n = (AltosRecord) super.clone(); + n.copy(this); + return n; + } catch (CloneNotSupportedException e) { + return null; + } } public AltosRecord() { - version = 0; seen = 0; + version = 0; callsign = "N0CALL"; serial = 0; flight = 0; @@ -295,19 +197,6 @@ public class AltosRecord implements Comparable { status = 0; state = AltosLib.ao_flight_startup; tick = 0; - accel = MISSING; - pres = MISSING; - temp = MISSING; - batt = MISSING; - drogue = MISSING; - main = MISSING; - flight_accel = 0; - ground_accel = 0; - flight_vel = 0; - flight_pres = 0; - ground_pres = 0; - accel_plus_g = 0; - accel_minus_g = 0; acceleration = MISSING; speed = MISSING; height = MISSING; diff --git a/altoslib/AltosRecordMM.java b/altoslib/AltosRecordMM.java new file mode 100644 index 00000000..8b3d745a --- /dev/null +++ b/altoslib/AltosRecordMM.java @@ -0,0 +1,186 @@ +/* + * Copyright © 2012 Keith Packard + * + * 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; + +public class AltosRecordMM extends AltosRecord { + + public int accel; + public int pres; + public int temp; + + public int v_batt; + public int v_pyro; + public int sense[]; + + public int ground_accel; + public int ground_pres; + public int accel_plus_g; + public int accel_minus_g; + + public int flight_accel; + public int flight_vel; + public int flight_pres; + + public final static int num_sense = 6; + + public AltosIMU imu; + public AltosMag mag; + + static double adc(int raw) { + return raw / 4095.0; + } + + public double raw_pressure() { + if (pres != MISSING) + return pres / 100.0; + return MISSING; + } + + public double filtered_pressure() { + return raw_pressure(); + } + + public double ground_pressure() { + if (ground_pres != MISSING) + return ground_pres / 100.0; + return MISSING; + } + + public double battery_voltage() { + if (v_batt != MISSING) + return 3.3 * adc(v_batt) * 27.0 / (15.0 + 27.0); + return MISSING; + } + + static double pyro(int raw) { + if (raw != MISSING) + return 3.3 * adc(raw) * 27.0 / (100.0 + 27.0); + return MISSING; + } + + public double main_voltage() { + return pyro(sense[1]); + } + + public double drogue_voltage() { + return pyro(sense[0]); + } + + public double temperature() { + if (temp != MISSING) + return temp / 100.0; + return MISSING; + } + + public AltosIMU imu() { return imu; } + + public AltosMag mag() { return mag; } + + double accel_counts_per_mss() { + double counts_per_g = Math.abs(accel_minus_g - accel_plus_g) / 2; + + return counts_per_g / 9.80665; + } + + public double acceleration() { + System.out.printf("MM record acceleration %g ground_accel %d accel %d accel_minus_g %d accel_plus_g %d\n", + acceleration, ground_accel, accel, accel_minus_g, accel_plus_g); + if (acceleration != MISSING) + return acceleration; + + if (ground_accel == MISSING || accel == MISSING) + return MISSING; + + if (accel_minus_g == MISSING || accel_plus_g == MISSING) + return MISSING; + + return (ground_accel - accel) / accel_counts_per_mss(); + } + + public double accel_speed() { + return speed; + } + + public void copy (AltosRecordMM old) { + super.copy(old); + + accel = old.accel; + pres = old.pres; + temp = old.temp; + + v_batt = old.v_batt; + v_pyro = old.v_pyro; + sense = new int[num_sense]; + + for (int i = 0; i < num_sense; i++) + sense[i] = old.sense[i]; + + ground_accel = old.ground_accel; + ground_pres = old.ground_pres; + accel_plus_g = old.accel_plus_g; + accel_minus_g = old.accel_minus_g; + + flight_accel = old.flight_accel; + flight_vel = old.flight_vel; + flight_pres = old.flight_pres; + + imu = old.imu; + mag = old.mag; + } + + public AltosRecordMM clone() { + AltosRecordMM n = (AltosRecordMM) super.clone(); + n.copy(this); + return n; + } + + void make_missing() { + + accel = MISSING; + pres = MISSING; + temp = MISSING; + + v_batt = MISSING; + v_pyro = MISSING; + sense = new int[num_sense]; + for (int i = 0; i < num_sense; i++) + sense[i] = MISSING; + + ground_accel = MISSING; + ground_pres = MISSING; + accel_plus_g = MISSING; + accel_minus_g = MISSING; + + flight_accel = 0; + flight_vel = 0; + flight_pres = 0; + + imu = new AltosIMU(); + mag = new AltosMag(); + } + + public AltosRecordMM(AltosRecord old) { + super.copy(old); + make_missing(); + } + + public AltosRecordMM() { + super(); + make_missing(); + } +} diff --git a/altoslib/AltosRecordTM.java b/altoslib/AltosRecordTM.java new file mode 100644 index 00000000..afb70790 --- /dev/null +++ b/altoslib/AltosRecordTM.java @@ -0,0 +1,199 @@ +/* + * Copyright © 2012 Keith Packard + * + * 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; + +public class AltosRecordTM extends AltosRecord { + public int accel; + public int pres; + public int temp; + public int batt; + public int drogue; + public int main; + + public int ground_accel; + public int ground_pres; + public int accel_plus_g; + public int accel_minus_g; + + public int flight_accel; + public int flight_vel; + public int flight_pres; + + /* + * Values for our MP3H6115A pressure sensor + * + * From the data sheet: + * + * Pressure range: 15-115 kPa + * Voltage at 115kPa: 2.82 + * Output scale: 27mV/kPa + * + * + * 27 mV/kPa * 2047 / 3300 counts/mV = 16.75 counts/kPa + * 2.82V * 2047 / 3.3 counts/V = 1749 counts/115 kPa + */ + + static final double counts_per_kPa = 27 * 2047 / 3300; + static final double counts_at_101_3kPa = 1674.0; + + static double + barometer_to_pressure(double count) + { + return ((count / 16.0) / 2047.0 + 0.095) / 0.009 * 1000.0; + } + + public double raw_pressure() { + if (pres == MISSING) + return MISSING; + return barometer_to_pressure(pres); + } + + public double filtered_pressure() { + if (flight_pres == MISSING) + return MISSING; + return barometer_to_pressure(flight_pres); + } + + public double ground_pressure() { + if (ground_pres == MISSING) + return MISSING; + return barometer_to_pressure(ground_pres); + } + + public double battery_voltage() { + if (batt == MISSING) + return MISSING; + return AltosConvert.cc_battery_to_voltage(batt); + } + + public double main_voltage() { + if (main == MISSING) + return MISSING; + return AltosConvert.cc_ignitor_to_voltage(main); + } + + public double drogue_voltage() { + if (drogue == MISSING) + return MISSING; + return AltosConvert.cc_ignitor_to_voltage(drogue); + } + + /* Value for the CC1111 built-in temperature sensor + * Output voltage at 0°C = 0.755V + * Coefficient = 0.00247V/°C + * Reference voltage = 1.25V + * + * temp = ((value / 32767) * 1.25 - 0.755) / 0.00247 + * = (value - 19791.268) / 32768 * 1.25 / 0.00247 + */ + + static double + thermometer_to_temperature(double thermo) + { + return (thermo - 19791.268) / 32728.0 * 1.25 / 0.00247; + } + + public double temperature() { + if (temp == MISSING) + return MISSING; + return thermometer_to_temperature(temp); + } + + double accel_counts_per_mss() { + double counts_per_g = Math.abs(accel_minus_g - accel_plus_g) / 2; + + return counts_per_g / 9.80665; + } + + public double acceleration() { + if (acceleration != MISSING) + return acceleration; + + if (ground_accel == MISSING || accel == MISSING) + return MISSING; + return (ground_accel - accel) / accel_counts_per_mss(); + } + + public double accel_speed() { + if (speed != MISSING) + return speed; + if (flight_vel == MISSING) + return MISSING; + return flight_vel / (accel_counts_per_mss() * 100.0); + } + + public void copy(AltosRecordTM old) { + super.copy(old); + + version = old.version; + callsign = old.callsign; + serial = old.serial; + flight = old.flight; + rssi = old.rssi; + status = old.status; + state = old.state; + tick = old.tick; + accel = old.accel; + pres = old.pres; + temp = old.temp; + batt = old.batt; + drogue = old.drogue; + main = old.main; + flight_accel = old.flight_accel; + ground_accel = old.ground_accel; + flight_vel = old.flight_vel; + flight_pres = old.flight_pres; + ground_pres = old.ground_pres; + accel_plus_g = old.accel_plus_g; + accel_minus_g = old.accel_minus_g; + } + + public AltosRecordTM clone() { + AltosRecordTM n = (AltosRecordTM) super.clone(); + n.copy(this); + return n; + } + + void make_missing() { + accel = MISSING; + pres = MISSING; + temp = MISSING; + batt = MISSING; + drogue = MISSING; + main = MISSING; + + flight_accel = 0; + flight_vel = 0; + flight_pres = 0; + + ground_accel = 0; + ground_pres = 0; + accel_plus_g = 0; + accel_minus_g = 0; + } + + public AltosRecordTM(AltosRecord old) { + super.copy(old); + make_missing(); + } + + public AltosRecordTM() { + super(); + make_missing(); + } +} diff --git a/altoslib/AltosTelemetry.java b/altoslib/AltosTelemetry.java index 04abb1f3..ee244824 100644 --- a/altoslib/AltosTelemetry.java +++ b/altoslib/AltosTelemetry.java @@ -84,7 +84,7 @@ import java.util.HashMap; * */ -public class AltosTelemetry extends AltosRecord { +public abstract class AltosTelemetry extends AltosRecord { /* * General header fields diff --git a/altoslib/AltosTelemetryIterable.java b/altoslib/AltosTelemetryIterable.java index f4b4029f..e95c15e0 100644 --- a/altoslib/AltosTelemetryIterable.java +++ b/altoslib/AltosTelemetryIterable.java @@ -45,7 +45,7 @@ public class AltosTelemetryIterable extends AltosRecordIterable { try { for (;;) { - String line = AltosRecord.gets(input); + String line = AltosLib.gets(input); if (line == null) { break; } @@ -67,11 +67,11 @@ public class AltosTelemetryIterable extends AltosRecordIterable { saw_boost = true; boost_tick = record.tick; } - if (record.accel != AltosRecord.MISSING) + if (record.acceleration() != AltosRecord.MISSING) has_accel = true; if (record.gps != null) has_gps = true; - if (record.main != AltosRecord.MISSING) + if (record.main_voltage() != AltosRecord.MISSING) has_ignite = true; if (previous != null && previous.tick != record.tick) records.add(previous); diff --git a/altoslib/AltosTelemetryRecord.java b/altoslib/AltosTelemetryRecord.java index 6b6a252d..6a8cfd35 100644 --- a/altoslib/AltosTelemetryRecord.java +++ b/altoslib/AltosTelemetryRecord.java @@ -43,6 +43,7 @@ public abstract class AltosTelemetryRecord { final static int packet_type_satellite = 0x06; final static int packet_type_companion = 0x07; final static int packet_type_MM_sensor = 0x08; + final static int packet_type_MM_data = 0x09; static AltosTelemetryRecord parse_hex(String hex) throws ParseException, AltosCRCException { AltosTelemetryRecord r; @@ -76,7 +77,6 @@ public abstract class AltosTelemetryRecord { case packet_type_TM_sensor: case packet_type_Tm_sensor: case packet_type_Tn_sensor: - case packet_type_MM_sensor: r = new AltosTelemetryRecordSensor(bytes, rssi); break; case packet_type_configuration: @@ -91,6 +91,12 @@ public abstract class AltosTelemetryRecord { case packet_type_companion: r = new AltosTelemetryRecordCompanion(bytes); break; + case packet_type_MM_sensor: + r = new AltosTelemetryRecordMegaSensor(bytes, rssi); + break; + case packet_type_MM_data: + r = new AltosTelemetryRecordMegaData(bytes); + break; default: r = new AltosTelemetryRecordRaw(bytes); break; diff --git a/altoslib/AltosTelemetryRecordLegacy.java b/altoslib/AltosTelemetryRecordLegacy.java index 85071d9c..3976a07a 100644 --- a/altoslib/AltosTelemetryRecordLegacy.java +++ b/altoslib/AltosTelemetryRecordLegacy.java @@ -232,7 +232,7 @@ public class AltosTelemetryRecordLegacy extends AltosTelemetryRecord { final static String AO_TELEM_SAT_SVID = "s_v"; final static String AO_TELEM_SAT_C_N_0 = "s_c"; - AltosRecord record; + AltosRecordTM record; private void parse_v4(String[] words, int i) throws ParseException { AltosTelemetryMap map = new AltosTelemetryMap(words, i); @@ -366,7 +366,7 @@ public class AltosTelemetryRecordLegacy extends AltosTelemetryRecord { String[] words = line.split("\\s+"); int i = 0; - record = new AltosRecord(); + record = new AltosRecordTM(); if (words[i].equals("CRC") && words[i+1].equals("INVALID")) { i += 2; @@ -388,7 +388,7 @@ public class AltosTelemetryRecordLegacy extends AltosTelemetryRecord { } /* - * Given a hex dump of a legacy telemetry line, construct an AltosRecord from that + * Given a hex dump of a legacy telemetry line, construct an AltosRecordTM from that */ int[] bytes; @@ -422,7 +422,7 @@ public class AltosTelemetryRecordLegacy extends AltosTelemetryRecord { static final int AO_GPS_COURSE_VALID = (1 << 7); public AltosTelemetryRecordLegacy(int[] in_bytes, int in_rssi, int in_status) { - record = new AltosRecord(); + record = new AltosRecordTM(); bytes = in_bytes; record.version = 4; diff --git a/altoslib/AltosTelemetryRecordMegaData.java b/altoslib/AltosTelemetryRecordMegaData.java new file mode 100644 index 00000000..cc35cd83 --- /dev/null +++ b/altoslib/AltosTelemetryRecordMegaData.java @@ -0,0 +1,96 @@ +/* + * Copyright © 2011 Keith Packard + * + * 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; + + +public class AltosTelemetryRecordMegaData extends AltosTelemetryRecordRaw { + + int state; + + int v_batt; + int v_pyro; + int sense[]; + + int ground_pres; + int ground_accel; + int accel_plus_g; + int accel_minus_g; + + int acceleration; + int speed; + int height; + + public AltosTelemetryRecordMegaData(int[] in_bytes) { + super(in_bytes); + + state = int8(5); + + v_batt = int16(6); + v_pyro = int16(8); + + sense = new int[6]; + + for (int i = 0; i < 6; i++) { + sense[i] = int8(10 + i) << 4; + sense[i] |= sense[i] >> 8; + } + + ground_pres = int32(16); + ground_accel = int16(20); + accel_plus_g = int16(22); + accel_minus_g = int16(24); + + acceleration = int16(26); + speed = int16(28); + height = int16(30); + } + + public AltosRecord update_state(AltosRecord previous) { + AltosRecord n = super.update_state(previous); + + AltosRecordMM next; + if (!(n instanceof AltosRecordMM)) { + System.out.printf("data making record MM\n"); + next = new AltosRecordMM(n); + } else { + System.out.printf ("data already has MM\n"); + next = (AltosRecordMM) n; + } + + next.state = state; + + next.v_batt = v_batt; + next.v_pyro = v_pyro; + + for (int i = 0; i < 6; i++) + next.sense[i] = sense[i]; + + next.ground_accel = ground_accel; + next.ground_pres = ground_pres; + next.accel_plus_g = accel_plus_g; + next.accel_minus_g = accel_minus_g; + + next.acceleration = acceleration / 16.0; + next.speed = speed / 16.0; + next.height = height; + + next.seen |= AltosRecord.seen_flight | AltosRecord.seen_temp_volt; + + return next; + } +} diff --git a/altoslib/AltosTelemetryRecordMegaSensor.java b/altoslib/AltosTelemetryRecordMegaSensor.java new file mode 100644 index 00000000..85a32d12 --- /dev/null +++ b/altoslib/AltosTelemetryRecordMegaSensor.java @@ -0,0 +1,98 @@ +/* + * Copyright © 2011 Keith Packard + * + * 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; + + +public class AltosTelemetryRecordMegaSensor extends AltosTelemetryRecordRaw { + int accel; + int pres; + int temp; + + int accel_x; + int accel_y; + int accel_z; + + int gyro_x; + int gyro_y; + int gyro_z; + + int mag_x; + int mag_y; + int mag_z; + + int rssi; + + public AltosTelemetryRecordMegaSensor(int[] in_bytes, int in_rssi) { + super(in_bytes); + + accel = int16(6); + pres = int32(8); + temp = int16(12); + + accel_x = int16(14); + accel_y = int16(16); + accel_z = int16(18); + + gyro_x = int16(20); + gyro_y = int16(22); + gyro_z = int16(24); + + mag_x = int16(26); + mag_y = int16(28); + mag_z = int16(30); + + rssi = in_rssi; + System.out.printf ("telem record accel: %d\n", accel); + } + + public AltosRecord update_state(AltosRecord previous) { + AltosRecord n = super.update_state(previous); + + AltosRecordMM next; + if (!(n instanceof AltosRecordMM)) { + System.out.printf("sensor making MM\n"); + next = new AltosRecordMM(n); + } else { + System.out.printf("sensor has MM\n"); + next = (AltosRecordMM) n; + } + + System.out.printf("telem update_state accel: %d\n", accel); + next.accel = accel; + next.pres = pres; + next.temp = temp; + + next.imu.accel_x = accel_x; + next.imu.accel_y = accel_y; + next.imu.accel_z = accel_z; + + next.imu.gyro_x = gyro_x; + next.imu.gyro_y = gyro_y; + next.imu.gyro_z = gyro_z; + + next.mag.x = mag_x; + next.mag.y = mag_y; + next.mag.z = mag_z; + + next.rssi = rssi; + + next.seen |= AltosRecord.seen_sensor; + + return next; + } +} diff --git a/altoslib/AltosTelemetryRecordRaw.java b/altoslib/AltosTelemetryRecordRaw.java index 43d0f17a..dc1b8947 100644 --- a/altoslib/AltosTelemetryRecordRaw.java +++ b/altoslib/AltosTelemetryRecordRaw.java @@ -49,6 +49,10 @@ public class AltosTelemetryRecordRaw extends AltosTelemetryRecord { return AltosLib.uint32(bytes, off + 1); } + public int int32(int off) { + return AltosLib.int32(bytes, off + 1); + } + public String string(int off, int l) { return AltosLib.string(bytes, off + 1, l); } @@ -63,7 +67,7 @@ public class AltosTelemetryRecordRaw extends AltosTelemetryRecord { public AltosRecord update_state(AltosRecord previous) { AltosRecord next; if (previous != null) - next = new AltosRecord(previous); + next = previous.clone(); else next = new AltosRecord(); next.serial = serial; diff --git a/altoslib/AltosTelemetryRecordSensor.java b/altoslib/AltosTelemetryRecordSensor.java index cfaf90b0..319a91b3 100644 --- a/altoslib/AltosTelemetryRecordSensor.java +++ b/altoslib/AltosTelemetryRecordSensor.java @@ -61,8 +61,14 @@ public class AltosTelemetryRecordSensor extends AltosTelemetryRecordRaw { rssi = in_rssi; } - public AltosRecord update_state(AltosRecord previous) { - AltosRecord next = super.update_state(previous); + public AltosRecord update_state(AltosRecord prev) { + AltosRecord n = super.update_state(prev); + + AltosRecordTM next; + if (!(n instanceof AltosRecordTM)) + next = new AltosRecordTM(n); + else + next = (AltosRecordTM) n; next.state = state; if (type == packet_type_TM_sensor) diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am index f644d46a..ac97c9cb 100644 --- a/altoslib/Makefile.am +++ b/altoslib/Makefile.am @@ -35,6 +35,8 @@ AltosLib_JAVA = \ $(SRC)/AltosRecordCompanion.java \ $(SRC)/AltosRecordIterable.java \ $(SRC)/AltosRecord.java \ + $(SRC)/AltosRecordTM.java \ + $(SRC)/AltosRecordMM.java \ $(SRC)/AltosReplayReader.java \ $(SRC)/AltosState.java \ $(SRC)/AltosTelemetry.java \ @@ -50,6 +52,8 @@ AltosLib_JAVA = \ $(SRC)/AltosTelemetryRecordRaw.java \ $(SRC)/AltosTelemetryRecordSatellite.java \ $(SRC)/AltosTelemetryRecordSensor.java \ + $(SRC)/AltosTelemetryRecordMegaSensor.java \ + $(SRC)/AltosTelemetryRecordMegaData.java \ $(SRC)/AltosMs5607.java \ $(SRC)/AltosIMU.java \ $(SRC)/AltosMag.java diff --git a/altosui/AltosCSV.java b/altosui/AltosCSV.java index be86a454..c876d9ca 100644 --- a/altosui/AltosCSV.java +++ b/altosui/AltosCSV.java @@ -146,8 +146,8 @@ public class AltosCSV implements AltosWriter { } void write_advanced(AltosRecord record) { - AltosIMU imu = record.imu; - AltosMag mag = record.mag; + AltosIMU imu = record.imu(); + AltosMag mag = record.mag(); if (imu == null) imu = new AltosIMU(); @@ -263,7 +263,7 @@ public class AltosCSV implements AltosWriter { write_general(record); out.printf(","); write_flight(record); out.printf(","); write_basic(record); out.printf(","); - if (record.imu != null || record.mag != null) + if (record.imu() != null || record.mag() != null) write_advanced(record); if (record.gps != null) { out.printf(","); @@ -287,7 +287,7 @@ public class AltosCSV implements AltosWriter { if (record.state == Altos.ao_flight_startup) return; if (!header_written) { - write_header(record.imu != null || record.mag != null, + write_header(record.imu() != null || record.mag() != null, record.gps != null, record.companion != null); header_written = true; } diff --git a/altosui/AltosIdleMonitorUI.java b/altosui/AltosIdleMonitorUI.java index 2ee90937..949e3926 100644 --- a/altosui/AltosIdleMonitorUI.java +++ b/altosui/AltosIdleMonitorUI.java @@ -204,17 +204,18 @@ class AltosIdleMonitor extends Thread { record.state = Altos.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.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; -- cgit v1.2.3 From 20bc23ddb90f8a6da1f7ea70f02cf3a038059d32 Mon Sep 17 00:00:00 2001 From: Mike Beattie Date: Fri, 7 Sep 2012 17:32:07 +1200 Subject: altoslib: Remove un-needed imports Signed-off-by: Mike Beattie --- altoslib/AltosConfigData.java | 3 --- altoslib/AltosEepromChunk.java | 2 -- altoslib/AltosEepromIterable.java | 2 -- altoslib/AltosEepromLog.java | 3 --- altoslib/AltosEepromMega.java | 4 ---- altoslib/AltosEepromMegaIterable.java | 2 -- altoslib/AltosEepromRecord.java | 4 ---- altoslib/AltosEepromTeleScience.java | 4 ---- altoslib/AltosFile.java | 1 - altoslib/AltosFlightReader.java | 1 - altoslib/AltosFrequency.java | 4 ---- altoslib/AltosGPS.java | 1 - altoslib/AltosIdleMonitor.java | 3 --- altoslib/AltosIdleMonitorListener.java | 6 ------ altoslib/AltosIdleRecordTM.java | 4 ---- altoslib/AltosLib.java | 2 -- altoslib/AltosLink.java | 2 -- altoslib/AltosLog.java | 2 -- altoslib/AltosParse.java | 1 - altoslib/AltosPreferences.java | 4 ---- altoslib/AltosRecord.java | 5 ----- altoslib/AltosReplayReader.java | 3 --- altoslib/AltosTelemetry.java | 2 -- altoslib/AltosTelemetryMap.java | 1 - altoslib/AltosTelemetryReader.java | 1 - altoslib/AltosTelemetryRecordGeneral.java | 2 -- altoslib/AltosTelemetryRecordLegacy.java | 2 -- altoslib/AltosTelemetryRecordRaw.java | 4 ---- 28 files changed, 75 deletions(-) (limited to 'altoslib/AltosTelemetry.java') diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index ecc2d0aa..c6e92e62 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -17,12 +17,9 @@ 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 { diff --git a/altoslib/AltosEepromChunk.java b/altoslib/AltosEepromChunk.java index 6d889723..77b22fe2 100644 --- a/altoslib/AltosEepromChunk.java +++ b/altoslib/AltosEepromChunk.java @@ -17,8 +17,6 @@ package org.altusmetrum.AltosLib; -import java.io.*; -import java.util.*; import java.text.*; import java.util.concurrent.*; diff --git a/altoslib/AltosEepromIterable.java b/altoslib/AltosEepromIterable.java index f8acdc16..fc308c34 100644 --- a/altoslib/AltosEepromIterable.java +++ b/altoslib/AltosEepromIterable.java @@ -20,8 +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 diff --git a/altoslib/AltosEepromLog.java b/altoslib/AltosEepromLog.java index 7fca4bd9..e27c382a 100644 --- a/altoslib/AltosEepromLog.java +++ b/altoslib/AltosEepromLog.java @@ -17,10 +17,7 @@ package org.altusmetrum.AltosLib; -import java.io.*; -import java.util.*; import java.text.*; -import java.util.prefs.*; import java.util.concurrent.*; /* diff --git a/altoslib/AltosEepromMega.java b/altoslib/AltosEepromMega.java index 2628279e..26bacf8d 100644 --- a/altoslib/AltosEepromMega.java +++ b/altoslib/AltosEepromMega.java @@ -17,11 +17,7 @@ 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; diff --git a/altoslib/AltosEepromMegaIterable.java b/altoslib/AltosEepromMegaIterable.java index f62cc45b..be20ba63 100644 --- a/altoslib/AltosEepromMegaIterable.java +++ b/altoslib/AltosEepromMegaIterable.java @@ -20,8 +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 diff --git a/altoslib/AltosEepromRecord.java b/altoslib/AltosEepromRecord.java index 1e845f46..c7ced6a3 100644 --- a/altoslib/AltosEepromRecord.java +++ b/altoslib/AltosEepromRecord.java @@ -17,11 +17,7 @@ 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; diff --git a/altoslib/AltosEepromTeleScience.java b/altoslib/AltosEepromTeleScience.java index 1758fa34..02ce4553 100644 --- a/altoslib/AltosEepromTeleScience.java +++ b/altoslib/AltosEepromTeleScience.java @@ -17,11 +17,7 @@ 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; diff --git a/altoslib/AltosFile.java b/altoslib/AltosFile.java index d2e4f2f7..1ab00b38 100644 --- a/altoslib/AltosFile.java +++ b/altoslib/AltosFile.java @@ -17,7 +17,6 @@ package org.altusmetrum.AltosLib; -import java.lang.*; import java.io.File; import java.util.*; diff --git a/altoslib/AltosFlightReader.java b/altoslib/AltosFlightReader.java index 3fdea469..cbd64153 100644 --- a/altoslib/AltosFlightReader.java +++ b/altoslib/AltosFlightReader.java @@ -17,7 +17,6 @@ package org.altusmetrum.AltosLib; -import java.lang.*; import java.text.*; import java.io.*; import java.util.concurrent.*; diff --git a/altoslib/AltosFrequency.java b/altoslib/AltosFrequency.java index f08ff116..e20f03b7 100644 --- a/altoslib/AltosFrequency.java +++ b/altoslib/AltosFrequency.java @@ -17,10 +17,6 @@ package org.altusmetrum.AltosLib; -import java.io.*; -import java.util.*; -import java.text.*; - public class AltosFrequency { public double frequency; public String description; diff --git a/altoslib/AltosGPS.java b/altoslib/AltosGPS.java index f078a469..2c2fd36b 100644 --- a/altoslib/AltosGPS.java +++ b/altoslib/AltosGPS.java @@ -17,7 +17,6 @@ package org.altusmetrum.AltosLib; -import java.lang.*; import java.text.*; public class AltosGPS { diff --git a/altoslib/AltosIdleMonitor.java b/altoslib/AltosIdleMonitor.java index 27ea3a2b..d83c4450 100644 --- a/altoslib/AltosIdleMonitor.java +++ b/altoslib/AltosIdleMonitor.java @@ -18,9 +18,6 @@ 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 { diff --git a/altoslib/AltosIdleMonitorListener.java b/altoslib/AltosIdleMonitorListener.java index 3c18bfaa..9f9ababf 100644 --- a/altoslib/AltosIdleMonitorListener.java +++ b/altoslib/AltosIdleMonitorListener.java @@ -17,12 +17,6 @@ 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 index 112b847e..d48ff7e4 100644 --- a/altoslib/AltosIdleRecordTM.java +++ b/altoslib/AltosIdleRecordTM.java @@ -17,10 +17,6 @@ package org.altusmetrum.AltosLib; -import java.io.*; -import java.util.*; -import java.text.*; -import java.util.prefs.*; import java.util.concurrent.*; class AltosADCTM { diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java index 2402331e..8d383f12 100644 --- a/altoslib/AltosLib.java +++ b/altoslib/AltosLib.java @@ -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; diff --git a/altoslib/AltosLink.java b/altoslib/AltosLink.java index 415c3c64..6d510563 100644 --- a/altoslib/AltosLink.java +++ b/altoslib/AltosLink.java @@ -17,11 +17,9 @@ 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 { diff --git a/altoslib/AltosLog.java b/altoslib/AltosLog.java index 55a25bb4..3c124700 100644 --- a/altoslib/AltosLog.java +++ b/altoslib/AltosLog.java @@ -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; diff --git a/altoslib/AltosParse.java b/altoslib/AltosParse.java index 7d832f1a..e938a177 100644 --- a/altoslib/AltosParse.java +++ b/altoslib/AltosParse.java @@ -18,7 +18,6 @@ package org.altusmetrum.AltosLib; import java.text.*; -import java.lang.*; public class AltosParse { public static boolean isdigit(char c) { diff --git a/altoslib/AltosPreferences.java b/altoslib/AltosPreferences.java index 9ab80cf5..13fee46d 100644 --- a/altoslib/AltosPreferences.java +++ b/altoslib/AltosPreferences.java @@ -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 { diff --git a/altoslib/AltosRecord.java b/altoslib/AltosRecord.java index 8722bc05..dd741716 100644 --- a/altoslib/AltosRecord.java +++ b/altoslib/AltosRecord.java @@ -17,11 +17,6 @@ package org.altusmetrum.AltosLib; -import java.lang.*; -import java.text.*; -import java.util.HashMap; -import java.io.*; - public class AltosRecord implements Comparable , Cloneable { public static final int seen_flight = 1; diff --git a/altoslib/AltosReplayReader.java b/altoslib/AltosReplayReader.java index 1585f9eb..50bef07a 100644 --- a/altoslib/AltosReplayReader.java +++ b/altoslib/AltosReplayReader.java @@ -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/AltosTelemetry.java b/altoslib/AltosTelemetry.java index ee244824..15534158 100644 --- a/altoslib/AltosTelemetry.java +++ b/altoslib/AltosTelemetry.java @@ -17,9 +17,7 @@ package org.altusmetrum.AltosLib; -import java.lang.*; import java.text.*; -import java.util.HashMap; /* * Telemetry data contents diff --git a/altoslib/AltosTelemetryMap.java b/altoslib/AltosTelemetryMap.java index 003cb6a9..bc1486d8 100644 --- a/altoslib/AltosTelemetryMap.java +++ b/altoslib/AltosTelemetryMap.java @@ -16,7 +16,6 @@ */ package org.altusmetrum.AltosLib; -import java.lang.*; import java.text.*; import java.util.HashMap; diff --git a/altoslib/AltosTelemetryReader.java b/altoslib/AltosTelemetryReader.java index bdb44eef..94fa560b 100644 --- a/altoslib/AltosTelemetryReader.java +++ b/altoslib/AltosTelemetryReader.java @@ -17,7 +17,6 @@ package org.altusmetrum.AltosLib; -import java.lang.*; import java.text.*; import java.io.*; import java.util.concurrent.*; diff --git a/altoslib/AltosTelemetryRecordGeneral.java b/altoslib/AltosTelemetryRecordGeneral.java index 5e157a54..a53280cf 100644 --- a/altoslib/AltosTelemetryRecordGeneral.java +++ b/altoslib/AltosTelemetryRecordGeneral.java @@ -17,9 +17,7 @@ package org.altusmetrum.AltosLib; -import java.lang.*; import java.text.*; -import java.util.HashMap; public class AltosTelemetryRecordGeneral { diff --git a/altoslib/AltosTelemetryRecordLegacy.java b/altoslib/AltosTelemetryRecordLegacy.java index 3976a07a..b11fed58 100644 --- a/altoslib/AltosTelemetryRecordLegacy.java +++ b/altoslib/AltosTelemetryRecordLegacy.java @@ -17,9 +17,7 @@ package org.altusmetrum.AltosLib; -import java.lang.*; import java.text.*; -import java.util.HashMap; /* * Telemetry data contents diff --git a/altoslib/AltosTelemetryRecordRaw.java b/altoslib/AltosTelemetryRecordRaw.java index dc1b8947..fbb373d5 100644 --- a/altoslib/AltosTelemetryRecordRaw.java +++ b/altoslib/AltosTelemetryRecordRaw.java @@ -17,10 +17,6 @@ package org.altusmetrum.AltosLib; -import java.lang.*; -import java.text.*; -import java.util.HashMap; - public class AltosTelemetryRecordRaw extends AltosTelemetryRecord { int[] bytes; int serial; -- cgit v1.2.3