X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altosuilib%2FAltosGraph.java;h=987c461e5836ee7afe074f259574786c77c9a97f;hb=da914cd72411af8c36af05b13c11b9093c8a378c;hp=f8c8b27b762e7b506332b5bd426c6734c9078a7b;hpb=6fc58142d2a108c91d257eb0175098bf082834f9;p=fw%2Faltos diff --git a/altosuilib/AltosGraph.java b/altosuilib/AltosGraph.java index f8c8b27b..987c461e 100644 --- a/altosuilib/AltosGraph.java +++ b/altosuilib/AltosGraph.java @@ -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,14 +16,14 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_2; +package org.altusmetrum.altosuilib_11; import java.io.*; import java.util.ArrayList; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altoslib_11.*; import org.jfree.ui.*; import org.jfree.chart.*; @@ -34,29 +35,6 @@ import org.jfree.chart.labels.*; import org.jfree.data.xy.*; import org.jfree.data.*; -class AltosVoltage extends AltosUnits { - - public double value(double v, boolean imperial_units) { - return v; - } - - public double inverse(double v, boolean imperial_units) { - return v; - } - - public String show_units(boolean imperial_units) { - return "V"; - } - - public String say_units(boolean imperial_units) { - return "volts"; - } - - public int show_fraction(int width, boolean imperial_units) { - return width / 2; - } -} - class AltosNsat extends AltosUnits { public double value(double v, boolean imperial_units) { @@ -80,29 +58,6 @@ class AltosNsat extends AltosUnits { } } -class AltosPressure extends AltosUnits { - - public double value(double p, boolean imperial_units) { - return p; - } - - public double inverse(double p, boolean imperial_units) { - return p; - } - - public String show_units(boolean imperial_units) { - return "Pa"; - } - - public String say_units(boolean imperial_units) { - return "pascals"; - } - - public int show_fraction(int width, boolean imperial_units) { - return 0; - } -} - class AltosDbm extends AltosUnits { public double value(double d, boolean imperial_units) { @@ -126,7 +81,7 @@ class AltosDbm extends AltosUnits { } } -class AltosGyroUnits extends AltosUnits { +class AltosMagUnits extends AltosUnits { public double value(double p, boolean imperial_units) { return p; @@ -137,19 +92,19 @@ class AltosGyroUnits extends AltosUnits { } public String show_units(boolean imperial_units) { - return "°/sec"; + return "Ga"; } public String say_units(boolean imperial_units) { - return "degrees per second"; + return "gauss"; } public int show_fraction(int width, boolean imperial_units) { - return 1; + return 2; } } -class AltosMagUnits extends AltosUnits { +class AltosDopUnits extends AltosUnits { public double value(double p, boolean imperial_units) { return p; @@ -160,15 +115,15 @@ class AltosMagUnits extends AltosUnits { } public String show_units(boolean imperial_units) { - return "Ga"; + return null; } public String say_units(boolean imperial_units) { - return "gauss"; + return null; } public int show_fraction(int width, boolean imperial_units) { - return 2; + return 1; } } @@ -191,6 +146,9 @@ public class AltosGraph extends AltosUIGraph { static final private Color gps_course_color = new Color (100, 31, 112); static final private Color gps_ground_speed_color = new Color (31, 112, 100); static final private Color gps_climb_rate_color = new Color (31, 31, 112); + static final private Color gps_pdop_color = new Color(50, 194, 0); + static final private Color gps_hdop_color = new Color(50, 0, 194); + static final private Color gps_vdop_color = new Color(194, 0, 50); static final private Color temperature_color = new Color (31, 194, 194); static final private Color dbm_color = new Color(31, 100, 100); static final private Color state_color = new Color(0,0,0); @@ -205,27 +163,26 @@ public class AltosGraph extends AltosUIGraph { static final private Color mag_z_color = new Color(0, 0, 128); static final private Color orient_color = new Color(31, 31, 31); - static AltosVoltage voltage_units = new AltosVoltage(); - static AltosPressure pressure_units = new AltosPressure(); static AltosNsat nsat_units = new AltosNsat(); static AltosDbm dbm_units = new AltosDbm(); - static AltosGyroUnits gyro_units = new AltosGyroUnits(); + static AltosRotationRate gyro_units = new AltosRotationRate(); static AltosOrient orient_units = new AltosOrient(); static AltosMagUnits mag_units = new AltosMagUnits(); + static AltosDopUnits dop_units = new AltosDopUnits(); AltosUIAxis height_axis, speed_axis, accel_axis, voltage_axis, temperature_axis, nsat_axis, dbm_axis; AltosUIAxis distance_axis, pressure_axis; AltosUIAxis gyro_axis, orient_axis, mag_axis; - AltosUIAxis course_axis; + AltosUIAxis course_axis, dop_axis; public AltosGraph(AltosUIEnable enable, AltosFlightStats stats, AltosGraphDataSet dataSet) { super(enable); height_axis = newAxis("Height", AltosConvert.height, height_color); - pressure_axis = newAxis("Pressure", pressure_units, pressure_color, 0); + pressure_axis = newAxis("Pressure", AltosConvert.pressure, pressure_color, 0); speed_axis = newAxis("Speed", AltosConvert.speed, speed_color); accel_axis = newAxis("Acceleration", AltosConvert.accel, accel_color); - voltage_axis = newAxis("Voltage", voltage_units, voltage_color); + voltage_axis = newAxis("Voltage", AltosConvert.voltage, voltage_color); temperature_axis = newAxis("Temperature", AltosConvert.temperature, temperature_color, 0); nsat_axis = newAxis("Satellites", nsat_units, gps_nsat_color, AltosUIAxis.axis_include_zero | AltosUIAxis.axis_integer); @@ -236,6 +193,7 @@ public class AltosGraph extends AltosUIGraph { orient_axis = newAxis("Tilt Angle", orient_units, orient_color, 0); mag_axis = newAxis("Magnetic Field", mag_units, mag_x_color, 0); course_axis = newAxis("Course", orient_units, gps_course_color, 0); + dop_axis = newAxis("Dilution of Precision", dop_units, gps_pdop_color, 0); addMarker("State", AltosGraphDataPoint.data_state, state_color); @@ -248,7 +206,7 @@ public class AltosGraph extends AltosUIGraph { height_axis); addSeries("Pressure", AltosGraphDataPoint.data_pressure, - pressure_units, + AltosConvert.pressure, pressure_color, false, pressure_axis); @@ -301,30 +259,54 @@ public class AltosGraph extends AltosUIGraph { gps_nsat_solution_color, false, nsat_axis); - addSeries("GPS Satellites in View", - AltosGraphDataPoint.data_gps_nsat_view, - nsat_units, - gps_nsat_view_color, - false, - nsat_axis); - addSeries("GPS Course", - AltosGraphDataPoint.data_gps_course, - orient_units, - gps_course_color, + if (stats.has_gps_sats) { + addSeries("GPS Satellites in View", + AltosGraphDataPoint.data_gps_nsat_view, + nsat_units, + gps_nsat_view_color, + false, + nsat_axis); + } + if (stats.has_gps_detail) { + addSeries("GPS Course", + AltosGraphDataPoint.data_gps_course, + orient_units, + gps_course_color, + false, + course_axis); + addSeries("GPS Ground Speed", + AltosGraphDataPoint.data_gps_ground_speed, + AltosConvert.speed, + gps_ground_speed_color, + enable_gps, + speed_axis); + addSeries("GPS Climb Rate", + AltosGraphDataPoint.data_gps_climb_rate, + AltosConvert.speed, + gps_climb_rate_color, + enable_gps, + speed_axis); + } + addSeries("GPS Position DOP", + AltosGraphDataPoint.data_gps_pdop, + dop_units, + gps_pdop_color, false, - course_axis); - addSeries("GPS Ground Speed", - AltosGraphDataPoint.data_gps_ground_speed, - AltosConvert.speed, - gps_ground_speed_color, - enable_gps, - speed_axis); - addSeries("GPS Climb Rate", - AltosGraphDataPoint.data_gps_climb_rate, - AltosConvert.speed, - gps_climb_rate_color, - enable_gps, - speed_axis); + dop_axis); + if (stats.has_gps_detail) { + addSeries("GPS Horizontal DOP", + AltosGraphDataPoint.data_gps_hdop, + dop_units, + gps_hdop_color, + false, + dop_axis); + addSeries("GPS Vertical DOP", + AltosGraphDataPoint.data_gps_vdop, + dop_units, + gps_vdop_color, + false, + dop_axis); + } } if (stats.has_rssi) addSeries("Received Signal Strength", @@ -337,7 +319,7 @@ public class AltosGraph extends AltosUIGraph { if (stats.has_battery) addSeries("Battery Voltage", AltosGraphDataPoint.data_battery_voltage, - voltage_units, + AltosConvert.voltage, battery_voltage_color, false, voltage_axis); @@ -351,71 +333,71 @@ public class AltosGraph extends AltosUIGraph { temperature_axis); addSeries("Drogue Voltage", AltosGraphDataPoint.data_drogue_voltage, - voltage_units, + AltosConvert.voltage, drogue_voltage_color, false, voltage_axis); addSeries("Main Voltage", AltosGraphDataPoint.data_main_voltage, - voltage_units, + AltosConvert.voltage, main_voltage_color, false, voltage_axis); } if (stats.has_imu) { - addSeries("Acceleration X", - AltosGraphDataPoint.data_accel_x, + addSeries("Acceleration Along", + AltosGraphDataPoint.data_accel_along, AltosConvert.accel, accel_x_color, false, accel_axis); - addSeries("Acceleration Y", - AltosGraphDataPoint.data_accel_y, + addSeries("Acceleration Across", + AltosGraphDataPoint.data_accel_across, AltosConvert.accel, accel_y_color, false, accel_axis); - addSeries("Acceleration Z", - AltosGraphDataPoint.data_accel_z, + addSeries("Acceleration Through", + AltosGraphDataPoint.data_accel_through, AltosConvert.accel, accel_z_color, false, accel_axis); - addSeries("Rotation Rate X", - AltosGraphDataPoint.data_gyro_x, + addSeries("Roll Rate", + AltosGraphDataPoint.data_gyro_roll, gyro_units, gyro_x_color, false, gyro_axis); - addSeries("Rotation Rate Y", - AltosGraphDataPoint.data_gyro_y, + addSeries("Pitch Rate", + AltosGraphDataPoint.data_gyro_pitch, gyro_units, gyro_y_color, false, gyro_axis); - addSeries("Rotation Rate Z", - AltosGraphDataPoint.data_gyro_z, + addSeries("Yaw Rate", + AltosGraphDataPoint.data_gyro_yaw, gyro_units, gyro_z_color, false, gyro_axis); } if (stats.has_mag) { - addSeries("Magnetometer X", - AltosGraphDataPoint.data_mag_x, + addSeries("Magnetometer Along", + AltosGraphDataPoint.data_mag_along, mag_units, mag_x_color, false, mag_axis); - addSeries("Magnetometer Y", - AltosGraphDataPoint.data_mag_y, + addSeries("Magnetometer Across", + AltosGraphDataPoint.data_mag_across, mag_units, mag_y_color, false, mag_axis); - addSeries("Magnetometer Z", - AltosGraphDataPoint.data_mag_z, + addSeries("Magnetometer Through", + AltosGraphDataPoint.data_mag_through, mag_units, mag_z_color, false, @@ -432,7 +414,7 @@ public class AltosGraph extends AltosUIGraph { for (int i = 0; i < stats.num_ignitor; i++) addSeries(AltosLib.ignitor_name(i), AltosGraphDataPoint.data_ignitor_0 + i, - voltage_units, + AltosConvert.voltage, main_voltage_color, false, voltage_axis);