2 * Copyright © 2010 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; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 import org.altusmetrum.altoslib_9.*;
22 import org.altusmetrum.altosuilib_9.*;
24 public class AltosPad extends AltosUIFlightTab {
26 class Battery extends AltosUIVoltageIndicator {
27 public double voltage(AltosState state) { return state.battery_voltage; }
28 public double good() { return AltosLib.ao_battery_good; }
29 public Battery (AltosUIFlightTab container, int y) { super(container, y, "Battery Voltage", 2); }
32 class Apogee extends AltosUIVoltageIndicator {
33 public boolean hide(double v) { return v == AltosLib.MISSING; }
34 public double voltage(AltosState state) { return state.apogee_voltage; }
35 public double good() { return AltosLib.ao_igniter_good; }
36 public Apogee (AltosUIFlightTab container, int y) { super(container, y, "Apogee Igniter Voltage", 2); }
39 class Main extends AltosUIVoltageIndicator {
40 public boolean hide(double v) { return v == AltosLib.MISSING; }
41 public double voltage(AltosState state) { return state.main_voltage; }
42 public double good() { return AltosLib.ao_igniter_good; }
43 public Main (AltosUIFlightTab container, int y) { super(container, y, "Main Igniter Voltage", 2); }
46 class LoggingReady extends AltosUIIndicator {
47 public void show (AltosState state, AltosListenerState listener_state) {
48 if (state == null || state.flight == AltosLib.MISSING) {
51 if (state.flight != 0) {
52 if (state.state() <= Altos.ao_flight_pad)
53 show("Ready to record");
54 else if (state.state() < Altos.ao_flight_landed ||
55 state.state() == AltosLib.ao_flight_stateless)
56 show("Recording data");
58 show("Recorded data");
61 set_lights(state.flight != 0);
64 public LoggingReady (AltosUIFlightTab container, int y) {
65 super(container, y, "On-board Data Logging", 1, true, 2);
69 class GPSLocked extends AltosUIIndicator {
70 public void show (AltosState state, AltosListenerState listener_state) {
71 if (state == null || state.gps == null)
74 int sol = state.gps.nsat;
75 int sat = state.gps.cc_gps_sat == null ? 0 : state.gps.cc_gps_sat.length;
76 show("%d in solution", sol, "%d in view", sat);
77 set_lights(state.gps.locked && sol >= 4);
80 public GPSLocked (AltosUIFlightTab container, int y) {
81 super (container, y, "GPS Locked", 2, true, 1);
85 class GPSReady extends AltosUIIndicator {
86 public void show (AltosState state, AltosListenerState listener_state) {
87 if (state == null || state.gps == null)
93 show("Waiting %d", state.gps_waiting);
94 set_lights(state.gps_ready);
97 public GPSReady (AltosUIFlightTab container, int y) {
98 super (container, y, "GPS Ready", 1, true, 2);
102 class ReceiverBattery extends AltosUIVoltageIndicator {
104 public double voltage(AltosState state) { return AltosLib.MISSING; }
106 public double good() { return AltosLib.ao_battery_good; }
108 public boolean hide(AltosState state, AltosListenerState listener_state, int i) {
109 return value(state, listener_state, i) == AltosLib.MISSING;
112 public double value(AltosState state, AltosListenerState listener_state, int i) {
113 if (listener_state == null)
114 return AltosLib.MISSING;
115 return listener_state.battery;
118 public ReceiverBattery (AltosUIFlightTab container, int y) {
119 super(container, y, "Receiver Battery", 2);
123 boolean report_pad(AltosState state) {
124 if ((state.state() == AltosLib.ao_flight_stateless ||
125 state.state() < AltosLib.ao_flight_pad) &&
127 state.gps.lat != AltosLib.MISSING)
134 class PadLat extends AltosUIIndicator {
136 double last_lat = AltosLib.MISSING - 1;
138 public void show (AltosState state, AltosListenerState listener_state) {
139 double lat = AltosLib.MISSING;
143 if (report_pad(state)) {
145 label = "Pad Latitude";
151 if (lat != last_lat) {
152 if (lat != AltosLib.MISSING) {
153 show(AltosConvert.latitude.show(10, lat));
161 public void reset() {
163 last_lat = AltosLib.MISSING - 1;
166 public PadLat (AltosUIFlightTab container, int y) {
167 super (container, y, "Pad Latitude", 1, false, 2);
171 class PadLon extends AltosUIIndicator {
173 double last_lon = AltosLib.MISSING - 1;
175 public void show (AltosState state, AltosListenerState listener_state) {
176 double lon = AltosLib.MISSING;
180 if (report_pad(state)) {
182 label = "Pad Longitude";
188 if (lon != last_lon) {
189 if (lon != AltosLib.MISSING) {
190 show(AltosConvert.longitude.show(10, lon));
198 public void reset() {
200 last_lon = AltosLib.MISSING - 1;
203 public PadLon (AltosUIFlightTab container, int y) {
204 super (container, y, "Pad Longitude", 1, false, 2);
208 class PadAlt extends AltosUIIndicator {
210 double last_alt = AltosLib.MISSING - 1;
212 public void show (AltosState state, AltosListenerState listener_state) {
213 double alt = AltosLib.MISSING;
217 if (report_pad(state)) {
219 label = "Pad Altitude";
225 if (alt != last_alt) {
226 if (alt != AltosLib.MISSING) {
227 show(AltosConvert.height.show(5, alt));
235 public void reset() {
237 last_alt = AltosLib.MISSING - 1;
240 public PadAlt (AltosUIFlightTab container, int y) {
241 super (container, y, "Pad Altitude", 1, false, 2);
244 public String getName() { return "Pad"; }
248 add(new Battery(this, y++));
249 add(new ReceiverBattery(this, y++));
250 add(new Apogee(this, y++));
251 add(new Main(this, y++));
252 add(new LoggingReady(this, y++));
253 add(new GPSLocked(this, y++));
254 add(new GPSReady(this, y++));
255 add(new PadLat(this, y++));
256 add(new PadLon(this, y++));
257 add(new PadAlt(this, y++));