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.
21 import java.util.ArrayList;
25 import org.altusmetrum.altoslib_2.*;
26 import org.altusmetrum.altosuilib_1.*;
28 import org.jfree.ui.*;
29 import org.jfree.chart.*;
30 import org.jfree.chart.plot.*;
31 import org.jfree.chart.axis.*;
32 import org.jfree.chart.renderer.*;
33 import org.jfree.chart.renderer.xy.*;
34 import org.jfree.chart.labels.*;
35 import org.jfree.data.xy.*;
36 import org.jfree.data.*;
38 class AltosVoltage extends AltosUnits {
40 public double value(double v, boolean imperial_units) {
44 public double inverse(double v, boolean imperial_units) {
48 public String show_units(boolean imperial_units) {
52 public String say_units(boolean imperial_units) {
56 public int show_fraction(int width, boolean imperial_units) {
61 class AltosNsat extends AltosUnits {
63 public double value(double v, boolean imperial_units) {
67 public double inverse(double v, boolean imperial_units) {
71 public String show_units(boolean imperial_units) {
75 public String say_units(boolean imperial_units) {
79 public int show_fraction(int width, boolean imperial_units) {
84 class AltosPressure extends AltosUnits {
86 public double value(double p, boolean imperial_units) {
90 public double inverse(double p, boolean imperial_units) {
94 public String show_units(boolean imperial_units) {
98 public String say_units(boolean imperial_units) {
102 public int show_fraction(int width, boolean imperial_units) {
107 class AltosDbm extends AltosUnits {
109 public double value(double d, boolean imperial_units) {
113 public double inverse(double d, boolean imperial_units) {
117 public String show_units(boolean imperial_units) {
121 public String say_units(boolean imperial_units) {
125 public int show_fraction(int width, boolean imperial_units) {
130 public class AltosGraph extends AltosUIGraph {
132 static final private Color height_color = new Color(194,31,31);
133 static final private Color gps_height_color = new Color(150,31,31);
134 static final private Color pressure_color = new Color (225,31,31);
135 static final private Color range_color = new Color(100, 31, 31);
136 static final private Color distance_color = new Color(100, 31, 194);
137 static final private Color speed_color = new Color(31,194,31);
138 static final private Color accel_color = new Color(31,31,194);
139 static final private Color voltage_color = new Color(194, 194, 31);
140 static final private Color battery_voltage_color = new Color(194, 194, 31);
141 static final private Color drogue_voltage_color = new Color(150, 150, 31);
142 static final private Color main_voltage_color = new Color(100, 100, 31);
143 static final private Color gps_nsat_color = new Color (194, 31, 194);
144 static final private Color gps_nsat_solution_color = new Color (194, 31, 194);
145 static final private Color gps_nsat_view_color = new Color (150, 31, 150);
146 static final private Color temperature_color = new Color (31, 194, 194);
147 static final private Color dbm_color = new Color(31, 100, 100);
148 static final private Color state_color = new Color(0,0,0);
150 static AltosVoltage voltage_units = new AltosVoltage();
151 static AltosPressure pressure_units = new AltosPressure();
152 static AltosNsat nsat_units = new AltosNsat();
153 static AltosDbm dbm_units = new AltosDbm();
155 AltosUIAxis height_axis, speed_axis, accel_axis, voltage_axis, temperature_axis, nsat_axis, dbm_axis;
156 AltosUIAxis distance_axis, pressure_axis;
158 public AltosGraph(AltosUIEnable enable, AltosFlightStats stats, AltosGraphDataSet dataSet) {
161 height_axis = newAxis("Height", AltosConvert.height, height_color);
162 pressure_axis = newAxis("Pressure", pressure_units, pressure_color, 0);
163 speed_axis = newAxis("Speed", AltosConvert.speed, speed_color);
164 accel_axis = newAxis("Acceleration", AltosConvert.accel, accel_color);
165 voltage_axis = newAxis("Voltage", voltage_units, voltage_color);
166 temperature_axis = newAxis("Temperature", AltosConvert.temperature, temperature_color, 0);
167 nsat_axis = newAxis("Satellites", nsat_units, gps_nsat_color,
168 AltosUIAxis.axis_include_zero | AltosUIAxis.axis_integer);
169 dbm_axis = newAxis("Signal Strength", dbm_units, dbm_color, 0);
170 distance_axis = newAxis("Distance", AltosConvert.distance, range_color);
172 addMarker("State", AltosGraphDataPoint.data_state, state_color);
174 AltosGraphDataPoint.data_height,
179 addSeries("Pressure",
180 AltosGraphDataPoint.data_pressure,
186 AltosGraphDataPoint.data_speed,
191 addSeries("Acceleration",
192 AltosGraphDataPoint.data_accel,
199 AltosGraphDataPoint.data_range,
200 AltosConvert.distance,
204 addSeries("Distance",
205 AltosGraphDataPoint.data_distance,
206 AltosConvert.distance,
210 addSeries("GPS Height",
211 AltosGraphDataPoint.data_gps_height,
216 addSeries("GPS Satellites in Solution",
217 AltosGraphDataPoint.data_gps_nsat_solution,
219 gps_nsat_solution_color,
222 addSeries("GPS Satellites in View",
223 AltosGraphDataPoint.data_gps_nsat_view,
230 addSeries("Received Signal Strength",
231 AltosGraphDataPoint.data_rssi,
236 if (stats.has_other_adc) {
237 addSeries("Temperature",
238 AltosGraphDataPoint.data_temperature,
239 AltosConvert.temperature,
243 addSeries("Battery Voltage",
244 AltosGraphDataPoint.data_battery_voltage,
246 battery_voltage_color,
249 addSeries("Drogue Voltage",
250 AltosGraphDataPoint.data_drogue_voltage,
252 drogue_voltage_color,
255 addSeries("Main Voltage",
256 AltosGraphDataPoint.data_main_voltage,