JFileChooser csv_chooser;
JPanel accessory;
JComboBox<String> combo_box;
- Iterable<AltosState> states;
+ AltosFlightSeries series;
+ AltosCalData cal_data;
AltosWriter writer;
static String[] combo_box_items = { "Comma Separated Values (.CSV)", "Googleearth Data (.KML)" };
set_default_file();
}
- public AltosCSVUI(JFrame frame, AltosStateIterable states, File source_file) {
- this.states = states;
+ public AltosCSVUI(JFrame frame, AltosFlightSeries series, AltosCalData cal_data, File source_file) {
+ this.series = series;
+ this.cal_data = cal_data;
csv_chooser = new JFileChooser(source_file);
accessory = new JPanel();
writer = new AltosCSV(file);
else
writer = new AltosKML(file);
- writer.write(states);
+ writer.write(series);
writer.close();
} catch (FileNotFoundException ee) {
JOptionPane.showMessageDialog(frame,
return file;
}
- public AltosStateIterable runDialog() {
+ public AltosRecordSet runDialog() {
int ret;
ret = showOpenDialog(frame);
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 fps", AltosConvert.mps_to_fps(stats.max_speed)),
- String.format("Mach %4.1f", AltosConvert.meters_to_mach(stats.max_speed)));
+ if (stats.max_speed != AltosLib.MISSING) {
+ new FlightStat(layout, y++, "Maximum speed",
+ String.format("%5.0f m/s", stats.max_speed),
+ String.format("%5.0f fps", AltosConvert.mps_to_fps(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),
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 AltosRotationRate gyro_units = new AltosRotationRate();
super(enable);
height_axis = newAxis("Height", AltosConvert.height, height_color);
- pressure_axis = newAxis("Pressure", pressure_units, pressure_color, 0);
+ 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", voltage_units, voltage_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);
height_axis);
addSeries("Pressure",
AltosGraphDataPoint.data_pressure,
- pressure_units,
+ AltosConvert.pressure,
pressure_color,
false,
pressure_axis);
if (stats.has_battery)
addSeries("Battery Voltage",
AltosGraphDataPoint.data_battery_voltage,
- voltage_units,
+ AltosConvert.voltage,
battery_voltage_color,
false,
voltage_axis);
temperature_axis);
addSeries("Drogue Voltage",
AltosGraphDataPoint.data_drogue_voltage,
- voltage_units,
+ AltosConvert.voltage,
drogue_voltage_color,
false,
voltage_axis);
addSeries("Main Voltage",
AltosGraphDataPoint.data_main_voltage,
- voltage_units,
+ AltosConvert.voltage,
main_voltage_color,
false,
voltage_axis);
for (int i = 0; i < stats.num_ignitor; i++)
addSeries(AltosLib.ignitor_name(i),
AltosGraphDataPoint.data_ignitor_0 + i,
- voltage_units,
+ AltosConvert.voltage,
main_voltage_color,
false,
voltage_axis);
public class AltosGraphNew extends AltosUIGraphNew {
static final private Color height_color = new Color(194,31,31);
+ static final private Color kalman_height_color = new Color(255,0,0);
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 kalman_speed_color = new Color(0,255,0);
static final private Color thrust_color = new Color(31,194,31);
static final private Color accel_color = new Color(31,31,194);
+ static final private Color kalman_accel_color = new Color(0,0,255);
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 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_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 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 AltosNsat nsat_units = new AltosNsat();
+ static AltosUnits nsat_units = null;
+// static AltosDbm dbm_units = new AltosDbm();
+ static AltosUnits dbm_units = null;
static AltosOrient orient_units = new AltosOrient();
- static AltosMagUnits mag_units = new AltosMagUnits();
- static AltosDopUnits dop_units = new AltosDopUnits();
+// static AltosMagUnits mag_units = new AltosMagUnits();
+ static AltosUnits mag_units = null;
+// static AltosDopUnits dop_units = new AltosDopUnits();
+ static AltosUnits dop_units = null;
AltosUIFlightSeries flight_series;
- AltosUITimeSeries[] setup(AltosFlightStats stats, AltosRecordSet record_set) {
+ AltosUITimeSeries[] setup(AltosFlightStats stats, AltosUIFlightSeries flight_series, AltosCalData cal_data) {
AltosUIAxis height_axis, speed_axis, accel_axis, voltage_axis, temperature_axis, nsat_axis, dbm_axis;
AltosUIAxis distance_axis, pressure_axis, thrust_axis;
course_axis = newAxis("Course", orient_units, gps_course_color, 0);
dop_axis = newAxis("Dilution of Precision", dop_units, gps_pdop_color, 0);
- flight_series = new AltosUIFlightSeries();
+ flight_series.register_axis("default",
+ speed_color,
+ false,
+ speed_axis);
- flight_series.register_extra("default",
- speed_color,
- false,
- speed_axis);
+ flight_series.register_marker(AltosUIFlightSeries.state_name,
+ state_color,
+ true,
+ plot);
- flight_series.register_extra(AltosUIFlightSeries.accel_name,
- accel_color,
- true,
- accel_axis);
+ flight_series.register_axis(AltosUIFlightSeries.accel_name,
+ accel_color,
+ true,
+ accel_axis);
- flight_series.register_extra(AltosUIFlightSeries.pressure_name,
- pressure_color,
- true,
- pressure_axis);
+ flight_series.register_axis(AltosUIFlightSeries.kalman_accel_name,
+ kalman_accel_color,
+ false,
+ accel_axis);
- flight_series.register_extra(AltosUIFlightSeries.thrust_name,
- thrust_color,
- true,
- thrust_axis);
+ flight_series.register_axis(AltosUIFlightSeries.rssi_name,
+ dbm_color,
+ false,
+ dbm_axis);
+
+ flight_series.register_axis(AltosUIFlightSeries.speed_name,
+ speed_color,
+ true,
+ speed_axis);
+
+ flight_series.register_axis(AltosUIFlightSeries.kalman_speed_name,
+ kalman_speed_color,
+ true,
+ speed_axis);
+
+ flight_series.register_axis(AltosUIFlightSeries.pressure_name,
+ pressure_color,
+ false,
+ pressure_axis);
+
+ flight_series.register_axis(AltosUIFlightSeries.height_name,
+ height_color,
+ true,
+ height_axis);
+
+ flight_series.register_axis(AltosUIFlightSeries.kalman_height_name,
+ kalman_height_color,
+ false,
+ height_axis);
+
+
+ flight_series.register_axis(AltosUIFlightSeries.sats_in_view_name,
+ gps_nsat_view_color,
+ false,
+ nsat_axis);
+
+
+ flight_series.register_axis(AltosUIFlightSeries.sats_in_soln_name,
+ gps_nsat_solution_color,
+ false,
+ nsat_axis);
-// addMarker("State", AltosGraphDataPoint.data_state, state_color);
- record_set.capture_series(flight_series);
+ flight_series.register_axis(AltosUIFlightSeries.gps_altitude_name,
+ gps_height_color,
+ false,
+ height_axis);
+
+ flight_series.register_axis(AltosUIFlightSeries.gps_height_name,
+ gps_height_color,
+ false,
+ height_axis);
+
+ flight_series.register_axis(AltosUIFlightSeries.gps_ground_speed_name,
+ gps_ground_speed_color,
+ false,
+ speed_axis);
+
+
+ flight_series.register_axis(AltosUIFlightSeries.gps_ascent_rate_name,
+ gps_climb_rate_color,
+ false,
+ speed_axis);
+
+
+ flight_series.register_axis(AltosUIFlightSeries.gps_course_name,
+ gps_course_color,
+ false,
+ course_axis);
+
+ flight_series.register_axis(AltosUIFlightSeries.gps_speed_name,
+ gps_speed_color,
+ false,
+ speed_axis);
+
+ flight_series.register_axis(AltosUIFlightSeries.thrust_name,
+ thrust_color,
+ true,
+ thrust_axis);
+
+// addMarker("State", AltosGraphDataPoint.data_state, state_color);
- return flight_series.series();
+ return flight_series.series(cal_data);
/*
if (stats.has_flight_data) {
addSeries("Height",
*/
}
- public AltosGraphNew(AltosUIEnable enable, AltosFlightStats stats, AltosRecordSet record_set) {
+ public AltosGraphNew(AltosUIEnable enable, AltosFlightStats stats, AltosUIFlightSeries flight_series, AltosCalData cal_data) {
super(enable, "Flight");
- set_series(setup(stats, record_set));
+ set_series(setup(stats, flight_series, cal_data));
}
}
public void show(AltosState state, AltosListenerState listener_state) {
+ AltosCalData cal_data = state.cal_data;
+
if (!isShowing()) {
last_state = state;
last_listener_state = listener_state;
reset();
if (state != null) {
- if (state.device_type != AltosLib.MISSING)
- info_add_row(0, "Device", "%s", AltosLib.product_name(state.device_type));
- else if (state.product != null)
- info_add_row(0, "Device", "%s", state.product);
+ if (cal_data.device_type != AltosLib.MISSING)
+ info_add_row(0, "Device", "%s", AltosLib.product_name(cal_data.device_type));
+ else if (cal_data.product != null)
+ info_add_row(0, "Device", "%s", cal_data.product);
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 (cal_data.ground_altitude != AltosLib.MISSING)
+ info_add_row(0, "Pad altitude", "%6.0f m", cal_data.ground_altitude);
if (state.height() != AltosLib.MISSING)
info_add_row(0, "Height", "%6.0f m", state.height());
if (state.max_height() != AltosLib.MISSING)
if (state == null)
continue;
packet_count++;
- if (state.flight != AltosLib.MISSING) {
- final AltosScanResult result = new AltosScanResult(state.callsign,
- state.serial,
- state.flight,
+ if (reader.cal_data.flight != AltosLib.MISSING) {
+ final AltosScanResult result = new AltosScanResult(reader.cal_data.callsign,
+ reader.cal_data.serial,
+ reader.cal_data.flight,
frequencies[frequency_index],
telemetry,
rate);
public final static int axis_default = axis_include_zero;
public void set_units() {
- String u = units.parse_units();
- if (u != null)
- setLabel(String.format("%s (%s)", label, u));
- else
- setLabel(label);
+ if (units != null) {
+ String u = units.parse_units();
+ if (u != null) {
+ setLabel(String.format("%s (%s)", label, u));
+ return;
+ }
+ }
+ setLabel(label);
}
public void set_enable(boolean enable) {
+ System.out.printf("axis %s set enable visible %d ref %d\n", label, visible, ref);
if (enable) {
visible++;
if (visible > ref)
import javax.swing.*;
import org.altusmetrum.altoslib_11.*;
-class AltosUITimeSeriesExtra {
+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 AltosUITimeSeriesAxis {
Color color;
boolean enabled;
+ boolean marker;
AltosUIAxis axis;
+ XYPlot plot;
- public AltosUITimeSeriesExtra(Color color, boolean enabled, AltosUIAxis axis) {
+ public AltosUITimeSeriesAxis(Color color, boolean enabled, AltosUIAxis axis, XYPlot plot, boolean marker) {
this.color = color;
this.enabled = enabled;
this.axis = axis;
+ this.plot = plot;
+ this.marker = marker;
}
}
public class AltosUIFlightSeries extends AltosFlightSeries {
- Hashtable<String,AltosUITimeSeriesExtra> extra;
+ Hashtable<String,AltosUITimeSeriesAxis> axes;
+
+ AltosUIFlightSeries flight_series;
+
+ void fill_axes(String label, AltosUITimeSeriesAxis axis) {
+ for (AltosTimeSeries ts : series) {
+ AltosUITimeSeries uts = (AltosUITimeSeries) ts;
+
+ if (label.equals(ts.label) || (label.equals("default") && uts.color == null)) {
+ if (axis.marker)
+ uts.set_marker(axis.color, axis.enabled, axis.plot);
+ else
+ uts.set_axis(axis.color, axis.enabled, axis.axis);
+ }
+ }
+ }
- public void register_extra(String label,
- Color color,
- boolean enabled,
- AltosUIAxis axis) {
+ public void register_axis(String label,
+ Color color,
+ boolean enabled,
+ AltosUIAxis axis) {
+ AltosUITimeSeriesAxis tsa = new AltosUITimeSeriesAxis(color,
+ enabled,
+ axis,
+ null,
+ false);
+ axes.put(label, tsa);
+ fill_axes(label, tsa);
+ }
- AltosUITimeSeriesExtra e = new AltosUITimeSeriesExtra(color,
+ public void register_marker(String label,
+ Color color,
+ boolean enabled,
+ XYPlot plot) {
+ AltosUITimeSeriesAxis tsa = new AltosUITimeSeriesAxis(color,
enabled,
- axis);
- System.out.printf("register extra label %s extra %s\n", label, e);
- extra.put(label, e);
+ null,
+ plot,
+ true);
+ axes.put(label, tsa);
+ fill_axes(label, tsa);
}
public AltosTimeSeries make_series(String label, AltosUnits units) {
- AltosUITimeSeriesExtra e = extra.get(label);
- if (e == null)
- e = extra.get("default");
- return new AltosUITimeSeries(label, units,
- e.color, e.enabled, e.axis);
+ AltosUITimeSeries time_series = new AltosUITimeSeries(label, units);
+
+ AltosUITimeSeriesAxis tsa = axes.get(label);
+ if (tsa == null)
+ tsa = axes.get("default");
+ if (tsa != null) {
+ if (tsa.marker)
+ time_series.set_marker(tsa.color, tsa.enabled, tsa.plot);
+ else
+ time_series.set_axis(tsa.color, tsa.enabled, tsa.axis);
+ }
+ return time_series;
}
- public AltosUITimeSeries[] series() {
+ public AltosUITimeSeries[] series(AltosCalData cal_data) {
+ fill_in();
return series.toArray(new AltosUITimeSeries[0]);
}
- public AltosUIFlightSeries () {
- super();
- extra = new Hashtable<String,AltosUITimeSeriesExtra>();
+ public AltosUIFlightSeries (AltosCalData cal_data) {
+ super(cal_data);
+ axes = new Hashtable<String,AltosUITimeSeriesAxis>();
}
}
void addAxis(AltosUIAxis axis) {
if (!axes_added.containsKey(axis.index)) {
- System.out.printf("Add axis %s %d\n", axis.label, axis_index);
axes_added.put(axis.index, true);
plot.setRangeAxis(axis.index, axis);
}
series_index++;
}
-/*
- public void addMarker(String label, int fetch, Color color) {
- AltosUIMarker marker = new AltosUIMarker(fetch, color, plot);
- this.graphers.add(marker);
+ public void addMarker(AltosUITimeSeries series) {
}
-*/
public void units_changed(boolean imperial_units) {
for (AltosUITimeSeries s : series)
map.show(state, listener_state);
}
+ public void show(AltosGPS gps, int state) {
+ map.show(gps, state);
+ }
+
public String getName() {
return "Map";
}
map.centre(state);
}
+ public void centre(AltosGPS gps) {
+ map.centre(gps);
+ }
+
/* internal layout bits */
private GridBagLayout layout = new GridBagLayout();
Color color;
boolean enable;
AltosUIAxis axis;
+ boolean marker;
XYItemRenderer renderer;
+ XYPlot plot;
AltosXYSeries xy_series;
+ ArrayList<ValueMarker> markers;
+
/* AltosUIGrapher interface */
public boolean need_reset() {
}
void set_data() {
- xy_series.clear();
-
- for (AltosTimeValue v : this) {
- double y = v.y;
- if (units != null)
- y = units.graph_value(y);
- xy_series.add(v.x, y);
+ if (marker) {
+ if (markers != null) {
+ for (ValueMarker marker : markers)
+ plot.removeDomainMarker(marker);
+ }
+ markers = new ArrayList<ValueMarker>();
+ for (AltosTimeValue v : this) {
+ String s = units.string_value(v.value);
+ ValueMarker marker = new ValueMarker(v.time);
+ marker.setLabel(s);
+ marker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
+ marker.setLabelTextAnchor(TextAnchor.TOP_LEFT);
+ marker.setPaint(color);
+ if (enable)
+ plot.addDomainMarker(marker);
+ markers.add(marker);
+ }
+ } else {
+ xy_series.clear();
+
+ for (AltosTimeValue v : this) {
+ double value = v.value;
+ if (units != null)
+ value = units.graph_value(value);
+ xy_series.add(v.time, value);
+ }
}
}
public void set_enable(boolean enable) {
if (this.enable != enable) {
this.enable = enable;
- renderer.setSeriesVisible(0, enable);
- axis.set_enable(enable);
+ if (marker) {
+ for (ValueMarker marker : markers) {
+ if (enable)
+ plot.addDomainMarker(marker);
+ else
+ plot.removeDomainMarker(marker);
+ }
+ } else {
+ renderer.setSeriesVisible(0, enable);
+ axis.set_enable(enable);
+ }
}
}
- public AltosUITimeSeries(String label, AltosUnits units,
- Color color, boolean enable,
- AltosUIAxis axis) {
- super(label, units);
- System.out.printf("time series %s units %s\n", label, units);
+ public void set_axis(Color color, boolean enable, AltosUIAxis axis) {
this.color = color;
this.enable = enable;
this.axis = axis;
+ this.marker = false;
axis.ref(this.enable);
renderer.setSeriesVisible(0, enable);
xy_series = new AltosXYSeries(label);
}
+
+ public void set_marker(Color color, boolean enable, XYPlot plot) {
+ this.color = color;
+ this.enable = enable;
+ this.marker = true;
+ this.plot = plot;
+ }
+
+ public AltosUITimeSeries(String label, AltosUnits units) {
+ super(label, units);
+ }
+
+ public AltosUITimeSeries(String label, AltosUnits units,
+ Color color, boolean enable,
+ AltosUIAxis axis) {
+ this(label, units);
+ set_axis(color, enable, axis);
+ }
}
AltosInfoTable.java \
AltosFlightInfoTableModel.java \
AltosFlightStatsTable.java \
- AltosGraph.java \
- AltosGraphDataPoint.java \
- AltosGraphDataSet.java \
AltosBTDevice.java \
AltosBTDeviceIterator.java \
AltosBTManage.java \