[chronojump] RaceAnalyzer at load shifted to 1st trigger or accel >= minAccel, whatever comes first. Fixed also 2



commit 0cd1357d23bd875c6377068590a1b523861dffd3
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed May 25 13:12:48 2022 +0200

    RaceAnalyzer at load shifted to 1st trigger or accel >= minAccel, whatever comes first. Fixed also 2 
first samples on shift.

 src/gui/app1/runEncoder.cs | 11 +++++------
 src/runEncoder.cs          | 38 +++++++++++++++++++++++++++++++++++---
 2 files changed, 40 insertions(+), 9 deletions(-)
---
diff --git a/src/gui/app1/runEncoder.cs b/src/gui/app1/runEncoder.cs
index a3c2bcbb5..f61274b17 100644
--- a/src/gui/app1/runEncoder.cs
+++ b/src/gui/app1/runEncoder.cs
@@ -1117,7 +1117,6 @@ public partial class ChronoJumpWindow
                        if(reCGSD.PassLoadedRow (row))
                                reCGSD.Calcule();
 
-                       rowPre = row;
                        speedPre2 = speedPre;
                        timePre2 = timePre;
                        speedPre = reCGSD.RunEncoderCaptureSpeed;
@@ -1172,11 +1171,9 @@ public partial class ChronoJumpWindow
 
                                                reCGSD.SetTimeAtEnoughAccelOrTrigger0 (shiftTo);
 
-                                               //pass previous row and this one
-                                               if(reCGSD.PassLoadedRow (rowPre))
-                                                       reCGSD.Calcule();
-                                               if(reCGSD.PassLoadedRow (row))
-                                                       reCGSD.Calcule();
+                                               if (reCGSD.PassLoadedRow (row))
+                                                       reCGSD.CalculeSpeedAt0Shifted (rowPre, row);
+                                               //LogB.Information(string.Format("after row 
runEncoderCaptureSpeed: {0}", reCGSD.RunEncoderCaptureSpeed));
 
                                                signalShifted = true;
                                        }
@@ -1207,6 +1204,8 @@ public partial class ChronoJumpWindow
                                                        UtilAll.DivideSafe(reCGSD.Time, 1000000),
                                                        accel));
                        }
+
+                       rowPre = row;
                }
 
                if(reCGSD.RunEncoderCaptureSpeedMax > 0)
diff --git a/src/runEncoder.cs b/src/runEncoder.cs
index 4a4ca46c2..4aac55409 100644
--- a/src/runEncoder.cs
+++ b/src/runEncoder.cs
@@ -353,13 +353,45 @@ public class RunEncoderCaptureGetSpeedAndDisplacement
                timeAtEnoughAccelOrTrigger0 = time;
        }
 
+       // when at load signal is shifted, calcule the speed of previous sample and the sample that will be 0
+       public void CalculeSpeedAt0Shifted (string rowPre, string row)
+       {
+               string [] cells = rowPre.Split(new char[] {';'});
+               if(cells.Length != 3)
+                       return;
+
+               if(! Util.IsNumber(cells[0], false) || ! Util.IsNumber(cells[1], false))
+                       return;
+
+               //int encDisplacement = Convert.ToInt32(cells[0]);
+               int tPre = Convert.ToInt32(cells[1]);
+
+               cells = row.Split(new char[] {';'});
+               if(cells.Length != 3)
+                       return;
+
+               if(! Util.IsNumber(cells[0], false) || ! Util.IsNumber(cells[1], false))
+                       return;
+
+               int encDisplacement = Convert.ToInt32(cells[0]);
+               int t = Convert.ToInt32(cells[1]);
+
+               double runEncoderCaptureDistanceAtThisSample = Math.Abs(encDisplacement) * 0.0030321; 
//hardcoded: same as sprintEncoder.R
+               runEncoderCaptureSpeed = UtilAll.DivideSafe(runEncoderCaptureDistanceAtThisSample, (t - 
tPre)) * 1000000;
+               //LogB.Information(string.Format("speed: {0}, runEncoderCaptureDistanceAtThisSample: {1}, 
tPre: {2}, t: {3}",
+               //                      runEncoderCaptureSpeed, runEncoderCaptureDistanceAtThisSample, tPre, 
t));
+
+               if(runEncoderCaptureSpeed > runEncoderCaptureSpeedMax)
+                       runEncoderCaptureSpeedMax = runEncoderCaptureSpeed;
+       }
+
        public bool Calcule ()
        {
                bool hasCalculed = false;
                if(time > timePre)
                {
-                       if(timePre > 0)
-                       {
+//                     if(timePre > 0)
+//                     {
                                double runEncoderCaptureDistanceAtThisSample = Math.Abs(encoderDisplacement) 
* 0.0030321; //hardcoded: same as sprintEncoder.R
                                runEncoderCaptureSpeed = 
UtilAll.DivideSafe(runEncoderCaptureDistanceAtThisSample, (time - timePre)) * 1000000;
                                if(runEncoderCaptureSpeed > runEncoderCaptureSpeedMax)
@@ -373,7 +405,7 @@ public class RunEncoderCaptureGetSpeedAndDisplacement
                                        updateSegmentDistTimeVariable ();
 
                                hasCalculed = true;
-                       }
+//                     }
                        timePre = time;
                }
                return hasCalculed;


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