2 * Copyright © 2013 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.
20 import org.altusmetrum.altosuilib_1.*;
21 import org.altusmetrum.altoslib_3.*;
23 public class AltosGraphDataPoint implements AltosUIDataPoint {
27 public static final int data_height = 0;
28 public static final int data_speed = 1;
29 public static final int data_accel = 2;
30 public static final int data_temp = 3;
31 public static final int data_battery_voltage = 4;
32 public static final int data_drogue_voltage = 5;
33 public static final int data_main_voltage = 6;
34 public static final int data_rssi = 7;
35 public static final int data_state = 8;
36 public static final int data_gps_height = 9;
37 public static final int data_gps_nsat_solution = 10;
38 public static final int data_gps_nsat_view = 11;
39 public static final int data_temperature = 12;
40 public static final int data_range = 13;
41 public static final int data_distance = 14;
42 public static final int data_pressure = 15;
43 public static final int data_accel_x = 16;
44 public static final int data_accel_y = 17;
45 public static final int data_accel_z = 18;
46 public static final int data_gyro_x = 19;
47 public static final int data_gyro_y = 20;
48 public static final int data_gyro_z = 21;
49 public static final int data_mag_x = 22;
50 public static final int data_mag_y = 23;
51 public static final int data_mag_z = 24;
52 public static final int data_orient = 25;
54 public double x() throws AltosUIDataMissing {
55 double time = state.time_since_boost();
57 throw new AltosUIDataMissing(-1);
61 public double y(int index) throws AltosUIDataMissing {
62 double y = AltosLib.MISSING;
71 y = state.acceleration();
74 y = state.temperature;
76 case data_battery_voltage:
77 y = state.battery_voltage;
79 case data_drogue_voltage:
80 y = state.apogee_voltage;
82 case data_main_voltage:
83 y = state.main_voltage;
91 case data_gps_nsat_solution:
92 if (state.gps != null)
95 case data_gps_nsat_view:
96 if (state.gps != null && state.gps.cc_gps_sat != null)
97 y = state.gps.cc_gps_sat.length;
99 case data_temperature:
100 y = state.temperature;
106 if (state.from_pad != null)
107 y = state.from_pad.distance;
110 y = state.pressure();
119 AltosIMU imu = state.imu;
146 AltosMag mag = state.mag;
165 if (y == AltosLib.MISSING)
166 throw new AltosUIDataMissing(index);
170 public int id(int index) {
171 if (index == data_state) {
173 if (s < Altos.ao_flight_boost || s > Altos.ao_flight_landed)
180 public String id_name(int index) {
181 if (index == data_state)
182 return state.state_name();
186 public AltosGraphDataPoint (AltosState state) {