- 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 private class OverallGraphs {
- AltosGraphTime.Element height =
- new AltosGraphTime.TimeSeries("Height (m)", "Height (AGL)", red) {
- public void gotTimeData(double time, AltosDataPoint d) {
- series.add(time, d.height());
- }
- };
-
- AltosGraphTime.Element speed =
- new AltosGraphTime.TimeSeries("Speed (m/s)", "Vertical Speed", green) {
- public void gotTimeData(double time, AltosDataPoint d) {
- if (d.state() < Altos.ao_flight_drogue) {
- series.add(time, d.accel_speed());
- } else {
- series.add(time, d.baro_speed());
- }
- }
- };
-
- AltosGraphTime.Element acceleration =
- new AltosGraphTime.TimeSeries("Acceleration (m/s\u00B2)",
- "Axial Acceleration", blue)
- {
- public void gotTimeData(double time, AltosDataPoint d) {
- series.add(time, d.acceleration());
- }
- };
-
- AltosGraphTime.Element temperature =
- new AltosGraphTime.TimeSeries("Temperature (\u00B0C)",
- "Board temperature", red)
- {
- public void gotTimeData(double time, AltosDataPoint d) {
- series.add(time, d.temperature());
- }
- };
-
- AltosGraphTime.Element drogue_voltage =
- new AltosGraphTime.TimeSeries("Voltage (V)", "Drogue Continuity", blue)
- {
- public void gotTimeData(double time, AltosDataPoint d) {
- series.add(time, d.drogue_voltage());
- }
- };
-
- AltosGraphTime.Element main_voltage =
- new AltosGraphTime.TimeSeries("Voltage (V)", "Main Continuity", green)
- {
- public void gotTimeData(double time, AltosDataPoint d) {
- series.add(time, d.main_voltage());
- }
- };
-
- 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_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("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) {
- super("Altos Graph");
-
- Iterable<AltosDataPoint> reader = new AltosDataPointReader (records);
- if (reader == null)
- return;
-
- init(reader, 0);
+ 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);
+ }