[chronojump] Race analyzer capture show line, message when >= minAccel



commit 30230b806838f16d9bee8efd2b60132e51904bd3
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue May 24 16:43:46 2022 +0200

    Race analyzer capture show line,message when >= minAccel

 src/gui/app1/runEncoder.cs    | 39 +++++++++++++++++++++++++++++++--------
 src/gui/cairo/raceAnalyzer.cs | 25 ++++++++++++++++++++-----
 src/runEncoder.cs             | 16 ++++++++++++++--
 3 files changed, 65 insertions(+), 15 deletions(-)
---
diff --git a/src/gui/app1/runEncoder.cs b/src/gui/app1/runEncoder.cs
index facd0351e..ce907bb71 100644
--- a/src/gui/app1/runEncoder.cs
+++ b/src/gui/app1/runEncoder.cs
@@ -704,6 +704,7 @@ public partial class ChronoJumpWindow
                double timePre2 = -1;
                double speedPre = -1;
                double timePre = -1;
+               bool enoughAccel = false; //accel has been > preferences.runEncoderMinAccel (default 10ms^2)
 
                int rowsCount = 0;
                while(! runEncoderProcessFinish && ! runEncoderProcessCancel && ! runEncoderProcessError)
@@ -755,15 +756,22 @@ public partial class ChronoJumpWindow
 
                                if(timePre2 > 0)
                                {
-                                       LogB.Information(string.Format("accel at capture is: {0} m/s",
-                                                               
UtilAll.DivideSafe(reCGSD.RunEncoderCaptureSpeed - speedPre2,
-                                                                       UtilAll.DivideSafe(reCGSD.Time, 
1000000) - timePre2)));
+                                       double accel = UtilAll.DivideSafe(reCGSD.RunEncoderCaptureSpeed - 
speedPre2,
+                                                               UtilAll.DivideSafe(reCGSD.Time, 1000000) - 
timePre2);
+
+                                       if (accel >= preferences.runEncoderMinAccel && ! enoughAccel)
+                                       {
+                                               enoughAccel = true;
+
+                                               //at load to shift times to the left
+                                               //at capture to draw a vertical line
+                                               reCGSD.SetTimeAtEnoughAccelMark (binaryReaded);
+                                       }
 
                                        //accel/time
                                        cairoGraphRaceAnalyzerPoints_at_l.Add(new PointF(
                                                                UtilAll.DivideSafe(reCGSD.Time, 1000000),
-                                                               
UtilAll.DivideSafe(reCGSD.RunEncoderCaptureSpeed - speedPre2,
-                                                                       UtilAll.DivideSafe(reCGSD.Time, 
1000000) - timePre2)));
+                                                               accel));
                                }
 
                                sw.Restart();
@@ -2312,6 +2320,10 @@ public partial class ChronoJumpWindow
                                reCGSD != null && reCGSD.SegmentCalcs != null)
                        segmentCalcs = reCGSD.SegmentCalcs;
 
+               int timeAtEnoughAccelMark = 0;
+               if (reCGSD != null)
+                       timeAtEnoughAccelMark = reCGSD.TimeAtEnoughAccelMark;
+
                if(cairoGraphRaceAnalyzer_dt == null || forceRedraw)
                        cairoGraphRaceAnalyzer_dt = new CairoGraphRaceAnalyzer(
                                        drawingarea_race_analyzer_capture_position_time, "title",
@@ -2324,7 +2336,8 @@ public partial class ChronoJumpWindow
                cairoGraphRaceAnalyzer_dt.DoSendingList (preferences.fontType.ToString(),
                                cairoGraphRaceAnalyzerPoints_dt_l, triggerListRunEncoder,
                                forceRedraw, CairoXY.PlotTypes.LINES, true,
-                               getSmoothFrom_gui_at_race_analyzer_capture_smooth_graphs ());
+                               getSmoothFrom_gui_at_race_analyzer_capture_smooth_graphs (),
+                               timeAtEnoughAccelMark, preferences.runEncoderMinAccel);
        }
        private void updateRaceAnalyzerCaptureSpeedTime(bool forceRedraw)
        {
@@ -2337,6 +2350,10 @@ public partial class ChronoJumpWindow
                                reCGSD != null && reCGSD.SegmentCalcs != null)
                        segmentCalcs = reCGSD.SegmentCalcs;
 
