altoslib,altosuilib,altosui: log_format/device_type TeleGPS selects stateless
[fw/altos] / altoslib / AltosDataListener.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 public abstract class AltosDataListener {
18
19         private AltosCalData    cal_data = null;
20
21         public double           time = AltosLib.MISSING;
22         public double           frequency = AltosLib.MISSING;
23
24         public void set_tick(int tick) {
25                 cal_data.set_tick(tick);
26                 set_time(cal_data.time());
27         }
28
29         public AltosCalData cal_data() {
30                 if (cal_data == null)
31                         cal_data = new AltosCalData();
32                 return cal_data;
33         }
34
35         public void set_time(double time) {
36                 if (time != AltosLib.MISSING)
37                         this.time = time;
38         }
39
40         public void set_serial(int serial) {
41                 cal_data().set_serial(serial);
42         }
43
44         public void set_device_type(int device_type) {
45                 cal_data().set_device_type(device_type);
46                 switch (device_type) {
47                 case AltosLib.product_telegps:
48                         set_state(AltosLib.ao_flight_stateless);
49                         break;
50                 }
51         }
52
53         public void set_log_format(int log_format) {
54                 cal_data().set_log_format(log_format);
55                 switch (log_format) {
56                 case AltosLib.AO_LOG_FORMAT_TELEGPS:
57                         set_state(AltosLib.ao_flight_stateless);
58                         break;
59                 }
60         }
61
62         public double time() {
63                 return time;
64         }
65
66         public void set_state(int state) {
67                 cal_data().set_state(state);
68         }
69
70         public int state() {
71                 return cal_data().state;
72         }
73
74         public void set_flight(int flight) {
75                 cal_data().set_flight(flight);
76         }
77
78         public void set_frequency(double frequency) {
79                 this.frequency = frequency;
80         }
81
82         /* Called after all records are captured */
83         public void finish() {
84         }
85
86         public void init() {
87                 set_state(AltosLib.ao_flight_invalid);
88                 time = AltosLib.MISSING;
89                 frequency = AltosLib.MISSING;
90         }
91
92         public abstract void set_rssi(int rssi, int status);
93         public abstract void set_received_time(long received_time);
94
95         public abstract void set_acceleration(double accel);
96         public abstract void set_pressure(double pa);
97         public abstract void set_thrust(double N);
98
99         public abstract void set_kalman(double height, double speed, double accel);
100
101         public abstract void set_temperature(double deg_c);
102         public abstract void set_battery_voltage(double volts);
103
104         public abstract void set_apogee_voltage(double volts);
105         public abstract void set_main_voltage(double volts);
106
107         public abstract void set_gps(AltosGPS gps);
108
109         public abstract void set_orient(double orient);
110         public abstract void set_gyro(double roll, double pitch, double yaw);
111         public abstract void set_accel_ground(double along, double across, double through);
112         public abstract void set_accel(double along, double across, double through);
113         public abstract void set_mag(double along, double across, double through);
114         public abstract void set_pyro_voltage(double volts);
115         public abstract void set_igniter_voltage(double[] voltage);
116         public abstract void set_pyro_fired(int pyro_mask);
117         public abstract void set_companion(AltosCompanion companion);
118
119         public AltosDataListener() {
120         }
121
122         public AltosDataListener(AltosCalData cal_data) {
123                 this.cal_data = cal_data;
124         }
125 }