From adddad0dd45f67d01487c8dd75b040ca3ab50fe2 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 2 Apr 2014 20:36:26 -0700 Subject: altoslib: Ignore speed/accel after boost when finding maxima Large spikes in acceleration often occur with ejection charges, which can cause bogus acceleration and speed data to be seen. Ignore those for the purpose of computing the maximum values of each. Signed-off-by: Keith Packard --- altoslib/AltosState.java | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index 758fd636..d65e3bd8 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -50,12 +50,13 @@ public class AltosState implements Cloneable { private double set_time; private double prev_set_time; + boolean can_max() { return true; } + void set(double new_value, double time) { if (new_value != AltosLib.MISSING) { value = new_value; - if (max_value == AltosLib.MISSING || value > max_value) { + if (can_max() && (max_value == AltosLib.MISSING || value > max_value)) max_value = value; - } set_time = time; } } @@ -108,7 +109,7 @@ public class AltosState implements Cloneable { void set_derivative(AltosValue in) { double n = in.rate(); - + if (n == AltosLib.MISSING) return; @@ -123,7 +124,7 @@ public class AltosState implements Cloneable { /* Clip changes to reduce noise */ double ddt = in.time() - pt; double ddv = (n - p) / ddt; - + final double max = 100000; /* 100gs */ @@ -246,11 +247,11 @@ public class AltosState implements Cloneable { void set_integral(AltosValue in) { computed.set_integral(in); } - + void set_integral(AltosCValue in) { set_integral(in.altos_value()); } - + void copy(AltosCValue old) { measured.copy(old.measured); computed.copy(old.computed); @@ -337,7 +338,7 @@ public class AltosState implements Cloneable { } private AltosGroundPressure ground_pressure; - + public double ground_pressure() { return ground_pressure.value(); } @@ -481,7 +482,11 @@ public class AltosState implements Cloneable { } class AltosSpeed extends AltosCValue { - + + boolean can_max() { + return state < AltosLib.ao_flight_fast; + } + void set_accel() { acceleration.set_derivative(this); } @@ -519,6 +524,11 @@ public class AltosState implements Cloneable { } class AltosAccel extends AltosCValue { + + boolean can_max() { + return state < AltosLib.ao_flight_fast; + } + void set_measured(double a, double time) { super.set_measured(a, time); if (ascent) @@ -729,7 +739,7 @@ public class AltosState implements Cloneable { time = old.time; time_change = old.time_change; prev_time = old.time; - + tick = old.tick; prev_tick = old.tick; boost_tick = old.boost_tick; @@ -747,7 +757,7 @@ public class AltosState implements Cloneable { apogee_delay = old.apogee_delay; main_deploy = old.main_deploy; flight_log_max = old.flight_log_max; - + set = 0; ground_pressure.copy(old.ground_pressure); @@ -831,7 +841,7 @@ public class AltosState implements Cloneable { baro = old.baro; companion = old.companion; } - + void update_time() { } -- cgit v1.2.3 From 21d584b9bf93b96a05ab374105493c0e17df320f Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 2 Apr 2014 22:04:18 -0700 Subject: altoslib: Fix EasyMini voltage computations Early Em prototypes had a 3.0V regulator. Early v1.0 boards measured power past the blocking diode. Deal with both conditions to try and report more accurate voltages for EasyMini data. Signed-off-by: Keith Packard --- altoslib/AltosConvert.java | 17 ++++++++++++++--- altoslib/AltosSensorEMini.java | 8 ++++---- 2 files changed, 18 insertions(+), 7 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosConvert.java b/altoslib/AltosConvert.java index 8f214c8b..35923ec3 100644 --- a/altoslib/AltosConvert.java +++ b/altoslib/AltosConvert.java @@ -224,10 +224,21 @@ public class AltosConvert { return sensor / 32767.0 * supply * 127/27; } - static double easy_mini_voltage(int sensor) { - double supply = 3.0; + static double easy_mini_voltage(int sensor, int serial) { + double supply = 3.3; + double diode_offset = 0.0; - return sensor / 32767.0 * supply * 127/27; + /* early prototypes had a 3.0V regulator */ + if (serial < 1000) + supply = 3.0; + + /* Purple v1.0 boards had the sensor after the + * blocking diode, which drops about 150mV + */ + if (serial < 1665) + diode_offset = 0.150; + + return sensor / 32767.0 * supply * 127/27 + diode_offset; } public static double radio_to_frequency(int freq, int setting, int cal, int channel) { diff --git a/altoslib/AltosSensorEMini.java b/altoslib/AltosSensorEMini.java index f888754c..5f43b3a9 100644 --- a/altoslib/AltosSensorEMini.java +++ b/altoslib/AltosSensorEMini.java @@ -31,10 +31,10 @@ public class AltosSensorEMini { if (sensor_emini == null) return; - state.set_battery_voltage(AltosConvert.easy_mini_voltage(sensor_emini.batt)); - state.set_apogee_voltage(AltosConvert.easy_mini_voltage(sensor_emini.apogee)); - state.set_main_voltage(AltosConvert.easy_mini_voltage(sensor_emini.main)); - + state.set_battery_voltage(AltosConvert.easy_mini_voltage(sensor_emini.batt, config_data.serial)); + state.set_apogee_voltage(AltosConvert.easy_mini_voltage(sensor_emini.apogee, config_data.serial)); + state.set_main_voltage(AltosConvert.easy_mini_voltage(sensor_emini.main, config_data.serial)); + } catch (TimeoutException te) { } } -- cgit v1.2.3 From bb9fdef607728cc326a82aa632e59724f272e53b Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 3 Apr 2014 00:10:19 -0700 Subject: altoslib: Missed a couple of easy mini voltage API changes Oh, and Tm was using Em conversions (which is almost right, except Tm doesn't have the history) Signed-off-by: Keith Packard --- altoslib/AltosEepromMini.java | 2 +- altoslib/AltosSensorTMini.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosEepromMini.java b/altoslib/AltosEepromMini.java index fb3b4d23..b308fbf4 100644 --- a/altoslib/AltosEepromMini.java +++ b/altoslib/AltosEepromMini.java @@ -43,7 +43,7 @@ public class AltosEepromMini extends AltosEeprom { double voltage(AltosState state, int sensor) { if (state.log_format == AltosLib.AO_LOG_FORMAT_EASYMINI) - return AltosConvert.easy_mini_voltage(sensor); + return AltosConvert.easy_mini_voltage(sensor, state.serial); else return AltosConvert.tele_mini_voltage(sensor); } diff --git a/altoslib/AltosSensorTMini.java b/altoslib/AltosSensorTMini.java index 35857e35..cc5718a0 100644 --- a/altoslib/AltosSensorTMini.java +++ b/altoslib/AltosSensorTMini.java @@ -31,9 +31,9 @@ public class AltosSensorTMini { if (sensor_tmini == null) return; - state.set_battery_voltage(AltosConvert.easy_mini_voltage(sensor_tmini.batt)); - state.set_apogee_voltage(AltosConvert.easy_mini_voltage(sensor_tmini.apogee)); - state.set_main_voltage(AltosConvert.easy_mini_voltage(sensor_tmini.main)); + state.set_battery_voltage(AltosConvert.tele_mini_voltage(sensor_tmini.batt)); + state.set_apogee_voltage(AltosConvert.tele_mini_voltage(sensor_tmini.apogee)); + state.set_main_voltage(AltosConvert.tele_mini_voltage(sensor_tmini.main)); } catch (TimeoutException te) { } -- cgit v1.2.3 From 99c729495a8cc589718607ee35d22454c6af2994 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 6 Apr 2014 23:46:48 -0700 Subject: altosui: Disable flight log configuration while flights are stored The log code won't let you resize the maximum flight log while there is still data on the flight computer; the code to figure that out in the UI was busted, leaving users confused about why it wasn't working. Signed-off-by: Keith Packard --- altoslib/AltosConfigData.java | 24 +++++++++++++++++++++--- altosui/AltosConfigUI.java | 29 ++++++++++++++++++----------- 2 files changed, 39 insertions(+), 14 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index c4e108f8..edaf4601 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -351,9 +351,22 @@ public class AltosConfigData implements Iterable { channel); } + boolean use_flash_for_config() { + if (product.startsWith("TeleMega")) + return false; + if (product.startsWith("TeleMetrum-v2")) + return false; + return true; + } + + public int log_limit() { - if (storage_size > 0 && storage_erase_unit > 0) { - int log_limit = storage_size - storage_erase_unit; + if (storage_size > 0) { + int log_limit = storage_size; + + if (storage_erase_unit > 0 && use_flash_for_config()) + log_limit -= storage_erase_unit; + if (log_limit > 0) return log_limit / 1024; } @@ -410,15 +423,20 @@ public class AltosConfigData implements Iterable { dest.set_radio_calibration(radio_calibration); dest.set_radio_frequency(frequency()); boolean max_enabled = true; + + if (log_limit() == 0) + max_enabled = false; + switch (log_format) { case AltosLib.AO_LOG_FORMAT_TINY: max_enabled = false; break; default: - if (stored_flight >= 0) + if (stored_flight > 0) max_enabled = false; break; } + dest.set_flight_log_max_enabled(max_enabled); dest.set_radio_enable(radio_enable); dest.set_flight_log_max_limit(log_limit()); diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java index 21ea50e6..656b0b6f 100644 --- a/altosui/AltosConfigUI.java +++ b/altosui/AltosConfigUI.java @@ -132,11 +132,21 @@ public class AltosConfigUI } } + boolean is_telemini_v1() { + String product = product_value.getText(); + return product != null && product.startsWith("TeleMini-v1"); + } + boolean is_telemini() { String product = product_value.getText(); return product != null && product.startsWith("TeleMini"); } + boolean is_easymini() { + String product = product_value.getText(); + return product != null && product.startsWith("EasyMini"); + } + boolean is_telemetrum() { String product = product_value.getText(); return product != null && product.startsWith("TeleMetrum"); @@ -167,12 +177,10 @@ public class AltosConfigUI if (flight_log_max_value.isEnabled()) flight_log_max_value.setToolTipText("Size reserved for each flight log (in kB)"); else { - if (is_telemetrum()) - flight_log_max_value.setToolTipText("Cannot set max value with flight logs in memory"); - else if (is_telemini()) - flight_log_max_value.setToolTipText("TeleMini stores only one flight"); + if (is_telemini_v1()) + flight_log_max_value.setToolTipText("TeleMini-v1 stores only one flight"); else - flight_log_max_value.setToolTipText("Cannot set max flight log value"); + flight_log_max_value.setToolTipText("Cannot set max value with flight logs in memory"); } } @@ -189,8 +197,8 @@ public class AltosConfigUI else { if (is_telemetrum()) pad_orientation_value.setToolTipText("Older TeleMetrum firmware must fly antenna forward"); - else if (is_telemini()) - pad_orientation_value.setToolTipText("TeleMini doesn't care how it is mounted"); + else if (is_telemini() || is_easymini()) + pad_orientation_value.setToolTipText("TeleMini and EasyMini don't care how they are mounted"); else pad_orientation_value.setToolTipText("Can't select orientation"); } @@ -742,14 +750,14 @@ public class AltosConfigUI String get_main_deploy_label() { return String.format("Main Deploy Altitude(%s):", AltosConvert.height.show_units()); } - + String[] main_deploy_values() { if (AltosConvert.imperial_units) return main_deploy_values_ft; else return main_deploy_values_m; } - + void set_main_deploy_values() { String[] v = main_deploy_values(); while (main_deploy_value.getItemCount() > 0) @@ -758,7 +766,7 @@ public class AltosConfigUI main_deploy_value.addItem(v[i]); main_deploy_value.setMaximumRowCount(v.length); } - + public void units_changed(boolean imperial_units) { String v = main_deploy_value.getSelectedItem().toString(); main_deploy_label.setText(get_main_deploy_label()); @@ -834,7 +842,6 @@ public class AltosConfigUI } public void set_flight_log_max(int new_flight_log_max) { - flight_log_max_value.setEnabled(new_flight_log_max > 0); flight_log_max_value.setSelectedItem(Integer.toString(new_flight_log_max)); set_flight_log_max_tool_tip(); } -- cgit v1.2.3 From 9e18c524fa2d1f648f265b3c3105f5ceacf06c10 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 11 Apr 2014 16:40:06 -0700 Subject: altoslib/altosui/altosuilib/libaltos: Remove trailing whitespace Just cleaning up the source code. Signed-off-by: Keith Packard --- altoslib/AltosEepromDownload.java | 2 +- altoslib/AltosEepromHeader.java | 4 ++-- altoslib/AltosEepromMega.java | 2 +- altoslib/AltosEepromMetrum2.java | 4 ++-- altoslib/AltosFile.java | 2 +- altoslib/AltosIdleFetch.java | 2 +- altoslib/AltosLib.java | 2 +- altoslib/AltosLink.java | 4 ++-- altoslib/AltosMag.java | 1 - altoslib/AltosMs5607.java | 4 ++-- altoslib/AltosPreferences.java | 4 ++-- altoslib/AltosPyro.java | 6 +++--- altoslib/AltosRomconfig.java | 2 +- altoslib/AltosSelfFlash.java | 4 ++-- altoslib/AltosSensorTM.java | 2 +- altoslib/AltosSensorTMini.java | 2 +- altoslib/AltosStateIterable.java | 2 +- altoslib/AltosTelemetry.java | 2 +- altoslib/AltosTelemetryFile.java | 2 +- altoslib/AltosTelemetryLegacy.java | 2 +- altoslib/AltosTelemetryMegaData.java | 6 +++--- altoslib/AltosTelemetryMegaSensor.java | 2 +- altoslib/AltosTelemetrySatellite.java | 2 +- altoslib/AltosUnits.java | 8 ++++---- altosui/AltosAscent.java | 4 ++-- altosui/AltosCompanionInfo.java | 2 +- altosui/AltosConfigFreqUI.java | 10 +++++----- altosui/AltosConfigPyroUI.java | 14 +++++++------- altosui/AltosConfigTDUI.java | 4 ++-- altosui/AltosConfigureUI.java | 4 ++-- altosui/AltosDescent.java | 2 +- altosui/AltosDeviceUIDialog.java | 2 +- altosui/AltosDisplayThread.java | 2 +- altosui/AltosFlashUI.java | 4 ++-- altosui/AltosFlightStatsTable.java | 2 +- altosui/AltosFlightUI.java | 2 +- altosui/AltosFreqList.java | 6 +++--- altosui/AltosGraphDataPoint.java | 4 ++-- altosui/AltosGraphUI.java | 2 +- altosui/AltosIgniteUI.java | 2 +- altosui/AltosInfoTable.java | 2 +- altosui/AltosLanded.java | 2 +- altosui/AltosPad.java | 6 +++--- altosui/AltosScanUI.java | 16 ++++++++-------- altosui/AltosSiteMap.java | 2 +- altosui/AltosSiteMapPreload.java | 16 ++++++++-------- altosui/AltosUI.java | 6 +++--- altosui/AltosUIPreferencesBackend.java | 2 +- altosuilib/AltosDeviceDialog.java | 2 +- altosuilib/AltosUIAxis.java | 2 +- altosuilib/AltosUIEnable.java | 2 +- altosuilib/AltosUIFrame.java | 10 +++++----- altosuilib/AltosUIGraph.java | 4 ++-- altosuilib/AltosUIGrapher.java | 2 +- altosuilib/AltosUIMarker.java | 2 +- altosuilib/AltosUIPreferencesBackend.java | 2 +- altosuilib/AltosUISeries.java | 4 ++-- libaltos/libaltos.c | 10 +++++----- 58 files changed, 115 insertions(+), 116 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosEepromDownload.java b/altoslib/AltosEepromDownload.java index 04101079..163ffad9 100644 --- a/altoslib/AltosEepromDownload.java +++ b/altoslib/AltosEepromDownload.java @@ -132,7 +132,7 @@ public class AltosEepromDownload implements Runnable { CheckFile(false); } - + void CaptureLog(AltosEepromLog log) throws IOException, InterruptedException, TimeoutException, ParseException { int block, state_block = 0; int log_format = flights.config_data.log_format; diff --git a/altoslib/AltosEepromHeader.java b/altoslib/AltosEepromHeader.java index 6ce7ddd3..fe5bf6c3 100644 --- a/altoslib/AltosEepromHeader.java +++ b/altoslib/AltosEepromHeader.java @@ -162,7 +162,7 @@ public class AltosEepromHeader extends AltosEeprom { break; } } - + public AltosEepromHeader (String[] tokens) { last = false; valid = true; @@ -269,7 +269,7 @@ public class AltosEepromHeader extends AltosEeprom { for (AltosEepromHeader header : headers) { header.write(out); } - + } public AltosEepromHeader (String line) { diff --git a/altoslib/AltosEepromMega.java b/altoslib/AltosEepromMega.java index b8a1b9e8..35e87885 100644 --- a/altoslib/AltosEepromMega.java +++ b/altoslib/AltosEepromMega.java @@ -70,7 +70,7 @@ public class AltosEepromMega extends AltosEeprom { public int year() { return data8(14); } public int month() { return data8(15); } public int day() { return data8(16); } - + /* AO_LOG_GPS_SAT elements */ public int nsat() { return data16(0); } public int svid(int n) { return data8(2 + n * 2); } diff --git a/altoslib/AltosEepromMetrum2.java b/altoslib/AltosEepromMetrum2.java index f1bca6dc..d13aac42 100644 --- a/altoslib/AltosEepromMetrum2.java +++ b/altoslib/AltosEepromMetrum2.java @@ -59,7 +59,7 @@ public class AltosEepromMetrum2 extends AltosEeprom { public int year() { return data8(4); } public int month() { return data8(5); } public int day() { return data8(6); } - + /* AO_LOG_GPS_SAT elements */ public int nsat() { return data8(0); } public int more() { return data8(1); } @@ -161,7 +161,7 @@ public class AltosEepromMetrum2 extends AltosEeprom { break; try { AltosEepromMetrum2 metrum = new AltosEepromMetrum2(line); - + if (metrum.cmd != AltosLib.AO_LOG_INVALID) metrums.add(metrum); } catch (Exception e) { diff --git a/altoslib/AltosFile.java b/altoslib/AltosFile.java index 37bf7075..79f6f1c6 100644 --- a/altoslib/AltosFile.java +++ b/altoslib/AltosFile.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_3; import java.io.File; import java.util.*; diff --git a/altoslib/AltosIdleFetch.java b/altoslib/AltosIdleFetch.java index 02cb7a94..b0e45797 100644 --- a/altoslib/AltosIdleFetch.java +++ b/altoslib/AltosIdleFetch.java @@ -142,7 +142,7 @@ public class AltosIdleFetch implements AltosStateUpdate { state.set_received_time(System.currentTimeMillis()); } catch (TimeoutException te) { } - + } public AltosIdleFetch(AltosLink link) { diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java index 05f0af8d..3f25bc31 100644 --- a/altoslib/AltosLib.java +++ b/altoslib/AltosLib.java @@ -203,7 +203,7 @@ public class AltosLib { throw new IllegalArgumentException(String.format("Invalid telemetry %d", telemetry)); } - + private static String[] state_to_string = { "startup", "idle", diff --git a/altoslib/AltosLink.java b/altoslib/AltosLink.java index 97fa7062..469b03c0 100644 --- a/altoslib/AltosLink.java +++ b/altoslib/AltosLink.java @@ -76,7 +76,7 @@ public abstract class AltosLink implements Runnable { return get_reply(5000); } - + public abstract boolean can_cancel_reply(); public abstract boolean show_reply_timeout(); public abstract void hide_reply_timeout(); @@ -215,7 +215,7 @@ public abstract class AltosLink implements Runnable { break; } } - + } finally { --in_reply; } diff --git a/altoslib/AltosMag.java b/altoslib/AltosMag.java index d2bb9da6..a3a0a74b 100644 --- a/altoslib/AltosMag.java +++ b/altoslib/AltosMag.java @@ -87,4 +87,3 @@ public class AltosMag implements Cloneable { } } } - \ No newline at end of file diff --git a/altoslib/AltosMs5607.java b/altoslib/AltosMs5607.java index 97d08c3e..4a851524 100644 --- a/altoslib/AltosMs5607.java +++ b/altoslib/AltosMs5607.java @@ -44,7 +44,7 @@ public class AltosMs5607 { //int P; dT = raw_temp - ((int) tref << 8); - + TEMP = (int) (2000 + (((long) dT * (long) tempsens) >> 23)); if (ms5611) { @@ -55,7 +55,7 @@ public class AltosMs5607 { OFF = ((long) off << 17) + (((long) tco * (long) dT) >> 6); SENS = ((long) sens << 16) + (((long) tcs * (long) dT) >> 7); - } + } if (TEMP < 2000) { int T2 = (int) (((long) dT * (long) dT) >> 31); diff --git a/altoslib/AltosPreferences.java b/altoslib/AltosPreferences.java index b8920d26..484cb644 100644 --- a/altoslib/AltosPreferences.java +++ b/altoslib/AltosPreferences.java @@ -55,7 +55,7 @@ public class AltosPreferences { /* Launcher channel preference name */ public final static String launcherChannelPreference = "LAUNCHER-CHANNEL"; - + /* Default logdir is ~/TeleMetrum */ public final static String logdirName = "TeleMetrum"; @@ -349,7 +349,7 @@ public class AltosPreferences { return launcher_channel; } } - + public static AltosPreferencesBackend bt_devices() { synchronized (backend) { return backend.node("bt_devices"); diff --git a/altoslib/AltosPyro.java b/altoslib/AltosPyro.java index aefc6fbd..a1414123 100644 --- a/altoslib/AltosPyro.java +++ b/altoslib/AltosPyro.java @@ -105,7 +105,7 @@ public class AltosPyro { private static HashMap pyro_to_units = new HashMap(); private static HashMap pyro_to_scale = new HashMap(); - + private static void insert_map(int flag, String string, String name, AltosUnits units, double scale) { string_to_pyro.put(string, flag); pyro_to_string.put(flag, string); @@ -114,7 +114,7 @@ public class AltosPyro { pyro_to_units.put(flag, units); pyro_to_scale.put(flag, scale); } - + public static int string_to_pyro(String name) { if (string_to_pyro.containsKey(name)) return string_to_pyro.get(name); @@ -174,7 +174,7 @@ public class AltosPyro { insert_map(pyro_after_motor, pyro_after_motor_string, pyro_after_motor_name, null, 1.0); insert_map(pyro_delay, pyro_delay_string, pyro_delay_name, null, pyro_delay_scale); - + insert_map(pyro_state_less, pyro_state_less_string, pyro_state_less_name, null, 1.0); insert_map(pyro_state_greater_or_equal, pyro_state_greater_or_equal_string, pyro_state_greater_or_equal_name, null, 1.0); } diff --git a/altoslib/AltosRomconfig.java b/altoslib/AltosRomconfig.java index 1273fbc6..506c3961 100644 --- a/altoslib/AltosRomconfig.java +++ b/altoslib/AltosRomconfig.java @@ -144,7 +144,7 @@ public class AltosRomconfig { ao_romconfig_check, ao_serial_number }; - + private static boolean name_required(String name) { for (String required : required_names) if (name.equals(required)) diff --git a/altoslib/AltosSelfFlash.java b/altoslib/AltosSelfFlash.java index aae993eb..051aa766 100644 --- a/altoslib/AltosSelfFlash.java +++ b/altoslib/AltosSelfFlash.java @@ -47,7 +47,7 @@ public class AltosSelfFlash extends AltosProgrammer { for (int offset = 0; offset < len; offset += 0x100) { link.printf("R %x\n", addr + offset); byte[] reply = link.get_binary_reply(5000, 0x100); - + if (reply == null) throw new IOException("Read device memory timeout"); for (b = 0; b < len; b++) @@ -55,7 +55,7 @@ public class AltosSelfFlash extends AltosProgrammer { } return data; } - + void write_memory(long addr, byte[] data, int start, int len) { int b; link.printf("W %x\n", addr); diff --git a/altoslib/AltosSensorTM.java b/altoslib/AltosSensorTM.java index b8f54bcb..a5129783 100644 --- a/altoslib/AltosSensorTM.java +++ b/altoslib/AltosSensorTM.java @@ -40,7 +40,7 @@ public class AltosSensorTM { state.set_battery_voltage(AltosConvert.cc_battery_to_voltage(sensor_tm.batt)); state.set_apogee_voltage(AltosConvert.cc_ignitor_to_voltage(sensor_tm.drogue)); state.set_main_voltage(AltosConvert.cc_ignitor_to_voltage(sensor_tm.main)); - + } catch (TimeoutException te) { } } diff --git a/altoslib/AltosSensorTMini.java b/altoslib/AltosSensorTMini.java index cc5718a0..bb60a794 100644 --- a/altoslib/AltosSensorTMini.java +++ b/altoslib/AltosSensorTMini.java @@ -34,7 +34,7 @@ public class AltosSensorTMini { state.set_battery_voltage(AltosConvert.tele_mini_voltage(sensor_tmini.batt)); state.set_apogee_voltage(AltosConvert.tele_mini_voltage(sensor_tmini.apogee)); state.set_main_voltage(AltosConvert.tele_mini_voltage(sensor_tmini.main)); - + } catch (TimeoutException te) { } } diff --git a/altoslib/AltosStateIterable.java b/altoslib/AltosStateIterable.java index 5a919b66..7ea3041b 100644 --- a/altoslib/AltosStateIterable.java +++ b/altoslib/AltosStateIterable.java @@ -24,6 +24,6 @@ public abstract class AltosStateIterable implements Iterable { public void write_comments (PrintStream out) { } - + public abstract void write(PrintStream out); } diff --git a/altoslib/AltosTelemetry.java b/altoslib/AltosTelemetry.java index 01bedd5e..1c4ce7bc 100644 --- a/altoslib/AltosTelemetry.java +++ b/altoslib/AltosTelemetry.java @@ -67,7 +67,7 @@ public abstract class AltosTelemetry implements AltosStateUpdate { final static int packet_type_metrum_sensor = 0x0a; final static int packet_type_metrum_data = 0x0b; final static int packet_type_mini = 0x10; - + static AltosTelemetry parse_hex(String hex) throws ParseException, AltosCRCException { AltosTelemetry telem = null; diff --git a/altoslib/AltosTelemetryFile.java b/altoslib/AltosTelemetryFile.java index 09d7d3f8..f6643134 100644 --- a/altoslib/AltosTelemetryFile.java +++ b/altoslib/AltosTelemetryFile.java @@ -62,7 +62,7 @@ public class AltosTelemetryFile extends AltosStateIterable { } public void write(PrintStream out) { - + } public AltosTelemetryFile(FileInputStream input) { diff --git a/altoslib/AltosTelemetryLegacy.java b/altoslib/AltosTelemetryLegacy.java index d302addd..da9296e4 100644 --- a/altoslib/AltosTelemetryLegacy.java +++ b/altoslib/AltosTelemetryLegacy.java @@ -470,7 +470,7 @@ public class AltosTelemetryLegacy extends AltosTelemetry { batt = int16(29); apogee = int16(31); main = int16(33); - + ground_accel = int16(7); ground_pres = int16(15); accel_plus_g = int16(17); diff --git a/altoslib/AltosTelemetryMegaData.java b/altoslib/AltosTelemetryMegaData.java index a4df70be..ffd82546 100644 --- a/altoslib/AltosTelemetryMegaData.java +++ b/altoslib/AltosTelemetryMegaData.java @@ -19,7 +19,7 @@ package org.altusmetrum.altoslib_3; public class AltosTelemetryMegaData extends AltosTelemetryStandard { int state; - + int v_batt; int v_pyro; int sense[]; @@ -41,7 +41,7 @@ public class AltosTelemetryMegaData extends AltosTelemetryStandard { v_batt = int16(6); v_pyro = int16(8); - sense = new int[6]; + sense = new int[6]; for (int i = 0; i < 6; i++) { sense[i] = int8(10 + i) << 4; @@ -62,7 +62,7 @@ public class AltosTelemetryMegaData extends AltosTelemetryStandard { super.update_state(state); state.set_state(this.state); - + state.set_battery_voltage(AltosConvert.mega_battery_voltage(v_batt)); state.set_pyro_voltage(AltosConvert.mega_pyro_voltage(v_pyro)); diff --git a/altoslib/AltosTelemetryMegaSensor.java b/altoslib/AltosTelemetryMegaSensor.java index d1a463c0..d9fd7fde 100644 --- a/altoslib/AltosTelemetryMegaSensor.java +++ b/altoslib/AltosTelemetryMegaSensor.java @@ -67,7 +67,7 @@ public class AltosTelemetryMegaSensor extends AltosTelemetryStandard { state.set_orient(orient); AltosIMU imu = new AltosIMU(); - + imu.accel_x = AltosIMU.convert_accel(accel_x); imu.accel_y = AltosIMU.convert_accel(accel_y); imu.accel_z = AltosIMU.convert_accel(accel_z); diff --git a/altoslib/AltosTelemetrySatellite.java b/altoslib/AltosTelemetrySatellite.java index 01252bde..24777b28 100644 --- a/altoslib/AltosTelemetrySatellite.java +++ b/altoslib/AltosTelemetrySatellite.java @@ -43,7 +43,7 @@ public class AltosTelemetrySatellite extends AltosTelemetryStandard { super.update_state(state); AltosGPS gps = state.make_temp_gps(true); - + gps.cc_gps_sat = sats; state.set_temp_gps(); } diff --git a/altoslib/AltosUnits.java b/altoslib/AltosUnits.java index e573a43b..82f102e4 100644 --- a/altoslib/AltosUnits.java +++ b/altoslib/AltosUnits.java @@ -41,7 +41,7 @@ public abstract class AltosUnits { public double value(double v) { return value(v, AltosConvert.imperial_units); } - + public double inverse(double v) { return inverse(v, AltosConvert.imperial_units); } @@ -49,15 +49,15 @@ public abstract class AltosUnits { public String show_units() { return show_units(AltosConvert.imperial_units); } - + public String say_units() { return say_units(AltosConvert.imperial_units); } - + public int show_fraction(int width) { return show_fraction(width, AltosConvert.imperial_units); } - + int say_fraction(boolean imperial_units) { return 0; } diff --git a/altosui/AltosAscent.java b/altosui/AltosAscent.java index 36871dd6..81b08d2c 100644 --- a/altosui/AltosAscent.java +++ b/altosui/AltosAscent.java @@ -48,7 +48,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { show(); value.setText(s); } - + void show(AltosUnits units, double v) { show(units.show(8, v)); } @@ -122,7 +122,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { show(); value.setText(s); } - + void show(AltosUnits units, double v) { show(units.show(8, v)); } diff --git a/altosui/AltosCompanionInfo.java b/altosui/AltosCompanionInfo.java index 4cc6c462..b90240fb 100644 --- a/altosui/AltosCompanionInfo.java +++ b/altosui/AltosCompanionInfo.java @@ -82,7 +82,7 @@ public class AltosCompanionInfo extends JTable { return String.format("%02x\n", companion.board_id); } } - + public void show(AltosState state, AltosListenerState listener_state) { if (state == null) return; diff --git a/altosui/AltosConfigFreqUI.java b/altosui/AltosConfigFreqUI.java index e9923a32..58778057 100644 --- a/altosui/AltosConfigFreqUI.java +++ b/altosui/AltosConfigFreqUI.java @@ -71,7 +71,7 @@ class AltosEditFreqUI extends AltosUIDialog implements ActionListener { GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets (4,4,4,4); - + c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.WEST; c.gridx = 0; @@ -126,7 +126,7 @@ class AltosEditFreqUI extends AltosUIDialog implements ActionListener { c.weightx = 0; c.weighty = 0; pane.add(ok_button, c); - + cancel_button = new JButton("Cancel"); cancel_button.setActionCommand("cancel"); cancel_button.addActionListener(this); @@ -139,7 +139,7 @@ class AltosEditFreqUI extends AltosUIDialog implements ActionListener { c.weightx = 0; c.weighty = 0; pane.add(cancel_button, c); - + if (existing == null) setTitle("Add New Frequency"); else { @@ -151,7 +151,7 @@ class AltosEditFreqUI extends AltosUIDialog implements ActionListener { pack(); setLocationRelativeTo(frame); - + } public AltosEditFreqUI(Frame in_frame) { @@ -290,7 +290,7 @@ public class AltosConfigFreqUI extends AltosUIDialog implements ActionListener { public AltosFrequency[] frequencies() { return frequencies.frequencies(); } - + public AltosConfigFreqUI(Frame in_frame, AltosFrequency[] in_frequencies) { super(in_frame, "Manage Frequencies", true); diff --git a/altosui/AltosConfigPyroUI.java b/altosui/AltosConfigPyroUI.java index b14c39ab..b667b15a 100644 --- a/altosui/AltosConfigPyroUI.java +++ b/altosui/AltosConfigPyroUI.java @@ -63,22 +63,22 @@ public class AltosConfigPyroUI public void itemStateChanged(ItemEvent e) { set_enable(enable.isSelected()); - if (!setting) + if (!setting) ui.set_dirty(); } public void changedUpdate(DocumentEvent e) { - if (!setting) + if (!setting) ui.set_dirty(); } public void insertUpdate(DocumentEvent e) { - if (!setting) + if (!setting) ui.set_dirty(); } public void removeUpdate(DocumentEvent e) { - if (!setting) + if (!setting) ui.set_dirty(); } @@ -149,7 +149,7 @@ public class AltosConfigPyroUI enable = new JCheckBox(); enable.addItemListener(this); pane.add(enable, c); - + if ((flag & AltosPyro.pyro_no_value) == 0) { c = new GridBagConstraints(); c.gridx = x+1; c.gridy = y; @@ -224,7 +224,7 @@ public class AltosConfigPyroUI items = new PyroItem[nrow]; int row = 0; - + GridBagConstraints c; c = new GridBagConstraints(); c.gridx = x; c.gridy = y; @@ -371,7 +371,7 @@ public class AltosConfigPyroUI pane.add(close, c); close.addActionListener(this); close.setActionCommand("Close"); - + addWindowListener(new ConfigListener(this, owner)); AltosPreferences.register_units_listener(this); } diff --git a/altosui/AltosConfigTDUI.java b/altosui/AltosConfigTDUI.java index 3ce0d98c..55d6aed9 100644 --- a/altosui/AltosConfigTDUI.java +++ b/altosui/AltosConfigTDUI.java @@ -311,7 +311,7 @@ public class AltosConfigTDUI int i; for (i = 0; i < radio_frequency_value.getItemCount(); i++) { AltosFrequency f = (AltosFrequency) radio_frequency_value.getItemAt(i); - + if (f.close(new_radio_frequency)) { radio_frequency_value.setSelectedIndex(i); return; @@ -319,7 +319,7 @@ public class AltosConfigTDUI } for (i = 0; i < radio_frequency_value.getItemCount(); i++) { AltosFrequency f = (AltosFrequency) radio_frequency_value.getItemAt(i); - + if (new_radio_frequency < f.frequency) break; } diff --git a/altosui/AltosConfigureUI.java b/altosui/AltosConfigureUI.java index 5e42f430..631c188d 100644 --- a/altosui/AltosConfigureUI.java +++ b/altosui/AltosConfigureUI.java @@ -123,10 +123,10 @@ public class AltosConfigureUI "Bottom", "Bottom right", }; - + public void add_position() { pane.add(new JLabel ("Menu position"), constraints(0, 1)); - + position_value = new JComboBox (position_names); position_value.setMaximumRowCount(position_names.length); int position = AltosUIPreferences.position(); diff --git a/altosui/AltosDescent.java b/altosui/AltosDescent.java index d1379083..cd993a75 100644 --- a/altosui/AltosDescent.java +++ b/altosui/AltosDescent.java @@ -318,7 +318,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { } Distance distance; - + class Apogee extends DescentStatus { void show (AltosState state, AltosListenerState listener_state) { diff --git a/altosui/AltosDeviceUIDialog.java b/altosui/AltosDeviceUIDialog.java index ceabe843..ca34357e 100644 --- a/altosui/AltosDeviceUIDialog.java +++ b/altosui/AltosDeviceUIDialog.java @@ -46,7 +46,7 @@ public class AltosDeviceUIDialog extends AltosDeviceDialog { buttonPane.add(manage_bluetooth_button); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); } - + public void actionPerformed(ActionEvent e) { super.actionPerformed(e); if ("manage".equals(e.getActionCommand())) { diff --git a/altosui/AltosDisplayThread.java b/altosui/AltosDisplayThread.java index 2a33f996..ab85607d 100644 --- a/altosui/AltosDisplayThread.java +++ b/altosui/AltosDisplayThread.java @@ -155,7 +155,7 @@ public class AltosDisplayThread extends Thread { wait(sleep_time); } } - + report(false); } } catch (InterruptedException ie) { diff --git a/altosui/AltosFlashUI.java b/altosui/AltosFlashUI.java index 793a8af3..ff9cb95d 100644 --- a/altosui/AltosFlashUI.java +++ b/altosui/AltosFlashUI.java @@ -231,7 +231,7 @@ public class AltosFlashUI javax.swing.filechooser.FileFilter ihx_filter = new FileNameExtensionFilter("Flash Image", "ihx"); hexfile_chooser.addChoosableFileFilter(ihx_filter); hexfile_chooser.setFileFilter(ihx_filter); - + if (!is_pair_programmed() && !device.matchProduct(AltosLib.product_altusmetrum)) { for (int i = 0; i < filters.length; i++) { if (device != null && device.matchProduct(filters[i].product)) @@ -247,7 +247,7 @@ public class AltosFlashUI if (file == null) return false; AltosUIPreferences.set_firmwaredir(file.getParentFile()); - + return true; } diff --git a/altosui/AltosFlightStatsTable.java b/altosui/AltosFlightStatsTable.java index cb0c1562..da71154e 100644 --- a/altosui/AltosFlightStatsTable.java +++ b/altosui/AltosFlightStatsTable.java @@ -140,5 +140,5 @@ public class AltosFlightStatsTable extends JComponent { pos(stats.lon,"E","W")); } } - + } \ No newline at end of file diff --git a/altosui/AltosFlightUI.java b/altosui/AltosFlightUI.java index aac4c9b0..0d21d296 100644 --- a/altosui/AltosFlightUI.java +++ b/altosui/AltosFlightUI.java @@ -226,7 +226,7 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay, A // Telemetry format menu if (reader.supports_telemetry(Altos.ao_telemetry_standard)) { telemetries = new JComboBox(); - for (int i = 1; i <= Altos.ao_telemetry_max; i++) + for (int i = 1; i <= Altos.ao_telemetry_max; i++) telemetries.addItem(Altos.telemetry_name(i)); int telemetry = AltosPreferences.telemetry(serial); if (telemetry <= Altos.ao_telemetry_off || diff --git a/altosui/AltosFreqList.java b/altosui/AltosFreqList.java index 039b5f22..525e5ce5 100644 --- a/altosui/AltosFreqList.java +++ b/altosui/AltosFreqList.java @@ -37,7 +37,7 @@ public class AltosFreqList extends JComboBox { for (i = 0; i < getItemCount(); i++) { AltosFrequency f = (AltosFrequency) getItemAt(i); - + if (f.close(new_frequency)) { setSelectedIndex(i); return; @@ -45,7 +45,7 @@ public class AltosFreqList extends JComboBox { } for (i = 0; i < getItemCount(); i++) { AltosFrequency f = (AltosFrequency) getItemAt(i); - + if (new_frequency < f.frequency) break; } @@ -59,7 +59,7 @@ public class AltosFreqList extends JComboBox { public void set_product(String new_product) { product = new_product; } - + public void set_serial(int new_serial) { serial = new_serial; } diff --git a/altosui/AltosGraphDataPoint.java b/altosui/AltosGraphDataPoint.java index 61a1a227..e672d1bf 100644 --- a/altosui/AltosGraphDataPoint.java +++ b/altosui/AltosGraphDataPoint.java @@ -87,7 +87,7 @@ public class AltosGraphDataPoint implements AltosUIDataPoint { break; case data_gps_height: y = state.gps_height; - break; + break; case data_gps_nsat_solution: if (state.gps != null) y = state.gps.nsat; @@ -109,7 +109,7 @@ public class AltosGraphDataPoint implements AltosUIDataPoint { case data_pressure: y = state.pressure(); break; - + case data_accel_x: case data_accel_y: case data_accel_z: diff --git a/altosui/AltosGraphUI.java b/altosui/AltosGraphUI.java index 40d2f7f4..92b9b94a 100644 --- a/altosui/AltosGraphUI.java +++ b/altosui/AltosGraphUI.java @@ -16,7 +16,7 @@ import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.ui.RefineryUtilities; -public class AltosGraphUI extends AltosUIFrame +public class AltosGraphUI extends AltosUIFrame { JTabbedPane pane; AltosGraph graph; diff --git a/altosui/AltosIgniteUI.java b/altosui/AltosIgniteUI.java index 2e69249f..3028bb9c 100644 --- a/altosui/AltosIgniteUI.java +++ b/altosui/AltosIgniteUI.java @@ -486,7 +486,7 @@ public class AltosIgniteUI pane.add(close, c); close.addActionListener(this); close.setActionCommand("close"); - + pack(); setLocationRelativeTo(owner); diff --git a/altosui/AltosInfoTable.java b/altosui/AltosInfoTable.java index 158b61f0..3242d652 100644 --- a/altosui/AltosInfoTable.java +++ b/altosui/AltosInfoTable.java @@ -205,7 +205,7 @@ public class AltosInfoTable extends JTable { info_add_deg(1, "Pad longitude", state.pad_lon, 'E', 'W'); info_add_row(1, "Pad GPS alt", "%6.0f m", state.pad_alt); } - if (state.gps.year != AltosLib.MISSING) + if (state.gps.year != AltosLib.MISSING) info_add_row(1, "GPS date", "%04d-%02d-%02d", state.gps.year, state.gps.month, diff --git a/altosui/AltosLanded.java b/altosui/AltosLanded.java index 74177753..25d768ad 100644 --- a/altosui/AltosLanded.java +++ b/altosui/AltosLanded.java @@ -44,7 +44,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio show(); value.setText(s); } - + void show(AltosUnits units, double v) { show(units.show(8, v)); } diff --git a/altosui/AltosPad.java b/altosui/AltosPad.java index 7baf0eb2..2844b32c 100644 --- a/altosui/AltosPad.java +++ b/altosui/AltosPad.java @@ -69,7 +69,7 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { public void set_label(String text) { label.setText(text); } - + public LaunchStatus (GridBagLayout layout, int y, String text) { GridBagConstraints c = new GridBagConstraints(); c.weighty = 1; @@ -142,7 +142,7 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { public void set_label(String text) { label.setText(text); } - + void reset() { value.setText(""); } @@ -414,7 +414,7 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { pad_lon.set_font(); pad_alt.set_font(); } - + public void show(AltosState state, AltosListenerState listener_state) { battery.show(state, listener_state); apogee.show(state, listener_state); diff --git a/altosui/AltosScanUI.java b/altosui/AltosScanUI.java index e4a93362..419fe957 100644 --- a/altosui/AltosScanUI.java +++ b/altosui/AltosScanUI.java @@ -34,9 +34,9 @@ class AltosScanResult { int flight; AltosFrequency frequency; int telemetry; - + boolean interrupted = false; - + public String toString() { return String.format("%-9.9s serial %-4d flight %-4d (%s %s)", callsign, serial, flight, frequency.toShortString(), Altos.telemetry_name(telemetry)); @@ -76,7 +76,7 @@ class AltosScanResult { } class AltosScanResults extends LinkedList implements ListModel { - + LinkedList listeners = new LinkedList(); void changed(ListDataEvent de) { @@ -107,7 +107,7 @@ class AltosScanResults extends LinkedList implements ListModel public void addListDataListener(ListDataListener l) { listeners.add(l); } - + public void removeListDataListener(ListDataListener l) { listeners.remove(l); } @@ -221,12 +221,12 @@ public class AltosScanUI void set_telemetry() { reader.set_telemetry(telemetry); } - + void set_frequency() throws InterruptedException, TimeoutException { reader.set_frequency(frequencies[frequency_index].frequency); reader.reset(); } - + void next() throws InterruptedException, TimeoutException { reader.set_monitor(false); Thread.sleep(100); @@ -402,7 +402,7 @@ public class AltosScanUI scanning_label = new JLabel("Scanning:"); frequency_label = new JLabel(""); telemetry_label = new JLabel(""); - + set_label(); c.fill = GridBagConstraints.HORIZONTAL; @@ -434,7 +434,7 @@ public class AltosScanUI } int y_offset = 3 + (Altos.ao_telemetry_max - Altos.ao_telemetry_min + 1); - + list = new JList(results) { //Subclass JList to workaround bug 4832765, which can cause the //scroll pane to not let the user easily scroll up to the beginning diff --git a/altosui/AltosSiteMap.java b/altosui/AltosSiteMap.java index 105afade..643417b5 100644 --- a/altosui/AltosSiteMap.java +++ b/altosui/AltosSiteMap.java @@ -237,7 +237,7 @@ public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay { AltosSiteMapTile tile = mapTiles.get(k); tile.clearMap(); } - + centre = getBaseLocation(lat, lng); scrollRocketToVisible(pt(lat,lng)); } diff --git a/altosui/AltosSiteMapPreload.java b/altosui/AltosSiteMapPreload.java index 66399557..8380b967 100644 --- a/altosui/AltosSiteMapPreload.java +++ b/altosui/AltosSiteMapPreload.java @@ -178,7 +178,7 @@ class AltosSites extends Thread { try { URLConnection uc = url.openConnection(); //int length = uc.getContentLength(); - + InputStreamReader in_stream = new InputStreamReader(uc.getInputStream(), Altos.unicode_set); BufferedReader in = new BufferedReader(in_stream); @@ -222,7 +222,7 @@ public class AltosSiteMapPreload extends AltosUIDialog implements ActionListener AltosSites sites; JLabel site_list_label; JComboBox site_list; - + JToggleButton load_button; boolean loading; JButton close_button; @@ -347,7 +347,7 @@ public class AltosSiteMapPreload extends AltosUIDialog implements ActionListener pbar.setValue(0); pbar.setString(""); pbar.setStringPainted(true); - + c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.CENTER; c.insets = i; @@ -373,7 +373,7 @@ public class AltosSiteMapPreload extends AltosUIDialog implements ActionListener c.gridwidth = 1; pane.add(site_list_label, c); - + site_list = new JComboBox(new String[] { "Site List" }); site_list.addItemListener(this); @@ -390,7 +390,7 @@ public class AltosSiteMapPreload extends AltosUIDialog implements ActionListener c.gridwidth = 1; pane.add(site_list, c); - + lat = new AltosMapPos(owner, "Latitude:", lat_hemi_names, @@ -407,7 +407,7 @@ public class AltosSiteMapPreload extends AltosUIDialog implements ActionListener c.anchor = GridBagConstraints.CENTER; pane.add(lat, c); - + lon = new AltosMapPos(owner, "Longitude:", lon_hemi_names, @@ -429,7 +429,7 @@ public class AltosSiteMapPreload extends AltosUIDialog implements ActionListener load_button = new JToggleButton("Load Map"); load_button.addActionListener(this); load_button.setActionCommand("load"); - + c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.CENTER; c.insets = i; @@ -446,7 +446,7 @@ public class AltosSiteMapPreload extends AltosUIDialog implements ActionListener close_button = new JButton("Close"); close_button.addActionListener(this); close_button.setActionCommand("close"); - + c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.CENTER; c.insets = i; diff --git a/altosui/AltosUI.java b/altosui/AltosUI.java index 5d459947..a1bc83bf 100644 --- a/altosui/AltosUI.java +++ b/altosui/AltosUI.java @@ -233,7 +233,7 @@ public class AltosUI extends AltosUIFrame { }); setLocationByPlatform(false); - + /* Insets aren't set before the window is visible */ setVisible(true); } @@ -468,7 +468,7 @@ public class AltosUI extends AltosUIFrame { } return false; } - + static boolean process_summary(File file) { AltosStateIterable states = record_iterable(file); if (states == null) @@ -547,7 +547,7 @@ public class AltosUI extends AltosUIFrame { System.out.printf(" --kml\tgenerate KML output for use with Google Earth\n"); System.exit(code); } - + public static void main(final String[] args) { int errors = 0; load_library(null); diff --git a/altosui/AltosUIPreferencesBackend.java b/altosui/AltosUIPreferencesBackend.java index 697d9902..f85735e8 100644 --- a/altosui/AltosUIPreferencesBackend.java +++ b/altosui/AltosUIPreferencesBackend.java @@ -25,7 +25,7 @@ import javax.swing.filechooser.FileSystemView; public class AltosUIPreferencesBackend implements AltosPreferencesBackend { private Preferences _preferences = null; - + public AltosUIPreferencesBackend() { _preferences = Preferences.userRoot().node("/org/altusmetrum/altosui"); } diff --git a/altosuilib/AltosDeviceDialog.java b/altosuilib/AltosDeviceDialog.java index 73bc0b2f..0a3ddb7b 100644 --- a/altosuilib/AltosDeviceDialog.java +++ b/altosuilib/AltosDeviceDialog.java @@ -30,7 +30,7 @@ public abstract class AltosDeviceDialog extends AltosUIDialog implements ActionL public Frame frame; public int product; public JPanel buttonPane; - + public AltosDevice getValue() { return value; } diff --git a/altosuilib/AltosUIAxis.java b/altosuilib/AltosUIAxis.java index 1638ea29..7bc2def9 100644 --- a/altosuilib/AltosUIAxis.java +++ b/altosuilib/AltosUIAxis.java @@ -50,7 +50,7 @@ public class AltosUIAxis extends NumberAxis { public void set_units() { setLabel(String.format("%s (%s)", label, units.show_units())); } - + public void set_enable(boolean enable) { if (enable) { visible++; diff --git a/altosuilib/AltosUIEnable.java b/altosuilib/AltosUIEnable.java index ea4bd00a..40b5f087 100644 --- a/altosuilib/AltosUIEnable.java +++ b/altosuilib/AltosUIEnable.java @@ -56,7 +56,7 @@ public class AltosUIEnable extends Container { this.name = name; this.grapher = grapher; enable = new JRadioButton(name, enabled); - grapher.set_enable(enabled); + grapher.set_enable(enabled); enable.addActionListener(this); } } diff --git a/altosuilib/AltosUIFrame.java b/altosuilib/AltosUIFrame.java index 3fc99910..3dc2a0ad 100644 --- a/altosuilib/AltosUIFrame.java +++ b/altosuilib/AltosUIFrame.java @@ -45,7 +45,7 @@ public class AltosUIFrame extends JFrame implements AltosUIListener, AltosPositi }; static public String[] icon_names; - + static public void set_icon_names(String[] new_icon_names) { icon_names = new_icon_names; } public String[] icon_names() { @@ -57,7 +57,7 @@ public class AltosUIFrame extends JFrame implements AltosUIListener, AltosPositi public void set_icon() { ArrayList icons = new ArrayList(); String[] icon_names = icon_names(); - + for (int i = 0; i < icon_names.length; i++) { java.net.URL imgURL = AltosUIFrame.class.getResource(icon_names[i]); if (imgURL != null) @@ -65,14 +65,14 @@ public class AltosUIFrame extends JFrame implements AltosUIListener, AltosPositi } setIconImages(icons); } - + private boolean location_by_platform = true; public void setLocationByPlatform(boolean lbp) { location_by_platform = lbp; super.setLocationByPlatform(lbp); } - + public void setSize() { /* Smash sizes around so that the window comes up in the right shape */ Insets i = getInsets(); @@ -153,7 +153,7 @@ public class AltosUIFrame extends JFrame implements AltosUIListener, AltosPositi setPosition(position); } } - + void init() { AltosUIPreferences.register_ui_listener(this); AltosUIPreferences.register_position_listener(this); diff --git a/altosuilib/AltosUIGraph.java b/altosuilib/AltosUIGraph.java index 061a7629..21e13cf6 100644 --- a/altosuilib/AltosUIGraph.java +++ b/altosuilib/AltosUIGraph.java @@ -82,7 +82,7 @@ public class AltosUIGraph implements AltosUnitsListener { public void addSeries(String label, int fetch, AltosUnits units, Color color) { addSeries(label, fetch, units, color, true, newAxis(label, units, color)); } - + public void addMarker(String label, int fetch, Color color) { AltosUIMarker marker = new AltosUIMarker(fetch, color, plot); if (enable != null) @@ -131,7 +131,7 @@ public class AltosUIGraph implements AltosUnitsListener { this.axis_index = 0; xAxis = new NumberAxis("Time (s)"); - + xAxis.setAutoRangeIncludesZero(true); plot = new XYPlot(); diff --git a/altosuilib/AltosUIGrapher.java b/altosuilib/AltosUIGrapher.java index 23e7d9f0..54f8d5a9 100644 --- a/altosuilib/AltosUIGrapher.java +++ b/altosuilib/AltosUIGrapher.java @@ -37,7 +37,7 @@ import org.jfree.data.*; interface AltosUIGrapher { public abstract void set_units(); - + public abstract void clear(); public abstract void add(AltosUIDataPoint dataPoint); diff --git a/altosuilib/AltosUIMarker.java b/altosuilib/AltosUIMarker.java index ae8eb034..efd27921 100644 --- a/altosuilib/AltosUIMarker.java +++ b/altosuilib/AltosUIMarker.java @@ -41,7 +41,7 @@ public class AltosUIMarker implements AltosUIGrapher { boolean enabled; int fetch; Color color; - + private void remove_markers() { for (ValueMarker marker : markers) plot.removeDomainMarker(marker); diff --git a/altosuilib/AltosUIPreferencesBackend.java b/altosuilib/AltosUIPreferencesBackend.java index 64d3e3df..d6575717 100644 --- a/altosuilib/AltosUIPreferencesBackend.java +++ b/altosuilib/AltosUIPreferencesBackend.java @@ -25,7 +25,7 @@ import javax.swing.filechooser.FileSystemView; public class AltosUIPreferencesBackend implements AltosPreferencesBackend { private Preferences _preferences = null; - + public AltosUIPreferencesBackend() { _preferences = Preferences.userRoot().node("/org/altusmetrum/altosui"); } diff --git a/altosuilib/AltosUISeries.java b/altosuilib/AltosUISeries.java index 1f2a1c3f..c17175e4 100644 --- a/altosuilib/AltosUISeries.java +++ b/altosuilib/AltosUISeries.java @@ -38,7 +38,7 @@ class AltosUITime extends AltosUnits { public double value(double v, boolean imperial_units) { return v; } public double inverse(double v, boolean imperial_unis) { return v; } - + public String show_units(boolean imperial_units) { return "s"; } public String say_units(boolean imperial_units) { return "seconds"; } @@ -60,7 +60,7 @@ public class AltosUISeries extends XYSeries implements AltosUIGrapher { XYItemRenderer renderer; int fetch; boolean enable; - + public void set_units() { axis.set_units(); StandardXYToolTipGenerator ttg; diff --git a/libaltos/libaltos.c b/libaltos/libaltos.c index a623d5ae..b7ec98fc 100644 --- a/libaltos/libaltos.c +++ b/libaltos/libaltos.c @@ -817,7 +817,7 @@ get_string(io_object_t object, CFStringRef entry, char *result, int result_len) got_string = CFStringGetCString(entry_as_string, result, result_len, kCFStringEncodingASCII); - + CFRelease(entry_as_string); if (got_string) return 1; @@ -830,7 +830,7 @@ get_number(io_object_t object, CFStringRef entry, int *result) { CFTypeRef entry_as_number; Boolean got_number; - + entry_as_number = IORegistryEntrySearchCFProperty (object, kIOServicePlane, entry, @@ -885,7 +885,7 @@ altos_list_next(struct altos_list *list, struct altos_device *device) object = IOIteratorNext(list->iterator); if (!object) return 0; - + if (!get_number (object, CFSTR(kUSBVendorID), &device->vendor) || !get_number (object, CFSTR(kUSBProductID), &device->product)) continue; @@ -989,7 +989,7 @@ log_message(char *fmt, ...) if (log) { SYSTEMTIME time; GetLocalTime(&time); - fprintf (log, "%4d-%02d-%02d %2d:%02d:%02d. ", + fprintf (log, "%4d-%02d-%02d %2d:%02d:%02d. ", time.wYear, time.wMonth, time.wDay, time.wHour, time.wMinute, time.wSecond); va_start(a, fmt); @@ -1340,7 +1340,7 @@ altos_open(struct altos_device *device) altos_set_last_windows_error(); Sleep(100); } - + if (file->handle == INVALID_HANDLE_VALUE) { free(file); return NULL; -- cgit v1.2.3 From ecebb3902868d1d7485d2bc99ba4140c6b90567e Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 30 Apr 2014 21:30:46 -0700 Subject: altoslib: Track pyro firing state when reading mega eeprom files TeleMega records whether each pyro has been fired in the eeprom file; track that in the AltosState record. Signed-off-by: Keith Packard --- altoslib/AltosEepromMega.java | 1 + altoslib/AltosState.java | 10 ++++++++++ 2 files changed, 11 insertions(+) (limited to 'altoslib') diff --git a/altoslib/AltosEepromMega.java b/altoslib/AltosEepromMega.java index 35e87885..da5f2a3e 100644 --- a/altoslib/AltosEepromMega.java +++ b/altoslib/AltosEepromMega.java @@ -150,6 +150,7 @@ public class AltosEepromMega extends AltosEeprom { voltages[i] = AltosConvert.mega_pyro_voltage(sense(i)); state.set_ignitor_voltage(voltages); + state.set_pyro_fired(pyro()); break; case AltosLib.AO_LOG_GPS_TIME: state.set_tick(tick); diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index d65e3bd8..4dbd751b 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -619,6 +619,8 @@ public class AltosState implements Cloneable { public AltosCompanion companion; + public int pyro_fired; + public void set_npad(int npad) { this.npad = npad; gps_waiting = MIN_PAD_SAMPLES - npad; @@ -711,6 +713,8 @@ public class AltosState implements Cloneable { baro = null; companion = null; + + pyro_fired = 0; } void finish_update() { @@ -840,6 +844,8 @@ public class AltosState implements Cloneable { baro = old.baro; companion = old.companion; + + pyro_fired = old.pyro_fired; } void update_time() { @@ -1114,6 +1120,10 @@ public class AltosState implements Cloneable { this.ignitor_voltage = voltage; } + public void set_pyro_fired(int fired) { + this.pyro_fired = fired; + } + public double time_since_boost() { if (tick == AltosLib.MISSING) return 0.0; -- cgit v1.2.3 From 2dfc4bc92b11252f17103f28198a702a3fdc2b2d Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 2 May 2014 13:53:08 -0700 Subject: altosui: Add configuration UI for beeper tone Signed-off-by: Keith Packard --- altoslib/AltosConfigData.java | 18 ++++++++++++ altoslib/AltosConfigValues.java | 4 +++ altoslib/AltosConvert.java | 12 ++++++++ altosui/AltosConfigUI.java | 62 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 96 insertions(+) (limited to 'altoslib') diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index edaf4601..750faa71 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -70,6 +70,9 @@ public class AltosConfigData implements Iterable { /* HAS_APRS */ public int aprs_interval; + /* HAS_BEEP */ + public int beep; + /* Storage info replies */ public int storage_size; public int storage_erase_unit; @@ -210,6 +213,8 @@ public class AltosConfigData implements Iterable { aprs_interval = -1; + beep = -1; + storage_size = -1; storage_erase_unit = -1; stored_flight = 0; @@ -286,6 +291,9 @@ public class AltosConfigData implements Iterable { /* HAS_APRS */ try { aprs_interval = get_int(line, "APRS interval:"); } catch (Exception e) {} + /* HAS_BEEP */ + try { beep = get_int(line, "Beeper setting:"); System.out.printf ("beeper now %d\n", beep); } catch (Exception e) {} + /* Storage info replies */ try { storage_size = get_int(line, "Storage size:"); } catch (Exception e) {} try { storage_erase_unit = get_int(line, "Storage erase unit:"); } catch (Exception e) {} @@ -409,8 +417,13 @@ public class AltosConfigData implements Iterable { if (npyro > 0) pyros = source.pyros(); + /* HAS_APRS */ if (aprs_interval >= 0) aprs_interval = source.aprs_interval(); + + /* HAS_BEEP */ + if (beep >= 0) + beep = source.beep(); } public void set_values(AltosConfigValues dest) { @@ -449,6 +462,7 @@ public class AltosConfigData implements Iterable { else dest.set_pyros(null); dest.set_aprs_interval(aprs_interval); + dest.set_beep(beep); } public void save(AltosLink link, boolean remote) throws InterruptedException, TimeoutException { @@ -515,6 +529,10 @@ public class AltosConfigData implements Iterable { if (aprs_interval >= 0) link.printf("c A %d\n", aprs_interval); + /* HAS_BEEP */ + if (beep >= 0) + link.printf("c b %d\n", beep); + link.printf("c w\n"); link.flush_output(); } diff --git a/altoslib/AltosConfigValues.java b/altoslib/AltosConfigValues.java index 4aa55d6a..1a9fddbf 100644 --- a/altoslib/AltosConfigValues.java +++ b/altoslib/AltosConfigValues.java @@ -76,4 +76,8 @@ public interface AltosConfigValues { public abstract int aprs_interval(); public abstract void set_aprs_interval(int new_aprs_interval); + + public abstract int beep(); + + public abstract void set_beep(int new_beep); } diff --git a/altoslib/AltosConvert.java b/altoslib/AltosConvert.java index 35923ec3..4ed45c68 100644 --- a/altoslib/AltosConvert.java +++ b/altoslib/AltosConvert.java @@ -359,4 +359,16 @@ public class AltosConvert { csum += data[i + start]; return csum & 0xff; } + + public static double beep_value_to_freq(int value) { + if (value == 0) + return 4000; + return 1.0/2.0 * (24.0e6/32.0) / (double) value; + } + + public static int beep_freq_to_value(double freq) { + if (freq == 0) + return 94; + return (int) Math.floor (1.0/2.0 * (24.0e6/32.0) / freq + 0.5); + } } diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java index 656b0b6f..0a5291ea 100644 --- a/altosui/AltosConfigUI.java +++ b/altosui/AltosConfigUI.java @@ -45,6 +45,7 @@ public class AltosConfigUI JLabel ignite_mode_label; JLabel pad_orientation_label; JLabel callsign_label; + JLabel beep_label; public boolean dirty; @@ -63,6 +64,7 @@ public class AltosConfigUI JComboBox ignite_mode_value; JComboBox pad_orientation_value; JTextField callsign_value; + JComboBox beep_value; JButton pyro; @@ -112,6 +114,12 @@ public class AltosConfigUI "10" }; + static String[] beep_values = { + "3750", + "4000", + "4250", + }; + static String[] pad_orientation_values = { "Antenna Up", "Antenna Down", @@ -204,6 +212,13 @@ public class AltosConfigUI } } + void set_beep_tool_tip() { + if (beep_value.isEnabled()) + beep_value.setToolTipText("What frequency the beeper will sound at"); + else + beep_value.setToolTipText("Older firmware could not select beeper frequency"); + } + /* Build the UI using a grid bag */ public AltosConfigUI(JFrame in_owner, boolean remote) { super (in_owner, "Configure Flight Computer", false); @@ -569,6 +584,32 @@ public class AltosConfigUI set_pad_orientation_tool_tip(); row++; + /* Beeper */ + c = new GridBagConstraints(); + c.gridx = 0; c.gridy = row; + c.gridwidth = 4; + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.LINE_START; + c.insets = il; + c.ipady = 5; + beep_label = new JLabel("Beeper Frequency:"); + pane.add(beep_label, c); + + c = new GridBagConstraints(); + c.gridx = 4; c.gridy = row; + c.gridwidth = 4; + c.fill = GridBagConstraints.HORIZONTAL; + c.weightx = 1; + c.anchor = GridBagConstraints.LINE_START; + c.insets = ir; + c.ipady = 5; + beep_value = new JComboBox(beep_values); + beep_value.setEditable(true); + beep_value.addItemListener(this); + pane.add(beep_value, c); + set_beep_tool_tip(); + row++; + /* Pyro channels */ c = new GridBagConstraints(); c.gridx = 4; c.gridy = row; @@ -908,6 +949,27 @@ public class AltosConfigUI return -1; } + public void set_beep(int new_beep) { + int new_freq = (int) Math.floor (AltosConvert.beep_value_to_freq(new_beep) + 0.5); + System.out.printf("set_beep %d %d\n", new_beep, new_freq); + for (int i = 0; i < beep_values.length; i++) + if (new_beep == AltosConvert.beep_freq_to_value(Integer.parseInt(beep_values[i]))) { + beep_value.setSelectedIndex(i); + set_beep_tool_tip(); + return; + } + beep_value.setSelectedItem(String.format("%d", new_freq)); + beep_value.setEnabled(new_beep >= 0); + set_beep_tool_tip(); + } + + public int beep() { + if (beep_value.isEnabled()) + return AltosConvert.beep_freq_to_value(Integer.parseInt(beep_value.getSelectedItem().toString())); + else + return -1; + } + public void set_pyros(AltosPyro[] new_pyros) { pyros = new_pyros; pyro.setVisible(pyros != null); -- cgit v1.2.3 From d2e6efa810b7fccc5af937386a40ae5af064bf26 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 5 May 2014 23:38:05 -0700 Subject: altoslib: Add a comment to remind us to fix the IMU code to deal with calibration Signed-off-by: Keith Packard --- altoslib/AltosIMU.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'altoslib') diff --git a/altoslib/AltosIMU.java b/altoslib/AltosIMU.java index 260f3587..99efb76f 100644 --- a/altoslib/AltosIMU.java +++ b/altoslib/AltosIMU.java @@ -28,6 +28,18 @@ public class AltosIMU implements Cloneable { public double gyro_y; public double gyro_z; +/* + * XXX use ground measurements to adjust values + + public double ground_accel_x; + public double ground_accel_y; + public double ground_accel_z; + + public double ground_gyro_x; + public double ground_gyro_y; + public double ground_gyro_z; +*/ + public static int counts_per_g = 2048; public static double convert_accel(int counts) { -- cgit v1.2.3 From 39fbc4cb1d4c92522c90aa5e36fd62a4827d8306 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 5 May 2014 23:38:44 -0700 Subject: altoslib: Parse remaining mega AO_LOG_FLIGNT and AO_LOG_GPS_TIME fields GPS fields past 'day' were not getting parsed. Ground values for the IMU were not getting parsed, but a false 'temperature' value was being read. Signed-off-by: Keith Packard --- altoslib/AltosEepromMega.java | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosEepromMega.java b/altoslib/AltosEepromMega.java index da5f2a3e..f0d7097e 100644 --- a/altoslib/AltosEepromMega.java +++ b/altoslib/AltosEepromMega.java @@ -32,7 +32,12 @@ public class AltosEepromMega extends AltosEeprom { public int flight() { return data16(0); } public int ground_accel() { return data16(2); } public int ground_pres() { return data32(4); } - public int ground_temp() { return data32(8); } + public int ground_accel_along() { return data16(8); } + public int ground_accel_across() { return data16(10); } + public int ground_accel_through() { return data16(12); } + public int ground_roll() { return data16(14); } + public int ground_pitch() { return data16(16); } + public int ground_yaw() { return data16(18); } /* AO_LOG_STATE elements */ public int state() { return data16(0); } @@ -70,6 +75,13 @@ public class AltosEepromMega extends AltosEeprom { public int year() { return data8(14); } public int month() { return data8(15); } public int day() { return data8(16); } + public int course() { return data8(17); } + public int ground_speed() { return data16(18); } + public int climb_rate() { return data16(20); } + public int pdop() { return data8(22); } + public int hdop() { return data8(23); } + public int vdop() { return data8(24); } + public int mode() { return data8(25); } /* AO_LOG_GPS_SAT elements */ public int nsat() { return data16(0); } @@ -106,7 +118,6 @@ public class AltosEepromMega extends AltosEeprom { state.set_flight(flight()); state.set_ground_accel(ground_accel()); state.set_ground_pressure(ground_pres()); - state.set_temperature(ground_temp() / 100.0); break; case AltosLib.AO_LOG_STATE: state.set_tick(tick); @@ -173,6 +184,11 @@ public class AltosEepromMega extends AltosEeprom { gps.year = 2000 + year(); gps.month = month(); gps.day = day(); + gps.ground_speed = ground_speed() * 1.0e-2; + gps.course = course() * 2; + gps.climb_rate = climb_rate() * 1.0e-2; + gps.hdop = hdop(); + gps.vdop = vdop(); break; case AltosLib.AO_LOG_GPS_SAT: state.set_tick(tick); -- cgit v1.2.3 From eeacc001ba089b4bf5552b8ef36e61a0a96efabe Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 15 May 2014 23:57:50 -0600 Subject: altosui: Remove debug printf about beep config Signed-off-by: Keith Packard --- altoslib/AltosConfigData.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'altoslib') diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index 750faa71..213d8f13 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -292,7 +292,7 @@ public class AltosConfigData implements Iterable { try { aprs_interval = get_int(line, "APRS interval:"); } catch (Exception e) {} /* HAS_BEEP */ - try { beep = get_int(line, "Beeper setting:"); System.out.printf ("beeper now %d\n", beep); } catch (Exception e) {} + try { beep = get_int(line, "Beeper setting:"); } catch (Exception e) {} /* Storage info replies */ try { storage_size = get_int(line, "Storage size:"); } catch (Exception e) {} -- cgit v1.2.3 From b60a3689910731d9bdb8a431a3dcc9e99f961b35 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 22 May 2014 18:46:58 -0700 Subject: altoslib: Move CSV/KML output code to altoslib It's sharable, so share it Signed-off-by: Keith Packard --- altoslib/AltosCSV.java | 334 +++++++++++++++++++++++++++++++++++++++++++++ altoslib/AltosKML.java | 178 ++++++++++++++++++++++++ altoslib/AltosWriter.java | 27 ++++ altoslib/Makefile.am | 5 +- altosui/AltosCSV.java | 335 ---------------------------------------------- altosui/AltosKML.java | 179 ------------------------- altosui/AltosWriter.java | 30 ----- altosui/Makefile.am | 3 - 8 files changed, 543 insertions(+), 548 deletions(-) create mode 100644 altoslib/AltosCSV.java create mode 100644 altoslib/AltosKML.java create mode 100644 altoslib/AltosWriter.java delete mode 100644 altosui/AltosCSV.java delete mode 100644 altosui/AltosKML.java delete mode 100644 altosui/AltosWriter.java (limited to 'altoslib') diff --git a/altoslib/AltosCSV.java b/altoslib/AltosCSV.java new file mode 100644 index 00000000..8176d21b --- /dev/null +++ b/altoslib/AltosCSV.java @@ -0,0 +1,334 @@ +/* + * Copyright © 2010 Keith Packard + * + * 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_3; + +import java.io.*; +import java.util.*; + +public class AltosCSV implements AltosWriter { + File name; + PrintStream out; + boolean header_written; + boolean seen_boost; + int boost_tick; + LinkedList pad_states; + AltosState state; + + static final int ALTOS_CSV_VERSION = 5; + + /* Version 4 format: + * + * General info + * version number + * serial number + * flight number + * callsign + * time (seconds since boost) + * clock (tick count / 100) + * rssi + * link quality + * + * Flight status + * state + * state name + * + * Basic sensors + * acceleration (m/s²) + * pressure (mBar) + * altitude (m) + * height (m) + * accelerometer speed (m/s) + * barometer speed (m/s) + * temp (°C) + * battery (V) + * drogue (V) + * main (V) + * + * Advanced sensors (if available) + * accel_x (m/s²) + * accel_y (m/s²) + * accel_z (m/s²) + * gyro_x (d/s) + * gyro_y (d/s) + * gyro_z (d/s) + * mag_x (g) + * mag_y (g) + * mag_z (g) + * + * GPS data (if available) + * connected (1/0) + * locked (1/0) + * nsat (used for solution) + * latitude (°) + * longitude (°) + * altitude (m) + * year (e.g. 2010) + * month (1-12) + * day (1-31) + * hour (0-23) + * minute (0-59) + * second (0-59) + * from_pad_dist (m) + * from_pad_azimuth (deg true) + * from_pad_range (m) + * from_pad_elevation (deg from horizon) + * hdop + * + * GPS Sat data + * C/N0 data for all 32 valid SDIDs + * + * Companion data + * companion_id (1-255. 10 is TeleScience) + * time of last companion data (seconds since boost) + * update_period (0.1-2.55 minimum telemetry interval) + * channels (0-12) + * channel data for all 12 possible channels + */ + + void write_general_header() { + out.printf("version,serial,flight,call,time,clock,rssi,lqi"); + } + + void write_general(AltosState state) { + out.printf("%s, %d, %d, %s, %8.2f, %8.2f, %4d, %3d", + ALTOS_CSV_VERSION, state.serial, state.flight, state.callsign, + (double) state.time, (double) state.tick / 100.0, + state.rssi, + state.status & 0x7f); + } + + void write_flight_header() { + out.printf("state,state_name"); + } + + void write_flight(AltosState state) { + out.printf("%d,%8s", state.state, state.state_name()); + } + + void write_basic_header() { + out.printf("acceleration,pressure,altitude,height,accel_speed,baro_speed,temperature,battery_voltage,drogue_voltage,main_voltage"); + } + + void write_basic(AltosState state) { + out.printf("%8.2f,%10.2f,%8.2f,%8.2f,%8.2f,%8.2f,%5.1f,%5.2f,%5.2f,%5.2f", + state.acceleration(), + state.pressure(), + state.altitude(), + state.height(), + state.speed(), + state.speed(), + state.temperature, + state.battery_voltage, + state.apogee_voltage, + state.main_voltage); + } + + void write_advanced_header() { + out.printf("accel_x,accel_y,accel_z,gyro_x,gyro_y,gyro_z"); + } + + void write_advanced(AltosState state) { + AltosIMU imu = state.imu; + AltosMag mag = state.mag; + + if (imu == null) + imu = new AltosIMU(); + if (mag == null) + mag = new AltosMag(); + out.printf("%6d,%6d,%6d,%6d,%6d,%6d,%6d,%6d,%6d", + imu.accel_x, imu.accel_y, imu.accel_z, + imu.gyro_x, imu.gyro_y, imu.gyro_z, + mag.x, mag.y, mag.z); + } + + void write_gps_header() { + out.printf("connected,locked,nsat,latitude,longitude,altitude,year,month,day,hour,minute,second,pad_dist,pad_range,pad_az,pad_el,hdop"); + } + + void write_gps(AltosState state) { + AltosGPS gps = state.gps; + if (gps == null) + gps = new AltosGPS(); + + AltosGreatCircle from_pad = state.from_pad; + if (from_pad == null) + from_pad = new AltosGreatCircle(); + + out.printf("%2d,%2d,%3d,%12.7f,%12.7f,%8.1f,%5d,%3d,%3d,%3d,%3d,%3d,%9.0f,%9.0f,%4.0f,%4.0f,%6.1f", + gps.connected?1:0, + gps.locked?1:0, + gps.nsat, + gps.lat, + gps.lon, + gps.alt, + gps.year, + gps.month, + gps.day, + gps.hour, + gps.minute, + gps.second, + from_pad.distance, + state.range, + from_pad.bearing, + state.elevation, + gps.hdop); + } + + void write_gps_sat_header() { + for(int i = 1; i <= 32; i++) { + out.printf("sat%02d", i); + if (i != 32) + out.printf(","); + } + } + + void write_gps_sat(AltosState state) { + AltosGPS gps = state.gps; + for(int i = 1; i <= 32; i++) { + int c_n0 = 0; + if (gps != null && gps.cc_gps_sat != null) { + for(int j = 0; j < gps.cc_gps_sat.length; j++) + if (gps.cc_gps_sat[j].svid == i) { + c_n0 = gps.cc_gps_sat[j].c_n0; + break; + } + } + out.printf ("%3d", c_n0); + if (i != 32) + out.printf(","); + } + } + + void write_companion_header() { + out.printf("companion_id,companion_time,companion_update,companion_channels"); + for (int i = 0; i < 12; i++) + out.printf(",companion_%02d", i); + } + + void write_companion(AltosState state) { + AltosCompanion companion = state.companion; + + int channels_written = 0; + if (companion == null) { + out.printf("0,0,0,0"); + } else { + out.printf("%3d,%5.2f,%5.2f,%2d", + companion.board_id, + (companion.tick - boost_tick) / 100.0, + companion.update_period / 100.0, + companion.channels); + for (; channels_written < companion.channels; channels_written++) + out.printf(",%5d", companion.companion_data[channels_written]); + } + for (; channels_written < 12; channels_written++) + out.printf(",0"); + } + + void write_header(boolean advanced, boolean gps, boolean companion) { + out.printf("#"); write_general_header(); + out.printf(","); write_flight_header(); + out.printf(","); write_basic_header(); + if (advanced) + out.printf(","); write_advanced_header(); + if (gps) { + out.printf(","); write_gps_header(); + out.printf(","); write_gps_sat_header(); + } + if (companion) { + out.printf(","); write_companion_header(); + } + out.printf ("\n"); + } + + void write_one(AltosState state) { + write_general(state); out.printf(","); + write_flight(state); out.printf(","); + write_basic(state); out.printf(","); + if (state.imu != null || state.mag != null) + write_advanced(state); + if (state.gps != null) { + out.printf(","); + write_gps(state); out.printf(","); + write_gps_sat(state); + } + if (state.companion != null) { + out.printf(","); + write_companion(state); + } + out.printf ("\n"); + } + + void flush_pad() { + while (!pad_states.isEmpty()) { + write_one (pad_states.remove()); + } + } + + public void write(AltosState state) { + if (state.state == AltosLib.ao_flight_startup) + return; + if (!header_written) { + write_header(state.imu != null || state.mag != null, + state.gps != null, state.companion != null); + header_written = true; + } + if (!seen_boost) { + if (state.state >= AltosLib.ao_flight_boost) { + seen_boost = true; + boost_tick = state.tick; + flush_pad(); + } + } + if (seen_boost) + write_one(state); + else + pad_states.add(state); + } + + public PrintStream out() { + return out; + } + + public void close() { + if (!pad_states.isEmpty()) { + boost_tick = pad_states.element().tick; + flush_pad(); + } + out.close(); + } + + public void write(AltosStateIterable states) { + states.write_comments(out()); + for (AltosState state : states) + write(state); + } + + public AltosCSV(PrintStream in_out, File in_name) { + name = in_name; + out = in_out; + pad_states = new LinkedList(); + } + + public AltosCSV(File in_name) throws FileNotFoundException { + this(new PrintStream(in_name), in_name); + } + + public AltosCSV(String in_string) throws FileNotFoundException { + this(new File(in_string)); + } +} diff --git a/altoslib/AltosKML.java b/altoslib/AltosKML.java new file mode 100644 index 00000000..cc9a9f51 --- /dev/null +++ b/altoslib/AltosKML.java @@ -0,0 +1,178 @@ +/* + * Copyright © 2010 Keith Packard + * + * 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_3; + +import java.io.*; + +public class AltosKML implements AltosWriter { + + File name; + PrintStream out; + int flight_state = -1; + AltosState prev = null; + double gps_start_altitude; + + static final String[] kml_state_colors = { + "FF000000", + "FF000000", + "FF000000", + "FF0000FF", + "FF4080FF", + "FF00FFFF", + "FFFF0000", + "FF00FF00", + "FF000000", + "FFFFFFFF" + }; + + static final String kml_header_start = + "\n" + + "\n" + + "\n" + + " AO Flight#%d S/N: %03d\n" + + " \n"; + static final String kml_header_end = + " \n" + + " 0\n"; + + static final String kml_style_start = + " \n"; + + static final String kml_placemark_start = + " \n" + + " %s\n" + + " #ao-flightstate-%s\n" + + " \n" + + " 1\n" + + " absolute\n" + + " \n"; + + static final String kml_coord_fmt = + " %.7f,%.7f,%.7f \n"; + + static final String kml_placemark_end = + " \n" + + " \n" + + " \n"; + + static final String kml_footer = + "\n" + + "\n"; + + void start (AltosState record) { + out.printf(kml_header_start, record.flight, record.serial); + out.printf("Date: %04d-%02d-%02d\n", + record.gps.year, record.gps.month, record.gps.day); + out.printf("Time: %2d:%02d:%02d\n", + record.gps.hour, record.gps.minute, record.gps.second); + out.printf("%s", kml_header_end); + } + + boolean started = false; + + void state_start(AltosState state) { + String state_name = AltosLib.state_name(state.state); + out.printf(kml_style_start, state_name, kml_state_colors[state.state]); + out.printf("\tState: %s\n", state_name); + out.printf("%s", kml_style_end); + out.printf(kml_placemark_start, state_name, state_name); + } + + void state_end(AltosState state) { + out.printf("%s", kml_placemark_end); + } + + void coord(AltosState state) { + AltosGPS gps = state.gps; + double altitude; + + if (state.height() != AltosLib.MISSING) + altitude = state.height() + gps_start_altitude; + else + altitude = gps.alt; + out.printf(kml_coord_fmt, + gps.lon, gps.lat, + altitude, (double) gps.alt, + state.time, gps.nsat); + } + + void end() { + out.printf("%s", kml_footer); + } + + public void close() { + if (prev != null) { + state_end(prev); + end(); + prev = null; + } + } + + public void write(AltosState state) { + AltosGPS gps = state.gps; + + if (gps == null) + return; + + if (gps.lat == AltosLib.MISSING) + return; + if (gps.lon == AltosLib.MISSING) + return; + if (!started) { + start(state); + started = true; + gps_start_altitude = gps.alt; + } + if (prev != null && prev.gps_sequence == state.gps_sequence) + return; + if (state.state != flight_state) { + flight_state = state.state; + if (prev != null) { + coord(state); + state_end(prev); + } + state_start(state); + } + coord(state); + prev = state; + } + + public void write(AltosStateIterable states) { + for (AltosState state : states) { + if ((state.set & AltosState.set_gps) != 0) + write(state); + } + } + + public AltosKML(File in_name) throws FileNotFoundException { + name = in_name; + out = new PrintStream(name); + } + + public AltosKML(String in_string) throws FileNotFoundException { + this(new File(in_string)); + } +} diff --git a/altoslib/AltosWriter.java b/altoslib/AltosWriter.java new file mode 100644 index 00000000..0b0daebd --- /dev/null +++ b/altoslib/AltosWriter.java @@ -0,0 +1,27 @@ +/* + * Copyright © 2010 Keith Packard + * + * 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_3; + +public interface AltosWriter { + + public void write(AltosState state); + + public void write(AltosStateIterable states); + + public void close(); +} diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am index 2ee4d89f..67cc38ff 100644 --- a/altoslib/Makefile.am +++ b/altoslib/Makefile.am @@ -31,6 +31,7 @@ altoslib_JAVA = \ AltosConfigValues.java \ AltosConvert.java \ AltosCRCException.java \ + AltosCSV.java \ AltosDebug.java \ AltosEeprom.java \ AltosEepromChunk.java \ @@ -62,6 +63,7 @@ altoslib_JAVA = \ AltosIdleMonitorListener.java \ AltosIgnite.java \ AltosIMU.java \ + AltosKML.java \ AltosLine.java \ AltosLink.java \ AltosListenerState.java \ @@ -114,7 +116,8 @@ altoslib_JAVA = \ AltosSpeed.java \ AltosTemperature.java \ AltosAccel.java \ - AltosPyro.java + AltosPyro.java \ + AltosWriter.java JAR=altoslib_$(ALTOSLIB_VERSION).jar diff --git a/altosui/AltosCSV.java b/altosui/AltosCSV.java deleted file mode 100644 index 13f29f07..00000000 --- a/altosui/AltosCSV.java +++ /dev/null @@ -1,335 +0,0 @@ -/* - * Copyright © 2010 Keith Packard - * - * 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 altosui; - -import java.io.*; -import java.util.*; -import org.altusmetrum.altoslib_3.*; - -public class AltosCSV implements AltosWriter { - File name; - PrintStream out; - boolean header_written; - boolean seen_boost; - int boost_tick; - LinkedList pad_states; - AltosState state; - - static final int ALTOS_CSV_VERSION = 5; - - /* Version 4 format: - * - * General info - * version number - * serial number - * flight number - * callsign - * time (seconds since boost) - * clock (tick count / 100) - * rssi - * link quality - * - * Flight status - * state - * state name - * - * Basic sensors - * acceleration (m/s²) - * pressure (mBar) - * altitude (m) - * height (m) - * accelerometer speed (m/s) - * barometer speed (m/s) - * temp (°C) - * battery (V) - * drogue (V) - * main (V) - * - * Advanced sensors (if available) - * accel_x (m/s²) - * accel_y (m/s²) - * accel_z (m/s²) - * gyro_x (d/s) - * gyro_y (d/s) - * gyro_z (d/s) - * mag_x (g) - * mag_y (g) - * mag_z (g) - * - * GPS data (if available) - * connected (1/0) - * locked (1/0) - * nsat (used for solution) - * latitude (°) - * longitude (°) - * altitude (m) - * year (e.g. 2010) - * month (1-12) - * day (1-31) - * hour (0-23) - * minute (0-59) - * second (0-59) - * from_pad_dist (m) - * from_pad_azimuth (deg true) - * from_pad_range (m) - * from_pad_elevation (deg from horizon) - * hdop - * - * GPS Sat data - * C/N0 data for all 32 valid SDIDs - * - * Companion data - * companion_id (1-255. 10 is TeleScience) - * time of last companion data (seconds since boost) - * update_period (0.1-2.55 minimum telemetry interval) - * channels (0-12) - * channel data for all 12 possible channels - */ - - void write_general_header() { - out.printf("version,serial,flight,call,time,clock,rssi,lqi"); - } - - void write_general(AltosState state) { - out.printf("%s, %d, %d, %s, %8.2f, %8.2f, %4d, %3d", - ALTOS_CSV_VERSION, state.serial, state.flight, state.callsign, - (double) state.time, (double) state.tick / 100.0, - state.rssi, - state.status & 0x7f); - } - - void write_flight_header() { - out.printf("state,state_name"); - } - - void write_flight(AltosState state) { - out.printf("%d,%8s", state.state, state.state_name()); - } - - void write_basic_header() { - out.printf("acceleration,pressure,altitude,height,accel_speed,baro_speed,temperature,battery_voltage,drogue_voltage,main_voltage"); - } - - void write_basic(AltosState state) { - out.printf("%8.2f,%10.2f,%8.2f,%8.2f,%8.2f,%8.2f,%5.1f,%5.2f,%5.2f,%5.2f", - state.acceleration(), - state.pressure(), - state.altitude(), - state.height(), - state.speed(), - state.speed(), - state.temperature, - state.battery_voltage, - state.apogee_voltage, - state.main_voltage); - } - - void write_advanced_header() { - out.printf("accel_x,accel_y,accel_z,gyro_x,gyro_y,gyro_z"); - } - - void write_advanced(AltosState state) { - AltosIMU imu = state.imu; - AltosMag mag = state.mag; - - if (imu == null) - imu = new AltosIMU(); - if (mag == null) - mag = new AltosMag(); - out.printf("%6d,%6d,%6d,%6d,%6d,%6d,%6d,%6d,%6d", - imu.accel_x, imu.accel_y, imu.accel_z, - imu.gyro_x, imu.gyro_y, imu.gyro_z, - mag.x, mag.y, mag.z); - } - - void write_gps_header() { - out.printf("connected,locked,nsat,latitude,longitude,altitude,year,month,day,hour,minute,second,pad_dist,pad_range,pad_az,pad_el,hdop"); - } - - void write_gps(AltosState state) { - AltosGPS gps = state.gps; - if (gps == null) - gps = new AltosGPS(); - - AltosGreatCircle from_pad = state.from_pad; - if (from_pad == null) - from_pad = new AltosGreatCircle(); - - out.printf("%2d,%2d,%3d,%12.7f,%12.7f,%8.1f,%5d,%3d,%3d,%3d,%3d,%3d,%9.0f,%9.0f,%4.0f,%4.0f,%6.1f", - gps.connected?1:0, - gps.locked?1:0, - gps.nsat, - gps.lat, - gps.lon, - gps.alt, - gps.year, - gps.month, - gps.day, - gps.hour, - gps.minute, - gps.second, - from_pad.distance, - state.range, - from_pad.bearing, - state.elevation, - gps.hdop); - } - - void write_gps_sat_header() { - for(int i = 1; i <= 32; i++) { - out.printf("sat%02d", i); - if (i != 32) - out.printf(","); - } - } - - void write_gps_sat(AltosState state) { - AltosGPS gps = state.gps; - for(int i = 1; i <= 32; i++) { - int c_n0 = 0; - if (gps != null && gps.cc_gps_sat != null) { - for(int j = 0; j < gps.cc_gps_sat.length; j++) - if (gps.cc_gps_sat[j].svid == i) { - c_n0 = gps.cc_gps_sat[j].c_n0; - break; - } - } - out.printf ("%3d", c_n0); - if (i != 32) - out.printf(","); - } - } - - void write_companion_header() { - out.printf("companion_id,companion_time,companion_update,companion_channels"); - for (int i = 0; i < 12; i++) - out.printf(",companion_%02d", i); - } - - void write_companion(AltosState state) { - AltosCompanion companion = state.companion; - - int channels_written = 0; - if (companion == null) { - out.printf("0,0,0,0"); - } else { - out.printf("%3d,%5.2f,%5.2f,%2d", - companion.board_id, - (companion.tick - boost_tick) / 100.0, - companion.update_period / 100.0, - companion.channels); - for (; channels_written < companion.channels; channels_written++) - out.printf(",%5d", companion.companion_data[channels_written]); - } - for (; channels_written < 12; channels_written++) - out.printf(",0"); - } - - void write_header(boolean advanced, boolean gps, boolean companion) { - out.printf("#"); write_general_header(); - out.printf(","); write_flight_header(); - out.printf(","); write_basic_header(); - if (advanced) - out.printf(","); write_advanced_header(); - if (gps) { - out.printf(","); write_gps_header(); - out.printf(","); write_gps_sat_header(); - } - if (companion) { - out.printf(","); write_companion_header(); - } - out.printf ("\n"); - } - - void write_one(AltosState state) { - write_general(state); out.printf(","); - write_flight(state); out.printf(","); - write_basic(state); out.printf(","); - if (state.imu != null || state.mag != null) - write_advanced(state); - if (state.gps != null) { - out.printf(","); - write_gps(state); out.printf(","); - write_gps_sat(state); - } - if (state.companion != null) { - out.printf(","); - write_companion(state); - } - out.printf ("\n"); - } - - void flush_pad() { - while (!pad_states.isEmpty()) { - write_one (pad_states.remove()); - } - } - - public void write(AltosState state) { - if (state.state == Altos.ao_flight_startup) - return; - if (!header_written) { - write_header(state.imu != null || state.mag != null, - state.gps != null, state.companion != null); - header_written = true; - } - if (!seen_boost) { - if (state.state >= Altos.ao_flight_boost) { - seen_boost = true; - boost_tick = state.tick; - flush_pad(); - } - } - if (seen_boost) - write_one(state); - else - pad_states.add(state); - } - - public PrintStream out() { - return out; - } - - public void close() { - if (!pad_states.isEmpty()) { - boost_tick = pad_states.element().tick; - flush_pad(); - } - out.close(); - } - - public void write(AltosStateIterable states) { - states.write_comments(out()); - for (AltosState state : states) - write(state); - } - - public AltosCSV(PrintStream in_out, File in_name) { - name = in_name; - out = in_out; - pad_states = new LinkedList(); - } - - public AltosCSV(File in_name) throws FileNotFoundException { - this(new PrintStream(in_name), in_name); - } - - public AltosCSV(String in_string) throws FileNotFoundException { - this(new File(in_string)); - } -} diff --git a/altosui/AltosKML.java b/altosui/AltosKML.java deleted file mode 100644 index ae1f8259..00000000 --- a/altosui/AltosKML.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright © 2010 Keith Packard - * - * 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 altosui; - -import java.io.*; -import org.altusmetrum.altoslib_3.*; - -public class AltosKML implements AltosWriter { - - File name; - PrintStream out; - int flight_state = -1; - AltosState prev = null; - double gps_start_altitude; - - static final String[] kml_state_colors = { - "FF000000", - "FF000000", - "FF000000", - "FF0000FF", - "FF4080FF", - "FF00FFFF", - "FFFF0000", - "FF00FF00", - "FF000000", - "FFFFFFFF" - }; - - static final String kml_header_start = - "\n" + - "\n" + - "\n" + - " AO Flight#%d S/N: %03d\n" + - " \n"; - static final String kml_header_end = - " \n" + - " 0\n"; - - static final String kml_style_start = - " \n"; - - static final String kml_placemark_start = - " \n" + - " %s\n" + - " #ao-flightstate-%s\n" + - " \n" + - " 1\n" + - " absolute\n" + - " \n"; - - static final String kml_coord_fmt = - " %.7f,%.7f,%.7f \n"; - - static final String kml_placemark_end = - " \n" + - " \n" + - " \n"; - - static final String kml_footer = - "\n" + - "\n"; - - void start (AltosState record) { - out.printf(kml_header_start, record.flight, record.serial); - out.printf("Date: %04d-%02d-%02d\n", - record.gps.year, record.gps.month, record.gps.day); - out.printf("Time: %2d:%02d:%02d\n", - record.gps.hour, record.gps.minute, record.gps.second); - out.printf("%s", kml_header_end); - } - - boolean started = false; - - void state_start(AltosState state) { - String state_name = Altos.state_name(state.state); - out.printf(kml_style_start, state_name, kml_state_colors[state.state]); - out.printf("\tState: %s\n", state_name); - out.printf("%s", kml_style_end); - out.printf(kml_placemark_start, state_name, state_name); - } - - void state_end(AltosState state) { - out.printf("%s", kml_placemark_end); - } - - void coord(AltosState state) { - AltosGPS gps = state.gps; - double altitude; - - if (state.height() != AltosLib.MISSING) - altitude = state.height() + gps_start_altitude; - else - altitude = gps.alt; - out.printf(kml_coord_fmt, - gps.lon, gps.lat, - altitude, (double) gps.alt, - state.time, gps.nsat); - } - - void end() { - out.printf("%s", kml_footer); - } - - public void close() { - if (prev != null) { - state_end(prev); - end(); - prev = null; - } - } - - public void write(AltosState state) { - AltosGPS gps = state.gps; - - if (gps == null) - return; - - if (gps.lat == AltosLib.MISSING) - return; - if (gps.lon == AltosLib.MISSING) - return; - if (!started) { - start(state); - started = true; - gps_start_altitude = gps.alt; - } - if (prev != null && prev.gps_sequence == state.gps_sequence) - return; - if (state.state != flight_state) { - flight_state = state.state; - if (prev != null) { - coord(state); - state_end(prev); - } - state_start(state); - } - coord(state); - prev = state; - } - - public void write(AltosStateIterable states) { - for (AltosState state : states) { - if ((state.set & AltosState.set_gps) != 0) - write(state); - } - } - - public AltosKML(File in_name) throws FileNotFoundException { - name = in_name; - out = new PrintStream(name); - } - - public AltosKML(String in_string) throws FileNotFoundException { - this(new File(in_string)); - } -} diff --git a/altosui/AltosWriter.java b/altosui/AltosWriter.java deleted file mode 100644 index 5ff44584..00000000 --- a/altosui/AltosWriter.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright © 2010 Keith Packard - * - * 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 altosui; - -import org.altusmetrum.altoslib_3.*; - - -public interface AltosWriter { - - public void write(AltosState state); - - public void write(AltosStateIterable states); - - public void close(); -} diff --git a/altosui/Makefile.am b/altosui/Makefile.am index 3a2a1863..76fe9961 100644 --- a/altosui/Makefile.am +++ b/altosui/Makefile.am @@ -28,7 +28,6 @@ altosui_JAVA = \ AltosConfigureUI.java \ AltosConfigTD.java \ AltosConfigTDUI.java \ - AltosCSV.java \ AltosCSVUI.java \ AltosDescent.java \ AltosDeviceUIDialog.java \ @@ -53,7 +52,6 @@ altosui_JAVA = \ AltosLaunch.java \ AltosLaunchUI.java \ AltosInfoTable.java \ - AltosKML.java \ AltosLanded.java \ AltosLed.java \ AltosLights.java \ @@ -68,7 +66,6 @@ altosui_JAVA = \ AltosSiteMapCache.java \ AltosSiteMapTile.java \ AltosUI.java \ - AltosWriter.java \ AltosGraph.java \ AltosGraphDataPoint.java \ AltosGraphDataSet.java \ -- cgit v1.2.3 From 0a6c76fc0525d6588a1d88127f0085f13a02f1af Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 25 May 2014 20:55:11 -0700 Subject: altosui/altosuilib/altoslib: Move more stuff out of autosui. Reduce site map memory Prepare to share with TeleGPS application. This also has the changes to the site map tile which cache only a few images and regenerate the flight path on the fly, saving piles of memory Signed-off-by: Keith Packard --- altoslib/AltosFlightStats.java | 188 ++++++++++++++ altoslib/Makefile.am | 3 +- altosui/AltosDisplayThread.java | 259 ------------------- altosui/AltosFlightDisplay.java | 28 --- altosui/AltosFlightStats.java | 189 -------------- altosui/AltosFreqList.java | 86 ------- altosui/AltosSiteMap.java | 476 ----------------------------------- altosui/AltosSiteMapCache.java | 119 --------- altosui/AltosSiteMapPreload.java | 467 ---------------------------------- altosui/AltosSiteMapTile.java | 122 --------- altosui/AltosVoice.java | 95 ------- altosui/GrabNDrag.java | 48 ---- altosui/Makefile.am | 12 +- altosuilib/AltosDisplayThread.java | 259 +++++++++++++++++++ altosuilib/AltosFlightDisplay.java | 28 +++ altosuilib/AltosFreqList.java | 85 +++++++ altosuilib/AltosSiteMap.java | 484 ++++++++++++++++++++++++++++++++++++ altosuilib/AltosSiteMapCache.java | 194 +++++++++++++++ altosuilib/AltosSiteMapPreload.java | 467 ++++++++++++++++++++++++++++++++++ altosuilib/AltosSiteMapTile.java | 142 +++++++++++ altosuilib/AltosVoice.java | 94 +++++++ altosuilib/GrabNDrag.java | 48 ++++ altosuilib/Makefile.am | 13 +- 23 files changed, 2003 insertions(+), 1903 deletions(-) create mode 100644 altoslib/AltosFlightStats.java delete mode 100644 altosui/AltosDisplayThread.java delete mode 100644 altosui/AltosFlightDisplay.java delete mode 100644 altosui/AltosFlightStats.java delete mode 100644 altosui/AltosFreqList.java delete mode 100644 altosui/AltosSiteMap.java delete mode 100644 altosui/AltosSiteMapCache.java delete mode 100644 altosui/AltosSiteMapPreload.java delete mode 100644 altosui/AltosSiteMapTile.java delete mode 100644 altosui/AltosVoice.java delete mode 100644 altosui/GrabNDrag.java create mode 100644 altosuilib/AltosDisplayThread.java create mode 100644 altosuilib/AltosFlightDisplay.java create mode 100644 altosuilib/AltosFreqList.java create mode 100644 altosuilib/AltosSiteMap.java create mode 100644 altosuilib/AltosSiteMapCache.java create mode 100644 altosuilib/AltosSiteMapPreload.java create mode 100644 altosuilib/AltosSiteMapTile.java create mode 100644 altosuilib/AltosVoice.java create mode 100644 altosuilib/GrabNDrag.java (limited to 'altoslib') diff --git a/altoslib/AltosFlightStats.java b/altoslib/AltosFlightStats.java new file mode 100644 index 00000000..87e04293 --- /dev/null +++ b/altoslib/AltosFlightStats.java @@ -0,0 +1,188 @@ +/* + * Copyright © 2011 Keith Packard + * + * 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_4; + +import java.io.*; + +public class AltosFlightStats { + public double max_height; + public double max_gps_height; + public double max_speed; + public double max_acceleration; + public double[] state_speed = new double[AltosLib.ao_flight_invalid + 1]; + public double[] state_accel = new double[AltosLib.ao_flight_invalid + 1]; + public int[] state_count = new int[AltosLib.ao_flight_invalid + 1]; + public double[] state_start = new double[AltosLib.ao_flight_invalid + 1]; + public double[] state_end = new double[AltosLib.ao_flight_invalid + 1]; + public int serial; + public int flight; + public int year, month, day; + public int hour, minute, second; + public double lat, lon; + public double pad_lat, pad_lon; + public boolean has_gps; + public boolean has_other_adc; + public boolean has_rssi; + public boolean has_imu; + public boolean has_mag; + public boolean has_orient; + public int num_ignitor; + + double landed_time(AltosStateIterable states) { + AltosState state = null; + + for (AltosState s : states) { + state = s; + if (state.state == AltosLib.ao_flight_landed) + break; + } + + if (state == null) + return 0; + + double landed_height = state.height(); + + state = null; + + boolean above = true; + + double landed_time = -1000; + + for (AltosState s : states) { + state = s; + + if (state.height() > landed_height + 10) { + above = true; + } else { + if (above && state.height() < landed_height + 2) { + above = false; + landed_time = state.time; + } + } + } + if (landed_time == -1000) + landed_time = state.time; + return landed_time; + } + + double boost_time(AltosStateIterable states) { + double boost_time = AltosLib.MISSING; + AltosState state = null; + + for (AltosState s : states) { + state = s; + if (state.acceleration() < 1) + boost_time = state.time; + if (state.state >= AltosLib.ao_flight_boost && state.state <= AltosLib.ao_flight_landed) + break; + } + if (state == null) + return 0; + + if (boost_time == AltosLib.MISSING) + boost_time = state.time; + return boost_time; + } + + + public AltosFlightStats(AltosStateIterable states) throws InterruptedException, IOException { + double boost_time = boost_time(states); + double end_time = 0; + double landed_time = landed_time(states); + + year = month = day = AltosLib.MISSING; + hour = minute = second = AltosLib.MISSING; + serial = flight = AltosLib.MISSING; + lat = lon = AltosLib.MISSING; + has_gps = false; + has_other_adc = false; + has_rssi = false; + has_imu = false; + has_mag = false; + has_orient = false; + for (AltosState state : states) { + if (serial == AltosLib.MISSING && state.serial != AltosLib.MISSING) + serial = state.serial; + if (flight == AltosLib.MISSING && state.flight != AltosLib.MISSING) + flight = state.flight; + if (state.battery_voltage != AltosLib.MISSING) + has_other_adc = true; + if (state.rssi != AltosLib.MISSING) + has_rssi = true; + end_time = state.time; + + int state_id = state.state; + if (state.time >= boost_time && state_id < AltosLib.ao_flight_boost) + state_id = AltosLib.ao_flight_boost; + if (state.time >= landed_time && state_id < AltosLib.ao_flight_landed) + state_id = AltosLib.ao_flight_landed; + if (state.gps != null && state.gps.locked) { + year = state.gps.year; + month = state.gps.month; + day = state.gps.day; + hour = state.gps.hour; + minute = state.gps.minute; + second = state.gps.second; + } + if (0 <= state_id && state_id < AltosLib.ao_flight_invalid) { + double acceleration = state.acceleration(); + double speed = state.speed(); + if (acceleration != AltosLib.MISSING && speed != AltosLib.MISSING) { + state_accel[state_id] += acceleration; + state_speed[state_id] += speed; + state_count[state_id]++; + } + if (state_start[state_id] == 0.0) + state_start[state_id] = state.time; + if (state_end[state_id] < state.time) + state_end[state_id] = state.time; + max_height = state.max_height(); + max_speed = state.max_speed(); + max_acceleration = state.max_acceleration(); + max_gps_height = state.max_gps_height(); + } + if (state.gps != null && state.gps.locked && state.gps.nsat >= 4) { + if (state_id <= AltosLib.ao_flight_pad) { + pad_lat = state.gps.lat; + pad_lon = state.gps.lon; + } + lat = state.gps.lat; + lon = state.gps.lon; + has_gps = true; + } + if (state.imu != null) + has_imu = true; + if (state.mag != null) + has_mag = true; + if (state.orient() != AltosLib.MISSING) + has_orient = true; + if (state.ignitor_voltage != null && state.ignitor_voltage.length > num_ignitor) + num_ignitor = state.ignitor_voltage.length; + } + for (int s = AltosLib.ao_flight_startup; s <= AltosLib.ao_flight_landed; s++) { + if (state_count[s] > 0) { + state_speed[s] /= state_count[s]; + state_accel[s] /= state_count[s]; + } + if (state_start[s] == 0) + state_start[s] = end_time; + if (state_end[s] == 0) + state_end[s] = end_time; + } + } +} diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am index 67cc38ff..bff09704 100644 --- a/altoslib/Makefile.am +++ b/altoslib/Makefile.am @@ -1,4 +1,4 @@ -AM_JAVACFLAGS=-target 1.6 -encoding UTF-8 -Xlint:deprecation -source 6 +AM_JAVACFLAGS=-target 1.6 -encoding UTF-8 -Xlint:deprecation -Xlint:unchecked -source 6 JAVAROOT=bin @@ -51,6 +51,7 @@ altoslib_JAVA = \ AltosFlash.java \ AltosFlashListener.java \ AltosFlightReader.java \ + AltosFlightStats.java \ AltosFrequency.java \ AltosGPS.java \ AltosGPSSat.java \ diff --git a/altosui/AltosDisplayThread.java b/altosui/AltosDisplayThread.java deleted file mode 100644 index ab85607d..00000000 --- a/altosui/AltosDisplayThread.java +++ /dev/null @@ -1,259 +0,0 @@ -/* - * Copyright © 2010 Keith Packard - * - * 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 altosui; - -import java.awt.*; -import javax.swing.*; -import java.io.*; -import java.text.*; -import org.altusmetrum.altoslib_3.*; - -public class AltosDisplayThread extends Thread { - - Frame parent; - IdleThread idle_thread; - AltosVoice voice; - AltosFlightReader reader; - AltosState old_state, state; - AltosListenerState listener_state; - AltosFlightDisplay display; - - synchronized void show_safely() { - final AltosState my_state = state; - final AltosListenerState my_listener_state = listener_state; - Runnable r = new Runnable() { - public void run() { - try { - display.show(my_state, my_listener_state); - } catch (Exception ex) { - } - } - }; - SwingUtilities.invokeLater(r); - } - - void reading_error_internal() { - JOptionPane.showMessageDialog(parent, - String.format("Error reading from \"%s\"", reader.name), - "Telemetry Read Error", - JOptionPane.ERROR_MESSAGE); - } - - void reading_error_safely() { - Runnable r = new Runnable() { - public void run() { - try { - reading_error_internal(); - } catch (Exception ex) { - } - } - }; - SwingUtilities.invokeLater(r); - } - - class IdleThread extends Thread { - - boolean started; - int reported_landing; - int report_interval; - long report_time; - - public synchronized void report(boolean last) { - if (state == null) - return; - - /* reset the landing count once we hear about a new flight */ - if (state.state < Altos.ao_flight_drogue) - reported_landing = 0; - - /* Shut up once the rocket is on the ground */ - if (reported_landing > 2) { - return; - } - - /* If the rocket isn't on the pad, then report height */ - if (Altos.ao_flight_drogue <= state.state && - state.state < Altos.ao_flight_landed && - state.from_pad != null && - state.range >= 0) - { - voice.speak("Height %s, bearing %s %d, elevation %d, range %s.\n", - AltosConvert.height.say(state.height()), - state.from_pad.bearing_words( - AltosGreatCircle.BEARING_VOICE), - (int) (state.from_pad.bearing + 0.5), - (int) (state.elevation + 0.5), - AltosConvert.distance.say(state.range)); - } else if (state.state > Altos.ao_flight_pad) { - voice.speak(AltosConvert.height.say_units(state.height())); - } else { - reported_landing = 0; - } - - /* If the rocket is coming down, check to see if it has landed; - * either we've got a landed report or we haven't heard from it in - * a long time - */ - if (state.state >= Altos.ao_flight_drogue && - (last || - System.currentTimeMillis() - state.received_time >= 15000 || - state.state == Altos.ao_flight_landed)) - { - if (Math.abs(state.speed()) < 20 && state.height() < 100) - voice.speak("rocket landed safely"); - else - voice.speak("rocket may have crashed"); - if (state.from_pad != null) - voice.speak("Bearing %d degrees, range %s.", - (int) (state.from_pad.bearing + 0.5), - AltosConvert.distance.say_units(state.from_pad.distance)); - ++reported_landing; - if (state.state != Altos.ao_flight_landed) { - state.state = Altos.ao_flight_landed; - show_safely(); - } - } - } - - long now () { - return System.currentTimeMillis(); - } - - void set_report_time() { - report_time = now() + report_interval; - } - - public void run () { - try { - for (;;) { - if (reader.has_monitor_battery()) { - listener_state.battery = reader.monitor_battery(); - show_safely(); - } - set_report_time(); - for (;;) { - voice.drain(); - synchronized (this) { - long sleep_time = report_time - now(); - if (sleep_time <= 0) - break; - wait(sleep_time); - } - } - - report(false); - } - } catch (InterruptedException ie) { - try { - voice.drain(); - } catch (InterruptedException iie) { } - } - } - - public synchronized void notice(boolean spoken) { - if (old_state != null && old_state.state != state.state) { - report_time = now(); - this.notify(); - } else if (spoken) - set_report_time(); - } - - public IdleThread() { - reported_landing = 0; - report_interval = 10000; - } - } - - synchronized boolean tell() { - boolean ret = false; - if (old_state == null || old_state.state != state.state) { - voice.speak(state.state_name()); - if ((old_state == null || old_state.state <= Altos.ao_flight_boost) && - state.state > Altos.ao_flight_boost) { - voice.speak("max speed: %s.", - AltosConvert.speed.say_units(state.max_speed() + 0.5)); - ret = true; - } else if ((old_state == null || old_state.state < Altos.ao_flight_drogue) && - state.state >= Altos.ao_flight_drogue) { - voice.speak("max height: %s.", - AltosConvert.height.say_units(state.max_height() + 0.5)); - ret = true; - } - } - if (old_state == null || old_state.gps_ready != state.gps_ready) { - if (state.gps_ready) { - voice.speak("GPS ready"); - ret = true; - } - else if (old_state != null) { - voice.speak("GPS lost"); - ret = true; - } - } - old_state = state; - return ret; - } - - public void run() { - boolean interrupted = false; - boolean told; - - idle_thread = new IdleThread(); - idle_thread.start(); - - try { - for (;;) { - try { - state = reader.read(); - if (state == null) - break; - reader.update(state); - show_safely(); - told = tell(); - idle_thread.notice(told); - } catch (ParseException pp) { - System.out.printf("Parse error: %d \"%s\"\n", pp.getErrorOffset(), pp.getMessage()); - } catch (AltosCRCException ce) { - ++listener_state.crc_errors; - show_safely(); - } - } - } catch (InterruptedException ee) { - interrupted = true; - } catch (IOException ie) { - reading_error_safely(); - } finally { - if (!interrupted) - idle_thread.report(true); - reader.close(interrupted); - idle_thread.interrupt(); - try { - idle_thread.join(); - } catch (InterruptedException ie) {} - } - } - - public AltosDisplayThread(Frame in_parent, AltosVoice in_voice, AltosFlightDisplay in_display, AltosFlightReader in_reader) { - listener_state = new AltosListenerState(); - parent = in_parent; - voice = in_voice; - display = in_display; - reader = in_reader; - display.reset(); - } -} diff --git a/altosui/AltosFlightDisplay.java b/altosui/AltosFlightDisplay.java deleted file mode 100644 index c1264259..00000000 --- a/altosui/AltosFlightDisplay.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright © 2010 Keith Packard - * - * 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 altosui; - -import org.altusmetrum.altoslib_3.*; - -public interface AltosFlightDisplay { - void reset(); - - void show(AltosState state, AltosListenerState listener_state); - - void set_font(); -} diff --git a/altosui/AltosFlightStats.java b/altosui/AltosFlightStats.java deleted file mode 100644 index d02a518d..00000000 --- a/altosui/AltosFlightStats.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright © 2011 Keith Packard - * - * 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 altosui; - -import java.io.*; -import org.altusmetrum.altoslib_3.*; - -public class AltosFlightStats { - double max_height; - double max_gps_height; - double max_speed; - double max_acceleration; - double[] state_speed = new double[Altos.ao_flight_invalid + 1]; - double[] state_accel = new double[Altos.ao_flight_invalid + 1]; - int[] state_count = new int[Altos.ao_flight_invalid + 1]; - double[] state_start = new double[Altos.ao_flight_invalid + 1]; - double[] state_end = new double[Altos.ao_flight_invalid + 1]; - int serial; - int flight; - int year, month, day; - int hour, minute, second; - double lat, lon; - double pad_lat, pad_lon; - boolean has_gps; - boolean has_other_adc; - boolean has_rssi; - boolean has_imu; - boolean has_mag; - boolean has_orient; - int num_ignitor; - - double landed_time(AltosStateIterable states) { - AltosState state = null; - - for (AltosState s : states) { - state = s; - if (state.state == Altos.ao_flight_landed) - break; - } - - if (state == null) - return 0; - - double landed_height = state.height(); - - state = null; - - boolean above = true; - - double landed_time = -1000; - - for (AltosState s : states) { - state = s; - - if (state.height() > landed_height + 10) { - above = true; - } else { - if (above && state.height() < landed_height + 2) { - above = false; - landed_time = state.time; - } - } - } - if (landed_time == -1000) - landed_time = state.time; - return landed_time; - } - - double boost_time(AltosStateIterable states) { - double boost_time = AltosLib.MISSING; - AltosState state = null; - - for (AltosState s : states) { - state = s; - if (state.acceleration() < 1) - boost_time = state.time; - if (state.state >= AltosLib.ao_flight_boost && state.state <= AltosLib.ao_flight_landed) - break; - } - if (state == null) - return 0; - - if (boost_time == AltosLib.MISSING) - boost_time = state.time; - return boost_time; - } - - - public AltosFlightStats(AltosStateIterable states) throws InterruptedException, IOException { - double boost_time = boost_time(states); - double end_time = 0; - double landed_time = landed_time(states); - - year = month = day = AltosLib.MISSING; - hour = minute = second = AltosLib.MISSING; - serial = flight = AltosLib.MISSING; - lat = lon = AltosLib.MISSING; - has_gps = false; - has_other_adc = false; - has_rssi = false; - has_imu = false; - has_mag = false; - has_orient = false; - for (AltosState state : states) { - if (serial == AltosLib.MISSING && state.serial != AltosLib.MISSING) - serial = state.serial; - if (flight == AltosLib.MISSING && state.flight != AltosLib.MISSING) - flight = state.flight; - if (state.battery_voltage != AltosLib.MISSING) - has_other_adc = true; - if (state.rssi != AltosLib.MISSING) - has_rssi = true; - end_time = state.time; - - int state_id = state.state; - if (state.time >= boost_time && state_id < Altos.ao_flight_boost) - state_id = Altos.ao_flight_boost; - if (state.time >= landed_time && state_id < Altos.ao_flight_landed) - state_id = Altos.ao_flight_landed; - if (state.gps != null && state.gps.locked) { - year = state.gps.year; - month = state.gps.month; - day = state.gps.day; - hour = state.gps.hour; - minute = state.gps.minute; - second = state.gps.second; - } - if (0 <= state_id && state_id < Altos.ao_flight_invalid) { - double acceleration = state.acceleration(); - double speed = state.speed(); - if (acceleration != AltosLib.MISSING && speed != AltosLib.MISSING) { - state_accel[state_id] += acceleration; - state_speed[state_id] += speed; - state_count[state_id]++; - } - if (state_start[state_id] == 0.0) - state_start[state_id] = state.time; - if (state_end[state_id] < state.time) - state_end[state_id] = state.time; - max_height = state.max_height(); - max_speed = state.max_speed(); - max_acceleration = state.max_acceleration(); - max_gps_height = state.max_gps_height(); - } - if (state.gps != null && state.gps.locked && state.gps.nsat >= 4) { - if (state_id <= Altos.ao_flight_pad) { - pad_lat = state.gps.lat; - pad_lon = state.gps.lon; - } - lat = state.gps.lat; - lon = state.gps.lon; - has_gps = true; - } - if (state.imu != null) - has_imu = true; - if (state.mag != null) - has_mag = true; - if (state.orient() != AltosLib.MISSING) - has_orient = true; - if (state.ignitor_voltage != null && state.ignitor_voltage.length > num_ignitor) - num_ignitor = state.ignitor_voltage.length; - } - for (int s = Altos.ao_flight_startup; s <= Altos.ao_flight_landed; s++) { - if (state_count[s] > 0) { - state_speed[s] /= state_count[s]; - state_accel[s] /= state_count[s]; - } - if (state_start[s] == 0) - state_start[s] = end_time; - if (state_end[s] == 0) - state_end[s] = end_time; - } - } -} diff --git a/altosui/AltosFreqList.java b/altosui/AltosFreqList.java deleted file mode 100644 index 525e5ce5..00000000 --- a/altosui/AltosFreqList.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright © 2011 Keith Packard - * - * 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 altosui; - -import javax.swing.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; - -public class AltosFreqList extends JComboBox { - - String product; - int serial; - int calibrate; - - public void set_frequency(double new_frequency) { - int i; - - if (new_frequency < 0) { - setVisible(false); - return; - } - - for (i = 0; i < getItemCount(); i++) { - AltosFrequency f = (AltosFrequency) getItemAt(i); - - if (f.close(new_frequency)) { - setSelectedIndex(i); - return; - } - } - for (i = 0; i < getItemCount(); i++) { - AltosFrequency f = (AltosFrequency) getItemAt(i); - - if (new_frequency < f.frequency) - break; - } - String description = String.format("%s serial %d", product, serial); - AltosFrequency frequency = new AltosFrequency(new_frequency, description); - AltosUIPreferences.add_common_frequency(frequency); - insertItemAt(frequency, i); - setMaximumRowCount(getItemCount()); - } - - public void set_product(String new_product) { - product = new_product; - } - - public void set_serial(int new_serial) { - serial = new_serial; - } - - public double frequency() { - AltosFrequency f = (AltosFrequency) getSelectedItem(); - if (f != null) - return f.frequency; - return 434.550; - } - - public AltosFreqList () { - super(AltosUIPreferences.common_frequencies()); - setMaximumRowCount(getItemCount()); - setEditable(false); - product = "Unknown"; - serial = 0; - } - - public AltosFreqList(double in_frequency) { - this(); - set_frequency(in_frequency); - } -} diff --git a/altosui/AltosSiteMap.java b/altosui/AltosSiteMap.java deleted file mode 100644 index 643417b5..00000000 --- a/altosui/AltosSiteMap.java +++ /dev/null @@ -1,476 +0,0 @@ -/* - * Copyright © 2010 Anthony Towns - * - * 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 altosui; - -import java.awt.*; -import javax.swing.*; -import java.io.*; -import java.lang.Math; -import java.awt.geom.Point2D; -import java.util.concurrent.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; - -public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay { - // preferred vertical step in a tile in naut. miles - // will actually choose a step size between x and 2x, where this - // is 1.5x - static final double tile_size_nmi = 0.75; - - static final int px_size = 512; - - static final int MAX_TILE_DELTA = 100; - - private static Point2D.Double translatePoint(Point2D.Double p, - Point2D.Double d) - { - return new Point2D.Double(p.x + d.x, p.y + d.y); - } - - static class LatLng { - public double lat, lng; - public LatLng(double lat, double lng) { - this.lat = lat; - this.lng = lng; - } - } - - // based on google js - // http://maps.gstatic.com/intl/en_us/mapfiles/api-3/2/10/main.js - // search for fromLatLngToPoint and fromPointToLatLng - /* - private static Point2D.Double pt(LatLng latlng, int zoom) { - double scale_x = 256/360.0 * Math.pow(2, zoom); - double scale_y = 256/(2.0*Math.PI) * Math.pow(2, zoom); - return pt(latlng, scale_x, scale_y); - } - */ - - private static Point2D.Double pt(LatLng latlng, - double scale_x, double scale_y) - { - Point2D.Double res = new Point2D.Double(); - double e; - - res.x = latlng.lng * scale_x; - - e = Math.sin(Math.toRadians(latlng.lat)); - e = Math.max(e,-(1-1.0E-15)); - e = Math.min(e, 1-1.0E-15 ); - - res.y = 0.5*Math.log((1+e)/(1-e))*-scale_y; - return res; - } - - static private LatLng latlng(Point2D.Double pt, - double scale_x, double scale_y) - { - double lat, lng; - double rads; - - lng = pt.x/scale_x; - rads = 2 * Math.atan(Math.exp(-pt.y/scale_y)); - lat = Math.toDegrees(rads - Math.PI/2); - - return new LatLng(lat,lng); - } - - int zoom; - double scale_x, scale_y; - - int radius; /* half width/height of tiles to load */ - - private Point2D.Double pt(double lat, double lng) { - return pt(new LatLng(lat, lng), scale_x, scale_y); - } - - private LatLng latlng(double x, double y) { - return latlng(new Point2D.Double(x,y), scale_x, scale_y); - } - /* - private LatLng latlng(Point2D.Double pt) { - return latlng(pt, scale_x, scale_y); - } - */ - - ConcurrentHashMap mapTiles = new ConcurrentHashMap(); - Point2D.Double centre; - - private Point2D.Double tileCoordOffset(Point p) { - return new Point2D.Double(centre.x - p.x*px_size, - centre.y - p.y * px_size); - } - - private Point tileOffset(Point2D.Double p) { - return new Point((int)Math.floor((centre.x+p.x)/px_size), - (int)Math.floor((centre.y+p.y)/px_size)); - } - - private Point2D.Double getBaseLocation(double lat, double lng) { - Point2D.Double locn, north_step; - - zoom = 2; - // stupid loop structure to please Java's control flow analysis - do { - zoom++; - scale_x = 256/360.0 * Math.pow(2, zoom); - scale_y = 256/(2.0*Math.PI) * Math.pow(2, zoom); - locn = pt(lat, lng); - north_step = pt(lat+tile_size_nmi*4/3/60.0, lng); - if (locn.y - north_step.y > px_size) - break; - } while (zoom < 22); - locn.x = -px_size * Math.floor(locn.x/px_size); - locn.y = -px_size * Math.floor(locn.y/px_size); - return locn; - } - - public void reset() { - // nothing - } - - public void set_font() { - // nothing - } - - private void loadMap(final AltosSiteMapTile tile, - File pngfile, String pngurl) - { - final ImageIcon res = AltosSiteMapCache.fetchAndLoadMap(pngfile, pngurl); - if (res != null) { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - tile.loadMap(res); - } - }); - } else { - System.out.printf("# Failed to fetch file %s\n", pngfile); - System.out.printf(" wget -O '%s' '%s'\n", pngfile, pngurl); - } - } - - File pngfile; - String pngurl; - - public int prefetchMap(int x, int y) { - LatLng map_latlng = latlng( - -centre.x + x*px_size + px_size/2, - -centre.y + y*px_size + px_size/2); - pngfile = MapFile(map_latlng.lat, map_latlng.lng, zoom); - pngurl = MapURL(map_latlng.lat, map_latlng.lng, zoom); - if (pngfile.exists()) { - return 1; - } else if (AltosSiteMapCache.fetchMap(pngfile, pngurl)) { - return 0; - } else { - return -1; - } - } - - public static void prefetchMaps(double lat, double lng) { - int w = AltosSiteMapPreload.width; - int h = AltosSiteMapPreload.height; - AltosSiteMap asm = new AltosSiteMap(true); - asm.centre = asm.getBaseLocation(lat, lng); - - //Point2D.Double p = new Point2D.Double(); - //Point2D.Double p2; - int dx = -w/2, dy = -h/2; - for (int y = dy; y < h+dy; y++) { - for (int x = dx; x < w+dx; x++) { - int r = asm.prefetchMap(x, y); - switch (r) { - case 1: - System.out.printf("Already have %s\n", asm.pngfile); - break; - case 0: - System.out.printf("Fetched map %s\n", asm.pngfile); - break; - case -1: - System.out.printf("# Failed to fetch file %s\n", asm.pngfile); - System.out.printf(" wget -O '%s' ''\n", asm.pngfile, asm.pngurl); - break; - } - } - } - } - - public String initMap(Point offset) { - AltosSiteMapTile tile = mapTiles.get(offset); - Point2D.Double coord = tileCoordOffset(offset); - - LatLng map_latlng = latlng(px_size/2-coord.x, px_size/2-coord.y); - - File pngfile = MapFile(map_latlng.lat, map_latlng.lng, zoom); - String pngurl = MapURL(map_latlng.lat, map_latlng.lng, zoom); - loadMap(tile, pngfile, pngurl); - return pngfile.toString(); - } - - public void initAndFinishMapAsync (final AltosSiteMapTile tile, final Point offset) { - Thread thread = new Thread() { - public void run() { - initMap(offset); - finishTileLater(tile, offset); - } - }; - thread.start(); - } - - public void setBaseLocation(double lat, double lng) { - for (Point k : mapTiles.keySet()) { - AltosSiteMapTile tile = mapTiles.get(k); - tile.clearMap(); - } - - centre = getBaseLocation(lat, lng); - scrollRocketToVisible(pt(lat,lng)); - } - - private void initMaps(double lat, double lng) { - setBaseLocation(lat, lng); - - Thread thread = new Thread() { - public void run() { - for (Point k : mapTiles.keySet()) - initMap(k); - } - }; - thread.start(); - } - - private static File MapFile(double lat, double lng, int zoom) { - char chlat = lat < 0 ? 'S' : 'N'; - char chlng = lng < 0 ? 'W' : 'E'; - if (lat < 0) lat = -lat; - if (lng < 0) lng = -lng; - return new File(AltosUIPreferences.mapdir(), - String.format("map-%c%.6f,%c%.6f-%d.png", - chlat, lat, chlng, lng, zoom)); - } - - private static String MapURL(double lat, double lng, int zoom) { - return String.format("http://maps.google.com/maps/api/staticmap?center=%.6f,%.6f&zoom=%d&size=%dx%d&sensor=false&maptype=hybrid&format=png32", lat, lng, zoom, px_size, px_size); - } - - boolean initialised = false; - Point2D.Double last_pt = null; - int last_state = -1; - - public void show(double lat, double lon) { - System.out.printf ("show %g %g\n", lat, lon); - return; -// initMaps(lat, lon); -// scrollRocketToVisible(pt(lat, lon)); - } - public void show(final AltosState state, final AltosListenerState listener_state) { - // if insufficient gps data, nothing to update - AltosGPS gps = state.gps; - - if (gps == null) - return; - - if (!gps.locked && gps.nsat < 4) - return; - - if (!initialised) { - if (state.pad_lat != AltosLib.MISSING && state.pad_lon != AltosLib.MISSING) { - initMaps(state.pad_lat, state.pad_lon); - initialised = true; - } else if (gps.lat != AltosLib.MISSING && gps.lon != AltosLib.MISSING) { - initMaps(gps.lat, gps.lon); - initialised = true; - } else { - return; - } - } - - final Point2D.Double pt = pt(gps.lat, gps.lon); - if (last_pt == pt && last_state == state.state) - return; - - if (last_pt == null) { - last_pt = pt; - } - boolean in_any = false; - for (Point offset : mapTiles.keySet()) { - AltosSiteMapTile tile = mapTiles.get(offset); - Point2D.Double ref, lref; - ref = translatePoint(pt, tileCoordOffset(offset)); - lref = translatePoint(last_pt, tileCoordOffset(offset)); - tile.show(state, listener_state, lref, ref); - if (0 <= ref.x && ref.x < px_size) - if (0 <= ref.y && ref.y < px_size) - in_any = true; - } - - Point offset = tileOffset(pt); - if (!in_any) { - Point2D.Double ref, lref; - ref = translatePoint(pt, tileCoordOffset(offset)); - lref = translatePoint(last_pt, tileCoordOffset(offset)); - - AltosSiteMapTile tile = createTile(offset); - tile.show(state, listener_state, lref, ref); - initAndFinishMapAsync(tile, offset); - } - - scrollRocketToVisible(pt); - - if (offset != tileOffset(last_pt)) { - ensureTilesAround(offset); - } - - last_pt = pt; - last_state = state.state; - } - - public void centre(Point2D.Double pt) { - Rectangle r = comp.getVisibleRect(); - Point2D.Double copt = translatePoint(pt, tileCoordOffset(topleft)); - int dx = (int)copt.x - r.width/2 - r.x; - int dy = (int)copt.y - r.height/2 - r.y; - r.x += dx; - r.y += dy; - comp.scrollRectToVisible(r); - } - - public void centre(AltosState state) { - if (!state.gps.locked && state.gps.nsat < 4) - return; - centre(pt(state.gps.lat, state.gps.lon)); - } - - public void draw_circle(double lat, double lon) { - final Point2D.Double pt = pt(lat, lon); - - for (Point offset : mapTiles.keySet()) { - AltosSiteMapTile tile = mapTiles.get(offset); - Point2D.Double ref = translatePoint(pt, tileCoordOffset(offset)); - tile.draw_circle(ref); - } - } - - private AltosSiteMapTile createTile(Point offset) { - AltosSiteMapTile tile = new AltosSiteMapTile(px_size); - mapTiles.put(offset, tile); - return tile; - } - private void finishTileLater(final AltosSiteMapTile tile, - final Point offset) - { - SwingUtilities.invokeLater( new Runnable() { - public void run() { - addTileAt(tile, offset); - } - } ); - } - - private void ensureTilesAround(Point base_offset) { - for (int x = -radius; x <= radius; x++) { - for (int y = -radius; y <= radius; y++) { - Point offset = new Point(base_offset.x + x, base_offset.y + y); - if (mapTiles.containsKey(offset)) - continue; - AltosSiteMapTile tile = createTile(offset); - initAndFinishMapAsync(tile, offset); - } - } - } - - private Point topleft = new Point(0,0); - private void scrollRocketToVisible(Point2D.Double pt) { - Rectangle r = comp.getVisibleRect(); - Point2D.Double copt = translatePoint(pt, tileCoordOffset(topleft)); - int dx = (int)copt.x - r.width/2 - r.x; - int dy = (int)copt.y - r.height/2 - r.y; - if (Math.abs(dx) > r.width/4 || Math.abs(dy) > r.height/4) { - r.x += dx; - r.y += dy; - comp.scrollRectToVisible(r); - } - } - - private void addTileAt(AltosSiteMapTile tile, Point offset) { - if (Math.abs(offset.x) >= MAX_TILE_DELTA || - Math.abs(offset.y) >= MAX_TILE_DELTA) - { - System.out.printf("Rocket too far away from pad (tile %d,%d)\n", - offset.x, offset.y); - return; - } - - boolean review = false; - Rectangle r = comp.getVisibleRect(); - if (offset.x < topleft.x) { - r.x += (topleft.x - offset.x) * px_size; - topleft.x = offset.x; - review = true; - } - if (offset.y < topleft.y) { - r.y += (topleft.y - offset.y) * px_size; - topleft.y = offset.y; - review = true; - } - GridBagConstraints c = new GridBagConstraints(); - c.anchor = GridBagConstraints.CENTER; - c.fill = GridBagConstraints.BOTH; - // put some space between the map tiles, debugging only - // c.insets = new Insets(5, 5, 5, 5); - - c.gridx = offset.x + MAX_TILE_DELTA; - c.gridy = offset.y + MAX_TILE_DELTA; - layout.setConstraints(tile, c); - - comp.add(tile); - if (review) { - comp.scrollRectToVisible(r); - } - } - - private AltosSiteMap(boolean knowWhatYouAreDoing) { - if (!knowWhatYouAreDoing) { - throw new RuntimeException("Arggh."); - } - } - - JComponent comp = new JComponent() { }; - private GridBagLayout layout = new GridBagLayout(); - - public AltosSiteMap(int in_radius) { - radius = in_radius; - - GrabNDrag scroller = new GrabNDrag(comp); - - comp.setLayout(layout); - - for (int x = -radius; x <= radius; x++) { - for (int y = -radius; y <= radius; y++) { - Point offset = new Point(x, y); - AltosSiteMapTile t = createTile(offset); - addTileAt(t, offset); - } - } - setViewportView(comp); - setPreferredSize(new Dimension(500,500)); - } - - public AltosSiteMap() { - this(1); - } -} diff --git a/altosui/AltosSiteMapCache.java b/altosui/AltosSiteMapCache.java deleted file mode 100644 index 03dc3cf5..00000000 --- a/altosui/AltosSiteMapCache.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright © 2010 Anthony Towns - * - * 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 altosui; - -import javax.swing.*; -import javax.imageio.ImageIO; -import java.awt.image.*; -import java.io.*; -import java.net.URL; -import java.net.URLConnection; - -public class AltosSiteMapCache extends JLabel { - static final long google_maps_ratelimit_ms = 1200; - // Google limits static map queries to 50 per minute per IP, so - // each query should take at least 1.2 seconds. - - public static boolean fetchMap(File file, String url) { - URL u; - long startTime = System.nanoTime(); - - try { - u = new URL(url); - } catch (java.net.MalformedURLException e) { - return false; - } - - byte[] data; - try { - URLConnection uc = u.openConnection(); - int contentLength = uc.getContentLength(); - InputStream in = new BufferedInputStream(uc.getInputStream()); - int bytesRead = 0; - int offset = 0; - data = new byte[contentLength]; - while (offset < contentLength) { - bytesRead = in.read(data, offset, data.length - offset); - if (bytesRead == -1) - break; - offset += bytesRead; - } - in.close(); - - if (offset != contentLength) { - return false; - } - } catch (IOException e) { - return false; - } - - try { - FileOutputStream out = new FileOutputStream(file); - out.write(data); - out.flush(); - out.close(); - } catch (FileNotFoundException e) { - return false; - } catch (IOException e) { - if (file.exists()) { - file.delete(); - } - return false; - } - - long duration_ms = (System.nanoTime() - startTime) / 1000000; - if (duration_ms < google_maps_ratelimit_ms) { - try { - Thread.sleep(google_maps_ratelimit_ms - duration_ms); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } - } - - return true; - } - - public static ImageIcon fetchAndLoadMap(File pngfile, String url) { - if (!pngfile.exists()) { - if (!fetchMap(pngfile, url)) { - return null; - } - } - return loadMap(pngfile, url); - } - - public static ImageIcon loadMap(File pngfile, String url) { - if (!pngfile.exists()) { - return null; - } - - try { - BufferedImage img; - - img = ImageIO.read(pngfile); - if (img == null) { - System.out.printf("# Can't read pngfile %s\n", pngfile); - return null; - } - return new ImageIcon(img); - } catch (IOException e) { - System.out.printf("# IO error trying to load %s\n", pngfile); - return null; - } - } -} diff --git a/altosui/AltosSiteMapPreload.java b/altosui/AltosSiteMapPreload.java deleted file mode 100644 index 8380b967..00000000 --- a/altosui/AltosSiteMapPreload.java +++ /dev/null @@ -1,467 +0,0 @@ -/* - * Copyright © 2011 Keith Packard - * - * 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 altosui; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import java.io.*; -import java.util.*; -import java.text.*; -import java.lang.Math; -import java.net.URL; -import java.net.URLConnection; -import org.altusmetrum.altosuilib_1.*; - -class AltosMapPos extends Box { - AltosUI owner; - JLabel label; - JComboBox hemi; - JTextField deg; - JLabel deg_label; - JTextField min; - JLabel min_label; - - public void set_value(double new_value) { - double d, m; - int h; - - h = 0; - if (new_value < 0) { - h = 1; - new_value = -new_value; - } - d = Math.floor(new_value); - deg.setText(String.format("%3.0f", d)); - m = (new_value - d) * 60.0; - min.setText(String.format("%7.4f", m)); - hemi.setSelectedIndex(h); - } - - public double get_value() throws NumberFormatException { - int h = hemi.getSelectedIndex(); - String d_t = deg.getText(); - String m_t = min.getText(); - double d, m, v; - try { - d = Double.parseDouble(d_t); - } catch (NumberFormatException ne) { - JOptionPane.showMessageDialog(owner, - String.format("Invalid degrees \"%s\"", - d_t), - "Invalid number", - JOptionPane.ERROR_MESSAGE); - throw ne; - } - try { - if (m_t.equals("")) - m = 0; - else - m = Double.parseDouble(m_t); - } catch (NumberFormatException ne) { - JOptionPane.showMessageDialog(owner, - String.format("Invalid minutes \"%s\"", - m_t), - "Invalid number", - JOptionPane.ERROR_MESSAGE); - throw ne; - } - v = d + m/60.0; - if (h == 1) - v = -v; - return v; - } - - public AltosMapPos(AltosUI in_owner, - String label_value, - String[] hemi_names, - double default_value) { - super(BoxLayout.X_AXIS); - owner = in_owner; - label = new JLabel(label_value); - hemi = new JComboBox(hemi_names); - hemi.setEditable(false); - deg = new JTextField(5); - deg.setMinimumSize(deg.getPreferredSize()); - deg.setHorizontalAlignment(JTextField.RIGHT); - deg_label = new JLabel("°"); - min = new JTextField(9); - min.setMinimumSize(min.getPreferredSize()); - min_label = new JLabel("'"); - set_value(default_value); - add(label); - add(Box.createRigidArea(new Dimension(5, 0))); - add(hemi); - add(Box.createRigidArea(new Dimension(5, 0))); - add(deg); - add(Box.createRigidArea(new Dimension(5, 0))); - add(deg_label); - add(Box.createRigidArea(new Dimension(5, 0))); - add(min); - add(Box.createRigidArea(new Dimension(5, 0))); - add(min_label); - } -} - -class AltosSite { - String name; - double latitude; - double longitude; - - public String toString() { - return name; - } - - public AltosSite(String in_name, double in_latitude, double in_longitude) { - name = in_name; - latitude = in_latitude; - longitude = in_longitude; - } - - public AltosSite(String line) throws ParseException { - String[] elements = line.split(":"); - - if (elements.length < 3) - throw new ParseException(String.format("Invalid site line %s", line), 0); - - name = elements[0]; - - try { - latitude = Double.parseDouble(elements[1]); - longitude = Double.parseDouble(elements[2]); - } catch (NumberFormatException ne) { - throw new ParseException(String.format("Invalid site line %s", line), 0); - } - } -} - -class AltosSites extends Thread { - AltosSiteMapPreload preload; - URL url; - LinkedList sites; - - void notify_complete() { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - preload.set_sites(); - } - }); - } - - void add(AltosSite site) { - sites.add(site); - } - - void add(String line) { - try { - add(new AltosSite(line)); - } catch (ParseException pe) { - } - } - - public void run() { - try { - URLConnection uc = url.openConnection(); - //int length = uc.getContentLength(); - - InputStreamReader in_stream = new InputStreamReader(uc.getInputStream(), Altos.unicode_set); - BufferedReader in = new BufferedReader(in_stream); - - for (;;) { - String line = in.readLine(); - if (line == null) - break; - add(line); - } - } catch (IOException e) { - } finally { - notify_complete(); - } - } - - public AltosSites(AltosSiteMapPreload in_preload) { - sites = new LinkedList(); - preload = in_preload; - try { - url = new URL(Altos.launch_sites_url); - } catch (java.net.MalformedURLException e) { - notify_complete(); - } - start(); - } -} - -public class AltosSiteMapPreload extends AltosUIDialog implements ActionListener, ItemListener { - AltosUI owner; - AltosSiteMap map; - - AltosMapPos lat; - AltosMapPos lon; - - final static int radius = 5; - final static int width = (radius * 2 + 1); - final static int height = (radius * 2 + 1); - - JProgressBar pbar; - - AltosSites sites; - JLabel site_list_label; - JComboBox site_list; - - JToggleButton load_button; - boolean loading; - JButton close_button; - - static final String[] lat_hemi_names = { "N", "S" }; - static final String[] lon_hemi_names = { "E", "W" }; - - class updatePbar implements Runnable { - int n; - String s; - - public updatePbar(int x, int y, String in_s) { - n = (x + radius) + (y + radius) * width + 1; - s = in_s; - } - - public void run() { - pbar.setValue(n); - pbar.setString(s); - if (n < width * height) { - pbar.setValue(n); - pbar.setString(s); - } else { - pbar.setValue(0); - pbar.setString(""); - load_button.setSelected(false); - loading = false; - } - } - } - - class bgLoad extends Thread { - - AltosSiteMap map; - - public bgLoad(AltosSiteMap in_map) { - map = in_map; - } - - public void run() { - for (int y = -map.radius; y <= map.radius; y++) { - for (int x = -map.radius; x <= map.radius; x++) { - String pngfile; - pngfile = map.initMap(new Point(x,y)); - SwingUtilities.invokeLater(new updatePbar(x, y, pngfile)); - } - } - } - } - - public void set_sites() { - int i = 1; - for (AltosSite site : sites.sites) { - site_list.insertItemAt(site, i); - i++; - } - } - - public void itemStateChanged(ItemEvent e) { - int state = e.getStateChange(); - - if (state == ItemEvent.SELECTED) { - Object o = e.getItem(); - if (o instanceof AltosSite) { - AltosSite site = (AltosSite) o; - lat.set_value(site.latitude); - lon.set_value(site.longitude); - } - } - } - - public void actionPerformed(ActionEvent e) { - String cmd = e.getActionCommand(); - - if (cmd.equals("close")) - setVisible(false); - - if (cmd.equals("load")) { - if (!loading) { - try { - final double latitude = lat.get_value(); - final double longitude = lon.get_value(); - map.setBaseLocation(latitude,longitude); - map.draw_circle(latitude,longitude); - loading = true; - bgLoad thread = new bgLoad(map); - thread.start(); - } catch (NumberFormatException ne) { - load_button.setSelected(false); - } - } - } - } - - public AltosSiteMapPreload(AltosUI in_owner) { - owner = in_owner; - - Container pane = getContentPane(); - GridBagConstraints c = new GridBagConstraints(); - Insets i = new Insets(4,4,4,4); - - pane.setLayout(new GridBagLayout()); - - map = new AltosSiteMap(radius); - - c.fill = GridBagConstraints.BOTH; - c.anchor = GridBagConstraints.CENTER; - c.insets = i; - c.weightx = 1; - c.weighty = 1; - - c.gridx = 0; - c.gridy = 0; - c.gridwidth = 2; - c.anchor = GridBagConstraints.CENTER; - - pane.add(map, c); - - pbar = new JProgressBar(); - pbar.setMinimum(0); - pbar.setMaximum(width * height); - pbar.setValue(0); - pbar.setString(""); - pbar.setStringPainted(true); - - c.fill = GridBagConstraints.HORIZONTAL; - c.anchor = GridBagConstraints.CENTER; - c.insets = i; - c.weightx = 1; - c.weighty = 0; - - c.gridx = 0; - c.gridy = 1; - c.gridwidth = 2; - - pane.add(pbar, c); - - site_list_label = new JLabel ("Known Launch Sites:"); - - c.fill = GridBagConstraints.NONE; - c.anchor = GridBagConstraints.CENTER; - c.insets = i; - c.weightx = 1; - c.weighty = 0; - - c.gridx = 0; - c.gridy = 2; - c.gridwidth = 1; - - pane.add(site_list_label, c); - - site_list = new JComboBox(new String[] { "Site List" }); - site_list.addItemListener(this); - - sites = new AltosSites(this); - - c.fill = GridBagConstraints.HORIZONTAL; - c.anchor = GridBagConstraints.CENTER; - c.insets = i; - c.weightx = 1; - c.weighty = 0; - - c.gridx = 1; - c.gridy = 2; - c.gridwidth = 1; - - pane.add(site_list, c); - - lat = new AltosMapPos(owner, - "Latitude:", - lat_hemi_names, - 37.167833333); - c.fill = GridBagConstraints.NONE; - c.anchor = GridBagConstraints.CENTER; - c.insets = i; - c.weightx = 0; - c.weighty = 0; - - c.gridx = 0; - c.gridy = 3; - c.gridwidth = 1; - c.anchor = GridBagConstraints.CENTER; - - pane.add(lat, c); - - lon = new AltosMapPos(owner, - "Longitude:", - lon_hemi_names, - -97.73975); - - c.fill = GridBagConstraints.NONE; - c.anchor = GridBagConstraints.CENTER; - c.insets = i; - c.weightx = 0; - c.weighty = 0; - - c.gridx = 1; - c.gridy = 3; - c.gridwidth = 1; - c.anchor = GridBagConstraints.CENTER; - - pane.add(lon, c); - - load_button = new JToggleButton("Load Map"); - load_button.addActionListener(this); - load_button.setActionCommand("load"); - - c.fill = GridBagConstraints.NONE; - c.anchor = GridBagConstraints.CENTER; - c.insets = i; - c.weightx = 1; - c.weighty = 0; - - c.gridx = 0; - c.gridy = 4; - c.gridwidth = 1; - c.anchor = GridBagConstraints.CENTER; - - pane.add(load_button, c); - - close_button = new JButton("Close"); - close_button.addActionListener(this); - close_button.setActionCommand("close"); - - c.fill = GridBagConstraints.NONE; - c.anchor = GridBagConstraints.CENTER; - c.insets = i; - c.weightx = 1; - c.weighty = 0; - - c.gridx = 1; - c.gridy = 4; - c.gridwidth = 1; - c.anchor = GridBagConstraints.CENTER; - - pane.add(close_button, c); - - pack(); - setLocationRelativeTo(owner); - setVisible(true); - } -} diff --git a/altosui/AltosSiteMapTile.java b/altosui/AltosSiteMapTile.java deleted file mode 100644 index 7d5b65e1..00000000 --- a/altosui/AltosSiteMapTile.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright © 2010 Anthony Towns - * - * 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 altosui; - -import java.awt.*; -import java.awt.image.*; -import javax.swing.*; -import java.awt.geom.Point2D; -import java.awt.geom.Line2D; -import org.altusmetrum.altoslib_3.*; - -public class AltosSiteMapTile extends JLayeredPane { - JLabel mapLabel; - JLabel draw; - Graphics2D g2d; - int px_size; - - public void loadMap(ImageIcon icn) { - mapLabel.setIcon(icn); - } - - public void clearMap() { - fillLabel(mapLabel, Color.GRAY, px_size); - g2d = fillLabel(draw, new Color(127,127,127,0), px_size); - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); - g2d.setStroke(new BasicStroke(6, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); - } - - static Color stateColors[] = { - Color.WHITE, // startup - Color.WHITE, // idle - Color.WHITE, // pad - Color.RED, // boost - Color.PINK, // fast - Color.YELLOW, // coast - Color.CYAN, // drogue - Color.BLUE, // main - Color.BLACK // landed - }; - - private boolean drawn_landed_circle = false; - private boolean drawn_boost_circle = false; - public synchronized void show(AltosState state, AltosListenerState listener_state, - Point2D.Double last_pt, Point2D.Double pt) - { - if (0 <= state.state && state.state < stateColors.length) { - g2d.setColor(stateColors[state.state]); - } - g2d.draw(new Line2D.Double(last_pt, pt)); - - if (state.state == 3 && !drawn_boost_circle) { - drawn_boost_circle = true; - g2d.setColor(Color.RED); - g2d.drawOval((int)last_pt.x-5, (int)last_pt.y-5, 10, 10); - g2d.drawOval((int)last_pt.x-20, (int)last_pt.y-20, 40, 40); - g2d.drawOval((int)last_pt.x-35, (int)last_pt.y-35, 70, 70); - } - if (state.state == 8 && !drawn_landed_circle) { - drawn_landed_circle = true; - g2d.setColor(Color.BLACK); - g2d.drawOval((int)pt.x-5, (int)pt.y-5, 10, 10); - g2d.drawOval((int)pt.x-20, (int)pt.y-20, 40, 40); - g2d.drawOval((int)pt.x-35, (int)pt.y-35, 70, 70); - } - - repaint(); - } - - public void draw_circle(Point2D.Double pt) { - g2d.setColor(Color.RED); - g2d.drawOval((int)pt.x-5, (int)pt.y-5, 10, 10); - g2d.drawOval((int)pt.x-20, (int)pt.y-20, 40, 40); - g2d.drawOval((int)pt.x-35, (int)pt.y-35, 70, 70); - } - - public static Graphics2D fillLabel(JLabel l, Color c, int px_size) { - BufferedImage img = new BufferedImage(px_size, px_size, - BufferedImage.TYPE_INT_ARGB); - Graphics2D g = img.createGraphics(); - g.setColor(c); - g.fillRect(0, 0, px_size, px_size); - l.setIcon(new ImageIcon(img)); - return g; - } - - public AltosSiteMapTile(int in_px_size) { - px_size = in_px_size; - setPreferredSize(new Dimension(px_size, px_size)); - - mapLabel = new JLabel(); - fillLabel(mapLabel, Color.GRAY, px_size); - mapLabel.setOpaque(true); - mapLabel.setBounds(0, 0, px_size, px_size); - add(mapLabel, new Integer(0)); - - draw = new JLabel(); - g2d = fillLabel(draw, new Color(127, 127, 127, 0), px_size); - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); - g2d.setStroke(new BasicStroke(6, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); - draw.setBounds(0, 0, px_size, px_size); - draw.setOpaque(false); - - add(draw, new Integer(1)); - } -} diff --git a/altosui/AltosVoice.java b/altosui/AltosVoice.java deleted file mode 100644 index 2ed6a8c2..00000000 --- a/altosui/AltosVoice.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright © 2010 Keith Packard - * - * 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 altosui; - -import com.sun.speech.freetts.Voice; -import com.sun.speech.freetts.VoiceManager; -import java.util.concurrent.LinkedBlockingQueue; -import org.altusmetrum.altosuilib_1.*; - -public class AltosVoice implements Runnable { - VoiceManager voice_manager; - Voice voice; - LinkedBlockingQueue phrases; - Thread thread; - boolean busy; - - final static String voice_name = "kevin16"; - - public void run() { - try { - for (;;) { - String s = phrases.take(); - voice.speak(s); - synchronized(this) { - if (phrases.isEmpty()) { - busy = false; - notifyAll(); - } - } - } - } catch (InterruptedException e) { - } - } - - public synchronized void drain() throws InterruptedException { - while (busy) - wait(); - } - - public void speak_always(String s) { - try { - if (voice != null) { - synchronized(this) { - busy = true; - phrases.put(s); - } - } - } catch (InterruptedException e) { - } - } - - public void speak(String s) { - if (AltosUIPreferences.voice()) - speak_always(s); - } - - public void speak(String format, Object... parameters) { - speak(String.format(format, parameters)); - } - - public AltosVoice () { - busy = false; - voice_manager = VoiceManager.getInstance(); - voice = voice_manager.getVoice(voice_name); - if (voice != null) { - voice.allocate(); - phrases = new LinkedBlockingQueue (); - thread = new Thread(this); - thread.start(); - } else { - System.out.printf("Voice manager failed to open %s\n", voice_name); - Voice[] voices = voice_manager.getVoices(); - System.out.printf("Available voices:\n"); - for (int i = 0; i < voices.length; i++) { - System.out.println(" " + voices[i].getName() - + " (" + voices[i].getDomain() + " domain)"); - } - } - } -} diff --git a/altosui/GrabNDrag.java b/altosui/GrabNDrag.java deleted file mode 100644 index 2fd6c4da..00000000 --- a/altosui/GrabNDrag.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright © 2010 Anthony Towns - * - * 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 altosui; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.event.MouseInputAdapter; - -class GrabNDrag extends MouseInputAdapter { - private JComponent scroll; - private Point startPt = new Point(); - - public GrabNDrag(JComponent scroll) { - this.scroll = scroll; - scroll.addMouseMotionListener(this); - scroll.addMouseListener(this); - scroll.setAutoscrolls(true); - } - - public void mousePressed(MouseEvent e) { - startPt.setLocation(e.getPoint()); - } - public void mouseDragged(MouseEvent e) { - int xd = e.getX() - startPt.x; - int yd = e.getY() - startPt.y; - - Rectangle r = scroll.getVisibleRect(); - r.x -= xd; - r.y -= yd; - scroll.scrollRectToVisible(r); - } -} diff --git a/altosui/Makefile.am b/altosui/Makefile.am index 76fe9961..0440b4af 100644 --- a/altosui/Makefile.am +++ b/altosui/Makefile.am @@ -1,6 +1,6 @@ JAVAROOT=classes -AM_JAVACFLAGS=-target 1.6 -encoding UTF-8 -Xlint:deprecation -source 6 +AM_JAVACFLAGS=-target 1.6 -encoding UTF-8 -Xlint:deprecation -Xlint:unchecked -source 6 man_MANS=altosui.1 @@ -17,7 +17,6 @@ altosui_BT = \ AltosBTKnown.java altosui_JAVA = \ - GrabNDrag.java \ AltosAscent.java \ AltosChannelMenu.java \ AltosCompanionInfo.java \ @@ -31,20 +30,16 @@ altosui_JAVA = \ AltosCSVUI.java \ AltosDescent.java \ AltosDeviceUIDialog.java \ - AltosDisplayThread.java \ AltosEepromDelete.java \ AltosEepromManage.java \ AltosEepromMonitorUI.java \ AltosEepromSelect.java \ AltosFlashUI.java \ - AltosFlightDisplay.java \ AltosFlightInfoTableModel.java \ - AltosFlightStats.java \ AltosFlightStatsTable.java \ AltosFlightStatus.java \ AltosFlightStatusUpdate.java \ AltosFlightUI.java \ - AltosFreqList.java \ Altos.java \ AltosIdleMonitorUI.java \ AltosIgniteUI.java \ @@ -61,17 +56,12 @@ altosui_JAVA = \ AltosScanUI.java \ AltosSerial.java \ AltosSerialInUseException.java \ - AltosSiteMap.java \ - AltosSiteMapPreload.java \ - AltosSiteMapCache.java \ - AltosSiteMapTile.java \ AltosUI.java \ AltosGraph.java \ AltosGraphDataPoint.java \ AltosGraphDataSet.java \ AltosGraphUI.java \ AltosDataChooser.java \ - AltosVoice.java \ $(altosui_BT) JFREECHART_CLASS= \ diff --git a/altosuilib/AltosDisplayThread.java b/altosuilib/AltosDisplayThread.java new file mode 100644 index 00000000..e88a891e --- /dev/null +++ b/altosuilib/AltosDisplayThread.java @@ -0,0 +1,259 @@ +/* + * Copyright © 2010 Keith Packard + * + * 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.altosuilib_2; + +import java.awt.*; +import javax.swing.*; +import java.io.*; +import java.text.*; +import org.altusmetrum.altoslib_4.*; + +public class AltosDisplayThread extends Thread { + + Frame parent; + IdleThread idle_thread; + AltosVoice voice; + AltosFlightReader reader; + AltosState old_state, state; + AltosListenerState listener_state; + AltosFlightDisplay display; + + synchronized void show_safely() { + final AltosState my_state = state; + final AltosListenerState my_listener_state = listener_state; + Runnable r = new Runnable() { + public void run() { + try { + display.show(my_state, my_listener_state); + } catch (Exception ex) { + } + } + }; + SwingUtilities.invokeLater(r); + } + + void reading_error_internal() { + JOptionPane.showMessageDialog(parent, + String.format("Error reading from \"%s\"", reader.name), + "Telemetry Read Error", + JOptionPane.ERROR_MESSAGE); + } + + void reading_error_safely() { + Runnable r = new Runnable() { + public void run() { + try { + reading_error_internal(); + } catch (Exception ex) { + } + } + }; + SwingUtilities.invokeLater(r); + } + + class IdleThread extends Thread { + + boolean started; + int reported_landing; + int report_interval; + long report_time; + + public synchronized void report(boolean last) { + if (state == null) + return; + + /* reset the landing count once we hear about a new flight */ + if (state.state < AltosLib.ao_flight_drogue) + reported_landing = 0; + + /* Shut up once the rocket is on the ground */ + if (reported_landing > 2) { + return; + } + + /* If the rocket isn't on the pad, then report height */ + if (AltosLib.ao_flight_drogue <= state.state && + state.state < AltosLib.ao_flight_landed && + state.from_pad != null && + state.range >= 0) + { + voice.speak("Height %s, bearing %s %d, elevation %d, range %s.\n", + AltosConvert.height.say(state.height()), + state.from_pad.bearing_words( + AltosGreatCircle.BEARING_VOICE), + (int) (state.from_pad.bearing + 0.5), + (int) (state.elevation + 0.5), + AltosConvert.distance.say(state.range)); + } else if (state.state > AltosLib.ao_flight_pad) { + voice.speak(AltosConvert.height.say_units(state.height())); + } else { + reported_landing = 0; + } + + /* If the rocket is coming down, check to see if it has landed; + * either we've got a landed report or we haven't heard from it in + * a long time + */ + if (state.state >= AltosLib.ao_flight_drogue && + (last || + System.currentTimeMillis() - state.received_time >= 15000 || + state.state == AltosLib.ao_flight_landed)) + { + if (Math.abs(state.speed()) < 20 && state.height() < 100) + voice.speak("rocket landed safely"); + else + voice.speak("rocket may have crashed"); + if (state.from_pad != null) + voice.speak("Bearing %d degrees, range %s.", + (int) (state.from_pad.bearing + 0.5), + AltosConvert.distance.say_units(state.from_pad.distance)); + ++reported_landing; + if (state.state != AltosLib.ao_flight_landed) { + state.state = AltosLib.ao_flight_landed; + show_safely(); + } + } + } + + long now () { + return System.currentTimeMillis(); + } + + void set_report_time() { + report_time = now() + report_interval; + } + + public void run () { + try { + for (;;) { + if (reader.has_monitor_battery()) { + listener_state.battery = reader.monitor_battery(); + show_safely(); + } + set_report_time(); + for (;;) { + voice.drain(); + synchronized (this) { + long sleep_time = report_time - now(); + if (sleep_time <= 0) + break; + wait(sleep_time); + } + } + + report(false); + } + } catch (InterruptedException ie) { + try { + voice.drain(); + } catch (InterruptedException iie) { } + } + } + + public synchronized void notice(boolean spoken) { + if (old_state != null && old_state.state != state.state) { + report_time = now(); + this.notify(); + } else if (spoken) + set_report_time(); + } + + public IdleThread() { + reported_landing = 0; + report_interval = 10000; + } + } + + synchronized boolean tell() { + boolean ret = false; + if (old_state == null || old_state.state != state.state) { + voice.speak(state.state_name()); + if ((old_state == null || old_state.state <= AltosLib.ao_flight_boost) && + state.state > AltosLib.ao_flight_boost) { + voice.speak("max speed: %s.", + AltosConvert.speed.say_units(state.max_speed() + 0.5)); + ret = true; + } else if ((old_state == null || old_state.state < AltosLib.ao_flight_drogue) && + state.state >= AltosLib.ao_flight_drogue) { + voice.speak("max height: %s.", + AltosConvert.height.say_units(state.max_height() + 0.5)); + ret = true; + } + } + if (old_state == null || old_state.gps_ready != state.gps_ready) { + if (state.gps_ready) { + voice.speak("GPS ready"); + ret = true; + } + else if (old_state != null) { + voice.speak("GPS lost"); + ret = true; + } + } + old_state = state; + return ret; + } + + public void run() { + boolean interrupted = false; + boolean told; + + idle_thread = new IdleThread(); + idle_thread.start(); + + try { + for (;;) { + try { + state = reader.read(); + if (state == null) + break; + reader.update(state); + show_safely(); + told = tell(); + idle_thread.notice(told); + } catch (ParseException pp) { + System.out.printf("Parse error: %d \"%s\"\n", pp.getErrorOffset(), pp.getMessage()); + } catch (AltosCRCException ce) { + ++listener_state.crc_errors; + show_safely(); + } + } + } catch (InterruptedException ee) { + interrupted = true; + } catch (IOException ie) { + reading_error_safely(); + } finally { + if (!interrupted) + idle_thread.report(true); + reader.close(interrupted); + idle_thread.interrupt(); + try { + idle_thread.join(); + } catch (InterruptedException ie) {} + } + } + + public AltosDisplayThread(Frame in_parent, AltosVoice in_voice, AltosFlightDisplay in_display, AltosFlightReader in_reader) { + listener_state = new AltosListenerState(); + parent = in_parent; + voice = in_voice; + display = in_display; + reader = in_reader; + display.reset(); + } +} diff --git a/altosuilib/AltosFlightDisplay.java b/altosuilib/AltosFlightDisplay.java new file mode 100644 index 00000000..5695a015 --- /dev/null +++ b/altosuilib/AltosFlightDisplay.java @@ -0,0 +1,28 @@ +/* + * Copyright © 2010 Keith Packard + * + * 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.altosuilib_2; + +import org.altusmetrum.altoslib_4.*; + +public interface AltosFlightDisplay { + void reset(); + + void show(AltosState state, AltosListenerState listener_state); + + void set_font(); +} diff --git a/altosuilib/AltosFreqList.java b/altosuilib/AltosFreqList.java new file mode 100644 index 00000000..e1299aae --- /dev/null +++ b/altosuilib/AltosFreqList.java @@ -0,0 +1,85 @@ +/* + * Copyright © 2011 Keith Packard + * + * 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.altosuilib_2; + +import javax.swing.*; +import org.altusmetrum.altoslib_4.*; + +public class AltosFreqList extends JComboBox { + + String product; + int serial; + int calibrate; + + public void set_frequency(double new_frequency) { + int i; + + if (new_frequency < 0) { + setVisible(false); + return; + } + + for (i = 0; i < getItemCount(); i++) { + AltosFrequency f = (AltosFrequency) getItemAt(i); + + if (f.close(new_frequency)) { + setSelectedIndex(i); + return; + } + } + for (i = 0; i < getItemCount(); i++) { + AltosFrequency f = (AltosFrequency) getItemAt(i); + + if (new_frequency < f.frequency) + break; + } + String description = String.format("%s serial %d", product, serial); + AltosFrequency frequency = new AltosFrequency(new_frequency, description); + AltosUIPreferences.add_common_frequency(frequency); + insertItemAt(frequency, i); + setMaximumRowCount(getItemCount()); + } + + public void set_product(String new_product) { + product = new_product; + } + + public void set_serial(int new_serial) { + serial = new_serial; + } + + public double frequency() { + AltosFrequency f = (AltosFrequency) getSelectedItem(); + if (f != null) + return f.frequency; + return 434.550; + } + + public AltosFreqList () { + super(AltosUIPreferences.common_frequencies()); + setMaximumRowCount(getItemCount()); + setEditable(false); + product = "Unknown"; + serial = 0; + } + + public AltosFreqList(double in_frequency) { + this(); + set_frequency(in_frequency); + } +} diff --git a/altosuilib/AltosSiteMap.java b/altosuilib/AltosSiteMap.java new file mode 100644 index 00000000..1cfbc8b5 --- /dev/null +++ b/altosuilib/AltosSiteMap.java @@ -0,0 +1,484 @@ +/* + * Copyright © 2010 Anthony Towns + * + * 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.altosuilib_2; + +import java.awt.*; +import javax.swing.*; +import java.io.*; +import java.lang.Math; +import java.awt.geom.Point2D; +import java.util.concurrent.*; +import org.altusmetrum.altoslib_4.*; + +public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay { + // preferred vertical step in a tile in naut. miles + // will actually choose a step size between x and 2x, where this + // is 1.5x + static final double tile_size_nmi = 0.75; + + static final int px_size = 512; + + static final int MAX_TILE_DELTA = 100; + + private static Point2D.Double translatePoint(Point2D.Double p, + Point2D.Double d) + { + return new Point2D.Double(p.x + d.x, p.y + d.y); + } + + static class LatLng { + public double lat, lng; + public LatLng(double lat, double lng) { + this.lat = lat; + this.lng = lng; + } + } + + // based on google js + // http://maps.gstatic.com/intl/en_us/mapfiles/api-3/2/10/main.js + // search for fromLatLngToPoint and fromPointToLatLng + /* + private static Point2D.Double pt(LatLng latlng, int zoom) { + double scale_x = 256/360.0 * Math.pow(2, zoom); + double scale_y = 256/(2.0*Math.PI) * Math.pow(2, zoom); + return pt(latlng, scale_x, scale_y); + } + */ + + private static Point2D.Double pt(LatLng latlng, + double scale_x, double scale_y) + { + Point2D.Double res = new Point2D.Double(); + double e; + + res.x = latlng.lng * scale_x; + + e = Math.sin(Math.toRadians(latlng.lat)); + e = Math.max(e,-(1-1.0E-15)); + e = Math.min(e, 1-1.0E-15 ); + + res.y = 0.5*Math.log((1+e)/(1-e))*-scale_y; + return res; + } + + static private LatLng latlng(Point2D.Double pt, + double scale_x, double scale_y) + { + double lat, lng; + double rads; + + lng = pt.x/scale_x; + rads = 2 * Math.atan(Math.exp(-pt.y/scale_y)); + lat = Math.toDegrees(rads - Math.PI/2); + + return new LatLng(lat,lng); + } + + int zoom; + double scale_x, scale_y; + + int radius; /* half width/height of tiles to load */ + + private Point2D.Double pt(double lat, double lng) { + return pt(new LatLng(lat, lng), scale_x, scale_y); + } + + private LatLng latlng(double x, double y) { + return latlng(new Point2D.Double(x,y), scale_x, scale_y); + } + /* + private LatLng latlng(Point2D.Double pt) { + return latlng(pt, scale_x, scale_y); + } + */ + + ConcurrentHashMap mapTiles = new ConcurrentHashMap(); + Point2D.Double centre; + + private Point2D.Double tileCoordOffset(Point p) { + return new Point2D.Double(centre.x - p.x*px_size, + centre.y - p.y * px_size); + } + + private Point tileOffset(Point2D.Double p) { + return new Point((int)Math.floor((centre.x+p.x)/px_size), + (int)Math.floor((centre.y+p.y)/px_size)); + } + + private Point2D.Double getBaseLocation(double lat, double lng) { + Point2D.Double locn, north_step; + + zoom = 2; + // stupid loop structure to please Java's control flow analysis + do { + zoom++; + scale_x = 256/360.0 * Math.pow(2, zoom); + scale_y = 256/(2.0*Math.PI) * Math.pow(2, zoom); + locn = pt(lat, lng); + north_step = pt(lat+tile_size_nmi*4/3/60.0, lng); + if (locn.y - north_step.y > px_size) + break; + } while (zoom < 22); + locn.x = -px_size * Math.floor(locn.x/px_size); + locn.y = -px_size * Math.floor(locn.y/px_size); + return locn; + } + + public void reset() { + // nothing + } + + public void set_font() { + // nothing + } + + private void loadMap(final AltosSiteMapTile tile, + final File pngfile, String pngurl) + { + boolean loaded = AltosSiteMapCache.fetchMap(pngfile, pngurl); + if (loaded) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + tile.loadMap(pngfile); + } + }); + } else { + System.out.printf("# Failed to fetch file %s\n", pngfile); + System.out.printf(" wget -O '%s' '%s'\n", pngfile, pngurl); + } + } + + + class AltosSiteMapPrefetch { + int x; + int y; + int result; + File pngfile; + String pngurl; + } + + public AltosSiteMapPrefetch prefetchMap(int x, int y) { + AltosSiteMapPrefetch prefetch = new AltosSiteMapPrefetch(); + LatLng map_latlng = latlng( + -centre.x + x*px_size + px_size/2, + -centre.y + y*px_size + px_size/2); + prefetch.pngfile = MapFile(map_latlng.lat, map_latlng.lng, zoom); + prefetch.pngurl = MapURL(map_latlng.lat, map_latlng.lng, zoom); + if (prefetch.pngfile.exists()) { + prefetch.result = 1; + } else if (AltosSiteMapCache.fetchMap(prefetch.pngfile, prefetch.pngurl)) { + prefetch.result = 0; + } else { + prefetch.result = -1; + } + return prefetch; + } + + public static void prefetchMaps(double lat, double lng) { + int w = AltosSiteMapPreload.width; + int h = AltosSiteMapPreload.height; + AltosSiteMap asm = new AltosSiteMap(true); + asm.centre = asm.getBaseLocation(lat, lng); + + //Point2D.Double p = new Point2D.Double(); + //Point2D.Double p2; + int dx = -w/2, dy = -h/2; + for (int y = dy; y < h+dy; y++) { + for (int x = dx; x < w+dx; x++) { + AltosSiteMapPrefetch prefetch = asm.prefetchMap(x, y); + switch (prefetch.result) { + case 1: + System.out.printf("Already have %s\n", prefetch.pngfile); + break; + case 0: + System.out.printf("Fetched map %s\n", prefetch.pngfile); + break; + case -1: + System.out.printf("# Failed to fetch file %s\n", prefetch.pngfile); + System.out.printf(" wget -O '%s' ''\n", + prefetch.pngfile, prefetch.pngurl); + break; + } + } + } + } + + public String initMap(Point offset) { + AltosSiteMapTile tile = mapTiles.get(offset); + Point2D.Double coord = tileCoordOffset(offset); + + LatLng map_latlng = latlng(px_size/2-coord.x, px_size/2-coord.y); + + File pngfile = MapFile(map_latlng.lat, map_latlng.lng, zoom); + String pngurl = MapURL(map_latlng.lat, map_latlng.lng, zoom); + loadMap(tile, pngfile, pngurl); + return pngfile.toString(); + } + + public void initAndFinishMapAsync (final AltosSiteMapTile tile, final Point offset) { + Thread thread = new Thread() { + public void run() { + initMap(offset); + finishTileLater(tile, offset); + } + }; + thread.start(); + } + + public void setBaseLocation(double lat, double lng) { + for (Point k : mapTiles.keySet()) { + AltosSiteMapTile tile = mapTiles.get(k); + tile.clearMap(); + } + + centre = getBaseLocation(lat, lng); + scrollRocketToVisible(pt(lat,lng)); + } + + private void initMaps(double lat, double lng) { + setBaseLocation(lat, lng); + + Thread thread = new Thread() { + public void run() { + for (Point k : mapTiles.keySet()) + initMap(k); + } + }; + thread.start(); + } + + private static File MapFile(double lat, double lng, int zoom) { + char chlat = lat < 0 ? 'S' : 'N'; + char chlng = lng < 0 ? 'W' : 'E'; + if (lat < 0) lat = -lat; + if (lng < 0) lng = -lng; + return new File(AltosUIPreferences.mapdir(), + String.format("map-%c%.6f,%c%.6f-%d.png", + chlat, lat, chlng, lng, zoom)); + } + + private static String MapURL(double lat, double lng, int zoom) { + return String.format("http://maps.google.com/maps/api/staticmap?center=%.6f,%.6f&zoom=%d&size=%dx%d&sensor=false&maptype=hybrid&format=png32", lat, lng, zoom, px_size, px_size); + } + + boolean initialised = false; + Point2D.Double last_pt = null; + int last_state = -1; + + public void show(double lat, double lon) { + System.out.printf ("show %g %g\n", lat, lon); + return; +// initMaps(lat, lon); +// scrollRocketToVisible(pt(lat, lon)); + } + public void show(final AltosState state, final AltosListenerState listener_state) { + // if insufficient gps data, nothing to update + AltosGPS gps = state.gps; + + if (gps == null) + return; + + if (!gps.locked && gps.nsat < 4) + return; + + if (!initialised) { + if (state.pad_lat != AltosLib.MISSING && state.pad_lon != AltosLib.MISSING) { + initMaps(state.pad_lat, state.pad_lon); + initialised = true; + } else if (gps.lat != AltosLib.MISSING && gps.lon != AltosLib.MISSING) { + initMaps(gps.lat, gps.lon); + initialised = true; + } else { + return; + } + } + + final Point2D.Double pt = pt(gps.lat, gps.lon); + if (last_pt == pt && last_state == state.state) + return; + + if (last_pt == null) { + last_pt = pt; + } + boolean in_any = false; + for (Point offset : mapTiles.keySet()) { + AltosSiteMapTile tile = mapTiles.get(offset); + Point2D.Double ref, lref; + ref = translatePoint(pt, tileCoordOffset(offset)); + lref = translatePoint(last_pt, tileCoordOffset(offset)); + tile.show(state, listener_state, lref, ref); + if (0 <= ref.x && ref.x < px_size) + if (0 <= ref.y && ref.y < px_size) + in_any = true; + } + + Point offset = tileOffset(pt); + if (!in_any) { + Point2D.Double ref, lref; + ref = translatePoint(pt, tileCoordOffset(offset)); + lref = translatePoint(last_pt, tileCoordOffset(offset)); + + AltosSiteMapTile tile = createTile(offset); + tile.show(state, listener_state, lref, ref); + initAndFinishMapAsync(tile, offset); + } + + scrollRocketToVisible(pt); + + if (offset != tileOffset(last_pt)) { + ensureTilesAround(offset); + } + + last_pt = pt; + last_state = state.state; + } + + public void centre(Point2D.Double pt) { + Rectangle r = comp.getVisibleRect(); + Point2D.Double copt = translatePoint(pt, tileCoordOffset(topleft)); + int dx = (int)copt.x - r.width/2 - r.x; + int dy = (int)copt.y - r.height/2 - r.y; + r.x += dx; + r.y += dy; + comp.scrollRectToVisible(r); + } + + public void centre(AltosState state) { + if (!state.gps.locked && state.gps.nsat < 4) + return; + centre(pt(state.gps.lat, state.gps.lon)); + } + + public void draw_circle(double lat, double lon) { + final Point2D.Double pt = pt(lat, lon); + + for (Point offset : mapTiles.keySet()) { + AltosSiteMapTile tile = mapTiles.get(offset); + Point2D.Double ref = translatePoint(pt, tileCoordOffset(offset)); + tile.set_boost(ref); + } + } + + private AltosSiteMapTile createTile(Point offset) { + AltosSiteMapTile tile = new AltosSiteMapTile(px_size); + mapTiles.put(offset, tile); + return tile; + } + private void finishTileLater(final AltosSiteMapTile tile, + final Point offset) + { + SwingUtilities.invokeLater( new Runnable() { + public void run() { + addTileAt(tile, offset); + } + } ); + } + + private void ensureTilesAround(Point base_offset) { + for (int x = -radius; x <= radius; x++) { + for (int y = -radius; y <= radius; y++) { + Point offset = new Point(base_offset.x + x, base_offset.y + y); + if (mapTiles.containsKey(offset)) + continue; + AltosSiteMapTile tile = createTile(offset); + initAndFinishMapAsync(tile, offset); + } + } + } + + private Point topleft = new Point(0,0); + private void scrollRocketToVisible(Point2D.Double pt) { + Rectangle r = comp.getVisibleRect(); + Point2D.Double copt = translatePoint(pt, tileCoordOffset(topleft)); + int dx = (int)copt.x - r.width/2 - r.x; + int dy = (int)copt.y - r.height/2 - r.y; + if (Math.abs(dx) > r.width/4 || Math.abs(dy) > r.height/4) { + r.x += dx; + r.y += dy; + comp.scrollRectToVisible(r); + } + } + + private void addTileAt(AltosSiteMapTile tile, Point offset) { + if (Math.abs(offset.x) >= MAX_TILE_DELTA || + Math.abs(offset.y) >= MAX_TILE_DELTA) + { + System.out.printf("Rocket too far away from pad (tile %d,%d)\n", + offset.x, offset.y); + return; + } + + boolean review = false; + Rectangle r = comp.getVisibleRect(); + if (offset.x < topleft.x) { + r.x += (topleft.x - offset.x) * px_size; + topleft.x = offset.x; + review = true; + } + if (offset.y < topleft.y) { + r.y += (topleft.y - offset.y) * px_size; + topleft.y = offset.y; + review = true; + } + GridBagConstraints c = new GridBagConstraints(); + c.anchor = GridBagConstraints.CENTER; + c.fill = GridBagConstraints.BOTH; + // put some space between the map tiles, debugging only + // c.insets = new Insets(5, 5, 5, 5); + + c.gridx = offset.x + MAX_TILE_DELTA; + c.gridy = offset.y + MAX_TILE_DELTA; + layout.setConstraints(tile, c); + + comp.add(tile); + if (review) { + comp.scrollRectToVisible(r); + } + } + + private AltosSiteMap(boolean knowWhatYouAreDoing) { + if (!knowWhatYouAreDoing) { + throw new RuntimeException("Arggh."); + } + } + + JComponent comp = new JComponent() { }; + private GridBagLayout layout = new GridBagLayout(); + + public AltosSiteMap(int in_radius) { + radius = in_radius; + + GrabNDrag scroller = new GrabNDrag(comp); + + comp.setLayout(layout); + + for (int x = -radius; x <= radius; x++) { + for (int y = -radius; y <= radius; y++) { + Point offset = new Point(x, y); + AltosSiteMapTile t = createTile(offset); + addTileAt(t, offset); + } + } + setViewportView(comp); + setPreferredSize(new Dimension(500,500)); + } + + public AltosSiteMap() { + this(1); + } +} diff --git a/altosuilib/AltosSiteMapCache.java b/altosuilib/AltosSiteMapCache.java new file mode 100644 index 00000000..cf93016a --- /dev/null +++ b/altosuilib/AltosSiteMapCache.java @@ -0,0 +1,194 @@ +/* + * Copyright © 2010 Anthony Towns + * + * 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.altosuilib_2; + +import javax.swing.*; +import javax.imageio.ImageIO; +import java.awt.image.*; +import java.awt.*; +import java.io.*; +import java.net.URL; +import java.net.URLConnection; + + +class AltosCacheImage { + Component component; + File file; + VolatileImage image; + int width; + int height; + long used; + + public void load_image() throws IOException { + BufferedImage bimg = ImageIO.read(file); + Graphics2D g = image.createGraphics(); + g.drawImage(bimg, 0, 0, null); + bimg.flush(); + } + + public Image validate() { + int returnCode; + + if (image != null) + returnCode = image.validate(component.getGraphicsConfiguration()); + else + returnCode = VolatileImage.IMAGE_INCOMPATIBLE; + if (returnCode == VolatileImage.IMAGE_RESTORED) { + try { + load_image(); + } catch (IOException e) { + return null; + } + } else if (returnCode == VolatileImage.IMAGE_INCOMPATIBLE) { + image = component.createVolatileImage(width, height); + try { + load_image(); + } catch (IOException e) { + return null; + } + } + return image; + } + + public void flush() { + image.flush(); + } + + public AltosCacheImage(Component component, File file, int w, int h) throws IOException { + this.component = component; + this.file = file; + width = w; + height = h; + image = component.createVolatileImage(w, h); + used = 0; + } +} + +public class AltosSiteMapCache extends JLabel { + static final long google_maps_ratelimit_ms = 1200; + // Google limits static map queries to 50 per minute per IP, so + // each query should take at least 1.2 seconds. + + public static boolean fetchMap(File file, String url) { + if (file.exists()) + return true; + + URL u; + long startTime = System.nanoTime(); + + try { + u = new URL(url); + } catch (java.net.MalformedURLException e) { + return false; + } + + byte[] data; + try { + URLConnection uc = u.openConnection(); + int contentLength = uc.getContentLength(); + InputStream in = new BufferedInputStream(uc.getInputStream()); + int bytesRead = 0; + int offset = 0; + data = new byte[contentLength]; + while (offset < contentLength) { + bytesRead = in.read(data, offset, data.length - offset); + if (bytesRead == -1) + break; + offset += bytesRead; + } + in.close(); + + if (offset != contentLength) { + return false; + } + } catch (IOException e) { + return false; + } + + try { + FileOutputStream out = new FileOutputStream(file); + out.write(data); + out.flush(); + out.close(); + } catch (FileNotFoundException e) { + return false; + } catch (IOException e) { + if (file.exists()) { + file.delete(); + } + return false; + } + + long duration_ms = (System.nanoTime() - startTime) / 1000000; + if (duration_ms < google_maps_ratelimit_ms) { + try { + Thread.sleep(google_maps_ratelimit_ms - duration_ms); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } + } + + return true; + } + + static int cache_size = 9; + + static AltosCacheImage[] images; + + static long used; + + public static void set_cache_size(int cache_size) { + AltosSiteMapCache.cache_size = cache_size; + images = null; + } + + public static Image get_image(Component component, File file, int width, int height) { + int oldest = -1; + long age = used; + AltosCacheImage image; + if (images == null) + images = new AltosCacheImage[cache_size]; + for (int i = 0; i < cache_size; i++) { + image = images[i]; + + if (image == null) { + oldest = i; + break; + } + if (image.component == component && file.equals(image.file)) { + image.used = used++; + return image.validate(); + } + if (image.used < age) { + oldest = i; + age = image.used; + } + } + + try { + image = new AltosCacheImage(component, file, width, height); + image.used = used++; + if (images[oldest] != null) + images[oldest].flush(); + images[oldest] = image; + return image.validate(); + } catch (IOException e) { + return null; + } + } +} diff --git a/altosuilib/AltosSiteMapPreload.java b/altosuilib/AltosSiteMapPreload.java new file mode 100644 index 00000000..baa7fc37 --- /dev/null +++ b/altosuilib/AltosSiteMapPreload.java @@ -0,0 +1,467 @@ +/* + * Copyright © 2011 Keith Packard + * + * 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.altosuilib_2; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import java.io.*; +import java.util.*; +import java.text.*; +import java.lang.Math; +import java.net.URL; +import java.net.URLConnection; +import org.altusmetrum.altoslib_4.*; + +class AltosMapPos extends Box { + AltosUIFrame owner; + JLabel label; + JComboBox hemi; + JTextField deg; + JLabel deg_label; + JTextField min; + JLabel min_label; + + public void set_value(double new_value) { + double d, m; + int h; + + h = 0; + if (new_value < 0) { + h = 1; + new_value = -new_value; + } + d = Math.floor(new_value); + deg.setText(String.format("%3.0f", d)); + m = (new_value - d) * 60.0; + min.setText(String.format("%7.4f", m)); + hemi.setSelectedIndex(h); + } + + public double get_value() throws NumberFormatException { + int h = hemi.getSelectedIndex(); + String d_t = deg.getText(); + String m_t = min.getText(); + double d, m, v; + try { + d = Double.parseDouble(d_t); + } catch (NumberFormatException ne) { + JOptionPane.showMessageDialog(owner, + String.format("Invalid degrees \"%s\"", + d_t), + "Invalid number", + JOptionPane.ERROR_MESSAGE); + throw ne; + } + try { + if (m_t.equals("")) + m = 0; + else + m = Double.parseDouble(m_t); + } catch (NumberFormatException ne) { + JOptionPane.showMessageDialog(owner, + String.format("Invalid minutes \"%s\"", + m_t), + "Invalid number", + JOptionPane.ERROR_MESSAGE); + throw ne; + } + v = d + m/60.0; + if (h == 1) + v = -v; + return v; + } + + public AltosMapPos(AltosUIFrame in_owner, + String label_value, + String[] hemi_names, + double default_value) { + super(BoxLayout.X_AXIS); + owner = in_owner; + label = new JLabel(label_value); + hemi = new JComboBox(hemi_names); + hemi.setEditable(false); + deg = new JTextField(5); + deg.setMinimumSize(deg.getPreferredSize()); + deg.setHorizontalAlignment(JTextField.RIGHT); + deg_label = new JLabel("°"); + min = new JTextField(9); + min.setMinimumSize(min.getPreferredSize()); + min_label = new JLabel("'"); + set_value(default_value); + add(label); + add(Box.createRigidArea(new Dimension(5, 0))); + add(hemi); + add(Box.createRigidArea(new Dimension(5, 0))); + add(deg); + add(Box.createRigidArea(new Dimension(5, 0))); + add(deg_label); + add(Box.createRigidArea(new Dimension(5, 0))); + add(min); + add(Box.createRigidArea(new Dimension(5, 0))); + add(min_label); + } +} + +class AltosSite { + String name; + double latitude; + double longitude; + + public String toString() { + return name; + } + + public AltosSite(String in_name, double in_latitude, double in_longitude) { + name = in_name; + latitude = in_latitude; + longitude = in_longitude; + } + + public AltosSite(String line) throws ParseException { + String[] elements = line.split(":"); + + if (elements.length < 3) + throw new ParseException(String.format("Invalid site line %s", line), 0); + + name = elements[0]; + + try { + latitude = Double.parseDouble(elements[1]); + longitude = Double.parseDouble(elements[2]); + } catch (NumberFormatException ne) { + throw new ParseException(String.format("Invalid site line %s", line), 0); + } + } +} + +class AltosSites extends Thread { + AltosSiteMapPreload preload; + URL url; + LinkedList sites; + + void notify_complete() { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + preload.set_sites(); + } + }); + } + + void add(AltosSite site) { + sites.add(site); + } + + void add(String line) { + try { + add(new AltosSite(line)); + } catch (ParseException pe) { + } + } + + public void run() { + try { + URLConnection uc = url.openConnection(); + //int length = uc.getContentLength(); + + InputStreamReader in_stream = new InputStreamReader(uc.getInputStream(), AltosLib.unicode_set); + BufferedReader in = new BufferedReader(in_stream); + + for (;;) { + String line = in.readLine(); + if (line == null) + break; + add(line); + } + } catch (IOException e) { + } finally { + notify_complete(); + } + } + + public AltosSites(AltosSiteMapPreload in_preload) { + sites = new LinkedList(); + preload = in_preload; + try { + url = new URL(AltosLib.launch_sites_url); + } catch (java.net.MalformedURLException e) { + notify_complete(); + } + start(); + } +} + +public class AltosSiteMapPreload extends AltosUIDialog implements ActionListener, ItemListener { + AltosUIFrame owner; + AltosSiteMap map; + + AltosMapPos lat; + AltosMapPos lon; + + final static int radius = 5; + final static int width = (radius * 2 + 1); + final static int height = (radius * 2 + 1); + + JProgressBar pbar; + + AltosSites sites; + JLabel site_list_label; + JComboBox site_list; + + JToggleButton load_button; + boolean loading; + JButton close_button; + + static final String[] lat_hemi_names = { "N", "S" }; + static final String[] lon_hemi_names = { "E", "W" }; + + class updatePbar implements Runnable { + int n; + String s; + + public updatePbar(int x, int y, String in_s) { + n = (x + radius) + (y + radius) * width + 1; + s = in_s; + } + + public void run() { + pbar.setValue(n); + pbar.setString(s); + if (n < width * height) { + pbar.setValue(n); + pbar.setString(s); + } else { + pbar.setValue(0); + pbar.setString(""); + load_button.setSelected(false); + loading = false; + } + } + } + + class bgLoad extends Thread { + + AltosSiteMap map; + + public bgLoad(AltosSiteMap in_map) { + map = in_map; + } + + public void run() { + for (int y = -map.radius; y <= map.radius; y++) { + for (int x = -map.radius; x <= map.radius; x++) { + String pngfile; + pngfile = map.initMap(new Point(x,y)); + SwingUtilities.invokeLater(new updatePbar(x, y, pngfile)); + } + } + } + } + + public void set_sites() { + int i = 1; + for (AltosSite site : sites.sites) { + site_list.insertItemAt(site, i); + i++; + } + } + + public void itemStateChanged(ItemEvent e) { + int state = e.getStateChange(); + + if (state == ItemEvent.SELECTED) { + Object o = e.getItem(); + if (o instanceof AltosSite) { + AltosSite site = (AltosSite) o; + lat.set_value(site.latitude); + lon.set_value(site.longitude); + } + } + } + + public void actionPerformed(ActionEvent e) { + String cmd = e.getActionCommand(); + + if (cmd.equals("close")) + setVisible(false); + + if (cmd.equals("load")) { + if (!loading) { + try { + final double latitude = lat.get_value(); + final double longitude = lon.get_value(); + map.setBaseLocation(latitude,longitude); + map.draw_circle(latitude,longitude); + loading = true; + bgLoad thread = new bgLoad(map); + thread.start(); + } catch (NumberFormatException ne) { + load_button.setSelected(false); + } + } + } + } + + public AltosSiteMapPreload(AltosUIFrame in_owner) { + owner = in_owner; + + Container pane = getContentPane(); + GridBagConstraints c = new GridBagConstraints(); + Insets i = new Insets(4,4,4,4); + + pane.setLayout(new GridBagLayout()); + + map = new AltosSiteMap(radius); + + c.fill = GridBagConstraints.BOTH; + c.anchor = GridBagConstraints.CENTER; + c.insets = i; + c.weightx = 1; + c.weighty = 1; + + c.gridx = 0; + c.gridy = 0; + c.gridwidth = 2; + c.anchor = GridBagConstraints.CENTER; + + pane.add(map, c); + + pbar = new JProgressBar(); + pbar.setMinimum(0); + pbar.setMaximum(width * height); + pbar.setValue(0); + pbar.setString(""); + pbar.setStringPainted(true); + + c.fill = GridBagConstraints.HORIZONTAL; + c.anchor = GridBagConstraints.CENTER; + c.insets = i; + c.weightx = 1; + c.weighty = 0; + + c.gridx = 0; + c.gridy = 1; + c.gridwidth = 2; + + pane.add(pbar, c); + + site_list_label = new JLabel ("Known Launch Sites:"); + + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.CENTER; + c.insets = i; + c.weightx = 1; + c.weighty = 0; + + c.gridx = 0; + c.gridy = 2; + c.gridwidth = 1; + + pane.add(site_list_label, c); + + site_list = new JComboBox(new AltosSite[] { new AltosSite("Site List", 0, 0) }); + site_list.addItemListener(this); + + sites = new AltosSites(this); + + c.fill = GridBagConstraints.HORIZONTAL; + c.anchor = GridBagConstraints.CENTER; + c.insets = i; + c.weightx = 1; + c.weighty = 0; + + c.gridx = 1; + c.gridy = 2; + c.gridwidth = 1; + + pane.add(site_list, c); + + lat = new AltosMapPos(owner, + "Latitude:", + lat_hemi_names, + 37.167833333); + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.CENTER; + c.insets = i; + c.weightx = 0; + c.weighty = 0; + + c.gridx = 0; + c.gridy = 3; + c.gridwidth = 1; + c.anchor = GridBagConstraints.CENTER; + + pane.add(lat, c); + + lon = new AltosMapPos(owner, + "Longitude:", + lon_hemi_names, + -97.73975); + + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.CENTER; + c.insets = i; + c.weightx = 0; + c.weighty = 0; + + c.gridx = 1; + c.gridy = 3; + c.gridwidth = 1; + c.anchor = GridBagConstraints.CENTER; + + pane.add(lon, c); + + load_button = new JToggleButton("Load Map"); + load_button.addActionListener(this); + load_button.setActionCommand("load"); + + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.CENTER; + c.insets = i; + c.weightx = 1; + c.weighty = 0; + + c.gridx = 0; + c.gridy = 4; + c.gridwidth = 1; + c.anchor = GridBagConstraints.CENTER; + + pane.add(load_button, c); + + close_button = new JButton("Close"); + close_button.addActionListener(this); + close_button.setActionCommand("close"); + + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.CENTER; + c.insets = i; + c.weightx = 1; + c.weighty = 0; + + c.gridx = 1; + c.gridy = 4; + c.gridwidth = 1; + c.anchor = GridBagConstraints.CENTER; + + pane.add(close_button, c); + + pack(); + setLocationRelativeTo(owner); + setVisible(true); + } +} diff --git a/altosuilib/AltosSiteMapTile.java b/altosuilib/AltosSiteMapTile.java new file mode 100644 index 00000000..1046d6bd --- /dev/null +++ b/altosuilib/AltosSiteMapTile.java @@ -0,0 +1,142 @@ +/* + * Copyright © 2010 Anthony Towns + * + * 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.altosuilib_2; + +import java.awt.*; +import java.awt.image.*; +import javax.swing.*; +import javax.imageio.*; +import java.awt.geom.Point2D; +import java.awt.geom.Line2D; +import java.io.*; +import java.util.*; +import org.altusmetrum.altoslib_4.*; + +class AltosPoint { + Point2D.Double pt; + int state; + + AltosPoint(Point2D.Double pt, int state) { + this.pt = pt; + this.state = state; + } +} + +public class AltosSiteMapTile extends JComponent { + int px_size; + File file; + + Point2D.Double boost; + Point2D.Double landed; + + LinkedList points; + + public void loadMap(File pngFile) { + file = pngFile; + repaint(); + } + + public void clearMap() { + boost = null; + landed = null; + points = null; + file = null; + } + + static Color stateColors[] = { + Color.WHITE, // startup + Color.WHITE, // idle + Color.WHITE, // pad + Color.RED, // boost + Color.PINK, // fast + Color.YELLOW, // coast + Color.CYAN, // drogue + Color.BLUE, // main + Color.BLACK // landed + }; + + private void draw_circle(Graphics g, Point2D.Double pt) { + g.drawOval((int)pt.x-5, (int)pt.y-5, 10, 10); + g.drawOval((int)pt.x-20, (int)pt.y-20, 40, 40); + g.drawOval((int)pt.x-35, (int)pt.y-35, 70, 70); + } + + public void set_boost(Point2D.Double boost) { + this.boost = boost; + repaint(); + } + + public void paint(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + AltosPoint prev = null; + Image img = null; + + if (file != null) + img = AltosSiteMapCache.get_image(this, file, px_size, px_size); + + if (img != null) { + g2d.drawImage(img, 0, 0, null); + } else { + g2d.setColor(Color.GRAY); + g2d.fillRect(0, 0, getWidth(), getHeight()); + } + + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + g2d.setStroke(new BasicStroke(6, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); + + if (points != null) { + for (AltosPoint point : points) { + if (prev != null) { + if (0 <= point.state && point.state < stateColors.length) + g2d.setColor(stateColors[point.state]); + g2d.draw(new Line2D.Double(prev.pt, point.pt)); + } + prev = point; + } + } + if (boost != null) { + g2d.setColor(Color.RED); + draw_circle(g2d, boost); + } + if (landed != null) { + g2d.setColor(Color.BLACK); + draw_circle(g2d, landed); + } + } + + public synchronized void show(AltosState state, AltosListenerState listener_state, + Point2D.Double last_pt, Point2D.Double pt) + { + if (points == null) + points = new LinkedList(); + + points.add(new AltosPoint(pt, state.state)); + + if (state.state == AltosLib.ao_flight_boost && boost == null) + boost = pt; + if (state.state == AltosLib.ao_flight_landed && landed == null) + landed = pt; + repaint(); + } + + public AltosSiteMapTile(int in_px_size) { + px_size = in_px_size; + setPreferredSize(new Dimension(px_size, px_size)); + } +} diff --git a/altosuilib/AltosVoice.java b/altosuilib/AltosVoice.java new file mode 100644 index 00000000..a3995f68 --- /dev/null +++ b/altosuilib/AltosVoice.java @@ -0,0 +1,94 @@ +/* + * Copyright © 2010 Keith Packard + * + * 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.altosuilib_2; + +import com.sun.speech.freetts.Voice; +import com.sun.speech.freetts.VoiceManager; +import java.util.concurrent.LinkedBlockingQueue; + +public class AltosVoice implements Runnable { + VoiceManager voice_manager; + Voice voice; + LinkedBlockingQueue phrases; + Thread thread; + boolean busy; + + final static String voice_name = "kevin16"; + + public void run() { + try { + for (;;) { + String s = phrases.take(); + voice.speak(s); + synchronized(this) { + if (phrases.isEmpty()) { + busy = false; + notifyAll(); + } + } + } + } catch (InterruptedException e) { + } + } + + public synchronized void drain() throws InterruptedException { + while (busy) + wait(); + } + + public void speak_always(String s) { + try { + if (voice != null) { + synchronized(this) { + busy = true; + phrases.put(s); + } + } + } catch (InterruptedException e) { + } + } + + public void speak(String s) { + if (AltosUIPreferences.voice()) + speak_always(s); + } + + public void speak(String format, Object... parameters) { + speak(String.format(format, parameters)); + } + + public AltosVoice () { + busy = false; + voice_manager = VoiceManager.getInstance(); + voice = voice_manager.getVoice(voice_name); + if (voice != null) { + voice.allocate(); + phrases = new LinkedBlockingQueue (); + thread = new Thread(this); + thread.start(); + } else { + System.out.printf("Voice manager failed to open %s\n", voice_name); + Voice[] voices = voice_manager.getVoices(); + System.out.printf("Available voices:\n"); + for (int i = 0; i < voices.length; i++) { + System.out.println(" " + voices[i].getName() + + " (" + voices[i].getDomain() + " domain)"); + } + } + } +} diff --git a/altosuilib/GrabNDrag.java b/altosuilib/GrabNDrag.java new file mode 100644 index 00000000..5e5fdd52 --- /dev/null +++ b/altosuilib/GrabNDrag.java @@ -0,0 +1,48 @@ +/* + * Copyright © 2010 Anthony Towns + * + * 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.altosuilib_2; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.event.MouseInputAdapter; + +class GrabNDrag extends MouseInputAdapter { + private JComponent scroll; + private Point startPt = new Point(); + + public GrabNDrag(JComponent scroll) { + this.scroll = scroll; + scroll.addMouseMotionListener(this); + scroll.addMouseListener(this); + scroll.setAutoscrolls(true); + } + + public void mousePressed(MouseEvent e) { + startPt.setLocation(e.getPoint()); + } + public void mouseDragged(MouseEvent e) { + int xd = e.getX() - startPt.x; + int yd = e.getY() - startPt.y; + + Rectangle r = scroll.getVisibleRect(); + r.x -= xd; + r.y -= yd; + scroll.scrollRectToVisible(r); + } +} diff --git a/altosuilib/Makefile.am b/altosuilib/Makefile.am index 4b22af1f..b7d624e2 100644 --- a/altosuilib/Makefile.am +++ b/altosuilib/Makefile.am @@ -1,4 +1,4 @@ -AM_JAVACFLAGS=-target 1.6 -encoding UTF-8 -Xlint:deprecation -source 6 +AM_JAVACFLAGS=-target 1.6 -encoding UTF-8 -Xlint:deprecation -Xlint:unchecked -source 6 JAVAROOT=bin @@ -9,8 +9,10 @@ SRC=. altosuilibdir = $(datadir)/java altosuilib_JAVA = \ + GrabNDrag.java \ AltosDevice.java \ AltosDeviceDialog.java \ + AltosFlightDisplay.java \ AltosFontListener.java \ AltosPositionListener.java \ AltosUIConfigure.java \ @@ -30,7 +32,14 @@ altosuilib_JAVA = \ AltosUIPreferences.java \ AltosUISeries.java \ AltosUIVersion.java \ - AltosUSBDevice.java + AltosUSBDevice.java \ + AltosSiteMap.java \ + AltosSiteMapCache.java \ + AltosSiteMapPreload.java \ + AltosSiteMapTile.java \ + AltosVoice.java \ + AltosDisplayThread.java \ + AltosFreqList.java JAR=altosuilib_$(ALTOSUILIB_VERSION).jar -- cgit v1.2.3 From f0216d721ed13f4d3dc608bb6ad8f83732b27c0a Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 25 May 2014 21:01:38 -0700 Subject: altoslib/altosuilib: Change versions to altoslib:4, altosuilib:2 API has changed for these libraries, time to bump the file versions Signed-off-by: Keith Packard --- altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferences.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/AltosVoice.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/TabAscent.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/TabDescent.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/TabLanded.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/TelemetryLogger.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java | 2 +- altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java | 2 +- altoslib/AltosAccel.java | 2 +- altoslib/AltosCRCException.java | 2 +- altoslib/AltosCSV.java | 2 +- altoslib/AltosCompanion.java | 2 +- altoslib/AltosConfigData.java | 2 +- altoslib/AltosConfigValues.java | 2 +- altoslib/AltosConvert.java | 2 +- altoslib/AltosDebug.java | 2 +- altoslib/AltosDistance.java | 2 +- altoslib/AltosEeprom.java | 2 +- altoslib/AltosEepromChunk.java | 2 +- altoslib/AltosEepromDownload.java | 2 +- altoslib/AltosEepromFile.java | 2 +- altoslib/AltosEepromHeader.java | 2 +- altoslib/AltosEepromIterable.java | 2 +- altoslib/AltosEepromList.java | 2 +- altoslib/AltosEepromLog.java | 2 +- altoslib/AltosEepromMega.java | 2 +- altoslib/AltosEepromMetrum2.java | 2 +- altoslib/AltosEepromMini.java | 2 +- altoslib/AltosEepromMonitor.java | 2 +- altoslib/AltosEepromTM.java | 2 +- altoslib/AltosEepromTm.java | 2 +- altoslib/AltosFile.java | 2 +- altoslib/AltosFlash.java | 2 +- altoslib/AltosFlashListener.java | 2 +- altoslib/AltosFlightReader.java | 2 +- altoslib/AltosFrequency.java | 2 +- altoslib/AltosGPS.java | 2 +- altoslib/AltosGPSSat.java | 2 +- altoslib/AltosGreatCircle.java | 2 +- altoslib/AltosHeight.java | 2 +- altoslib/AltosHexfile.java | 2 +- altoslib/AltosHexsym.java | 2 +- altoslib/AltosIMU.java | 2 +- altoslib/AltosIdle.java | 2 +- altoslib/AltosIdleFetch.java | 2 +- altoslib/AltosIdleMonitor.java | 2 +- altoslib/AltosIdleMonitorListener.java | 2 +- altoslib/AltosIgnite.java | 2 +- altoslib/AltosKML.java | 2 +- altoslib/AltosLib.java | 2 +- altoslib/AltosLine.java | 2 +- altoslib/AltosLink.java | 2 +- altoslib/AltosListenerState.java | 2 +- altoslib/AltosLog.java | 2 +- altoslib/AltosMag.java | 2 +- altoslib/AltosMma655x.java | 2 +- altoslib/AltosMs5607.java | 2 +- altoslib/AltosNoSymbol.java | 2 +- altoslib/AltosOrient.java | 2 +- altoslib/AltosParse.java | 2 +- altoslib/AltosPreferences.java | 2 +- altoslib/AltosPreferencesBackend.java | 2 +- altoslib/AltosProgrammer.java | 2 +- altoslib/AltosPyro.java | 2 +- altoslib/AltosReplayReader.java | 2 +- altoslib/AltosRomconfig.java | 2 +- altoslib/AltosSelfFlash.java | 2 +- altoslib/AltosSensorEMini.java | 2 +- altoslib/AltosSensorMM.java | 2 +- altoslib/AltosSensorMega.java | 2 +- altoslib/AltosSensorMetrum.java | 2 +- altoslib/AltosSensorTM.java | 2 +- altoslib/AltosSensorTMini.java | 2 +- altoslib/AltosSpeed.java | 2 +- altoslib/AltosState.java | 2 +- altoslib/AltosStateIterable.java | 2 +- altoslib/AltosStateUpdate.java | 2 +- altoslib/AltosTelemetry.java | 2 +- altoslib/AltosTelemetryConfiguration.java | 2 +- altoslib/AltosTelemetryFile.java | 2 +- altoslib/AltosTelemetryIterable.java | 2 +- altoslib/AltosTelemetryLegacy.java | 2 +- altoslib/AltosTelemetryLocation.java | 2 +- altoslib/AltosTelemetryMap.java | 2 +- altoslib/AltosTelemetryMegaData.java | 2 +- altoslib/AltosTelemetryMegaSensor.java | 2 +- altoslib/AltosTelemetryMetrumData.java | 2 +- altoslib/AltosTelemetryMetrumSensor.java | 2 +- altoslib/AltosTelemetryMini.java | 2 +- altoslib/AltosTelemetryRaw.java | 2 +- altoslib/AltosTelemetryReader.java | 2 +- altoslib/AltosTelemetrySatellite.java | 2 +- altoslib/AltosTelemetrySensor.java | 2 +- altoslib/AltosTelemetryStandard.java | 2 +- altoslib/AltosTemperature.java | 2 +- altoslib/AltosUnits.java | 2 +- altoslib/AltosUnitsListener.java | 2 +- altoslib/AltosWriter.java | 2 +- altosui/Altos.java | 4 ++-- altosui/AltosAscent.java | 3 ++- altosui/AltosBTDevice.java | 2 +- altosui/AltosBTKnown.java | 4 ++-- altosui/AltosBTManage.java | 2 +- altosui/AltosCSVUI.java | 4 ++-- altosui/AltosCompanionInfo.java | 2 +- altosui/AltosConfig.java | 4 ++-- altosui/AltosConfigFreqUI.java | 4 ++-- altosui/AltosConfigPyroUI.java | 4 ++-- altosui/AltosConfigTD.java | 4 ++-- altosui/AltosConfigTDUI.java | 4 ++-- altosui/AltosConfigUI.java | 4 ++-- altosui/AltosConfigureUI.java | 2 +- altosui/AltosDataChooser.java | 4 ++-- altosui/AltosDescent.java | 3 ++- altosui/AltosDeviceUIDialog.java | 2 +- altosui/AltosEepromDelete.java | 2 +- altosui/AltosEepromManage.java | 4 ++-- altosui/AltosEepromMonitor.java | 2 +- altosui/AltosEepromMonitorUI.java | 4 ++-- altosui/AltosEepromSelect.java | 4 ++-- altosui/AltosFlashUI.java | 4 ++-- altosui/AltosFlightStatsTable.java | 2 +- altosui/AltosFlightStatus.java | 3 ++- altosui/AltosFlightStatusTableModel.java | 2 +- altosui/AltosFlightStatusUpdate.java | 2 +- altosui/AltosFlightUI.java | 4 ++-- altosui/AltosGraph.java | 4 ++-- altosui/AltosGraphDataPoint.java | 4 ++-- altosui/AltosGraphDataSet.java | 4 ++-- altosui/AltosGraphUI.java | 4 ++-- altosui/AltosIdleMonitorUI.java | 4 ++-- altosui/AltosIgniteUI.java | 4 ++-- altosui/AltosIgnitor.java | 3 ++- altosui/AltosInfoTable.java | 2 +- altosui/AltosLanded.java | 3 ++- altosui/AltosLaunch.java | 2 +- altosui/AltosLaunchUI.java | 2 +- altosui/AltosPad.java | 3 ++- altosui/AltosRomconfigUI.java | 4 ++-- altosui/AltosScanUI.java | 4 ++-- altosui/AltosSerial.java | 4 ++-- altosui/AltosSerialInUseException.java | 2 +- altosui/AltosUI.java | 4 ++-- altosui/AltosUIPreferencesBackend.java | 2 +- altosuilib/AltosDevice.java | 2 +- altosuilib/AltosDeviceDialog.java | 2 +- altosuilib/AltosFontListener.java | 2 +- altosuilib/AltosPositionListener.java | 2 +- altosuilib/AltosUIAxis.java | 4 ++-- altosuilib/AltosUIConfigure.java | 2 +- altosuilib/AltosUIDataMissing.java | 2 +- altosuilib/AltosUIDataPoint.java | 2 +- altosuilib/AltosUIDataSet.java | 2 +- altosuilib/AltosUIDialog.java | 2 +- altosuilib/AltosUIEnable.java | 4 ++-- altosuilib/AltosUIFrame.java | 2 +- altosuilib/AltosUIGraph.java | 4 ++-- altosuilib/AltosUIGrapher.java | 4 ++-- altosuilib/AltosUILib.java | 4 ++-- altosuilib/AltosUIListener.java | 2 +- altosuilib/AltosUIMarker.java | 4 ++-- altosuilib/AltosUIPreferences.java | 4 ++-- altosuilib/AltosUIPreferencesBackend.java | 4 ++-- altosuilib/AltosUISeries.java | 4 ++-- altosuilib/AltosUIVersion.java.in | 2 +- altosuilib/AltosUSBDevice.java | 2 +- configure.ac | 4 ++-- micropeak/MicroData.java | 4 ++-- micropeak/MicroDataPoint.java | 2 +- micropeak/MicroDeviceDialog.java | 2 +- micropeak/MicroDownload.java | 4 ++-- micropeak/MicroExport.java | 4 ++-- micropeak/MicroFile.java | 4 ++-- micropeak/MicroFileChooser.java | 4 ++-- micropeak/MicroFrame.java | 2 +- micropeak/MicroGraph.java | 4 ++-- micropeak/MicroPeak.java | 4 ++-- micropeak/MicroRaw.java | 4 ++-- micropeak/MicroSave.java | 4 ++-- micropeak/MicroSerial.java | 2 +- micropeak/MicroSerialLog.java | 2 +- micropeak/MicroStats.java | 4 ++-- micropeak/MicroStatsTable.java | 4 ++-- micropeak/MicroUSB.java | 2 +- 189 files changed, 241 insertions(+), 235 deletions(-) (limited to 'altoslib') diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java index 634769cc..1b4d45ed 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java @@ -31,7 +31,7 @@ import android.os.Handler; //import android.os.Message; import android.util.Log; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; public class AltosBluetooth extends AltosLink { diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java index 9125d56b..f61baf1e 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java @@ -49,7 +49,7 @@ import android.widget.Toast; import android.app.AlertDialog; import android.location.Location; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; public class AltosDroid extends FragmentActivity { // Debugging diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferences.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferences.java index 067cb620..f6e6881d 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferences.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferences.java @@ -23,7 +23,7 @@ import android.content.Context; import android.content.SharedPreferences; import android.os.Environment; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; public class AltosDroidPreferences implements AltosPreferencesBackend { public final static String NAME = "org.altusmetrum.AltosDroid"; diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java index 9d155385..fac4b8d4 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java @@ -17,7 +17,7 @@ package org.altusmetrum.AltosDroid; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; import android.location.Location; public interface AltosDroidTab { diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosVoice.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosVoice.java index b50cab22..77d4ba38 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosVoice.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosVoice.java @@ -21,7 +21,7 @@ package org.altusmetrum.AltosDroid; import android.speech.tts.TextToSpeech; import android.speech.tts.TextToSpeech.OnInitListener; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; public class AltosVoice { diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabAscent.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabAscent.java index edfd8245..e4a815eb 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TabAscent.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabAscent.java @@ -17,7 +17,7 @@ package org.altusmetrum.AltosDroid; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; import android.app.Activity; import android.os.Bundle; diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabDescent.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabDescent.java index cc070b0d..cbbe4d44 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TabDescent.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabDescent.java @@ -17,7 +17,7 @@ package org.altusmetrum.AltosDroid; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; import android.app.Activity; import android.os.Bundle; diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabLanded.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabLanded.java index 5a703978..b2e6fd20 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TabLanded.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabLanded.java @@ -17,7 +17,7 @@ package org.altusmetrum.AltosDroid; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; import android.app.Activity; import android.os.Bundle; diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java index 5fe88f51..38922771 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java @@ -19,7 +19,7 @@ package org.altusmetrum.AltosDroid; import java.util.Arrays; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java index 3f0a1887..10bb3bd9 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java @@ -17,7 +17,7 @@ package org.altusmetrum.AltosDroid; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; import android.app.Activity; import android.os.Bundle; diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryLogger.java b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryLogger.java index c8c61838..4215a330 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryLogger.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryLogger.java @@ -1,6 +1,6 @@ package org.altusmetrum.AltosDroid; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; import android.content.BroadcastReceiver; import android.content.Context; diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java index 2a2cc404..5bc4b90d 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java @@ -25,7 +25,7 @@ import java.util.concurrent.*; import android.util.Log; import android.os.Handler; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; public class TelemetryReader extends Thread { diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java index 96cedad8..da5e044f 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java @@ -44,7 +44,7 @@ import android.location.LocationManager; import android.location.LocationListener; import android.location.Criteria; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; public class TelemetryService extends Service implements LocationListener { diff --git a/altoslib/AltosAccel.java b/altoslib/AltosAccel.java index 43dc20bd..3d340e5d 100644 --- a/altoslib/AltosAccel.java +++ b/altoslib/AltosAccel.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosAccel extends AltosUnits { diff --git a/altoslib/AltosCRCException.java b/altoslib/AltosCRCException.java index 94962731..253ca435 100644 --- a/altoslib/AltosCRCException.java +++ b/altoslib/AltosCRCException.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosCRCException extends Exception { public int rssi; diff --git a/altoslib/AltosCSV.java b/altoslib/AltosCSV.java index 8176d21b..27e1fade 100644 --- a/altoslib/AltosCSV.java +++ b/altoslib/AltosCSV.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosCompanion.java b/altoslib/AltosCompanion.java index 47ca328e..09bfe9f3 100644 --- a/altoslib/AltosCompanion.java +++ b/altoslib/AltosCompanion.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosCompanion { public final static int board_id_telescience = 0x0a; diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index 213d8f13..e5c546ff 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.util.*; import java.text.*; diff --git a/altoslib/AltosConfigValues.java b/altoslib/AltosConfigValues.java index 1a9fddbf..b7c0c6ed 100644 --- a/altoslib/AltosConfigValues.java +++ b/altoslib/AltosConfigValues.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public interface AltosConfigValues { /* set and get all of the dialog values */ diff --git a/altoslib/AltosConvert.java b/altoslib/AltosConvert.java index 4ed45c68..484f6213 100644 --- a/altoslib/AltosConvert.java +++ b/altoslib/AltosConvert.java @@ -18,7 +18,7 @@ /* * Sensor data conversion functions */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosConvert { /* diff --git a/altoslib/AltosDebug.java b/altoslib/AltosDebug.java index 4dfb31e5..b0e52fc1 100644 --- a/altoslib/AltosDebug.java +++ b/altoslib/AltosDebug.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; diff --git a/altoslib/AltosDistance.java b/altoslib/AltosDistance.java index 71ee81d7..76ca20c0 100644 --- a/altoslib/AltosDistance.java +++ b/altoslib/AltosDistance.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosDistance extends AltosUnits { diff --git a/altoslib/AltosEeprom.java b/altoslib/AltosEeprom.java index 57ee73ad..be18ba24 100644 --- a/altoslib/AltosEeprom.java +++ b/altoslib/AltosEeprom.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromChunk.java b/altoslib/AltosEepromChunk.java index c884b659..32de96bc 100644 --- a/altoslib/AltosEepromChunk.java +++ b/altoslib/AltosEepromChunk.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.text.*; import java.util.concurrent.*; diff --git a/altoslib/AltosEepromDownload.java b/altoslib/AltosEepromDownload.java index 163ffad9..a2dfc438 100644 --- a/altoslib/AltosEepromDownload.java +++ b/altoslib/AltosEepromDownload.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromFile.java b/altoslib/AltosEepromFile.java index 91ffc223..2a26c484 100644 --- a/altoslib/AltosEepromFile.java +++ b/altoslib/AltosEepromFile.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromHeader.java b/altoslib/AltosEepromHeader.java index fe5bf6c3..0d022f46 100644 --- a/altoslib/AltosEepromHeader.java +++ b/altoslib/AltosEepromHeader.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromIterable.java b/altoslib/AltosEepromIterable.java index 081721b3..415c5b62 100644 --- a/altoslib/AltosEepromIterable.java +++ b/altoslib/AltosEepromIterable.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromList.java b/altoslib/AltosEepromList.java index a9dac13a..ab853a88 100644 --- a/altoslib/AltosEepromList.java +++ b/altoslib/AltosEepromList.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromLog.java b/altoslib/AltosEepromLog.java index cc298207..1a430c03 100644 --- a/altoslib/AltosEepromLog.java +++ b/altoslib/AltosEepromLog.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.text.*; import java.util.concurrent.*; diff --git a/altoslib/AltosEepromMega.java b/altoslib/AltosEepromMega.java index f0d7097e..71719a26 100644 --- a/altoslib/AltosEepromMega.java +++ b/altoslib/AltosEepromMega.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromMetrum2.java b/altoslib/AltosEepromMetrum2.java index d13aac42..d137614a 100644 --- a/altoslib/AltosEepromMetrum2.java +++ b/altoslib/AltosEepromMetrum2.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromMini.java b/altoslib/AltosEepromMini.java index b308fbf4..32985639 100644 --- a/altoslib/AltosEepromMini.java +++ b/altoslib/AltosEepromMini.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromMonitor.java b/altoslib/AltosEepromMonitor.java index 9ab1a5ab..b97287c3 100644 --- a/altoslib/AltosEepromMonitor.java +++ b/altoslib/AltosEepromMonitor.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public interface AltosEepromMonitor { diff --git a/altoslib/AltosEepromTM.java b/altoslib/AltosEepromTM.java index c8b1e60c..77fe20c5 100644 --- a/altoslib/AltosEepromTM.java +++ b/altoslib/AltosEepromTM.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromTm.java b/altoslib/AltosEepromTm.java index 049dd340..6cbb7253 100644 --- a/altoslib/AltosEepromTm.java +++ b/altoslib/AltosEepromTm.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosFile.java b/altoslib/AltosFile.java index 79f6f1c6..2a738996 100644 --- a/altoslib/AltosFile.java +++ b/altoslib/AltosFile.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.File; import java.util.*; diff --git a/altoslib/AltosFlash.java b/altoslib/AltosFlash.java index 25c76863..8e8722c2 100644 --- a/altoslib/AltosFlash.java +++ b/altoslib/AltosFlash.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; diff --git a/altoslib/AltosFlashListener.java b/altoslib/AltosFlashListener.java index b7fcd73b..8bb86bba 100644 --- a/altoslib/AltosFlashListener.java +++ b/altoslib/AltosFlashListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public interface AltosFlashListener { public void position(String label, int percent); diff --git a/altoslib/AltosFlightReader.java b/altoslib/AltosFlightReader.java index 86757e82..2fcd556e 100644 --- a/altoslib/AltosFlightReader.java +++ b/altoslib/AltosFlightReader.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.text.*; import java.io.*; diff --git a/altoslib/AltosFrequency.java b/altoslib/AltosFrequency.java index 5770b646..7c291ea9 100644 --- a/altoslib/AltosFrequency.java +++ b/altoslib/AltosFrequency.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosFrequency { public double frequency; diff --git a/altoslib/AltosGPS.java b/altoslib/AltosGPS.java index 01e6fdbc..2708d026 100644 --- a/altoslib/AltosGPS.java +++ b/altoslib/AltosGPS.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.text.*; import java.util.concurrent.*; diff --git a/altoslib/AltosGPSSat.java b/altoslib/AltosGPSSat.java index 76fa3a56..ef24d497 100644 --- a/altoslib/AltosGPSSat.java +++ b/altoslib/AltosGPSSat.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosGPSSat { public int svid; diff --git a/altoslib/AltosGreatCircle.java b/altoslib/AltosGreatCircle.java index b884a3bc..39df4fc8 100644 --- a/altoslib/AltosGreatCircle.java +++ b/altoslib/AltosGreatCircle.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.lang.Math; diff --git a/altoslib/AltosHeight.java b/altoslib/AltosHeight.java index a81897e7..84981032 100644 --- a/altoslib/AltosHeight.java +++ b/altoslib/AltosHeight.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosHeight extends AltosUnits { diff --git a/altoslib/AltosHexfile.java b/altoslib/AltosHexfile.java index 60f4ecdc..d5fa8f5f 100644 --- a/altoslib/AltosHexfile.java +++ b/altoslib/AltosHexfile.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.LinkedList; diff --git a/altoslib/AltosHexsym.java b/altoslib/AltosHexsym.java index a98ef0fc..403b5644 100644 --- a/altoslib/AltosHexsym.java +++ b/altoslib/AltosHexsym.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosHexsym { String name; diff --git a/altoslib/AltosIMU.java b/altoslib/AltosIMU.java index 99efb76f..a22b3fed 100644 --- a/altoslib/AltosIMU.java +++ b/altoslib/AltosIMU.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.util.concurrent.*; diff --git a/altoslib/AltosIdle.java b/altoslib/AltosIdle.java index c7b546b6..55f6f5c9 100644 --- a/altoslib/AltosIdle.java +++ b/altoslib/AltosIdle.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosIdleFetch.java b/altoslib/AltosIdleFetch.java index b0e45797..5cd8bf36 100644 --- a/altoslib/AltosIdleFetch.java +++ b/altoslib/AltosIdleFetch.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosIdleMonitor.java b/altoslib/AltosIdleMonitor.java index 8342f8a5..f81abdff 100644 --- a/altoslib/AltosIdleMonitor.java +++ b/altoslib/AltosIdleMonitor.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.concurrent.*; diff --git a/altoslib/AltosIdleMonitorListener.java b/altoslib/AltosIdleMonitorListener.java index dcaa77a6..6a9abea2 100644 --- a/altoslib/AltosIdleMonitorListener.java +++ b/altoslib/AltosIdleMonitorListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public interface AltosIdleMonitorListener { public void update(AltosState state, AltosListenerState listener_state); diff --git a/altoslib/AltosIgnite.java b/altoslib/AltosIgnite.java index 8ab47d1d..c21f17ac 100644 --- a/altoslib/AltosIgnite.java +++ b/altoslib/AltosIgnite.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.util.*; import java.io.*; diff --git a/altoslib/AltosKML.java b/altoslib/AltosKML.java index cc9a9f51..d55da9ef 100644 --- a/altoslib/AltosKML.java +++ b/altoslib/AltosKML.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java index 3f25bc31..5e18202f 100644 --- a/altoslib/AltosLib.java +++ b/altoslib/AltosLib.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.util.*; import java.io.*; diff --git a/altoslib/AltosLine.java b/altoslib/AltosLine.java index 9d796a89..f9c712a3 100644 --- a/altoslib/AltosLine.java +++ b/altoslib/AltosLine.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosLine { public String line; diff --git a/altoslib/AltosLink.java b/altoslib/AltosLink.java index 469b03c0..7f434a06 100644 --- a/altoslib/AltosLink.java +++ b/altoslib/AltosLink.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.concurrent.*; diff --git a/altoslib/AltosListenerState.java b/altoslib/AltosListenerState.java index 53ed33f9..5bf761b0 100644 --- a/altoslib/AltosListenerState.java +++ b/altoslib/AltosListenerState.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosListenerState { public int crc_errors; diff --git a/altoslib/AltosLog.java b/altoslib/AltosLog.java index 70c017b7..8ecb1e96 100644 --- a/altoslib/AltosLog.java +++ b/altoslib/AltosLog.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.text.*; diff --git a/altoslib/AltosMag.java b/altoslib/AltosMag.java index a3a0a74b..9262de2d 100644 --- a/altoslib/AltosMag.java +++ b/altoslib/AltosMag.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.util.concurrent.*; diff --git a/altoslib/AltosMma655x.java b/altoslib/AltosMma655x.java index 0d90c351..cb2e63d4 100644 --- a/altoslib/AltosMma655x.java +++ b/altoslib/AltosMma655x.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.util.concurrent.*; diff --git a/altoslib/AltosMs5607.java b/altoslib/AltosMs5607.java index 4a851524..5aa3a7ec 100644 --- a/altoslib/AltosMs5607.java +++ b/altoslib/AltosMs5607.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.util.concurrent.*; diff --git a/altoslib/AltosNoSymbol.java b/altoslib/AltosNoSymbol.java index 791899c0..f5e53b8c 100644 --- a/altoslib/AltosNoSymbol.java +++ b/altoslib/AltosNoSymbol.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosNoSymbol extends Exception { public AltosNoSymbol(String name) { diff --git a/altoslib/AltosOrient.java b/altoslib/AltosOrient.java index d916a0fb..5fcbe28d 100644 --- a/altoslib/AltosOrient.java +++ b/altoslib/AltosOrient.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosOrient extends AltosUnits { diff --git a/altoslib/AltosParse.java b/altoslib/AltosParse.java index 5137fef8..1bff7682 100644 --- a/altoslib/AltosParse.java +++ b/altoslib/AltosParse.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.text.*; diff --git a/altoslib/AltosPreferences.java b/altoslib/AltosPreferences.java index 484cb644..d299f27b 100644 --- a/altoslib/AltosPreferences.java +++ b/altoslib/AltosPreferences.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosPreferencesBackend.java b/altoslib/AltosPreferencesBackend.java index 2eb29702..461b5c80 100644 --- a/altoslib/AltosPreferencesBackend.java +++ b/altoslib/AltosPreferencesBackend.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.File; diff --git a/altoslib/AltosProgrammer.java b/altoslib/AltosProgrammer.java index 750e1f02..c96f04ca 100644 --- a/altoslib/AltosProgrammer.java +++ b/altoslib/AltosProgrammer.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; diff --git a/altoslib/AltosPyro.java b/altoslib/AltosPyro.java index a1414123..9e47bc80 100644 --- a/altoslib/AltosPyro.java +++ b/altoslib/AltosPyro.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.util.*; import java.text.*; diff --git a/altoslib/AltosReplayReader.java b/altoslib/AltosReplayReader.java index 4cf642ca..ac7df414 100644 --- a/altoslib/AltosReplayReader.java +++ b/altoslib/AltosReplayReader.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosRomconfig.java b/altoslib/AltosRomconfig.java index 506c3961..10df11af 100644 --- a/altoslib/AltosRomconfig.java +++ b/altoslib/AltosRomconfig.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; diff --git a/altoslib/AltosSelfFlash.java b/altoslib/AltosSelfFlash.java index 051aa766..502c6d65 100644 --- a/altoslib/AltosSelfFlash.java +++ b/altoslib/AltosSelfFlash.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; diff --git a/altoslib/AltosSensorEMini.java b/altoslib/AltosSensorEMini.java index 5f43b3a9..ee0238f9 100644 --- a/altoslib/AltosSensorEMini.java +++ b/altoslib/AltosSensorEMini.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.util.concurrent.TimeoutException; diff --git a/altoslib/AltosSensorMM.java b/altoslib/AltosSensorMM.java index 0c23d671..e34e71b7 100644 --- a/altoslib/AltosSensorMM.java +++ b/altoslib/AltosSensorMM.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.util.concurrent.TimeoutException; diff --git a/altoslib/AltosSensorMega.java b/altoslib/AltosSensorMega.java index c52f688d..02f3a256 100644 --- a/altoslib/AltosSensorMega.java +++ b/altoslib/AltosSensorMega.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.util.concurrent.TimeoutException; diff --git a/altoslib/AltosSensorMetrum.java b/altoslib/AltosSensorMetrum.java index bb794a1e..e5421ef5 100644 --- a/altoslib/AltosSensorMetrum.java +++ b/altoslib/AltosSensorMetrum.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.util.concurrent.TimeoutException; diff --git a/altoslib/AltosSensorTM.java b/altoslib/AltosSensorTM.java index a5129783..2d60d8cf 100644 --- a/altoslib/AltosSensorTM.java +++ b/altoslib/AltosSensorTM.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.util.concurrent.TimeoutException; diff --git a/altoslib/AltosSensorTMini.java b/altoslib/AltosSensorTMini.java index bb60a794..b9eeca0c 100644 --- a/altoslib/AltosSensorTMini.java +++ b/altoslib/AltosSensorTMini.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.util.concurrent.TimeoutException; diff --git a/altoslib/AltosSpeed.java b/altoslib/AltosSpeed.java index d93229dd..9134f5f4 100644 --- a/altoslib/AltosSpeed.java +++ b/altoslib/AltosSpeed.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosSpeed extends AltosUnits { diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index 4dbd751b..71263151 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -19,7 +19,7 @@ * Track flight state from telemetry or eeprom data stream */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosState implements Cloneable { diff --git a/altoslib/AltosStateIterable.java b/altoslib/AltosStateIterable.java index 7ea3041b..be812095 100644 --- a/altoslib/AltosStateIterable.java +++ b/altoslib/AltosStateIterable.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosStateUpdate.java b/altoslib/AltosStateUpdate.java index 4614c67a..ac4e963e 100644 --- a/altoslib/AltosStateUpdate.java +++ b/altoslib/AltosStateUpdate.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public interface AltosStateUpdate { public void update_state(AltosState state) throws InterruptedException; diff --git a/altoslib/AltosTelemetry.java b/altoslib/AltosTelemetry.java index 1c4ce7bc..62948378 100644 --- a/altoslib/AltosTelemetry.java +++ b/altoslib/AltosTelemetry.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.text.*; diff --git a/altoslib/AltosTelemetryConfiguration.java b/altoslib/AltosTelemetryConfiguration.java index 67a43748..d1341b9e 100644 --- a/altoslib/AltosTelemetryConfiguration.java +++ b/altoslib/AltosTelemetryConfiguration.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosTelemetryConfiguration extends AltosTelemetryStandard { diff --git a/altoslib/AltosTelemetryFile.java b/altoslib/AltosTelemetryFile.java index f6643134..3d3fa407 100644 --- a/altoslib/AltosTelemetryFile.java +++ b/altoslib/AltosTelemetryFile.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosTelemetryIterable.java b/altoslib/AltosTelemetryIterable.java index 002f53b4..cba97ddc 100644 --- a/altoslib/AltosTelemetryIterable.java +++ b/altoslib/AltosTelemetryIterable.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.io.*; import java.util.*; diff --git a/altoslib/AltosTelemetryLegacy.java b/altoslib/AltosTelemetryLegacy.java index da9296e4..3367ece7 100644 --- a/altoslib/AltosTelemetryLegacy.java +++ b/altoslib/AltosTelemetryLegacy.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.text.*; diff --git a/altoslib/AltosTelemetryLocation.java b/altoslib/AltosTelemetryLocation.java index 8dcda9e1..8368188f 100644 --- a/altoslib/AltosTelemetryLocation.java +++ b/altoslib/AltosTelemetryLocation.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosTelemetryLocation extends AltosTelemetryStandard { diff --git a/altoslib/AltosTelemetryMap.java b/altoslib/AltosTelemetryMap.java index 37b2527b..8d0de355 100644 --- a/altoslib/AltosTelemetryMap.java +++ b/altoslib/AltosTelemetryMap.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.text.*; import java.util.HashMap; diff --git a/altoslib/AltosTelemetryMegaData.java b/altoslib/AltosTelemetryMegaData.java index ffd82546..fac5695f 100644 --- a/altoslib/AltosTelemetryMegaData.java +++ b/altoslib/AltosTelemetryMegaData.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosTelemetryMegaData extends AltosTelemetryStandard { int state; diff --git a/altoslib/AltosTelemetryMegaSensor.java b/altoslib/AltosTelemetryMegaSensor.java index d9fd7fde..9e73bc4e 100644 --- a/altoslib/AltosTelemetryMegaSensor.java +++ b/altoslib/AltosTelemetryMegaSensor.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosTelemetryMegaSensor extends AltosTelemetryStandard { int accel; diff --git a/altoslib/AltosTelemetryMetrumData.java b/altoslib/AltosTelemetryMetrumData.java index b8f7e9ea..96617306 100644 --- a/altoslib/AltosTelemetryMetrumData.java +++ b/altoslib/AltosTelemetryMetrumData.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosTelemetryMetrumData extends AltosTelemetryStandard { diff --git a/altoslib/AltosTelemetryMetrumSensor.java b/altoslib/AltosTelemetryMetrumSensor.java index 232468bb..e7055404 100644 --- a/altoslib/AltosTelemetryMetrumSensor.java +++ b/altoslib/AltosTelemetryMetrumSensor.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosTelemetryMetrumSensor extends AltosTelemetryStandard { diff --git a/altoslib/AltosTelemetryMini.java b/altoslib/AltosTelemetryMini.java index e0a493dc..fbfaff8e 100644 --- a/altoslib/AltosTelemetryMini.java +++ b/altoslib/AltosTelemetryMini.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosTelemetryMini extends AltosTelemetryStandard { diff --git a/altoslib/AltosTelemetryRaw.java b/altoslib/AltosTelemetryRaw.java index 91cfbb18..0dca62aa 100644 --- a/altoslib/AltosTelemetryRaw.java +++ b/altoslib/AltosTelemetryRaw.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosTelemetryRaw extends AltosTelemetryStandard { public AltosTelemetryRaw(int[] bytes) { diff --git a/altoslib/AltosTelemetryReader.java b/altoslib/AltosTelemetryReader.java index 5e283587..3dff661a 100644 --- a/altoslib/AltosTelemetryReader.java +++ b/altoslib/AltosTelemetryReader.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; import java.text.*; import java.io.*; diff --git a/altoslib/AltosTelemetrySatellite.java b/altoslib/AltosTelemetrySatellite.java index 24777b28..d611e88c 100644 --- a/altoslib/AltosTelemetrySatellite.java +++ b/altoslib/AltosTelemetrySatellite.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosTelemetrySatellite extends AltosTelemetryStandard { int channels; diff --git a/altoslib/AltosTelemetrySensor.java b/altoslib/AltosTelemetrySensor.java index d6389865..ad4d9283 100644 --- a/altoslib/AltosTelemetrySensor.java +++ b/altoslib/AltosTelemetrySensor.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosTelemetrySensor extends AltosTelemetryStandard { diff --git a/altoslib/AltosTelemetryStandard.java b/altoslib/AltosTelemetryStandard.java index c9531fcb..23ae9d21 100644 --- a/altoslib/AltosTelemetryStandard.java +++ b/altoslib/AltosTelemetryStandard.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public abstract class AltosTelemetryStandard extends AltosTelemetry { int[] bytes; diff --git a/altoslib/AltosTemperature.java b/altoslib/AltosTemperature.java index 36e26564..5fa71b86 100644 --- a/altoslib/AltosTemperature.java +++ b/altoslib/AltosTemperature.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public class AltosTemperature extends AltosUnits { diff --git a/altoslib/AltosUnits.java b/altoslib/AltosUnits.java index 82f102e4..d29cfae7 100644 --- a/altoslib/AltosUnits.java +++ b/altoslib/AltosUnits.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public abstract class AltosUnits { diff --git a/altoslib/AltosUnitsListener.java b/altoslib/AltosUnitsListener.java index e9b29f9a..ca6faafd 100644 --- a/altoslib/AltosUnitsListener.java +++ b/altoslib/AltosUnitsListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public interface AltosUnitsListener { public void units_changed(boolean imperial_units); diff --git a/altoslib/AltosWriter.java b/altoslib/AltosWriter.java index 0b0daebd..c3479a93 100644 --- a/altoslib/AltosWriter.java +++ b/altoslib/AltosWriter.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_3; +package org.altusmetrum.altoslib_4; public interface AltosWriter { diff --git a/altosui/Altos.java b/altosui/Altos.java index 4b171fa7..28038ad6 100644 --- a/altosui/Altos.java +++ b/altosui/Altos.java @@ -20,8 +20,8 @@ package altosui; import java.awt.*; import libaltosJNI.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class Altos extends AltosUILib { diff --git a/altosui/AltosAscent.java b/altosui/AltosAscent.java index 81b08d2c..f6ccbf0c 100644 --- a/altosui/AltosAscent.java +++ b/altosui/AltosAscent.java @@ -19,7 +19,8 @@ package altosui; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosAscent extends JComponent implements AltosFlightDisplay { GridBagLayout layout; diff --git a/altosui/AltosBTDevice.java b/altosui/AltosBTDevice.java index 727a9f66..e920803a 100644 --- a/altosui/AltosBTDevice.java +++ b/altosui/AltosBTDevice.java @@ -17,7 +17,7 @@ package altosui; import libaltosJNI.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altosuilib_2.*; public class AltosBTDevice extends altos_bt_device implements AltosDevice { diff --git a/altosui/AltosBTKnown.java b/altosui/AltosBTKnown.java index 968d72d5..3abbbe08 100644 --- a/altosui/AltosBTKnown.java +++ b/altosui/AltosBTKnown.java @@ -17,8 +17,8 @@ package altosui; import java.util.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosBTKnown implements Iterable { LinkedList devices = new LinkedList(); diff --git a/altosui/AltosBTManage.java b/altosui/AltosBTManage.java index ad1c28b6..e6e7efd4 100644 --- a/altosui/AltosBTManage.java +++ b/altosui/AltosBTManage.java @@ -23,7 +23,7 @@ import javax.swing.*; import javax.swing.plaf.basic.*; import java.util.*; import java.util.concurrent.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altosuilib_2.*; public class AltosBTManage extends AltosUIDialog implements ActionListener, Iterable { LinkedBlockingQueue found_devices; diff --git a/altosui/AltosCSVUI.java b/altosui/AltosCSVUI.java index 95a8aeea..a0fceee5 100644 --- a/altosui/AltosCSVUI.java +++ b/altosui/AltosCSVUI.java @@ -21,8 +21,8 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosCSVUI extends AltosUIDialog diff --git a/altosui/AltosCompanionInfo.java b/altosui/AltosCompanionInfo.java index b90240fb..42413a57 100644 --- a/altosui/AltosCompanionInfo.java +++ b/altosui/AltosCompanionInfo.java @@ -19,7 +19,7 @@ package altosui; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; public class AltosCompanionInfo extends JTable { private AltosFlightInfoTableModel model; diff --git a/altosui/AltosConfig.java b/altosui/AltosConfig.java index e1805fc1..3128114f 100644 --- a/altosui/AltosConfig.java +++ b/altosui/AltosConfig.java @@ -22,8 +22,8 @@ import javax.swing.*; import java.io.*; import java.util.concurrent.*; import java.text.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosConfig implements ActionListener { diff --git a/altosui/AltosConfigFreqUI.java b/altosui/AltosConfigFreqUI.java index 663782f0..c7181e14 100644 --- a/altosui/AltosConfigFreqUI.java +++ b/altosui/AltosConfigFreqUI.java @@ -21,8 +21,8 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; class AltosEditFreqUI extends AltosUIDialog implements ActionListener { Frame frame; diff --git a/altosui/AltosConfigPyroUI.java b/altosui/AltosConfigPyroUI.java index cd42a3b0..9df2d87d 100644 --- a/altosui/AltosConfigPyroUI.java +++ b/altosui/AltosConfigPyroUI.java @@ -21,8 +21,8 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosConfigPyroUI extends AltosUIDialog diff --git a/altosui/AltosConfigTD.java b/altosui/AltosConfigTD.java index ad9ebbfa..bfbd2c77 100644 --- a/altosui/AltosConfigTD.java +++ b/altosui/AltosConfigTD.java @@ -21,8 +21,8 @@ import java.awt.event.*; import javax.swing.*; import java.io.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosConfigTD implements ActionListener { diff --git a/altosui/AltosConfigTDUI.java b/altosui/AltosConfigTDUI.java index 55d6aed9..22b3384d 100644 --- a/altosui/AltosConfigTDUI.java +++ b/altosui/AltosConfigTDUI.java @@ -21,8 +21,8 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosConfigTDUI extends AltosUIDialog diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java index 7f4e1eb0..3ec3cdb0 100644 --- a/altosui/AltosConfigUI.java +++ b/altosui/AltosConfigUI.java @@ -21,8 +21,8 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosConfigUI extends AltosUIDialog diff --git a/altosui/AltosConfigureUI.java b/altosui/AltosConfigureUI.java index 80876959..e61a4a5b 100644 --- a/altosui/AltosConfigureUI.java +++ b/altosui/AltosConfigureUI.java @@ -22,7 +22,7 @@ import java.awt.event.*; import java.beans.*; import javax.swing.*; import javax.swing.event.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altosuilib_2.*; public class AltosConfigureUI extends AltosUIConfigure diff --git a/altosui/AltosDataChooser.java b/altosui/AltosDataChooser.java index a9344a01..43726a44 100644 --- a/altosui/AltosDataChooser.java +++ b/altosui/AltosDataChooser.java @@ -20,8 +20,8 @@ package altosui; import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; import java.io.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosDataChooser extends JFileChooser { JFrame frame; diff --git a/altosui/AltosDescent.java b/altosui/AltosDescent.java index cd993a75..5cb693fe 100644 --- a/altosui/AltosDescent.java +++ b/altosui/AltosDescent.java @@ -19,7 +19,8 @@ package altosui; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosDescent extends JComponent implements AltosFlightDisplay { GridBagLayout layout; diff --git a/altosui/AltosDeviceUIDialog.java b/altosui/AltosDeviceUIDialog.java index ca34357e..307c77f8 100644 --- a/altosui/AltosDeviceUIDialog.java +++ b/altosui/AltosDeviceUIDialog.java @@ -20,7 +20,7 @@ package altosui; import javax.swing.*; import java.awt.*; import java.awt.event.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altosuilib_2.*; public class AltosDeviceUIDialog extends AltosDeviceDialog { diff --git a/altosui/AltosEepromDelete.java b/altosui/AltosEepromDelete.java index b2d2e291..b6ac7edb 100644 --- a/altosui/AltosEepromDelete.java +++ b/altosui/AltosEepromDelete.java @@ -21,7 +21,7 @@ import java.awt.event.*; import javax.swing.*; import java.io.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; public class AltosEepromDelete implements Runnable { AltosEepromList flights; diff --git a/altosui/AltosEepromManage.java b/altosui/AltosEepromManage.java index e3635571..aa43ab9e 100644 --- a/altosui/AltosEepromManage.java +++ b/altosui/AltosEepromManage.java @@ -21,8 +21,8 @@ import java.awt.event.*; import javax.swing.*; import java.io.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosEepromManage implements ActionListener { diff --git a/altosui/AltosEepromMonitor.java b/altosui/AltosEepromMonitor.java index 50921da1..ce1c1625 100644 --- a/altosui/AltosEepromMonitor.java +++ b/altosui/AltosEepromMonitor.java @@ -20,7 +20,7 @@ package altosui; import java.awt.*; import java.awt.event.*; import javax.swing.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altosuilib_2.*; public class AltosEepromMonitor extends AltosUIDialog { diff --git a/altosui/AltosEepromMonitorUI.java b/altosui/AltosEepromMonitorUI.java index c2e925a2..c1c1eb25 100644 --- a/altosui/AltosEepromMonitorUI.java +++ b/altosui/AltosEepromMonitorUI.java @@ -20,8 +20,8 @@ package altosui; import java.awt.*; import java.awt.event.*; import javax.swing.*; -import org.altusmetrum.altosuilib_1.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altosuilib_2.*; +import org.altusmetrum.altoslib_4.*; public class AltosEepromMonitorUI extends AltosUIDialog implements AltosEepromMonitor { JFrame owner; diff --git a/altosui/AltosEepromSelect.java b/altosui/AltosEepromSelect.java index b7cdbb72..66a197c9 100644 --- a/altosui/AltosEepromSelect.java +++ b/altosui/AltosEepromSelect.java @@ -21,8 +21,8 @@ import javax.swing.*; import javax.swing.border.*; import java.awt.*; import java.awt.event.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; class AltosEepromItem implements ActionListener { AltosEepromLog log; diff --git a/altosui/AltosFlashUI.java b/altosui/AltosFlashUI.java index ff9cb95d..d8c70a06 100644 --- a/altosui/AltosFlashUI.java +++ b/altosui/AltosFlashUI.java @@ -23,8 +23,8 @@ import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; import java.io.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosFlashUI extends AltosUIDialog diff --git a/altosui/AltosFlightStatsTable.java b/altosui/AltosFlightStatsTable.java index da71154e..e7a8e728 100644 --- a/altosui/AltosFlightStatsTable.java +++ b/altosui/AltosFlightStatsTable.java @@ -19,7 +19,7 @@ package altosui; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; public class AltosFlightStatsTable extends JComponent { GridBagLayout layout; diff --git a/altosui/AltosFlightStatus.java b/altosui/AltosFlightStatus.java index b467bbde..73b84f8d 100644 --- a/altosui/AltosFlightStatus.java +++ b/altosui/AltosFlightStatus.java @@ -19,7 +19,8 @@ package altosui; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosFlightStatus extends JComponent implements AltosFlightDisplay { GridBagLayout layout; diff --git a/altosui/AltosFlightStatusTableModel.java b/altosui/AltosFlightStatusTableModel.java index e372d401..b33f40a4 100644 --- a/altosui/AltosFlightStatusTableModel.java +++ b/altosui/AltosFlightStatusTableModel.java @@ -27,7 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; public class AltosFlightStatusTableModel extends AbstractTableModel { private String[] columnNames = { diff --git a/altosui/AltosFlightStatusUpdate.java b/altosui/AltosFlightStatusUpdate.java index 93399a13..0daec04e 100644 --- a/altosui/AltosFlightStatusUpdate.java +++ b/altosui/AltosFlightStatusUpdate.java @@ -18,7 +18,7 @@ package altosui; import java.awt.event.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; public class AltosFlightStatusUpdate implements ActionListener { diff --git a/altosui/AltosFlightUI.java b/altosui/AltosFlightUI.java index b31de12c..2bd60d6c 100644 --- a/altosui/AltosFlightUI.java +++ b/altosui/AltosFlightUI.java @@ -21,8 +21,8 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay, AltosFontListener { AltosVoice voice; diff --git a/altosui/AltosGraph.java b/altosui/AltosGraph.java index d5c00247..ba3875c6 100644 --- a/altosui/AltosGraph.java +++ b/altosui/AltosGraph.java @@ -22,8 +22,8 @@ import java.util.ArrayList; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; import org.jfree.ui.*; import org.jfree.chart.*; diff --git a/altosui/AltosGraphDataPoint.java b/altosui/AltosGraphDataPoint.java index a0b0925c..06a9b62d 100644 --- a/altosui/AltosGraphDataPoint.java +++ b/altosui/AltosGraphDataPoint.java @@ -17,8 +17,8 @@ package altosui; -import org.altusmetrum.altosuilib_1.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altosuilib_2.*; +import org.altusmetrum.altoslib_4.*; public class AltosGraphDataPoint implements AltosUIDataPoint { diff --git a/altosui/AltosGraphDataSet.java b/altosui/AltosGraphDataSet.java index d2773a3f..a90c2563 100644 --- a/altosui/AltosGraphDataSet.java +++ b/altosui/AltosGraphDataSet.java @@ -20,8 +20,8 @@ package altosui; import java.lang.*; import java.io.*; import java.util.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; class AltosGraphIterator implements Iterator { AltosGraphDataSet dataSet; diff --git a/altosui/AltosGraphUI.java b/altosui/AltosGraphUI.java index 92b9b94a..33e12130 100644 --- a/altosui/AltosGraphUI.java +++ b/altosui/AltosGraphUI.java @@ -9,8 +9,8 @@ import java.util.ArrayList; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; diff --git a/altosui/AltosIdleMonitorUI.java b/altosui/AltosIdleMonitorUI.java index 7ca935b6..62b50568 100644 --- a/altosui/AltosIdleMonitorUI.java +++ b/altosui/AltosIdleMonitorUI.java @@ -24,8 +24,8 @@ import javax.swing.event.*; import java.io.*; import java.util.concurrent.*; import java.util.Arrays; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDisplay, AltosFontListener, AltosIdleMonitorListener, DocumentListener { AltosDevice device; diff --git a/altosui/AltosIgniteUI.java b/altosui/AltosIgniteUI.java index 3028bb9c..c251bbe2 100644 --- a/altosui/AltosIgniteUI.java +++ b/altosui/AltosIgniteUI.java @@ -24,8 +24,8 @@ import java.io.*; import java.text.*; import java.util.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosIgniteUI extends AltosUIDialog diff --git a/altosui/AltosIgnitor.java b/altosui/AltosIgnitor.java index fcab7427..7f79f42b 100644 --- a/altosui/AltosIgnitor.java +++ b/altosui/AltosIgnitor.java @@ -19,7 +19,8 @@ package altosui; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosIgnitor extends JComponent implements AltosFlightDisplay { GridBagLayout layout; diff --git a/altosui/AltosInfoTable.java b/altosui/AltosInfoTable.java index 3242d652..125fa94c 100644 --- a/altosui/AltosInfoTable.java +++ b/altosui/AltosInfoTable.java @@ -20,7 +20,7 @@ package altosui; import java.awt.*; import javax.swing.*; import javax.swing.table.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; public class AltosInfoTable extends JTable { private AltosFlightInfoTableModel model; diff --git a/altosui/AltosLanded.java b/altosui/AltosLanded.java index 25d768ad..707d8fcc 100644 --- a/altosui/AltosLanded.java +++ b/altosui/AltosLanded.java @@ -21,7 +21,8 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosLanded extends JComponent implements AltosFlightDisplay, ActionListener { GridBagLayout layout; diff --git a/altosui/AltosLaunch.java b/altosui/AltosLaunch.java index 04948ee6..9ac1e44c 100644 --- a/altosui/AltosLaunch.java +++ b/altosui/AltosLaunch.java @@ -20,7 +20,7 @@ package altosui; import java.io.*; import java.util.concurrent.*; import java.awt.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altosuilib_2.*; public class AltosLaunch { AltosDevice device; diff --git a/altosui/AltosLaunchUI.java b/altosui/AltosLaunchUI.java index 4d9fbda5..cc082542 100644 --- a/altosui/AltosLaunchUI.java +++ b/altosui/AltosLaunchUI.java @@ -23,7 +23,7 @@ import javax.swing.*; import java.io.*; import java.text.*; import java.util.concurrent.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altosuilib_2.*; class FireButton extends JButton { protected void processMouseEvent(MouseEvent e) { diff --git a/altosui/AltosPad.java b/altosui/AltosPad.java index 2844b32c..a6ac70db 100644 --- a/altosui/AltosPad.java +++ b/altosui/AltosPad.java @@ -19,7 +19,8 @@ package altosui; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosPad extends JComponent implements AltosFlightDisplay { GridBagLayout layout; diff --git a/altosui/AltosRomconfigUI.java b/altosui/AltosRomconfigUI.java index 89994679..d2fe54d9 100644 --- a/altosui/AltosRomconfigUI.java +++ b/altosui/AltosRomconfigUI.java @@ -20,8 +20,8 @@ package altosui; import java.awt.*; import java.awt.event.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosRomconfigUI extends AltosUIDialog diff --git a/altosui/AltosScanUI.java b/altosui/AltosScanUI.java index 5cc74a77..1f1f59ad 100644 --- a/altosui/AltosScanUI.java +++ b/altosui/AltosScanUI.java @@ -25,8 +25,8 @@ import java.io.*; import java.util.*; import java.text.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; class AltosScanResult { String callsign; diff --git a/altosui/AltosSerial.java b/altosui/AltosSerial.java index 2c5d2dfd..9b2180ba 100644 --- a/altosui/AltosSerial.java +++ b/altosui/AltosSerial.java @@ -25,8 +25,8 @@ import java.io.*; import java.util.*; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; import libaltosJNI.*; diff --git a/altosui/AltosSerialInUseException.java b/altosui/AltosSerialInUseException.java index b45d9157..318155c8 100644 --- a/altosui/AltosSerialInUseException.java +++ b/altosui/AltosSerialInUseException.java @@ -16,7 +16,7 @@ */ package altosui; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altosuilib_2.*; public class AltosSerialInUseException extends Exception { public AltosDevice device; diff --git a/altosui/AltosUI.java b/altosui/AltosUI.java index a1bc83bf..9df02ec9 100644 --- a/altosui/AltosUI.java +++ b/altosui/AltosUI.java @@ -22,8 +22,8 @@ import java.awt.event.*; import javax.swing.*; import java.io.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class AltosUI extends AltosUIFrame { public AltosVoice voice = new AltosVoice(); diff --git a/altosui/AltosUIPreferencesBackend.java b/altosui/AltosUIPreferencesBackend.java index f85735e8..28047086 100644 --- a/altosui/AltosUIPreferencesBackend.java +++ b/altosui/AltosUIPreferencesBackend.java @@ -19,7 +19,7 @@ package altosui; import java.io.File; import java.util.prefs.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; import javax.swing.filechooser.FileSystemView; public class AltosUIPreferencesBackend implements AltosPreferencesBackend { diff --git a/altosuilib/AltosDevice.java b/altosuilib/AltosDevice.java index 2461df1b..251ae994 100644 --- a/altosuilib/AltosDevice.java +++ b/altosuilib/AltosDevice.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; import libaltosJNI.*; diff --git a/altosuilib/AltosDeviceDialog.java b/altosuilib/AltosDeviceDialog.java index 7fb23e13..0bedea97 100644 --- a/altosuilib/AltosDeviceDialog.java +++ b/altosuilib/AltosDeviceDialog.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; import javax.swing.*; import java.awt.*; diff --git a/altosuilib/AltosFontListener.java b/altosuilib/AltosFontListener.java index da903352..a98cc131 100644 --- a/altosuilib/AltosFontListener.java +++ b/altosuilib/AltosFontListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; public interface AltosFontListener { void font_size_changed(int font_size); diff --git a/altosuilib/AltosPositionListener.java b/altosuilib/AltosPositionListener.java index e75d2de5..34cf1650 100644 --- a/altosuilib/AltosPositionListener.java +++ b/altosuilib/AltosPositionListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; public interface AltosPositionListener { public void position_changed(int position); diff --git a/altosuilib/AltosUIAxis.java b/altosuilib/AltosUIAxis.java index 7bc2def9..74561673 100644 --- a/altosuilib/AltosUIAxis.java +++ b/altosuilib/AltosUIAxis.java @@ -15,14 +15,14 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; import java.io.*; import java.util.ArrayList; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; import org.jfree.ui.*; import org.jfree.chart.*; diff --git a/altosuilib/AltosUIConfigure.java b/altosuilib/AltosUIConfigure.java index 153eb8ee..ae7626de 100644 --- a/altosuilib/AltosUIConfigure.java +++ b/altosuilib/AltosUIConfigure.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; import java.awt.*; import java.awt.event.*; diff --git a/altosuilib/AltosUIDataMissing.java b/altosuilib/AltosUIDataMissing.java index c7b01859..353ff30f 100644 --- a/altosuilib/AltosUIDataMissing.java +++ b/altosuilib/AltosUIDataMissing.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; public class AltosUIDataMissing extends Exception { public int id; diff --git a/altosuilib/AltosUIDataPoint.java b/altosuilib/AltosUIDataPoint.java index d3020410..3f16500e 100644 --- a/altosuilib/AltosUIDataPoint.java +++ b/altosuilib/AltosUIDataPoint.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; public interface AltosUIDataPoint { public abstract double x() throws AltosUIDataMissing; diff --git a/altosuilib/AltosUIDataSet.java b/altosuilib/AltosUIDataSet.java index 6f23ef9a..ee70a3fd 100644 --- a/altosuilib/AltosUIDataSet.java +++ b/altosuilib/AltosUIDataSet.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; public interface AltosUIDataSet { public abstract String name(); diff --git a/altosuilib/AltosUIDialog.java b/altosuilib/AltosUIDialog.java index e1e699a7..dc737414 100644 --- a/altosuilib/AltosUIDialog.java +++ b/altosuilib/AltosUIDialog.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; import java.awt.*; import java.awt.event.*; diff --git a/altosuilib/AltosUIEnable.java b/altosuilib/AltosUIEnable.java index 40b5f087..8d42c09b 100644 --- a/altosuilib/AltosUIEnable.java +++ b/altosuilib/AltosUIEnable.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; import java.awt.*; import java.awt.event.*; @@ -23,7 +23,7 @@ import javax.swing.*; import java.io.*; import java.util.concurrent.*; import java.util.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; import org.jfree.ui.*; import org.jfree.chart.*; diff --git a/altosuilib/AltosUIFrame.java b/altosuilib/AltosUIFrame.java index 3dc2a0ad..ce86ad83 100644 --- a/altosuilib/AltosUIFrame.java +++ b/altosuilib/AltosUIFrame.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; import java.awt.*; import java.awt.event.*; diff --git a/altosuilib/AltosUIGraph.java b/altosuilib/AltosUIGraph.java index 21e13cf6..909c471b 100644 --- a/altosuilib/AltosUIGraph.java +++ b/altosuilib/AltosUIGraph.java @@ -15,14 +15,14 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; import java.io.*; import java.util.ArrayList; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; import org.jfree.ui.*; import org.jfree.chart.*; diff --git a/altosuilib/AltosUIGrapher.java b/altosuilib/AltosUIGrapher.java index 54f8d5a9..724fac18 100644 --- a/altosuilib/AltosUIGrapher.java +++ b/altosuilib/AltosUIGrapher.java @@ -15,14 +15,14 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; import java.io.*; import java.util.ArrayList; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; import org.jfree.ui.*; import org.jfree.chart.*; diff --git a/altosuilib/AltosUILib.java b/altosuilib/AltosUILib.java index 76782e2e..b51c5963 100644 --- a/altosuilib/AltosUILib.java +++ b/altosuilib/AltosUILib.java @@ -15,12 +15,12 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; import java.awt.*; import libaltosJNI.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; public class AltosUILib extends AltosLib { diff --git a/altosuilib/AltosUIListener.java b/altosuilib/AltosUIListener.java index 450dc0bf..75a0ad94 100644 --- a/altosuilib/AltosUIListener.java +++ b/altosuilib/AltosUIListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; public interface AltosUIListener { public void ui_changed(String look_and_feel); diff --git a/altosuilib/AltosUIMarker.java b/altosuilib/AltosUIMarker.java index efd27921..cd6fa589 100644 --- a/altosuilib/AltosUIMarker.java +++ b/altosuilib/AltosUIMarker.java @@ -15,14 +15,14 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; import java.io.*; import java.util.ArrayList; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; import org.jfree.ui.*; import org.jfree.chart.*; diff --git a/altosuilib/AltosUIPreferences.java b/altosuilib/AltosUIPreferences.java index 4c995f80..7a582a7d 100644 --- a/altosuilib/AltosUIPreferences.java +++ b/altosuilib/AltosUIPreferences.java @@ -15,13 +15,13 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; import java.io.*; import java.util.*; import java.awt.Component; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; public class AltosUIPreferences extends AltosPreferences { diff --git a/altosuilib/AltosUIPreferencesBackend.java b/altosuilib/AltosUIPreferencesBackend.java index d6575717..da29253d 100644 --- a/altosuilib/AltosUIPreferencesBackend.java +++ b/altosuilib/AltosUIPreferencesBackend.java @@ -15,11 +15,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; import java.io.File; import java.util.prefs.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; import javax.swing.filechooser.FileSystemView; public class AltosUIPreferencesBackend implements AltosPreferencesBackend { diff --git a/altosuilib/AltosUISeries.java b/altosuilib/AltosUISeries.java index 10ea1614..b0632d18 100644 --- a/altosuilib/AltosUISeries.java +++ b/altosuilib/AltosUISeries.java @@ -15,14 +15,14 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; import java.io.*; import java.util.ArrayList; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; +import org.altusmetrum.altoslib_4.*; import org.jfree.ui.*; import org.jfree.chart.*; diff --git a/altosuilib/AltosUIVersion.java.in b/altosuilib/AltosUIVersion.java.in index 169cca1b..3f629560 100644 --- a/altosuilib/AltosUIVersion.java.in +++ b/altosuilib/AltosUIVersion.java.in @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; public class AltosUIVersion { public final static String version = "@VERSION@"; diff --git a/altosuilib/AltosUSBDevice.java b/altosuilib/AltosUSBDevice.java index 4f329840..b70b5e83 100644 --- a/altosuilib/AltosUSBDevice.java +++ b/altosuilib/AltosUSBDevice.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_1; +package org.altusmetrum.altosuilib_2; import java.util.*; import libaltosJNI.*; diff --git a/configure.ac b/configure.ac index 01867e9f..d2d87754 100644 --- a/configure.ac +++ b/configure.ac @@ -29,8 +29,8 @@ AC_SUBST(VERSION_DASH) dnl ========================================================================== dnl Java library versions -ALTOSUILIB_VERSION=1 -ALTOSLIB_VERSION=3 +ALTOSUILIB_VERSION=2 +ALTOSLIB_VERSION=4 AC_SUBST(ALTOSLIB_VERSION) AC_DEFINE(ALTOSLIB_VERSION,$ALTOSLIB_VERSION,[Version of the AltosLib package]) diff --git a/micropeak/MicroData.java b/micropeak/MicroData.java index e786ff1e..ca211f16 100644 --- a/micropeak/MicroData.java +++ b/micropeak/MicroData.java @@ -20,8 +20,8 @@ package org.altusmetrum.micropeak; import java.lang.*; import java.io.*; import java.util.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; class MicroIterator implements Iterator { int i; diff --git a/micropeak/MicroDataPoint.java b/micropeak/MicroDataPoint.java index 61faf794..5a5e8c37 100644 --- a/micropeak/MicroDataPoint.java +++ b/micropeak/MicroDataPoint.java @@ -17,7 +17,7 @@ package org.altusmetrum.micropeak; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altosuilib_2.*; public class MicroDataPoint implements AltosUIDataPoint { public double time; diff --git a/micropeak/MicroDeviceDialog.java b/micropeak/MicroDeviceDialog.java index 533605d6..305421a7 100644 --- a/micropeak/MicroDeviceDialog.java +++ b/micropeak/MicroDeviceDialog.java @@ -21,7 +21,7 @@ import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altosuilib_2.*; public class MicroDeviceDialog extends AltosDeviceDialog { diff --git a/micropeak/MicroDownload.java b/micropeak/MicroDownload.java index 7d2e9eb4..1c70e1d1 100644 --- a/micropeak/MicroDownload.java +++ b/micropeak/MicroDownload.java @@ -23,8 +23,8 @@ import javax.swing.*; import java.io.*; import java.util.concurrent.*; import java.util.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class MicroDownload extends AltosUIDialog implements Runnable, ActionListener, MicroSerialLog, WindowListener { MicroPeak owner; diff --git a/micropeak/MicroExport.java b/micropeak/MicroExport.java index c170f544..87d5499b 100644 --- a/micropeak/MicroExport.java +++ b/micropeak/MicroExport.java @@ -23,8 +23,8 @@ import java.util.ArrayList; import java.awt.*; import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class MicroExport extends JFileChooser { diff --git a/micropeak/MicroFile.java b/micropeak/MicroFile.java index b6a9d401..019346ae 100644 --- a/micropeak/MicroFile.java +++ b/micropeak/MicroFile.java @@ -19,8 +19,8 @@ package org.altusmetrum.micropeak; import java.io.*; import java.util.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class MicroFile { diff --git a/micropeak/MicroFileChooser.java b/micropeak/MicroFileChooser.java index 595d1ff7..00b6690a 100644 --- a/micropeak/MicroFileChooser.java +++ b/micropeak/MicroFileChooser.java @@ -20,8 +20,8 @@ package org.altusmetrum.micropeak; import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; import java.io.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class MicroFileChooser extends JFileChooser { JFrame frame; diff --git a/micropeak/MicroFrame.java b/micropeak/MicroFrame.java index ef8b24cc..5bfe5bf7 100644 --- a/micropeak/MicroFrame.java +++ b/micropeak/MicroFrame.java @@ -21,7 +21,7 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altosuilib_2.*; public class MicroFrame extends AltosUIFrame { static String[] micro_icon_names = { diff --git a/micropeak/MicroGraph.java b/micropeak/MicroGraph.java index 5960fe4d..f9968919 100644 --- a/micropeak/MicroGraph.java +++ b/micropeak/MicroGraph.java @@ -22,8 +22,8 @@ import java.util.ArrayList; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; import org.jfree.ui.*; import org.jfree.chart.*; diff --git a/micropeak/MicroPeak.java b/micropeak/MicroPeak.java index 78bc857e..19e91660 100644 --- a/micropeak/MicroPeak.java +++ b/micropeak/MicroPeak.java @@ -23,8 +23,8 @@ import javax.swing.*; import java.io.*; import java.util.concurrent.*; import java.util.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class MicroPeak extends MicroFrame implements ActionListener, ItemListener { diff --git a/micropeak/MicroRaw.java b/micropeak/MicroRaw.java index d64da387..26d62012 100644 --- a/micropeak/MicroRaw.java +++ b/micropeak/MicroRaw.java @@ -20,8 +20,8 @@ package org.altusmetrum.micropeak; import java.awt.*; import java.io.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class MicroRaw extends JTextArea { diff --git a/micropeak/MicroSave.java b/micropeak/MicroSave.java index 0addfa88..7c5d6abe 100644 --- a/micropeak/MicroSave.java +++ b/micropeak/MicroSave.java @@ -24,8 +24,8 @@ import javax.swing.filechooser.FileNameExtensionFilter; import java.io.*; import java.util.concurrent.*; import java.util.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class MicroSave extends JFileChooser { diff --git a/micropeak/MicroSerial.java b/micropeak/MicroSerial.java index 39f421ec..37b68636 100644 --- a/micropeak/MicroSerial.java +++ b/micropeak/MicroSerial.java @@ -20,7 +20,7 @@ package org.altusmetrum.micropeak; import java.util.*; import java.io.*; import libaltosJNI.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altosuilib_2.*; public class MicroSerial extends InputStream { SWIGTYPE_p_altos_file file; diff --git a/micropeak/MicroSerialLog.java b/micropeak/MicroSerialLog.java index 0a5a0b91..7300f06d 100644 --- a/micropeak/MicroSerialLog.java +++ b/micropeak/MicroSerialLog.java @@ -20,7 +20,7 @@ package org.altusmetrum.micropeak; import java.util.*; import java.io.*; import libaltosJNI.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altosuilib_2.*; public interface MicroSerialLog { diff --git a/micropeak/MicroStats.java b/micropeak/MicroStats.java index 765525b0..45c9f225 100644 --- a/micropeak/MicroStats.java +++ b/micropeak/MicroStats.java @@ -18,8 +18,8 @@ package org.altusmetrum.micropeak; import java.io.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class MicroStats { double coast_height; diff --git a/micropeak/MicroStatsTable.java b/micropeak/MicroStatsTable.java index ea1609ac..268a7ff0 100644 --- a/micropeak/MicroStatsTable.java +++ b/micropeak/MicroStatsTable.java @@ -19,8 +19,8 @@ package org.altusmetrum.micropeak; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_3.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; public class MicroStatsTable extends JComponent implements AltosFontListener { GridBagLayout layout; diff --git a/micropeak/MicroUSB.java b/micropeak/MicroUSB.java index 3bd61470..437fa0bc 100644 --- a/micropeak/MicroUSB.java +++ b/micropeak/MicroUSB.java @@ -19,7 +19,7 @@ package org.altusmetrum.micropeak; import java.util.*; import libaltosJNI.*; -import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altosuilib_2.*; public class MicroUSB extends altos_device implements AltosDevice { -- cgit v1.2.3 From 4a5ef9eaa8b809c56813625133120e7e91fc8e65 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 28 May 2014 02:06:18 -0700 Subject: altoslib: When log-format is missing, use product log-format was added for 1.0; earlier log files don't include that, but do say which product they're from. Signed-off-by: Keith Packard --- altoslib/AltosEepromFile.java | 11 ++++++++++- altoslib/AltosEepromHeader.java | 1 + altoslib/AltosState.java | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) (limited to 'altoslib') diff --git a/altoslib/AltosEepromFile.java b/altoslib/AltosEepromFile.java index 2a26c484..1664dc95 100644 --- a/altoslib/AltosEepromFile.java +++ b/altoslib/AltosEepromFile.java @@ -74,6 +74,15 @@ public class AltosEepromFile extends AltosStateIterable { start = headers.state(); start.set_state(AltosLib.ao_flight_pad); + if (start.log_format == AltosLib.MISSING) { + if (start.product != null) { + if (start.product.startsWith("TeleMetrum")) + start.log_format = AltosLib.AO_LOG_FORMAT_FULL; + else if (start.product.startsWith("TeleMini")) + start.log_format = AltosLib.AO_LOG_FORMAT_TINY; + } + } + switch (start.log_format) { case AltosLib.AO_LOG_FORMAT_FULL: body = new AltosEepromIterable(AltosEepromTM.read(input)); @@ -120,4 +129,4 @@ public class AltosEepromFile extends AltosStateIterable { } return new AltosEepromIterator(state, i); } -} \ No newline at end of file +} diff --git a/altoslib/AltosEepromHeader.java b/altoslib/AltosEepromHeader.java index 0d022f46..ea6f5e28 100644 --- a/altoslib/AltosEepromHeader.java +++ b/altoslib/AltosEepromHeader.java @@ -53,6 +53,7 @@ public class AltosEepromHeader extends AltosEeprom { case AltosLib.AO_LOG_MANUFACTURER: break; case AltosLib.AO_LOG_PRODUCT: + state.product = data; break; case AltosLib.AO_LOG_LOG_FORMAT: state.log_format = config_a; diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index 71263151..9e8e22ac 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -614,6 +614,7 @@ public class AltosState implements Cloneable { public double ground_accel_avg; public int log_format; + public String product; public AltosMs5607 baro; @@ -708,6 +709,7 @@ public class AltosState implements Cloneable { ground_accel_avg = AltosLib.MISSING; log_format = AltosLib.MISSING; + product = null; serial = AltosLib.MISSING; receiver_serial = AltosLib.MISSING; @@ -839,6 +841,7 @@ public class AltosState implements Cloneable { ground_accel_avg = old.ground_accel_avg; log_format = old.log_format; + product = old.product; serial = old.serial; receiver_serial = old.receiver_serial; -- cgit v1.2.3 From 3871b9ac036e3adfa1da089245fc7973b268c921 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 28 May 2014 21:56:52 -0700 Subject: telegps: Add 'Info' tab This contains a summary of the tracking info, including position, speed and course. Signed-off-by: Keith Packard --- altoslib/AltosConvert.java | 26 ++ altoslib/AltosGreatCircle.java | 26 +- altoslib/AltosState.java | 24 ++ altosui/AltosCSVUI.java | 104 -------- altosui/AltosDataChooser.java | 83 ------- altosui/AltosLed.java | 45 ---- altosui/AltosLights.java | 65 ----- altosui/Makefile.am | 15 +- altosuilib/AltosCSVUI.java | 103 ++++++++ altosuilib/AltosDataChooser.java | 82 +++++++ altosuilib/AltosLed.java | 45 ++++ altosuilib/AltosLights.java | 65 +++++ altosuilib/Makefile.am | 20 +- icon/telegps-128.png | Bin 0 -> 8736 bytes icon/telegps-16.png | Bin 0 -> 507 bytes icon/telegps-256.png | Bin 0 -> 21589 bytes icon/telegps-32.png | Bin 0 -> 1475 bytes icon/telegps-48.png | Bin 0 -> 2507 bytes icon/telegps-512.png | Bin 0 -> 56581 bytes icon/telegps-64.png | Bin 0 -> 3678 bytes icon/telegps.ico | Bin 0 -> 285478 bytes icon/telegps.svg | 215 ++++++++++++++++ telegps/Makefile.am | 1 + telegps/TeleGPS.java | 13 + telegps/TeleGPSInfo.java | 511 +++++++++++++++++++++++++++++++++++++++ 25 files changed, 1109 insertions(+), 334 deletions(-) delete mode 100644 altosui/AltosCSVUI.java delete mode 100644 altosui/AltosDataChooser.java delete mode 100644 altosui/AltosLed.java delete mode 100644 altosui/AltosLights.java create mode 100644 altosuilib/AltosCSVUI.java create mode 100644 altosuilib/AltosDataChooser.java create mode 100644 altosuilib/AltosLed.java create mode 100644 altosuilib/AltosLights.java create mode 100644 icon/telegps-128.png create mode 100644 icon/telegps-16.png create mode 100644 icon/telegps-256.png create mode 100644 icon/telegps-32.png create mode 100644 icon/telegps-48.png create mode 100644 icon/telegps-512.png create mode 100644 icon/telegps-64.png create mode 100644 icon/telegps.ico create mode 100644 icon/telegps.svg create mode 100644 telegps/TeleGPSInfo.java (limited to 'altoslib') diff --git a/altoslib/AltosConvert.java b/altoslib/AltosConvert.java index 484f6213..a65669da 100644 --- a/altoslib/AltosConvert.java +++ b/altoslib/AltosConvert.java @@ -371,4 +371,30 @@ public class AltosConvert { return 94; return (int) Math.floor (1.0/2.0 * (24.0e6/32.0) / freq + 0.5); } + + public static final int BEARING_LONG = 0; + public static final int BEARING_SHORT = 1; + public static final int BEARING_VOICE = 2; + + public static String bearing_to_words(int length, double bearing) { + String [][] bearing_string = { + { + "North", "North North East", "North East", "East North East", + "East", "East South East", "South East", "South South East", + "South", "South South West", "South West", "West South West", + "West", "West North West", "North West", "North North West" + }, { + "N", "NNE", "NE", "ENE", + "E", "ESE", "SE", "SSE", + "S", "SSW", "SW", "WSW", + "W", "WNW", "NW", "NNW" + }, { + "north", "nor nor east", "north east", "east nor east", + "east", "east sow east", "south east", "sow sow east", + "south", "sow sow west", "south west", "west sow west", + "west", "west nor west", "north west", "nor nor west " + } + }; + return bearing_string[length][(int)((bearing / 90 * 8 + 1) / 2)%16]; + } } diff --git a/altoslib/AltosGreatCircle.java b/altoslib/AltosGreatCircle.java index 39df4fc8..4782c34d 100644 --- a/altoslib/AltosGreatCircle.java +++ b/altoslib/AltosGreatCircle.java @@ -30,30 +30,12 @@ public class AltosGreatCircle implements Cloneable { static final double rad = Math.PI / 180; static final double earth_radius = 6371.2 * 1000; /* in meters */ - public static final int BEARING_LONG = 0; - public static final int BEARING_SHORT = 1; - public static final int BEARING_VOICE = 2; + public static final int BEARING_LONG = AltosConvert.BEARING_LONG; + public static final int BEARING_SHORT = AltosConvert.BEARING_SHORT; + public static final int BEARING_VOICE = AltosConvert.BEARING_VOICE; public String bearing_words(int length) { - String [][] bearing_string = { - { - "North", "North North East", "North East", "East North East", - "East", "East South East", "South East", "South South East", - "South", "South South West", "South West", "West South West", - "West", "West North West", "North West", "North North West" - }, { - "N", "NNE", "NE", "ENE", - "E", "ESE", "SE", "SSE", - "S", "SSW", "SW", "WSW", - "W", "WNW", "NW", "NNW" - }, { - "north", "nor nor east", "north east", "east nor east", - "east", "east sow east", "south east", "sow sow east", - "south", "sow sow west", "south west", "west sow west", - "west", "west nor west", "north west", "nor nor west " - } - }; - return bearing_string[length][(int)((bearing / 90 * 8 + 1) / 2)%16]; + return AltosConvert.bearing_to_words(length, bearing); } public AltosGreatCircle (double start_lat, double start_lon, double start_alt, diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index 9e8e22ac..1162e522 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -389,6 +389,10 @@ public class AltosState implements Cloneable { private AltosGpsAltitude gps_altitude; + private AltosValue gps_ground_speed; + private AltosValue gps_ascent_rate; + private AltosValue gps_course; + public double altitude() { double a = altitude.value(); if (a != AltosLib.MISSING) @@ -419,6 +423,18 @@ public class AltosState implements Cloneable { gps_altitude.set(new_gps_altitude, time); } + public double gps_ground_speed() { + return gps_ground_speed.value(); + } + + public double gps_ascent_rate() { + return gps_ascent_rate.value(); + } + + public double gps_course() { + return gps_course.value(); + } + class AltosPressure extends AltosValue { void set(double p, double time) { super.set(p, time); @@ -695,6 +711,8 @@ public class AltosState implements Cloneable { gps_altitude = new AltosGpsAltitude(); gps_ground_altitude = new AltosGpsGroundAltitude(); + gps_ground_speed = new AltosValue(); + gps_ascent_rate = new AltosValue(); speak_tick = AltosLib.MISSING; speak_altitude = AltosLib.MISSING; @@ -877,6 +895,12 @@ public class AltosState implements Cloneable { gps_ground_altitude.set(gps.alt, time); } gps_altitude.set(gps.alt, time); + if (gps.climb_rate != AltosLib.MISSING) + gps_ascent_rate.set(gps.climb_rate, time); + if (gps.ground_speed != AltosLib.MISSING) + gps_ground_speed.set(gps.ground_speed, time); + if (gps.course != AltosLib.MISSING) + gps_course.set(gps.course, time); } if (gps.lat != 0 && gps.lon != 0 && pad_lat != AltosLib.MISSING && diff --git a/altosui/AltosCSVUI.java b/altosui/AltosCSVUI.java deleted file mode 100644 index a0fceee5..00000000 --- a/altosui/AltosCSVUI.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright © 2010 Keith Packard - * - * 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 altosui; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import java.io.*; -import org.altusmetrum.altoslib_4.*; -import org.altusmetrum.altosuilib_2.*; - -public class AltosCSVUI - extends AltosUIDialog - implements ActionListener -{ - JFileChooser csv_chooser; - JPanel accessory; - JComboBox combo_box; - Iterable states; - AltosWriter writer; - - static String[] combo_box_items = { "Comma Separated Values (.CSV)", "Googleearth Data (.KML)" }; - - void set_default_file() { - File current = csv_chooser.getSelectedFile(); - String current_name = current.getName(); - String new_name = null; - String selected = (String) combo_box.getSelectedItem(); - - if (selected.contains("CSV")) - new_name = Altos.replace_extension(current_name, ".csv"); - else if (selected.contains("KML")) - new_name = Altos.replace_extension(current_name, ".kml"); - if (new_name != null) - csv_chooser.setSelectedFile(new File(new_name)); - } - - public void actionPerformed(ActionEvent e) { - if (e.getActionCommand().equals("comboBoxChanged")) - set_default_file(); - } - - public AltosCSVUI(JFrame frame, AltosStateIterable states, File source_file) { - this.states = states; - csv_chooser = new JFileChooser(source_file); - - accessory = new JPanel(); - accessory.setLayout(new GridBagLayout()); - - GridBagConstraints c = new GridBagConstraints(); - c.fill = GridBagConstraints.NONE; - c.weightx = 1; - c.weighty = 0; - c.insets = new Insets (4, 4, 4, 4); - - JLabel accessory_label = new JLabel("Export File Type"); - c.gridx = 0; - c.gridy = 0; - accessory.add(accessory_label, c); - - combo_box = new JComboBox(combo_box_items); - combo_box.addActionListener(this); - c.gridx = 0; - c.gridy = 1; - accessory.add(combo_box, c); - - csv_chooser.setAccessory(accessory); - csv_chooser.setSelectedFile(source_file); - set_default_file(); - int ret = csv_chooser.showSaveDialog(frame); - if (ret == JFileChooser.APPROVE_OPTION) { - File file = csv_chooser.getSelectedFile(); - String type = (String) combo_box.getSelectedItem(); - try { - if (type.contains("CSV")) - writer = new AltosCSV(file); - else - writer = new AltosKML(file); - writer.write(states); - writer.close(); - } catch (FileNotFoundException ee) { - JOptionPane.showMessageDialog(frame, - ee.getMessage(), - "Cannot open file", - JOptionPane.ERROR_MESSAGE); - } - } - } -} diff --git a/altosui/AltosDataChooser.java b/altosui/AltosDataChooser.java deleted file mode 100644 index 43726a44..00000000 --- a/altosui/AltosDataChooser.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright © 2010 Keith Packard - * - * 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 altosui; - -import javax.swing.*; -import javax.swing.filechooser.FileNameExtensionFilter; -import java.io.*; -import org.altusmetrum.altoslib_4.*; -import org.altusmetrum.altosuilib_2.*; - -public class AltosDataChooser extends JFileChooser { - JFrame frame; - String filename; - File file; - - public String filename() { - return filename; - } - - public File file() { - return file; - } - - public AltosStateIterable runDialog() { - int ret; - - ret = showOpenDialog(frame); - if (ret == APPROVE_OPTION) { - file = getSelectedFile(); - if (file == null) - return null; - filename = file.getName(); - try { - if (filename.endsWith("eeprom")) { - FileInputStream in = new FileInputStream(file); - return new AltosEepromFile(in); - } else if (filename.endsWith("telem")) { - FileInputStream in = new FileInputStream(file); - return new AltosTelemetryFile(in); - } else { - throw new FileNotFoundException(); - } - } catch (FileNotFoundException fe) { - JOptionPane.showMessageDialog(frame, - fe.getMessage(), - "Cannot open file", - JOptionPane.ERROR_MESSAGE); - } - } - return null; - } - - public AltosDataChooser(JFrame in_frame) { - frame = in_frame; - setDialogTitle("Select Flight Record File"); - setFileFilter(new FileNameExtensionFilter("TeleMetrum eeprom file", - "eeprom")); - setFileFilter(new FileNameExtensionFilter("Telemetry file", - "telem")); - setFileFilter(new FileNameExtensionFilter("TeleMega eeprom file", - "mega")); - setFileFilter(new FileNameExtensionFilter("EasyMini eeprom file", - "mini")); - setFileFilter(new FileNameExtensionFilter("Flight data file", - "telem", "eeprom", "mega", "mini")); - setCurrentDirectory(AltosUIPreferences.logdir()); - } -} diff --git a/altosui/AltosLed.java b/altosui/AltosLed.java deleted file mode 100644 index 93064f1e..00000000 --- a/altosui/AltosLed.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright © 2010 Keith Packard - * - * 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 altosui; - -import javax.swing.*; - -public class AltosLed extends JLabel { - ImageIcon on, off; - - ImageIcon create_icon(String path) { - java.net.URL imgURL = AltosUI.class.getResource(path); - if (imgURL != null) - return new ImageIcon(imgURL); - System.err.printf("Cannot find icon \"%s\"\n", path); - return null; - } - - public void set(boolean set) { - if (set) - setIcon(on); - else - setIcon(off); - } - - public AltosLed(String on_path, String off_path) { - on = create_icon(on_path); - off = create_icon(off_path); - setIcon(off); - } -} diff --git a/altosui/AltosLights.java b/altosui/AltosLights.java deleted file mode 100644 index 7ad22f3e..00000000 --- a/altosui/AltosLights.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright © 2010 Keith Packard - * - * 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 altosui; - -import java.awt.*; -import javax.swing.*; - -public class AltosLights extends JComponent { - - GridBagLayout gridbag; - - AltosLed red, green; - - ImageIcon create_icon(String path, String description) { - java.net.URL imgURL = AltosUI.class.getResource(path); - if (imgURL != null) - return new ImageIcon(imgURL, description); - System.err.printf("Cannot find icon \"%s\"\n", path); - return null; - } - - public void set (boolean on) { - if (on) { - red.set(false); - green.set(true); - } else { - red.set(true); - green.set(false); - } - } - - public AltosLights() { - GridBagConstraints c; - gridbag = new GridBagLayout(); - setLayout(gridbag); - - c = new GridBagConstraints(); - red = new AltosLed("/redled.png", "/grayled.png"); - c.gridx = 0; c.gridy = 0; - c.insets = new Insets (0, 5, 0, 5); - gridbag.setConstraints(red, c); - add(red); - red.set(true); - green = new AltosLed("/greenled.png", "/grayled.png"); - c.gridx = 1; c.gridy = 0; - gridbag.setConstraints(green, c); - add(green); - green.set(false); - } -} diff --git a/altosui/Makefile.am b/altosui/Makefile.am index c834646d..9eff1614 100644 --- a/altosui/Makefile.am +++ b/altosui/Makefile.am @@ -20,7 +20,6 @@ altosui_JAVA = \ AltosConfigureUI.java \ AltosConfigTD.java \ AltosConfigTDUI.java \ - AltosCSVUI.java \ AltosDescent.java \ AltosFlashUI.java \ AltosFlightInfoTableModel.java \ @@ -36,8 +35,6 @@ altosui_JAVA = \ AltosLaunchUI.java \ AltosInfoTable.java \ AltosLanded.java \ - AltosLed.java \ - AltosLights.java \ AltosPad.java \ AltosUIPreferencesBackend.java \ AltosRomconfigUI.java \ @@ -45,8 +42,7 @@ altosui_JAVA = \ AltosGraph.java \ AltosGraphDataPoint.java \ AltosGraphDataSet.java \ - AltosGraphUI.java \ - AltosDataChooser.java + AltosGraphUI.java JFREECHART_CLASS= \ jfreechart.jar @@ -94,20 +90,13 @@ JAVA_ICONS=\ $(ICONDIR)/altus-metrum-128.png \ $(ICONDIR)/altus-metrum-256.png -ICONS= $(ICONDIR)/redled.png $(ICONDIR)/redoff.png \ - $(ICONDIR)/greenled.png $(ICONDIR)/greenoff.png \ - $(ICONDIR)/grayled.png $(ICONDIR)/grayoff.png - # icon base names for jar ICONJAR= -C $(ICONDIR) altus-metrum-16.png \ -C $(ICONDIR) altus-metrum-32.png \ -C $(ICONDIR) altus-metrum-48.png \ -C $(ICONDIR) altus-metrum-64.png \ -C $(ICONDIR) altus-metrum-128.png \ - -C $(ICONDIR) altus-metrum-256.png \ - -C $(ICONDIR) redled.png -C $(ICONDIR) redoff.png \ - -C $(ICONDIR) greenled.png -C $(ICONDIR) greenoff.png \ - -C $(ICONDIR) grayon.png -C $(ICONDIR) grayled.png + -C $(ICONDIR) altus-metrum-256.png WINDOWS_ICON=$(ICONDIR)/altus-metrum.ico diff --git a/altosuilib/AltosCSVUI.java b/altosuilib/AltosCSVUI.java new file mode 100644 index 00000000..0a5e4fa2 --- /dev/null +++ b/altosuilib/AltosCSVUI.java @@ -0,0 +1,103 @@ +/* + * Copyright © 2010 Keith Packard + * + * 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.altosuilib_2; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import java.io.*; +import org.altusmetrum.altoslib_4.*; + +public class AltosCSVUI + extends AltosUIDialog + implements ActionListener +{ + JFileChooser csv_chooser; + JPanel accessory; + JComboBox combo_box; + Iterable states; + AltosWriter writer; + + static String[] combo_box_items = { "Comma Separated Values (.CSV)", "Googleearth Data (.KML)" }; + + void set_default_file() { + File current = csv_chooser.getSelectedFile(); + String current_name = current.getName(); + String new_name = null; + String selected = (String) combo_box.getSelectedItem(); + + if (selected.contains("CSV")) + new_name = AltosLib.replace_extension(current_name, ".csv"); + else if (selected.contains("KML")) + new_name = AltosLib.replace_extension(current_name, ".kml"); + if (new_name != null) + csv_chooser.setSelectedFile(new File(new_name)); + } + + public void actionPerformed(ActionEvent e) { + if (e.getActionCommand().equals("comboBoxChanged")) + set_default_file(); + } + + public AltosCSVUI(JFrame frame, AltosStateIterable states, File source_file) { + this.states = states; + csv_chooser = new JFileChooser(source_file); + + accessory = new JPanel(); + accessory.setLayout(new GridBagLayout()); + + GridBagConstraints c = new GridBagConstraints(); + c.fill = GridBagConstraints.NONE; + c.weightx = 1; + c.weighty = 0; + c.insets = new Insets (4, 4, 4, 4); + + JLabel accessory_label = new JLabel("Export File Type"); + c.gridx = 0; + c.gridy = 0; + accessory.add(accessory_label, c); + + combo_box = new JComboBox(combo_box_items); + combo_box.addActionListener(this); + c.gridx = 0; + c.gridy = 1; + accessory.add(combo_box, c); + + csv_chooser.setAccessory(accessory); + csv_chooser.setSelectedFile(source_file); + set_default_file(); + int ret = csv_chooser.showSaveDialog(frame); + if (ret == JFileChooser.APPROVE_OPTION) { + File file = csv_chooser.getSelectedFile(); + String type = (String) combo_box.getSelectedItem(); + try { + if (type.contains("CSV")) + writer = new AltosCSV(file); + else + writer = new AltosKML(file); + writer.write(states); + writer.close(); + } catch (FileNotFoundException ee) { + JOptionPane.showMessageDialog(frame, + ee.getMessage(), + "Cannot open file", + JOptionPane.ERROR_MESSAGE); + } + } + } +} diff --git a/altosuilib/AltosDataChooser.java b/altosuilib/AltosDataChooser.java new file mode 100644 index 00000000..14d28115 --- /dev/null +++ b/altosuilib/AltosDataChooser.java @@ -0,0 +1,82 @@ +/* + * Copyright © 2010 Keith Packard + * + * 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.altosuilib_2; + +import javax.swing.*; +import javax.swing.filechooser.FileNameExtensionFilter; +import java.io.*; +import org.altusmetrum.altoslib_4.*; + +public class AltosDataChooser extends JFileChooser { + JFrame frame; + String filename; + File file; + + public String filename() { + return filename; + } + + public File file() { + return file; + } + + public AltosStateIterable runDialog() { + int ret; + + ret = showOpenDialog(frame); + if (ret == APPROVE_OPTION) { + file = getSelectedFile(); + if (file == null) + return null; + filename = file.getName(); + try { + if (filename.endsWith("eeprom")) { + FileInputStream in = new FileInputStream(file); + return new AltosEepromFile(in); + } else if (filename.endsWith("telem")) { + FileInputStream in = new FileInputStream(file); + return new AltosTelemetryFile(in); + } else { + throw new FileNotFoundException(); + } + } catch (FileNotFoundException fe) { + JOptionPane.showMessageDialog(frame, + fe.getMessage(), + "Cannot open file", + JOptionPane.ERROR_MESSAGE); + } + } + return null; + } + + public AltosDataChooser(JFrame in_frame) { + frame = in_frame; + setDialogTitle("Select Flight Record File"); + setFileFilter(new FileNameExtensionFilter("TeleMetrum eeprom file", + "eeprom")); + setFileFilter(new FileNameExtensionFilter("Telemetry file", + "telem")); + setFileFilter(new FileNameExtensionFilter("TeleMega eeprom file", + "mega")); + setFileFilter(new FileNameExtensionFilter("EasyMini eeprom file", + "mini")); + setFileFilter(new FileNameExtensionFilter("Flight data file", + "telem", "eeprom", "mega", "mini")); + setCurrentDirectory(AltosUIPreferences.logdir()); + } +} diff --git a/altosuilib/AltosLed.java b/altosuilib/AltosLed.java new file mode 100644 index 00000000..2debb62a --- /dev/null +++ b/altosuilib/AltosLed.java @@ -0,0 +1,45 @@ +/* + * Copyright © 2010 Keith Packard + * + * 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.altosuilib_2; + +import javax.swing.*; + +public class AltosLed extends JLabel { + ImageIcon on, off; + + ImageIcon create_icon(String path) { + java.net.URL imgURL = AltosUILib.class.getResource(path); + if (imgURL != null) + return new ImageIcon(imgURL); + System.err.printf("Cannot find icon \"%s\"\n", path); + return null; + } + + public void set(boolean set) { + if (set) + setIcon(on); + else + setIcon(off); + } + + public AltosLed(String on_path, String off_path) { + on = create_icon(on_path); + off = create_icon(off_path); + setIcon(off); + } +} diff --git a/altosuilib/AltosLights.java b/altosuilib/AltosLights.java new file mode 100644 index 00000000..c91b70e9 --- /dev/null +++ b/altosuilib/AltosLights.java @@ -0,0 +1,65 @@ +/* + * Copyright © 2010 Keith Packard + * + * 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.altosuilib_2; + +import java.awt.*; +import javax.swing.*; + +public class AltosLights extends JComponent { + + GridBagLayout gridbag; + + AltosLed red, green; + + ImageIcon create_icon(String path, String description) { + java.net.URL imgURL = AltosUILib.class.getResource(path); + if (imgURL != null) + return new ImageIcon(imgURL, description); + System.err.printf("Cannot find icon \"%s\"\n", path); + return null; + } + + public void set (boolean on) { + if (on) { + red.set(false); + green.set(true); + } else { + red.set(true); + green.set(false); + } + } + + public AltosLights() { + GridBagConstraints c; + gridbag = new GridBagLayout(); + setLayout(gridbag); + + c = new GridBagConstraints(); + red = new AltosLed("/redled.png", "/grayled.png"); + c.gridx = 0; c.gridy = 0; + c.insets = new Insets (0, 5, 0, 5); + gridbag.setConstraints(red, c); + add(red); + red.set(true); + green = new AltosLed("/greenled.png", "/grayled.png"); + c.gridx = 1; c.gridy = 0; + gridbag.setConstraints(green, c); + add(green); + green.set(false); + } +} diff --git a/altosuilib/Makefile.am b/altosuilib/Makefile.am index 4dc4c47f..f554fd74 100644 --- a/altosuilib/Makefile.am +++ b/altosuilib/Makefile.am @@ -50,6 +50,10 @@ altosuilib_JAVA = \ AltosEepromManage.java \ AltosEepromMonitorUI.java \ AltosEepromSelect.java \ + AltosCSVUI.java \ + AltosDataChooser.java \ + AltosLights.java \ + AltosLed.java \ AltosBTDevice.java \ AltosBTDeviceIterator.java \ AltosBTManage.java \ @@ -58,6 +62,18 @@ altosuilib_JAVA = \ JAR=altosuilib_$(ALTOSUILIB_VERSION).jar +# Icons +ICONDIR=$(top_srcdir)/icon + +ICONS= $(ICONDIR)/redled.png $(ICONDIR)/redoff.png \ + $(ICONDIR)/greenled.png $(ICONDIR)/greenoff.png \ + $(ICONDIR)/grayon.png $(ICONDIR)/grayled.png + +# icon base names for jar +ICONJAR= -C $(ICONDIR) redled.png -C $(ICONDIR) redoff.png \ + -C $(ICONDIR) greenled.png -C $(ICONDIR) greenoff.png \ + -C $(ICONDIR) grayon.png -C $(ICONDIR) grayled.png + all-local: $(JAR) clean-local: @@ -72,5 +88,5 @@ install-altosuilibJAVA: $(JAR) $(JAVAROOT): mkdir -p $(JAVAROOT) -$(JAR): classaltosuilib.stamp - jar cf $@ -C $(JAVAROOT) . +$(JAR): classaltosuilib.stamp $(ICONS) + jar cf $@ $(ICONJAR) -C $(JAVAROOT) . diff --git a/icon/telegps-128.png b/icon/telegps-128.png new file mode 100644 index 00000000..f1343d9e Binary files /dev/null and b/icon/telegps-128.png differ diff --git a/icon/telegps-16.png b/icon/telegps-16.png new file mode 100644 index 00000000..5bd45999 Binary files /dev/null and b/icon/telegps-16.png differ diff --git a/icon/telegps-256.png b/icon/telegps-256.png new file mode 100644 index 00000000..46e1670a Binary files /dev/null and b/icon/telegps-256.png differ diff --git a/icon/telegps-32.png b/icon/telegps-32.png new file mode 100644 index 00000000..c8588899 Binary files /dev/null and b/icon/telegps-32.png differ diff --git a/icon/telegps-48.png b/icon/telegps-48.png new file mode 100644 index 00000000..3bee98e6 Binary files /dev/null and b/icon/telegps-48.png differ diff --git a/icon/telegps-512.png b/icon/telegps-512.png new file mode 100644 index 00000000..47c47003 Binary files /dev/null and b/icon/telegps-512.png differ diff --git a/icon/telegps-64.png b/icon/telegps-64.png new file mode 100644 index 00000000..0ee086a6 Binary files /dev/null and b/icon/telegps-64.png differ diff --git a/icon/telegps.ico b/icon/telegps.ico new file mode 100644 index 00000000..bedf04ef Binary files /dev/null and b/icon/telegps.ico differ diff --git a/icon/telegps.svg b/icon/telegps.svg new file mode 100644 index 00000000..256b8c5a --- /dev/null +++ b/icon/telegps.svg @@ -0,0 +1,215 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/telegps/Makefile.am b/telegps/Makefile.am index 280b1e40..f8e2e63c 100644 --- a/telegps/Makefile.am +++ b/telegps/Makefile.am @@ -15,6 +15,7 @@ telegps_JAVA= \ TeleGPS.java \ TeleGPSStatus.java \ TeleGPSStatusUpdate.java \ + TeleGPSInfo.java \ TeleGPSConfig.java \ TeleGPSConfigUI.java \ TeleGPSPreferences.java diff --git a/telegps/TeleGPS.java b/telegps/TeleGPS.java index ad46fbdd..1bb505e0 100644 --- a/telegps/TeleGPS.java +++ b/telegps/TeleGPS.java @@ -53,6 +53,7 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo JTabbedPane pane; AltosSiteMap sitemap; + TeleGPSInfo gps_info; boolean has_map; JMenuBar menu_bar; @@ -115,10 +116,12 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo public void reset() { sitemap.reset(); + gps_info.reset(); } public void set_font() { sitemap.set_font(); + gps_info.set_font(); } public void font_size_changed(int font_size) { @@ -135,6 +138,7 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo state = new AltosState(); sitemap.show(state, listener_state); + gps_info.show(state, listener_state); telegps_status.show(state, listener_state); } @@ -225,6 +229,12 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo } void export() { + AltosDataChooser chooser; + chooser = new AltosDataChooser(this); + AltosStateIterable states = chooser.runDialog(); + if (states == null) + return; + new AltosCSVUI(this, states, chooser.file()); } void graph() { @@ -394,6 +404,9 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo sitemap = new AltosSiteMap(); pane.add("Site Map", sitemap); + gps_info = new TeleGPSInfo(); + pane.add("Info", gps_info); + setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); AltosUIPreferences.register_font_listener(this); diff --git a/telegps/TeleGPSInfo.java b/telegps/TeleGPSInfo.java new file mode 100644 index 00000000..0fba77d5 --- /dev/null +++ b/telegps/TeleGPSInfo.java @@ -0,0 +1,511 @@ +/* + * Copyright © 2010 Keith Packard + * + * 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.telegps; + +import java.awt.*; +import javax.swing.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; + +public class TeleGPSInfo extends JComponent implements AltosFlightDisplay { + GridBagLayout layout; + JLabel cur, max; + + public class Info { + JLabel label; + JTextField value; + AltosLights lights; + + void show() { + value.setVisible(true); + lights.setVisible(true); + label.setVisible(true); + } + + void hide() { + value.setVisible(false); + lights.setVisible(false); + label.setVisible(false); + } + + void show(AltosState state, AltosListenerState listener_state) {} + + void show(String s) { + show(); + value.setText(s); + } + + void show(AltosUnits units, double v) { + show(units.show(8, v)); + } + + void show(String format, double v) { + show(String.format(format, v)); + } + + void reset() { + lights.set(false); + value.setText(""); + } + + void set_font() { + label.setFont(AltosUILib.label_font); + value.setFont(AltosUILib.value_font); + } + + public Info (GridBagLayout layout, int y, String text) { + GridBagConstraints c = new GridBagConstraints(); + c.weighty = 1; + + lights = new AltosLights(); + c.gridx = 0; c.gridy = y; + c.anchor = GridBagConstraints.CENTER; + c.fill = GridBagConstraints.VERTICAL; + c.weightx = 0; + layout.setConstraints(lights, c); + add(lights); + + label = new JLabel(text); + label.setFont(AltosUILib.label_font); + label.setHorizontalAlignment(SwingConstants.LEFT); + c.gridx = 1; c.gridy = y; + c.insets = new Insets(AltosUILib.tab_elt_pad, AltosUILib.tab_elt_pad, AltosUILib.tab_elt_pad, AltosUILib.tab_elt_pad); + c.anchor = GridBagConstraints.WEST; + c.fill = GridBagConstraints.VERTICAL; + c.weightx = 0; + layout.setConstraints(label, c); + add(label); + + value = new JTextField(AltosUILib.text_width); + value.setFont(AltosUILib.value_font); + value.setHorizontalAlignment(SwingConstants.RIGHT); + c.gridx = 2; c.gridy = y; + c.gridwidth = 2; + c.anchor = GridBagConstraints.WEST; + c.fill = GridBagConstraints.BOTH; + c.weightx = 1; + layout.setConstraints(value, c); + add(value); + } + } + + public class Value { + JLabel label; + JTextField value; + void show(AltosState state, AltosListenerState listener_state) {} + + void reset() { + value.setText(""); + } + + void show() { + label.setVisible(true); + value.setVisible(true); + } + + void show(String s) { + show(); + value.setText(s); + } + + void show(AltosUnits units, double v) { + show(units.show(8, v)); + } + + void show(String format, double v) { + show(String.format(format, v)); + } + + void hide() { + label.setVisible(false); + value.setVisible(false); + } + void set_font() { + label.setFont(AltosUILib.label_font); + value.setFont(AltosUILib.value_font); + } + + public Value (GridBagLayout layout, int y, String text) { + GridBagConstraints c = new GridBagConstraints(); + c.weighty = 1; + + label = new JLabel(text); + label.setFont(AltosUILib.label_font); + label.setHorizontalAlignment(SwingConstants.LEFT); + c.gridx = 1; c.gridy = y; + c.insets = new Insets(AltosUILib.tab_elt_pad, AltosUILib.tab_elt_pad, AltosUILib.tab_elt_pad, AltosUILib.tab_elt_pad); + c.anchor = GridBagConstraints.WEST; + c.fill = GridBagConstraints.VERTICAL; + c.weightx = 0; + layout.setConstraints(label, c); + add(label); + + value = new JTextField(AltosUILib.text_width); + value.setFont(AltosUILib.value_font); + value.setHorizontalAlignment(SwingConstants.RIGHT); + c.gridx = 2; c.gridy = y; + c.anchor = GridBagConstraints.WEST; + c.fill = GridBagConstraints.BOTH; + c.gridwidth = 2; + c.weightx = 1; + layout.setConstraints(value, c); + add(value); + } + } + + public abstract class DualValue { + JLabel label; + JTextField value1; + JTextField value2; + + void reset() { + value1.setText(""); + value2.setText(""); + } + + void show() { + label.setVisible(true); + value1.setVisible(true); + value2.setVisible(true); + } + + void hide() { + label.setVisible(false); + value1.setVisible(false); + value2.setVisible(false); + } + + void set_font() { + label.setFont(AltosUILib.label_font); + value1.setFont(AltosUILib.value_font); + value2.setFont(AltosUILib.value_font); + } + + abstract void show(AltosState state, AltosListenerState listener_state); + + void show(String v1, String v2) { + show(); + value1.setText(v1); + value2.setText(v2); + } + void show(String f1, double v1, String f2, double v2) { + show(); + value1.setText(String.format(f1, v1)); + value2.setText(String.format(f2, v2)); + } + + public DualValue (GridBagLayout layout, int x, int y, String text) { + GridBagConstraints c = new GridBagConstraints(); + c.weighty = 1; + + label = new JLabel(text); + label.setFont(AltosUILib.label_font); + label.setHorizontalAlignment(SwingConstants.LEFT); + c.gridx = x + 1; c.gridy = y; + c.insets = new Insets(AltosUILib.tab_elt_pad, AltosUILib.tab_elt_pad, AltosUILib.tab_elt_pad, AltosUILib.tab_elt_pad); + c.anchor = GridBagConstraints.WEST; + c.fill = GridBagConstraints.VERTICAL; + c.weightx = 0; + layout.setConstraints(label, c); + add(label); + + value1 = new JTextField(AltosUILib.text_width); + value1.setFont(AltosUILib.value_font); + value1.setHorizontalAlignment(SwingConstants.RIGHT); + c.gridx = x + 2; c.gridy = y; + c.anchor = GridBagConstraints.WEST; + c.fill = GridBagConstraints.BOTH; + c.weightx = 1; + layout.setConstraints(value1, c); + add(value1); + + value2 = new JTextField(AltosUILib.text_width); + value2.setFont(AltosUILib.value_font); + value2.setHorizontalAlignment(SwingConstants.RIGHT); + c.gridx = x + 3; c.gridy = y; + c.anchor = GridBagConstraints.WEST; + c.fill = GridBagConstraints.BOTH; + c.weightx = 1; + c.gridwidth = 1; + layout.setConstraints(value2, c); + add(value2); + } + } + + public class ValueHold { + JLabel label; + JTextField value; + JTextField max_value; + double max; + + void show(AltosState state, AltosListenerState listener_state) {} + + void reset() { + value.setText(""); + max_value.setText(""); + max = AltosLib.MISSING; + } + + void set_font() { + label.setFont(AltosUILib.label_font); + value.setFont(AltosUILib.value_font); + max_value.setFont(AltosUILib.value_font); + } + + void show(AltosUnits units, double v) { + if (v == AltosLib.MISSING) { + value.setText("Missing"); + max_value.setText("Missing"); + } else { + value.setText(units.show(8, v)); + if (v > max || max == AltosLib.MISSING) { + max_value.setText(units.show(8, v)); + max = v; + } + } + } + + void hide() { + label.setVisible(false); + value.setVisible(false); + max_value.setVisible(false); + } + + public ValueHold (GridBagLayout layout, int y, String text) { + GridBagConstraints c = new GridBagConstraints(); + c.weighty = 1; + + label = new JLabel(text); + label.setFont(AltosUILib.label_font); + label.setHorizontalAlignment(SwingConstants.LEFT); + c.gridx = 1; c.gridy = y; + c.insets = new Insets(AltosUILib.tab_elt_pad, AltosUILib.tab_elt_pad, AltosUILib.tab_elt_pad, AltosUILib.tab_elt_pad); + c.anchor = GridBagConstraints.WEST; + c.fill = GridBagConstraints.VERTICAL; + c.weightx = 0; + layout.setConstraints(label, c); + add(label); + + value = new JTextField(AltosUILib.text_width); + value.setFont(AltosUILib.value_font); + value.setHorizontalAlignment(SwingConstants.RIGHT); + c.gridx = 2; c.gridy = y; + c.anchor = GridBagConstraints.EAST; + c.fill = GridBagConstraints.BOTH; + c.weightx = 1; + layout.setConstraints(value, c); + add(value); + + max_value = new JTextField(AltosUILib.text_width); + max_value.setFont(AltosUILib.value_font); + max_value.setHorizontalAlignment(SwingConstants.RIGHT); + c.gridx = 3; c.gridy = y; + c.anchor = GridBagConstraints.EAST; + c.fill = GridBagConstraints.BOTH; + c.weightx = 1; + layout.setConstraints(max_value, c); + add(max_value); + } + } + + + class Altitude extends ValueHold { + void show (AltosState state, AltosListenerState listener_state) { + show(AltosConvert.height, state.altitude()); + } + public Altitude (GridBagLayout layout, int y) { + super (layout, y, "Altitude"); + } + } + + Altitude altitude; + + class AscentRate extends ValueHold { + void show (AltosState state, AltosListenerState listener_state) { + show(AltosConvert.speed, state.gps_ascent_rate()); + } + public AscentRate (GridBagLayout layout, int y) { + super (layout, y, "Ascent Rate"); + } + } + + AscentRate ascent_rate; + + class GroundSpeed extends ValueHold { + void show (AltosState state, AltosListenerState listener_state) { + show(AltosConvert.speed, state.gps_ground_speed()); + } + public GroundSpeed (GridBagLayout layout, int y) { + super (layout, y, "Ground Speed"); + } + } + + GroundSpeed ground_speed; + + String pos(double p, String pos, String neg) { + String h = pos; + if (p < 0) { + h = neg; + p = -p; + } + int deg = (int) Math.floor(p); + double min = (p - Math.floor(p)) * 60.0; + return String.format("%s %4d° %9.6f", h, deg, min); + } + + class Course extends DualValue { + void show (AltosState state, AltosListenerState listener_state) { + double course = state.gps_course(); + if (course != AltosLib.MISSING) + show( String.format("%3.0f°", course), + AltosConvert.bearing_to_words( + AltosConvert.BEARING_LONG, + course)); + } + public Course (GridBagLayout layout, int y) { + super (layout, 0, y, "Course"); + } + } + + Course course; + + class Lat extends Value { + void show (AltosState state, AltosListenerState listener_state) { + if (state.gps != null && state.gps.connected && state.gps.lat != AltosLib.MISSING) + show(pos(state.gps.lat,"N", "S")); + else + show("???"); + } + public Lat (GridBagLayout layout, int y) { + super (layout, y, "Latitude"); + } + } + + Lat lat; + + class Lon extends Value { + void show (AltosState state, AltosListenerState listener_state) { + if (state.gps != null && state.gps.connected && state.gps.lon != AltosLib.MISSING) + show(pos(state.gps.lon,"E", "W")); + else + show("???"); + } + public Lon (GridBagLayout layout, int y) { + super (layout, y, "Longitude"); + } + } + + Lon lon; + + class GPSLocked extends Info { + void show (AltosState state, AltosListenerState listener_state) { + if (state == null || state.gps == null) + hide(); + else { + show("%4d sats", state.gps.nsat); + lights.set(state.gps.locked && state.gps.nsat >= 4); + } + } + public GPSLocked (GridBagLayout layout, int y) { + super (layout, y, "GPS Locked"); + } + } + + GPSLocked gps_locked; + + public void reset() { + lat.reset(); + lon.reset(); + altitude.reset(); + ground_speed.reset(); + ascent_rate.reset(); + course.reset(); + gps_locked.reset(); + } + + public void set_font() { + cur.setFont(AltosUILib.label_font); + max.setFont(AltosUILib.label_font); + lat.set_font(); + lon.set_font(); + altitude.set_font(); + ground_speed.set_font(); + ascent_rate.set_font(); + course.set_font(); + gps_locked.set_font(); + } + + public void show(AltosState state, AltosListenerState listener_state) { + if (state.gps != null && state.gps.connected) { + lat.show(state, listener_state); + lon.show(state, listener_state); + } else { + lat.hide(); + lon.hide(); + } + altitude.show(state, listener_state); + ground_speed.show(state, listener_state); + ascent_rate.show(state, listener_state); + course.show(state, listener_state); + gps_locked.show(state, listener_state); + } + + public void labels(GridBagLayout layout, int y) { + GridBagConstraints c; + + cur = new JLabel("Current"); + cur.setFont(AltosUILib.label_font); + c = new GridBagConstraints(); + c.gridx = 2; c.gridy = y; + c.insets = new Insets(AltosUILib.tab_elt_pad, AltosUILib.tab_elt_pad, AltosUILib.tab_elt_pad, AltosUILib.tab_elt_pad); + layout.setConstraints(cur, c); + add(cur); + + max = new JLabel("Maximum"); + max.setFont(AltosUILib.label_font); + c.gridx = 3; c.gridy = y; + layout.setConstraints(max, c); + add(max); + } + + public String getName() { + return "Info"; + } + + public TeleGPSInfo() { + layout = new GridBagLayout(); + + setLayout(layout); + + /* Elements in ascent display: + * + * lat + * lon + * height + */ + int y = 0; + labels(layout, y++); + altitude = new Altitude(layout, y++); + ground_speed = new GroundSpeed(layout, y++); + ascent_rate = new AscentRate(layout, y++); + course = new Course(layout, y++); + lat = new Lat(layout, y++); + lon = new Lon(layout, y++); + gps_locked = new GPSLocked(layout, y++); + } +} -- cgit v1.2.3 From 71715337eb532a1fbe1a753240e7417d5223489f Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 29 May 2014 10:16:15 -0700 Subject: telegps: Add info table Move a couple of files from altosui to altosuilib, hook up the info table after changing it to implement the AltosFlightDisplay interface Signed-off-by: Keith Packard --- altoslib/AltosState.java | 4 + altosui/AltosCompanionInfo.java | 7 +- altosui/AltosFlightInfoTableModel.java | 75 ---------- altosui/AltosIdleMonitorUI.java | 4 +- altosui/AltosInfoTable.java | 236 ------------------------------ altosui/Makefile.am | 2 - altosuilib/AltosFlightInfoTableModel.java | 75 ++++++++++ altosuilib/AltosInfoTable.java | 236 ++++++++++++++++++++++++++++++ altosuilib/Makefile.am | 2 + telegps/TeleGPS.java | 72 +++++---- telegps/TeleGPSInfo.java | 4 + 11 files changed, 371 insertions(+), 346 deletions(-) delete mode 100644 altosui/AltosFlightInfoTableModel.java delete mode 100644 altosui/AltosInfoTable.java create mode 100644 altosuilib/AltosFlightInfoTableModel.java create mode 100644 altosuilib/AltosInfoTable.java (limited to 'altoslib') diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index 1162e522..ddda82b9 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -713,6 +713,7 @@ public class AltosState implements Cloneable { gps_ground_altitude = new AltosGpsGroundAltitude(); gps_ground_speed = new AltosValue(); gps_ascent_rate = new AltosValue(); + gps_course = new AltosValue(); speak_tick = AltosLib.MISSING; speak_altitude = AltosLib.MISSING; @@ -842,6 +843,9 @@ public class AltosState implements Cloneable { gps_altitude.copy(old.gps_altitude); gps_ground_altitude.copy(old.gps_ground_altitude); + gps_ground_speed.copy(old.gps_ground_speed); + gps_ascent_rate.copy(old.gps_ascent_rate); + gps_course.copy(old.gps_course); pad_lat = old.pad_lat; pad_lon = old.pad_lon; diff --git a/altosui/AltosCompanionInfo.java b/altosui/AltosCompanionInfo.java index 42413a57..f8d033a8 100644 --- a/altosui/AltosCompanionInfo.java +++ b/altosui/AltosCompanionInfo.java @@ -20,8 +20,9 @@ package altosui; import java.awt.*; import javax.swing.*; import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; -public class AltosCompanionInfo extends JTable { +public class AltosCompanionInfo extends JTable implements AltosFlightDisplay { private AltosFlightInfoTableModel model; static final int info_columns = 2; @@ -50,7 +51,7 @@ public class AltosCompanionInfo extends JTable { return getPreferredSize(); } - void info_reset() { + public void reset() { model.reset(); } @@ -88,7 +89,7 @@ public class AltosCompanionInfo extends JTable { return; if (state.companion != null) companion = state.companion; - info_reset(); + reset(); info_add_row(0, "Companion board", "%s", board_name()); if (companion != null) { info_add_row(0, "Last Data", "%5d", companion.tick); diff --git a/altosui/AltosFlightInfoTableModel.java b/altosui/AltosFlightInfoTableModel.java deleted file mode 100644 index 249f6497..00000000 --- a/altosui/AltosFlightInfoTableModel.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright © 2010 Keith Packard - * - * 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 altosui; - -import javax.swing.table.*; - -public class AltosFlightInfoTableModel extends AbstractTableModel { - final static private String[] columnNames = {"Field", "Value"}; - - int rows; - int cols; - private String[][] data; - - public int getColumnCount() { return cols; } - public int getRowCount() { return rows; } - public String getColumnName(int col) { return columnNames[col & 1]; } - - public Object getValueAt(int row, int col) { - if (row >= rows || col >= cols) - return ""; - return data[row][col]; - } - - int[] current_row; - - public void reset() { - for (int i = 0; i < cols / 2; i++) - current_row[i] = 0; - } - - public void clear() { - reset(); - for (int c = 0; c < cols; c++) - for (int r = 0; r < rows; r++) - data[r][c] = ""; - fireTableDataChanged(); - } - - public void addRow(int col, String name, String value) { - if (current_row[col] < rows) { - data[current_row[col]][col * 2] = name; - data[current_row[col]][col * 2 + 1] = value; - } - current_row[col]++; - } - - public void finish() { - for (int c = 0; c < cols / 2; c++) - while (current_row[c] < rows) - addRow(c, "", ""); - fireTableDataChanged(); - } - - public AltosFlightInfoTableModel (int in_rows, int in_cols) { - rows = in_rows; - cols = in_cols * 2; - data = new String[rows][cols]; - current_row = new int[in_cols]; - } -} diff --git a/altosui/AltosIdleMonitorUI.java b/altosui/AltosIdleMonitorUI.java index 62b50568..b5652df3 100644 --- a/altosui/AltosIdleMonitorUI.java +++ b/altosui/AltosIdleMonitorUI.java @@ -234,7 +234,9 @@ public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDispl try { disconnect(); } catch (Exception ex) { - System.out.println(Arrays.toString(ex.getStackTrace())); + System.out.printf("Exception %s\n", ex.toString()); + for (StackTraceElement e : ex.getStackTrace()) + System.out.printf("%s\n", e.toString()); } setVisible(false); dispose(); diff --git a/altosui/AltosInfoTable.java b/altosui/AltosInfoTable.java deleted file mode 100644 index 125fa94c..00000000 --- a/altosui/AltosInfoTable.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright © 2010 Keith Packard - * - * 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 altosui; - -import java.awt.*; -import javax.swing.*; -import javax.swing.table.*; -import org.altusmetrum.altoslib_4.*; - -public class AltosInfoTable extends JTable { - private AltosFlightInfoTableModel model; - - static final int info_columns = 3; - static final int info_rows = 17; - - int desired_row_height() { - FontMetrics infoValueMetrics = getFontMetrics(Altos.table_value_font); - return (infoValueMetrics.getHeight() + infoValueMetrics.getLeading()) * 18 / 10; - } - - int text_width(String t) { - FontMetrics infoValueMetrics = getFontMetrics(Altos.table_value_font); - - return infoValueMetrics.stringWidth(t); - } - - void set_layout() { - setRowHeight(desired_row_height()); - for (int i = 0; i < info_columns * 2; i++) - { - TableColumn column = getColumnModel().getColumn(i); - - if ((i & 1) == 0) - column.setPreferredWidth(text_width(" Satellites Visible")); - else - column.setPreferredWidth(text_width("W 179°59.99999' ")); - } - } - - public AltosInfoTable() { - super(new AltosFlightInfoTableModel(info_rows, info_columns)); - model = (AltosFlightInfoTableModel) getModel(); - setFont(Altos.table_value_font); - setAutoResizeMode(AUTO_RESIZE_ALL_COLUMNS); - setShowGrid(true); - set_layout(); - doLayout(); - } - - public void set_font() { - setFont(Altos.table_value_font); - set_layout(); - doLayout(); - } - - public Dimension getPreferredScrollableViewportSize() { - return getPreferredSize(); - } - - void info_reset() { - model.reset(); - } - - void info_add_row(int col, String name, String value) { - model.addRow(col, name, value); - } - - void info_add_row(int col, String name, String format, Object... parameters) { - info_add_row (col, name, String.format(format, parameters)); - } - - void info_add_deg(int col, String name, double v, int pos, int neg) { - int c = pos; - if (v < 0) { - c = neg; - v = -v; - } - double deg = Math.floor(v); - double min = (v - deg) * 60; - - info_add_row(col, name, String.format("%c %3.0f°%08.5f'", c, deg, min)); - } - - void info_finish() { - model.finish(); - } - - public void clear() { - model.clear(); - } - - public void show(AltosState state, AltosListenerState listener_state) { - info_reset(); - if (state != null) { - if (state.device_type != AltosLib.MISSING) - info_add_row(0, "Device", "%s", AltosLib.product_name(state.device_type)); - if (state.altitude() != AltosLib.MISSING) - info_add_row(0, "Altitude", "%6.0f m", state.altitude()); - if (state.ground_altitude() != AltosLib.MISSING) - info_add_row(0, "Pad altitude", "%6.0f m", state.ground_altitude()); - if (state.height() != AltosLib.MISSING) - info_add_row(0, "Height", "%6.0f m", state.height()); - if (state.max_height() != AltosLib.MISSING) - info_add_row(0, "Max height", "%6.0f m", state.max_height()); - if (state.acceleration() != AltosLib.MISSING) - info_add_row(0, "Acceleration", "%8.1f m/s²", state.acceleration()); - if (state.max_acceleration() != AltosLib.MISSING) - info_add_row(0, "Max acceleration", "%8.1f m/s²", state.max_acceleration()); - if (state.speed() != AltosLib.MISSING) - info_add_row(0, "Speed", "%8.1f m/s", state.speed()); - if (state.max_speed() != AltosLib.MISSING) - info_add_row(0, "Max Speed", "%8.1f m/s", state.max_speed()); - if (state.orient() != AltosLib.MISSING) - info_add_row(0, "Tilt", "%4.0f °", state.orient()); - if (state.max_orient() != AltosLib.MISSING) - info_add_row(0, "Max Tilt", "%4.0f °", state.max_orient()); - if (state.temperature != AltosLib.MISSING) - info_add_row(0, "Temperature", "%9.2f °C", state.temperature); - if (state.battery_voltage != AltosLib.MISSING) - info_add_row(0, "Battery", "%9.2f V", state.battery_voltage); - if (state.apogee_voltage != AltosLib.MISSING) - info_add_row(0, "Drogue", "%9.2f V", state.apogee_voltage); - if (state.main_voltage != AltosLib.MISSING) - info_add_row(0, "Main", "%9.2f V", state.main_voltage); - } - if (listener_state != null) { - info_add_row(0, "CRC Errors", "%6d", listener_state.crc_errors); - - if (listener_state.battery != AltosLib.MISSING) - info_add_row(0, "Receiver Battery", "%9.2f", listener_state.battery); - } - - if (state != null) { - if (state.gps == null || !state.gps.connected) { - info_add_row(1, "GPS", "not available"); - } else { - if (state.gps_ready) - info_add_row(1, "GPS state", "%s", "ready"); - else - info_add_row(1, "GPS state", "wait (%d)", - state.gps_waiting); - if (state.gps.locked) - info_add_row(1, "GPS", " locked"); - else if (state.gps.connected) - info_add_row(1, "GPS", " unlocked"); - else - info_add_row(1, "GPS", " missing"); - info_add_row(1, "Satellites", "%6d", state.gps.nsat); - if (state.gps.lat != AltosLib.MISSING) - info_add_deg(1, "Latitude", state.gps.lat, 'N', 'S'); - if (state.gps.lon != AltosLib.MISSING) - info_add_deg(1, "Longitude", state.gps.lon, 'E', 'W'); - if (state.gps.alt != AltosLib.MISSING) - info_add_row(1, "GPS altitude", "%8.1f", state.gps.alt); - if (state.gps_height != AltosLib.MISSING) - info_add_row(1, "GPS height", "%8.1f", state.gps_height); - - /* The SkyTraq GPS doesn't report these values */ - /* - if (false) { - info_add_row(1, "GPS ground speed", "%8.1f m/s %3d°", - state.gps.ground_speed, - state.gps.course); - info_add_row(1, "GPS climb rate", "%8.1f m/s", - state.gps.climb_rate); - info_add_row(1, "GPS error", "%6d m(h)%3d m(v)", - state.gps.h_error, state.gps.v_error); - } - */ - - info_add_row(1, "GPS hdop", "%8.1f", state.gps.hdop); - - if (state.npad > 0) { - if (state.from_pad != null) { - info_add_row(1, "Distance from pad", "%6d m", - (int) (state.from_pad.distance + 0.5)); - info_add_row(1, "Direction from pad", "%6d°", - (int) (state.from_pad.bearing + 0.5)); - info_add_row(1, "Elevation from pad", "%6d°", - (int) (state.elevation + 0.5)); - info_add_row(1, "Range from pad", "%6d m", - (int) (state.range + 0.5)); - } else { - info_add_row(1, "Distance from pad", "unknown"); - info_add_row(1, "Direction from pad", "unknown"); - info_add_row(1, "Elevation from pad", "unknown"); - info_add_row(1, "Range from pad", "unknown"); - } - info_add_deg(1, "Pad latitude", state.pad_lat, 'N', 'S'); - info_add_deg(1, "Pad longitude", state.pad_lon, 'E', 'W'); - info_add_row(1, "Pad GPS alt", "%6.0f m", state.pad_alt); - } - if (state.gps.year != AltosLib.MISSING) - info_add_row(1, "GPS date", "%04d-%02d-%02d", - state.gps.year, - state.gps.month, - state.gps.day); - if (state.gps.hour != AltosLib.MISSING) - info_add_row(1, "GPS time", " %02d:%02d:%02d", - state.gps.hour, - state.gps.minute, - state.gps.second); - //int nsat_vis = 0; - int c; - - if (state.gps.cc_gps_sat == null) - info_add_row(2, "Satellites Visible", "%4d", 0); - else { - info_add_row(2, "Satellites Visible", "%4d", state.gps.cc_gps_sat.length); - for (c = 0; c < state.gps.cc_gps_sat.length; c++) { - info_add_row(2, "Satellite id,C/N0", - "%4d, %4d", - state.gps.cc_gps_sat[c].svid, - state.gps.cc_gps_sat[c].c_n0); - } - } - } - } - info_finish(); - } -} diff --git a/altosui/Makefile.am b/altosui/Makefile.am index 686b5967..add46825 100644 --- a/altosui/Makefile.am +++ b/altosui/Makefile.am @@ -21,7 +21,6 @@ altosui_JAVA = \ AltosConfigTD.java \ AltosConfigTDUI.java \ AltosDescent.java \ - AltosFlightInfoTableModel.java \ AltosFlightStatsTable.java \ AltosFlightStatus.java \ AltosFlightStatusUpdate.java \ @@ -32,7 +31,6 @@ altosui_JAVA = \ AltosIgnitor.java \ AltosLaunch.java \ AltosLaunchUI.java \ - AltosInfoTable.java \ AltosLanded.java \ AltosPad.java \ AltosUIPreferencesBackend.java \ diff --git a/altosuilib/AltosFlightInfoTableModel.java b/altosuilib/AltosFlightInfoTableModel.java new file mode 100644 index 00000000..3995efb3 --- /dev/null +++ b/altosuilib/AltosFlightInfoTableModel.java @@ -0,0 +1,75 @@ +/* + * Copyright © 2010 Keith Packard + * + * 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.altosuilib_2; + +import javax.swing.table.*; + +public class AltosFlightInfoTableModel extends AbstractTableModel { + final static private String[] columnNames = {"Field", "Value"}; + + int rows; + int cols; + private String[][] data; + + public int getColumnCount() { return cols; } + public int getRowCount() { return rows; } + public String getColumnName(int col) { return columnNames[col & 1]; } + + public Object getValueAt(int row, int col) { + if (row >= rows || col >= cols) + return ""; + return data[row][col]; + } + + int[] current_row; + + public void reset() { + for (int i = 0; i < cols / 2; i++) + current_row[i] = 0; + } + + public void clear() { + reset(); + for (int c = 0; c < cols; c++) + for (int r = 0; r < rows; r++) + data[r][c] = ""; + fireTableDataChanged(); + } + + public void addRow(int col, String name, String value) { + if (current_row[col] < rows) { + data[current_row[col]][col * 2] = name; + data[current_row[col]][col * 2 + 1] = value; + } + current_row[col]++; + } + + public void finish() { + for (int c = 0; c < cols / 2; c++) + while (current_row[c] < rows) + addRow(c, "", ""); + fireTableDataChanged(); + } + + public AltosFlightInfoTableModel (int in_rows, int in_cols) { + rows = in_rows; + cols = in_cols * 2; + data = new String[rows][cols]; + current_row = new int[in_cols]; + } +} diff --git a/altosuilib/AltosInfoTable.java b/altosuilib/AltosInfoTable.java new file mode 100644 index 00000000..0d8779d1 --- /dev/null +++ b/altosuilib/AltosInfoTable.java @@ -0,0 +1,236 @@ +/* + * Copyright © 2010 Keith Packard + * + * 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.altosuilib_2; + +import java.awt.*; +import javax.swing.*; +import javax.swing.table.*; +import org.altusmetrum.altoslib_4.*; + +public class AltosInfoTable extends JTable implements AltosFlightDisplay { + private AltosFlightInfoTableModel model; + + static final int info_columns = 3; + static final int info_rows = 17; + + int desired_row_height() { + FontMetrics infoValueMetrics = getFontMetrics(AltosUILib.table_value_font); + return (infoValueMetrics.getHeight() + infoValueMetrics.getLeading()) * 18 / 10; + } + + int text_width(String t) { + FontMetrics infoValueMetrics = getFontMetrics(AltosUILib.table_value_font); + + return infoValueMetrics.stringWidth(t); + } + + void set_layout() { + setRowHeight(desired_row_height()); + for (int i = 0; i < info_columns * 2; i++) + { + TableColumn column = getColumnModel().getColumn(i); + + if ((i & 1) == 0) + column.setPreferredWidth(text_width(" Satellites Visible")); + else + column.setPreferredWidth(text_width("W 179°59.99999' ")); + } + } + + public AltosInfoTable() { + super(new AltosFlightInfoTableModel(info_rows, info_columns)); + model = (AltosFlightInfoTableModel) getModel(); + setFont(AltosUILib.table_value_font); + setAutoResizeMode(AUTO_RESIZE_ALL_COLUMNS); + setShowGrid(true); + set_layout(); + doLayout(); + } + + public void set_font() { + setFont(AltosUILib.table_value_font); + set_layout(); + doLayout(); + } + + public Dimension getPreferredScrollableViewportSize() { + return getPreferredSize(); + } + + public void reset() { + model.reset(); + } + + void info_add_row(int col, String name, String value) { + model.addRow(col, name, value); + } + + void info_add_row(int col, String name, String format, Object... parameters) { + info_add_row (col, name, String.format(format, parameters)); + } + + void info_add_deg(int col, String name, double v, int pos, int neg) { + int c = pos; + if (v < 0) { + c = neg; + v = -v; + } + double deg = Math.floor(v); + double min = (v - deg) * 60; + + info_add_row(col, name, String.format("%c %3.0f°%08.5f'", c, deg, min)); + } + + void info_finish() { + model.finish(); + } + + public void clear() { + model.clear(); + } + + public void show(AltosState state, AltosListenerState listener_state) { + reset(); + if (state != null) { + if (state.device_type != AltosLib.MISSING) + info_add_row(0, "Device", "%s", AltosLib.product_name(state.device_type)); + if (state.altitude() != AltosLib.MISSING) + info_add_row(0, "Altitude", "%6.0f m", state.altitude()); + if (state.ground_altitude() != AltosLib.MISSING) + info_add_row(0, "Pad altitude", "%6.0f m", state.ground_altitude()); + if (state.height() != AltosLib.MISSING) + info_add_row(0, "Height", "%6.0f m", state.height()); + if (state.max_height() != AltosLib.MISSING) + info_add_row(0, "Max height", "%6.0f m", state.max_height()); + if (state.acceleration() != AltosLib.MISSING) + info_add_row(0, "Acceleration", "%8.1f m/s²", state.acceleration()); + if (state.max_acceleration() != AltosLib.MISSING) + info_add_row(0, "Max acceleration", "%8.1f m/s²", state.max_acceleration()); + if (state.speed() != AltosLib.MISSING) + info_add_row(0, "Speed", "%8.1f m/s", state.speed()); + if (state.max_speed() != AltosLib.MISSING) + info_add_row(0, "Max Speed", "%8.1f m/s", state.max_speed()); + if (state.orient() != AltosLib.MISSING) + info_add_row(0, "Tilt", "%4.0f °", state.orient()); + if (state.max_orient() != AltosLib.MISSING) + info_add_row(0, "Max Tilt", "%4.0f °", state.max_orient()); + if (state.temperature != AltosLib.MISSING) + info_add_row(0, "Temperature", "%9.2f °C", state.temperature); + if (state.battery_voltage != AltosLib.MISSING) + info_add_row(0, "Battery", "%9.2f V", state.battery_voltage); + if (state.apogee_voltage != AltosLib.MISSING) + info_add_row(0, "Drogue", "%9.2f V", state.apogee_voltage); + if (state.main_voltage != AltosLib.MISSING) + info_add_row(0, "Main", "%9.2f V", state.main_voltage); + } + if (listener_state != null) { + info_add_row(0, "CRC Errors", "%6d", listener_state.crc_errors); + + if (listener_state.battery != AltosLib.MISSING) + info_add_row(0, "Receiver Battery", "%9.2f", listener_state.battery); + } + + if (state != null) { + if (state.gps == null || !state.gps.connected) { + info_add_row(1, "GPS", "not available"); + } else { + if (state.gps_ready) + info_add_row(1, "GPS state", "%s", "ready"); + else + info_add_row(1, "GPS state", "wait (%d)", + state.gps_waiting); + if (state.gps.locked) + info_add_row(1, "GPS", " locked"); + else if (state.gps.connected) + info_add_row(1, "GPS", " unlocked"); + else + info_add_row(1, "GPS", " missing"); + info_add_row(1, "Satellites", "%6d", state.gps.nsat); + if (state.gps.lat != AltosLib.MISSING) + info_add_deg(1, "Latitude", state.gps.lat, 'N', 'S'); + if (state.gps.lon != AltosLib.MISSING) + info_add_deg(1, "Longitude", state.gps.lon, 'E', 'W'); + if (state.gps.alt != AltosLib.MISSING) + info_add_row(1, "GPS altitude", "%8.1f", state.gps.alt); + if (state.gps_height != AltosLib.MISSING) + info_add_row(1, "GPS height", "%8.1f", state.gps_height); + + /* The SkyTraq GPS doesn't report these values */ + /* + if (false) { + info_add_row(1, "GPS ground speed", "%8.1f m/s %3d°", + state.gps.ground_speed, + state.gps.course); + info_add_row(1, "GPS climb rate", "%8.1f m/s", + state.gps.climb_rate); + info_add_row(1, "GPS error", "%6d m(h)%3d m(v)", + state.gps.h_error, state.gps.v_error); + } + */ + + info_add_row(1, "GPS hdop", "%8.1f", state.gps.hdop); + + if (state.npad > 0) { + if (state.from_pad != null) { + info_add_row(1, "Distance from pad", "%6d m", + (int) (state.from_pad.distance + 0.5)); + info_add_row(1, "Direction from pad", "%6d°", + (int) (state.from_pad.bearing + 0.5)); + info_add_row(1, "Elevation from pad", "%6d°", + (int) (state.elevation + 0.5)); + info_add_row(1, "Range from pad", "%6d m", + (int) (state.range + 0.5)); + } else { + info_add_row(1, "Distance from pad", "unknown"); + info_add_row(1, "Direction from pad", "unknown"); + info_add_row(1, "Elevation from pad", "unknown"); + info_add_row(1, "Range from pad", "unknown"); + } + info_add_deg(1, "Pad latitude", state.pad_lat, 'N', 'S'); + info_add_deg(1, "Pad longitude", state.pad_lon, 'E', 'W'); + info_add_row(1, "Pad GPS alt", "%6.0f m", state.pad_alt); + } + if (state.gps.year != AltosLib.MISSING) + info_add_row(1, "GPS date", "%04d-%02d-%02d", + state.gps.year, + state.gps.month, + state.gps.day); + if (state.gps.hour != AltosLib.MISSING) + info_add_row(1, "GPS time", " %02d:%02d:%02d", + state.gps.hour, + state.gps.minute, + state.gps.second); + //int nsat_vis = 0; + int c; + + if (state.gps.cc_gps_sat == null) + info_add_row(2, "Satellites Visible", "%4d", 0); + else { + info_add_row(2, "Satellites Visible", "%4d", state.gps.cc_gps_sat.length); + for (c = 0; c < state.gps.cc_gps_sat.length; c++) { + info_add_row(2, "Satellite id,C/N0", + "%4d, %4d", + state.gps.cc_gps_sat[c].svid, + state.gps.cc_gps_sat[c].c_n0); + } + } + } + } + info_finish(); + } +} diff --git a/altosuilib/Makefile.am b/altosuilib/Makefile.am index e697b17c..65a8228a 100644 --- a/altosuilib/Makefile.am +++ b/altosuilib/Makefile.am @@ -56,6 +56,8 @@ altosuilib_JAVA = \ AltosLed.java \ AltosFlashUI.java \ AltosRomconfigUI.java \ + AltosInfoTable.java \ + AltosFlightInfoTableModel.java \ AltosBTDevice.java \ AltosBTDeviceIterator.java \ AltosBTManage.java \ diff --git a/telegps/TeleGPS.java b/telegps/TeleGPS.java index 7f34c763..d30d8dc5 100644 --- a/telegps/TeleGPS.java +++ b/telegps/TeleGPS.java @@ -50,16 +50,25 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo AltosFlightReader reader; AltosDisplayThread thread; - JTabbedPane pane; + JMenuBar menu_bar; - AltosSiteMap sitemap; - TeleGPSInfo gps_info; - boolean has_map; + JMenu file_menu; + JMenu monitor_menu; + JMenu device_menu; + AltosFreqList frequencies; + + Container bag; + + TeleGPSStatus telegps_status; + TeleGPSStatusUpdate status_update; + + JTabbedPane pane; + + AltosSiteMap sitemap; + TeleGPSInfo gps_info; + AltosInfoTable info_table; - JMenuBar menu_bar; - JMenu file_menu; - JMenu monitor_menu; - JMenu device_menu; + LinkedList displays; /* File menu */ final static String new_command = "new"; @@ -113,41 +122,38 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo } public void reset() { - sitemap.reset(); - gps_info.reset(); + for (AltosFlightDisplay display : displays) + display.reset(); } public void set_font() { - sitemap.set_font(); - gps_info.set_font(); + for (AltosFlightDisplay display : displays) + display.set_font(); } public void font_size_changed(int font_size) { set_font(); } - -// AltosFlightStatusUpdate status_update; - public void show(AltosState state, AltosListenerState listener_state) { -// status_update.saved_state = state; + try { + status_update.saved_state = state; - if (state == null) - state = new AltosState(); + if (state == null) + state = new AltosState(); - sitemap.show(state, listener_state); - gps_info.show(state, listener_state); - telegps_status.show(state, listener_state); + int i = 0; + for (AltosFlightDisplay display : displays) { + display.show(state, listener_state); + i++; + } + } catch (Exception ex) { + System.out.printf("Exception %s\n", ex.toString()); + for (StackTraceElement e : ex.getStackTrace()) + System.out.printf("%s\n", e.toString()); + } } - Container bag; - AltosFreqList frequencies; - JLabel telemetry; - TeleGPSStatus telegps_status; - TeleGPSStatusUpdate status_update; - - ActionListener show_timer; - void new_window() { new TeleGPS(); } @@ -379,6 +385,7 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo file_menu = make_menu("File", file_menu_entries); monitor_menu = make_menu("Monitor", monitor_menu_entries); device_menu = make_menu("Device", device_menu_entries); + displays = new LinkedList(); int serial = -1; @@ -391,6 +398,7 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo c.gridwidth = 2; bag.add(telegps_status, c); c.gridwidth = 1; + displays.add(telegps_status); /* The rest of the window uses a tabbed pane to @@ -409,9 +417,15 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo sitemap = new AltosSiteMap(); pane.add("Site Map", sitemap); + displays.add(sitemap); gps_info = new TeleGPSInfo(); pane.add("Info", gps_info); + displays.add(gps_info); + + info_table = new AltosInfoTable(); + pane.add("Table", info_table); + displays.add(info_table); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); diff --git a/telegps/TeleGPSInfo.java b/telegps/TeleGPSInfo.java index 0fba77d5..da3df44e 100644 --- a/telegps/TeleGPSInfo.java +++ b/telegps/TeleGPSInfo.java @@ -58,6 +58,10 @@ public class TeleGPSInfo extends JComponent implements AltosFlightDisplay { show(String.format(format, v)); } + void show(String format, int v) { + show(String.format(format, v)); + } + void reset() { lights.set(false); value.setText(""); -- cgit v1.2.3 From bf684a4c290573a3aa627fd8ddf6f6ebbe5fa057 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 29 May 2014 14:36:14 -0700 Subject: telegps: Add graph display Moved the altosui graph files to altosuilib and fixed things up. Signed-off-by: Keith Packard --- altoslib/AltosLib.java | 4 + altosui/AltosGraph.java | 429 ------------------------------------ altosui/AltosGraphDataPoint.java | 242 -------------------- altosui/AltosGraphDataSet.java | 95 -------- altosui/AltosGraphUI.java | 19 +- altosui/AltosIgnitor.java | 6 +- altosui/Makefile.am | 3 - altosuilib/AltosGraph.java | 428 +++++++++++++++++++++++++++++++++++ altosuilib/AltosGraphDataPoint.java | 241 ++++++++++++++++++++ altosuilib/AltosGraphDataSet.java | 94 ++++++++ altosuilib/AltosUIGraph.java | 4 +- altosuilib/Makefile.am | 3 + telegps/Makefile.am | 5 +- telegps/TeleGPS.java | 10 + 14 files changed, 801 insertions(+), 782 deletions(-) delete mode 100644 altosui/AltosGraph.java delete mode 100644 altosui/AltosGraphDataPoint.java delete mode 100644 altosui/AltosGraphDataSet.java create mode 100644 altosuilib/AltosGraph.java create mode 100644 altosuilib/AltosGraphDataPoint.java create mode 100644 altosuilib/AltosGraphDataSet.java (limited to 'altoslib') diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java index 5e18202f..3aef077a 100644 --- a/altoslib/AltosLib.java +++ b/altoslib/AltosLib.java @@ -479,4 +479,8 @@ public class AltosLib { default: return "unknown"; } } + + public static String ignitor_name(int i) { + return String.format("Ignitor %c", 'A' + i); + } } diff --git a/altosui/AltosGraph.java b/altosui/AltosGraph.java deleted file mode 100644 index ba3875c6..00000000 --- a/altosui/AltosGraph.java +++ /dev/null @@ -1,429 +0,0 @@ -/* - * Copyright © 2013 Keith Packard - * - * 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 altosui; - -import java.io.*; -import java.util.ArrayList; - -import java.awt.*; -import javax.swing.*; -import org.altusmetrum.altoslib_4.*; -import org.altusmetrum.altosuilib_2.*; - -import org.jfree.ui.*; -import org.jfree.chart.*; -import org.jfree.chart.plot.*; -import org.jfree.chart.axis.*; -import org.jfree.chart.renderer.*; -import org.jfree.chart.renderer.xy.*; -import org.jfree.chart.labels.*; -import org.jfree.data.xy.*; -import org.jfree.data.*; - -class AltosVoltage extends AltosUnits { - - public double value(double v, boolean imperial_units) { - return v; - } - - public double inverse(double v, boolean imperial_units) { - return v; - } - - public String show_units(boolean imperial_units) { - return "V"; - } - - public String say_units(boolean imperial_units) { - return "volts"; - } - - public int show_fraction(int width, boolean imperial_units) { - return width / 2; - } -} - -class AltosNsat extends AltosUnits { - - public double value(double v, boolean imperial_units) { - return v; - } - - public double inverse(double v, boolean imperial_units) { - return v; - } - - public String show_units(boolean imperial_units) { - return "Sats"; - } - - public String say_units(boolean imperial_units) { - return "Satellites"; - } - - public int show_fraction(int width, boolean imperial_units) { - return 0; - } -} - -class AltosPressure extends AltosUnits { - - public double value(double p, boolean imperial_units) { - return p; - } - - public double inverse(double p, boolean imperial_units) { - return p; - } - - public String show_units(boolean imperial_units) { - return "Pa"; - } - - public String say_units(boolean imperial_units) { - return "pascals"; - } - - public int show_fraction(int width, boolean imperial_units) { - return 0; - } -} - -class AltosDbm extends AltosUnits { - - public double value(double d, boolean imperial_units) { - return d; - } - - public double inverse(double d, boolean imperial_units) { - return d; - } - - public String show_units(boolean imperial_units) { - return "dBm"; - } - - public String say_units(boolean imperial_units) { - return "D B M"; - } - - public int show_fraction(int width, boolean imperial_units) { - return 0; - } -} - -class AltosGyroUnits extends AltosUnits { - - public double value(double p, boolean imperial_units) { - return p; - } - - public double inverse(double p, boolean imperial_units) { - return p; - } - - public String show_units(boolean imperial_units) { - return "°/sec"; - } - - public String say_units(boolean imperial_units) { - return "degrees per second"; - } - - public int show_fraction(int width, boolean imperial_units) { - return 1; - } -} - -class AltosMagUnits extends AltosUnits { - - public double value(double p, boolean imperial_units) { - return p; - } - - public double inverse(double p, boolean imperial_units) { - return p; - } - - public String show_units(boolean imperial_units) { - return "Ga"; - } - - public String say_units(boolean imperial_units) { - return "gauss"; - } - - public int show_fraction(int width, boolean imperial_units) { - return 2; - } -} - -public class AltosGraph extends AltosUIGraph { - - static final private Color height_color = new Color(194,31,31); - static final private Color gps_height_color = new Color(150,31,31); - static final private Color pressure_color = new Color (225,31,31); - static final private Color range_color = new Color(100, 31, 31); - static final private Color distance_color = new Color(100, 31, 194); - static final private Color speed_color = new Color(31,194,31); - static final private Color accel_color = new Color(31,31,194); - static final private Color voltage_color = new Color(194, 194, 31); - static final private Color battery_voltage_color = new Color(194, 194, 31); - static final private Color drogue_voltage_color = new Color(150, 150, 31); - static final private Color main_voltage_color = new Color(100, 100, 31); - static final private Color gps_nsat_color = new Color (194, 31, 194); - static final private Color gps_nsat_solution_color = new Color (194, 31, 194); - static final private Color gps_nsat_view_color = new Color (150, 31, 150); - static final private Color gps_course_color = new Color (100, 31, 112); - static final private Color gps_ground_speed_color = new Color (31, 112, 100); - static final private Color gps_climb_rate_color = new Color (31, 31, 112); - static final private Color temperature_color = new Color (31, 194, 194); - static final private Color dbm_color = new Color(31, 100, 100); - static final private Color state_color = new Color(0,0,0); - static final private Color accel_x_color = new Color(255, 0, 0); - static final private Color accel_y_color = new Color(0, 255, 0); - static final private Color accel_z_color = new Color(0, 0, 255); - static final private Color gyro_x_color = new Color(192, 0, 0); - static final private Color gyro_y_color = new Color(0, 192, 0); - static final private Color gyro_z_color = new Color(0, 0, 192); - static final private Color mag_x_color = new Color(128, 0, 0); - static final private Color mag_y_color = new Color(0, 128, 0); - static final private Color mag_z_color = new Color(0, 0, 128); - static final private Color orient_color = new Color(31, 31, 31); - - static AltosVoltage voltage_units = new AltosVoltage(); - static AltosPressure pressure_units = new AltosPressure(); - static AltosNsat nsat_units = new AltosNsat(); - static AltosDbm dbm_units = new AltosDbm(); - static AltosGyroUnits gyro_units = new AltosGyroUnits(); - static AltosOrient orient_units = new AltosOrient(); - static AltosMagUnits mag_units = new AltosMagUnits(); - - AltosUIAxis height_axis, speed_axis, accel_axis, voltage_axis, temperature_axis, nsat_axis, dbm_axis; - AltosUIAxis distance_axis, pressure_axis; - AltosUIAxis gyro_axis, orient_axis, mag_axis; - AltosUIAxis course_axis; - - public AltosGraph(AltosUIEnable enable, AltosFlightStats stats, AltosGraphDataSet dataSet) { - super(enable); - - height_axis = newAxis("Height", AltosConvert.height, height_color); - pressure_axis = newAxis("Pressure", pressure_units, pressure_color, 0); - speed_axis = newAxis("Speed", AltosConvert.speed, speed_color); - accel_axis = newAxis("Acceleration", AltosConvert.accel, accel_color); - voltage_axis = newAxis("Voltage", voltage_units, voltage_color); - temperature_axis = newAxis("Temperature", AltosConvert.temperature, temperature_color, 0); - nsat_axis = newAxis("Satellites", nsat_units, gps_nsat_color, - AltosUIAxis.axis_include_zero | AltosUIAxis.axis_integer); - dbm_axis = newAxis("Signal Strength", dbm_units, dbm_color, 0); - distance_axis = newAxis("Distance", AltosConvert.distance, range_color); - - gyro_axis = newAxis("Rotation Rate", gyro_units, gyro_z_color, 0); - orient_axis = newAxis("Tilt Angle", orient_units, orient_color, 0); - mag_axis = newAxis("Magnetic Field", mag_units, mag_x_color, 0); - course_axis = newAxis("Course", orient_units, gps_course_color, 0); - - addMarker("State", AltosGraphDataPoint.data_state, state_color); - addSeries("Height", - AltosGraphDataPoint.data_height, - AltosConvert.height, - height_color, - true, - height_axis); - addSeries("Pressure", - AltosGraphDataPoint.data_pressure, - pressure_units, - pressure_color, - false, - pressure_axis); - addSeries("Speed", - AltosGraphDataPoint.data_speed, - AltosConvert.speed, - speed_color, - true, - speed_axis); - addSeries("Acceleration", - AltosGraphDataPoint.data_accel, - AltosConvert.accel, - accel_color, - true, - accel_axis); - if (stats.has_gps) { - addSeries("Range", - AltosGraphDataPoint.data_range, - AltosConvert.distance, - range_color, - false, - distance_axis); - addSeries("Distance", - AltosGraphDataPoint.data_distance, - AltosConvert.distance, - distance_color, - false, - distance_axis); - addSeries("GPS Height", - AltosGraphDataPoint.data_gps_height, - AltosConvert.height, - gps_height_color, - false, - height_axis); - addSeries("GPS Satellites in Solution", - AltosGraphDataPoint.data_gps_nsat_solution, - nsat_units, - gps_nsat_solution_color, - false, - nsat_axis); - addSeries("GPS Satellites in View", - AltosGraphDataPoint.data_gps_nsat_view, - nsat_units, - gps_nsat_view_color, - false, - nsat_axis); - addSeries("GPS Course", - AltosGraphDataPoint.data_gps_course, - orient_units, - gps_course_color, - false, - course_axis); - addSeries("GPS Ground Speed", - AltosGraphDataPoint.data_gps_ground_speed, - AltosConvert.speed, - gps_ground_speed_color, - false, - speed_axis); - addSeries("GPS Climb Rate", - AltosGraphDataPoint.data_gps_climb_rate, - AltosConvert.speed, - gps_climb_rate_color, - false, - speed_axis); - } - if (stats.has_rssi) - addSeries("Received Signal Strength", - AltosGraphDataPoint.data_rssi, - dbm_units, - dbm_color, - false, - dbm_axis); - if (stats.has_other_adc) { - addSeries("Temperature", - AltosGraphDataPoint.data_temperature, - AltosConvert.temperature, - temperature_color, - false, - temperature_axis); - addSeries("Battery Voltage", - AltosGraphDataPoint.data_battery_voltage, - voltage_units, - battery_voltage_color, - false, - voltage_axis); - addSeries("Drogue Voltage", - AltosGraphDataPoint.data_drogue_voltage, - voltage_units, - drogue_voltage_color, - false, - voltage_axis); - addSeries("Main Voltage", - AltosGraphDataPoint.data_main_voltage, - voltage_units, - main_voltage_color, - false, - voltage_axis); - } - - if (stats.has_imu) { - addSeries("Acceleration X", - AltosGraphDataPoint.data_accel_x, - AltosConvert.accel, - accel_x_color, - false, - accel_axis); - addSeries("Acceleration Y", - AltosGraphDataPoint.data_accel_y, - AltosConvert.accel, - accel_y_color, - false, - accel_axis); - addSeries("Acceleration Z", - AltosGraphDataPoint.data_accel_z, - AltosConvert.accel, - accel_z_color, - false, - accel_axis); - addSeries("Rotation Rate X", - AltosGraphDataPoint.data_gyro_x, - gyro_units, - gyro_x_color, - false, - gyro_axis); - addSeries("Rotation Rate Y", - AltosGraphDataPoint.data_gyro_y, - gyro_units, - gyro_y_color, - false, - gyro_axis); - addSeries("Rotation Rate Z", - AltosGraphDataPoint.data_gyro_z, - gyro_units, - gyro_z_color, - false, - gyro_axis); - } - if (stats.has_mag) { - addSeries("Magnetometer X", - AltosGraphDataPoint.data_mag_x, - mag_units, - mag_x_color, - false, - mag_axis); - addSeries("Magnetometer Y", - AltosGraphDataPoint.data_mag_y, - mag_units, - mag_y_color, - false, - mag_axis); - addSeries("Magnetometer Z", - AltosGraphDataPoint.data_mag_z, - mag_units, - mag_z_color, - false, - mag_axis); - } - if (stats.has_orient) - addSeries("Tilt Angle", - AltosGraphDataPoint.data_orient, - orient_units, - orient_color, - false, - orient_axis); - if (stats.num_ignitor > 0) { - for (int i = 0; i < stats.num_ignitor; i++) - addSeries(AltosIgnitor.ignitor_name(i), - AltosGraphDataPoint.data_ignitor_0 + i, - voltage_units, - main_voltage_color, - false, - voltage_axis); - for (int i = 0; i < stats.num_ignitor; i++) - addMarker(AltosIgnitor.ignitor_name(i), AltosGraphDataPoint.data_ignitor_fired_0 + i, state_color); - } - - setDataSet(dataSet); - } -} diff --git a/altosui/AltosGraphDataPoint.java b/altosui/AltosGraphDataPoint.java deleted file mode 100644 index 06a9b62d..00000000 --- a/altosui/AltosGraphDataPoint.java +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Copyright © 2013 Keith Packard - * - * 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 altosui; - -import org.altusmetrum.altosuilib_2.*; -import org.altusmetrum.altoslib_4.*; - -public class AltosGraphDataPoint implements AltosUIDataPoint { - - AltosState state; - - public static final int data_height = 0; - public static final int data_speed = 1; - public static final int data_accel = 2; - public static final int data_temp = 3; - public static final int data_battery_voltage = 4; - public static final int data_drogue_voltage = 5; - public static final int data_main_voltage = 6; - public static final int data_rssi = 7; - public static final int data_state = 8; - public static final int data_gps_height = 9; - public static final int data_gps_nsat_solution = 10; - public static final int data_gps_nsat_view = 11; - public static final int data_temperature = 12; - public static final int data_range = 13; - public static final int data_distance = 14; - public static final int data_pressure = 15; - public static final int data_accel_x = 16; - public static final int data_accel_y = 17; - public static final int data_accel_z = 18; - public static final int data_gyro_x = 19; - public static final int data_gyro_y = 20; - public static final int data_gyro_z = 21; - public static final int data_mag_x = 22; - public static final int data_mag_y = 23; - public static final int data_mag_z = 24; - public static final int data_orient = 25; - public static final int data_gps_course = 26; - public static final int data_gps_ground_speed = 27; - public static final int data_gps_climb_rate = 28; - public static final int data_ignitor_0 = 29; - public static final int data_ignitor_num = 32; - public static final int data_ignitor_max = data_ignitor_0 + data_ignitor_num - 1; - public static final int data_ignitor_fired_0 = data_ignitor_0 + data_ignitor_num; - public static final int data_ignitor_fired_max = data_ignitor_fired_0 + data_ignitor_num - 1; - - public double x() throws AltosUIDataMissing { - double time = state.time_since_boost(); - if (time < -2) - throw new AltosUIDataMissing(-1); - return time; - } - - public double y(int index) throws AltosUIDataMissing { - double y = AltosLib.MISSING; - switch (index) { - case data_height: - y = state.height(); - break; - case data_speed: - y = state.speed(); - break; - case data_accel: - y = state.acceleration(); - break; - case data_temp: - y = state.temperature; - break; - case data_battery_voltage: - y = state.battery_voltage; - break; - case data_drogue_voltage: - y = state.apogee_voltage; - break; - case data_main_voltage: - y = state.main_voltage; - break; - case data_rssi: - y = state.rssi; - break; - case data_gps_height: - y = state.gps_height; - break; - case data_gps_nsat_solution: - if (state.gps != null) - y = state.gps.nsat; - break; - case data_gps_nsat_view: - if (state.gps != null && state.gps.cc_gps_sat != null) - y = state.gps.cc_gps_sat.length; - break; - case data_temperature: - y = state.temperature; - break; - case data_range: - y = state.range; - break; - case data_distance: - if (state.from_pad != null) - y = state.from_pad.distance; - break; - case data_pressure: - y = state.pressure(); - break; - - case data_accel_x: - case data_accel_y: - case data_accel_z: - case data_gyro_x: - case data_gyro_y: - case data_gyro_z: - AltosIMU imu = state.imu; - if (imu == null) - break; - switch (index) { - case data_accel_x: - y = imu.accel_x; - break; - case data_accel_y: - y = imu.accel_y; - break; - case data_accel_z: - y = imu.accel_z; - break; - case data_gyro_x: - y = imu.gyro_x; - break; - case data_gyro_y: - y = imu.gyro_y; - break; - case data_gyro_z: - y = imu.gyro_z; - break; - } - break; - case data_mag_x: - case data_mag_y: - case data_mag_z: - AltosMag mag = state.mag; - if (mag == null) - break; - switch (index) { - case data_mag_x: - y = mag.x; - break; - case data_mag_y: - y = mag.y; - break; - case data_mag_z: - y = mag.z; - break; - } - break; - case data_orient: - y = state.orient(); - break; - case data_gps_course: - if (state.gps != null) - y = state.gps.course; - else - y = AltosLib.MISSING; - break; - case data_gps_ground_speed: - if (state.gps != null) - y = state.gps.ground_speed; - else - y = AltosLib.MISSING; - break; - case data_gps_climb_rate: - if (state.gps != null) - y = state.gps.climb_rate; - else - y = AltosLib.MISSING; - break; - default: - if (data_ignitor_0 <= index && index <= data_ignitor_max) { - int ignitor = index - data_ignitor_0; - if (state.ignitor_voltage != null && ignitor < state.ignitor_voltage.length) - y = state.ignitor_voltage[ignitor]; - } else if (data_ignitor_fired_0 <= index && index <= data_ignitor_fired_max) { - int ignitor = index - data_ignitor_fired_0; - if (state.ignitor_voltage != null && ignitor < state.ignitor_voltage.length) { - if ((state.pyro_fired & (1 << ignitor)) != 0) - y = 1; - else - y = 0; - } - } - break; - } - if (y == AltosLib.MISSING) - throw new AltosUIDataMissing(index); - return y; - } - - public int id(int index) { - if (index == data_state) { - int s = state.state; - if (Altos.ao_flight_boost <= s && s <= Altos.ao_flight_landed) - return s; - } else if (data_ignitor_fired_0 <= index && index <= data_ignitor_fired_max) { - int ignitor = index - data_ignitor_fired_0; - if (state.ignitor_voltage != null && ignitor < state.ignitor_voltage.length) { - if (state.ignitor_voltage != null && ignitor < state.ignitor_voltage.length) { - if ((state.pyro_fired & (1 << ignitor)) != 0) - return 1; - } - } - } - return -1; - } - - public String id_name(int index) { - if (index == data_state) { - return state.state_name(); - } else if (data_ignitor_fired_0 <= index && index <= data_ignitor_fired_max) { - int ignitor = index - data_ignitor_fired_0; - if (state.ignitor_voltage != null && ignitor < state.ignitor_voltage.length) - return AltosIgnitor.ignitor_name(ignitor); - } - return ""; - } - - public AltosGraphDataPoint (AltosState state) { - this.state = state; - } -} diff --git a/altosui/AltosGraphDataSet.java b/altosui/AltosGraphDataSet.java deleted file mode 100644 index a90c2563..00000000 --- a/altosui/AltosGraphDataSet.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright © 2013 Keith Packard - * - * 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 altosui; - -import java.lang.*; -import java.io.*; -import java.util.*; -import org.altusmetrum.altoslib_4.*; -import org.altusmetrum.altosuilib_2.*; - -class AltosGraphIterator implements Iterator { - AltosGraphDataSet dataSet; - Iterator iterator; - - public boolean hasNext() { - return iterator.hasNext(); - } - - public AltosUIDataPoint next() { - AltosState state = iterator.next(); - - if (state.flight != AltosLib.MISSING) { - if (dataSet.callsign == null && state.callsign != null) - dataSet.callsign = state.callsign; - - if (dataSet.serial == 0 && state.serial != 0) - dataSet.serial = state.serial; - - if (dataSet.flight == 0 && state.flight != 0) - dataSet.flight = state.flight; - } - - return new AltosGraphDataPoint(state); - } - - public AltosGraphIterator (Iterator iterator, AltosGraphDataSet dataSet) { - this.iterator = iterator; - this.dataSet = dataSet; - } - - public void remove() { - } -} - -class AltosGraphIterable implements Iterable { - AltosGraphDataSet dataSet; - - public Iterator iterator() { - return new AltosGraphIterator(dataSet.states.iterator(), dataSet); - } - - public AltosGraphIterable(AltosGraphDataSet dataSet) { - this.dataSet = dataSet; - } -} - -public class AltosGraphDataSet implements AltosUIDataSet { - String callsign; - int serial; - int flight; - AltosStateIterable states; - - public String name() { - if (callsign != null) - return String.format("%s - %d/%d", callsign, serial, flight); - else - return String.format("%d/%d", serial, flight); - } - - public Iterable dataPoints() { - return new AltosGraphIterable(this); - } - - public AltosGraphDataSet (AltosStateIterable states) { - this.states = states; - this.callsign = null; - this.serial = 0; - this.flight = 0; - } -} diff --git a/altosui/AltosGraphUI.java b/altosui/AltosGraphUI.java index 33e12130..9e8a1939 100644 --- a/altosui/AltosGraphUI.java +++ b/altosui/AltosGraphUI.java @@ -1,6 +1,19 @@ - -// Copyright (c) 2010 Anthony Towns -// GPL v2 or later +/* + * Copyright © 2010 Anthony Towns + * + * 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 or any later version 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 altosui; diff --git a/altosui/AltosIgnitor.java b/altosui/AltosIgnitor.java index 27917b30..7f62938d 100644 --- a/altosui/AltosIgnitor.java +++ b/altosui/AltosIgnitor.java @@ -114,10 +114,6 @@ public class AltosIgnitor extends JComponent implements AltosFlightDisplay { } } - public static String ignitor_name(int i) { - return String.format("Ignitor %c", 'A' + i); - } - class Ignitor extends LaunchStatus { int ignitor; @@ -131,7 +127,7 @@ public class AltosIgnitor extends JComponent implements AltosFlightDisplay { } public Ignitor (GridBagLayout layout, int y) { - super(layout, y, String.format ("%s Voltage", ignitor_name(y))); + super(layout, y, String.format ("%s Voltage", AltosLib.ignitor_name(y))); ignitor = y; } } diff --git a/altosui/Makefile.am b/altosui/Makefile.am index add46825..1eb2d967 100644 --- a/altosui/Makefile.am +++ b/altosui/Makefile.am @@ -35,9 +35,6 @@ altosui_JAVA = \ AltosPad.java \ AltosUIPreferencesBackend.java \ AltosUI.java \ - AltosGraph.java \ - AltosGraphDataPoint.java \ - AltosGraphDataSet.java \ AltosGraphUI.java JFREECHART_CLASS= \ diff --git a/altosuilib/AltosGraph.java b/altosuilib/AltosGraph.java new file mode 100644 index 00000000..5e5a35cf --- /dev/null +++ b/altosuilib/AltosGraph.java @@ -0,0 +1,428 @@ +/* + * Copyright © 2013 Keith Packard + * + * 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.altosuilib_2; + +import java.io.*; +import java.util.ArrayList; + +import java.awt.*; +import javax.swing.*; +import org.altusmetrum.altoslib_4.*; + +import org.jfree.ui.*; +import org.jfree.chart.*; +import org.jfree.chart.plot.*; +import org.jfree.chart.axis.*; +import org.jfree.chart.renderer.*; +import org.jfree.chart.renderer.xy.*; +import org.jfree.chart.labels.*; +import org.jfree.data.xy.*; +import org.jfree.data.*; + +class AltosVoltage extends AltosUnits { + + public double value(double v, boolean imperial_units) { + return v; + } + + public double inverse(double v, boolean imperial_units) { + return v; + } + + public String show_units(boolean imperial_units) { + return "V"; + } + + public String say_units(boolean imperial_units) { + return "volts"; + } + + public int show_fraction(int width, boolean imperial_units) { + return width / 2; + } +} + +class AltosNsat extends AltosUnits { + + public double value(double v, boolean imperial_units) { + return v; + } + + public double inverse(double v, boolean imperial_units) { + return v; + } + + public String show_units(boolean imperial_units) { + return "Sats"; + } + + public String say_units(boolean imperial_units) { + return "Satellites"; + } + + public int show_fraction(int width, boolean imperial_units) { + return 0; + } +} + +class AltosPressure extends AltosUnits { + + public double value(double p, boolean imperial_units) { + return p; + } + + public double inverse(double p, boolean imperial_units) { + return p; + } + + public String show_units(boolean imperial_units) { + return "Pa"; + } + + public String say_units(boolean imperial_units) { + return "pascals"; + } + + public int show_fraction(int width, boolean imperial_units) { + return 0; + } +} + +class AltosDbm extends AltosUnits { + + public double value(double d, boolean imperial_units) { + return d; + } + + public double inverse(double d, boolean imperial_units) { + return d; + } + + public String show_units(boolean imperial_units) { + return "dBm"; + } + + public String say_units(boolean imperial_units) { + return "D B M"; + } + + public int show_fraction(int width, boolean imperial_units) { + return 0; + } +} + +class AltosGyroUnits extends AltosUnits { + + public double value(double p, boolean imperial_units) { + return p; + } + + public double inverse(double p, boolean imperial_units) { + return p; + } + + public String show_units(boolean imperial_units) { + return "°/sec"; + } + + public String say_units(boolean imperial_units) { + return "degrees per second"; + } + + public int show_fraction(int width, boolean imperial_units) { + return 1; + } +} + +class AltosMagUnits extends AltosUnits { + + public double value(double p, boolean imperial_units) { + return p; + } + + public double inverse(double p, boolean imperial_units) { + return p; + } + + public String show_units(boolean imperial_units) { + return "Ga"; + } + + public String say_units(boolean imperial_units) { + return "gauss"; + } + + public int show_fraction(int width, boolean imperial_units) { + return 2; + } +} + +public class AltosGraph extends AltosUIGraph { + + static final private Color height_color = new Color(194,31,31); + static final private Color gps_height_color = new Color(150,31,31); + static final private Color pressure_color = new Color (225,31,31); + static final private Color range_color = new Color(100, 31, 31); + static final private Color distance_color = new Color(100, 31, 194); + static final private Color speed_color = new Color(31,194,31); + static final private Color accel_color = new Color(31,31,194); + static final private Color voltage_color = new Color(194, 194, 31); + static final private Color battery_voltage_color = new Color(194, 194, 31); + static final private Color drogue_voltage_color = new Color(150, 150, 31); + static final private Color main_voltage_color = new Color(100, 100, 31); + static final private Color gps_nsat_color = new Color (194, 31, 194); + static final private Color gps_nsat_solution_color = new Color (194, 31, 194); + static final private Color gps_nsat_view_color = new Color (150, 31, 150); + static final private Color gps_course_color = new Color (100, 31, 112); + static final private Color gps_ground_speed_color = new Color (31, 112, 100); + static final private Color gps_climb_rate_color = new Color (31, 31, 112); + static final private Color temperature_color = new Color (31, 194, 194); + static final private Color dbm_color = new Color(31, 100, 100); + static final private Color state_color = new Color(0,0,0); + static final private Color accel_x_color = new Color(255, 0, 0); + static final private Color accel_y_color = new Color(0, 255, 0); + static final private Color accel_z_color = new Color(0, 0, 255); + static final private Color gyro_x_color = new Color(192, 0, 0); + static final private Color gyro_y_color = new Color(0, 192, 0); + static final private Color gyro_z_color = new Color(0, 0, 192); + static final private Color mag_x_color = new Color(128, 0, 0); + static final private Color mag_y_color = new Color(0, 128, 0); + static final private Color mag_z_color = new Color(0, 0, 128); + static final private Color orient_color = new Color(31, 31, 31); + + static AltosVoltage voltage_units = new AltosVoltage(); + static AltosPressure pressure_units = new AltosPressure(); + static AltosNsat nsat_units = new AltosNsat(); + static AltosDbm dbm_units = new AltosDbm(); + static AltosGyroUnits gyro_units = new AltosGyroUnits(); + static AltosOrient orient_units = new AltosOrient(); + static AltosMagUnits mag_units = new AltosMagUnits(); + + AltosUIAxis height_axis, speed_axis, accel_axis, voltage_axis, temperature_axis, nsat_axis, dbm_axis; + AltosUIAxis distance_axis, pressure_axis; + AltosUIAxis gyro_axis, orient_axis, mag_axis; + AltosUIAxis course_axis; + + public AltosGraph(AltosUIEnable enable, AltosFlightStats stats, AltosGraphDataSet dataSet) { + super(enable); + + height_axis = newAxis("Height", AltosConvert.height, height_color); + pressure_axis = newAxis("Pressure", pressure_units, pressure_color, 0); + speed_axis = newAxis("Speed", AltosConvert.speed, speed_color); + accel_axis = newAxis("Acceleration", AltosConvert.accel, accel_color); + voltage_axis = newAxis("Voltage", voltage_units, voltage_color); + temperature_axis = newAxis("Temperature", AltosConvert.temperature, temperature_color, 0); + nsat_axis = newAxis("Satellites", nsat_units, gps_nsat_color, + AltosUIAxis.axis_include_zero | AltosUIAxis.axis_integer); + dbm_axis = newAxis("Signal Strength", dbm_units, dbm_color, 0); + distance_axis = newAxis("Distance", AltosConvert.distance, range_color); + + gyro_axis = newAxis("Rotation Rate", gyro_units, gyro_z_color, 0); + orient_axis = newAxis("Tilt Angle", orient_units, orient_color, 0); + mag_axis = newAxis("Magnetic Field", mag_units, mag_x_color, 0); + course_axis = newAxis("Course", orient_units, gps_course_color, 0); + + addMarker("State", AltosGraphDataPoint.data_state, state_color); + addSeries("Height", + AltosGraphDataPoint.data_height, + AltosConvert.height, + height_color, + true, + height_axis); + addSeries("Pressure", + AltosGraphDataPoint.data_pressure, + pressure_units, + pressure_color, + false, + pressure_axis); + addSeries("Speed", + AltosGraphDataPoint.data_speed, + AltosConvert.speed, + speed_color, + true, + speed_axis); + addSeries("Acceleration", + AltosGraphDataPoint.data_accel, + AltosConvert.accel, + accel_color, + true, + accel_axis); + if (stats.has_gps) { + addSeries("Range", + AltosGraphDataPoint.data_range, + AltosConvert.distance, + range_color, + false, + distance_axis); + addSeries("Distance", + AltosGraphDataPoint.data_distance, + AltosConvert.distance, + distance_color, + false, + distance_axis); + addSeries("GPS Height", + AltosGraphDataPoint.data_gps_height, + AltosConvert.height, + gps_height_color, + false, + height_axis); + addSeries("GPS Satellites in Solution", + AltosGraphDataPoint.data_gps_nsat_solution, + nsat_units, + gps_nsat_solution_color, + false, + nsat_axis); + addSeries("GPS Satellites in View", + AltosGraphDataPoint.data_gps_nsat_view, + nsat_units, + gps_nsat_view_color, + false, + nsat_axis); + addSeries("GPS Course", + AltosGraphDataPoint.data_gps_course, + orient_units, + gps_course_color, + false, + course_axis); + addSeries("GPS Ground Speed", + AltosGraphDataPoint.data_gps_ground_speed, + AltosConvert.speed, + gps_ground_speed_color, + false, + speed_axis); + addSeries("GPS Climb Rate", + AltosGraphDataPoint.data_gps_climb_rate, + AltosConvert.speed, + gps_climb_rate_color, + false, + speed_axis); + } + if (stats.has_rssi) + addSeries("Received Signal Strength", + AltosGraphDataPoint.data_rssi, + dbm_units, + dbm_color, + false, + dbm_axis); + if (stats.has_other_adc) { + addSeries("Temperature", + AltosGraphDataPoint.data_temperature, + AltosConvert.temperature, + temperature_color, + false, + temperature_axis); + addSeries("Battery Voltage", + AltosGraphDataPoint.data_battery_voltage, + voltage_units, + battery_voltage_color, + false, + voltage_axis); + addSeries("Drogue Voltage", + AltosGraphDataPoint.data_drogue_voltage, + voltage_units, + drogue_voltage_color, + false, + voltage_axis); + addSeries("Main Voltage", + AltosGraphDataPoint.data_main_voltage, + voltage_units, + main_voltage_color, + false, + voltage_axis); + } + + if (stats.has_imu) { + addSeries("Acceleration X", + AltosGraphDataPoint.data_accel_x, + AltosConvert.accel, + accel_x_color, + false, + accel_axis); + addSeries("Acceleration Y", + AltosGraphDataPoint.data_accel_y, + AltosConvert.accel, + accel_y_color, + false, + accel_axis); + addSeries("Acceleration Z", + AltosGraphDataPoint.data_accel_z, + AltosConvert.accel, + accel_z_color, + false, + accel_axis); + addSeries("Rotation Rate X", + AltosGraphDataPoint.data_gyro_x, + gyro_units, + gyro_x_color, + false, + gyro_axis); + addSeries("Rotation Rate Y", + AltosGraphDataPoint.data_gyro_y, + gyro_units, + gyro_y_color, + false, + gyro_axis); + addSeries("Rotation Rate Z", + AltosGraphDataPoint.data_gyro_z, + gyro_units, + gyro_z_color, + false, + gyro_axis); + } + if (stats.has_mag) { + addSeries("Magnetometer X", + AltosGraphDataPoint.data_mag_x, + mag_units, + mag_x_color, + false, + mag_axis); + addSeries("Magnetometer Y", + AltosGraphDataPoint.data_mag_y, + mag_units, + mag_y_color, + false, + mag_axis); + addSeries("Magnetometer Z", + AltosGraphDataPoint.data_mag_z, + mag_units, + mag_z_color, + false, + mag_axis); + } + if (stats.has_orient) + addSeries("Tilt Angle", + AltosGraphDataPoint.data_orient, + orient_units, + orient_color, + false, + orient_axis); + if (stats.num_ignitor > 0) { + for (int i = 0; i < stats.num_ignitor; i++) + addSeries(AltosLib.ignitor_name(i), + AltosGraphDataPoint.data_ignitor_0 + i, + voltage_units, + main_voltage_color, + false, + voltage_axis); + for (int i = 0; i < stats.num_ignitor; i++) + addMarker(AltosLib.ignitor_name(i), AltosGraphDataPoint.data_ignitor_fired_0 + i, state_color); + } + + setDataSet(dataSet); + } +} diff --git a/altosuilib/AltosGraphDataPoint.java b/altosuilib/AltosGraphDataPoint.java new file mode 100644 index 00000000..a64a9d14 --- /dev/null +++ b/altosuilib/AltosGraphDataPoint.java @@ -0,0 +1,241 @@ +/* + * Copyright © 2013 Keith Packard + * + * 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.altosuilib_2; + +import org.altusmetrum.altoslib_4.*; + +public class AltosGraphDataPoint implements AltosUIDataPoint { + + AltosState state; + + public static final int data_height = 0; + public static final int data_speed = 1; + public static final int data_accel = 2; + public static final int data_temp = 3; + public static final int data_battery_voltage = 4; + public static final int data_drogue_voltage = 5; + public static final int data_main_voltage = 6; + public static final int data_rssi = 7; + public static final int data_state = 8; + public static final int data_gps_height = 9; + public static final int data_gps_nsat_solution = 10; + public static final int data_gps_nsat_view = 11; + public static final int data_temperature = 12; + public static final int data_range = 13; + public static final int data_distance = 14; + public static final int data_pressure = 15; + public static final int data_accel_x = 16; + public static final int data_accel_y = 17; + public static final int data_accel_z = 18; + public static final int data_gyro_x = 19; + public static final int data_gyro_y = 20; + public static final int data_gyro_z = 21; + public static final int data_mag_x = 22; + public static final int data_mag_y = 23; + public static final int data_mag_z = 24; + public static final int data_orient = 25; + public static final int data_gps_course = 26; + public static final int data_gps_ground_speed = 27; + public static final int data_gps_climb_rate = 28; + public static final int data_ignitor_0 = 29; + public static final int data_ignitor_num = 32; + public static final int data_ignitor_max = data_ignitor_0 + data_ignitor_num - 1; + public static final int data_ignitor_fired_0 = data_ignitor_0 + data_ignitor_num; + public static final int data_ignitor_fired_max = data_ignitor_fired_0 + data_ignitor_num - 1; + + public double x() throws AltosUIDataMissing { + double time = state.time_since_boost(); + if (time < -2) + throw new AltosUIDataMissing(-1); + return time; + } + + public double y(int index) throws AltosUIDataMissing { + double y = AltosLib.MISSING; + switch (index) { + case data_height: + y = state.height(); + break; + case data_speed: + y = state.speed(); + break; + case data_accel: + y = state.acceleration(); + break; + case data_temp: + y = state.temperature; + break; + case data_battery_voltage: + y = state.battery_voltage; + break; + case data_drogue_voltage: + y = state.apogee_voltage; + break; + case data_main_voltage: + y = state.main_voltage; + break; + case data_rssi: + y = state.rssi; + break; + case data_gps_height: + y = state.gps_height; + break; + case data_gps_nsat_solution: + if (state.gps != null) + y = state.gps.nsat; + break; + case data_gps_nsat_view: + if (state.gps != null && state.gps.cc_gps_sat != null) + y = state.gps.cc_gps_sat.length; + break; + case data_temperature: + y = state.temperature; + break; + case data_range: + y = state.range; + break; + case data_distance: + if (state.from_pad != null) + y = state.from_pad.distance; + break; + case data_pressure: + y = state.pressure(); + break; + + case data_accel_x: + case data_accel_y: + case data_accel_z: + case data_gyro_x: + case data_gyro_y: + case data_gyro_z: + AltosIMU imu = state.imu; + if (imu == null) + break; + switch (index) { + case data_accel_x: + y = imu.accel_x; + break; + case data_accel_y: + y = imu.accel_y; + break; + case data_accel_z: + y = imu.accel_z; + break; + case data_gyro_x: + y = imu.gyro_x; + break; + case data_gyro_y: + y = imu.gyro_y; + break; + case data_gyro_z: + y = imu.gyro_z; + break; + } + break; + case data_mag_x: + case data_mag_y: + case data_mag_z: + AltosMag mag = state.mag; + if (mag == null) + break; + switch (index) { + case data_mag_x: + y = mag.x; + break; + case data_mag_y: + y = mag.y; + break; + case data_mag_z: + y = mag.z; + break; + } + break; + case data_orient: + y = state.orient(); + break; + case data_gps_course: + if (state.gps != null) + y = state.gps.course; + else + y = AltosLib.MISSING; + break; + case data_gps_ground_speed: + if (state.gps != null) + y = state.gps.ground_speed; + else + y = AltosLib.MISSING; + break; + case data_gps_climb_rate: + if (state.gps != null) + y = state.gps.climb_rate; + else + y = AltosLib.MISSING; + break; + default: + if (data_ignitor_0 <= index && index <= data_ignitor_max) { + int ignitor = index - data_ignitor_0; + if (state.ignitor_voltage != null && ignitor < state.ignitor_voltage.length) + y = state.ignitor_voltage[ignitor]; + } else if (data_ignitor_fired_0 <= index && index <= data_ignitor_fired_max) { + int ignitor = index - data_ignitor_fired_0; + if (state.ignitor_voltage != null && ignitor < state.ignitor_voltage.length) { + if ((state.pyro_fired & (1 << ignitor)) != 0) + y = 1; + else + y = 0; + } + } + break; + } + if (y == AltosLib.MISSING) + throw new AltosUIDataMissing(index); + return y; + } + + public int id(int index) { + if (index == data_state) { + int s = state.state; + if (AltosLib.ao_flight_boost <= s && s <= AltosLib.ao_flight_landed) + return s; + } else if (data_ignitor_fired_0 <= index && index <= data_ignitor_fired_max) { + int ignitor = index - data_ignitor_fired_0; + if (state.ignitor_voltage != null && ignitor < state.ignitor_voltage.length) { + if (state.ignitor_voltage != null && ignitor < state.ignitor_voltage.length) { + if ((state.pyro_fired & (1 << ignitor)) != 0) + return 1; + } + } + } + return -1; + } + + public String id_name(int index) { + if (index == data_state) { + return state.state_name(); + } else if (data_ignitor_fired_0 <= index && index <= data_ignitor_fired_max) { + int ignitor = index - data_ignitor_fired_0; + if (state.ignitor_voltage != null && ignitor < state.ignitor_voltage.length) + return AltosLib.ignitor_name(ignitor); + } + return ""; + } + + public AltosGraphDataPoint (AltosState state) { + this.state = state; + } +} diff --git a/altosuilib/AltosGraphDataSet.java b/altosuilib/AltosGraphDataSet.java new file mode 100644 index 00000000..36933e9b --- /dev/null +++ b/altosuilib/AltosGraphDataSet.java @@ -0,0 +1,94 @@ +/* + * Copyright © 2013 Keith Packard + * + * 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.altosuilib_2; + +import java.lang.*; +import java.io.*; +import java.util.*; +import org.altusmetrum.altoslib_4.*; + +class AltosGraphIterator implements Iterator { + AltosGraphDataSet dataSet; + Iterator iterator; + + public boolean hasNext() { + return iterator.hasNext(); + } + + public AltosUIDataPoint next() { + AltosState state = iterator.next(); + + if (state.flight != AltosLib.MISSING) { + if (dataSet.callsign == null && state.callsign != null) + dataSet.callsign = state.callsign; + + if (dataSet.serial == 0 && state.serial != 0) + dataSet.serial = state.serial; + + if (dataSet.flight == 0 && state.flight != 0) + dataSet.flight = state.flight; + } + + return new AltosGraphDataPoint(state); + } + + public AltosGraphIterator (Iterator iterator, AltosGraphDataSet dataSet) { + this.iterator = iterator; + this.dataSet = dataSet; + } + + public void remove() { + } +} + +class AltosGraphIterable implements Iterable { + AltosGraphDataSet dataSet; + + public Iterator iterator() { + return new AltosGraphIterator(dataSet.states.iterator(), dataSet); + } + + public AltosGraphIterable(AltosGraphDataSet dataSet) { + this.dataSet = dataSet; + } +} + +public class AltosGraphDataSet implements AltosUIDataSet { + String callsign; + int serial; + int flight; + AltosStateIterable states; + + public String name() { + if (callsign != null) + return String.format("%s - %d/%d", callsign, serial, flight); + else + return String.format("%d/%d", serial, flight); + } + + public Iterable dataPoints() { + return new AltosGraphIterable(this); + } + + public AltosGraphDataSet (AltosStateIterable states) { + this.states = states; + this.callsign = null; + this.serial = 0; + this.flight = 0; + } +} diff --git a/altosuilib/AltosUIGraph.java b/altosuilib/AltosUIGraph.java index 909c471b..9cca088d 100644 --- a/altosuilib/AltosUIGraph.java +++ b/altosuilib/AltosUIGraph.java @@ -85,8 +85,6 @@ public class AltosUIGraph implements AltosUnitsListener { public void addMarker(String label, int fetch, Color color) { AltosUIMarker marker = new AltosUIMarker(fetch, color, plot); - if (enable != null) - enable.add(label, marker, true); this.graphers.add(marker); } @@ -158,4 +156,4 @@ public class AltosUIGraph implements AltosUnitsListener { AltosPreferences.register_units_listener(this); } -} \ No newline at end of file +} diff --git a/altosuilib/Makefile.am b/altosuilib/Makefile.am index 65a8228a..e415fc5b 100644 --- a/altosuilib/Makefile.am +++ b/altosuilib/Makefile.am @@ -58,6 +58,9 @@ altosuilib_JAVA = \ AltosRomconfigUI.java \ AltosInfoTable.java \ AltosFlightInfoTableModel.java \ + AltosGraph.java \ + AltosGraphDataPoint.java \ + AltosGraphDataSet.java \ AltosBTDevice.java \ AltosBTDeviceIterator.java \ AltosBTManage.java \ diff --git a/telegps/Makefile.am b/telegps/Makefile.am index f064a488..87d8a66a 100644 --- a/telegps/Makefile.am +++ b/telegps/Makefile.am @@ -5,7 +5,7 @@ man_MANS=telegps.1 altoslibdir=$(libdir)/altos -CLASSPATH_ENV=mkdir -p $(JAVAROOT); CLASSPATH=".:classes:../altoslib/*:../altosuilib/*:../libaltos:$(JCOMMON)/jcommon.jar:$(JFREECHART)/jfreechart.jar $(FREETTS)/freetts.jar" +CLASSPATH_ENV=mkdir -p $(JAVAROOT); CLASSPATH=".:classes:../altoslib/*:../altosuilib/*:../libaltos:$(JCOMMON)/jcommon.jar:$(JFREECHART)/jfreechart.jar:$(FREETTS)/freetts.jar" bin_SCRIPTS=telegps @@ -18,7 +18,8 @@ telegps_JAVA= \ TeleGPSInfo.java \ TeleGPSConfig.java \ TeleGPSConfigUI.java \ - TeleGPSPreferences.java + TeleGPSPreferences.java \ + TeleGPSGraphUI.java JFREECHART_CLASS= \ jfreechart.jar diff --git a/telegps/TeleGPS.java b/telegps/TeleGPS.java index bef0bbc6..5a707547 100644 --- a/telegps/TeleGPS.java +++ b/telegps/TeleGPS.java @@ -246,6 +246,16 @@ public class TeleGPS } void graph() { + AltosDataChooser chooser; + chooser = new AltosDataChooser(this); + AltosStateIterable states = chooser.runDialog(); + if (states == null) + return; + try { + new TeleGPSGraphUI(states, chooser.file()); + } catch (InterruptedException ie) { + } catch (IOException ie) { + } } void flash() { -- cgit v1.2.3 From 2d9842ee011139f5783a102ceb2b7f4c88b1a10f Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 30 May 2014 17:17:42 -0700 Subject: telegps: Add config for tracker starting distances Signed-off-by: Keith Packard --- altoslib/AltosConfigData.java | 30 ++++++ altoslib/AltosConfigValues.java | 4 + altosui/AltosConfigUI.java | 171 ++++++++++++++++++++++++++++++++++ telegps/TeleGPSConfigUI.java | 199 +++++++++++++++++++++++++++++++++++----- 4 files changed, 381 insertions(+), 23 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index e5c546ff..83c184cd 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -80,6 +80,9 @@ public class AltosConfigData implements Iterable { /* Log listing replies */ public int stored_flight; + /* HAS_TRACKER */ + public int[] tracker_distances; + public static String get_string(String line, String label) throws ParseException { if (line.startsWith(label)) { String quoted = line.substring(label.length()).trim(); @@ -103,6 +106,20 @@ public class AltosConfigData implements Iterable { throw new ParseException("mismatch", 0); } + public static int[] get_distances(String line, String label) throws NumberFormatException, ParseException { + if (line.startsWith(label)) { + String tail = line.substring(label.length()).trim(); + String[] tokens = tail.split("\\s+"); + if (tokens.length > 1) { + int[] distances = new int[2]; + distances[0] = Integer.parseInt(tokens[0]); + distances[1] = Integer.parseInt(tokens[1]); + return distances; + } + } + throw new ParseException("mismatch", 0); + } + public Iterator iterator() { return lines.iterator(); } @@ -215,6 +232,8 @@ public class AltosConfigData implements Iterable { beep = -1; + tracker_distances = null; + storage_size = -1; storage_erase_unit = -1; stored_flight = 0; @@ -294,6 +313,9 @@ public class AltosConfigData implements Iterable { /* HAS_BEEP */ try { beep = get_int(line, "Beeper setting:"); } catch (Exception e) {} + /* HAS_TRACKER */ + try { tracker_distances = get_distances(line, "Tracker setting:"); } catch (Exception e) {} + /* Storage info replies */ try { storage_size = get_int(line, "Storage size:"); } catch (Exception e) {} try { storage_erase_unit = get_int(line, "Storage erase unit:"); } catch (Exception e) {} @@ -424,6 +446,9 @@ public class AltosConfigData implements Iterable { /* HAS_BEEP */ if (beep >= 0) beep = source.beep(); + /* HAS_TRACKER */ + if (tracker_distances != null) + tracker_distances = source.tracker_distances(); } public void set_values(AltosConfigValues dest) { @@ -463,6 +488,7 @@ public class AltosConfigData implements Iterable { dest.set_pyros(null); dest.set_aprs_interval(aprs_interval); dest.set_beep(beep); + dest.set_tracker_distances(tracker_distances); } public void save(AltosLink link, boolean remote) throws InterruptedException, TimeoutException { @@ -533,6 +559,10 @@ public class AltosConfigData implements Iterable { if (beep >= 0) link.printf("c b %d\n", beep); + /* HAS_TRACKER */ + if (tracker_distances != null) + link.printf("c t %d %d\n", tracker_distances[0], tracker_distances[1]); + link.printf("c w\n"); link.flush_output(); } diff --git a/altoslib/AltosConfigValues.java b/altoslib/AltosConfigValues.java index b7c0c6ed..37af2ed5 100644 --- a/altoslib/AltosConfigValues.java +++ b/altoslib/AltosConfigValues.java @@ -80,4 +80,8 @@ public interface AltosConfigValues { public abstract int beep(); public abstract void set_beep(int new_beep); + + public abstract int[] tracker_distances(); + + public abstract void set_tracker_distances(int[] tracker_distances); } diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java index 3ec3cdb0..2a9d727d 100644 --- a/altosui/AltosConfigUI.java +++ b/altosui/AltosConfigUI.java @@ -46,6 +46,8 @@ public class AltosConfigUI JLabel pad_orientation_label; JLabel callsign_label; JLabel beep_label; + JLabel tracker_horiz_label; + JLabel tracker_vert_label; public boolean dirty; @@ -65,6 +67,8 @@ public class AltosConfigUI JComboBox pad_orientation_value; JTextField callsign_value; JComboBox beep_value; + JComboBox tracker_horiz_value; + JComboBox tracker_vert_value; JButton pyro; @@ -125,6 +129,34 @@ public class AltosConfigUI "Antenna Down", }; + static String[] tracker_horiz_values_m = { + "250", + "500", + "1000", + "2000" + }; + + static String[] tracker_horiz_values_ft = { + "500", + "1000", + "2500", + "5000" + }; + + static String[] tracker_vert_values_m = { + "25", + "50", + "100", + "200" + }; + + static String[] tracker_vert_values_ft = { + "50", + "100", + "250", + "500" + }; + /* A window listener to catch closing events and tell the config code */ class ConfigListener extends WindowAdapter { AltosConfigUI ui; @@ -610,6 +642,57 @@ public class AltosConfigUI set_beep_tool_tip(); row++; + /* Tracker triger horiz distances */ + c = new GridBagConstraints(); + c.gridx = 0; c.gridy = row; + c.gridwidth = 4; + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.LINE_START; + c.insets = il; + c.ipady = 5; + tracker_horiz_label = new JLabel(get_tracker_horiz_label()); + pane.add(tracker_horiz_label, c); + + c = new GridBagConstraints(); + c.gridx = 4; c.gridy = row; + c.gridwidth = 4; + c.fill = GridBagConstraints.HORIZONTAL; + c.weightx = 1; + c.anchor = GridBagConstraints.LINE_START; + c.insets = ir; + c.ipady = 5; + tracker_horiz_value = new JComboBox(tracker_horiz_values()); + tracker_horiz_value.setEditable(true); + tracker_horiz_value.addItemListener(this); + pane.add(tracker_horiz_value, c); + row++; + + /* Tracker triger vert distances */ + c = new GridBagConstraints(); + c.gridx = 0; c.gridy = row; + c.gridwidth = 4; + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.LINE_START; + c.insets = il; + c.ipady = 5; + tracker_vert_label = new JLabel(get_tracker_vert_label()); + pane.add(tracker_vert_label, c); + + c = new GridBagConstraints(); + c.gridx = 4; c.gridy = row; + c.gridwidth = 4; + c.fill = GridBagConstraints.HORIZONTAL; + c.weightx = 1; + c.anchor = GridBagConstraints.LINE_START; + c.insets = ir; + c.ipady = 5; + tracker_vert_value = new JComboBox(tracker_vert_values()); + tracker_vert_value.setEditable(true); + tracker_vert_value.addItemListener(this); + pane.add(tracker_vert_value, c); + set_tracker_tool_tip(); + row++; + /* Pyro channels */ c = new GridBagConstraints(); c.gridx = 4; c.gridy = row; @@ -814,6 +897,20 @@ public class AltosConfigUI set_main_deploy_values(); int m = (int) (AltosConvert.height.parse(v, !imperial_units) + 0.5); set_main_deploy(m); + + if (tracker_horiz_value.isEnabled() && tracker_vert_value.isEnabled()) { + String th = tracker_horiz_value.getSelectedItem().toString(); + String tv = tracker_vert_value.getSelectedItem().toString(); + tracker_horiz_label.setText(get_tracker_horiz_label()); + tracker_vert_label.setText(get_tracker_vert_label()); + set_tracker_horiz_values(); + set_tracker_vert_values(); + int[] t = { + (int) (AltosConvert.height.parse(th, !imperial_units) + 0.5), + (int) (AltosConvert.height.parse(tv, !imperial_units) + 0.5) + }; + set_tracker_distances(t); + } } public void set_apogee_delay(int new_apogee_delay) { @@ -969,6 +1066,80 @@ public class AltosConfigUI return -1; } + String[] tracker_horiz_values() { + if (AltosConvert.imperial_units) + return tracker_horiz_values_ft; + else + return tracker_horiz_values_m; + } + + void set_tracker_horiz_values() { + String[] v = tracker_horiz_values(); + while (tracker_horiz_value.getItemCount() > 0) + tracker_horiz_value.removeItemAt(0); + for (int i = 0; i < v.length; i++) + tracker_horiz_value.addItem(v[i]); + tracker_horiz_value.setMaximumRowCount(v.length); + } + + String get_tracker_horiz_label() { + return String.format("Logging Trigger Horizontal (%s):", AltosConvert.height.show_units()); + } + + String[] tracker_vert_values() { + if (AltosConvert.imperial_units) + return tracker_vert_values_ft; + else + return tracker_vert_values_m; + } + + void set_tracker_vert_values() { + String[] v = tracker_vert_values(); + while (tracker_vert_value.getItemCount() > 0) + tracker_vert_value.removeItemAt(0); + for (int i = 0; i < v.length; i++) + tracker_vert_value.addItem(v[i]); + tracker_vert_value.setMaximumRowCount(v.length); + } + + void set_tracker_tool_tip() { + if (tracker_horiz_value.isEnabled()) + tracker_horiz_value.setToolTipText("How far the device must move before logging is enabled"); + else + tracker_horiz_value.setToolTipText("This device doesn't disable logging before motion"); + if (tracker_vert_value.isEnabled()) + tracker_vert_value.setToolTipText("How far the device must move before logging is enabled"); + else + tracker_vert_value.setToolTipText("This device doesn't disable logging before motion"); + } + + String get_tracker_vert_label() { + return String.format("Logging Trigger Vertical (%s):", AltosConvert.height.show_units()); + } + + public void set_tracker_distances(int[] tracker_distances) { + if (tracker_distances != null) { + tracker_horiz_value.setSelectedItem(AltosConvert.height.say(tracker_distances[0])); + tracker_vert_value.setSelectedItem(AltosConvert.height.say(tracker_distances[1])); + tracker_horiz_value.setEnabled(true); + tracker_vert_value.setEnabled(true); + } else { + tracker_horiz_value.setEnabled(false); + tracker_vert_value.setEnabled(false); + } + } + + public int[] tracker_distances() { + if (tracker_horiz_value.isEnabled() && tracker_vert_value.isEnabled()) { + int[] t = { + (int) (AltosConvert.height.parse(tracker_horiz_value.getSelectedItem().toString()) + 0.5), + (int) (AltosConvert.height.parse(tracker_vert_value.getSelectedItem().toString()) + 0.5), + }; + return t; + } + return null; + } + public void set_pyros(AltosPyro[] new_pyros) { pyros = new_pyros; pyro.setVisible(pyros != null); diff --git a/telegps/TeleGPSConfigUI.java b/telegps/TeleGPSConfigUI.java index d1f66eef..863d61bb 100644 --- a/telegps/TeleGPSConfigUI.java +++ b/telegps/TeleGPSConfigUI.java @@ -26,7 +26,7 @@ import org.altusmetrum.altosuilib_2.*; public class TeleGPSConfigUI extends AltosUIDialog - implements ActionListener, ItemListener, DocumentListener, AltosConfigValues + implements ActionListener, ItemListener, DocumentListener, AltosConfigValues, AltosUnitsListener { Container pane; @@ -40,6 +40,8 @@ public class TeleGPSConfigUI JLabel aprs_interval_label; JLabel flight_log_max_label; JLabel callsign_label; + JLabel tracker_horiz_label; + JLabel tracker_vert_label; public boolean dirty; @@ -53,6 +55,8 @@ public class TeleGPSConfigUI JComboBox aprs_interval_value; JComboBox flight_log_max_value; JTextField callsign_value; + JComboBox tracker_horiz_value; + JComboBox tracker_vert_value; JButton save; JButton reset; @@ -74,6 +78,34 @@ public class TeleGPSConfigUI "10" }; + static String[] tracker_horiz_values_m = { + "250", + "500", + "1000", + "2000" + }; + + static String[] tracker_horiz_values_ft = { + "500", + "1000", + "2500", + "5000" + }; + + static String[] tracker_vert_values_m = { + "25", + "50", + "100", + "200" + }; + + static String[] tracker_vert_values_ft = { + "50", + "100", + "250", + "500" + }; + /* A window listener to catch closing events and tell the config code */ class ConfigListener extends WindowAdapter { TeleGPSConfigUI ui; @@ -362,6 +394,57 @@ public class TeleGPSConfigUI set_flight_log_max_tool_tip(); row++; + /* Tracker triger horiz distances */ + c = new GridBagConstraints(); + c.gridx = 0; c.gridy = row; + c.gridwidth = 4; + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.LINE_START; + c.insets = il; + c.ipady = 5; + tracker_horiz_label = new JLabel(get_tracker_horiz_label()); + pane.add(tracker_horiz_label, c); + + c = new GridBagConstraints(); + c.gridx = 4; c.gridy = row; + c.gridwidth = 4; + c.fill = GridBagConstraints.HORIZONTAL; + c.weightx = 1; + c.anchor = GridBagConstraints.LINE_START; + c.insets = ir; + c.ipady = 5; + tracker_horiz_value = new JComboBox(tracker_horiz_values()); + tracker_horiz_value.setEditable(true); + tracker_horiz_value.addItemListener(this); + pane.add(tracker_horiz_value, c); + row++; + + /* Tracker triger vert distances */ + c = new GridBagConstraints(); + c.gridx = 0; c.gridy = row; + c.gridwidth = 4; + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.LINE_START; + c.insets = il; + c.ipady = 5; + tracker_vert_label = new JLabel(get_tracker_vert_label()); + pane.add(tracker_vert_label, c); + + c = new GridBagConstraints(); + c.gridx = 4; c.gridy = row; + c.gridwidth = 4; + c.fill = GridBagConstraints.HORIZONTAL; + c.weightx = 1; + c.anchor = GridBagConstraints.LINE_START; + c.insets = ir; + c.ipady = 5; + tracker_vert_value = new JComboBox(tracker_vert_values()); + tracker_vert_value.setEditable(true); + tracker_vert_value.addItemListener(this); + pane.add(tracker_vert_value, c); + set_tracker_tool_tip(); + row++; + /* Buttons */ c = new GridBagConstraints(); c.gridx = 0; c.gridy = row; @@ -408,6 +491,7 @@ public class TeleGPSConfigUI close.setActionCommand("Close"); addWindowListener(new ConfigListener(this)); + AltosPreferences.register_units_listener(this); } /* Once the initial values are set, the config code will show the dialog */ @@ -445,6 +529,7 @@ public class TeleGPSConfigUI } public void dispose() { + AltosPreferences.unregister_units_listener(this); super.dispose(); } @@ -486,6 +571,22 @@ public class TeleGPSConfigUI listener = l; } + public void units_changed(boolean imperial_units) { + if (tracker_horiz_value.isEnabled() && tracker_vert_value.isEnabled()) { + String th = tracker_horiz_value.getSelectedItem().toString(); + String tv = tracker_vert_value.getSelectedItem().toString(); + tracker_horiz_label.setText(get_tracker_horiz_label()); + tracker_vert_label.setText(get_tracker_vert_label()); + set_tracker_horiz_values(); + set_tracker_vert_values(); + int[] t = { + (int) (AltosConvert.height.parse(th, !imperial_units) + 0.5), + (int) (AltosConvert.height.parse(tv, !imperial_units) + 0.5) + }; + set_tracker_distances(t); + } + } + /* set and get all of the dialog values */ public void set_product(String product) { radio_frequency_value.set_product(product); @@ -509,28 +610,6 @@ public class TeleGPSConfigUI return -1; } -/* - String get_main_deploy_label() { - return String.format("Main Deploy Altitude(%s):", AltosConvert.height.show_units()); - } - - String[] main_deploy_values() { - if (AltosConvert.imperial_units) - return main_deploy_values_ft; - else - return main_deploy_values_m; - } - - void set_main_deploy_values() { - String[] v = main_deploy_values(); - while (main_deploy_value.getItemCount() > 0) - main_deploy_value.removeItemAt(0); - for (int i = 0; i < v.length; i++) - main_deploy_value.addItem(v[i]); - main_deploy_value.setMaximumRowCount(v.length); - } -*/ - public void set_apogee_delay(int new_apogee_delay) { } public int apogee_delay() { @@ -626,6 +705,80 @@ public class TeleGPSConfigUI public int beep() { return -1; } + String[] tracker_horiz_values() { + if (AltosConvert.imperial_units) + return tracker_horiz_values_ft; + else + return tracker_horiz_values_m; + } + + void set_tracker_horiz_values() { + String[] v = tracker_horiz_values(); + while (tracker_horiz_value.getItemCount() > 0) + tracker_horiz_value.removeItemAt(0); + for (int i = 0; i < v.length; i++) + tracker_horiz_value.addItem(v[i]); + tracker_horiz_value.setMaximumRowCount(v.length); + } + + String get_tracker_horiz_label() { + return String.format("Logging Trigger Horizontal (%s):", AltosConvert.height.show_units()); + } + + String[] tracker_vert_values() { + if (AltosConvert.imperial_units) + return tracker_vert_values_ft; + else + return tracker_vert_values_m; + } + + void set_tracker_vert_values() { + String[] v = tracker_vert_values(); + while (tracker_vert_value.getItemCount() > 0) + tracker_vert_value.removeItemAt(0); + for (int i = 0; i < v.length; i++) + tracker_vert_value.addItem(v[i]); + tracker_vert_value.setMaximumRowCount(v.length); + } + + void set_tracker_tool_tip() { + if (tracker_horiz_value.isEnabled()) + tracker_horiz_value.setToolTipText("How far the device must move before logging is enabled"); + else + tracker_horiz_value.setToolTipText("This device doesn't disable logging before motion"); + if (tracker_vert_value.isEnabled()) + tracker_vert_value.setToolTipText("How far the device must move before logging is enabled"); + else + tracker_vert_value.setToolTipText("This device doesn't disable logging before motion"); + } + + String get_tracker_vert_label() { + return String.format("Logging Trigger Vertical (%s):", AltosConvert.height.show_units()); + } + + public void set_tracker_distances(int[] tracker_distances) { + if (tracker_distances != null) { + tracker_horiz_value.setSelectedItem(AltosConvert.height.say(tracker_distances[0])); + tracker_vert_value.setSelectedItem(AltosConvert.height.say(tracker_distances[1])); + tracker_horiz_value.setEnabled(true); + tracker_vert_value.setEnabled(true); + } else { + tracker_horiz_value.setEnabled(false); + tracker_vert_value.setEnabled(false); + } + } + + public int[] tracker_distances() { + if (tracker_horiz_value.isEnabled() && tracker_vert_value.isEnabled()) { + int[] t = { + (int) (AltosConvert.height.parse(tracker_horiz_value.getSelectedItem().toString()) + 0.5), + (int) (AltosConvert.height.parse(tracker_vert_value.getSelectedItem().toString()) + 0.5), + }; + return t; + } + return null; + } + public void set_aprs_interval(int new_aprs_interval) { String s; -- cgit v1.2.3 From ace5f42b5567cff07a61b622171ac364ea8c165d Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 2 Jun 2014 22:07:39 -0700 Subject: altosui: Display error message when parsing pyro channel values fails Build an exception handling chain to get numeric parse errors propagated all the way back to the original 'save' command and up into a dialog window, including the pyro channel, field and value that were in error. Signed-off-by: Keith Packard --- altoslib/AltosConfigData.java | 2 +- altoslib/AltosConfigValues.java | 2 +- altoslib/Makefile.am | 1 + altosui/AltosConfig.java | 14 ++++++++++---- altosui/AltosConfigPyroUI.java | 31 +++++++++++++++++++++++-------- altosui/AltosConfigUI.java | 2 +- 6 files changed, 37 insertions(+), 15 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index 83c184cd..2f36e215 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -403,7 +403,7 @@ public class AltosConfigData implements Iterable { return 1024; } - public void get_values(AltosConfigValues source) { + public void get_values(AltosConfigValues source) throws AltosConfigDataException { /* HAS_FLIGHT */ if (main_deploy >= 0) diff --git a/altoslib/AltosConfigValues.java b/altoslib/AltosConfigValues.java index 37af2ed5..6ca1f5c6 100644 --- a/altoslib/AltosConfigValues.java +++ b/altoslib/AltosConfigValues.java @@ -71,7 +71,7 @@ public interface AltosConfigValues { public abstract void set_pyros(AltosPyro[] new_pyros); - public abstract AltosPyro[] pyros(); + public abstract AltosPyro[] pyros() throws AltosConfigDataException; public abstract int aprs_interval(); diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am index bff09704..0f1d7a47 100644 --- a/altoslib/Makefile.am +++ b/altoslib/Makefile.am @@ -28,6 +28,7 @@ altoslib_JAVA = \ AltosLib.java \ AltosCompanion.java \ AltosConfigData.java \ + AltosConfigDataException.java \ AltosConfigValues.java \ AltosConvert.java \ AltosCRCException.java \ diff --git a/altosui/AltosConfig.java b/altosui/AltosConfig.java index 3128114f..2cf69525 100644 --- a/altosui/AltosConfig.java +++ b/altosui/AltosConfig.java @@ -242,9 +242,15 @@ public class AltosConfig implements ActionListener { /* Pull data out of the UI and stuff back into our local data record */ - data.get_values(config_ui); - - run_serial_thread(serial_mode_save); + try { + data.get_values(config_ui); + run_serial_thread(serial_mode_save); + } catch (AltosConfigDataException ae) { + JOptionPane.showMessageDialog(owner, + ae.getMessage(), + "Configuration Data Error", + JOptionPane.ERROR_MESSAGE); + } } public void actionPerformed(ActionEvent e) { @@ -298,4 +304,4 @@ public class AltosConfig implements ActionListener { } } } -} \ No newline at end of file +} diff --git a/altosui/AltosConfigPyroUI.java b/altosui/AltosConfigPyroUI.java index 6cbac316..7a298a3c 100644 --- a/altosui/AltosConfigPyroUI.java +++ b/altosui/AltosConfigPyroUI.java @@ -124,12 +124,16 @@ public class AltosConfigPyroUI return enable.isSelected(); } - public double value() { + public double value() throws AltosConfigDataException { if (value != null) { AltosUnits units = AltosPyro.pyro_to_units(flag); - if (units != null) - return units.parse(value.getText()); - return Double.parseDouble(value.getText()); + try { + if (units != null) + return units.parse(value.getText()); + return Double.parseDouble(value.getText()); + } catch (NumberFormatException e) { + throw new AltosConfigDataException("\"%s\": %s\n", value.getText(), e.getMessage()); + } } if (combo != null) return combo.getSelectedIndex() + AltosLib.ao_flight_boost; @@ -189,15 +193,21 @@ public class AltosConfigPyroUI } } - public AltosPyro get() { + public AltosPyro get() throws AltosConfigDataException { AltosPyro p = new AltosPyro(channel); int row = 0; for (int flag = 1; flag < AltosPyro.pyro_all; flag <<= 1) { if ((AltosPyro.pyro_all & flag) != 0) { if (items[row].enabled()) { + try { p.flags |= flag; p.set_value(flag, items[row].value()); + } catch (AltosConfigDataException ae) { + throw new AltosConfigDataException("%s, %s", + AltosPyro.pyro_to_name(flag), + ae.getMessage()); + } } row++; } @@ -256,10 +266,15 @@ public class AltosConfigPyroUI } } - public AltosPyro[] get_pyros() { + public AltosPyro[] get_pyros() throws AltosConfigDataException { AltosPyro[] pyros = new AltosPyro[columns.length]; - for (int c = 0; c < columns.length; c++) - pyros[c] = columns[c].get(); + for (int c = 0; c < columns.length; c++) { + try { + pyros[c] = columns[c].get(); + } catch (AltosConfigDataException ae) { + throw new AltosConfigDataException ("Channel %c, %s", c + 'A', ae.getMessage()); + } + } return pyros; } diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java index 2a9d727d..bcb3e12c 100644 --- a/altosui/AltosConfigUI.java +++ b/altosui/AltosConfigUI.java @@ -1147,7 +1147,7 @@ public class AltosConfigUI pyro_ui.set_pyros(pyros); } - public AltosPyro[] pyros() { + public AltosPyro[] pyros() throws AltosConfigDataException { if (pyro_ui != null) pyros = pyro_ui.get_pyros(); return pyros; -- cgit v1.2.3 From 5e4087cd2fbb3ac67f90cd82edaa73c1eedbf67c Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 2 Jun 2014 22:23:31 -0700 Subject: altoslib: Add missing AltosConfigDataException file --- altoslib/AltosConfigDataException.java | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 altoslib/AltosConfigDataException.java (limited to 'altoslib') diff --git a/altoslib/AltosConfigDataException.java b/altoslib/AltosConfigDataException.java new file mode 100644 index 00000000..ae5621cc --- /dev/null +++ b/altoslib/AltosConfigDataException.java @@ -0,0 +1,26 @@ +/* + * Copyright © 2014 Keith Packard + * + * 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_4; + +public class AltosConfigDataException extends Exception { + + public AltosConfigDataException(String format, Object... args) { + super(String.format(format, args)); + } + +} -- cgit v1.2.3 From 537db628c0223f0c1f797705a353857c696f8051 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 7 Jun 2014 11:44:55 -0700 Subject: altoslib: All products with logging have the 'l' command Instead of listing products with the 'l' command, just exclude products that don't have logging from using the 'l' command to collect the number of stored flights. Signed-off-by: Keith Packard --- altoslib/AltosConfigData.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index 2f36e215..9292a5a2 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -572,12 +572,12 @@ public class AltosConfigData implements Iterable { link.printf("c s\nf\nv\n"); read_link(link, "software-version"); switch (log_format) { - case AltosLib.AO_LOG_FORMAT_FULL: - case AltosLib.AO_LOG_FORMAT_TINY: - case AltosLib.AO_LOG_FORMAT_TELEMEGA: + case AltosLib.AO_LOG_FORMAT_UNKNOWN: + case AltosLib.AO_LOG_FORMAT_NONE: + break; + default: link.printf("l\n"); read_link(link, "done"); - default: break; } } -- cgit v1.2.3 From fcea12ac416b1eab11e9e8aae801358574308f73 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 7 Jun 2014 11:46:32 -0700 Subject: altoslib: Add TeleGPS log parsing code Signed-off-by: Keith Packard --- altoslib/AltosEepromChunk.java | 5 +- altoslib/AltosEepromFile.java | 3 + altoslib/AltosEepromGPS.java | 159 +++++++++++++++++++++++++++++++++++++++++ altoslib/AltosLib.java | 1 + altoslib/Makefile.am | 1 + 5 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 altoslib/AltosEepromGPS.java (limited to 'altoslib') diff --git a/altoslib/AltosEepromChunk.java b/altoslib/AltosEepromChunk.java index 32de96bc..91eebc5a 100644 --- a/altoslib/AltosEepromChunk.java +++ b/altoslib/AltosEepromChunk.java @@ -84,6 +84,9 @@ public class AltosEepromChunk { case AltosLib.AO_LOG_FORMAT_EASYMINI: eeprom = new AltosEepromMini(this, offset); break; + case AltosLib.AO_LOG_FORMAT_TELEGPS: + eeprom = new AltosEepromGPS(this, offset); + break; default: throw new ParseException("unknown eeprom format " + log_format, 0); } @@ -125,4 +128,4 @@ public class AltosEepromChunk { } } } -} \ No newline at end of file +} diff --git a/altoslib/AltosEepromFile.java b/altoslib/AltosEepromFile.java index 1664dc95..f59585f8 100644 --- a/altoslib/AltosEepromFile.java +++ b/altoslib/AltosEepromFile.java @@ -102,6 +102,9 @@ public class AltosEepromFile extends AltosStateIterable { case AltosLib.AO_LOG_FORMAT_EASYMINI: body = new AltosEepromIterable(AltosEepromMini.read(input)); break; + case AltosLib.AO_LOG_FORMAT_TELEGPS: + body = new AltosEepromIterable(AltosEepromGPS.read(input)); + break; default: body = new AltosEepromIterable(new LinkedList()); break; diff --git a/altoslib/AltosEepromGPS.java b/altoslib/AltosEepromGPS.java new file mode 100644 index 00000000..33172eed --- /dev/null +++ b/altoslib/AltosEepromGPS.java @@ -0,0 +1,159 @@ +/* + * Copyright © 2014 Keith Packard + * + * 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_4; + +import java.io.*; +import java.util.*; +import java.text.*; + +public class AltosEepromGPS extends AltosEeprom { + public static final int record_length = 32; + + public static final int max_sat = 12; + + public int record_length() { return record_length; } + + /* AO_LOG_FLIGHT elements */ + public int flight() { return data16(0); } + public int start_altitude() { return data16(2); } + public int start_latitude() { return data32(4); } + public int start_longitude() { return data32(8); } + + /* AO_LOG_GPS_TIME elements */ + public int latitude() { return data32(0); } + public int longitude() { return data32(4); } + public int altitude() { return data16(8); } + public int hour() { return data8(10); } + public int minute() { return data8(11); } + public int second() { return data8(12); } + public int flags() { return data8(13); } + public int year() { return data8(14); } + public int month() { return data8(15); } + public int day() { return data8(16); } + public int course() { return data8(17); } + public int ground_speed() { return data16(18); } + public int climb_rate() { return data16(20); } + public int pdop() { return data8(22); } + public int hdop() { return data8(23); } + public int vdop() { return data8(24); } + public int mode() { return data8(25); } + public int state() { return data8(26); } + + /* AO_LOG_GPS_SAT elements */ + public int nsat() { return data16(0); } + public int svid(int n) { return data8(2 + n * 2); } + public int c_n(int n) { return data8(2 + n * 2 + 1); } + + public AltosEepromGPS (AltosEepromChunk chunk, int start) throws ParseException { + parse_chunk(chunk, start); + } + + public void update_state(AltosState state) { + super.update_state(state); + + AltosGPS gps; + + /* Flush any pending GPS changes */ + if (state.gps_pending) { + switch (cmd) { + case AltosLib.AO_LOG_GPS_LAT: + case AltosLib.AO_LOG_GPS_LON: + case AltosLib.AO_LOG_GPS_ALT: + case AltosLib.AO_LOG_GPS_SAT: + case AltosLib.AO_LOG_GPS_DATE: + break; + default: + state.set_temp_gps(); + break; + } + } + + switch (cmd) { + case AltosLib.AO_LOG_FLIGHT: + state.set_boost_tick(tick); + state.set_flight(flight()); + /* no place to log start lat/lon yet */ + break; + case AltosLib.AO_LOG_GPS_TIME: + state.set_tick(tick); + state.set_state(state()); + gps = state.make_temp_gps(false); + gps.lat = latitude() / 1e7; + gps.lon = longitude() / 1e7; + gps.alt = altitude(); + + gps.hour = hour(); + gps.minute = minute(); + gps.second = second(); + + int flags = flags(); + + gps.connected = (flags & AltosLib.AO_GPS_RUNNING) != 0; + gps.locked = (flags & AltosLib.AO_GPS_VALID) != 0; + gps.nsat = (flags & AltosLib.AO_GPS_NUM_SAT_MASK) >> + AltosLib.AO_GPS_NUM_SAT_SHIFT; + + gps.year = 2000 + year(); + gps.month = month(); + gps.day = day(); + gps.ground_speed = ground_speed() * 1.0e-2; + gps.course = course() * 2; + gps.climb_rate = climb_rate() * 1.0e-2; + gps.hdop = hdop(); + gps.vdop = vdop(); + break; + case AltosLib.AO_LOG_GPS_SAT: + state.set_tick(tick); + gps = state.make_temp_gps(true); + + int n = nsat(); + if (n > max_sat) + n = max_sat; + for (int i = 0; i < n; i++) + gps.add_sat(svid(i), c_n(i)); + break; + } + } + + public AltosEepromGPS (String line) { + parse_string(line); + } + + static public LinkedList read(FileInputStream input) { + LinkedList tgpss = new LinkedList(); + + for (;;) { + try { + String line = AltosLib.gets(input); + if (line == null) + break; + try { + AltosEepromGPS tgps = new AltosEepromGPS(line); + if (tgps.cmd != AltosLib.AO_LOG_INVALID) + tgpss.add(tgps); + } catch (Exception e) { + System.out.printf ("exception\n"); + } + } catch (IOException ie) { + break; + } + } + + return tgpss; + } +} diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java index 3aef077a..7080ebfe 100644 --- a/altoslib/AltosLib.java +++ b/altoslib/AltosLib.java @@ -265,6 +265,7 @@ public class AltosLib { public static final int AO_LOG_FORMAT_EASYMINI = 6; public static final int AO_LOG_FORMAT_TELEMETRUM = 7; public static final int AO_LOG_FORMAT_TELEMINI = 8; + public static final int AO_LOG_FORMAT_TELEGPS = 9; public static final int AO_LOG_FORMAT_NONE = 127; public static boolean isspace(int c) { diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am index 0f1d7a47..1086f858 100644 --- a/altoslib/Makefile.am +++ b/altoslib/Makefile.am @@ -47,6 +47,7 @@ altoslib_JAVA = \ AltosEepromMega.java \ AltosEepromMetrum2.java \ AltosEepromMini.java \ + AltosEepromGPS.java \ AltosEepromMonitor.java \ AltosFile.java \ AltosFlash.java \ -- cgit v1.2.3 From e0dfa934ba76d6f913af37999e05c20e614bd3e9 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 7 Jun 2014 11:47:11 -0700 Subject: altoslib: Record whether flight data includes sensor values in AltosFlightStats Provide a way to elide the usual flight data from a graph for TeleGPS Signed-off-by: Keith Packard --- altoslib/AltosFlightStats.java | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'altoslib') diff --git a/altoslib/AltosFlightStats.java b/altoslib/AltosFlightStats.java index 87e04293..b3305a05 100644 --- a/altoslib/AltosFlightStats.java +++ b/altoslib/AltosFlightStats.java @@ -35,6 +35,7 @@ public class AltosFlightStats { public int hour, minute, second; public double lat, lon; public double pad_lat, pad_lon; + public boolean has_flight_data; public boolean has_gps; public boolean has_other_adc; public boolean has_rssi; @@ -109,6 +110,7 @@ public class AltosFlightStats { hour = minute = second = AltosLib.MISSING; serial = flight = AltosLib.MISSING; lat = lon = AltosLib.MISSING; + has_flight_data = false; has_gps = false; has_other_adc = false; has_rssi = false; @@ -126,6 +128,9 @@ public class AltosFlightStats { has_rssi = true; end_time = state.time; + if (state.pressure() != AltosLib.MISSING) + has_flight_data = true; + int state_id = state.state; if (state.time >= boost_time && state_id < AltosLib.ao_flight_boost) state_id = AltosLib.ao_flight_boost; -- cgit v1.2.3 From d69547796caf74405f8304d23d4ae318315bbd7b Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 7 Jun 2014 21:13:40 -0700 Subject: altoslib: Parse TeleGPS state value from GPS telemetry packet TeleGPS adds 0x80 to the state value to signify that this otherwise unused byte contains the current state value Signed-off-by: Keith Packard --- altoslib/AltosGPS.java | 7 +++++++ altoslib/AltosState.java | 3 +++ altoslib/AltosTelemetryLocation.java | 3 +++ 3 files changed, 13 insertions(+) (limited to 'altoslib') diff --git a/altoslib/AltosGPS.java b/altoslib/AltosGPS.java index 2708d026..f2810833 100644 --- a/altoslib/AltosGPS.java +++ b/altoslib/AltosGPS.java @@ -45,6 +45,10 @@ public class AltosGPS implements Cloneable { public int h_error; /* m */ public int v_error; /* m */ + public int state; /* for TeleGPS */ + + static final int AO_GPS_STATE_VALID = 0x80; + public AltosGPSSat[] cc_gps_sat; /* tracking data */ public void ParseGPSDate(String date) throws ParseException { @@ -298,6 +302,7 @@ public class AltosGPS implements Cloneable { g.hdop = hdop; /* unitless? */ g.h_error = h_error; /* m */ g.v_error = v_error; /* m */ + g.state = state; if (cc_gps_sat != null) { g.cc_gps_sat = new AltosGPSSat[cc_gps_sat.length]; @@ -330,6 +335,7 @@ public class AltosGPS implements Cloneable { hdop = old.hdop; /* unitless? */ h_error = old.h_error; /* m */ v_error = old.v_error; /* m */ + state = old.state; if (old.cc_gps_sat != null) { cc_gps_sat = new AltosGPSSat[old.cc_gps_sat.length]; @@ -345,6 +351,7 @@ public class AltosGPS implements Cloneable { alt = AltosLib.MISSING; ClearGPSTime(); cc_gps_sat = null; + state = 0; } } diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index ddda82b9..ef3a0976 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -918,6 +918,9 @@ public class AltosState implements Cloneable { elevation = from_pad.elevation; range = from_pad.range; } + + if ((gps.state & AltosGPS.AO_GPS_STATE_VALID) != 0) + set_state (gps.state & ~(AltosGPS.AO_GPS_STATE_VALID)); } public void set_tick(int new_tick) { diff --git a/altoslib/AltosTelemetryLocation.java b/altoslib/AltosTelemetryLocation.java index 8368188f..67705cde 100644 --- a/altoslib/AltosTelemetryLocation.java +++ b/altoslib/AltosTelemetryLocation.java @@ -36,6 +36,7 @@ public class AltosTelemetryLocation extends AltosTelemetryStandard { int ground_speed; int climb_rate; int course; + int state; public AltosTelemetryLocation(int[] bytes) { super(bytes); @@ -57,6 +58,7 @@ public class AltosTelemetryLocation extends AltosTelemetryStandard { ground_speed = uint16(26); climb_rate = int16(28); course = uint8(30); + state = uint8(31); } public void update_state(AltosState state) { @@ -66,6 +68,7 @@ public class AltosTelemetryLocation extends AltosTelemetryStandard { gps.nsat = flags & 0xf; gps.locked = (flags & (1 << 4)) != 0; gps.connected = (flags & (1 << 5)) != 0; + gps.state = this.state; if (gps.locked) { gps.lat = latitude * 1.0e-7; -- cgit v1.2.3 From 6950506beacb1bcd5b8e54c3935174cf800e9aed Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 7 Jun 2014 22:24:08 -0700 Subject: altoslib: TeleMega uses 5.6k/10k divider for v_batt I suspect the 15 and 27 values are a 'close approximation' for integer work on the cc1111 devices Signed-off-by: Keith Packard --- altoslib/AltosConvert.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'altoslib') diff --git a/altoslib/AltosConvert.java b/altoslib/AltosConvert.java index a65669da..8bcb9c96 100644 --- a/altoslib/AltosConvert.java +++ b/altoslib/AltosConvert.java @@ -208,7 +208,7 @@ public class AltosConvert { static public double mega_battery_voltage(int v_batt) { if (v_batt != AltosLib.MISSING) - return 3.3 * mega_adc(v_batt) * (15.0 + 27.0) / 27.0; + return 3.3 * mega_adc(v_batt) * (5.6 + 10.0) / 10.0; return AltosLib.MISSING; } -- cgit v1.2.3 From b33de8ba1e48d8ad0cb78f1c5692bb81da916080 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 7 Jun 2014 22:25:17 -0700 Subject: altoslib: Recover battery voltage from TeleGPS configuration packet TeleGPS stuffs battery voltage in the apogee_delay slot of the configuration packet. Pull it out from there and stick it into the current state. Signed-off-by: Keith Packard --- altoslib/AltosConvert.java | 6 ++++++ altoslib/AltosState.java | 9 ++++++--- altoslib/AltosTelemetryConfiguration.java | 8 +++++++- 3 files changed, 19 insertions(+), 4 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosConvert.java b/altoslib/AltosConvert.java index 8bcb9c96..6578e90f 100644 --- a/altoslib/AltosConvert.java +++ b/altoslib/AltosConvert.java @@ -224,6 +224,12 @@ public class AltosConvert { return sensor / 32767.0 * supply * 127/27; } + static double tele_gps_voltage(int sensor) { + double supply = 3.3; + + return sensor / 32767.0 * supply * (5.6 + 10.0) / 10.0; + } + static double easy_mini_voltage(int sensor, int serial) { double supply = 3.3; double diode_offset = 0.0; diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index ef3a0976..7871da77 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -959,11 +959,14 @@ public class AltosState implements Cloneable { this.device_type = device_type; } - public void set_config(int major, int minor, int apogee_delay, int main_deploy, int flight_log_max) { - config_major = major; - config_minor = minor; + public void set_flight_params(int apogee_delay, int main_deploy) { this.apogee_delay = apogee_delay; this.main_deploy = main_deploy; + } + + public void set_config(int major, int minor, int flight_log_max) { + config_major = major; + config_minor = minor; this.flight_log_max = flight_log_max; } diff --git a/altoslib/AltosTelemetryConfiguration.java b/altoslib/AltosTelemetryConfiguration.java index d1341b9e..e3884051 100644 --- a/altoslib/AltosTelemetryConfiguration.java +++ b/altoslib/AltosTelemetryConfiguration.java @@ -25,6 +25,7 @@ public class AltosTelemetryConfiguration extends AltosTelemetryStandard { int config_minor; int apogee_delay; int main_deploy; + int v_batt; int flight_log_max; String callsign; String version; @@ -36,6 +37,7 @@ public class AltosTelemetryConfiguration extends AltosTelemetryStandard { flight = uint16(6); config_major = uint8(8); config_minor = uint8(9); + v_batt = uint16(10); apogee_delay = uint16(10); main_deploy = uint16(12); flight_log_max = uint16(14); @@ -47,7 +49,11 @@ public class AltosTelemetryConfiguration extends AltosTelemetryStandard { super.update_state(state); state.set_device_type(device_type); state.set_flight(flight); - state.set_config(config_major, config_minor, apogee_delay, main_deploy, flight_log_max); + state.set_config(config_major, config_minor, flight_log_max); + if (device_type == AltosLib.product_telegps) + state.set_battery_voltage(AltosConvert.tele_gps_voltage(v_batt)); + else + state.set_flight_params(apogee_delay, main_deploy); state.set_callsign(callsign); state.set_firmware_version(version); -- cgit v1.2.3 From d696b34b4823647e2e91093ba9d5a351d3a52f8a Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 8 Jun 2014 16:08:30 -0700 Subject: Revert "altoslib: Parse TeleGPS state value from GPS telemetry packet" This reverts commit d69547796caf74405f8304d23d4ae318315bbd7b. --- altoslib/AltosGPS.java | 7 ------- altoslib/AltosState.java | 3 --- altoslib/AltosTelemetryLocation.java | 3 --- 3 files changed, 13 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosGPS.java b/altoslib/AltosGPS.java index f2810833..2708d026 100644 --- a/altoslib/AltosGPS.java +++ b/altoslib/AltosGPS.java @@ -45,10 +45,6 @@ public class AltosGPS implements Cloneable { public int h_error; /* m */ public int v_error; /* m */ - public int state; /* for TeleGPS */ - - static final int AO_GPS_STATE_VALID = 0x80; - public AltosGPSSat[] cc_gps_sat; /* tracking data */ public void ParseGPSDate(String date) throws ParseException { @@ -302,7 +298,6 @@ public class AltosGPS implements Cloneable { g.hdop = hdop; /* unitless? */ g.h_error = h_error; /* m */ g.v_error = v_error; /* m */ - g.state = state; if (cc_gps_sat != null) { g.cc_gps_sat = new AltosGPSSat[cc_gps_sat.length]; @@ -335,7 +330,6 @@ public class AltosGPS implements Cloneable { hdop = old.hdop; /* unitless? */ h_error = old.h_error; /* m */ v_error = old.v_error; /* m */ - state = old.state; if (old.cc_gps_sat != null) { cc_gps_sat = new AltosGPSSat[old.cc_gps_sat.length]; @@ -351,7 +345,6 @@ public class AltosGPS implements Cloneable { alt = AltosLib.MISSING; ClearGPSTime(); cc_gps_sat = null; - state = 0; } } diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index 7871da77..1d6ee3c8 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -918,9 +918,6 @@ public class AltosState implements Cloneable { elevation = from_pad.elevation; range = from_pad.range; } - - if ((gps.state & AltosGPS.AO_GPS_STATE_VALID) != 0) - set_state (gps.state & ~(AltosGPS.AO_GPS_STATE_VALID)); } public void set_tick(int new_tick) { diff --git a/altoslib/AltosTelemetryLocation.java b/altoslib/AltosTelemetryLocation.java index 67705cde..8368188f 100644 --- a/altoslib/AltosTelemetryLocation.java +++ b/altoslib/AltosTelemetryLocation.java @@ -36,7 +36,6 @@ public class AltosTelemetryLocation extends AltosTelemetryStandard { int ground_speed; int climb_rate; int course; - int state; public AltosTelemetryLocation(int[] bytes) { super(bytes); @@ -58,7 +57,6 @@ public class AltosTelemetryLocation extends AltosTelemetryStandard { ground_speed = uint16(26); climb_rate = int16(28); course = uint8(30); - state = uint8(31); } public void update_state(AltosState state) { @@ -68,7 +66,6 @@ public class AltosTelemetryLocation extends AltosTelemetryStandard { gps.nsat = flags & 0xf; gps.locked = (flags & (1 << 4)) != 0; gps.connected = (flags & (1 << 5)) != 0; - gps.state = this.state; if (gps.locked) { gps.lat = latitude * 1.0e-7; -- cgit v1.2.3 From ae1174317fc476e39077f7dc257ec08709c6b301 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 10 Jun 2014 10:11:03 -0700 Subject: altoslib/altosui/telegps: Change log size configuration * Use new log-space value provided by firmware when available. * Divide that up into 1-8 flights and offer those sizes as options to the user instead of a fixed set of sizes. * Show how many flights each selection will store * This also checks values provided by the user Signed-off-by: Keith Packard --- altoslib/AltosConfigData.java | 38 ++++--- altosui/AltosConfig.java | 24 ++--- altosui/AltosConfigUI.java | 72 ++++++++----- telegps/Makefile.am | 3 +- telegps/TeleGPS.java | 4 +- telegps/TeleGPSConfig.java | 24 ++--- telegps/TeleGPSConfigUI.java | 64 +++++++----- telegps/TeleGPSDisplayThread.java | 209 ++++++++++++++++++++++++++++++++++++++ 8 files changed, 345 insertions(+), 93 deletions(-) create mode 100644 telegps/TeleGPSDisplayThread.java (limited to 'altoslib') diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index 9292a5a2..9462ae6f 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -29,6 +29,7 @@ public class AltosConfigData implements Iterable { public int serial; public int flight; public int log_format; + public int log_space; public String version; /* Strings returned */ @@ -124,6 +125,22 @@ public class AltosConfigData implements Iterable { return lines.iterator(); } + public int log_space() { + if (log_space > 0) + return log_space; + + if (storage_size > 0) { + int space = storage_size; + + if (storage_erase_unit > 0 && use_flash_for_config()) + space -= storage_erase_unit; + + if (space > 0) + return space; + } + return 0; + } + public int log_available() { switch (log_format) { case AltosLib.AO_LOG_FORMAT_TINY: @@ -137,7 +154,7 @@ public class AltosConfigData implements Iterable { if (flight_log_max <= 0) return 1; int log_max = flight_log_max * 1024; - int log_space = storage_size - storage_erase_unit; + int log_space = log_space(); int log_used; if (stored_flight <= 0) @@ -202,6 +219,7 @@ public class AltosConfigData implements Iterable { serial = 0; flight = 0; log_format = AltosLib.AO_LOG_FORMAT_UNKNOWN; + log_space = -1; version = "unknown"; main_deploy = -1; @@ -247,6 +265,7 @@ public class AltosConfigData implements Iterable { try { serial = get_int(line, "serial-number"); } catch (Exception e) {} try { flight = get_int(line, "current-flight"); } catch (Exception e) {} try { log_format = get_int(line, "log-format"); } catch (Exception e) {} + try { log_space = get_int(line, "log-space"); } catch (Exception e) {} try { version = get_string(line, "software-version"); } catch (Exception e) {} /* Version also contains MS5607 info, which we ignore here */ @@ -390,19 +409,6 @@ public class AltosConfigData implements Iterable { } - public int log_limit() { - if (storage_size > 0) { - int log_limit = storage_size; - - if (storage_erase_unit > 0 && use_flash_for_config()) - log_limit -= storage_erase_unit; - - if (log_limit > 0) - return log_limit / 1024; - } - return 1024; - } - public void get_values(AltosConfigValues source) throws AltosConfigDataException { /* HAS_FLIGHT */ @@ -462,7 +468,7 @@ public class AltosConfigData implements Iterable { dest.set_radio_frequency(frequency()); boolean max_enabled = true; - if (log_limit() == 0) + if (log_space() == 0) max_enabled = false; switch (log_format) { @@ -477,7 +483,7 @@ public class AltosConfigData implements Iterable { dest.set_flight_log_max_enabled(max_enabled); dest.set_radio_enable(radio_enable); - dest.set_flight_log_max_limit(log_limit()); + dest.set_flight_log_max_limit(log_space() / 1024); dest.set_flight_log_max(flight_log_max); dest.set_ignite_mode(ignite_mode); dest.set_pad_orientation(pad_orientation); diff --git a/altosui/AltosConfig.java b/altosui/AltosConfig.java index 2cf69525..6eb7d40c 100644 --- a/altosui/AltosConfig.java +++ b/altosui/AltosConfig.java @@ -229,20 +229,20 @@ public class AltosConfig implements ActionListener { void save_data() { - /* bounds check stuff */ - if (config_ui.flight_log_max() > data.log_limit()) { - JOptionPane.showMessageDialog(owner, - String.format("Requested flight log, %dk, is larger than the available space, %dk.\n", - config_ui.flight_log_max(), - data.log_limit()), - "Maximum Flight Log Too Large", - JOptionPane.ERROR_MESSAGE); - return; - } + try { + /* bounds check stuff */ + if (config_ui.flight_log_max() > data.log_space() / 1024) { + JOptionPane.showMessageDialog(owner, + String.format("Requested flight log, %dk, is larger than the available space, %dk.\n", + config_ui.flight_log_max(), + data.log_space() / 1024), + "Maximum Flight Log Too Large", + JOptionPane.ERROR_MESSAGE); + return; + } - /* Pull data out of the UI and stuff back into our local data record */ + /* Pull data out of the UI and stuff back into our local data record */ - try { data.get_values(config_ui); run_serial_thread(serial_mode_save); } catch (AltosConfigDataException ae) { diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java index bcb3e12c..f936d92c 100644 --- a/altosui/AltosConfigUI.java +++ b/altosui/AltosConfigUI.java @@ -99,12 +99,6 @@ public class AltosConfigUI "0", "5", "10", "15", "20" }; - static String[] flight_log_max_values = { - "64", "128", "192", "256", "320", - "384", "448", "512", "576", "640", - "704", "768", "832", "896", "960", - }; - static String[] ignite_mode_values = { "Dual Deploy", "Redundant Apogee", @@ -546,7 +540,7 @@ public class AltosConfigUI c.anchor = GridBagConstraints.LINE_START; c.insets = il; c.ipady = 5; - flight_log_max_label = new JLabel("Maximum Flight Log Size:"); + flight_log_max_label = new JLabel("Maximum Flight Log Size (kB):"); pane.add(flight_log_max_label, c); c = new GridBagConstraints(); @@ -557,7 +551,7 @@ public class AltosConfigUI c.anchor = GridBagConstraints.LINE_START; c.insets = ir; c.ipady = 5; - flight_log_max_value = new JComboBox(flight_log_max_values); + flight_log_max_value = new JComboBox(); flight_log_max_value.setEditable(true); flight_log_max_value.addItemListener(this); pane.add(flight_log_max_value, c); @@ -918,8 +912,19 @@ public class AltosConfigUI apogee_delay_value.setEnabled(new_apogee_delay >= 0); } - public int apogee_delay() { - return Integer.parseInt(apogee_delay_value.getSelectedItem().toString()); + private int parse_int(String name, String s, boolean split) throws AltosConfigDataException { + String v = s; + if (split) + v = s.split("\\s+")[0]; + try { + return Integer.parseInt(v); + } catch (NumberFormatException ne) { + throw new AltosConfigDataException("Invalid %s \"%s\"", name, s); + } + } + + public int apogee_delay() throws AltosConfigDataException { + return parse_int("apogee delay", apogee_delay_value.getSelectedItem().toString(), false); } public void set_apogee_lockout(int new_apogee_lockout) { @@ -927,8 +932,8 @@ public class AltosConfigUI apogee_lockout_value.setEnabled(new_apogee_lockout >= 0); } - public int apogee_lockout() { - return Integer.parseInt(apogee_lockout_value.getSelectedItem().toString()); + public int apogee_lockout() throws AltosConfigDataException { + return parse_int("apogee lockout", apogee_lockout_value.getSelectedItem().toString(), false); } public void set_radio_frequency(double new_radio_frequency) { @@ -947,8 +952,8 @@ public class AltosConfigUI radio_calibration_value.setText(String.format("%d", new_radio_calibration)); } - public int radio_calibration() { - return Integer.parseInt(radio_calibration_value.getText()); + public int radio_calibration() throws AltosConfigDataException { + return parse_int("radio calibration", radio_calibration_value.getText(), false); } public void set_radio_enable(int new_radio_enable) { @@ -979,8 +984,22 @@ public class AltosConfigUI return callsign_value.getText(); } + int flight_log_max_limit; + int flight_log_max; + + public String flight_log_max_label(int flight_log_max) { + if (flight_log_max_limit != 0) { + int nflight = flight_log_max_limit / flight_log_max; + String plural = nflight > 1 ? "s" : ""; + + return String.format("%d (%d flight%s)", flight_log_max, nflight, plural); + } + return String.format("%d", flight_log_max); + } + public void set_flight_log_max(int new_flight_log_max) { - flight_log_max_value.setSelectedItem(Integer.toString(new_flight_log_max)); + flight_log_max_value.setSelectedItem(flight_log_max_label(new_flight_log_max)); + flight_log_max = new_flight_log_max; set_flight_log_max_tool_tip(); } @@ -989,20 +1008,19 @@ public class AltosConfigUI set_flight_log_max_tool_tip(); } - public int flight_log_max() { - return Integer.parseInt(flight_log_max_value.getSelectedItem().toString()); + public int flight_log_max() throws AltosConfigDataException { + return parse_int("flight log max", flight_log_max_value.getSelectedItem().toString(), true); } - public void set_flight_log_max_limit(int flight_log_max_limit) { - //boolean any_added = false; + public void set_flight_log_max_limit(int new_flight_log_max_limit) { + flight_log_max_limit = new_flight_log_max_limit; flight_log_max_value.removeAllItems(); - for (int i = 0; i < flight_log_max_values.length; i++) { - if (Integer.parseInt(flight_log_max_values[i]) < flight_log_max_limit){ - flight_log_max_value.addItem(flight_log_max_values[i]); - //any_added = true; - } + for (int i = 8; i >= 1; i--) { + int size = flight_log_max_limit / i; + flight_log_max_value.addItem(String.format("%d (%d flights)", size, i)); } - flight_log_max_value.addItem(String.format("%d", flight_log_max_limit)); + if (flight_log_max != 0) + set_flight_log_max(flight_log_max); } public void set_ignite_mode(int new_ignite_mode) { @@ -1165,11 +1183,11 @@ public class AltosConfigUI set_aprs_interval_tool_tip(); } - public int aprs_interval() { + public int aprs_interval() throws AltosConfigDataException { String s = aprs_interval_value.getSelectedItem().toString(); if (s.equals("Disabled")) return 0; - return Integer.parseInt(s); + return parse_int("aprs interval", s, false); } } diff --git a/telegps/Makefile.am b/telegps/Makefile.am index 7e17b331..e0d596e7 100644 --- a/telegps/Makefile.am +++ b/telegps/Makefile.am @@ -19,7 +19,8 @@ telegps_JAVA= \ TeleGPSConfig.java \ TeleGPSConfigUI.java \ TeleGPSPreferences.java \ - TeleGPSGraphUI.java + TeleGPSGraphUI.java \ + TeleGPSDisplayThread.java JFREECHART_CLASS= \ jfreechart.jar diff --git a/telegps/TeleGPS.java b/telegps/TeleGPS.java index 71174436..c61b245e 100644 --- a/telegps/TeleGPS.java +++ b/telegps/TeleGPS.java @@ -51,7 +51,7 @@ public class TeleGPS } AltosFlightReader reader; - AltosDisplayThread thread; + TeleGPSDisplayThread thread; JMenuBar menu_bar; @@ -349,7 +349,7 @@ public class TeleGPS public void set_reader(AltosFlightReader reader) { setTitle(String.format("TeleGPS %s", reader.name)); - thread = new AltosDisplayThread(this, voice(), this, reader); + thread = new TeleGPSDisplayThread(this, voice(), this, reader); thread.start(); } diff --git a/telegps/TeleGPSConfig.java b/telegps/TeleGPSConfig.java index 22e6a3ac..3505b0bb 100644 --- a/telegps/TeleGPSConfig.java +++ b/telegps/TeleGPSConfig.java @@ -221,20 +221,20 @@ public class TeleGPSConfig implements ActionListener { void save_data() { - /* bounds check stuff */ - if (config_ui.flight_log_max() > data.log_limit()) { - JOptionPane.showMessageDialog(owner, - String.format("Requested flight log, %dk, is larger than the available space, %dk.\n", - config_ui.flight_log_max(), - data.log_limit()), - "Maximum Flight Log Too Large", - JOptionPane.ERROR_MESSAGE); - return; - } + try { + /* bounds check stuff */ + if (config_ui.flight_log_max() > data.log_space()/1024) { + JOptionPane.showMessageDialog(owner, + String.format("Requested flight log, %dk, is larger than the available space, %dk.\n", + config_ui.flight_log_max(), + data.log_space()/1024), + "Maximum Flight Log Too Large", + JOptionPane.ERROR_MESSAGE); + return; + } - /* Pull data out of the UI and stuff back into our local data record */ + /* Pull data out of the UI and stuff back into our local data record */ - try { data.get_values(config_ui); run_serial_thread(serial_mode_save); } catch (AltosConfigDataException ae) { diff --git a/telegps/TeleGPSConfigUI.java b/telegps/TeleGPSConfigUI.java index 863d61bb..03666036 100644 --- a/telegps/TeleGPSConfigUI.java +++ b/telegps/TeleGPSConfigUI.java @@ -65,12 +65,6 @@ public class TeleGPSConfigUI ActionListener listener; - static String[] flight_log_max_values = { - "64", "128", "192", "256", "320", - "384", "448", "512", "576", "640", - "704", "768", "832", "896", "960", - }; - static String[] aprs_interval_values = { "Disabled", "2", @@ -376,7 +370,7 @@ public class TeleGPSConfigUI c.anchor = GridBagConstraints.LINE_START; c.insets = il; c.ipady = 5; - flight_log_max_label = new JLabel("Maximum Flight Log Size:"); + flight_log_max_label = new JLabel("Maximum Log Size (kB):"); pane.add(flight_log_max_label, c); c = new GridBagConstraints(); @@ -387,7 +381,7 @@ public class TeleGPSConfigUI c.anchor = GridBagConstraints.LINE_START; c.insets = ir; c.ipady = 5; - flight_log_max_value = new JComboBox(flight_log_max_values); + flight_log_max_value = new JComboBox(); flight_log_max_value.setEditable(true); flight_log_max_value.addItemListener(this); pane.add(flight_log_max_value, c); @@ -636,8 +630,19 @@ public class TeleGPSConfigUI radio_calibration_value.setText(String.format("%d", new_radio_calibration)); } - public int radio_calibration() { - return Integer.parseInt(radio_calibration_value.getText()); + private int parse_int(String name, String s, boolean split) throws AltosConfigDataException { + String v = s; + if (split) + v = s.split("\\s+")[0]; + try { + return Integer.parseInt(v); + } catch (NumberFormatException ne) { + throw new AltosConfigDataException("Invalid %s \"%s\"", name, s); + } + } + + public int radio_calibration() throws AltosConfigDataException { + return parse_int("radio calibration", radio_calibration_value.getText(), false); } public void set_radio_enable(int new_radio_enable) { @@ -668,8 +673,22 @@ public class TeleGPSConfigUI return callsign_value.getText(); } + int flight_log_max_limit; + int flight_log_max; + + public String flight_log_max_label(int flight_log_max) { + if (flight_log_max_limit != 0) { + int nflight = flight_log_max_limit / flight_log_max; + String plural = nflight > 1 ? "s" : ""; + + return String.format("%d (%d flight%s)", flight_log_max, nflight, plural); + } + return String.format("%d", flight_log_max); + } + public void set_flight_log_max(int new_flight_log_max) { - flight_log_max_value.setSelectedItem(Integer.toString(new_flight_log_max)); + flight_log_max_value.setSelectedItem(flight_log_max_label(new_flight_log_max)); + flight_log_max = new_flight_log_max; set_flight_log_max_tool_tip(); } @@ -678,20 +697,19 @@ public class TeleGPSConfigUI set_flight_log_max_tool_tip(); } - public int flight_log_max() { - return Integer.parseInt(flight_log_max_value.getSelectedItem().toString()); + public int flight_log_max() throws AltosConfigDataException { + return parse_int("flight log max", flight_log_max_value.getSelectedItem().toString(), true); } - public void set_flight_log_max_limit(int flight_log_max_limit) { - //boolean any_added = false; + public void set_flight_log_max_limit(int new_flight_log_max_limit) { + flight_log_max_limit = new_flight_log_max_limit; flight_log_max_value.removeAllItems(); - for (int i = 0; i < flight_log_max_values.length; i++) { - if (Integer.parseInt(flight_log_max_values[i]) < flight_log_max_limit){ - flight_log_max_value.addItem(flight_log_max_values[i]); - //any_added = true; - } + for (int i = 8; i >= 1; i--) { + int size = flight_log_max_limit / i; + flight_log_max_value.addItem(String.format("%d (%d flights)", size, i)); } - flight_log_max_value.addItem(String.format("%d", flight_log_max_limit)); + if (flight_log_max != 0) + set_flight_log_max(flight_log_max); } public void set_ignite_mode(int new_ignite_mode) { } @@ -791,11 +809,11 @@ public class TeleGPSConfigUI set_aprs_interval_tool_tip(); } - public int aprs_interval() { + public int aprs_interval() throws AltosConfigDataException { String s = aprs_interval_value.getSelectedItem().toString(); if (s.equals("Disabled")) return 0; - return Integer.parseInt(s); + return parse_int("aprs interval", s, false); } } diff --git a/telegps/TeleGPSDisplayThread.java b/telegps/TeleGPSDisplayThread.java new file mode 100644 index 00000000..9de33098 --- /dev/null +++ b/telegps/TeleGPSDisplayThread.java @@ -0,0 +1,209 @@ +/* + * Copyright © 2010 Keith Packard + * + * 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.telegps; + +import java.awt.*; +import javax.swing.*; +import java.io.*; +import java.text.*; +import org.altusmetrum.altoslib_4.*; +import org.altusmetrum.altosuilib_2.*; + +public class TeleGPSDisplayThread extends Thread { + + Frame parent; + IdleThread idle_thread; + AltosVoice voice; + AltosFlightReader reader; + AltosState old_state, state; + AltosListenerState listener_state; + AltosFlightDisplay display; + + synchronized void show_safely() { + final AltosState my_state = state; + final AltosListenerState my_listener_state = listener_state; + Runnable r = new Runnable() { + public void run() { + try { + display.show(my_state, my_listener_state); + } catch (Exception ex) { + } + } + }; + SwingUtilities.invokeLater(r); + } + + void reading_error_internal() { + JOptionPane.showMessageDialog(parent, + String.format("Error reading from \"%s\"", reader.name), + "Telemetry Read Error", + JOptionPane.ERROR_MESSAGE); + } + + void reading_error_safely() { + Runnable r = new Runnable() { + public void run() { + try { + reading_error_internal(); + } catch (Exception ex) { + } + } + }; + SwingUtilities.invokeLater(r); + } + + class IdleThread extends Thread { + + boolean started; + int report_interval; + long report_time; + + public synchronized void report(boolean last) { + if (state == null) + return; + + if (state.height() != AltosLib.MISSING) { + if (state.from_pad != null) { + voice.speak("Height %s, bearing %s %d, elevation %d, range %s, .\n", + AltosConvert.height.say(state.gps_height()), + state.from_pad.bearing_words( + AltosGreatCircle.BEARING_VOICE), + (int) (state.from_pad.bearing + 0.5), + (int) (state.elevation + 0.5), + AltosConvert.distance.say(state.range)); + } else { + voice.speak("Height %s.\n", + AltosConvert.height.say(state.height())); + } + } else { + voice.speak("Height is unknown.\n"); + } + } + + long now () { + return System.currentTimeMillis(); + } + + void set_report_time() { + report_time = now() + report_interval; + } + + public void run () { + try { + for (;;) { + if (reader.has_monitor_battery()) { + listener_state.battery = reader.monitor_battery(); + show_safely(); + } + set_report_time(); + for (;;) { + voice.drain(); + synchronized (this) { + long sleep_time = report_time - now(); + if (sleep_time <= 0) + break; + wait(sleep_time); + } + } + + report(false); + } + } catch (InterruptedException ie) { + try { + voice.drain(); + } catch (InterruptedException iie) { } + } + } + + public synchronized void notice(boolean spoken) { + if (old_state != null && old_state.state != state.state) { + report_time = now(); + this.notify(); + } else if (spoken) + set_report_time(); + } + + public IdleThread() { + report_interval = 10000; + } + } + + synchronized boolean tell() { + boolean ret = false; + if (old_state == null || old_state.gps_ready != state.gps_ready) { + if (state.gps_ready) { + voice.speak("GPS ready"); + ret = true; + } + else if (old_state != null) { + voice.speak("GPS lost"); + ret = true; + } + } + old_state = state; + return ret; + } + + public void run() { + boolean interrupted = false; + boolean told; + + idle_thread = new IdleThread(); + idle_thread.start(); + + try { + for (;;) { + try { + state = reader.read(); + if (state == null) + break; + reader.update(state); + show_safely(); + told = tell(); + idle_thread.notice(told); + } catch (ParseException pp) { + System.out.printf("Parse error: %d \"%s\"\n", pp.getErrorOffset(), pp.getMessage()); + } catch (AltosCRCException ce) { + ++listener_state.crc_errors; + show_safely(); + } + } + } catch (InterruptedException ee) { + interrupted = true; + } catch (IOException ie) { + reading_error_safely(); + } finally { + if (!interrupted) + idle_thread.report(true); + reader.close(interrupted); + idle_thread.interrupt(); + try { + idle_thread.join(); + } catch (InterruptedException ie) {} + } + } + + public TeleGPSDisplayThread(Frame in_parent, AltosVoice in_voice, AltosFlightDisplay in_display, AltosFlightReader in_reader) { + listener_state = new AltosListenerState(); + parent = in_parent; + voice = in_voice; + display = in_display; + reader = in_reader; + display.reset(); + } +} -- cgit v1.2.3 From 5f2029bd4e31289fb03e6af39abdbc16f8b8fa78 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 10 Jun 2014 10:14:07 -0700 Subject: altoslib/altosui/telegps: Switch TeleGPS config to motion/interval TeleGPS had configurable boost-detect values; those have been replaced with a configurable stop-tracking motion limit and logging/telemetry interval value. Signed-off-by: Keith Packard --- altoslib/AltosConfigData.java | 35 +++++---- altoslib/AltosConfigValues.java | 24 +++--- altosui/AltosConfigUI.java | 165 +++++++++++++++------------------------- telegps/TeleGPSConfigUI.java | 165 +++++++++++++++------------------------- 4 files changed, 160 insertions(+), 229 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index 9462ae6f..563bef4b 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -82,7 +82,8 @@ public class AltosConfigData implements Iterable { public int stored_flight; /* HAS_TRACKER */ - public int[] tracker_distances; + public int tracker_motion; + public int tracker_interval; public static String get_string(String line, String label) throws ParseException { if (line.startsWith(label)) { @@ -107,15 +108,15 @@ public class AltosConfigData implements Iterable { throw new ParseException("mismatch", 0); } - public static int[] get_distances(String line, String label) throws NumberFormatException, ParseException { + public static int[] get_values(String line, String label) throws NumberFormatException, ParseException { if (line.startsWith(label)) { String tail = line.substring(label.length()).trim(); String[] tokens = tail.split("\\s+"); if (tokens.length > 1) { - int[] distances = new int[2]; - distances[0] = Integer.parseInt(tokens[0]); - distances[1] = Integer.parseInt(tokens[1]); - return distances; + int[] values = new int[2]; + values[0] = Integer.parseInt(tokens[0]); + values[1] = Integer.parseInt(tokens[1]); + return values; } } throw new ParseException("mismatch", 0); @@ -250,7 +251,8 @@ public class AltosConfigData implements Iterable { beep = -1; - tracker_distances = null; + tracker_motion = -1; + tracker_interval = -1; storage_size = -1; storage_erase_unit = -1; @@ -333,7 +335,11 @@ public class AltosConfigData implements Iterable { try { beep = get_int(line, "Beeper setting:"); } catch (Exception e) {} /* HAS_TRACKER */ - try { tracker_distances = get_distances(line, "Tracker setting:"); } catch (Exception e) {} + try { + int[] values = get_values(line, "Tracker setting:"); + tracker_motion = values[0]; + tracker_interval = values[1]; + } catch (Exception e) {} /* Storage info replies */ try { storage_size = get_int(line, "Storage size:"); } catch (Exception e) {} @@ -453,8 +459,10 @@ public class AltosConfigData implements Iterable { if (beep >= 0) beep = source.beep(); /* HAS_TRACKER */ - if (tracker_distances != null) - tracker_distances = source.tracker_distances(); + if (tracker_motion >= 0) + tracker_motion = source.tracker_motion(); + if (tracker_interval >= 0) + tracker_interval = source.tracker_interval(); } public void set_values(AltosConfigValues dest) { @@ -494,7 +502,8 @@ public class AltosConfigData implements Iterable { dest.set_pyros(null); dest.set_aprs_interval(aprs_interval); dest.set_beep(beep); - dest.set_tracker_distances(tracker_distances); + dest.set_tracker_motion(tracker_motion); + dest.set_tracker_interval(tracker_interval); } public void save(AltosLink link, boolean remote) throws InterruptedException, TimeoutException { @@ -566,8 +575,8 @@ public class AltosConfigData implements Iterable { link.printf("c b %d\n", beep); /* HAS_TRACKER */ - if (tracker_distances != null) - link.printf("c t %d %d\n", tracker_distances[0], tracker_distances[1]); + if (tracker_motion >= 0 && tracker_interval >= 0) + link.printf("c t %d %d\n", tracker_motion, tracker_interval); link.printf("c w\n"); link.flush_output(); diff --git a/altoslib/AltosConfigValues.java b/altoslib/AltosConfigValues.java index 6ca1f5c6..778f1222 100644 --- a/altoslib/AltosConfigValues.java +++ b/altoslib/AltosConfigValues.java @@ -27,23 +27,23 @@ public interface AltosConfigValues { public abstract void set_main_deploy(int new_main_deploy); - public abstract int main_deploy(); + public abstract int main_deploy() throws AltosConfigDataException; public abstract void set_apogee_delay(int new_apogee_delay); - public abstract int apogee_delay(); + public abstract int apogee_delay() throws AltosConfigDataException; public abstract void set_apogee_lockout(int new_apogee_lockout); - public abstract int apogee_lockout(); + public abstract int apogee_lockout() throws AltosConfigDataException; public abstract void set_radio_frequency(double new_radio_frequency); - public abstract double radio_frequency(); + public abstract double radio_frequency() throws AltosConfigDataException; public abstract void set_radio_calibration(int new_radio_calibration); - public abstract int radio_calibration(); + public abstract int radio_calibration() throws AltosConfigDataException; public abstract void set_radio_enable(int new_radio_enable); @@ -57,7 +57,7 @@ public interface AltosConfigValues { public abstract void set_flight_log_max_enabled(boolean enable); - public abstract int flight_log_max(); + public abstract int flight_log_max() throws AltosConfigDataException; public abstract void set_flight_log_max_limit(int flight_log_max_limit); @@ -73,15 +73,19 @@ public interface AltosConfigValues { public abstract AltosPyro[] pyros() throws AltosConfigDataException; - public abstract int aprs_interval(); + public abstract int aprs_interval() throws AltosConfigDataException; public abstract void set_aprs_interval(int new_aprs_interval); - public abstract int beep(); + public abstract int beep() throws AltosConfigDataException; public abstract void set_beep(int new_beep); - public abstract int[] tracker_distances(); + public abstract int tracker_motion() throws AltosConfigDataException; - public abstract void set_tracker_distances(int[] tracker_distances); + public abstract void set_tracker_motion(int tracker_motion); + + public abstract int tracker_interval() throws AltosConfigDataException; + + public abstract void set_tracker_interval(int tracker_motion); } diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java index f936d92c..ee54e31e 100644 --- a/altosui/AltosConfigUI.java +++ b/altosui/AltosConfigUI.java @@ -46,8 +46,8 @@ public class AltosConfigUI JLabel pad_orientation_label; JLabel callsign_label; JLabel beep_label; - JLabel tracker_horiz_label; - JLabel tracker_vert_label; + JLabel tracker_motion_label; + JLabel tracker_interval_label; public boolean dirty; @@ -67,8 +67,8 @@ public class AltosConfigUI JComboBox pad_orientation_value; JTextField callsign_value; JComboBox beep_value; - JComboBox tracker_horiz_value; - JComboBox tracker_vert_value; + JComboBox tracker_motion_value; + JComboBox tracker_interval_value; JButton pyro; @@ -123,32 +123,25 @@ public class AltosConfigUI "Antenna Down", }; - static String[] tracker_horiz_values_m = { - "250", - "500", - "1000", - "2000" - }; - - static String[] tracker_horiz_values_ft = { - "500", - "1000", - "2500", - "5000" + static String[] tracker_motion_values_m = { + "2", + "5", + "10", + "25", }; - static String[] tracker_vert_values_m = { - "25", + static String[] tracker_motion_values_ft = { + "5", + "20", "50", - "100", - "200" + "100" }; - static String[] tracker_vert_values_ft = { - "50", - "100", - "250", - "500" + static String[] tracker_interval_values = { + "1", + "2", + "5", + "10" }; /* A window listener to catch closing events and tell the config code */ @@ -644,8 +637,8 @@ public class AltosConfigUI c.anchor = GridBagConstraints.LINE_START; c.insets = il; c.ipady = 5; - tracker_horiz_label = new JLabel(get_tracker_horiz_label()); - pane.add(tracker_horiz_label, c); + tracker_motion_label = new JLabel(get_tracker_motion_label()); + pane.add(tracker_motion_label, c); c = new GridBagConstraints(); c.gridx = 4; c.gridy = row; @@ -655,10 +648,10 @@ public class AltosConfigUI c.anchor = GridBagConstraints.LINE_START; c.insets = ir; c.ipady = 5; - tracker_horiz_value = new JComboBox(tracker_horiz_values()); - tracker_horiz_value.setEditable(true); - tracker_horiz_value.addItemListener(this); - pane.add(tracker_horiz_value, c); + tracker_motion_value = new JComboBox(tracker_motion_values()); + tracker_motion_value.setEditable(true); + tracker_motion_value.addItemListener(this); + pane.add(tracker_motion_value, c); row++; /* Tracker triger vert distances */ @@ -669,8 +662,8 @@ public class AltosConfigUI c.anchor = GridBagConstraints.LINE_START; c.insets = il; c.ipady = 5; - tracker_vert_label = new JLabel(get_tracker_vert_label()); - pane.add(tracker_vert_label, c); + tracker_interval_label = new JLabel("Position Reporting Interval(s):"); + pane.add(tracker_interval_label, c); c = new GridBagConstraints(); c.gridx = 4; c.gridy = row; @@ -680,10 +673,10 @@ public class AltosConfigUI c.anchor = GridBagConstraints.LINE_START; c.insets = ir; c.ipady = 5; - tracker_vert_value = new JComboBox(tracker_vert_values()); - tracker_vert_value.setEditable(true); - tracker_vert_value.addItemListener(this); - pane.add(tracker_vert_value, c); + tracker_interval_value = new JComboBox(tracker_interval_values); + tracker_interval_value.setEditable(true); + tracker_interval_value.addItemListener(this); + pane.add(tracker_interval_value, c); set_tracker_tool_tip(); row++; @@ -892,18 +885,11 @@ public class AltosConfigUI int m = (int) (AltosConvert.height.parse(v, !imperial_units) + 0.5); set_main_deploy(m); - if (tracker_horiz_value.isEnabled() && tracker_vert_value.isEnabled()) { - String th = tracker_horiz_value.getSelectedItem().toString(); - String tv = tracker_vert_value.getSelectedItem().toString(); - tracker_horiz_label.setText(get_tracker_horiz_label()); - tracker_vert_label.setText(get_tracker_vert_label()); - set_tracker_horiz_values(); - set_tracker_vert_values(); - int[] t = { - (int) (AltosConvert.height.parse(th, !imperial_units) + 0.5), - (int) (AltosConvert.height.parse(tv, !imperial_units) + 0.5) - }; - set_tracker_distances(t); + if (tracker_motion_value.isEnabled()) { + String motion = tracker_motion_value.getSelectedItem().toString(); + tracker_motion_label.setText(get_tracker_motion_label()); + set_tracker_motion_values(); + set_tracker_motion((int) (AltosConvert.height.parse(motion, !imperial_units) + 0.5)); } } @@ -1084,78 +1070,51 @@ public class AltosConfigUI return -1; } - String[] tracker_horiz_values() { + String[] tracker_motion_values() { if (AltosConvert.imperial_units) - return tracker_horiz_values_ft; + return tracker_motion_values_ft; else - return tracker_horiz_values_m; + return tracker_motion_values_m; } - void set_tracker_horiz_values() { - String[] v = tracker_horiz_values(); - while (tracker_horiz_value.getItemCount() > 0) - tracker_horiz_value.removeItemAt(0); + void set_tracker_motion_values() { + String[] v = tracker_motion_values(); + while (tracker_motion_value.getItemCount() > 0) + tracker_motion_value.removeItemAt(0); for (int i = 0; i < v.length; i++) - tracker_horiz_value.addItem(v[i]); - tracker_horiz_value.setMaximumRowCount(v.length); + tracker_motion_value.addItem(v[i]); + tracker_motion_value.setMaximumRowCount(v.length); } - String get_tracker_horiz_label() { - return String.format("Logging Trigger Horizontal (%s):", AltosConvert.height.show_units()); - } - - String[] tracker_vert_values() { - if (AltosConvert.imperial_units) - return tracker_vert_values_ft; - else - return tracker_vert_values_m; - } - - void set_tracker_vert_values() { - String[] v = tracker_vert_values(); - while (tracker_vert_value.getItemCount() > 0) - tracker_vert_value.removeItemAt(0); - for (int i = 0; i < v.length; i++) - tracker_vert_value.addItem(v[i]); - tracker_vert_value.setMaximumRowCount(v.length); + String get_tracker_motion_label() { + return String.format("Logging Trigger Motion (%s):", AltosConvert.height.show_units()); } void set_tracker_tool_tip() { - if (tracker_horiz_value.isEnabled()) - tracker_horiz_value.setToolTipText("How far the device must move before logging is enabled"); + if (tracker_motion_value.isEnabled()) + tracker_motion_value.setToolTipText("How far the device must move before logging"); else - tracker_horiz_value.setToolTipText("This device doesn't disable logging before motion"); - if (tracker_vert_value.isEnabled()) - tracker_vert_value.setToolTipText("How far the device must move before logging is enabled"); + tracker_motion_value.setToolTipText("This device doesn't disable logging when stationary"); + if (tracker_interval_value.isEnabled()) + tracker_interval_value.setToolTipText("How often to report GPS position"); else - tracker_vert_value.setToolTipText("This device doesn't disable logging before motion"); + tracker_interval_value.setToolTipText("This device can't configure interval"); } - String get_tracker_vert_label() { - return String.format("Logging Trigger Vertical (%s):", AltosConvert.height.show_units()); + public void set_tracker_motion(int tracker_motion) { + tracker_motion_value.setSelectedItem(AltosConvert.height.say(tracker_motion)); } - public void set_tracker_distances(int[] tracker_distances) { - if (tracker_distances != null) { - tracker_horiz_value.setSelectedItem(AltosConvert.height.say(tracker_distances[0])); - tracker_vert_value.setSelectedItem(AltosConvert.height.say(tracker_distances[1])); - tracker_horiz_value.setEnabled(true); - tracker_vert_value.setEnabled(true); - } else { - tracker_horiz_value.setEnabled(false); - tracker_vert_value.setEnabled(false); - } + public int tracker_motion() throws AltosConfigDataException { + return (int) AltosConvert.height.parse(tracker_motion_value.getSelectedItem().toString()); } - public int[] tracker_distances() { - if (tracker_horiz_value.isEnabled() && tracker_vert_value.isEnabled()) { - int[] t = { - (int) (AltosConvert.height.parse(tracker_horiz_value.getSelectedItem().toString()) + 0.5), - (int) (AltosConvert.height.parse(tracker_vert_value.getSelectedItem().toString()) + 0.5), - }; - return t; - } - return null; + public void set_tracker_interval(int tracker_interval) { + tracker_interval_value.setSelectedItem(String.format("%d", tracker_interval)); + } + + public int tracker_interval() throws AltosConfigDataException { + return parse_int ("tracker interval", tracker_interval_value.getSelectedItem().toString(), false); } public void set_pyros(AltosPyro[] new_pyros) { diff --git a/telegps/TeleGPSConfigUI.java b/telegps/TeleGPSConfigUI.java index 03666036..325ca7b9 100644 --- a/telegps/TeleGPSConfigUI.java +++ b/telegps/TeleGPSConfigUI.java @@ -40,8 +40,8 @@ public class TeleGPSConfigUI JLabel aprs_interval_label; JLabel flight_log_max_label; JLabel callsign_label; - JLabel tracker_horiz_label; - JLabel tracker_vert_label; + JLabel tracker_motion_label; + JLabel tracker_interval_label; public boolean dirty; @@ -55,8 +55,8 @@ public class TeleGPSConfigUI JComboBox aprs_interval_value; JComboBox flight_log_max_value; JTextField callsign_value; - JComboBox tracker_horiz_value; - JComboBox tracker_vert_value; + JComboBox tracker_motion_value; + JComboBox tracker_interval_value; JButton save; JButton reset; @@ -72,32 +72,25 @@ public class TeleGPSConfigUI "10" }; - static String[] tracker_horiz_values_m = { - "250", - "500", - "1000", - "2000" - }; - - static String[] tracker_horiz_values_ft = { - "500", - "1000", - "2500", - "5000" + static String[] tracker_motion_values_m = { + "2", + "5", + "10", + "25", }; - static String[] tracker_vert_values_m = { - "25", + static String[] tracker_motion_values_ft = { + "5", + "20", "50", - "100", - "200" + "100" }; - static String[] tracker_vert_values_ft = { - "50", - "100", - "250", - "500" + static String[] tracker_interval_values = { + "1", + "2", + "5", + "10" }; /* A window listener to catch closing events and tell the config code */ @@ -396,8 +389,8 @@ public class TeleGPSConfigUI c.anchor = GridBagConstraints.LINE_START; c.insets = il; c.ipady = 5; - tracker_horiz_label = new JLabel(get_tracker_horiz_label()); - pane.add(tracker_horiz_label, c); + tracker_motion_label = new JLabel(get_tracker_motion_label()); + pane.add(tracker_motion_label, c); c = new GridBagConstraints(); c.gridx = 4; c.gridy = row; @@ -407,10 +400,10 @@ public class TeleGPSConfigUI c.anchor = GridBagConstraints.LINE_START; c.insets = ir; c.ipady = 5; - tracker_horiz_value = new JComboBox(tracker_horiz_values()); - tracker_horiz_value.setEditable(true); - tracker_horiz_value.addItemListener(this); - pane.add(tracker_horiz_value, c); + tracker_motion_value = new JComboBox(tracker_motion_values()); + tracker_motion_value.setEditable(true); + tracker_motion_value.addItemListener(this); + pane.add(tracker_motion_value, c); row++; /* Tracker triger vert distances */ @@ -421,8 +414,8 @@ public class TeleGPSConfigUI c.anchor = GridBagConstraints.LINE_START; c.insets = il; c.ipady = 5; - tracker_vert_label = new JLabel(get_tracker_vert_label()); - pane.add(tracker_vert_label, c); + tracker_interval_label = new JLabel("Position Reporting Interval (s):"); + pane.add(tracker_interval_label, c); c = new GridBagConstraints(); c.gridx = 4; c.gridy = row; @@ -432,10 +425,10 @@ public class TeleGPSConfigUI c.anchor = GridBagConstraints.LINE_START; c.insets = ir; c.ipady = 5; - tracker_vert_value = new JComboBox(tracker_vert_values()); - tracker_vert_value.setEditable(true); - tracker_vert_value.addItemListener(this); - pane.add(tracker_vert_value, c); + tracker_interval_value = new JComboBox(tracker_interval_values); + tracker_interval_value.setEditable(true); + tracker_interval_value.addItemListener(this); + pane.add(tracker_interval_value, c); set_tracker_tool_tip(); row++; @@ -566,18 +559,11 @@ public class TeleGPSConfigUI } public void units_changed(boolean imperial_units) { - if (tracker_horiz_value.isEnabled() && tracker_vert_value.isEnabled()) { - String th = tracker_horiz_value.getSelectedItem().toString(); - String tv = tracker_vert_value.getSelectedItem().toString(); - tracker_horiz_label.setText(get_tracker_horiz_label()); - tracker_vert_label.setText(get_tracker_vert_label()); - set_tracker_horiz_values(); - set_tracker_vert_values(); - int[] t = { - (int) (AltosConvert.height.parse(th, !imperial_units) + 0.5), - (int) (AltosConvert.height.parse(tv, !imperial_units) + 0.5) - }; - set_tracker_distances(t); + if (tracker_motion_value.isEnabled()) { + String motion = tracker_motion_value.getSelectedItem().toString(); + tracker_motion_label.setText(get_tracker_motion_label()); + set_tracker_motion_values(); + set_tracker_motion((int) (AltosConvert.height.parse(motion, !imperial_units) + 0.5)); } } @@ -723,78 +709,51 @@ public class TeleGPSConfigUI public int beep() { return -1; } - String[] tracker_horiz_values() { + String[] tracker_motion_values() { if (AltosConvert.imperial_units) - return tracker_horiz_values_ft; + return tracker_motion_values_ft; else - return tracker_horiz_values_m; + return tracker_motion_values_m; } - void set_tracker_horiz_values() { - String[] v = tracker_horiz_values(); - while (tracker_horiz_value.getItemCount() > 0) - tracker_horiz_value.removeItemAt(0); + void set_tracker_motion_values() { + String[] v = tracker_motion_values(); + while (tracker_motion_value.getItemCount() > 0) + tracker_motion_value.removeItemAt(0); for (int i = 0; i < v.length; i++) - tracker_horiz_value.addItem(v[i]); - tracker_horiz_value.setMaximumRowCount(v.length); - } - - String get_tracker_horiz_label() { - return String.format("Logging Trigger Horizontal (%s):", AltosConvert.height.show_units()); - } - - String[] tracker_vert_values() { - if (AltosConvert.imperial_units) - return tracker_vert_values_ft; - else - return tracker_vert_values_m; + tracker_motion_value.addItem(v[i]); + tracker_motion_value.setMaximumRowCount(v.length); } - void set_tracker_vert_values() { - String[] v = tracker_vert_values(); - while (tracker_vert_value.getItemCount() > 0) - tracker_vert_value.removeItemAt(0); - for (int i = 0; i < v.length; i++) - tracker_vert_value.addItem(v[i]); - tracker_vert_value.setMaximumRowCount(v.length); + String get_tracker_motion_label() { + return String.format("Logging Trigger Motion (%s):", AltosConvert.height.show_units()); } void set_tracker_tool_tip() { - if (tracker_horiz_value.isEnabled()) - tracker_horiz_value.setToolTipText("How far the device must move before logging is enabled"); + if (tracker_motion_value.isEnabled()) + tracker_motion_value.setToolTipText("How far the device must move before logging"); else - tracker_horiz_value.setToolTipText("This device doesn't disable logging before motion"); - if (tracker_vert_value.isEnabled()) - tracker_vert_value.setToolTipText("How far the device must move before logging is enabled"); + tracker_motion_value.setToolTipText("This device doesn't disable logging when stationary"); + if (tracker_interval_value.isEnabled()) + tracker_interval_value.setToolTipText("How often to report GPS position"); else - tracker_vert_value.setToolTipText("This device doesn't disable logging before motion"); + tracker_interval_value.setToolTipText("This device can't configure interval"); } - String get_tracker_vert_label() { - return String.format("Logging Trigger Vertical (%s):", AltosConvert.height.show_units()); + public void set_tracker_motion(int tracker_motion) { + tracker_motion_value.setSelectedItem(AltosConvert.height.say(tracker_motion)); } - public void set_tracker_distances(int[] tracker_distances) { - if (tracker_distances != null) { - tracker_horiz_value.setSelectedItem(AltosConvert.height.say(tracker_distances[0])); - tracker_vert_value.setSelectedItem(AltosConvert.height.say(tracker_distances[1])); - tracker_horiz_value.setEnabled(true); - tracker_vert_value.setEnabled(true); - } else { - tracker_horiz_value.setEnabled(false); - tracker_vert_value.setEnabled(false); - } + public int tracker_motion() throws AltosConfigDataException { + return (int) AltosConvert.height.parse(tracker_motion_value.getSelectedItem().toString()); } - public int[] tracker_distances() { - if (tracker_horiz_value.isEnabled() && tracker_vert_value.isEnabled()) { - int[] t = { - (int) (AltosConvert.height.parse(tracker_horiz_value.getSelectedItem().toString()) + 0.5), - (int) (AltosConvert.height.parse(tracker_vert_value.getSelectedItem().toString()) + 0.5), - }; - return t; - } - return null; + public void set_tracker_interval(int tracker_interval) { + tracker_interval_value.setSelectedItem(String.format("%d", tracker_interval)); + } + + public int tracker_interval() throws AltosConfigDataException { + return parse_int ("tracker interval", tracker_interval_value.getSelectedItem().toString(), false); } public void set_aprs_interval(int new_aprs_interval) { -- cgit v1.2.3 From 871fb4753a3b54cc2e22309e80e24dfe9cc54511 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 10 Jun 2014 10:15:47 -0700 Subject: altoslib: TeleGPS no longer logs satellite information This doubles the amount of space available to log position information Signed-off-by: Keith Packard --- altoslib/AltosEepromGPS.java | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosEepromGPS.java b/altoslib/AltosEepromGPS.java index 33172eed..1820cd61 100644 --- a/altoslib/AltosEepromGPS.java +++ b/altoslib/AltosEepromGPS.java @@ -52,12 +52,6 @@ public class AltosEepromGPS extends AltosEeprom { public int hdop() { return data8(23); } public int vdop() { return data8(24); } public int mode() { return data8(25); } - public int state() { return data8(26); } - - /* AO_LOG_GPS_SAT elements */ - public int nsat() { return data16(0); } - public int svid(int n) { return data8(2 + n * 2); } - public int c_n(int n) { return data8(2 + n * 2 + 1); } public AltosEepromGPS (AltosEepromChunk chunk, int start) throws ParseException { parse_chunk(chunk, start); @@ -91,7 +85,6 @@ public class AltosEepromGPS extends AltosEeprom { break; case AltosLib.AO_LOG_GPS_TIME: state.set_tick(tick); - state.set_state(state()); gps = state.make_temp_gps(false); gps.lat = latitude() / 1e7; gps.lon = longitude() / 1e7; @@ -117,16 +110,6 @@ public class AltosEepromGPS extends AltosEeprom { gps.hdop = hdop(); gps.vdop = vdop(); break; - case AltosLib.AO_LOG_GPS_SAT: - state.set_tick(tick); - gps = state.make_temp_gps(true); - - int n = nsat(); - if (n > max_sat) - n = max_sat; - for (int i = 0; i < n; i++) - gps.add_sat(svid(i), c_n(i)); - break; } } -- cgit v1.2.3 From ff13cf1359e1f4ae33b16a5867fd364993566b65 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 10 Jun 2014 10:18:44 -0700 Subject: altoslib: Add new 'stateless' flight state for TeleGPS TeleGPS has no flight state, so add a new 'stateless' state for code to handle this case differently than any of the existing states Signed-off-by: Keith Packard --- altoslib/AltosEepromFile.java | 3 ++- altoslib/AltosEepromHeader.java | 2 +- altoslib/AltosLib.java | 4 ++++ altoslib/AltosState.java | 23 ++++++++++++++++++----- 4 files changed, 25 insertions(+), 7 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosEepromFile.java b/altoslib/AltosEepromFile.java index f59585f8..b7e446ce 100644 --- a/altoslib/AltosEepromFile.java +++ b/altoslib/AltosEepromFile.java @@ -72,7 +72,8 @@ public class AltosEepromFile extends AltosStateIterable { headers = new AltosEepromIterable(AltosEepromHeader.read(input)); start = headers.state(); - start.set_state(AltosLib.ao_flight_pad); + if (start.state != AltosLib.ao_flight_stateless) + start.set_state(AltosLib.ao_flight_pad); if (start.log_format == AltosLib.MISSING) { if (start.product != null) { diff --git a/altoslib/AltosEepromHeader.java b/altoslib/AltosEepromHeader.java index ea6f5e28..839aa06e 100644 --- a/altoslib/AltosEepromHeader.java +++ b/altoslib/AltosEepromHeader.java @@ -56,7 +56,7 @@ public class AltosEepromHeader extends AltosEeprom { state.product = data; break; case AltosLib.AO_LOG_LOG_FORMAT: - state.log_format = config_a; + state.set_log_format(config_a); break; case AltosLib.AO_LOG_SERIAL_NUMBER: state.set_serial(config_a); diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java index 7080ebfe..69c6d604 100644 --- a/altoslib/AltosLib.java +++ b/altoslib/AltosLib.java @@ -79,6 +79,7 @@ public class AltosLib { public static final int ao_flight_main = 7; public static final int ao_flight_landed = 8; public static final int ao_flight_invalid = 9; + public static final int ao_flight_stateless = 10; /* USB product IDs */ public final static int vendor_altusmetrum = 0xfffe; @@ -187,6 +188,7 @@ public class AltosLib { string_to_state.put("main", ao_flight_main); string_to_state.put("landed", ao_flight_landed); string_to_state.put("invalid", ao_flight_invalid); + string_to_state.put("stateless", ao_flight_stateless); map_initialized = true; } @@ -215,6 +217,7 @@ public class AltosLib { "main", "landed", "invalid", + "stateless", }; private static String[] state_to_string_capital = { @@ -228,6 +231,7 @@ public class AltosLib { "Main", "Landed", "Invalid", + "Stateless", }; public static int state(String state) { diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index 1d6ee3c8..2d75f72e 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -500,7 +500,7 @@ public class AltosState implements Cloneable { class AltosSpeed extends AltosCValue { boolean can_max() { - return state < AltosLib.ao_flight_fast; + return state < AltosLib.ao_flight_fast || state == AltosLib.ao_flight_stateless; } void set_accel() { @@ -542,7 +542,7 @@ public class AltosState implements Cloneable { class AltosAccel extends AltosCValue { boolean can_max() { - return state < AltosLib.ao_flight_fast; + return state < AltosLib.ao_flight_fast || state == AltosLib.ao_flight_stateless; } void set_measured(double a, double time) { @@ -885,9 +885,9 @@ public class AltosState implements Cloneable { if (gps.locked && gps.nsat >= 4) { /* Track consecutive 'good' gps reports, waiting for 10 of them */ - if (state == AltosLib.ao_flight_pad) { + if (state == AltosLib.ao_flight_pad || state == AltosLib.ao_flight_stateless) { set_npad(npad+1); - if (pad_lat != AltosLib.MISSING) { + if (pad_lat != AltosLib.MISSING && (npad < 10 || state == AltosLib.ao_flight_pad)) { pad_lat = (pad_lat * 31 + gps.lat) / 32; pad_lon = (pad_lon * 31 + gps.lon) / 32; gps_ground_altitude.set_filtered(gps.alt, time); @@ -949,11 +949,24 @@ public class AltosState implements Cloneable { state <= AltosLib.ao_flight_coast); boost = (AltosLib.ao_flight_boost == state); } - } public void set_device_type(int device_type) { this.device_type = device_type; + switch (device_type) { + case AltosLib.product_telegps: + this.state = AltosLib.ao_flight_stateless; + break; + } + } + + public void set_log_format(int log_format) { + this.log_format = log_format; + switch (log_format) { + case AltosLib.AO_LOG_FORMAT_TELEGPS: + this.state = AltosLib.ao_flight_stateless; + break; + } } public void set_flight_params(int apogee_delay, int main_deploy) { -- cgit v1.2.3 From 9d39bbd22e6cde1bbb39e7b5450f297d47365769 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 10 Jun 2014 10:19:43 -0700 Subject: altoslib: Check for time going backwards when replaying from file Signed-off-by: Keith Packard --- altoslib/AltosReplayReader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'altoslib') diff --git a/altoslib/AltosReplayReader.java b/altoslib/AltosReplayReader.java index ac7df414..bf7e0e5b 100644 --- a/altoslib/AltosReplayReader.java +++ b/altoslib/AltosReplayReader.java @@ -39,7 +39,7 @@ public class AltosReplayReader extends AltosFlightReader { public void update(AltosState state) throws InterruptedException { /* Make it run in realtime after the rocket leaves the pad */ - if (state.state > AltosLib.ao_flight_pad) + if (state.state > AltosLib.ao_flight_pad && state.time_change > 0) Thread.sleep((int) (Math.min(state.time_change,10) * 1000)); state.set_received_time(System.currentTimeMillis()); } -- cgit v1.2.3 From 6fc58142d2a108c91d257eb0175098bf082834f9 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 10 Jun 2014 11:30:36 -0700 Subject: altosuilib: Split battery graph enable out from other adc enables This lets TeleGPS just show the battery voltage values without also adding enable lines for the other flight computer ADC values like ignitor voltages. Signed-off-by: Keith Packard --- altoslib/AltosFlightStats.java | 30 ++++--- altosui/AltosFlightStatsTable.java | 144 ---------------------------------- altosuilib/AltosFlightStatsTable.java | 144 ++++++++++++++++++++++++++++++++++ altosuilib/AltosGraph.java | 17 ++-- 4 files changed, 173 insertions(+), 162 deletions(-) delete mode 100644 altosui/AltosFlightStatsTable.java create mode 100644 altosuilib/AltosFlightStatsTable.java (limited to 'altoslib') diff --git a/altoslib/AltosFlightStats.java b/altoslib/AltosFlightStats.java index b3305a05..56feb848 100644 --- a/altoslib/AltosFlightStats.java +++ b/altoslib/AltosFlightStats.java @@ -37,7 +37,8 @@ public class AltosFlightStats { public double pad_lat, pad_lon; public boolean has_flight_data; public boolean has_gps; - public boolean has_other_adc; + public boolean has_flight_adc; + public boolean has_battery; public boolean has_rssi; public boolean has_imu; public boolean has_mag; @@ -112,7 +113,8 @@ public class AltosFlightStats { lat = lon = AltosLib.MISSING; has_flight_data = false; has_gps = false; - has_other_adc = false; + has_flight_adc = false; + has_battery = false; has_rssi = false; has_imu = false; has_mag = false; @@ -123,7 +125,9 @@ public class AltosFlightStats { if (flight == AltosLib.MISSING && state.flight != AltosLib.MISSING) flight = state.flight; if (state.battery_voltage != AltosLib.MISSING) - has_other_adc = true; + has_battery = true; + if (state.main_voltage != AltosLib.MISSING) + has_flight_adc = true; if (state.rssi != AltosLib.MISSING) has_rssi = true; end_time = state.time; @@ -144,6 +148,11 @@ public class AltosFlightStats { minute = state.gps.minute; second = state.gps.second; } + max_height = state.max_height(); + max_speed = state.max_speed(); + max_acceleration = state.max_acceleration(); + max_gps_height = state.max_gps_height(); + if (0 <= state_id && state_id < AltosLib.ao_flight_invalid) { double acceleration = state.acceleration(); double speed = state.speed(); @@ -156,16 +165,12 @@ public class AltosFlightStats { state_start[state_id] = state.time; if (state_end[state_id] < state.time) state_end[state_id] = state.time; - max_height = state.max_height(); - max_speed = state.max_speed(); - max_acceleration = state.max_acceleration(); - max_gps_height = state.max_gps_height(); + } + if (state.pad_lat != AltosLib.MISSING) { + pad_lat = state.pad_lat; + pad_lon = state.pad_lon; } if (state.gps != null && state.gps.locked && state.gps.nsat >= 4) { - if (state_id <= AltosLib.ao_flight_pad) { - pad_lat = state.gps.lat; - pad_lon = state.gps.lon; - } lat = state.gps.lat; lon = state.gps.lon; has_gps = true; @@ -183,6 +188,9 @@ public class AltosFlightStats { if (state_count[s] > 0) { state_speed[s] /= state_count[s]; state_accel[s] /= state_count[s]; + } else { + state_speed[s] = AltosLib.MISSING; + state_accel[s] = AltosLib.MISSING; } if (state_start[s] == 0) state_start[s] = end_time; diff --git a/altosui/AltosFlightStatsTable.java b/altosui/AltosFlightStatsTable.java deleted file mode 100644 index e7a8e728..00000000 --- a/altosui/AltosFlightStatsTable.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright © 2011 Keith Packard - * - * 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 altosui; - -import java.awt.*; -import javax.swing.*; -import org.altusmetrum.altoslib_4.*; - -public class AltosFlightStatsTable extends JComponent { - GridBagLayout layout; - - class FlightStat { - JLabel label; - JTextField value; - - public FlightStat(GridBagLayout layout, int y, String label_text, String ... values) { - GridBagConstraints c = new GridBagConstraints(); - c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad); - c.weighty = 1; - - label = new JLabel(label_text); - label.setFont(Altos.label_font); - label.setHorizontalAlignment(SwingConstants.LEFT); - c.gridx = 0; c.gridy = y; - c.anchor = GridBagConstraints.WEST; - c.fill = GridBagConstraints.VERTICAL; - c.weightx = 0; - layout.setConstraints(label, c); - add(label); - - for (int j = 0; j < values.length; j++) { - value = new JTextField(values[j]); - value.setFont(Altos.value_font); - value.setHorizontalAlignment(SwingConstants.RIGHT); - c.gridx = j+1; c.gridy = y; - c.anchor = GridBagConstraints.EAST; - c.fill = GridBagConstraints.BOTH; - c.weightx = 1; - layout.setConstraints(value, c); - add(value); - } - } - - } - - static String pos(double p, String pos, String neg) { - String h = pos; - if (p < 0) { - h = neg; - p = -p; - } - int deg = (int) Math.floor(p); - double min = (p - Math.floor(p)) * 60.0; - return String.format("%s %4d° %9.6f'", h, deg, min); - } - - public AltosFlightStatsTable(AltosFlightStats stats) { - layout = new GridBagLayout(); - - setLayout(layout); - int y = 0; - new FlightStat(layout, y++, "Serial", String.format("%d", stats.serial)); - new FlightStat(layout, y++, "Flight", String.format("%d", stats.flight)); - if (stats.year != AltosLib.MISSING && stats.hour != AltosLib.MISSING) - new FlightStat(layout, y++, "Date/Time", - String.format("%04d-%02d-%02d", stats.year, stats.month, stats.day), - String.format("%02d:%02d:%02d UTC", stats.hour, stats.minute, stats.second)); - else { - if (stats.year != AltosLib.MISSING) - new FlightStat(layout, y++, "Date", - String.format("%04d-%02d-%02d", stats.year, stats.month, stats.day)); - if (stats.hour != AltosLib.MISSING) - new FlightStat(layout, y++, "Time", - String.format("%02d:%02d:%02d UTC", stats.hour, stats.minute, stats.second)); - } - new FlightStat(layout, y++, "Maximum height", - String.format("%5.0f m", stats.max_height), - String.format("%5.0f ft", AltosConvert.meters_to_feet(stats.max_height))); - if (stats.max_gps_height != AltosLib.MISSING) { - new FlightStat(layout, y++, "Maximum GPS height", - String.format("%5.0f m", stats.max_gps_height), - String.format("%5.0f ft", AltosConvert.meters_to_feet(stats.max_gps_height))); - } - new FlightStat(layout, y++, "Maximum speed", - String.format("%5.0f m/s", stats.max_speed), - String.format("%5.0f mph", AltosConvert.meters_to_mph(stats.max_speed)), - String.format("Mach %4.1f", AltosConvert.meters_to_mach(stats.max_speed))); - if (stats.max_acceleration != AltosLib.MISSING) { - new FlightStat(layout, y++, "Maximum boost acceleration", - String.format("%5.0f m/s²", stats.max_acceleration), - String.format("%5.0f ft/s²", AltosConvert.meters_to_feet(stats.max_acceleration)), - String.format("%5.0f G", AltosConvert.meters_to_g(stats.max_acceleration))); - new FlightStat(layout, y++, "Average boost acceleration", - String.format("%5.0f m/s²", stats.state_accel[Altos.ao_flight_boost]), - String.format("%5.0f ft/s²", AltosConvert.meters_to_feet(stats.state_accel[Altos.ao_flight_boost])), - String.format("%5.0f G", AltosConvert.meters_to_g(stats.state_accel[Altos.ao_flight_boost]))); - } - new FlightStat(layout, y++, "Drogue descent rate", - String.format("%5.0f m/s", stats.state_speed[Altos.ao_flight_drogue]), - String.format("%5.0f ft/s", AltosConvert.meters_to_feet(stats.state_speed[Altos.ao_flight_drogue]))); - new FlightStat(layout, y++, "Main descent rate", - String.format("%5.0f m/s", stats.state_speed[Altos.ao_flight_main]), - String.format("%5.0f ft/s", AltosConvert.meters_to_feet(stats.state_speed[Altos.ao_flight_main]))); - new FlightStat(layout, y++, "Ascent time", - String.format("%6.1f s %s", stats.state_end[AltosLib.ao_flight_boost] - stats.state_start[AltosLib.ao_flight_boost], - AltosLib.state_name(Altos.ao_flight_boost)), - String.format("%6.1f s %s", stats.state_end[AltosLib.ao_flight_fast] - stats.state_start[AltosLib.ao_flight_fast], - AltosLib.state_name(Altos.ao_flight_fast)), - String.format("%6.1f s %s", stats.state_end[AltosLib.ao_flight_coast] - stats.state_start[AltosLib.ao_flight_coast], - AltosLib.state_name(Altos.ao_flight_coast))); - new FlightStat(layout, y++, "Descent time", - String.format("%6.1f s %s", stats.state_end[AltosLib.ao_flight_drogue] - stats.state_start[AltosLib.ao_flight_drogue], - AltosLib.state_name(Altos.ao_flight_drogue)), - String.format("%6.1f s %s", stats.state_end[AltosLib.ao_flight_main] - stats.state_start[AltosLib.ao_flight_main], - AltosLib.state_name(Altos.ao_flight_main))); - new FlightStat(layout, y++, "Flight time", - String.format("%6.1f s", stats.state_end[Altos.ao_flight_main] - - stats.state_start[Altos.ao_flight_boost])); - if (stats.has_gps) { - new FlightStat(layout, y++, "Pad location", - pos(stats.pad_lat,"N","S"), - pos(stats.pad_lon,"E","W")); - new FlightStat(layout, y++, "Last reported location", - pos(stats.lat,"N","S"), - pos(stats.lon,"E","W")); - } - } - -} \ No newline at end of file diff --git a/altosuilib/AltosFlightStatsTable.java b/altosuilib/AltosFlightStatsTable.java new file mode 100644 index 00000000..e7a8e728 --- /dev/null +++ b/altosuilib/AltosFlightStatsTable.java @@ -0,0 +1,144 @@ +/* + * Copyright © 2011 Keith Packard + * + * 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 altosui; + +import java.awt.*; +import javax.swing.*; +import org.altusmetrum.altoslib_4.*; + +public class AltosFlightStatsTable extends JComponent { + GridBagLayout layout; + + class FlightStat { + JLabel label; + JTextField value; + + public FlightStat(GridBagLayout layout, int y, String label_text, String ... values) { + GridBagConstraints c = new GridBagConstraints(); + c.insets = new Insets(Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad, Altos.tab_elt_pad); + c.weighty = 1; + + label = new JLabel(label_text); + label.setFont(Altos.label_font); + label.setHorizontalAlignment(SwingConstants.LEFT); + c.gridx = 0; c.gridy = y; + c.anchor = GridBagConstraints.WEST; + c.fill = GridBagConstraints.VERTICAL; + c.weightx = 0; + layout.setConstraints(label, c); + add(label); + + for (int j = 0; j < values.length; j++) { + value = new JTextField(values[j]); + value.setFont(Altos.value_font); + value.setHorizontalAlignment(SwingConstants.RIGHT); + c.gridx = j+1; c.gridy = y; + c.anchor = GridBagConstraints.EAST; + c.fill = GridBagConstraints.BOTH; + c.weightx = 1; + layout.setConstraints(value, c); + add(value); + } + } + + } + + static String pos(double p, String pos, String neg) { + String h = pos; + if (p < 0) { + h = neg; + p = -p; + } + int deg = (int) Math.floor(p); + double min = (p - Math.floor(p)) * 60.0; + return String.format("%s %4d° %9.6f'", h, deg, min); + } + + public AltosFlightStatsTable(AltosFlightStats stats) { + layout = new GridBagLayout(); + + setLayout(layout); + int y = 0; + new FlightStat(layout, y++, "Serial", String.format("%d", stats.serial)); + new FlightStat(layout, y++, "Flight", String.format("%d", stats.flight)); + if (stats.year != AltosLib.MISSING && stats.hour != AltosLib.MISSING) + new FlightStat(layout, y++, "Date/Time", + String.format("%04d-%02d-%02d", stats.year, stats.month, stats.day), + String.format("%02d:%02d:%02d UTC", stats.hour, stats.minute, stats.second)); + else { + if (stats.year != AltosLib.MISSING) + new FlightStat(layout, y++, "Date", + String.format("%04d-%02d-%02d", stats.year, stats.month, stats.day)); + if (stats.hour != AltosLib.MISSING) + new FlightStat(layout, y++, "Time", + String.format("%02d:%02d:%02d UTC", stats.hour, stats.minute, stats.second)); + } + new FlightStat(layout, y++, "Maximum height", + String.format("%5.0f m", stats.max_height), + String.format("%5.0f ft", AltosConvert.meters_to_feet(stats.max_height))); + if (stats.max_gps_height != AltosLib.MISSING) { + new FlightStat(layout, y++, "Maximum GPS height", + String.format("%5.0f m", stats.max_gps_height), + String.format("%5.0f ft", AltosConvert.meters_to_feet(stats.max_gps_height))); + } + new FlightStat(layout, y++, "Maximum speed", + String.format("%5.0f m/s", stats.max_speed), + String.format("%5.0f mph", AltosConvert.meters_to_mph(stats.max_speed)), + String.format("Mach %4.1f", AltosConvert.meters_to_mach(stats.max_speed))); + if (stats.max_acceleration != AltosLib.MISSING) { + new FlightStat(layout, y++, "Maximum boost acceleration", + String.format("%5.0f m/s²", stats.max_acceleration), + String.format("%5.0f ft/s²", AltosConvert.meters_to_feet(stats.max_acceleration)), + String.format("%5.0f G", AltosConvert.meters_to_g(stats.max_acceleration))); + new FlightStat(layout, y++, "Average boost acceleration", + String.format("%5.0f m/s²", stats.state_accel[Altos.ao_flight_boost]), + String.format("%5.0f ft/s²", AltosConvert.meters_to_feet(stats.state_accel[Altos.ao_flight_boost])), + String.format("%5.0f G", AltosConvert.meters_to_g(stats.state_accel[Altos.ao_flight_boost]))); + } + new FlightStat(layout, y++, "Drogue descent rate", + String.format("%5.0f m/s", stats.state_speed[Altos.ao_flight_drogue]), + String.format("%5.0f ft/s", AltosConvert.meters_to_feet(stats.state_speed[Altos.ao_flight_drogue]))); + new FlightStat(layout, y++, "Main descent rate", + String.format("%5.0f m/s", stats.state_speed[Altos.ao_flight_main]), + String.format("%5.0f ft/s", AltosConvert.meters_to_feet(stats.state_speed[Altos.ao_flight_main]))); + new FlightStat(layout, y++, "Ascent time", + String.format("%6.1f s %s", stats.state_end[AltosLib.ao_flight_boost] - stats.state_start[AltosLib.ao_flight_boost], + AltosLib.state_name(Altos.ao_flight_boost)), + String.format("%6.1f s %s", stats.state_end[AltosLib.ao_flight_fast] - stats.state_start[AltosLib.ao_flight_fast], + AltosLib.state_name(Altos.ao_flight_fast)), + String.format("%6.1f s %s", stats.state_end[AltosLib.ao_flight_coast] - stats.state_start[AltosLib.ao_flight_coast], + AltosLib.state_name(Altos.ao_flight_coast))); + new FlightStat(layout, y++, "Descent time", + String.format("%6.1f s %s", stats.state_end[AltosLib.ao_flight_drogue] - stats.state_start[AltosLib.ao_flight_drogue], + AltosLib.state_name(Altos.ao_flight_drogue)), + String.format("%6.1f s %s", stats.state_end[AltosLib.ao_flight_main] - stats.state_start[AltosLib.ao_flight_main], + AltosLib.state_name(Altos.ao_flight_main))); + new FlightStat(layout, y++, "Flight time", + String.format("%6.1f s", stats.state_end[Altos.ao_flight_main] - + stats.state_start[Altos.ao_flight_boost])); + if (stats.has_gps) { + new FlightStat(layout, y++, "Pad location", + pos(stats.pad_lat,"N","S"), + pos(stats.pad_lon,"E","W")); + new FlightStat(layout, y++, "Last reported location", + pos(stats.lat,"N","S"), + pos(stats.lon,"E","W")); + } + } + +} \ No newline at end of file diff --git a/altosuilib/AltosGraph.java b/altosuilib/AltosGraph.java index 73c53a22..f8c8b27b 100644 --- a/altosuilib/AltosGraph.java +++ b/altosuilib/AltosGraph.java @@ -333,19 +333,22 @@ public class AltosGraph extends AltosUIGraph { dbm_color, false, dbm_axis); - if (stats.has_other_adc) { - addSeries("Temperature", - AltosGraphDataPoint.data_temperature, - AltosConvert.temperature, - temperature_color, - false, - temperature_axis); + + if (stats.has_battery) addSeries("Battery Voltage", AltosGraphDataPoint.data_battery_voltage, voltage_units, battery_voltage_color, false, voltage_axis); + + if (stats.has_flight_adc) { + addSeries("Temperature", + AltosGraphDataPoint.data_temperature, + AltosConvert.temperature, + temperature_color, + false, + temperature_axis); addSeries("Drogue Voltage", AltosGraphDataPoint.data_drogue_voltage, voltage_units, -- cgit v1.2.3 From 7bdd0deabaae38ddfecd1ea2ea8deaf9af40b2ac Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 10 Jun 2014 11:31:53 -0700 Subject: altoslib: Use GPS speed/height values when other sensors are missing This lets TeleGPS report height/speed values without needing to customize every AltosState user to pull out GPS values when the other sensors aren't present. Signed-off-by: Keith Packard --- altoslib/AltosState.java | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index 2d75f72e..6926994c 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -392,6 +392,7 @@ public class AltosState implements Cloneable { private AltosValue gps_ground_speed; private AltosValue gps_ascent_rate; private AltosValue gps_course; + private AltosValue gps_speed; public double altitude() { double a = altitude.value(); @@ -427,14 +428,30 @@ public class AltosState implements Cloneable { return gps_ground_speed.value(); } + public double max_gps_ground_speed() { + return gps_ground_speed.max(); + } + public double gps_ascent_rate() { return gps_ascent_rate.value(); } + public double max_gps_ascent_rate() { + return gps_ascent_rate.max(); + } + public double gps_course() { return gps_course.value(); } + public double gps_speed() { + return gps_speed.value(); + } + + public double max_gps_speed() { + return gps_speed.max(); + } + class AltosPressure extends AltosValue { void set(double p, double time) { super.set(p, time); @@ -476,7 +493,7 @@ public class AltosState implements Cloneable { double g = ground_altitude(); if (a != AltosLib.MISSING && g != AltosLib.MISSING) return a - g; - return AltosLib.MISSING; + return max_gps_height(); } public double gps_height() { @@ -529,14 +546,26 @@ public class AltosState implements Cloneable { double v = kalman_speed.value(); if (v != AltosLib.MISSING) return v; - return speed.value(); + v = speed.value(); + if (v != AltosLib.MISSING) + return v; + v = gps_speed(); + if (v != AltosLib.MISSING) + return v; + return AltosLib.MISSING; } public double max_speed() { double v = kalman_speed.max(); if (v != AltosLib.MISSING) return v; - return speed.max(); + v = speed.max(); + if (v != AltosLib.MISSING) + return v; + v = max_gps_speed(); + if (v != AltosLib.MISSING) + return v; + return AltosLib.MISSING; } class AltosAccel extends AltosCValue { @@ -712,6 +741,7 @@ public class AltosState implements Cloneable { gps_altitude = new AltosGpsAltitude(); gps_ground_altitude = new AltosGpsGroundAltitude(); gps_ground_speed = new AltosValue(); + gps_speed = new AltosValue(); gps_ascent_rate = new AltosValue(); gps_course = new AltosValue(); @@ -846,6 +876,7 @@ public class AltosState implements Cloneable { gps_ground_speed.copy(old.gps_ground_speed); gps_ascent_rate.copy(old.gps_ascent_rate); gps_course.copy(old.gps_course); + gps_speed.copy(old.gps_speed); pad_lat = old.pad_lat; pad_lon = old.pad_lon; @@ -903,6 +934,9 @@ public class AltosState implements Cloneable { gps_ascent_rate.set(gps.climb_rate, time); if (gps.ground_speed != AltosLib.MISSING) gps_ground_speed.set(gps.ground_speed, time); + if (gps.climb_rate != AltosLib.MISSING && gps.ground_speed != AltosLib.MISSING) + gps_speed.set(Math.sqrt(gps.ground_speed * gps.ground_speed + + gps.climb_rate * gps.climb_rate), time); if (gps.course != AltosLib.MISSING) gps_course.set(gps.course, time); } -- cgit v1.2.3 From a8325483adb8d9ffda62d3f4900cf52bde70ff62 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 11 Jun 2014 18:48:11 -0700 Subject: altoslib: Use GPS seconds as an additional sort key for TeleGPS eeprom Long idle periods with TeleGPS can easily overflow 16 bits of tick count. Using the GPS seconds provides an additional sort which will span the tick wrap-around. Signed-off-by: Keith Packard --- altoslib/AltosEeprom.java | 4 ++++ altoslib/AltosEepromGPS.java | 11 +++++++++++ altoslib/AltosEepromIterable.java | 9 ++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) (limited to 'altoslib') diff --git a/altoslib/AltosEeprom.java b/altoslib/AltosEeprom.java index be18ba24..020590eb 100644 --- a/altoslib/AltosEeprom.java +++ b/altoslib/AltosEeprom.java @@ -43,6 +43,10 @@ public abstract class AltosEeprom implements AltosStateUpdate { return data8[i] | (data8[i+1] << 8) | (data8[i+2] << 16) | (data8[i+3] << 24); } + public boolean has_seconds() { return false; } + + public int seconds() { return 0; } + public final static int header_length = 4; public abstract int record_length(); diff --git a/altoslib/AltosEepromGPS.java b/altoslib/AltosEepromGPS.java index 1820cd61..3c1852c0 100644 --- a/altoslib/AltosEepromGPS.java +++ b/altoslib/AltosEepromGPS.java @@ -53,6 +53,17 @@ public class AltosEepromGPS extends AltosEeprom { public int vdop() { return data8(24); } public int mode() { return data8(25); } + public boolean has_seconds() { return cmd == AltosLib.AO_LOG_GPS_TIME; } + + public int seconds() { + switch (cmd) { + case AltosLib.AO_LOG_GPS_TIME: + return second() + 60 * (minute() + 60 * (hour() + 24 * (day() + 31 * month()))); + default: + return 0; + } + } + public AltosEepromGPS (AltosEepromChunk chunk, int start) throws ParseException { parse_chunk(chunk, start); } diff --git a/altoslib/AltosEepromIterable.java b/altoslib/AltosEepromIterable.java index 415c5b62..d6832c1b 100644 --- a/altoslib/AltosEepromIterable.java +++ b/altoslib/AltosEepromIterable.java @@ -38,6 +38,13 @@ class AltosEepromOrdered implements Comparable { if (cmd_diff != 0) return cmd_diff; + if (eeprom.has_seconds() && o.eeprom.has_seconds()) { + int seconds_diff = eeprom.seconds() - o.eeprom.seconds(); + + if (seconds_diff != 0) + return seconds_diff; + } + int tick_diff = tick - o.tick; if (tick_diff != 0) @@ -116,4 +123,4 @@ public class AltosEepromIterable implements Iterable { eeproms = new LinkedList(); return new AltosEepromOrderedIterator(eeproms); } -} \ No newline at end of file +} -- cgit v1.2.3 From d744e588b7504f314e39b1407152d11c031673c9 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 11 Jun 2014 19:51:37 -0700 Subject: altosui: Add pyro firing time configuration Signed-off-by: Keith Packard --- altoslib/AltosConfigData.java | 8 +++++++ altoslib/AltosConfigValues.java | 4 ++++ altosui/AltosConfigPyroUI.java | 50 ++++++++++++++++++++++++++++++++++++++++- altosui/AltosConfigUI.java | 16 ++++++++++++- telegps/TeleGPSConfigUI.java | 7 ++++++ 5 files changed, 83 insertions(+), 2 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index 563bef4b..e1043958 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -67,6 +67,7 @@ public class AltosConfigData implements Iterable { public AltosPyro[] pyros; public int npyro; public int pyro; + public double pyro_firing_time; /* HAS_APRS */ public int aprs_interval; @@ -246,6 +247,7 @@ public class AltosConfigData implements Iterable { pyro = 0; npyro = 0; pyros = null; + pyro_firing_time = -1; aprs_interval = -1; @@ -327,6 +329,7 @@ public class AltosConfigData implements Iterable { pyros[pyro++] = p; } catch (Exception e) {} } + try { pyro_firing_time = get_int(line, "Pyro time:") / 100.0; } catch (Exception e) {} /* HAS_APRS */ try { aprs_interval = get_int(line, "APRS interval:"); } catch (Exception e) {} @@ -450,6 +453,8 @@ public class AltosConfigData implements Iterable { /* AO_PYRO_NUM */ if (npyro > 0) pyros = source.pyros(); + if (pyro_firing_time >= 0) + pyro_firing_time = source.pyro_firing_time(); /* HAS_APRS */ if (aprs_interval >= 0) @@ -500,6 +505,7 @@ public class AltosConfigData implements Iterable { dest.set_pyros(pyros); else dest.set_pyros(null); + dest.set_pyro_firing_time(pyro_firing_time); dest.set_aprs_interval(aprs_interval); dest.set_beep(beep); dest.set_tracker_motion(tracker_motion); @@ -565,6 +571,8 @@ public class AltosConfigData implements Iterable { pyros[p].toString()); } } + if (pyro_firing_time >= 0) + link.printf("c I %d\n", (int) (pyro_firing_time * 100.0 + 0.5)); /* HAS_APRS */ if (aprs_interval >= 0) diff --git a/altoslib/AltosConfigValues.java b/altoslib/AltosConfigValues.java index 778f1222..724ba7dc 100644 --- a/altoslib/AltosConfigValues.java +++ b/altoslib/AltosConfigValues.java @@ -73,6 +73,10 @@ public interface AltosConfigValues { public abstract AltosPyro[] pyros() throws AltosConfigDataException; + public abstract void set_pyro_firing_time(double new_pyro_firing_time); + + public abstract double pyro_firing_time() throws AltosConfigDataException; + public abstract int aprs_interval() throws AltosConfigDataException; public abstract void set_aprs_interval(int new_aprs_interval); diff --git a/altosui/AltosConfigPyroUI.java b/altosui/AltosConfigPyroUI.java index 7a298a3c..f0b4f0f9 100644 --- a/altosui/AltosConfigPyroUI.java +++ b/altosui/AltosConfigPyroUI.java @@ -278,6 +278,28 @@ public class AltosConfigPyroUI return pyros; } + JLabel pyro_firing_time_label; + JComboBox pyro_firing_time_value; + + static String[] pyro_firing_time_values = { + "0.050", "0.100", "0.250", "0.500", "1.0", "2.0" + }; + + public void set_pyro_firing_time(double new_pyro_firing_time) { + pyro_firing_time_value.setSelectedItem(Double.toString(new_pyro_firing_time)); + pyro_firing_time_value.setEnabled(new_pyro_firing_time >= 0); + } + + public double get_pyro_firing_time() throws AltosConfigDataException { + String v = pyro_firing_time_value.getSelectedItem().toString(); + + try { + return Double.parseDouble(v); + } catch (NumberFormatException e) { + throw new AltosConfigDataException("Invalid pyro firing time \"%s\"", v); + } + } + public void set_dirty() { owner.set_dirty(); } @@ -334,7 +356,7 @@ public class AltosConfigPyroUI setVisible(false); } - public AltosConfigPyroUI(AltosConfigUI in_owner, AltosPyro[] pyros) { + public AltosConfigPyroUI(AltosConfigUI in_owner, AltosPyro[] pyros, double pyro_firing_time) { super(in_owner, "Configure Pyro Channels", false); @@ -379,6 +401,32 @@ public class AltosConfigPyroUI columns[i].set(pyros[i]); } + /* Pyro firing time */ + c = new GridBagConstraints(); + c.gridx = 0; c.gridy = row; + c.gridwidth = 2; + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.LINE_START; + c.insets = il; + c.ipady = 5; + pyro_firing_time_label = new JLabel("Pyro Firing Time(s):"); + pane.add(pyro_firing_time_label, c); + + c = new GridBagConstraints(); + c.gridx = 2; c.gridy = row; + c.gridwidth = 7; + c.fill = GridBagConstraints.HORIZONTAL; + c.weightx = 1; + c.anchor = GridBagConstraints.LINE_START; + c.insets = ir; + c.ipady = 5; + pyro_firing_time_value = new JComboBox(pyro_firing_time_values); + pyro_firing_time_value.setEditable(true); + pyro_firing_time_value.addItemListener(this); + set_pyro_firing_time(pyro_firing_time); + pane.add(pyro_firing_time_value, c); + pyro_firing_time_value.setToolTipText("Length of extra pyro channel firing pulse"); + c = new GridBagConstraints(); c.gridx = pyros.length*2-1; c.fill = GridBagConstraints.HORIZONTAL; diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java index ee54e31e..56d0d2a7 100644 --- a/altosui/AltosConfigUI.java +++ b/altosui/AltosConfigUI.java @@ -78,6 +78,7 @@ public class AltosConfigUI JButton close; AltosPyro[] pyros; + double pyro_firing_time; ActionListener listener; @@ -792,7 +793,7 @@ public class AltosConfigUI if (cmd.equals("Pyro")) { if (pyro_ui == null && pyros != null) - pyro_ui = new AltosConfigPyroUI(this, pyros); + pyro_ui = new AltosConfigPyroUI(this, pyros, pyro_firing_time); if (pyro_ui != null) pyro_ui.make_visible(); return; @@ -1130,6 +1131,19 @@ public class AltosConfigUI return pyros; } + public void set_pyro_firing_time(double new_pyro_firing_time) { + pyro_firing_time = new_pyro_firing_time; + pyro.setVisible(pyro_firing_time >= 0); + if (pyro_firing_time >= 0 && pyro_ui != null) + pyro_ui.set_pyro_firing_time(pyro_firing_time); + } + + public double pyro_firing_time() throws AltosConfigDataException { + if (pyro_ui != null) + pyro_firing_time = pyro_ui.get_pyro_firing_time(); + return pyro_firing_time; + } + public void set_aprs_interval(int new_aprs_interval) { String s; diff --git a/telegps/TeleGPSConfigUI.java b/telegps/TeleGPSConfigUI.java index 325ca7b9..f6c69040 100644 --- a/telegps/TeleGPSConfigUI.java +++ b/telegps/TeleGPSConfigUI.java @@ -115,6 +115,13 @@ public class TeleGPSConfigUI return null; } + public void set_pyro_firing_time(double new_pyro_firing_time) { + } + + public double pyro_firing_time() { + return -1; + } + boolean is_telemetrum() { String product = product_value.getText(); return product != null && product.startsWith("TeleGPS"); -- cgit v1.2.3 From efb6a3d5ed12f8061a48a66efcfe066e68eaf792 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 11 Jun 2014 23:04:11 -0700 Subject: altoslib: Report GPS height when baro height is not available Signed-off-by: Keith Packard --- altoslib/AltosState.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'altoslib') diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index 6926994c..256826a5 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -481,7 +481,7 @@ public class AltosState implements Cloneable { double g = ground_altitude(); if (a != AltosLib.MISSING && g != AltosLib.MISSING) return a - g; - return AltosLib.MISSING; + return gps_height(); } public double max_height() { -- cgit v1.2.3 From 07baa7596b36cf808cd1ee26ff158b1cf8585294 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 13 Jun 2014 00:01:46 -0700 Subject: altoslib: Call state.set_serial first for telemetry parsing If we ever get around to supporting multiple simultaneous remote devices, we'll need to notice that the serial changed right away Signed-off-by: Keith Packard --- altoslib/AltosTelemetry.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'altoslib') diff --git a/altoslib/AltosTelemetry.java b/altoslib/AltosTelemetry.java index 62948378..8182ec6b 100644 --- a/altoslib/AltosTelemetry.java +++ b/altoslib/AltosTelemetry.java @@ -43,9 +43,9 @@ public abstract class AltosTelemetry implements AltosStateUpdate { } public void update_state(AltosState state) { + state.set_serial(serial); if (state.state == AltosLib.ao_flight_invalid) state.set_state(AltosLib.ao_flight_startup); - state.set_serial(serial); state.set_tick(tick); state.set_rssi(rssi, status); state.set_received_time(received_time); -- cgit v1.2.3 From fd9ae83492648c5d39f60bdcff15481efb365701 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 13 Jun 2014 00:27:19 -0700 Subject: altoslib: Remove telem monitoring when closing log file If we don't remove the telemetry monitor, the telemetry device will still be sending telemetry, which isn't good. Signed-off-by: Keith Packard --- altoslib/AltosLog.java | 1 + 1 file changed, 1 insertion(+) (limited to 'altoslib') diff --git a/altoslib/AltosLog.java b/altoslib/AltosLog.java index 8ecb1e96..c4e9e425 100644 --- a/altoslib/AltosLog.java +++ b/altoslib/AltosLog.java @@ -48,6 +48,7 @@ public class AltosLog implements Runnable { } public void close() { + link.remove_monitor(input_queue); close_log_file(); if (log_thread != null) { log_thread.interrupt(); -- cgit v1.2.3 From 3bfba8f9dbc1627a317804713f83b9d06566d008 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 13 Jun 2014 15:21:28 -0700 Subject: altoslib: Add conversion class for voltages Provide a common presentation for voltage values Signed-off-by: Keith Packard --- altoslib/AltosConvert.java | 2 ++ altoslib/AltosVoltage.java | 41 +++++++++++++++++++++++++++++++++++++++++ altoslib/Makefile.am | 1 + 3 files changed, 44 insertions(+) create mode 100644 altoslib/AltosVoltage.java (limited to 'altoslib') diff --git a/altoslib/AltosConvert.java b/altoslib/AltosConvert.java index 6578e90f..87b9eaf2 100644 --- a/altoslib/AltosConvert.java +++ b/altoslib/AltosConvert.java @@ -349,6 +349,8 @@ public class AltosConvert { public static AltosOrient orient = new AltosOrient(); + public static AltosVoltage voltage = new AltosVoltage(); + public static String show_gs(String format, double a) { a = meters_to_g(a); format = format.concat(" g"); diff --git a/altoslib/AltosVoltage.java b/altoslib/AltosVoltage.java new file mode 100644 index 00000000..351bf115 --- /dev/null +++ b/altoslib/AltosVoltage.java @@ -0,0 +1,41 @@ +/* + * Copyright © 2012 Keith Packard + * + * 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_4; + +public class AltosVoltage extends AltosUnits { + + public double value(double v, boolean imperial_units) { + return v; + } + + public double inverse(double v, boolean imperial_units) { + return v; + } + + public String show_units(boolean imperial_units) { + return "V"; + } + + public String say_units(boolean imperial_units) { + return "volts"; + } + + public int show_fraction(int width, boolean imperial_units) { + return 2; + } +} diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am index 1086f858..bd47f89f 100644 --- a/altoslib/Makefile.am +++ b/altoslib/Makefile.am @@ -119,6 +119,7 @@ altoslib_JAVA = \ AltosSpeed.java \ AltosTemperature.java \ AltosAccel.java \ + AltosVoltage.java \ AltosPyro.java \ AltosWriter.java -- cgit v1.2.3 From 876acbdc22ff93c22836f789e0b6394eb19e0da3 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 13 Jun 2014 15:22:25 -0700 Subject: altoslib: Correctly save firmware version in AltosState It wasn't getting cloned Signed-off-by: Keith Packard --- altoslib/AltosState.java | 2 ++ 1 file changed, 2 insertions(+) (limited to 'altoslib') diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index 256826a5..d391dcfb 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -749,6 +749,7 @@ public class AltosState implements Cloneable { speak_altitude = AltosLib.MISSING; callsign = null; + firmware_version = null; accel_plus_g = AltosLib.MISSING; accel_minus_g = AltosLib.MISSING; @@ -886,6 +887,7 @@ public class AltosState implements Cloneable { speak_altitude = old.speak_altitude; callsign = old.callsign; + firmware_version = old.firmware_version; accel_plus_g = old.accel_plus_g; accel_minus_g = old.accel_minus_g; -- cgit v1.2.3 From 451950bba9ee3b25b5d0c6e5f0b55f08a5b29f73 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 14 Jun 2014 14:33:58 -0700 Subject: altoslib: Add units converters for latitude and longitude Makes display of these values consistent across all instances Signed-off-by: Keith Packard --- altoslib/AltosConvert.java | 4 +++ altoslib/AltosLatitude.java | 23 +++++++++++++++ altoslib/AltosLocation.java | 66 ++++++++++++++++++++++++++++++++++++++++++++ altoslib/AltosLongitude.java | 23 +++++++++++++++ altoslib/Makefile.am | 3 ++ 5 files changed, 119 insertions(+) create mode 100644 altoslib/AltosLatitude.java create mode 100644 altoslib/AltosLocation.java create mode 100644 altoslib/AltosLongitude.java (limited to 'altoslib') diff --git a/altoslib/AltosConvert.java b/altoslib/AltosConvert.java index 87b9eaf2..dc0fbb62 100644 --- a/altoslib/AltosConvert.java +++ b/altoslib/AltosConvert.java @@ -351,6 +351,10 @@ public class AltosConvert { public static AltosVoltage voltage = new AltosVoltage(); + public static AltosLatitude latitude = new AltosLatitude(); + + public static AltosLongitude longitude = new AltosLongitude(); + public static String show_gs(String format, double a) { a = meters_to_g(a); format = format.concat(" g"); diff --git a/altoslib/AltosLatitude.java b/altoslib/AltosLatitude.java new file mode 100644 index 00000000..6156d6dc --- /dev/null +++ b/altoslib/AltosLatitude.java @@ -0,0 +1,23 @@ +/* + * Copyright © 2014 Keith Packard + * + * 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_4; + +public class AltosLatitude extends AltosLocation { + public String pos() { return "N"; } + public String neg() { return "S"; } +} diff --git a/altoslib/AltosLocation.java b/altoslib/AltosLocation.java new file mode 100644 index 00000000..725a02ba --- /dev/null +++ b/altoslib/AltosLocation.java @@ -0,0 +1,66 @@ +/* + * Copyright © 2014 Keith Packard + * + * 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_4; + +public abstract class AltosLocation extends AltosUnits { + + public abstract String pos(); + public abstract String neg(); + + public double value(double v, boolean imperial_units) { + return v; + } + + public double inverse(double v, boolean imperial_units) { + return v; + } + + public String show_units(boolean imperial_units) { + return "°"; + } + + public String say_units(boolean imperial_units) { + return "degrees"; + } + + public int show_fraction(int width, boolean imperial_units) { + return 2; + } + + public String show(int width, double v, boolean imperial_units) { + String h = pos(); + if (v < 0) { + h = neg(); + v = -v; + } + int deg = (int) Math.floor(v); + double min = (v - Math.floor(v)) * 60.0; + return String.format("%s %4d° %9.6f", h, deg, min); + } + + public String say(double v, boolean imperial_units) { + String h = pos(); + if (v < 0) { + h = neg(); + v = -v; + } + int deg = (int) Math.floor(v); + double min = (v - Math.floor(v)) * 60.0; + return String.format("%s %d degrees %d", h, deg, (int) Math.floor(min + 0.5)); + } +} diff --git a/altoslib/AltosLongitude.java b/altoslib/AltosLongitude.java new file mode 100644 index 00000000..29a5dcd4 --- /dev/null +++ b/altoslib/AltosLongitude.java @@ -0,0 +1,23 @@ +/* + * Copyright © 2014 Keith Packard + * + * 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_4; + +public class AltosLongitude extends AltosLocation { + public String pos() { return "E"; } + public String neg() { return "W"; } +} diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am index bd47f89f..e81418bb 100644 --- a/altoslib/Makefile.am +++ b/altoslib/Makefile.am @@ -120,6 +120,9 @@ altoslib_JAVA = \ AltosTemperature.java \ AltosAccel.java \ AltosVoltage.java \ + AltosLocation.java \ + AltosLatitude.java \ + AltosLongitude.java \ AltosPyro.java \ AltosWriter.java -- cgit v1.2.3 From 14f0faae48849ff6f1e326a294b54c504c730bb9 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 14 Jun 2014 14:34:59 -0700 Subject: altoslib: When GPS disappears, set range and elevation to MISSING Use MISSING instead of bogus values so that displayers can tell what to do. Signed-off-by: Keith Packard --- altoslib/AltosState.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index d391dcfb..b05cd358 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -910,8 +910,8 @@ public class AltosState implements Cloneable { } void update_gps() { - elevation = 0; - range = -1; + elevation = AltosLib.MISSING; + range = AltosLib.MISSING; if (gps == null) return; -- cgit v1.2.3