+               int timeAtEnoughAccelMark = 0;
+               if (reCGSD != null)
+                       timeAtEnoughAccelMark = reCGSD.TimeAtEnoughAccelMark;
+
                if(cairoGraphRaceAnalyzer_st == null || forceRedraw)
                        cairoGraphRaceAnalyzer_st = new CairoGraphRaceAnalyzer(
                                        drawingarea_race_analyzer_capture_speed_time, "title",
@@ -2349,7 +2366,8 @@ public partial class ChronoJumpWindow
                cairoGraphRaceAnalyzer_st.DoSendingList (preferences.fontType.ToString(),
                                cairoGraphRaceAnalyzerPoints_st_l, triggerListRunEncoder,
                                forceRedraw, CairoXY.PlotTypes.LINES, true,
-                               getSmoothFrom_gui_at_race_analyzer_capture_smooth_graphs ());
+                               getSmoothFrom_gui_at_race_analyzer_capture_smooth_graphs (),
+                               timeAtEnoughAccelMark, preferences.runEncoderMinAccel);
        }
        private void updateRaceAnalyzerCaptureAccelTime(bool forceRedraw)
        {
@@ -2365,6 +2383,10 @@ public partial class ChronoJumpWindow
                                reCGSD != null && reCGSD.SegmentCalcs != null)
                        segmentCalcs = reCGSD.SegmentCalcs;
 
+               int timeAtEnoughAccelMark = 0;
+               if (reCGSD != null)
+                       timeAtEnoughAccelMark = reCGSD.TimeAtEnoughAccelMark;
+
                if(cairoGraphRaceAnalyzer_at == null || forceRedraw)
                        cairoGraphRaceAnalyzer_at = new CairoGraphRaceAnalyzer(
                                        drawingarea_race_analyzer_capture_accel_time, "title",
@@ -2377,7 +2399,8 @@ public partial class ChronoJumpWindow
                cairoGraphRaceAnalyzer_at.DoSendingList (preferences.fontType.ToString(),
                                cairoGraphRaceAnalyzerPoints_at_l, triggerListRunEncoder,
                                forceRedraw, CairoXY.PlotTypes.LINES, false,
-                               getSmoothFrom_gui_at_race_analyzer_capture_smooth_graphs ());
+                               getSmoothFrom_gui_at_race_analyzer_capture_smooth_graphs (),
+                               timeAtEnoughAccelMark, preferences.runEncoderMinAccel);
        }
 
        private void on_check_race_analyzer_capture_smooth_graphs_clicked (object o, EventArgs args)
diff --git a/src/gui/cairo/raceAnalyzer.cs b/src/gui/cairo/raceAnalyzer.cs
index 11bc8c710..d7a34253b 100644
--- a/src/gui/cairo/raceAnalyzer.cs
+++ b/src/gui/cairo/raceAnalyzer.cs
@@ -82,14 +82,18 @@ public class CairoGraphRaceAnalyzer : CairoXY
        }
 
        //separated in two methods to ensure endGraphDisposing on any return of the other method
-       public void DoSendingList (string font, List<PointF> points_list, TriggerList triggerList, bool 
forceRedraw, PlotTypes plotType, bool blackLine, int smoothLineWindow)
+       public void DoSendingList (string font, List<PointF> points_list, TriggerList triggerList, bool 
forceRedraw,
+                       PlotTypes plotType, bool blackLine, int smoothLineWindow,
+                       int timeAtEnoughAccelMark, double minAccel)
        {
-               if(doSendingList (font, points_list, triggerList, forceRedraw, plotType, blackLine, 
smoothLineWindow))
+               if(doSendingList (font, points_list, triggerList, forceRedraw, plotType, blackLine, 
smoothLineWindow, timeAtEnoughAccelMark, minAccel))
                        endGraphDisposing(g, surface, area.GdkWindow);
        }
 
        //return true if graph is inited (to dispose it)
