2 * Copyright © 2017 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, either version 2 of the License, or
7 * (at your option) any later version.
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.
15 package org.altusmetrum.altoslib_14;
17 public abstract class AltosDataListener {
19 private AltosCalData cal_data = null;
21 public double time = AltosLib.MISSING;
22 public double frequency = AltosLib.MISSING;
24 public int raw_tick = AltosLib.MISSING;
30 public void set_tick(int tick) {
32 cal_data.set_tick(tick);
33 set_time(cal_data.time());
36 public AltosCalData cal_data() {
38 cal_data = new AltosCalData();
42 public void set_time(double time) {
43 if (time != AltosLib.MISSING)
47 public void set_serial(int serial) {
48 cal_data().set_serial(serial);
51 public void set_device_type(int device_type) {
52 cal_data().set_device_type(device_type);
53 switch (device_type) {
54 case AltosLib.product_telegps:
55 set_state(AltosLib.ao_flight_stateless);
60 public void set_log_format(int log_format) {
61 cal_data().set_log_format(log_format);
63 case AltosLib.AO_LOG_FORMAT_TELEGPS:
64 set_state(AltosLib.ao_flight_stateless);
69 public double time() {
73 public String state_name() {
74 return cal_data().state_name();
77 public void set_state(int state) {
78 cal_data().set_state(state);
82 return cal_data().state;
85 public void set_flight(int flight) {
86 cal_data().set_flight(flight);
89 public void set_frequency(double frequency) {
90 this.frequency = frequency;
93 public void set_avoid_duplicate_files() {
96 /* Called after all records are captured */
97 public void finish() {
101 set_state(AltosLib.ao_flight_invalid);
102 time = AltosLib.MISSING;
103 frequency = AltosLib.MISSING;
106 public abstract void set_rssi(int rssi, int status);
107 public abstract void set_received_time(long received_time);
109 public abstract void set_acceleration(double accel);
110 public abstract void set_pressure(double pa);
111 public abstract void set_thrust(double N);
113 public abstract void set_kalman(double height, double speed, double accel);
115 public abstract void set_temperature(double deg_c);
116 public abstract void set_battery_voltage(double volts);
118 public abstract void set_apogee_voltage(double volts);
119 public abstract void set_main_voltage(double volts);
121 public void set_gps(AltosGPS gps, boolean set_location, boolean set_sats) {
122 AltosCalData cal_data = cal_data();
123 cal_data.set_cal_gps(gps);
126 public AltosGPS make_temp_gps(boolean sats) {
127 return cal_data().make_temp_cal_gps(tick(), sats);
130 public AltosGPS temp_gps() {
131 return cal_data().temp_cal_gps();
134 public abstract void set_orient(double orient);
135 public abstract void set_gyro(double roll, double pitch, double yaw);
136 public abstract void set_accel_ground(double along, double across, double through);
137 public abstract void set_accel(double along, double across, double through);
138 public abstract void set_mag(double along, double across, double through);
139 public abstract void set_pyro_voltage(double volts);
140 public abstract void set_igniter_voltage(double[] voltage);
141 public abstract void set_pyro_fired(int pyro_mask);
142 public abstract void set_companion(AltosCompanion companion);
143 public abstract void set_motor_pressure(double motor_pressure);
145 public AltosDataListener() {
148 public AltosDataListener(AltosCalData cal_data) {
149 this.cal_data = cal_data;