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_11;
17 public abstract class AltosFlightListener {
22 public int boost_tick;
25 public double accel_plus_g;
26 public double accel_minus_g;
29 public double ground_pressure;
30 public double ground_altitude;
33 int temp_gps_sat_tick;
36 /* AltosEepromRecord */
37 public void set_boost_tick(int boost_tick) {
38 if (boost_tick != AltosLib.MISSING)
39 this.boost_tick = boost_tick;
42 public void set_tick(int tick) {
43 if (tick != AltosLib.MISSING)
47 public double time() {
48 if (tick == AltosLib.MISSING)
49 return AltosLib.MISSING;
50 if (boost_tick != AltosLib.MISSING)
51 return (tick - boost_tick) / 100.0;
56 public double boost_time() {
57 if (boost_tick == AltosLib.MISSING)
58 return AltosLib.MISSING;
59 return boost_tick / 100.0;
62 public abstract void set_rssi(int rssi, int status);
63 public abstract void set_received_time(long received_time);
65 /* AltosEepromRecordFull */
67 public void set_serial(int serial) {
68 if (serial != AltosLib.MISSING)
72 public void set_state(int state) {
73 if (state != AltosLib.MISSING)
77 public int state() { return state; }
79 public abstract void set_ground_accel(double ground_accel);
80 public void set_flight(int flight) {
81 if (flight != AltosLib.MISSING)
88 public abstract void set_accel(double accel);
89 public abstract void set_acceleration(double accel);
90 public abstract void set_accel_g(double accel_plus_g, double accel_minus_g);
91 public abstract void set_pressure(double pa);
92 public abstract void set_thrust(double N);
94 public abstract void set_temperature(double deg_c);
95 public abstract void set_battery_voltage(double volts);
97 public abstract void set_apogee_voltage(double volts);
98 public abstract void set_main_voltage(double volts);
100 public void set_temp_gps() {
104 public boolean gps_pending() {
105 return temp_gps != null;
108 public AltosGPS make_temp_gps(boolean sats) {
109 if (temp_gps == null) {
110 temp_gps = new AltosGPS();
113 if (tick != temp_gps_sat_tick)
114 temp_gps.cc_gps_sat = null;
115 temp_gps_sat_tick = tick;
120 public void set_ground_pressure(double ground_pressure) {
121 if (ground_pressure != AltosLib.MISSING) {
122 this.ground_pressure = ground_pressure;
123 this.ground_altitude = AltosConvert.pressure_to_altitude(ground_pressure);
127 public abstract void set_accel_ground(double along, double across, double through);
128 public abstract void set_gyro_zero(double roll, double pitch, double yaw);
129 public abstract void check_imu_wrap(AltosIMU imu);
130 public abstract void set_imu(AltosIMU imu);
131 public abstract void set_mag(AltosMag mag);
132 public abstract void set_pyro_voltage(double volts);
133 public abstract void set_igniter_voltage(double[] voltage);
134 public abstract void set_pyro_fired(int pyro_mask);
136 public void copy(AltosFlightListener old) {
140 boost_tick = old.boost_tick;
141 accel_plus_g = old.accel_plus_g;
142 accel_minus_g = old.accel_minus_g;
143 ground_pressure = old.ground_pressure;
144 ground_altitude = old.ground_altitude;
145 temp_gps = old.temp_gps;
146 temp_gps_sat_tick = old.temp_gps_sat_tick;
150 flight = AltosLib.MISSING;
151 serial = AltosLib.MISSING;
152 tick = AltosLib.MISSING;
153 boost_tick = AltosLib.MISSING;
154 accel_plus_g = AltosLib.MISSING;
155 accel_minus_g = AltosLib.MISSING;
156 accel = AltosLib.MISSING;
157 ground_pressure = AltosLib.MISSING;
158 ground_altitude = AltosLib.MISSING;
160 temp_gps_sat_tick = AltosLib.MISSING;