2 * Copyright © 2010 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
18 package org.altusmetrum.AltosLib;
20 public abstract class AltosRecord implements Comparable <AltosRecord>, Cloneable {
22 public static final int seen_flight = 1;
23 public static final int seen_sensor = 2;
24 public static final int seen_temp_volt = 4;
25 public static final int seen_deploy = 8;
26 public static final int seen_gps_time = 16;
27 public static final int seen_gps_lat = 32;
28 public static final int seen_gps_lon = 64;
29 public static final int seen_companion = 128;
33 public final static int MISSING = 0x7fffffff;
35 /* Every AltosRecord implementation provides these fields */
38 public String callsign;
47 public boolean new_gps;
49 public double time; /* seconds since boost */
51 public int device_type;
52 public int config_major;
53 public int config_minor;
54 public int apogee_delay;
55 public int main_deploy;
56 public int flight_log_max;
57 public String firmware_version;
59 public AltosRecordCompanion companion;
61 /* Telemetry sources have these values recorded from the flight computer */
62 public double kalman_height;
63 public double kalman_speed;
64 public double kalman_acceleration;
67 * Abstract methods that convert record data
78 abstract public double pressure();
79 abstract public double ground_pressure();
80 abstract public double acceleration();
82 public double altitude() {
83 double p = pressure();
87 return AltosConvert.pressure_to_altitude(p);
90 public double ground_altitude() {
91 double p = ground_pressure();
95 return AltosConvert.pressure_to_altitude(p);
98 public double height() {
99 double g = ground_altitude();
100 double a = altitude();
109 public double battery_voltage() { return MISSING; }
111 public double main_voltage() { return MISSING; }
113 public double drogue_voltage() { return MISSING; }
115 public double temperature() { return MISSING; }
117 public AltosIMU imu() { return null; }
119 public AltosMag mag() { return null; }
121 public String state() {
122 return AltosLib.state_name(state);
125 public int compareTo(AltosRecord o) {
126 return tick - o.tick;
129 abstract public AltosRecord clone();
131 public void copy(AltosRecord old) {
133 version = old.version;
134 callsign = old.callsign;
141 gps = new AltosGPS(old.gps);
142 new_gps = old.new_gps;
143 companion = old.companion;
144 kalman_acceleration = old.kalman_acceleration;
145 kalman_speed = old.kalman_speed;
146 kalman_height = old.kalman_height;
149 public AltosRecord() {
157 state = AltosLib.ao_flight_startup;
159 gps = new AltosGPS();
163 kalman_acceleration = MISSING;
164 kalman_speed = MISSING;
165 kalman_height = MISSING;