Switch from GPLv2 to GPLv2+
[fw/altos] / altosuilib / AltosGraphDataPoint.java
index a64a9d1437fa57dca3ebaefb16f15267aef9ae9b..0012d96a145598bc6128d0e85d7328e7809d5ef8 100644 (file)
@@ -3,7 +3,8 @@
  *
  * 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.
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,9 +16,9 @@
  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  */
 
-package org.altusmetrum.altosuilib_2;
+package org.altusmetrum.altosuilib_11;
 
-import org.altusmetrum.altoslib_4.*;
+import org.altusmetrum.altoslib_11.*;
 
 public class AltosGraphDataPoint implements AltosUIDataPoint {
 
@@ -35,24 +36,28 @@ public class AltosGraphDataPoint implements AltosUIDataPoint {
        public static final int data_gps_height = 9;
        public static final int data_gps_nsat_solution = 10;
        public static final int data_gps_nsat_view = 11;
-       public static final int data_temperature = 12;
-       public static final int data_range = 13;
-       public static final int data_distance = 14;
-       public static final int data_pressure = 15;
-       public static final int data_accel_x = 16;
-       public static final int data_accel_y = 17;
-       public static final int data_accel_z = 18;
-       public static final int data_gyro_x = 19;
-       public static final int data_gyro_y = 20;
-       public static final int data_gyro_z = 21;
-       public static final int data_mag_x = 22;
-       public static final int data_mag_y = 23;
-       public static final int data_mag_z = 24;
-       public static final int data_orient = 25;
-       public static final int data_gps_course = 26;
-       public static final int data_gps_ground_speed = 27;
-       public static final int data_gps_climb_rate = 28;
-       public static final int data_ignitor_0 = 29;
+       public static final int data_gps_altitude = 12;
+       public static final int data_temperature = 13;
+       public static final int data_range = 14;
+       public static final int data_distance = 15;
+       public static final int data_pressure = 16;
+       public static final int data_accel_along = 17;
+       public static final int data_accel_across = 18;
+       public static final int data_accel_through = 19;
+       public static final int data_gyro_roll = 20;
+       public static final int data_gyro_pitch = 21;
+       public static final int data_gyro_yaw = 22;
+       public static final int data_mag_along = 23;
+       public static final int data_mag_across = 24;
+       public static final int data_mag_through = 25;
+       public static final int data_orient = 26;
+       public static final int data_gps_course = 27;
+       public static final int data_gps_ground_speed = 28;
+       public static final int data_gps_climb_rate = 29;
+       public static final int data_gps_pdop = 30;
+       public static final int data_gps_hdop = 31;
+       public static final int data_gps_vdop = 32;
+       public static final int data_ignitor_0 = 33;
        public static final int data_ignitor_num = 32;
        public static final int data_ignitor_max = data_ignitor_0 + data_ignitor_num - 1;
        public static final int data_ignitor_fired_0 = data_ignitor_0 + data_ignitor_num;
@@ -100,8 +105,15 @@ public class AltosGraphDataPoint implements AltosUIDataPoint {
                                y = state.gps.nsat;
                        break;
                case data_gps_nsat_view:
-                       if (state.gps != null && state.gps.cc_gps_sat != null)
-                               y = state.gps.cc_gps_sat.length;
+                       if (state.gps != null) {
+                               if (state.gps.cc_gps_sat != null)
+                                       y = state.gps.cc_gps_sat.length;
+                               else
+                                       y = 0;
+                       }
+                       break;
+               case data_gps_altitude:
+                       y = state.gps_altitude();
                        break;
                case data_temperature:
                        y = state.temperature;
@@ -117,53 +129,32 @@ public class AltosGraphDataPoint implements AltosUIDataPoint {
                        y = state.pressure();
                        break;
 
-               case data_accel_x:
-               case data_accel_y:
-               case data_accel_z:
-               case data_gyro_x:
-               case data_gyro_y:
-               case data_gyro_z:
-                       AltosIMU        imu = state.imu;
-                       if (imu == null)
-                               break;
-                       switch (index) {
-                       case data_accel_x:
-                               y = imu.accel_x;
-                               break;
-                       case data_accel_y:
-                               y = imu.accel_y;
-                               break;
-                       case data_accel_z:
-                               y = imu.accel_z;
-                               break;
-                       case data_gyro_x:
-                               y = imu.gyro_x;
-                               break;
-                       case data_gyro_y:
-                               y = imu.gyro_y;
-                               break;
-                       case data_gyro_z:
-                               y = imu.gyro_z;
-                               break;
-                       }
+               case data_accel_along:
+                       y = state.accel_along();
                        break;
-               case data_mag_x:
-               case data_mag_y:
-               case data_mag_z:
-                       AltosMag        mag = state.mag;
-                       if (mag == null)
-                               break;
-                       switch (index) {
-                       case data_mag_x:
-                               y = mag.x;
-                               break;
-                       case data_mag_y:
-                               y = mag.y;
-                               break;
-                       case data_mag_z:
-                               y = mag.z;
-                               break;
-                       }
+               case data_accel_across:
+                       y = state.accel_across();
+                       break;
+               case data_accel_through:
+                       y = state.accel_through();
+                       break;
+               case data_gyro_roll:
+                       y = state.gyro_roll();
+                       break;
+               case data_gyro_pitch:
+                       y = state.gyro_pitch();
+                       break;
+               case data_gyro_yaw:
+                       y = state.gyro_yaw();
+                       break;
+               case data_mag_along:
+                       y = state.mag_along();
+                       break;
+               case data_mag_across:
+                       y = state.mag_across();
+                       break;
+               case data_mag_through:
+                       y = state.mag_through();
                        break;
                case data_orient:
                        y = state.orient();
@@ -186,6 +177,24 @@ public class AltosGraphDataPoint implements AltosUIDataPoint {
                        else
                                y = AltosLib.MISSING;
                        break;
+               case data_gps_pdop:
+                       if (state.gps != null)
+                               y = state.gps.pdop;
+                       else
+                               y = AltosLib.MISSING;
+                       break;
+               case data_gps_hdop:
+                       if (state.gps != null)
+                               y = state.gps.hdop;
+                       else
+                               y = AltosLib.MISSING;
+                       break;
+               case data_gps_vdop:
+                       if (state.gps != null)
+                               y = state.gps.vdop;
+                       else
+                               y = AltosLib.MISSING;
+                       break;
                default:
                        if (data_ignitor_0 <= index && index <= data_ignitor_max) {
                                int ignitor = index - data_ignitor_0;
@@ -209,7 +218,7 @@ public class AltosGraphDataPoint implements AltosUIDataPoint {
 
        public int id(int index) {
                if (index == data_state) {
-                       int s = state.state;
+                       int s = state.state();
                        if (AltosLib.ao_flight_boost <= s && s <= AltosLib.ao_flight_landed)
                                return s;
                } else if (data_ignitor_fired_0 <= index && index <= data_ignitor_fired_max) {