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.
22 import java.awt.event.*;
24 import org.altusmetrum.altoslib_7.*;
25 import org.altusmetrum.altosuilib_7.*;
27 public class AltosDescent extends AltosUIFlightTab {
29 class Height extends AltosUIUnitsIndicator {
30 public double value(AltosState state, int i) { return state.height(); }
32 public Height (Container container, int x, int y) {
33 super (container, x, y, AltosConvert.height, "Height");
37 class Speed extends AltosUIUnitsIndicator {
38 public double value(AltosState state, int i) { return state.speed(); }
40 public Speed (Container container, int x, int y) {
41 super (container, x, y, AltosConvert.speed, "Speed");
45 class Lat extends AltosUIUnitsIndicator {
47 public boolean hide (AltosState state, int i) { return state.gps == null || !state.gps.connected; }
49 public double value(AltosState state, int i) {
50 if (state.gps == null)
51 return AltosLib.MISSING;
52 if (!state.gps.connected)
53 return AltosLib.MISSING;
57 public Lat (Container container, int x, int y) {
58 super (container, x, y, AltosConvert.latitude, "Latitude");
62 class Lon extends AltosUIUnitsIndicator {
63 public boolean hide (AltosState state, int i) { return state.gps == null || !state.gps.connected; }
65 public double value(AltosState state, int i) {
66 if (state.gps == null)
67 return AltosLib.MISSING;
68 if (!state.gps.connected)
69 return AltosLib.MISSING;
73 public Lon (Container container, int x, int y) {
74 super (container, x, y, AltosConvert.longitude, "Longitude");
78 class Apogee extends AltosUIUnitsIndicator {
79 public boolean hide(double v) { return v == AltosLib.MISSING; }
80 public double value(AltosState state, int i) { return state.apogee_voltage; }
81 public double good() { return AltosLib.ao_igniter_good; }
83 public Apogee (Container container, int y) {
84 super(container, 0, y, 3, AltosConvert.voltage, "Apogee Igniter Voltage", 1, true, 3);
88 class Main extends AltosUIUnitsIndicator {
89 public boolean hide(double v) { return v == AltosLib.MISSING; }
90 public double value(AltosState state, int i) { return state.main_voltage; }
91 public double good() { return AltosLib.ao_igniter_good; }
93 public Main (Container container, int y) {
94 super(container, 0, y, 3, AltosConvert.voltage, "Main Igniter Voltage", 1, true, 3);
98 class Distance extends AltosUIUnitsIndicator {
99 public double value(AltosState state, int i) {
100 if (state.from_pad != null)
101 return state.from_pad.distance;
103 return AltosLib.MISSING;
106 public Distance(Container container, int x, int y) {
107 super(container, x, y, AltosConvert.distance, "Ground Distance");
111 class Range extends AltosUIUnitsIndicator {
112 public double value(AltosState state, int i) {
115 public Range (Container container, int x, int y) {
116 super (container, x, y, AltosConvert.distance, "Range");
120 class Bearing extends AltosUIIndicator {
121 public void show (AltosState state, AltosListenerState listener_state) {
122 if (state.from_pad != null && state.from_pad.bearing != AltosLib.MISSING) {
123 show( String.format("%3.0f°", state.from_pad.bearing),
124 state.from_pad.bearing_words(
125 AltosGreatCircle.BEARING_LONG));
127 show("Missing", "Missing");
130 public Bearing (Container container, int x, int y) {
131 super (container, x, y, 1, "Bearing", 2, false, 1, 2);
135 class Elevation extends AltosUIIndicator {
136 public void show (AltosState state, AltosListenerState listener_state) {
137 if (state.elevation == AltosLib.MISSING)
140 show("%3.0f°", state.elevation);
142 public Elevation (Container container, int x, int y) {
143 super (container, x, y, "Elevation", 1, false, 1);
147 public String getName() {
151 public AltosDescent() {
152 /* Elements in descent display */
153 add(new Speed(this, 0, 0));
154 add(new Height(this, 2, 0));
155 add(new Elevation(this, 0, 1));
156 add(new Range(this, 2, 1));
157 add(new Bearing(this, 0, 2));
158 add(new Distance(this, 0, 3));
159 add(new Lat(this, 0, 4));
160 add(new Lon(this, 2, 4));
161 add(new Apogee(this, 5));
162 add(new Main(this, 6));