Everything has switched to JSON now.
Signed-off-by: Keith Packard <keithp@keithp.com>
import java.io.*;
-public class AltosCompanion implements AltosHashable, AltosJsonable {
+public class AltosCompanion implements AltosJsonable {
public final static int board_id_telescience = 0x0a;
public final static int MAX_CHANNELS = 12;
companion_data = new int[channels];
}
- public AltosHashSet hashSet() {
- AltosHashSet h = new AltosHashSet();
-
- h.putInt("tick", tick);
- h.putInt("board_id", board_id);
- h.putInt("update_period", update_period);
- h.putInt("channels", channels);
- h.putIntArray("companion_data", companion_data);
- return h;
- }
-
public AltosJson json() {
AltosJson j = new AltosJson();
return j;
}
- public AltosCompanion(AltosHashSet h) {
- tick = h.getInt("tick", tick);
- board_id = h.getInt("board_id", board_id);
- update_period = h.getInt("update_period", update_period);
- channels = h.getInt("channels", channels);
- companion_data = h.getIntArray("companion_data", new int[channels]);
- }
-
- public static AltosCompanion fromHashSet(AltosHashSet h, AltosCompanion def) {
- if (h == null)
- return def;
-
- return new AltosCompanion(h);
- }
-
public AltosCompanion(AltosJson j) {
tick = j.get_int("tick", tick);
board_id = j.get_int("board_id", board_id);
return diff < 0.010;
}
- public AltosHashSet hashSet() {
- AltosHashSet h = new AltosHashSet();
-
- h.putDouble("frequency", frequency);
- h.putString("description", description);
- return h;
- }
-
public AltosJson json() {
AltosJson j = new AltosJson();
description = d;
}
- private AltosFrequency(AltosHashSet h) {
- frequency = h.getDouble("frequency", 0.0);
- description = h.getString("description", "");
- }
-
- public static AltosFrequency fromHashSet(AltosHashSet h, AltosFrequency def) {
- if (h == null)
- return def;
- return new AltosFrequency(h);
- }
-
private AltosFrequency(AltosJson j) {
frequency = j.get_double("frequency", 0.0);
description = j.get_string("description", "");
import java.util.concurrent.*;
import java.io.*;
-public class AltosGPS implements Cloneable, AltosHashable, AltosJsonable {
+public class AltosGPS implements Cloneable, AltosJsonable {
public final static int MISSING = AltosLib.MISSING;
}
}
- public AltosHashSet hashSet() {
- AltosHashSet h = new AltosHashSet();
-
- h.putInt("nsat", nsat);
- h.putBoolean("locked", locked);
- h.putBoolean("connected", connected);
- h.putDouble("lat", lat);
- h.putDouble("lon", lon);
- h.putDouble("alt", alt);
- h.putInt("year", year);
- h.putInt("month", month);
- h.putInt("day", day);
- h.putInt("hour", hour);
- h.putInt("minute", minute);
- h.putInt("second", second);
-
- h.putDouble("ground_speed", ground_speed);
- h.putInt("course", course);
- h.putDouble("climb_rate", climb_rate);
- h.putDouble("pdop", pdop);
- h.putDouble("hdop", hdop);
- h.putDouble("vdop", vdop);
- h.putDouble("h_error", h_error);
- h.putDouble("v_error", v_error);
- h.putString("cc_gps_sat", AltosGPSSat.toString(cc_gps_sat));
- return h;
- }
-
public AltosJson json() {
AltosJson j = new AltosJson();
return j;
}
- public AltosGPS(AltosHashSet h) {
- init();
- nsat = h.getInt("nsat", nsat);
- locked = h.getBoolean("locked", locked);
- connected = h.getBoolean("connected", connected);
- lat = h.getDouble("lat", lat);
- lon = h.getDouble("lon", lon);
- alt = h.getDouble("alt", alt);
- year = h.getInt("year", year);
- month = h.getInt("month", month);
- day = h.getInt("day", day);
- hour = h.getInt("hour", hour);
- minute = h.getInt("minute", minute);
- second = h.getInt("second", second);
-
- ground_speed = h.getDouble("ground_speed", ground_speed);
- course = h.getInt("course", course);
- climb_rate = h.getDouble("climb_rate", climb_rate);
- pdop = h.getDouble("pdop", pdop);
- hdop = h.getDouble("hdop", hdop);
- vdop = h.getDouble("vdop", vdop);
- h_error = h.getDouble("h_error", h_error);
- v_error = h.getDouble("v_error", v_error);
- cc_gps_sat = AltosGPSSat.array(h.getString("cc_gps_sat", null));
- }
-
public AltosGPS(AltosJson j) {
init();
nsat = j.get_int("nsat", nsat);
cc_gps_sat = AltosGPSSat.json_array(j.get("cc_gps_sat"));
}
- public static AltosGPS fromHashSet(AltosHashSet h, AltosGPS def) {
- if (h == null)
- return def;
-
- return new AltosGPS(h);
- }
-
public static AltosGPS fromJson(AltosJson j, AltosGPS def) {
if (j == null)
return def;
public AltosGPSSat() {
}
- public AltosHashSet hashSet() {
- AltosHashSet h = new AltosHashSet();
- h.putInt("svid", svid);
- h.putInt("c_n0", c_n0);
- return h;
- }
-
public AltosJson json() {
AltosJson j = new AltosJson();
j.put("svid", svid);
return j;
}
- private AltosGPSSat(AltosHashSet h) {
- svid = h.getInt("svid", 0);
- c_n0 = h.getInt("c_n0", 0);
- }
-
private AltosGPSSat(AltosJson j) {
svid = j.get_int("svid", 0);
c_n0 = j.get_int("c_n0", 0);
}
- static public AltosGPSSat fromHashSet(AltosHashSet h, AltosGPSSat def) {
- if (h == null)
- return def;
- return new AltosGPSSat(h);
- }
-
static public AltosGPSSat[] json_array(AltosJson j) {
if (j == null)
return null;
sats[i] = new AltosGPSSat(j.get(i));
return sats;
}
-
- static public AltosGPSSat[] array(String string) {
-
- if (string == null)
- return null;
-
- try {
- StringReader reader = new StringReader(string);
- ArrayList<AltosGPSSat> array = new ArrayList<AltosGPSSat>();
- String element;
-
- while ((element = AltosHashSet.get_token(reader)) != null) {
- AltosGPSSat sat = AltosGPSSat.fromHashSet(AltosHashSet.fromString(element), null);
- if (sat != null)
- array.add(sat);
- }
- return array.toArray(new AltosGPSSat[0]);
- } catch (IOException ie) {
- return null;
- }
- }
-
- public static String toString(AltosGPSSat[] sats) {
- if (sats == null)
- return null;
-
- try {
- StringWriter writer = new StringWriter();
-
- for (AltosGPSSat g : sats) {
- String element = g.hashSet().toString();
- AltosHashSet.put_token(writer, element);
- }
- return writer.toString();
- } catch (IOException ie) {
- return null;
- }
- }
}
import java.lang.Math;
import java.io.*;
-public class AltosGreatCircle implements Cloneable, AltosHashable, AltosJsonable {
+public class AltosGreatCircle implements Cloneable, AltosJsonable {
public double distance;
public double bearing;
public double range;
elevation = 0;
}
- public AltosHashSet hashSet() {
- AltosHashSet h = new AltosHashSet();
-
- h.putDouble("distance", distance);
- h.putDouble("bearing", bearing);
- h.putDouble("range", range);
- h.putDouble("elevation", elevation);
-
- return h;
- }
-
public AltosJson json() {
AltosJson j = new AltosJson();
return j;
}
- public AltosGreatCircle(AltosHashSet h) {
- this();
-
- distance = h.getDouble("distance", distance);
- bearing = h.getDouble("bearing", bearing);
- range = h.getDouble("range", range);
- elevation = h.getDouble("elevation", elevation);
- }
-
- public static AltosGreatCircle fromHashSet(AltosHashSet h, AltosGreatCircle def) {
- if (h == null)
- return def;
-
- return new AltosGreatCircle(h);
- }
-
public AltosGreatCircle(AltosJson j) {
this();
+++ /dev/null
-/*
- * Copyright © 2016 Keith Packard <keithp@keithp.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-
-package org.altusmetrum.altoslib_11;
-
-import java.io.*;
-import java.util.*;
-import java.text.*;
-
-public class AltosHashSet extends Hashtable<String,String> {
- static private int get(StringReader reader) throws IOException {
- return reader.read();
- }
-
- static public String get_token(StringReader reader) throws IOException {
- int c = get(reader);
-
- if (c == -1)
- return null;
-
- ArrayList<Integer> chars = new ArrayList<Integer>();
-
- for (;;) {
- if (c == -1 || c == ';')
- break;
- if (c == '\\')
- c = get(reader);
- chars.add(c);
- c = get(reader);
- }
- int[] ch = new int[chars.size()];
- for (int i = 0; i < ch.length; i++)
- ch[i] = chars.get(i);
- return new String(ch, 0, ch.length);
- }
-
- static private void put(StringWriter writer, int c) throws IOException {
- writer.write(c);
- }
-
- static public void put_token(StringWriter writer, String token) throws IOException {
- for (int i = 0; i < token.length(); i++) {
- int c = token.codePointAt(i);
-
- switch (c) {
- case ';':
- case '\\':
- put(writer, '\\');
- }
- put(writer, c);
- }
- put(writer, ';');
- }
-
- public String toString() {
- try {
- StringWriter writer = new StringWriter();
-
- for (String key : keySet()) {
- String value = get(key);
- put_token(writer, key);
- put_token(writer, value);
- }
- return writer.toString();
- } catch (IOException ie) {
- return null;
- }
- }
-
- public void putBoolean(String key, boolean value) {
- put(key, value ? "t" : "f");
- }
-
- public boolean getBoolean(String key, boolean def) {
- String value = get(key);
-
- if (value == null)
- return def;
- if (value.equals("t"))
- return true;
- if (value.equals("f"))
- return false;
- return def;
- }
-
- public void putInt(String key, int value) {
- put(key, Integer.toString(value));
- }
-
- public int getInt(String key, int def) {
- String value = get(key);
-
- if (value == null)
- return def;
- try {
- return AltosParse.parse_int(value);
- } catch (ParseException pe) {
- return def;
- }
- }
-
- public void putIntArray(String key, int value[]) {
- if (value == null)
- return;
-
- StringWriter writer = new StringWriter();
-
- try {
- for (int i = 0; i < value.length; i++)
- put_token(writer, Integer.toString(value[i]));
- put(key, writer.toString());
- } catch (IOException ie) {
- }
- }
-
- public int[] getIntArray(String key, int[] def) {
- String value = get(key);
-
- if (value == null)
- return def;
- try {
- StringReader reader = new StringReader(value);
- ArrayList<Integer> array = new ArrayList<Integer>();
- String elt;
-
- while ((elt = get_token(reader)) != null)
- array.add(AltosParse.parse_int(elt));
- int[] ret = new int[array.size()];
- for (int i = 0; i < ret.length; i++)
- ret[i] = array.get(i);
- return ret;
- } catch (ParseException pe) {
- return def;
- } catch (IOException ie) {
- return def;
- }
- }
-
- public void putLong(String key, long value) {
- put(key, Long.toString(value));
- }
-
- public long getLong(String key, long def) {
- String value = get(key);
-
- if (value == null)
- return def;
- try {
- return AltosParse.parse_long(value);
- } catch (ParseException pe) {
- return def;
- }
- }
-
- public void putDouble(String key, double value) {
- put(key, AltosParse.format_double_net(value));
- }
-
- public double getDouble(String key, double def) {
- String value = get(key);
-
- if (value == null)
- return def;
- try {
- return AltosParse.parse_double_net(value);
- } catch (ParseException pe) {
- return def;
- }
- }
-
- public void putDoubleArray(String key, double value[]) {
- if (value == null)
- return;
-
- StringWriter writer = new StringWriter();
-
- try {
- for (int i = 0; i < value.length; i++)
- put_token(writer, AltosParse.format_double_net(value[i]));
- put(key, writer.toString());
- } catch (IOException ie) {
- }
- }
-
- public double[] getDoubleArray(String key, double[] def) {
- String value = get(key);
-
- if (value == null)
- return def;
- try {
- StringReader reader = new StringReader(value);
- ArrayList<Double> array = new ArrayList<Double>();
- String elt;
-
- while ((elt = get_token(reader)) != null)
- array.add(AltosParse.parse_double_net(elt));
- double[] ret = new double[array.size()];
- for (int i = 0; i < ret.length; i++)
- ret[i] = array.get(i);
- return ret;
- } catch (ParseException pe) {
- return def;
- } catch (IOException ie) {
- return def;
- }
- }
-
- public String getString(String key, String def) {
- String value = get(key);
-
- if (value == null)
- return def;
- return value;
- }
-
- public void putString(String key, String value) {
- if (value != null)
- put(key, value);
- }
-
- public AltosHashSet getHash(String key) {
- String value = get(key);
-
- if (value == null)
- return null;
- try {
- return new AltosHashSet(value);
- } catch (IOException ie) {
- return null;
- }
- }
-
- public void putHash(String key, AltosHashSet h) {
- put(key, h.toString());
- }
-
- public void putHashable(String key, AltosHashable h) {
- if (h == null)
- return;
-
- put(key, h.hashSet().toString());
- }
-
- private AltosHashSet (String string) throws IOException {
- StringReader reader = new StringReader(string);
- String key, value;
-
- for (;;) {
- key = get_token(reader);
- value = get_token(reader);
- if (key == null || value == null)
- break;
- put(key, value);
- }
- }
-
- public AltosHashSet() {
- }
-
- static public AltosHashSet fromString(String string) {
- try {
- return new AltosHashSet(string);
- } catch (IOException ie) {
- return null;
- }
- }
-
- static public AltosHashSet[] array(String string) {
-
- if (string == null)
- return null;
-
- try {
- StringReader reader = new StringReader(string);
- ArrayList<AltosHashSet> array = new ArrayList<AltosHashSet>();
- String element;
-
- while ((element = get_token(reader)) != null)
- array.add(new AltosHashSet(element));
- return array.toArray(new AltosHashSet[0]);
- } catch (IOException ie) {
- return null;
- }
- }
-
- static public String toString(AltosHashSet[] sets) {
- if (sets == null)
- return null;
-
- try {
- StringWriter writer = new StringWriter();
-
- for (AltosHashSet h : sets) {
- String element = h.toString();
- put_token(writer, element);
- }
- return writer.toString();
- } catch (IOException ie) {
- return null;
- }
- }
-}
+++ /dev/null
-/*
- * Copyright © 2016 Keith Packard <keithp@keithp.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-
-package org.altusmetrum.altoslib_11;
-
-import java.io.*;
-
-public interface AltosHashable {
-
- public AltosHashSet hashSet();
-}
import java.util.concurrent.*;
import java.io.*;
-public class AltosIMU implements Cloneable, AltosHashable, AltosJsonable {
+public class AltosIMU implements Cloneable, AltosJsonable {
public int accel_along;
public int accel_across;
public int accel_through;
}
}
- public AltosIMU (AltosHashSet h) {
- this();
-
- accel_along = h.getInt("accel_along", accel_along);
- accel_across = h.getInt("accel_across", accel_across);
- accel_through = h.getInt("accel_through", accel_through);
-
- gyro_roll = h.getInt("gyro_roll", gyro_roll);
- gyro_pitch = h.getInt("gyro_pitch", gyro_pitch);
- gyro_yaw = h.getInt("gyro_yaw", gyro_yaw);
- }
-
public AltosIMU (AltosJson j) {
this();
gyro_yaw = j.get_int("gyro_yaw", gyro_yaw);
}
- static public AltosIMU fromHashSet(AltosHashSet h, AltosIMU def) {
- if (h == null)
- return def;
- return new AltosIMU(h);
- }
-
static public AltosIMU fromJson(AltosJson j, AltosIMU def) {
if (j == null)
return def;
return new AltosIMU(j);
}
- public AltosHashSet hashSet() {
- AltosHashSet h = new AltosHashSet();
-
- h.putInt("accel_along", accel_along);
- h.putInt("accel_across", accel_across);
- h.putInt("accel_through", accel_through);
-
- h.putInt("gyro_roll", gyro_roll);
- h.putInt("gyro_pitch", gyro_pitch);
- h.putInt("gyro_yaw", gyro_yaw);
- return h;
- }
-
public AltosJson json() {
AltosJson j = new AltosJson();
import java.util.concurrent.*;
import java.io.*;
-public class AltosMag implements Cloneable, AltosHashable, AltosJsonable {
+public class AltosMag implements Cloneable, AltosJsonable {
public int along;
public int across;
public int through;
}
}
- public AltosHashSet hashSet() {
- AltosHashSet h = new AltosHashSet();
-
- h.putInt("along", along);
- h.putInt("across", across);
- h.putInt("through", through);
- return h;
- }
-
public AltosJson json() {
AltosJson j = new AltosJson();
return j;
}
- public AltosMag(AltosHashSet h) {
- this();
-
- along = h.getInt("along", along);
- across = h.getInt("across", across);
- through = h.getInt("through", through);
- }
-
- public static AltosMag fromHashSet(AltosHashSet h, AltosMag def) {
- if (h == null)
- return def;
-
- return new AltosMag(h);
- }
-
public AltosMag(AltosJson j) {
this();
import java.util.concurrent.*;
import java.io.*;
-public class AltosMs5607 implements AltosHashable, AltosJsonable {
+public class AltosMs5607 implements AltosJsonable {
public int reserved;
public int sens;
public int off;
convert();
}
- public AltosHashSet hashSet() {
- AltosHashSet h = new AltosHashSet();
-
- h.putInt("reserved", reserved);
- h.putInt("sens", sens);
- h.putInt("off", off);
- h.putInt("tcs", tcs);
- h.putInt("tco", tco);
- h.putInt("tref", tref);
- h.putInt("tempsens", tempsens);
- h.putInt("crc", crc);
- h.putInt("raw_pres", raw_pres);
- h.putInt("raw_temp", raw_temp);
- h.putInt("pa", pa);
- h.putInt("cc", cc);
- return h;
- }
-
public AltosJson json() {
AltosJson j = new AltosJson();
return j;
}
- public AltosMs5607(AltosHashSet h) {
- this();
-
- reserved = h.getInt("reserved", reserved);
- sens = h.getInt("sens", sens);
- off = h.getInt("off", off);
- tcs = h.getInt("tcs", tcs);
- tco = h.getInt("tco", tco);
- tref = h.getInt("tref", tref);
- tempsens = h.getInt("tempsens", tempsens);
- crc = h.getInt("crc", crc);
- raw_pres = h.getInt("raw_pres", raw_pres);
- raw_temp = h.getInt("raw_temp", raw_temp);
- pa = h.getInt("pa", pa);
- cc = h.getInt("cc", cc);
- }
-
- public static AltosMs5607 fromHashSet(AltosHashSet h, AltosMs5607 def) {
- if (h == null)
- return def;
-
- return new AltosMs5607(h);
- }
-
public AltosMs5607(AltosJson j) {
this();
public abstract byte[] getBytes(String key, byte[] def);
public abstract void putBytes(String key, byte[] value);
- public AltosHashSet getHashSet(String key) {
- String value = getString(key, null);
-
- if (value == null)
- return null;
- return AltosHashSet.fromString(value);
- }
-
- public void putHashSet(String key, AltosHashSet h) {
- putString(key, h.toString());
- }
-
public AltosJson getJson(String key) {
String value = getString(key, null);
package org.altusmetrum.altoslib_11;
-public class AltosQuaternion implements AltosHashable, AltosJsonable {
+public class AltosQuaternion implements AltosJsonable {
double r; /* real bit */
double x, y, z; /* imaginary bits */
c_x * c_y * s_z - s_x * s_y * c_z);
}
- public AltosHashSet hashSet() {
- AltosHashSet h = new AltosHashSet();
-
- h.putDouble("r", r);
- h.putDouble("x", x);
- h.putDouble("y", y);
- h.putDouble("z", z);
- return h;
- }
-
public AltosJson json() {
AltosJson j = new AltosJson();
return j;
}
- public AltosQuaternion(AltosHashSet h) {
- if (h == null)
- return;
-
- r = h.getDouble("r", 1);
- x = h.getDouble("x", 0);
- y = h.getDouble("y", 0);
- z = h.getDouble("z", 0);
- }
-
public AltosQuaternion(AltosJson j) {
if (j == null)
return;
package org.altusmetrum.altoslib_11;
-public class AltosRotation implements AltosHashable, AltosJsonable {
+public class AltosRotation implements AltosJsonable {
private AltosQuaternion rotation;
public double tilt() {
rotation = up.vectors_to_rotation(orient);
}
- public AltosHashSet hashSet() {
- AltosHashSet h = new AltosHashSet();
-
- h.putHashable("rotation", rotation);
- return h;
- }
-
public AltosJson json() {
return rotation.json();
}
- public AltosRotation(AltosHashSet h) {
- rotation = new AltosQuaternion(h.getHash("rotation"));
- }
-
- public static AltosRotation fromHashSet(AltosHashSet h, AltosRotation def) {
- if (h == null)
- return def;
-
- return new AltosRotation(h);
- }
-
public AltosRotation(AltosJson j) {
rotation = new AltosQuaternion(j);
}
import java.io.*;
-public class AltosState implements Cloneable, AltosHashable {
+public class AltosState implements Cloneable, AltosJsonable {
public static final int set_position = 1;
public static final int set_gps = 2;
private int prev_tick;
public int boost_tick;
- class AltosValue implements AltosHashable, AltosJsonable {
+ class AltosValue implements AltosJsonable {
double value;
double prev_value;
private double max_value;
prev_set_time = set_time;
}
- public AltosHashSet hashSet() {
- AltosHashSet h = new AltosHashSet();
-
- h.putDouble("value", value);
- h.putDouble("prev_value", prev_value);
- h.putDouble("max_value", max_value);
- h.putDouble("set_time", set_time);
- h.putDouble("prev_set_time", prev_set_time);
- return h;
- }
-
public AltosJson json() {
AltosJson j = new AltosJson();
return j;
}
- AltosValue(AltosHashSet h) {
- this();
- if (h != null) {
- value = h.getDouble("value", value);
- prev_value = h.getDouble("prev_value", prev_value);
- max_value = h.getDouble("max_value", max_value);
- set_time = h.getDouble("set_time", 0);
- prev_set_time = h.getDouble("prev_set_time", 0);
- }
- }
-
AltosValue(AltosJson j) {
this();
if (j != null) {
}
- AltosValue AltosValue_fromHashSet(AltosHashSet h, AltosValue def) {
- if (h == null)
- return def;
- return new AltosValue(h);
- }
-
AltosValue AltosValue_fromJson(AltosJson j, AltosValue def) {
if (j == null)
return def;
return new AltosValue(j);
}
- class AltosCValue implements AltosHashable, AltosJsonable {
+ class AltosCValue implements AltosJsonable {
- class AltosIValue extends AltosValue implements AltosHashable, AltosJsonable {
+ class AltosIValue extends AltosValue implements AltosJsonable {
boolean can_max() {
return c_can_max();
}
super();
}
- AltosIValue(AltosHashSet h) {
- super(h);
- }
-
AltosIValue(AltosJson j) {
super(j);
}
computed = new AltosIValue();
}
- public AltosHashSet hashSet() {
- AltosHashSet h = new AltosHashSet();
-
- h.putHashable("measured", measured);
- h.putHashable("computed", computed);
- return h;
- }
-
public AltosJson json() {
AltosJson j = new AltosJson();
return j;
}
- AltosCValue(AltosHashSet h) {
- measured = new AltosIValue(h.getHash("measured"));
- computed = new AltosIValue(h.getHash("computed"));
- }
-
AltosCValue(AltosJson j) {
measured = new AltosIValue(j.get("measured"));
computed = new AltosIValue(j.get("computed"));
}
}
- AltosCValue AltosCValue_fromHashSet(AltosHashSet h, AltosCValue def) {
- if (h == null)
- return def;
- return new AltosCValue(h);
- }
-
AltosCValue AltosCValue_fromJson(AltosJson j, AltosCValue def) {
if (j == null)
return def;
super();
}
- AltosGpsGroundAltitude (AltosHashSet h) {
- super(h);
- }
-
AltosGpsGroundAltitude (AltosJson j) {
super(j);
}
}
- AltosGpsGroundAltitude AltosGpsGroundAltitude_fromHashSet(AltosHashSet h, AltosGpsGroundAltitude def) {
- if (h == null) return def;
- return new AltosGpsGroundAltitude(h);
- }
-
AltosGpsGroundAltitude AltosGpsGroundAltitude_fromJson(AltosJson j, AltosGpsGroundAltitude def) {
if (j == null) return def;
return new AltosGpsGroundAltitude(j);
super();
}
- AltosGroundPressure (AltosHashSet h) {
- super(h);
- }
-
AltosGroundPressure (AltosJson j) {
super(j);
}
}
- AltosGroundPressure AltosGroundPressure_fromHashSet(AltosHashSet h, AltosGroundPressure def) {
- if (h == null) return def;
- return new AltosGroundPressure(h);
- }
-
AltosGroundPressure AltosGroundPressure_fromJson(AltosJson j, AltosGroundPressure def) {
if (j == null) return def;
return new AltosGroundPressure(j);
ground_pressure.set_measured(pressure, time);
}
- class AltosAltitude extends AltosCValue implements AltosHashable {
+ class AltosAltitude extends AltosCValue {
private void set_speed(AltosValue v) {
if (!acceleration.is_measured() || !ascent)
super();
}
- AltosAltitude (AltosHashSet h) {
- super(h);
- }
-
AltosAltitude (AltosJson j) {
super(j);
}
}
- AltosAltitude AltosAltitude_fromHashSet(AltosHashSet h, AltosAltitude def) {
- if (h == null) return def;
- return new AltosAltitude(h);
- }
-
AltosAltitude AltosAltitude_fromJson(AltosJson j, AltosAltitude def) {
if (j == null) return def;
return new AltosAltitude(j);
private AltosAltitude altitude;
- class AltosGpsAltitude extends AltosValue implements AltosHashable {
+ class AltosGpsAltitude extends AltosValue {
private void set_gps_height() {
double a = value();
super();
}
- AltosGpsAltitude (AltosHashSet h) {
- super(h);
- }
-
AltosGpsAltitude (AltosJson j) {
super(j);
}
}
- AltosGpsAltitude AltosGpsAltitude_fromHashSet(AltosHashSet h, AltosGpsAltitude def) {
- if (h == null) return def;
- return new AltosGpsAltitude(h);
- }
-
AltosGpsAltitude AltosGpsAltitude_fromJson(AltosJson j, AltosGpsAltitude def) {
if (j == null) return def;
return new AltosGpsAltitude(j);
super();
}
- AltosPressure (AltosHashSet h) {
- super(h);
- }
-
AltosPressure (AltosJson j) {
super(j);
}
}
- AltosPressure AltosPressure_fromHashSet(AltosHashSet h, AltosPressure def) {
- if (h == null) return def;
- return new AltosPressure(h);
- }
-
AltosPressure AltosPressure_fromJson(AltosJson j, AltosPressure def) {
if (j == null) return def;
return new AltosPressure(j);
return AltosLib.MISSING;
}
- class AltosSpeed extends AltosCValue implements AltosHashable {
+ class AltosSpeed extends AltosCValue {
boolean can_max() {
return state < AltosLib.ao_flight_fast || state == AltosLib.ao_flight_stateless;
super();
}
- AltosSpeed (AltosHashSet h) {
- super(h);
- }
-
AltosSpeed (AltosJson j) {
super(j);
}
}
- AltosSpeed AltosSpeed_fromHashSet(AltosHashSet h, AltosSpeed def) {
- if (h == null) return def;
- return new AltosSpeed(h);
- }
-
AltosSpeed AltosSpeed_fromJson(AltosJson j, AltosSpeed def) {
if (j == null) return def;
return new AltosSpeed(j);
return AltosLib.MISSING;
}
- class AltosAccel extends AltosCValue implements AltosHashable {
+ class AltosAccel extends AltosCValue {
boolean can_max() {
return state < AltosLib.ao_flight_fast || state == AltosLib.ao_flight_stateless;
super();
}
- AltosAccel (AltosHashSet h) {
- super(h);
- }
-
AltosAccel (AltosJson j) {
super(j);
}
}
- AltosAccel AltosAccel_fromHashSet(AltosHashSet h, AltosAccel def) {
- if (h == null) return def;
- return new AltosAccel(h);
- }
-
AltosAccel AltosAccel_fromJson(AltosJson j, AltosAccel def) {
if (j == null) return def;
return new AltosAccel(j);
System.exit(1);
}
}
- if (false) {
- AltosHashSet hash = hashSet();
- String onetrip = hash.toString();
- AltosHashSet back = AltosHashSet.fromString(onetrip);
- AltosState tripstate = AltosState.fromHashSet(back);
- AltosHashSet triphash = tripstate.hashSet();
- String twotrip = triphash.toString();
-
- if (!onetrip.equals(twotrip)) {
- System.out.printf("%s\n%s\n", onetrip, twotrip);
- System.exit(1);
- }
- }
return s;
}
init();
}
- public AltosHashSet hashSet() {
- AltosHashSet h = new AltosHashSet();
-
- h.putBoolean("valid", true);
- h.putInt("set", set);
- h.putLong("received_time", received_time);
- h.putDouble("time", time);
- h.putDouble("prev_time", prev_time);
- h.putDouble("time_change", time_change);
- h.putInt("tick", tick);
- h.putInt("prev_tick", prev_tick);
- h.putInt("boost_tick", boost_tick);
- h.putInt("state", state);
- h.putInt("flight", flight);
- h.putInt("serial", serial);
- h.putInt("altitude_32", altitude_32);
- h.putInt("receiver_serial", receiver_serial);
- h.putBoolean("landed", landed);
- h.putBoolean("ascent", ascent);
- h.putBoolean("boost", boost);
- h.putInt("rssi", rssi);
- h.putInt("status", status);
- h.putInt("device_type", device_type);
- h.putInt("config_major", config_major);
- h.putInt("config_minor", config_minor);
- h.putInt("apogee_delay", apogee_delay);
- h.putInt("main_deploy", main_deploy);
- h.putInt("flight_log_max", flight_log_max);
- h.putHashable("ground_altitude", ground_altitude);
- h.putHashable("gps_ground_altitude", gps_ground_altitude);
- h.putHashable("ground_pressure", ground_pressure);
- h.putHashable("altitude", altitude);
- h.putHashable("gps_altitude", gps_altitude);
- h.putHashable("gps_ground_speed", gps_ground_speed);
- h.putHashable("gps_ascent_rate", gps_ascent_rate);
- h.putHashable("gps_course", gps_course);
- h.putHashable("gps_speed", gps_speed);
- h.putHashable("pressure", pressure);
- h.putHashable("speed", speed);
- h.putHashable("acceleration", acceleration);
- h.putHashable("orient", orient);
- h.putHashable("kalman_height", kalman_height);
- h.putHashable("kalman_speed", kalman_speed);
- h.putHashable("kalman_acceleration", kalman_acceleration);
-
- h.putDouble("battery_voltage",battery_voltage);
- h.putDouble("pyro_voltage",pyro_voltage);
- h.putDouble("temperature",temperature);
- h.putDouble("apogee_voltage",apogee_voltage);
- h.putDouble("main_voltage",main_voltage);
- h.putDoubleArray("ignitor_voltage",ignitor_voltage);
- h.putHashable("gps", gps);
- h.putHashable("temp_gps", temp_gps);
- h.putInt("temp_gps_sat_tick", temp_gps_sat_tick);
- h.putBoolean("gps_pending", gps_pending);
- h.putInt("gps_sequence", gps_sequence);
- h.putHashable("imu", imu);
- h.putHashable("mag", mag);
-
- h.putInt("npad", npad);
- h.putInt("gps_waiting", gps_waiting);
- h.putBoolean("gps_ready", gps_ready);
- h.putInt("ngps", ngps);
- h.putHashable("from_pad", from_pad);
- h.putDouble("elevation", elevation);
- h.putDouble("range", range);
- h.putDouble("gps_height", gps_height);
- h.putDouble("pad_lat", pad_lat);
- h.putDouble("pad_lon", pad_lon);
- h.putDouble("pad_alt", pad_alt);
- h.putInt("speak_tick", speak_tick);
- h.putDouble("speak_altitude", speak_altitude);
- h.putString("callsign", callsign);
- h.putString("firmware_version", firmware_version);
- h.putDouble("accel_plus_g", accel_plus_g);
- h.putDouble("accel_minus_g", accel_minus_g);
- h.putDouble("accel", accel);
- h.putDouble("ground_accel", ground_accel);
- h.putDouble("ground_accel_avg", ground_accel_avg);
- h.putInt("log_format", log_format);
- h.putInt("log_space", log_space);
- h.putString("product", product);
- h.putHashable("baro", baro);
- h.putHashable("companion", companion);
- h.putInt("pyro_fired", pyro_fired);
- h.putDouble("accel_zero_along", accel_zero_along);
- h.putDouble("accel_zero_across", accel_zero_across);
- h.putDouble("accel_zero_through", accel_zero_through);
-
- h.putHashable("rotation", rotation);
- h.putHashable("ground_rotation", ground_rotation);
-
- h.putInt("pad_orientation", pad_orientation);
-
- h.putDouble("accel_ground_along", accel_ground_along);
- h.putDouble("accel_ground_across", accel_ground_across);
- h.putDouble("accel_ground_through", accel_ground_through);
-
- h.putDouble("gyro_zero_roll", gyro_zero_roll);
- h.putDouble("gyro_zero_pitch", gyro_zero_pitch);
- h.putDouble("gyro_zero_yaw", gyro_zero_yaw);
-
- h.putDouble("last_imu_time", last_imu_time);
- return h;
- }
-
public AltosJson json() {
AltosJson j = new AltosJson();
return j;
}
- public AltosState(AltosHashSet h) {
- this();
-
- set = h.getInt("set", set);
- received_time = h.getLong("received_time", received_time);
- time = h.getDouble("time", time);
- prev_time = h.getDouble("prev_time", prev_time);
- time_change = h.getDouble("time_change", time_change);
- tick = h.getInt("tick", tick);
- prev_tick = h.getInt("prev_tick", prev_tick);
- boost_tick = h.getInt("boost_tick", boost_tick);
- state = h.getInt("state", state);
- flight = h.getInt("flight", flight);
- serial = h.getInt("serial", serial);
- altitude_32 = h.getInt("altitude_32", altitude_32);
- receiver_serial = h.getInt("receiver_serial", receiver_serial);
- landed = h.getBoolean("landed", landed);
- ascent = h.getBoolean("ascent", ascent);
- boost = h.getBoolean("boost", boost);
- rssi = h.getInt("rssi", rssi);
- status = h.getInt("status", status);
- device_type = h.getInt("device_type", device_type);
- config_major = h.getInt("config_major", config_major);
- config_minor = h.getInt("config_minor", config_minor);
- apogee_delay = h.getInt("apogee_delay", apogee_delay);
- main_deploy = h.getInt("main_deploy", main_deploy);
- flight_log_max = h.getInt("flight_log_max", flight_log_max);
- ground_altitude = AltosCValue_fromHashSet(h.getHash("ground_altitude"), ground_altitude);
- gps_ground_altitude = AltosGpsGroundAltitude_fromHashSet(h.getHash("gps_ground_altitude"), gps_ground_altitude);
- ground_pressure = AltosGroundPressure_fromHashSet(h.getHash("ground_pressure"), ground_pressure);
- altitude = AltosAltitude_fromHashSet(h.getHash("altitude"), altitude);
- gps_altitude = AltosGpsAltitude_fromHashSet(h.getHash("gps_altitude"), gps_altitude);
- gps_ground_speed = AltosValue_fromHashSet(h.getHash("gps_ground_speed"), gps_ground_speed);
- gps_ascent_rate = AltosValue_fromHashSet(h.getHash("gps_ascent_rate"), gps_ascent_rate);
- gps_course = AltosValue_fromHashSet(h.getHash("gps_course"), gps_course);
- gps_speed = AltosValue_fromHashSet(h.getHash("gps_speed"), gps_speed);
- pressure = AltosPressure_fromHashSet(h.getHash("pressure"), pressure);
- speed = AltosSpeed_fromHashSet(h.getHash("speed"), speed);
- acceleration = AltosAccel_fromHashSet(h.getHash("acceleration"), acceleration);
- orient = AltosCValue_fromHashSet(h.getHash("orient"), orient);
- kalman_height = AltosValue_fromHashSet(h.getHash("kalman_height"), kalman_height);
- kalman_speed = AltosValue_fromHashSet(h.getHash("kalman_speed"), kalman_speed);
- kalman_acceleration = AltosValue_fromHashSet(h.getHash("kalman_acceleration"), kalman_acceleration);
-
- battery_voltage = h.getDouble("battery_voltage", battery_voltage);
- pyro_voltage = h.getDouble("pyro_voltage", pyro_voltage);
- temperature = h.getDouble("temperature", temperature);
- apogee_voltage = h.getDouble("apogee_voltage", apogee_voltage);
- main_voltage= h.getDouble("main_voltage", main_voltage);
- ignitor_voltage = h.getDoubleArray("ignitor_voltage", ignitor_voltage);
- gps = AltosGPS.fromHashSet(h.getHash("gps"), gps);
- temp_gps = AltosGPS.fromHashSet(h.getHash("temp_gps"), temp_gps);
- temp_gps_sat_tick = h.getInt("temp_gps_sat_tick", temp_gps_sat_tick);
- gps_pending = h.getBoolean("gps_pending", gps_pending);
- gps_sequence = h.getInt("gps_sequence", gps_sequence);
- imu = AltosIMU.fromHashSet(h.getHash("imu"), imu);
- mag = AltosMag.fromHashSet(h.getHash("mag"), mag);
-
- npad = h.getInt("npad", npad);
- gps_waiting = h.getInt("gps_waiting", gps_waiting);
- gps_ready = h.getBoolean("gps_ready", gps_ready);
- ngps = h.getInt("ngps", ngps);
- from_pad = AltosGreatCircle.fromHashSet(h.getHash("from_pad"), from_pad);
- elevation = h.getDouble("elevation", elevation);
- range = h.getDouble("range", range);
- gps_height = h.getDouble("gps_height", gps_height);
- pad_lat = h.getDouble("pad_lat", pad_lat);
- pad_lon = h.getDouble("pad_lon", pad_lon);
- pad_alt = h.getDouble("pad_alt", pad_alt);
- speak_tick = h.getInt("speak_tick", speak_tick);
- speak_altitude = h.getDouble("speak_altitude", speak_altitude);
- callsign = h.getString("callsign", callsign);
- firmware_version = h.getString("firmware_version", firmware_version);
- accel_plus_g = h.getDouble("accel_plus_g", accel_plus_g);
- accel_minus_g = h.getDouble("accel_minus_g", accel_minus_g);
- accel = h.getDouble("accel", accel);
- ground_accel = h.getDouble("ground_accel", ground_accel);
- ground_accel_avg = h.getDouble("ground_accel_avg", ground_accel_avg);
- log_format = h.getInt("log_format", log_format);
- log_space = h.getInt("log_space", log_space);
- product = h.getString("product", product);
- baro = AltosMs5607.fromHashSet(h.getHash("baro"), baro);
- companion = AltosCompanion.fromHashSet(h.getHash("companion"), companion);
- pyro_fired = h.getInt("pyro_fired", pyro_fired);
- accel_zero_along = h.getDouble("accel_zero_along", accel_zero_along);
- accel_zero_across = h.getDouble("accel_zero_across", accel_zero_across);
- accel_zero_through = h.getDouble("accel_zero_through", accel_zero_through);
-
- rotation = AltosRotation.fromHashSet(h.getHash("rotation"), rotation);
- ground_rotation = AltosRotation.fromHashSet(h.getHash("ground_rotation"), ground_rotation);
-
- pad_orientation = h.getInt("pad_orientation", pad_orientation);
-
- accel_ground_along = h.getDouble("accel_ground_along", accel_ground_along);
- accel_ground_across = h.getDouble("accel_ground_across", accel_ground_across);
- accel_ground_through = h.getDouble("accel_ground_through", accel_ground_through);
-
- gyro_zero_roll = h.getDouble("gyro_zero_roll", gyro_zero_roll);
- gyro_zero_pitch = h.getDouble("gyro_zero_pitch", gyro_zero_pitch);
- gyro_zero_yaw = h.getDouble("gyro_zero_yaw", gyro_zero_yaw);
-
- last_imu_time = h.getDouble("last_imu_time", last_imu_time);
- }
-
public AltosState(AltosJson j) {
this();
last_imu_time = j.get_double("last_imu_time", last_imu_time);
}
- public static AltosState fromHashSet(AltosHashSet h) {
- if (h == null)
- return null;
- if (!h.getBoolean("valid", false))
- return null;
- return new AltosState(h);
- }
public static AltosState fromJson(AltosJson j) {
if (j == null)
AltosMapLoaderListener.java \
AltosMapLoader.java \
AltosMapTypeListener.java \
- AltosHashSet.java \
- AltosHashable.java \
AltosJson.java \
AltosJsonable.java \
AltosVersion.java