2 * Copyright © 2012 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 class AltosRecordMM extends AltosRecord {
30 public int ground_accel;
31 public int ground_pres;
32 public int accel_plus_g;
33 public int accel_minus_g;
35 public int flight_accel;
36 public int flight_vel;
37 public int flight_pres;
39 public final static int num_sense = 6;
44 static double adc(int raw) {
48 public double raw_pressure() {
54 public double filtered_pressure() {
55 return raw_pressure();
58 public double ground_pressure() {
59 if (ground_pres != MISSING)
64 public double battery_voltage() {
65 if (v_batt != MISSING)
66 return 3.3 * adc(v_batt) * (15.0 + 27.0) / 27.0;
70 static double pyro(int raw) {
72 return 3.3 * adc(raw) * (100.0 + 27.0) / 27.0;
76 public double main_voltage() {
77 return pyro(sense[1]);
80 public double drogue_voltage() {
81 return pyro(sense[0]);
84 public double temperature() {
90 public AltosIMU imu() { return imu; }
92 public AltosMag mag() { return mag; }
94 double accel_counts_per_mss() {
95 double counts_per_g = Math.abs(accel_minus_g - accel_plus_g) / 2;
97 return counts_per_g / 9.80665;
100 public double acceleration() {
101 if (acceleration != MISSING)
104 if (ground_accel == MISSING || accel == MISSING)
107 if (accel_minus_g == MISSING || accel_plus_g == MISSING)
110 return (ground_accel - accel) / accel_counts_per_mss();
113 public double accel_speed() {
114 if (speed != MISSING)
116 if (flight_vel == MISSING)
118 return flight_vel / (accel_counts_per_mss() * 100.0);
121 public void copy (AltosRecordMM old) {
130 sense = new int[num_sense];
132 for (int i = 0; i < num_sense; i++)
133 sense[i] = old.sense[i];
135 ground_accel = old.ground_accel;
136 ground_pres = old.ground_pres;
137 accel_plus_g = old.accel_plus_g;
138 accel_minus_g = old.accel_minus_g;
140 flight_accel = old.flight_accel;
141 flight_vel = old.flight_vel;
142 flight_pres = old.flight_pres;
148 public AltosRecordMM clone() {
149 AltosRecordMM n = (AltosRecordMM) super.clone();
154 void make_missing() {
162 sense = new int[num_sense];
163 for (int i = 0; i < num_sense; i++)
166 ground_accel = MISSING;
167 ground_pres = MISSING;
168 accel_plus_g = MISSING;
169 accel_minus_g = MISSING;
175 imu = new AltosIMU();
176 mag = new AltosMag();
179 public AltosRecordMM(AltosRecord old) {
184 public AltosRecordMM() {