-public class AltosTelemetry {
- int version;
- String callsign;
- int serial;
- int flight;
- int rssi;
- int status;
- String state;
- int tick;
- int accel;
- int pres;
- int temp;
- int batt;
- int drogue;
- int main;
- int flight_accel;
- int ground_accel;
- int flight_vel;
- int flight_pres;
- int ground_pres;
- int accel_plus_g;
- int accel_minus_g;
- AltosGPS gps;
- AltosGPSTracking gps_tracking;
-
- int parse_int(String v) throws ParseException {
- try {
- return Integer.parseInt(v);
- } catch (NumberFormatException e) {
- throw new ParseException("error parsing int " + v, 0);
- }
- }
-
- int parse_hex(String v) throws ParseException {
- try {
- return Integer.parseInt(v, 16);
- } catch (NumberFormatException e) {
- throw new ParseException("error parsing hex " + v, 0);
- }
- }
-
- double parse_double(String v) throws ParseException {
- try {
- return Double.parseDouble(v);
- } catch (NumberFormatException e) {
- throw new ParseException("error parsing double " + v, 0);
- }
- }
-
- double parse_coord(String coord) throws ParseException {
- String[] dsf = coord.split("\\D+");
-
- if (dsf.length != 3) {
- throw new ParseException("error parsing coord " + coord, 0);
- }
- int deg = parse_int(dsf[0]);
- int min = parse_int(dsf[1]);
- int frac = parse_int(dsf[2]);
-
- double r = deg + (min + frac / 10000.0) / 60.0;
- if (coord.endsWith("S") || coord.endsWith("W"))
- r = -r;
- return r;
- }
-
- String strip_suffix(String v, String suffix) {
- if (v.endsWith(suffix))
- return v.substring(0, v.length() - suffix.length());
- return v;
- }
-
- void word(String v, String m) throws ParseException {
- if (!v.equals(m)) {
- throw new ParseException("error matching '" + v + "' '" + m + "'", 0);
- }
- }
-
- public AltosTelemetry(String line) throws ParseException {