-       private bool doSendingList (string font, List<PointF> points_list, TriggerList triggerList, bool 
forceRedraw, PlotTypes plotType, bool blackLine, int smoothLineWindow)
+       private bool doSendingList (string font, List<PointF> points_list, TriggerList triggerList, bool 
forceRedraw,
+                       PlotTypes plotType, bool blackLine, int smoothLineWindow,
+                       int timeAtEnoughAccelMark, double minAccel) //timeAtEnoughAccelMark: only for capture 
(just to display mark), minAccel is the value at preferences
        {
                // 1) init graph
 
@@ -253,7 +257,7 @@ public class CairoGraphRaceAnalyzer : CairoXY
                        paintAxis();
                }
 
-               // 3) paint points, paint smooth line, paint maximum mark
+               // 3) paint points, paint smooth line, paint maximum mark, paint timeAtEnoughAccelMark on 
capture
                pointsRadius = 1;
                if( graphInited && points_list != null &&
                                (maxValuesChanged || forceRedraw || points_list.Count != points_list_painted) 
)
@@ -314,9 +318,20 @@ public class CairoGraphRaceAnalyzer : CairoXY
                                        g.Stroke();
                                }
                        }
+
+                       if (timeAtEnoughAccelMark > 0)
+                       {
+                               double xTimeAtEnoughAccelMark = calculatePaintX 
(timeAtEnoughAccelMark/1000000.0);
+                               g.SetSourceColor(red);
+                               g.MoveTo (xTimeAtEnoughAccelMark, topMargin);
+                               g.LineTo (xTimeAtEnoughAccelMark, graphHeight - bottomMargin);
+                               g.Stroke ();
+                               printText(xTimeAtEnoughAccelMark, graphHeight -bottomMargin*3/4,
+                                               0, textHeight-3, string.Format("a >= {0} m/s^2", minAccel), 
g, alignTypes.LEFT);
+                       }
                }
 
-               // 4) paint triggers
+               // 5) paint triggers
                if(graphInited && triggerList != null && triggerList.Count() > 0)
                        foreach(Trigger trigger in triggerList.GetList())
                                paintVerticalTriggerLine(g, trigger, textHeight -3);
diff --git a/src/runEncoder.cs b/src/runEncoder.cs
index 7aaaf7196..db55a0352 100644
--- a/src/runEncoder.cs
+++ b/src/runEncoder.cs
@@ -290,7 +290,8 @@ public class RunEncoderCaptureGetSpeedAndDisplacement
        private int encoderOrRCA;
 
        private int timePre;
-       private int timeAtEnoughAccel;
+       private int timeAtEnoughAccel; //load (discard previous and shift time)
+       private int timeAtEnoughAccelMark; //capture (just draw a vertical line, to not erase previous points 
while capture)
 
        private double runEncoderCaptureSpeed;
        private double runEncoderCaptureSpeedMax;
@@ -305,6 +306,7 @@ public class RunEncoderCaptureGetSpeedAndDisplacement
                segmentCalcs = new RunEncoderSegmentCalcs (massKg, angle);
                timePre = 0;
                timeAtEnoughAccel = 0;
+               timeAtEnoughAccelMark = 0;
        }
 
        public void PassCapturedRow (List<int> binaryReaded)
@@ -334,7 +336,13 @@ public class RunEncoderCaptureGetSpeedAndDisplacement
                return true;
        }
 
-       //to sync time
+       //to show a vertical line at capture capture (meaning: passed the min accel)
+       public void SetTimeAtEnoughAccelMark (List<int> binaryReaded)
+       {
+               timeAtEnoughAccelMark = binaryReaded[1];
+       }
+
+       //to sync time at load
        public void SetTimeAtEnoughAccel (string row)
        {
                string [] cells = row.Split(new char[] {';'});
@@ -418,6 +426,10 @@ public class RunEncoderCaptureGetSpeedAndDisplacement
        public RunEncoderSegmentCalcs SegmentCalcs {
                get { return segmentCalcs; }
        }
+
+       public int TimeAtEnoughAccelMark {
+               get { return timeAtEnoughAccelMark; }
+       }
 }
 
 /*


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]