altosui: Allow for multiple instances of each state in the graph
authorKeith Packard <keithp@keithp.com>
Sat, 8 Oct 2011 17:46:38 +0000 (11:46 -0600)
committerKeith Packard <keithp@keithp.com>
Sat, 8 Oct 2011 17:46:38 +0000 (11:46 -0600)
With the new boost re-detect code, we can get multiple instances of
boost/fast/coast, so make sure each are displayed in the graph.

Signed-off-by: Keith Packard <keithp@keithp.com>
altosui/AltosGraphTime.java
altosui/AltosGraphUI.java

index ada6ef131ae3d3ea777cb3c36e7922eb58844b6b..6a084b2ceab2c7d2fd3f02770b4896a09a0b5842 100644 (file)
@@ -4,6 +4,11 @@
 
 package altosui;
 
+import java.lang.*;
+import java.io.*;
+import java.util.concurrent.*;
+import java.util.*;
+import java.text.*;
 import java.awt.Color;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -98,9 +103,10 @@ class AltosGraphTime extends AltosGraph {
     }
 
     static class StateMarker implements Element {
-        private double val = Double.NaN;
+       private LinkedList<Double> times = new LinkedList<Double>();
         private String name;
         private int state;
+       private int prev_state = Altos.ao_flight_startup;
 
         StateMarker(int state, String name) {
             this.state = state;
@@ -109,22 +115,19 @@ class AltosGraphTime extends AltosGraph {
 
         public void attachGraph(AltosGraphTime g) { return; }
         public void gotTimeData(double time, AltosDataPoint d) {
-            if (Double.isNaN(val) || time < val) {
-                if (d.state() == state) {
-                    val = time;
-                }
-            }
+           if (prev_state != state && d.state() == state)
+               times.add(time);
+           prev_state = d.state();
         }
 
         public void addToPlot(AltosGraphTime g, XYPlot plot) {
-            if (Double.isNaN(val))
-                return;
-
-            ValueMarker m = new ValueMarker(val);
-            m.setLabel(name);
-            m.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
-            m.setLabelTextAnchor(TextAnchor.TOP_LEFT);
-            plot.addDomainMarker(m);
+           for (double time : times) {
+               ValueMarker m = new ValueMarker(time);
+               m.setLabel(name);
+               m.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
+               m.setLabelTextAnchor(TextAnchor.TOP_LEFT);
+               plot.addDomainMarker(m);
+           }
         }
     }
 
index be52bd4e97d14eb3426dee6d10ff64edd780f40c..030bbc25d4dd25f54c114caaa98124979f14b8fc 100644 (file)
@@ -109,6 +109,8 @@ public class AltosGraphUI extends JFrame
         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);
@@ -238,8 +240,8 @@ public class AltosGraphUI extends JFrame
     {
         ArrayList<AltosGraph> graph = new ArrayList<AltosGraph>();
         graph.addAll((new OverallGraphs()).graphs());
-        graph.addAll((new AscentGraphs()).graphs());
-        graph.addAll((new DescentGraphs()).graphs());
+//        graph.addAll((new AscentGraphs()).graphs());
+//        graph.addAll((new DescentGraphs()).graphs());
 
         if (which > 0) {
             if (which >= graph.size()) {