add thrust as a graphable time series type
[fw/altos] / altoslib / AltosFlightListener.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_11;
16
17 public abstract class AltosFlightListener {
18
19         int flight;
20
21         public int tick;
22         int boost_tick;
23
24         AltosGPS temp_gps;
25         int temp_gps_sat_tick;
26
27         /* AltosEepromRecord */
28         public void set_boost_tick(int boost_tick) {
29                 if (boost_tick != AltosLib.MISSING)
30                         this.boost_tick = boost_tick;
31         }
32
33         public void set_tick(int tick) {
34                 if (tick != AltosLib.MISSING)
35                         this.tick = tick;
36         }
37
38         public double time() {
39                 if (tick == AltosLib.MISSING)
40                         return AltosLib.MISSING;
41                 return tick / 100.0;
42         }
43
44         public double boost_time() {
45                 if (boost_tick == AltosLib.MISSING)
46                         return AltosLib.MISSING;
47                 return boost_tick / 100.0;
48         }
49
50         /* AltosEepromRecordFull */
51
52         public abstract void set_state(int state);
53         public abstract void set_ground_accel(double ground_accel);
54         public void set_flight(int flight) {
55                 if (flight != AltosLib.MISSING)
56                         this.flight = flight;
57         }
58         public int flight() {
59                 return flight;
60         }
61
62         public abstract void set_accel(double accel);
63         public abstract void set_accel_g(double accel_plus_g, double accel_minus_g);
64         public abstract void set_pressure(double pa);
65         public abstract void set_thrust(double N);
66
67         public abstract void set_temperature(double deg_c);
68         public abstract void set_battery_voltage(double volts);
69
70         public abstract void set_apogee_voltage(double volts);
71         public abstract void set_main_voltage(double volts);
72
73         public void set_temp_gps() {
74                 temp_gps = null;
75         }
76
77         public boolean gps_pending() {
78                 return temp_gps != null;
79         }
80
81         public AltosGPS make_temp_gps(boolean sats) {
82                 if (temp_gps == null) {
83                         temp_gps = new AltosGPS();
84                 }
85                 if (sats) {
86                         if (tick != temp_gps_sat_tick)
87                                 temp_gps.cc_gps_sat = null;
88                         temp_gps_sat_tick = tick;
89                 }
90                 return temp_gps;
91         }
92
93         public abstract void set_ground_pressure(double ground_pressure);
94         public abstract void set_accel_ground(double along, double across, double through);
95         public abstract void set_gyro_zero(double roll, double pitch, double yaw);
96         public abstract void set_ms5607(int pres_val, int temp_val);
97         public abstract void check_imu_wrap(AltosIMU imu);
98         public abstract void set_imu(AltosIMU imu);
99         public abstract void set_mag(AltosMag mag);
100         public abstract void set_pyro_voltage(double volts);
101         public abstract void set_ignitor_voltage(double[] voltage);
102         public abstract void set_pyro_fired(int pyro_mask);
103
104         public void copy(AltosFlightListener old) {
105                 flight = old.flight;
106                 tick = old.tick;
107                 boost_tick = old.boost_tick;
108                 temp_gps = old.temp_gps;
109                 temp_gps_sat_tick = old.temp_gps_sat_tick;
110         }
111
112         public void init() {
113                 flight = AltosLib.MISSING;
114                 tick = AltosLib.MISSING;
115                 boost_tick = AltosLib.MISSING;
116                 temp_gps_sat_tick = AltosLib.MISSING;
117         }
118 }