From 4c5acb57d7ac1abec7bb4cda9dc88c2a19767a2d Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 28 May 2017 16:53:43 -0700 Subject: [PATCH] altoslib,altosuilib: Remove stale source files These aren't built any longer Signed-off-by: Keith Packard --- altoslib/AltosStateIterable.java | 41 --- altoslib/AltosTelemetryRecordSet.java | 99 ------ altosuilib/AltosEepromMonitor.java | 252 --------------- altosuilib/AltosFlightStatsTable.java | 4 +- altosuilib/AltosGraph.java | 427 -------------------------- altosuilib/AltosGraphDataPoint.java | 250 --------------- altosuilib/AltosGraphDataSet.java | 95 ------ altosuilib/AltosUIGraph.java | 160 ---------- altosuilib/AltosUIGraphNew.java | 9 + altosuilib/AltosUISeries.java | 114 ------- altosuilib/AltosUITimeSeries.java | 18 ++ altosuilib/Makefile.am | 2 - 12 files changed, 30 insertions(+), 1441 deletions(-) delete mode 100644 altoslib/AltosStateIterable.java delete mode 100644 altoslib/AltosTelemetryRecordSet.java delete mode 100644 altosuilib/AltosEepromMonitor.java delete mode 100644 altosuilib/AltosGraph.java delete mode 100644 altosuilib/AltosGraphDataPoint.java delete mode 100644 altosuilib/AltosGraphDataSet.java delete mode 100644 altosuilib/AltosUIGraph.java delete mode 100644 altosuilib/AltosUISeries.java diff --git a/altoslib/AltosStateIterable.java b/altoslib/AltosStateIterable.java deleted file mode 100644 index ec3d944d..00000000 --- a/altoslib/AltosStateIterable.java +++ /dev/null @@ -1,41 +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; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -package org.altusmetrum.altoslib_11; - -import java.io.*; -import java.util.*; - -public abstract class AltosStateIterable implements Iterable { - - public void write_comments (PrintStream out) { - } - - public abstract void write(PrintStream out); - - public static AltosStateIterable iterable(File file) { - try { - if (file.getName().endsWith("telem")) - return new AltosTelemetryFile(new FileInputStream(file)); - else - return new AltosEepromFile(new FileReader(file)); - } catch (Exception e) { - return null; - } - } -} diff --git a/altoslib/AltosTelemetryRecordSet.java b/altoslib/AltosTelemetryRecordSet.java deleted file mode 100644 index a3191100..00000000 --- a/altoslib/AltosTelemetryRecordSet.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright © 2017 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, either version 2 of the License, or - * (at your option) any later version. - * - * 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. - */ - -package org.altusmetrum.altoslib_11; - -import java.io.*; -import java.util.*; - -public class AltosTelemetryRecordSet implements AltosRecordSet { - AltosTelemetry telemetry; - TreeSet ordered; - - public void capture_series(AltosDataListener listener) { - listener.cal_data.reset(); - for (AltosTelemetryRecord record : ordered) { - record.update_state(listener); - } - listener.finish(); - } - - public AltosTelemetryRecordSet(AltosTelemetry telemetry) { - this.telemetry = telemetry; - - AltosTelemetryRecord record = null; - - switch (config_data.log_format) { - case AltosLib.AO_LOG_FORMAT_FULL: - record = new AltosTelemetryRecordFull(eeprom); - break; - case AltosLib.AO_LOG_FORMAT_TINY: - record = new AltosTelemetryRecordTiny(eeprom); - break; - case AltosLib.AO_LOG_FORMAT_TELEMETRY: - case AltosLib.AO_LOG_FORMAT_TELESCIENCE: - case AltosLib.AO_LOG_FORMAT_TELEMEGA: - case AltosLib.AO_LOG_FORMAT_TELEMEGA_OLD: - record = new AltosTelemetryRecordMega(eeprom); - break; - case AltosLib.AO_LOG_FORMAT_TELEMETRUM: - record = new AltosTelemetryRecordMetrum(eeprom); - break; - case AltosLib.AO_LOG_FORMAT_TELEMINI2: - case AltosLib.AO_LOG_FORMAT_TELEMINI3: - case AltosLib.AO_LOG_FORMAT_EASYMINI: - record = new AltosTelemetryRecordMini(eeprom); - break; - case AltosLib.AO_LOG_FORMAT_TELEGPS: - record = new AltosTelemetryRecordGps(eeprom); - break; - case AltosLib.AO_LOG_FORMAT_TELEFIRETWO: - record = new AltosTelemetryRecordFireTwo(eeprom); - break; - } - - if (record == null) { - System.out.printf("failed to parse log format %d\n", config_data.log_format); - return; - } - ordered = new TreeSet(); - int tick = 0; - boolean first = true; - - start_state = new AltosState(); - start_state.set_config_data(record.eeprom.config_data()); - - for (;;) { - int t = record.tick(); - - if (first) { - tick = t; - first = false; - } else { - while (t < tick - 32767) - t += 65536; - tick = t; - } - record.wide_tick = tick; - ordered.add(record); - if (!record.hasNext()) - break; - record = record.next(); - } - } - - public AltosTelemetryRecordSet(Reader input) throws IOException { - this(new AltosTelemetryNew(input)); - } -} diff --git a/altosuilib/AltosEepromMonitor.java b/altosuilib/AltosEepromMonitor.java deleted file mode 100644 index d61169f4..00000000 --- a/altosuilib/AltosEepromMonitor.java +++ /dev/null @@ -1,252 +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; either version 2 of the License, or - * (at your option) any later version. - * - * 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_11; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; - -public class AltosEepromMonitor extends AltosUIDialog { - - Container pane; - Box box; - JLabel serial_label; - JLabel flight_label; - JLabel file_label; - JLabel serial_value; - JLabel flight_value; - JLabel file_value; - JButton cancel; - JProgressBar pbar; - int min_state, max_state; - - public AltosEepromMonitor(JFrame owner, int in_min_state, int in_max_state) { - super (owner, "Download Flight Data", false); - - GridBagConstraints c; - Insets il = new Insets(4,4,4,4); - Insets ir = new Insets(4,4,4,4); - - pane = getContentPane(); - pane.setLayout(new GridBagLayout()); - - c = new GridBagConstraints(); - c.gridx = 0; c.gridy = 0; - c.fill = GridBagConstraints.NONE; - c.anchor = GridBagConstraints.LINE_START; - c.insets = il; - serial_label = new JLabel("Serial:"); - pane.add(serial_label, c); - - c = new GridBagConstraints(); - c.gridx = 1; c.gridy = 0; - c.fill = GridBagConstraints.HORIZONTAL; - c.weightx = 1; - c.anchor = GridBagConstraints.LINE_START; - c.insets = ir; - serial_value = new JLabel(""); - pane.add(serial_value, c); - - c = new GridBagConstraints(); - c.fill = GridBagConstraints.NONE; - c.gridx = 0; c.gridy = 1; - c.anchor = GridBagConstraints.LINE_START; - c.insets = il; - flight_label = new JLabel("Flight:"); - pane.add(flight_label, c); - - c = new GridBagConstraints(); - c.fill = GridBagConstraints.HORIZONTAL; - c.weightx = 1; - c.gridx = 1; c.gridy = 1; - c.anchor = GridBagConstraints.LINE_START; - c.insets = ir; - flight_value = new JLabel(""); - pane.add(flight_value, c); - - c = new GridBagConstraints(); - c.fill = GridBagConstraints.NONE; - c.gridx = 0; c.gridy = 2; - c.anchor = GridBagConstraints.LINE_START; - c.insets = il; - file_label = new JLabel("File:"); - pane.add(file_label, c); - - c = new GridBagConstraints(); - c.fill = GridBagConstraints.HORIZONTAL; - c.weightx = 1; - c.gridx = 1; c.gridy = 2; - c.anchor = GridBagConstraints.LINE_START; - c.insets = ir; - file_value = new JLabel(""); - pane.add(file_value, c); - - min_state = in_min_state; - max_state = in_max_state; - pbar = new JProgressBar(); - pbar.setMinimum(0); - pbar.setMaximum(1000); - pbar.setValue(0); - pbar.setString("startup"); - pbar.setStringPainted(true); - pbar.setPreferredSize(new Dimension(600, 20)); - c = new GridBagConstraints(); - c.fill = GridBagConstraints.HORIZONTAL; - c.anchor = GridBagConstraints.CENTER; - c.gridx = 0; c.gridy = 3; - c.gridwidth = GridBagConstraints.REMAINDER; - Insets ib = new Insets(4,4,4,4); - c.insets = ib; - pane.add(pbar, c); - - - cancel = new JButton("Cancel"); - c = new GridBagConstraints(); - c.fill = GridBagConstraints.NONE; - c.anchor = GridBagConstraints.CENTER; - c.gridx = 0; c.gridy = 4; - c.gridwidth = GridBagConstraints.REMAINDER; - Insets ic = new Insets(4,4,4,4); - c.insets = ic; - pane.add(cancel, c); - - pack(); - setLocationRelativeTo(owner); - setVisible(true); - } - - public void addActionListener (ActionListener l) { - cancel.addActionListener(l); - } - - private void set_value_internal(String state_name, int state, int state_block, int block) { - if (state_block > 100) - state_block = 100; - if (state < min_state) state = min_state; - if (state >= max_state) state = max_state - 1; - state -= min_state; - - int pos = state * 100 + state_block; - - pbar.setString(String.format("block %d state %s", block, state_name)); - pbar.setValue(pos); - } - - public void set_value(String in_state_name, int in_state, int in_state_block, int in_block) { - final String state_name = in_state_name; - final int state = in_state; - final int state_block = in_state_block; - final int block = in_block; - Runnable r = new Runnable() { - public void run() { - try { - set_value_internal(state_name, state, state_block, block); - } catch (Exception ex) { - } - } - }; - SwingUtilities.invokeLater(r); - } - - private void set_serial_internal(int serial) { - serial_value.setText(String.format("%d", serial)); - } - - public void set_serial(int in_serial) { - final int serial = in_serial; - Runnable r = new Runnable() { - public void run() { - try { - set_serial_internal(serial); - } catch (Exception ex) { - } - } - }; - SwingUtilities.invokeLater(r); - } - - private void set_flight_internal(int flight) { - flight_value.setText(String.format("%d", flight)); - } - - public void set_flight(int in_flight) { - final int flight = in_flight; - Runnable r = new Runnable() { - public void run() { - try { - set_flight_internal(flight); - } catch (Exception ex) { - } - } - }; - SwingUtilities.invokeLater(r); - } - - private void set_file_internal(String file) { - file_value.setText(String.format("%s", file)); - } - - public void set_file(String in_file) { - final String file = in_file; - Runnable r = new Runnable() { - public void run() { - try { - set_file_internal(file); - } catch (Exception ex) { - } - } - }; - SwingUtilities.invokeLater(r); - } - - private void done_internal() { - setVisible(false); - dispose(); - } - - public void done() { - Runnable r = new Runnable() { - public void run() { - try { - done_internal(); - } catch (Exception ex) { - } - } - }; - SwingUtilities.invokeLater(r); - } - - private void reset_internal() { - set_value_internal("startup",min_state,0, 0); - set_flight_internal(0); - set_file_internal(""); - } - - public void reset() { - Runnable r = new Runnable() { - public void run() { - try { - reset_internal(); - } catch (Exception ex) { - } - } - }; - SwingUtilities.invokeLater(r); - } -} diff --git a/altosuilib/AltosFlightStatsTable.java b/altosuilib/AltosFlightStatsTable.java index beda38bf..70a56110 100644 --- a/altosuilib/AltosFlightStatsTable.java +++ b/altosuilib/AltosFlightStatsTable.java @@ -194,10 +194,12 @@ public class AltosFlightStatsTable extends JComponent implements AltosFontListen if (stats.state_start[AltosLib.ao_flight_boost] < stats.state_start[AltosLib.ao_flight_landed]) new FlightStat(layout, y++, "Flight time", String.format("%6.1f s", stats.landed_time - stats.boost_time)); - if (stats.has_gps) { + if (stats.pad_lat != AltosLib.MISSING) { new FlightStat(layout, y++, "Pad location", pos(stats.pad_lat,"N","S"), pos(stats.pad_lon,"E","W")); + } + if (stats.lat != AltosLib.MISSING) { new FlightStat(layout, y++, "Last reported location", pos(stats.lat,"N","S"), pos(stats.lon,"E","W")); diff --git a/altosuilib/AltosGraph.java b/altosuilib/AltosGraph.java deleted file mode 100644 index 987c461e..00000000 --- a/altosuilib/AltosGraph.java +++ /dev/null @@ -1,427 +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; either version 2 of the License, or - * (at your option) any later version. - * - * 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_11; - -import java.io.*; -import java.util.ArrayList; - -import java.awt.*; -import javax.swing.*; -import org.altusmetrum.altoslib_11.*; - -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 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 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 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; - } -} - -class AltosDopUnits 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 null; - } - - public String say_units(boolean imperial_units) { - return null; - } - - public int show_fraction(int width, boolean imperial_units) { - return 1; - } -} - -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 gps_pdop_color = new Color(50, 194, 0); - static final private Color gps_hdop_color = new Color(50, 0, 194); - static final private Color gps_vdop_color = new Color(194, 0, 50); - 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 AltosNsat nsat_units = new AltosNsat(); - static AltosDbm dbm_units = new AltosDbm(); - static AltosRotationRate gyro_units = new AltosRotationRate(); - static AltosOrient orient_units = new AltosOrient(); - static AltosMagUnits mag_units = new AltosMagUnits(); - static AltosDopUnits dop_units = new AltosDopUnits(); - - 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, dop_axis; - - public AltosGraph(AltosUIEnable enable, AltosFlightStats stats, AltosGraphDataSet dataSet) { - super(enable); - - height_axis = newAxis("Height", AltosConvert.height, height_color); - pressure_axis = newAxis("Pressure", AltosConvert.pressure, pressure_color, 0); - speed_axis = newAxis("Speed", AltosConvert.speed, speed_color); - accel_axis = newAxis("Acceleration", AltosConvert.accel, accel_color); - voltage_axis = newAxis("Voltage", AltosConvert.voltage, 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); - dop_axis = newAxis("Dilution of Precision", dop_units, gps_pdop_color, 0); - - addMarker("State", AltosGraphDataPoint.data_state, state_color); - - if (stats.has_flight_data) { - addSeries("Height", - AltosGraphDataPoint.data_height, - AltosConvert.height, - height_color, - true, - height_axis); - addSeries("Pressure", - AltosGraphDataPoint.data_pressure, - AltosConvert.pressure, - 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) { - boolean enable_gps = false; - - if (!stats.has_flight_data) - enable_gps = true; - - addSeries("Range", - AltosGraphDataPoint.data_range, - AltosConvert.distance, - range_color, - false, - distance_axis); - addSeries("Distance", - AltosGraphDataPoint.data_distance, - AltosConvert.distance, - distance_color, - enable_gps, - distance_axis); - addSeries("GPS Height", - AltosGraphDataPoint.data_gps_height, - AltosConvert.height, - gps_height_color, - enable_gps, - height_axis); - addSeries("GPS Altitude", - AltosGraphDataPoint.data_gps_altitude, - 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); - if (stats.has_gps_sats) { - addSeries("GPS Satellites in View", - AltosGraphDataPoint.data_gps_nsat_view, - nsat_units, - gps_nsat_view_color, - false, - nsat_axis); - } - if (stats.has_gps_detail) { - 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, - enable_gps, - speed_axis); - addSeries("GPS Climb Rate", - AltosGraphDataPoint.data_gps_climb_rate, - AltosConvert.speed, - gps_climb_rate_color, - enable_gps, - speed_axis); - } - addSeries("GPS Position DOP", - AltosGraphDataPoint.data_gps_pdop, - dop_units, - gps_pdop_color, - false, - dop_axis); - if (stats.has_gps_detail) { - addSeries("GPS Horizontal DOP", - AltosGraphDataPoint.data_gps_hdop, - dop_units, - gps_hdop_color, - false, - dop_axis); - addSeries("GPS Vertical DOP", - AltosGraphDataPoint.data_gps_vdop, - dop_units, - gps_vdop_color, - false, - dop_axis); - } - } - if (stats.has_rssi) - addSeries("Received Signal Strength", - AltosGraphDataPoint.data_rssi, - dbm_units, - dbm_color, - false, - dbm_axis); - - if (stats.has_battery) - addSeries("Battery Voltage", - AltosGraphDataPoint.data_battery_voltage, - AltosConvert.voltage, - 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, - AltosConvert.voltage, - drogue_voltage_color, - false, - voltage_axis); - addSeries("Main Voltage", - AltosGraphDataPoint.data_main_voltage, - AltosConvert.voltage, - main_voltage_color, - false, - voltage_axis); - } - - if (stats.has_imu) { - addSeries("Acceleration Along", - AltosGraphDataPoint.data_accel_along, - AltosConvert.accel, - accel_x_color, - false, - accel_axis); - addSeries("Acceleration Across", - AltosGraphDataPoint.data_accel_across, - AltosConvert.accel, - accel_y_color, - false, - accel_axis); - addSeries("Acceleration Through", - AltosGraphDataPoint.data_accel_through, - AltosConvert.accel, - accel_z_color, - false, - accel_axis); - addSeries("Roll Rate", - AltosGraphDataPoint.data_gyro_roll, - gyro_units, - gyro_x_color, - false, - gyro_axis); - addSeries("Pitch Rate", - AltosGraphDataPoint.data_gyro_pitch, - gyro_units, - gyro_y_color, - false, - gyro_axis); - addSeries("Yaw Rate", - AltosGraphDataPoint.data_gyro_yaw, - gyro_units, - gyro_z_color, - false, - gyro_axis); - } - if (stats.has_mag) { - addSeries("Magnetometer Along", - AltosGraphDataPoint.data_mag_along, - mag_units, - mag_x_color, - false, - mag_axis); - addSeries("Magnetometer Across", - AltosGraphDataPoint.data_mag_across, - mag_units, - mag_y_color, - false, - mag_axis); - addSeries("Magnetometer Through", - AltosGraphDataPoint.data_mag_through, - 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, - AltosConvert.voltage, - 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 deleted file mode 100644 index 0012d96a..00000000 --- a/altosuilib/AltosGraphDataPoint.java +++ /dev/null @@ -1,250 +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; either version 2 of the License, or - * (at your option) any later version. - * - * 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_11; - -import org.altusmetrum.altoslib_11.*; - -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_gps_altitude = 12; - public static final int data_temperature = 13; - public static final int data_range = 14; - public static final int data_distance = 15; - public static final int data_pressure = 16; - public static final int data_accel_along = 17; - public static final int data_accel_across = 18; - public static final int data_accel_through = 19; - public static final int data_gyro_roll = 20; - public static final int data_gyro_pitch = 21; - public static final int data_gyro_yaw = 22; - public static final int data_mag_along = 23; - public static final int data_mag_across = 24; - public static final int data_mag_through = 25; - public static final int data_orient = 26; - public static final int data_gps_course = 27; - public static final int data_gps_ground_speed = 28; - public static final int data_gps_climb_rate = 29; - public static final int data_gps_pdop = 30; - public static final int data_gps_hdop = 31; - public static final int data_gps_vdop = 32; - public static final int data_ignitor_0 = 33; - 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) { - if (state.gps.cc_gps_sat != null) - y = state.gps.cc_gps_sat.length; - else - y = 0; - } - break; - case data_gps_altitude: - y = state.gps_altitude(); - 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_along: - y = state.accel_along(); - break; - case data_accel_across: - y = state.accel_across(); - break; - case data_accel_through: - y = state.accel_through(); - break; - case data_gyro_roll: - y = state.gyro_roll(); - break; - case data_gyro_pitch: - y = state.gyro_pitch(); - break; - case data_gyro_yaw: - y = state.gyro_yaw(); - break; - case data_mag_along: - y = state.mag_along(); - break; - case data_mag_across: - y = state.mag_across(); - break; - case data_mag_through: - y = state.mag_through(); - 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; - case data_gps_pdop: - if (state.gps != null) - y = state.gps.pdop; - else - y = AltosLib.MISSING; - break; - case data_gps_hdop: - if (state.gps != null) - y = state.gps.hdop; - else - y = AltosLib.MISSING; - break; - case data_gps_vdop: - if (state.gps != null) - y = state.gps.vdop; - 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 deleted file mode 100644 index 065a7815..00000000 --- a/altosuilib/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; either version 2 of the License, or - * (at your option) any later version. - * - * 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_11; - -import java.lang.*; -import java.io.*; -import java.util.*; -import org.altusmetrum.altoslib_11.*; - -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 deleted file mode 100644 index d3760384..00000000 --- a/altosuilib/AltosUIGraph.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * 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; either version 2 of the License, or - * (at your option) any later version. - * - * 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_11; - -import java.io.*; -import java.util.ArrayList; - -import java.awt.*; -import javax.swing.*; -import org.altusmetrum.altoslib_11.*; - -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.*; - -public class AltosUIGraph implements AltosUnitsListener { - - XYPlot plot; - JFreeChart chart; - public ChartPanel panel; - NumberAxis xAxis; - AltosUIEnable enable; - ArrayList graphers; - AltosUIDataSet dataSet; - int axis_index; - int series_index; - - static final private Color gridline_color = new Color(0, 0, 0); - static final private Color border_color = new Color(255, 255, 255); - static final private Color background_color = new Color(255, 255, 255); - - public JPanel panel() { - return panel; - } - - public AltosUIAxis newAxis(String label, AltosUnits units, Color color, int flags) { - AltosUIAxis axis = new AltosUIAxis(label, units, color, axis_index++, flags); - plot.setRangeAxis(axis.index, axis); - return axis; - } - - public AltosUIAxis newAxis(String label, AltosUnits units, Color color) { - return newAxis(label, units, color, AltosUIAxis.axis_default); - } - - public void addSeries(String label, int fetch, AltosUnits units, Color color, - boolean enabled, AltosUIAxis axis) { - AltosUISeries series = new AltosUISeries(label, fetch, units, color, enabled, axis); - XYSeriesCollection dataset = new XYSeriesCollection(series); - - series.renderer.setPlot(plot); - plot.setDataset(series_index, dataset); - plot.setRenderer(series_index, series.renderer); - plot.mapDatasetToRangeAxis(series_index, axis.index); - if (enable != null) - enable.add(label, series, enabled); - this.graphers.add(series); - series_index++; - } - - 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); - this.graphers.add(marker); - } - - public void resetData() { - for (AltosUIGrapher g : graphers) { - g.clear(); - g.setNotify(false); - } - if (dataSet != null) { - for (AltosUIDataPoint dataPoint : dataSet.dataPoints()) - for (AltosUIGrapher g : graphers) - g.add(dataPoint); - } - for (AltosUIGrapher g : graphers) { - g.setNotify(true); - g.fireSeriesChanged(); - } - } - - public void units_changed(boolean imperial_units) { - for (AltosUIGrapher g : graphers) - g.set_units(); - resetData(); - } - - public void setName (String name) { - chart.setTitle(name); - } - - public void setDataSet (AltosUIDataSet dataSet) { - this.dataSet = dataSet; - resetData(); - if (dataSet != null) - setName(dataSet.name()); - } - - public AltosUIGraph(AltosUIEnable enable) { - - this.enable = enable; - this.graphers = new ArrayList(); - this.series_index = 0; - this.axis_index = 0; - - xAxis = new NumberAxis("Time (s)"); - - xAxis.setAutoRangeIncludesZero(true); - - plot = new XYPlot(); - plot.setDomainAxis(xAxis); - plot.setOrientation(PlotOrientation.VERTICAL); - plot.setDomainPannable(true); - plot.setRangePannable(true); - - chart = new JFreeChart("Flight", JFreeChart.DEFAULT_TITLE_FONT, - plot, true); - - ChartUtilities.applyCurrentTheme(chart); - - plot.setDomainGridlinePaint(gridline_color); - plot.setRangeGridlinePaint(gridline_color); - plot.setBackgroundPaint(background_color); - plot.setBackgroundAlpha((float) 1); - - chart.setBackgroundPaint(background_color); - chart.setBorderPaint(border_color); - panel = new ChartPanel(chart); - panel.setMouseWheelEnabled(true); - panel.setPreferredSize(new java.awt.Dimension(800, 500)); - - AltosPreferences.register_units_listener(this); - } -} diff --git a/altosuilib/AltosUIGraphNew.java b/altosuilib/AltosUIGraphNew.java index b96399ab..b820518d 100644 --- a/altosuilib/AltosUIGraphNew.java +++ b/altosuilib/AltosUIGraphNew.java @@ -101,6 +101,15 @@ public class AltosUIGraphNew implements AltosUnitsListener { public void set_series(AltosUITimeSeries[] series) { this.series = series; + boolean any_enabled = false; + + for (AltosUITimeSeries s : series) + if (s.enable) + any_enabled = true; + + if (!any_enabled) + for (AltosUITimeSeries s : series) + s.set_enable(true); for (AltosUITimeSeries s : series) addSeries(s); diff --git a/altosuilib/AltosUISeries.java b/altosuilib/AltosUISeries.java deleted file mode 100644 index aa598bac..00000000 --- a/altosuilib/AltosUISeries.java +++ /dev/null @@ -1,114 +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; either version 2 of the License, or - * (at your option) any later version. - * - * 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_11; - -import java.io.*; -import java.util.ArrayList; - -import java.awt.*; -import javax.swing.*; -import org.altusmetrum.altoslib_11.*; - -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 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"; } - - public int show_fraction(int width, boolean imperial_units) { - if (width < 5) - return 0; - return width - 5; - } - - public int say_fraction(boolean imperial_units) { return 0; } -} - -public class AltosUISeries extends XYSeries implements AltosUIGrapher { - AltosUIAxis axis; - String label; - AltosUnits units; - Color color; - XYItemRenderer renderer; - int fetch; - boolean enable; - - public void set_units() { - axis.set_units(); - StandardXYToolTipGenerator ttg; - - String time_example = (new AltosUITime()).graph_format(7); - String example = units.graph_format(7); - - ttg = new StandardXYToolTipGenerator(String.format("{1}s: {2}%s ({0})", - units.graph_units()), - new java.text.DecimalFormat(time_example), - new java.text.DecimalFormat(example)); - renderer.setBaseToolTipGenerator(ttg); - } - - public boolean need_reset() { return true; } - - public void set_enable(boolean enable) { - if (this.enable != enable) { - this.enable = enable; - renderer.setSeriesVisible(0, enable); - axis.set_enable(enable); - } - } - - public void add(AltosUIDataPoint dataPoint) { - try { - super.add(dataPoint.x(), units.graph_value(dataPoint.y(fetch))); - } catch (AltosUIDataMissing dm) { - } - } - - public AltosUISeries (String label, int fetch, AltosUnits units, Color color, - boolean enable, AltosUIAxis axis) { - super(label); - this.label = label; - this.fetch = fetch; - this.units = units; - this.color = color; - this.enable = enable; - this.axis = axis; - - axis.ref(this.enable); - - renderer = new XYLineAndShapeRenderer(true, false); - renderer.setSeriesPaint(0, color); - renderer.setSeriesStroke(0, new BasicStroke(2, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); - renderer.setSeriesVisible(0, enable); - set_units(); - } -} diff --git a/altosuilib/AltosUITimeSeries.java b/altosuilib/AltosUITimeSeries.java index 7c48264e..26c5efca 100644 --- a/altosuilib/AltosUITimeSeries.java +++ b/altosuilib/AltosUITimeSeries.java @@ -35,6 +35,24 @@ import org.jfree.chart.labels.*; import org.jfree.data.xy.*; import org.jfree.data.*; +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"; } + + public int show_fraction(int width, boolean imperial_units) { + if (width < 5) + return 0; + return width - 5; + } + + public int say_fraction(boolean imperial_units) { return 0; } +} + class AltosXYSeries extends XYSeries { public AltosXYSeries(String label) { diff --git a/altosuilib/Makefile.am b/altosuilib/Makefile.am index b7cfedc0..6f08fd10 100644 --- a/altosuilib/Makefile.am +++ b/altosuilib/Makefile.am @@ -18,7 +18,6 @@ altosuilib_JAVA = \ AltosUIDataMissing.java \ AltosUIDataPoint.java \ AltosUIDataSet.java \ - AltosUIGraph.java \ AltosUIGrapher.java \ AltosUIDialog.java \ AltosUIEnable.java \ @@ -28,7 +27,6 @@ altosuilib_JAVA = \ AltosUIMarker.java \ AltosUIPreferencesBackend.java \ AltosUIPreferences.java \ - AltosUISeries.java \ AltosUIFlightSeries.java \ AltosUIGraphNew.java \ AltosGraphNew.java \ -- 2.30.2