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.
25 /* EEProm command letters */
26 static final int AO_LOG_FLIGHT = 'F';
27 static final int AO_LOG_SENSOR = 'A';
28 static final int AO_LOG_TEMP_VOLT = 'T';
29 static final int AO_LOG_DEPLOY = 'D';
30 static final int AO_LOG_STATE = 'S';
31 static final int AO_LOG_GPS_TIME = 'G';
32 static final int AO_LOG_GPS_LAT = 'N';
33 static final int AO_LOG_GPS_LON = 'W';
34 static final int AO_LOG_GPS_ALT = 'H';
35 static final int AO_LOG_GPS_SAT = 'V';
36 static final int AO_LOG_GPS_DATE = 'Y';
38 /* Added for 'serial-number' entry in eeprom files */
39 static final int AO_LOG_SERIAL_NUMBER = 1000;
41 /* Added to flag invalid records */
42 static final int AO_LOG_INVALID = -1;
44 /* Flight state numbers and names */
45 static final int ao_flight_startup = 0;
46 static final int ao_flight_idle = 1;
47 static final int ao_flight_pad = 2;
48 static final int ao_flight_boost = 3;
49 static final int ao_flight_fast = 4;
50 static final int ao_flight_coast = 5;
51 static final int ao_flight_drogue = 6;
52 static final int ao_flight_main = 7;
53 static final int ao_flight_landed = 8;
54 static final int ao_flight_invalid = 9;
56 static HashMap<String,Integer> string_to_state = new HashMap<String,Integer>();
58 string_to_state.put("startup", ao_flight_startup);
59 string_to_state.put("idle", ao_flight_idle);
60 string_to_state.put("pad", ao_flight_pad);
61 string_to_state.put("boost", ao_flight_boost);
62 string_to_state.put("fast", ao_flight_fast);
63 string_to_state.put("coast", ao_flight_coast);
64 string_to_state.put("drogue", ao_flight_drogue);
65 string_to_state.put("main", ao_flight_main);
66 string_to_state.put("landed", ao_flight_landed);
67 string_to_state.put("invalid", ao_flight_invalid);
70 static String[] state_to_string = {
83 static public int state(String state) {
84 if (string_to_state.containsKey(state))
85 return string_to_state.get(state);
86 return ao_flight_invalid;
89 static public String state_name(int state) {
90 if (state < 0 || state_to_string.length <= state)
92 return state_to_string[state];