1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
|
/*
* Copyright © 2013 Keith Packard <keithp@keithp.com>
*
* 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.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
package org.altusmetrum.altosuilib_3;
import java.io.*;
import java.util.ArrayList;
import java.awt.*;
import javax.swing.*;
import org.altusmetrum.altoslib_5.*;
import org.jfree.ui.*;
import org.jfree.chart.*;
import org.jfree.chart.plot.*;
import org.jfree.chart.axis.*;
import org.jfree.chart.renderer.*;
import org.jfree.chart.renderer.xy.*;
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) {
return v;
}
public double inverse(double v, boolean imperial_units) {
return v;
}
public String show_units(boolean imperial_units) {
return "Sats";
}
public String say_units(boolean imperial_units) {
return "Satellites";
}
public int show_fraction(int width, boolean imperial_units) {
return 0;
}
}
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) {
return d;
}
public double inverse(double d, boolean imperial_units) {
return d;
}
public String show_units(boolean imperial_units) {
return "dBm";
}
public String say_units(boolean imperial_units) {
return "D B M";
}
public int show_fraction(int width, boolean imperial_units) {
return 0;
}
}
class AltosGyroUnits 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 "°/sec";
}
public String say_units(boolean imperial_units) {
return "degrees per second";
}
public int show_fraction(int width, boolean imperial_units) {
return 1;
}
}
class AltosMagUnits 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 "Ga";
}
public String say_units(boolean imperial_units) {
return "gauss";
}
public int show_fraction(int width, boolean imperial_units) {
return 2;
}
}
class AltosDopUnits 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 null;
}
public String say_units(boolean imperial_units) {
return null;
}
public int show_fraction(int width, boolean imperial_units) {
return 1;
}
}
public class AltosGraph extends AltosUIGraph {
static final private Color height_color = new Color(194,31,31);
static final private Color gps_height_color = new Color(150,31,31);
static final private Color pressure_color = new Color (225,31,31);
static final private Color range_color = new Color(100, 31, 31);
static final private Color distance_color = new Color(100, 31, 194);
static final private Color speed_color = new Color(31,194,31);
static final private Color accel_color = new Color(31,31,194);
static final private Color voltage_color = new Color(194, 194, 31);
static final private Color battery_voltage_color = new Color(194, 194, 31);
static final private Color drogue_voltage_color = new Color(150, 150, 31);
static final private Color main_voltage_color = new Color(100, 100, 31);
static final private Color gps_nsat_color = new Color (194, 31, 194);
static final private Color gps_nsat_solution_color = new Color (194, 31, 194);
static final private Color gps_nsat_view_color = new Color (150, 31, 150);
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);
static final private Color accel_x_color = new Color(255, 0, 0);
static final private Color accel_y_color = new Color(0, 255, 0);
static final private Color accel_z_color = new Color(0, 0, 255);
static final private Color gyro_x_color = new Color(192, 0, 0);
static final private Color gyro_y_color = new Color(0, 192, 0);
static final private Color gyro_z_color = new Color(0, 0, 192);
static final private Color mag_x_color = new Color(128, 0, 0);
static final private Color mag_y_color = new Color(0, 128, 0);
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 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, 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);
speed_axis = newAxis("Speed", AltosConvert.speed, speed_color);
accel_axis = newAxis("Acceleration", AltosConvert.accel, accel_color);
voltage_axis = newAxis("Voltage", voltage_units, 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);
dbm_axis = newAxis("Signal Strength", dbm_units, dbm_color, 0);
distance_axis = newAxis("Distance", AltosConvert.distance, range_color);
gyro_axis = newAxis("Rotation Rate", gyro_units, gyro_z_color, 0);
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);
if (stats.has_flight_data) {
addSeries("Height",
AltosGraphDataPoint.data_height,
AltosConvert.height,
height_color,
true,
height_axis);
addSeries("Pressure",
AltosGraphDataPoint.data_pressure,
pressure_units,
pressure_color,
false,
pressure_axis);
addSeries("Speed",
AltosGraphDataPoint.data_speed,
AltosConvert.speed,
speed_color,
true,
speed_axis);
addSeries("Acceleration",
AltosGraphDataPoint.data_accel,
AltosConvert.accel,
accel_color,
true,
accel_axis);
}
if (stats.has_gps) {
boolean enable_gps = false;
if (!stats.has_flight_data)
enable_gps = true;
addSeries("Range",
AltosGraphDataPoint.data_range,
AltosConvert.distance,
range_color,
false,
distance_axis);
addSeries("Distance",
AltosGraphDataPoint.data_distance,
AltosConvert.distance,
distance_color,
enable_gps,
distance_axis);
addSeries("GPS Height",
AltosGraphDataPoint.data_gps_height,
AltosConvert.height,
gps_height_color,
enable_gps,
height_axis);
addSeries("GPS Altitude",
AltosGraphDataPoint.data_gps_altitude,
AltosConvert.height,
gps_height_color,
false,
height_axis);
addSeries("GPS Satellites in Solution",
AltosGraphDataPoint.data_gps_nsat_solution,
nsat_units,
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,
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,
dop_axis);
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",
AltosGraphDataPoint.data_rssi,
dbm_units,
dbm_color,
false,
dbm_axis);
if (stats.has_battery)
addSeries("Battery Voltage",
AltosGraphDataPoint.data_battery_voltage,
voltage_units,
battery_voltage_color,
false,
voltage_axis);
if (stats.has_flight_adc) {
addSeries("Temperature",
AltosGraphDataPoint.data_temperature,
AltosConvert.temperature,
temperature_color,
false,
temperature_axis);
addSeries("Drogue Voltage",
AltosGraphDataPoint.data_drogue_voltage,
voltage_units,
drogue_voltage_color,
false,
voltage_axis);
addSeries("Main Voltage",
AltosGraphDataPoint.data_main_voltage,
voltage_units,
main_voltage_color,
false,
voltage_axis);
}
if (stats.has_imu) {
addSeries("Acceleration X",
AltosGraphDataPoint.data_accel_x,
AltosConvert.accel,
accel_x_color,
false,
accel_axis);
addSeries("Acceleration Y",
AltosGraphDataPoint.data_accel_y,
AltosConvert.accel,
accel_y_color,
false,
accel_axis);
addSeries("Acceleration Z",
AltosGraphDataPoint.data_accel_z,
AltosConvert.accel,
accel_z_color,
false,
accel_axis);
addSeries("Rotation Rate X",
AltosGraphDataPoint.data_gyro_x,
gyro_units,
gyro_x_color,
false,
gyro_axis);
addSeries("Rotation Rate Y",
AltosGraphDataPoint.data_gyro_y,
gyro_units,
gyro_y_color,
false,
gyro_axis);
addSeries("Rotation Rate Z",
AltosGraphDataPoint.data_gyro_z,
gyro_units,
gyro_z_color,
false,
gyro_axis);
}
if (stats.has_mag) {
addSeries("Magnetometer X",
AltosGraphDataPoint.data_mag_x,
mag_units,
mag_x_color,
false,
mag_axis);
addSeries("Magnetometer Y",
AltosGraphDataPoint.data_mag_y,
mag_units,
mag_y_color,
false,
mag_axis);
addSeries("Magnetometer Z",
AltosGraphDataPoint.data_mag_z,
mag_units,
mag_z_color,
false,
mag_axis);
}
if (stats.has_orient)
addSeries("Tilt Angle",
AltosGraphDataPoint.data_orient,
orient_units,
orient_color,
false,
orient_axis);
if (stats.num_ignitor > 0) {
for (int i = 0; i < stats.num_ignitor; i++)
addSeries(AltosLib.ignitor_name(i),
AltosGraphDataPoint.data_ignitor_0 + i,
voltage_units,
main_voltage_color,
false,
voltage_axis);
for (int i = 0; i < stats.num_ignitor; i++)
addMarker(AltosLib.ignitor_name(i), AltosGraphDataPoint.data_ignitor_fired_0 + i, state_color);
}
setDataSet(dataSet);
}
}
|