altosuilib: Show raw tick values in graph and info table
[fw/altos] / altoslib / AltosFlightSeries.java
1 /*
2  * Copyright © 2017 Keith Packard <keithp@keithp.com>
3  *
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, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  */
14
15 package org.altusmetrum.altoslib_12;
16
17 import java.util.*;
18
19 public class AltosFlightSeries extends AltosDataListener {
20
21         public ArrayList<AltosTimeSeries> series = new ArrayList<AltosTimeSeries>();
22
23         public double   speed_filter_width = 4.0;
24         public double   accel_filter_width = 4.0;
25
26         public int[] indices() {
27                 int[] indices = new int[series.size()];
28                 for (int i = 0; i < indices.length; i++)
29                         indices[i] = -1;
30                 step_indices(indices);
31                 return indices;
32         }
33
34         private double time(int id, int index) {
35                 AltosTimeSeries         s = series.get(id);
36
37                 if (index < 0)
38                         return Double.NEGATIVE_INFINITY;
39
40                 if (index < s.values.size())
41                         return s.values.get(index).time;
42                 return Double.POSITIVE_INFINITY;
43         }
44
45         public boolean step_indices(int[] indices) {
46                 double  min_next = time(0, indices[0]+1);
47
48                 for (int i = 1; i < indices.length; i++) {
49                         double next = time(i, indices[i]+1);
50                         if (next < min_next)
51                                 min_next = next;
52                 }
53
54                 if (min_next == Double.POSITIVE_INFINITY)
55                         return false;
56
57                 for (int i = 0; i < indices.length; i++) {
58                         double  t = time(i, indices[i] + 1);
59
60                         if (t <= min_next)
61                                 indices[i]++;
62                 }
63                 return true;
64         }
65
66         public double time(int[] indices) {
67                 double max = time(0, indices[0]);
68
69                 for (int i = 1; i < indices.length; i++) {
70                         double t = time(i, indices[i]);
71                         if (t >= max)
72                                 max = t;
73                 }
74                 return max;
75         }
76
77         public double value(String name, int[] indices) {
78                 for (int i = 0; i < indices.length; i++) {
79                         AltosTimeSeries s = series.get(i);
80                         if (s.label.equals(name)) {
81                                 int index = indices[i];
82                                 if (index < 0)
83                                         index = 0;
84                                 if (index >= s.values.size())
85                                         index = s.values.size() - 1;
86                                 return s.values.get(index).value;
87                         }
88                 }
89                 return AltosLib.MISSING;
90         }
91
92         public double value(String name, double time) {
93                 for (AltosTimeSeries s : series) {
94                         if (s.label.equals(name))
95                                 return s.value(time);
96                 }
97                 return AltosLib.MISSING;
98         }
99
100         public double value_before(String name, double time) {
101                 for (AltosTimeSeries s : series) {
102                         if (s.label.equals(name))
103                                 return s.value_before(time);
104                 }
105                 return AltosLib.MISSING;
106         }
107
108         public double value_after(String name, double time) {
109                 for (AltosTimeSeries s : series) {
110                         if (s.label.equals(name))
111                                 return s.value_after(time);
112                 }
113                 return AltosLib.MISSING;
114         }
115
116         public AltosTimeSeries make_series(String label, AltosUnits units) {
117                 return new AltosTimeSeries(label, units);
118         }
119
120         public void add_series(AltosTimeSeries s) {
121                 for (int e = 0; e < series.size(); e++) {
122                         if (s.compareTo(series.get(e)) < 0){
123                                 series.add(e, s);
124                                 return;
125                         }
126                 }
127                 series.add(s);
128         }
129
130         public AltosTimeSeries add_series(String label, AltosUnits units) {
131                 AltosTimeSeries s = make_series(label, units);
132                 add_series(s);
133                 return s;
134         }
135
136         public void remove_series(AltosTimeSeries s) {
137                 series.remove(s);
138         }
139
140         public boolean has_series(String label) {
141                 for (AltosTimeSeries s : series)
142                         if (s.label.equals(label))
143                                 return true;
144                 return false;
145         }
146
147         public AltosTimeSeries state_series;
148
149         public static final String state_name = "State";
150
151         public void set_state(int state) {
152
153                 if (state != AltosLib.ao_flight_pad && state != AltosLib.MISSING && state != AltosLib.ao_flight_stateless) {
154                         if (state_series == null)
155                                 state_series = add_series(state_name, AltosConvert.state_name);
156                         if (this.state() != state)
157                                 state_series.add(time(), state);
158                 }
159                 super.set_state(state);
160         }
161
162         public AltosTimeSeries  accel_series;
163
164         public static final String accel_name = "Accel";
165
166         public AltosTimeSeries  vert_accel_series;
167
168         public static final String vert_accel_name = "Vertical Accel";
169
170         public void set_acceleration(double acceleration) {
171                 if (acceleration == AltosLib.MISSING)
172                         return;
173                 if (accel_series == null)
174                         accel_series = add_series(accel_name, AltosConvert.accel);
175
176                 accel_series.add(time(), acceleration);
177         }
178
179         private void compute_accel() {
180                 if (accel_series != null)
181                         return;
182
183                 if (speed_series != null) {
184                         AltosTimeSeries temp_series = make_series(speed_name, AltosConvert.speed);
185                         speed_series.filter(temp_series, accel_filter_width);
186                         accel_series = add_series(accel_name, AltosConvert.accel);
187                         temp_series.differentiate(accel_series);
188                 }
189         }
190
191         public void set_received_time(long received_time) {
192         }
193
194         public AltosTimeSeries tick_series;
195
196         public static final String tick_name = "Tick";
197
198         public void set_tick(int tick) {
199                 super.set_tick(tick);
200                 if (tick_series == null)
201                         tick_series = add_series(tick_name, null);
202                 tick_series.add(time(), tick);
203         }
204
205         public AltosTimeSeries rssi_series;
206
207         public static final String rssi_name = "RSSI";
208
209         public AltosTimeSeries status_series;
210
211         public static final String status_name = "Radio Status";
212
213         public void set_rssi(int rssi, int status) {
214                 if (rssi_series == null) {
215                         rssi_series = add_series(rssi_name, null);
216                         status_series = add_series(status_name, null);
217                 }
218                 rssi_series.add(time(), rssi);
219                 status_series.add(time(), status);
220         }
221
222         public AltosTimeSeries pressure_series;
223
224         public static final String pressure_name = "Pressure";
225
226         public AltosTimeSeries altitude_series;
227
228         public static final String altitude_name = "Altitude";
229
230         public AltosTimeSeries height_series;
231
232         public static final String height_name = "Height";
233
234         public  void set_pressure(double pa) {
235                 if (pa == AltosLib.MISSING)
236                         return;
237
238                 if (pressure_series == null)
239                         pressure_series = add_series(pressure_name, AltosConvert.pressure);
240                 pressure_series.add(time(), pa);
241                 if (altitude_series == null)
242                         altitude_series = add_series(altitude_name, AltosConvert.height);
243
244                 if (cal_data().ground_pressure == AltosLib.MISSING)
245                         cal_data().set_ground_pressure(pa);
246
247                 double altitude = AltosConvert.pressure_to_altitude(pa);
248                 altitude_series.add(time(), altitude);
249         }
250
251         private void compute_height() {
252                 double ground_altitude = cal_data().ground_altitude;
253                 if (height_series == null && ground_altitude != AltosLib.MISSING && altitude_series != null) {
254                         height_series = add_series(height_name, AltosConvert.height);
255                         for (AltosTimeValue alt : altitude_series)
256                                 height_series.add(alt.time, alt.value - ground_altitude);
257                 }
258
259                 if (gps_height == null && cal_data().gps_pad != null && cal_data().gps_pad.alt != AltosLib.MISSING && gps_altitude != null) {
260                         double gps_ground_altitude = cal_data().gps_pad.alt;
261                         gps_height = add_series(gps_height_name, AltosConvert.height);
262                         for (AltosTimeValue gps_alt : gps_altitude)
263                                 gps_height.add(gps_alt.time, gps_alt.value - gps_ground_altitude);
264                 }
265         }
266
267         public AltosTimeSeries speed_series;
268
269         public static final String speed_name = "Speed";
270
271         private void compute_speed() {
272                 if (speed_series != null)
273                         return;
274
275                 AltosTimeSeries alt_speed_series = null;
276                 AltosTimeSeries accel_speed_series = null;
277
278                 if (altitude_series != null) {
279                         AltosTimeSeries temp_series = make_series(altitude_name, AltosConvert.height);
280                         altitude_series.filter(temp_series, speed_filter_width);
281
282                         alt_speed_series = make_series(speed_name, AltosConvert.speed);
283                         temp_series.differentiate(alt_speed_series);
284                 }
285                 if (accel_series != null) {
286
287                         if (orient_series != null) {
288                                 vert_accel_series = add_series(vert_accel_name, AltosConvert.accel);
289
290                                 for (AltosTimeValue a : accel_series) {
291                                         double  orient = orient_series.value(a.time);
292                                         double  a_abs = a.value + AltosConvert.gravity;
293                                         double  v_a = a_abs * Math.cos(AltosConvert.degrees_to_radians(orient)) - AltosConvert.gravity;
294
295                                         vert_accel_series.add(a.time, v_a);
296                                 }
297                         }
298
299                         AltosTimeSeries temp_series = make_series(speed_name, AltosConvert.speed);
300
301                         if (vert_accel_series != null)
302                                 vert_accel_series.integrate(temp_series);
303                         else
304                                 accel_series.integrate(temp_series);
305
306                         accel_speed_series = make_series(speed_name, AltosConvert.speed);
307                         temp_series.filter(accel_speed_series, 0.1);
308                 }
309
310                 if (alt_speed_series != null && accel_speed_series != null) {
311                         double  apogee_time = AltosLib.MISSING;
312                         if (state_series != null) {
313                                 for (AltosTimeValue d : state_series) {
314                                         if (d.value >= AltosLib.ao_flight_drogue){
315                                                 apogee_time = d.time;
316                                                 break;
317                                         }
318                                 }
319                         }
320                         if (apogee_time == AltosLib.MISSING) {
321                                 speed_series = alt_speed_series;
322                         } else {
323                                 speed_series = make_series(speed_name, AltosConvert.speed);
324                                 for (AltosTimeValue d : accel_speed_series) {
325                                         if (d.time <= apogee_time)
326                                                 speed_series.add(d);
327                                 }
328                                 for (AltosTimeValue d : alt_speed_series) {
329                                         if (d.time > apogee_time)
330                                                 speed_series.add(d);
331                                 }
332
333                         }
334                 } else if (alt_speed_series != null) {
335                         speed_series = alt_speed_series;
336                 } else if (accel_speed_series != null) {
337                         speed_series = accel_speed_series;
338                 }
339                 if (speed_series != null)
340                         add_series(speed_series);
341         }
342
343         public AltosTimeSeries orient_series;
344
345         public static final String orient_name = "Tilt Angle";
346
347         private void compute_orient() {
348
349                 if (orient_series != null)
350                         return;
351
352                 if (accel_ground_across == AltosLib.MISSING)
353                         return;
354
355                 if (cal_data().pad_orientation == AltosLib.MISSING)
356                         return;
357
358                 if (cal_data().accel_zero_across == AltosLib.MISSING)
359                         return;
360
361                 AltosRotation rotation = new AltosRotation(AltosIMU.convert_accel(accel_ground_across - cal_data().accel_zero_across),
362                                                            AltosIMU.convert_accel(accel_ground_through - cal_data().accel_zero_through),
363                                                            AltosIMU.convert_accel(accel_ground_along - cal_data().accel_zero_along),
364                                                            cal_data().pad_orientation);
365                 double prev_time = ground_time;
366
367                 orient_series = add_series(orient_name, AltosConvert.orient);
368                 orient_series.add(ground_time, rotation.tilt());
369
370                 for (AltosTimeValue roll_v : gyro_roll) {
371                         double  time = roll_v.time;
372                         double  dt = time - prev_time;
373
374                         if (dt > 0) {
375                                 double  roll = AltosConvert.degrees_to_radians(roll_v.value) * dt;
376                                 double  pitch = AltosConvert.degrees_to_radians(gyro_pitch.value(time)) * dt;
377                                 double  yaw = AltosConvert.degrees_to_radians(gyro_yaw.value(time)) * dt;
378
379                                 rotation.rotate(pitch, yaw, roll);
380                                 orient_series.add(time, rotation.tilt());
381                         }
382                         prev_time = time;
383                 }
384         }
385
386         public AltosTimeSeries  kalman_height_series, kalman_speed_series, kalman_accel_series;
387
388         public static final String kalman_height_name = "Kalman Height";
389         public static final String kalman_speed_name = "Kalman Speed";
390         public static final String kalman_accel_name = "Kalman Accel";
391
392         public void set_kalman(double height, double speed, double acceleration) {
393                 if (kalman_height_series == null) {
394                         kalman_height_series = add_series(kalman_height_name, AltosConvert.height);
395                         kalman_speed_series = add_series(kalman_speed_name, AltosConvert.speed);
396                         kalman_accel_series = add_series(kalman_accel_name, AltosConvert.accel);
397                 }
398                 kalman_height_series.add(time(), height);
399                 kalman_speed_series.add(time(), speed);
400                 kalman_accel_series.add(time(), acceleration);
401         }
402
403         public AltosTimeSeries thrust_series;
404
405         public static final String thrust_name = "Thrust";
406
407         public  void set_thrust(double N) {
408                 if (thrust_series == null)
409                         thrust_series = add_series(thrust_name, AltosConvert.force);
410                 thrust_series.add(time(), N);
411         }
412
413         public AltosTimeSeries temperature_series;
414
415         public static final String temperature_name = "Temperature";
416
417         public  void set_temperature(double deg_c) {
418                 if (temperature_series == null)
419                         temperature_series = add_series(temperature_name, AltosConvert.temperature);
420                 temperature_series.add(time(), deg_c);
421         }
422
423         public AltosTimeSeries battery_voltage_series;
424
425         public static final String battery_voltage_name = "Battery Voltage";
426
427         public void set_battery_voltage(double volts) {
428                 if (volts == AltosLib.MISSING)
429                         return;
430                 if (battery_voltage_series == null)
431                         battery_voltage_series = add_series(battery_voltage_name, AltosConvert.voltage);
432                 battery_voltage_series.add(time(), volts);
433         }
434
435         public AltosTimeSeries apogee_voltage_series;
436
437         public static final String apogee_voltage_name = "Apogee Voltage";
438
439         public void set_apogee_voltage(double volts) {
440                 if (volts == AltosLib.MISSING)
441                         return;
442                 if (apogee_voltage_series == null)
443                         apogee_voltage_series = add_series(apogee_voltage_name, AltosConvert.voltage);
444                 apogee_voltage_series.add(time(), volts);
445         }
446
447         public AltosTimeSeries main_voltage_series;
448
449         public static final String main_voltage_name = "Main Voltage";
450
451         public void set_main_voltage(double volts) {
452                 if (volts == AltosLib.MISSING)
453                         return;
454                 if (main_voltage_series == null)
455                         main_voltage_series = add_series(main_voltage_name, AltosConvert.voltage);
456                 main_voltage_series.add(time(), volts);
457         }
458
459         public ArrayList<AltosGPSTimeValue> gps_series;
460
461         public AltosGPS gps_before(double time) {
462                 AltosGPS gps = null;
463                 for (AltosGPSTimeValue gtv : gps_series)
464                         if (gtv.time <= time)
465                                 gps = gtv.gps;
466                         else
467                                 break;
468                 return gps;
469         }
470
471         public AltosTimeSeries  sats_in_view;
472         public AltosTimeSeries sats_in_soln;
473         public AltosTimeSeries gps_altitude;
474         public AltosTimeSeries gps_height;
475         public AltosTimeSeries gps_ground_speed;
476         public AltosTimeSeries gps_ascent_rate;
477         public AltosTimeSeries gps_course;
478         public AltosTimeSeries gps_speed;
479         public AltosTimeSeries gps_pdop, gps_vdop, gps_hdop;
480
481         public static final String sats_in_view_name = "Satellites in view";
482         public static final String sats_in_soln_name = "Satellites in solution";
483         public static final String gps_altitude_name = "GPS Altitude";
484         public static final String gps_height_name = "GPS Height";
485         public static final String gps_ground_speed_name = "GPS Ground Speed";
486         public static final String gps_ascent_rate_name = "GPS Ascent Rate";
487         public static final String gps_course_name = "GPS Course";
488         public static final String gps_speed_name = "GPS Speed";
489         public static final String gps_pdop_name = "GPS Dilution of Precision";
490         public static final String gps_vdop_name = "GPS Vertical Dilution of Precision";
491         public static final String gps_hdop_name = "GPS Horizontal Dilution of Precision";
492
493         public void set_gps(AltosGPS gps) {
494                 if (gps_series == null)
495                         gps_series = new ArrayList<AltosGPSTimeValue>();
496                 gps_series.add(new AltosGPSTimeValue(time(), gps));
497
498                 if (sats_in_soln == null) {
499                         sats_in_soln = add_series(sats_in_soln_name, null);
500                 }
501                 sats_in_soln.add(time(), gps.nsat);
502                 if (gps.pdop != AltosLib.MISSING) {
503                         if (gps_pdop == null)
504                                 gps_pdop = add_series(gps_pdop_name, null);
505                         gps_pdop.add(time(), gps.pdop);
506                 }
507                 if (gps.hdop != AltosLib.MISSING) {
508                         if (gps_hdop == null)
509                                 gps_hdop = add_series(gps_hdop_name, null);
510                         gps_hdop.add(time(), gps.hdop);
511                 }
512                 if (gps.vdop != AltosLib.MISSING) {
513                         if (gps_vdop == null)
514                                 gps_vdop = add_series(gps_vdop_name, null);
515                         gps_vdop.add(time(), gps.vdop);
516                 }
517                 if (gps.locked) {
518                         if (gps.alt != AltosLib.MISSING) {
519                                 if (gps_altitude == null)
520                                         gps_altitude = add_series(gps_altitude_name, AltosConvert.height);
521                                 gps_altitude.add(time(), gps.alt);
522                         }
523                         if (gps.ground_speed != AltosLib.MISSING) {
524                                 if (gps_ground_speed == null)
525                                         gps_ground_speed = add_series(gps_ground_speed_name, AltosConvert.speed);
526                                 gps_ground_speed.add(time(), gps.ground_speed);
527                         }
528                         if (gps.climb_rate != AltosLib.MISSING) {
529                                 if (gps_ascent_rate == null)
530                                         gps_ascent_rate = add_series(gps_ascent_rate_name, AltosConvert.speed);
531                                 gps_ascent_rate.add(time(), gps.climb_rate);
532                         }
533                         if (gps.course != AltosLib.MISSING) {
534                                 if (gps_course == null)
535                                         gps_course = add_series(gps_course_name, null);
536                                 gps_course.add(time(), gps.course);
537                         }
538                         if (gps.ground_speed != AltosLib.MISSING && gps.climb_rate != AltosLib.MISSING) {
539                                 if (gps_speed == null)
540                                         gps_speed = add_series(gps_speed_name, null);
541                                 gps_speed.add(time(), Math.sqrt(gps.ground_speed * gps.ground_speed +
542                                                                 gps.climb_rate * gps.climb_rate));
543                         }
544                 }
545                 if (gps.cc_gps_sat != null) {
546                         if (sats_in_view == null)
547                                 sats_in_view = add_series(sats_in_view_name, null);
548                         sats_in_view.add(time(), gps.cc_gps_sat.length);
549                 }
550         }
551
552         public static final String accel_along_name = "Accel Along";
553         public static final String accel_across_name = "Accel Across";
554         public static final String accel_through_name = "Accel Through";
555
556         public AltosTimeSeries accel_along, accel_across, accel_through;
557
558         public static final String gyro_roll_name = "Roll Rate";
559         public static final String gyro_pitch_name = "Pitch Rate";
560         public static final String gyro_yaw_name = "Yaw Rate";
561
562         public AltosTimeSeries gyro_roll, gyro_pitch, gyro_yaw;
563
564         public static final String mag_along_name = "Magnetic Field Along";
565         public static final String mag_across_name = "Magnetic Field Across";
566         public static final String mag_through_name = "Magnetic Field Through";
567
568         public AltosTimeSeries mag_along, mag_across, mag_through;
569
570         public  void set_accel(double along, double across, double through) {
571                 if (accel_along == null) {
572                         accel_along = add_series(accel_along_name, AltosConvert.accel);
573                         accel_across = add_series(accel_across_name, AltosConvert.accel);
574                         accel_through = add_series(accel_through_name, AltosConvert.accel);
575                 }
576                 accel_along.add(time(), along);
577                 accel_across.add(time(), across);
578                 accel_through.add(time(), through);
579         }
580
581         private double  accel_ground_along = AltosLib.MISSING;
582         private double  accel_ground_across = AltosLib.MISSING;
583         private double  accel_ground_through = AltosLib.MISSING;
584
585         private double          ground_time;
586
587         public  void set_accel_ground(double along, double across, double through) {
588                 accel_ground_along = along;
589                 accel_ground_across = across;
590                 accel_ground_through = through;
591                 ground_time = time();
592         }
593
594         public  void set_gyro(double roll, double pitch, double yaw) {
595                 if (gyro_roll == null) {
596                         gyro_roll = add_series(gyro_roll_name, AltosConvert.rotation_rate);
597                         gyro_pitch = add_series(gyro_pitch_name, AltosConvert.rotation_rate);
598                         gyro_yaw = add_series(gyro_yaw_name, AltosConvert.rotation_rate);
599                 }
600                 gyro_roll.add(time(), roll);
601                 gyro_pitch.add(time(), pitch);
602                 gyro_yaw.add(time(), yaw);
603         }
604
605         public  void set_mag(double along, double across, double through) {
606                 if (mag_along == null) {
607                         mag_along = add_series(mag_along_name, AltosConvert.magnetic_field);
608                         mag_across = add_series(mag_across_name, AltosConvert.magnetic_field);
609                         mag_through = add_series(mag_through_name, AltosConvert.magnetic_field);
610                 }
611                 mag_along.add(time(), along);
612                 mag_across.add(time(), across);
613                 mag_through.add(time(), through);
614         }
615
616         public void set_orient(double orient) {
617                 if (orient_series == null)
618                         orient_series = add_series(orient_name, AltosConvert.orient);
619                 orient_series.add(time(), orient);
620         }
621
622         public static final String pyro_voltage_name = "Pyro Voltage";
623
624         public AltosTimeSeries pyro_voltage;
625
626         public  void set_pyro_voltage(double volts) {
627                 if (pyro_voltage == null)
628                         pyro_voltage = add_series(pyro_voltage_name, AltosConvert.voltage);
629                 pyro_voltage.add(time(), volts);
630         }
631
632         private static String[] igniter_voltage_names;
633
634         public String igniter_voltage_name(int channel) {
635                 if (igniter_voltage_names == null || igniter_voltage_names.length <= channel) {
636                         String[] new_igniter_voltage_names = new String[channel + 1];
637                         int     i = 0;
638
639                         if (igniter_voltage_names != null) {
640                                 for (; i < igniter_voltage_names.length; i++)
641                                         new_igniter_voltage_names[i] = igniter_voltage_names[i];
642                         }
643                         for (; i < channel+1; i++)
644                                 new_igniter_voltage_names[i] = AltosLib.igniter_name(i);
645                         igniter_voltage_names = new_igniter_voltage_names;
646                 }
647                 return igniter_voltage_names[channel];
648         }
649
650         public AltosTimeSeries[] igniter_voltage;
651
652         public  void set_igniter_voltage(double[] voltage) {
653                 int channels = voltage.length;
654                 if (igniter_voltage == null || igniter_voltage.length <= channels) {
655                         AltosTimeSeries[]       new_igniter_voltage = new AltosTimeSeries[channels];
656                         int                     i = 0;
657
658                         if (igniter_voltage != null) {
659                                 for (; i < igniter_voltage.length; i++)
660                                         new_igniter_voltage[i] = igniter_voltage[i];
661                         }
662                         for (; i < channels; i++)
663                                 new_igniter_voltage[i] = add_series(igniter_voltage_name(i), AltosConvert.voltage);
664                         igniter_voltage = new_igniter_voltage;
665                 }
666                 for (int channel = 0; channel < voltage.length; channel++)
667                         igniter_voltage[channel].add(time(), voltage[channel]);
668         }
669
670         public static final String pyro_fired_name = "Pyro Channel State";
671
672         public AltosTimeSeries pyro_fired_series;
673
674         int     last_pyro_mask;
675
676         public  void set_pyro_fired(int pyro_mask) {
677                 if (pyro_fired_series == null)
678                         pyro_fired_series = add_series(pyro_fired_name, AltosConvert.pyro_name);
679                 for (int channel = 0; channel < 32; channel++) {
680                         if ((last_pyro_mask & (1 << channel)) == 0 &&
681                             (pyro_mask & (1 << channel)) != 0) {
682                                 pyro_fired_series.add(time(), channel);
683                         }
684                 }
685                 last_pyro_mask = pyro_mask;
686         }
687
688         public void set_companion(AltosCompanion companion) {
689         }
690
691         public void finish() {
692                 compute_orient();
693                 compute_speed();
694                 compute_accel();
695                 compute_height();
696         }
697
698         public AltosTimeSeries[] series() {
699                 finish();
700                 return series.toArray(new AltosTimeSeries[0]);
701         }
702
703         public AltosFlightSeries(AltosCalData cal_data) {
704                 super(cal_data);
705         }
706 }