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_14.*;
26 import org.altusmetrum.altosuilib_14.*;
28 public class AltosAscent extends AltosUIFlightTab {
31 class Height extends AltosUIUnitsIndicator {
33 public double value(AltosState state, int i) {
35 return state.height();
37 return state.max_height();
40 public Height(Container container, int y) {
41 super(container, y, AltosConvert.height, "Height", 2, false, 1);
45 class Speed extends AltosUIUnitsIndicator {
46 public double value(AltosState state, int i) {
50 return state.max_speed();
53 public Speed(Container container, int y) {
54 super(container, y, AltosConvert.speed, "Speed", 2, false, 1);
58 class Accel extends AltosUIUnitsIndicator {
59 public boolean hide(double v) { return v == AltosLib.MISSING; }
61 public double value(AltosState state, int i) {
63 return state.acceleration();
65 return state.max_acceleration();
68 public Accel(Container container, int y) {
69 super(container, y, AltosConvert.accel, "Acceleration", 2, false, 1);
73 class Orient extends AltosUIUnitsIndicator {
75 public boolean hide(double v) { return v == AltosLib.MISSING; }
77 public double value(AltosState state, int i) {
79 return state.orient();
81 return state.max_orient();
84 public Orient(Container container, int y) {
85 super(container, y, AltosConvert.orient, "Tilt Angle", 2, false, 1);
90 class Apogee extends AltosUIUnitsIndicator {
92 public double value(AltosState state, int i) {
93 return state.apogee_voltage;
96 public boolean good(double v) { return v >= AltosLib.ao_igniter_good; }
97 public boolean hide(double v) { return v == AltosLib.MISSING; }
99 public Apogee (Container container, int y) {
100 super(container, y, AltosConvert.voltage, "Apogee Igniter Voltage", 1, true, 2);
104 class Main extends AltosUIUnitsIndicator {
105 public double value(AltosState state, int i) {
106 return state.main_voltage;
109 public boolean good(double v) { return v >= AltosLib.ao_igniter_good; }
110 public boolean hide(double v) { return v == AltosLib.MISSING; }
112 public Main (Container container, int y) {
113 super(container, y, AltosConvert.voltage, "Main Igniter Voltage", 1, true, 2);
117 class Lat extends AltosUIUnitsIndicator {
119 public boolean hide(AltosState state, int i) {
120 return state.gps == null || !state.gps.connected;
123 public double value(AltosState state, int i) {
124 if (state.gps == null)
125 return AltosLib.MISSING;
126 if (!state.gps.connected)
127 return AltosLib.MISSING;
128 return state.gps.lat;
131 Lat (Container container, int y) {
132 super (container, y, AltosConvert.latitude, "Latitude", 1, false, 2);
136 class Lon extends AltosUIUnitsIndicator {
138 public boolean hide(AltosState state, int i) {
139 return state.gps == null || !state.gps.connected;
142 public double value(AltosState state, int i) {
143 if (state.gps == null)
144 return AltosLib.MISSING;
145 if (!state.gps.connected)
146 return AltosLib.MISSING;
147 return state.gps.lon;
150 Lon (Container container, int y) {
151 super (container, y, AltosConvert.longitude, "Longitude", 1, false, 2);
155 public void font_size_changed(int font_size) {
156 super.font_size_changed(font_size);
157 cur.setFont(AltosUILib.label_font);
158 max.setFont(AltosUILib.label_font);
161 public void labels(GridBagLayout layout, int y) {
162 GridBagConstraints c;
164 cur = new JLabel("Current");
165 cur.setFont(AltosUILib.label_font);
166 c = new GridBagConstraints();
167 c.gridx = 2; c.gridy = y;
168 c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad);
169 layout.setConstraints(cur, c);
172 max = new JLabel("Maximum");
173 max.setFont(AltosUILib.label_font);
174 c.gridx = 3; c.gridy = y;
175 layout.setConstraints(max, c);
179 public String getName() {
183 public AltosAscent() {
186 add(new Height(this, y++));
187 add(new Speed(this, y++));
188 add(new Accel(this, y++));
189 add(new Orient(this, y++));
190 add(new Lat(this, y++));
191 add(new Lon(this, y++));
192 add(new Apogee(this, y++));
193 add(new Main(this, y++));