- JTabbedPane pane;
-
- static final private Color red = new Color(194,31,31);
- static final private Color green = new Color(31,194,31);
- static final private Color blue = new Color(31,31,194);
- //static final private Color black = new Color(31,31,31);
- static final private Color yellow = new Color(194,194,31);
- //static final private Color cyan = new Color(31,194,194);
- static final private Color magenta = new Color(194,31,194);
-
- static private class OverallGraphs {
- AltosGraphTime.Element height =
- new AltosGraphTime.TimeSeries(String.format("Height (%s)", AltosConvert.height.show_units()), "Height (AGL)", red) {
- public void gotTimeData(double time, AltosDataPoint d) {
- double height = d.height();
- if (height != AltosRecord.MISSING)
- series.add(time, AltosConvert.height.value(height));
- }
- };
-
- AltosGraphTime.Element speed =
- new AltosGraphTime.TimeSeries(String.format("Speed (%s)", AltosConvert.speed.show_units()), "Vertical Speed", green) {
- public void gotTimeData(double time, AltosDataPoint d) {
- double speed;
- if (d.state() < Altos.ao_flight_drogue && d.has_accel()) {
- speed = d.accel_speed();
- } else {
- speed = d.baro_speed();
- }
- if (speed != AltosRecord.MISSING)
- series.add(time, AltosConvert.speed.value(speed));
- }
- };
-
- AltosGraphTime.Element acceleration =
- new AltosGraphTime.TimeSeries(String.format("Acceleration (%s)",
- AltosConvert.accel.show_units()),
- "Axial Acceleration", blue)
- {
- public void gotTimeData(double time, AltosDataPoint d) {
- double acceleration = d.acceleration();
- if (acceleration != AltosRecord.MISSING)
- series.add(time, AltosConvert.accel.value(acceleration));
- }
- };
-
- AltosGraphTime.Element temperature =
- new AltosGraphTime.TimeSeries("Temperature (\u00B0C)",
- "Board temperature", red)
- {
- public void gotTimeData(double time, AltosDataPoint d) {
- double temp = d.temperature();
- if (temp != AltosRecord.MISSING)
- series.add(time, d.temperature());
- }
- };
-
- AltosGraphTime.Element drogue_voltage =
- new AltosGraphTime.TimeSeries("Voltage (V)", "Drogue Continuity", yellow)
- {
- public void gotTimeData(double time, AltosDataPoint d) {
- double v = d.drogue_voltage();
- if (v != AltosRecord.MISSING)
- series.add(time, v);
- }
- };
-
- AltosGraphTime.Element main_voltage =
- new AltosGraphTime.TimeSeries("Voltage (V)", "Main Continuity", magenta)
- {
- public void gotTimeData(double time, AltosDataPoint d) {
- double v = d.main_voltage();
- if (v != AltosRecord.MISSING)
- series.add(time, v);
- }
- };
-
- //AltosGraphTime.Element e_pad = new AltosGraphTime.StateMarker(Altos.ao_flight_pad, "Pad");
- AltosGraphTime.Element e_boost = new AltosGraphTime.StateMarker(Altos.ao_flight_boost, "Boost");
- AltosGraphTime.Element e_fast = new AltosGraphTime.StateMarker(Altos.ao_flight_fast, "Fast");
- AltosGraphTime.Element e_coast = new AltosGraphTime.StateMarker(Altos.ao_flight_coast, "Coast");
- AltosGraphTime.Element e_drogue = new AltosGraphTime.StateMarker(Altos.ao_flight_drogue, "Drogue");
- AltosGraphTime.Element e_main = new AltosGraphTime.StateMarker(Altos.ao_flight_main, "Main");
- AltosGraphTime.Element e_landed = new AltosGraphTime.StateMarker(Altos.ao_flight_landed, "Landed");
-
- protected AltosGraphTime myAltosGraphTime(String suffix) {
- return (new AltosGraphTime("Overall " + suffix))
- .addElement(e_boost)
- .addElement(e_fast)
- .addElement(e_coast)
- .addElement(e_drogue)
- .addElement(e_main)
- .addElement(e_landed);
- }
-
- public ArrayList<AltosGraph> graphs() {
- ArrayList<AltosGraph> graphs = new ArrayList<AltosGraph>();
-
- graphs.add( myAltosGraphTime("Summary")
- .addElement(height)
- .addElement(speed)
- .addElement(acceleration) );
-
- graphs.add( myAltosGraphTime("Summary")
- .addElement(height)
- .addElement(speed));
-
- graphs.add( myAltosGraphTime("Altitude")
- .addElement(height) );
-
- graphs.add( myAltosGraphTime("Speed")
- .addElement(speed) );
-
- graphs.add( myAltosGraphTime("Acceleration")
- .addElement(acceleration) );
-
- graphs.add( myAltosGraphTime("Temperature")
- .addElement(temperature) );
-
- graphs.add( myAltosGraphTime("Continuity")
- .addElement(drogue_voltage)
- .addElement(main_voltage) );
-
- return graphs;
- }
- }
-
- /*
- static private class AscentGraphs extends OverallGraphs {
- protected AltosGraphTime myAltosGraphTime(String suffix) {
- return (new AltosGraphTime("Ascent " + suffix) {
- public void addData(AltosDataPoint d) {
- int state = d.state();
- if (Altos.ao_flight_boost <= state && state <= Altos.ao_flight_coast) {
- super.addData(d);
- }
- }
- }).addElement(e_boost)
- .addElement(e_fast)
- .addElement(e_coast);
- }
- }
- */
-
- /*
- static private class DescentGraphs extends OverallGraphs {
- protected AltosGraphTime myAltosGraphTime(String suffix) {
- return (new AltosGraphTime("Descent " + suffix) {
- public void addData(AltosDataPoint d) {
- int state = d.state();
- if (Altos.ao_flight_drogue <= state && state <= Altos.ao_flight_main) {
- super.addData(d);
- }
- }
- }).addElement(e_drogue)
- .addElement(e_main);
- // ((XYGraph)graph[8]).ymin = new Double(-50);
- }
- }
- */
-
- public AltosGraphUI(AltosRecordIterable records, String name) throws InterruptedException, IOException {
- super(String.format("Altos Graph %s", name));
-
- AltosDataPointReader reader = new AltosDataPointReader (records);
- if (reader == null)
- return;
-
- if (reader.has_accel)
- init(reader, records, 0);
- else
- init(reader, records, 1);
+ JTabbedPane pane;
+ AltosGraph graph;
+ AltosUIEnable enable;
+ AltosUIMap map;
+ AltosFlightStats stats;
+ AltosFlightStatsTable statsTable;
+ AltosGPS gps;
+ boolean has_gps;
+
+ void fill_map(AltosFlightSeries flight_series) {
+ boolean any_gps = false;
+ AltosGPSTimeValue gtv_last = null;
+ double gps_pad_altitude = flight_series.cal_data().gps_pad_altitude;;
+
+ if (flight_series.gps_series != null) {
+ for (AltosGPSTimeValue gtv : flight_series.gps_series) {
+ AltosGPS gps = gtv.gps;
+ if (gps != null &&
+ gps.locked &&
+ gps.nsat >= 4) {
+ if (map == null)
+ map = new AltosUIMap();
+ double gps_height = gps.alt - gps_pad_altitude;
+ int state = (int) flight_series.value_before(AltosFlightSeries.state_name, gtv.time);
+ map.show(gps, gtv.time, state, gps_height);
+ this.gps = gps;
+ gtv_last = gtv;
+ has_gps = true;
+ }
+ }
+ }
+ if (gtv_last != null) {
+ int state = (int) flight_series.value_after(AltosFlightSeries.state_name, gtv_last.time);
+ double gps_height = gps.alt - gps_pad_altitude;
+ if (state == AltosLib.ao_flight_landed)
+ map.show(gtv_last.gps, gtv_last.time, state,gps_height);
+ }