summaryrefslogtreecommitdiff
path: root/altoslib/AltosFlightListener.java
blob: ff5e4c3d6fe520000cd30162bb2e0be3fc3c2a7c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
 * Copyright © 2017 Keith Packard <keithp@keithp.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 */

package org.altusmetrum.altoslib_11;

public abstract class AltosFlightListener {

	int flight;

	public int tick;
	int boost_tick;

	AltosGPS temp_gps;
	int temp_gps_sat_tick;

	/* AltosEepromRecord */
	public void set_boost_tick(int boost_tick) {
		if (boost_tick != AltosLib.MISSING)
			this.boost_tick = boost_tick;
	}

	public void set_tick(int tick) {
		if (tick != AltosLib.MISSING)
			this.tick = tick;
	}

	public double time() {
		if (tick == AltosLib.MISSING)
			return AltosLib.MISSING;
		return tick / 100.0;
	}

	public double boost_time() {
		if (boost_tick == AltosLib.MISSING)
			return AltosLib.MISSING;
		return boost_tick / 100.0;
	}

	/* AltosEepromRecordFull */

	public abstract void set_state(int state);
	public abstract void set_ground_accel(double ground_accel);
	public void set_flight(int flight) {
		if (flight != AltosLib.MISSING)
			this.flight = flight;
	}
	public int flight() {
		return flight;
	}

	public abstract void set_accel(double accel);
	public abstract void set_accel_g(double accel_plus_g, double accel_minus_g);
	public abstract void set_pressure(double pa);

	public abstract void set_temperature(double deg_c);
	public abstract void set_battery_voltage(double volts);

	public abstract void set_apogee_voltage(double volts);
	public abstract void set_main_voltage(double volts);

	public void set_temp_gps() {
		temp_gps = null;
	}

	public boolean gps_pending() {
		return temp_gps != null;
	}

	public AltosGPS make_temp_gps(boolean sats) {
		if (temp_gps == null) {
			temp_gps = new AltosGPS();
		}
		if (sats) {
			if (tick != temp_gps_sat_tick)
				temp_gps.cc_gps_sat = null;
			temp_gps_sat_tick = tick;
		}
		return temp_gps;
	}

	public abstract void set_ground_pressure(double ground_pressure);
	public abstract void set_accel_ground(double along, double across, double through);
	public abstract void set_gyro_zero(double roll, double pitch, double yaw);
	public abstract void set_ms5607(int pres_val, int temp_val);
	public abstract void check_imu_wrap(AltosIMU imu);
	public abstract void set_imu(AltosIMU imu);
	public abstract void set_mag(AltosMag mag);
	public abstract void set_pyro_voltage(double volts);
	public abstract void set_ignitor_voltage(double[] voltage);
	public abstract void set_pyro_fired(int pyro_mask);

	public void copy(AltosFlightListener old) {
		flight = old.flight;
		tick = old.tick;
		boost_tick = old.boost_tick;
		temp_gps = old.temp_gps;
		temp_gps_sat_tick = old.temp_gps_sat_tick;
	}

	public void init() {
		flight = AltosLib.MISSING;
		tick = AltosLib.MISSING;
		boost_tick = AltosLib.MISSING;
		temp_gps_sat_tick = AltosLib.MISSING;
	}
}