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; 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.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
23 import java.awt.event.*;
25 import org.altusmetrum.altoslib_11.*;
26 import org.altusmetrum.altosuilib_11.*;
28 public class AltosDescent extends AltosUIFlightTab {
30 class Height extends AltosUIUnitsIndicator {
31 public double value(AltosState state, int i) { return state.height(); }
33 public Height (Container container, int x, int y) {
34 super (container, x, y, AltosConvert.height, "Height");
38 class Speed extends AltosUIUnitsIndicator {
39 public double value(AltosState state, int i) { return state.speed(); }
41 public Speed (Container container, int x, int y) {
42 super (container, x, y, AltosConvert.speed, "Speed");
46 class Lat extends AltosUIUnitsIndicator {
48 public boolean hide (AltosState state, int i) { return state.gps == null || !state.gps.connected; }
50 public double value(AltosState state, int i) {
51 if (state.gps == null)
52 return AltosLib.MISSING;
53 if (!state.gps.connected)
54 return AltosLib.MISSING;
58 public Lat (Container container, int x, int y) {
59 super (container, x, y, AltosConvert.latitude, "Latitude");
63 class Lon extends AltosUIUnitsIndicator {
64 public boolean hide (AltosState state, int i) { return state.gps == null || !state.gps.connected; }
66 public double value(AltosState state, int i) {
67 if (state.gps == null)
68 return AltosLib.MISSING;
69 if (!state.gps.connected)
70 return AltosLib.MISSING;
74 public Lon (Container container, int x, int y) {
75 super (container, x, y, AltosConvert.longitude, "Longitude");
79 class Apogee extends AltosUIUnitsIndicator {
80 public boolean hide(double v) { return v == AltosLib.MISSING; }
81 public double value(AltosState state, int i) { return state.apogee_voltage; }
82 public double good() { return AltosLib.ao_igniter_good; }
84 public Apogee (Container container, int y) {
85 super(container, 0, y, 3, AltosConvert.voltage, "Apogee Igniter Voltage", 1, true, 3);
89 class Main extends AltosUIUnitsIndicator {
90 public boolean hide(double v) { return v == AltosLib.MISSING; }
91 public double value(AltosState state, int i) { return state.main_voltage; }
92 public double good() { return AltosLib.ao_igniter_good; }
94 public Main (Container container, int y) {
95 super(container, 0, y, 3, AltosConvert.voltage, "Main Igniter Voltage", 1, true, 3);
99 class Distance extends AltosUIUnitsIndicator {
100 public double value(AltosState state, int i) {
101 if (state.from_pad != null)
102 return state.from_pad.distance;
104 return AltosLib.MISSING;
107 public Distance(Container container, int x, int y) {
108 super(container, x, y, AltosConvert.distance, "Ground Distance");
112 class Range extends AltosUIUnitsIndicator {
113 public double value(AltosState state, int i) {
116 public Range (Container container, int x, int y) {
117 super (container, x, y, AltosConvert.distance, "Range");
121 class Bearing extends AltosUIIndicator {
122 public void show (AltosState state, AltosListenerState listener_state) {
123 if (state.from_pad != null && state.from_pad.bearing != AltosLib.MISSING) {
124 show( String.format("%3.0f°", state.from_pad.bearing),
125 state.from_pad.bearing_words(
126 AltosGreatCircle.BEARING_LONG));
128 show("Missing", "Missing");
131 public Bearing (Container container, int x, int y) {
132 super (container, x, y, 1, "Bearing", 2, false, 1, 2);
136 class Elevation extends AltosUIIndicator {
137 public void show (AltosState state, AltosListenerState listener_state) {
138 if (state.elevation == AltosLib.MISSING)
141 show("%3.0f°", state.elevation);
143 public Elevation (Container container, int x, int y) {
144 super (container, x, y, "Elevation", 1, false, 1);
148 public String getName() {
152 public AltosDescent() {
153 /* Elements in descent display */
154 add(new Speed(this, 0, 0));
155 add(new Height(this, 2, 0));
156 add(new Elevation(this, 0, 1));
157 add(new Range(this, 2, 1));
158 add(new Bearing(this, 0, 2));
159 add(new Distance(this, 0, 3));
160 add(new Lat(this, 0, 4));
161 add(new Lon(this, 2, 4));
162 add(new Apogee(this, 5));
163 add(new Main(this, 6));