[chronojump] runInterval: Fixed double contacts graph of "speedStart start at first in"



commit b0f1c33141b50f3cd18594c4e6a8d9a40c668d66
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Apr 6 17:08:50 2018 +0200

    runInterval: Fixed double contacts graph of "speedStart start at first in"

 src/execute/event.cs      |    4 ++--
 src/execute/runObjects.cs |   26 ++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 2 deletions(-)
---
diff --git a/src/execute/event.cs b/src/execute/event.cs
index 96a9bd1..590ee6f 100644
--- a/src/execute/event.cs
+++ b/src/execute/event.cs
@@ -605,9 +605,9 @@ public class PhaseTime
 
        public override string ToString()
        {
-               string strMode = "IN";
+               string strMode = "IN (TC)";
                if(! contactIn)
-                       strMode = "OUT";
+                       strMode = "OUT (TF)";
 
                //TODO: use a printf mode to have always same digits
                return "\n" + Math.Round(Util.DivideSafe(duration, 1000.0), 3) + " - " + strMode;
diff --git a/src/execute/runObjects.cs b/src/execute/runObjects.cs
index 9871275..01aa892 100644
--- a/src/execute/runObjects.cs
+++ b/src/execute/runObjects.cs
@@ -366,16 +366,42 @@ public class RunPhaseTimeList
                int currentMS = 0;
                int startInMS = -1;
 
+               // 1) create a copy of listPhaseTime in order to do foreach without problems with other 
thread that adds records
                //This is problematic (Collection was modified; enumeration operation may not execute) if 
other thread is changing it:
                //foreach(PhaseTime pt in listPhaseTime)
                //solution:
                List<PhaseTime> listPhaseTimeShallowCloned = new List<PhaseTime>(listPhaseTime);
+
+               /*
+                * 2) check if we started in because 1st TC has to be counted in the track
+                * but 2nd TC has to be the end of the first track
+                * we need this to synchronize correctly
+                */
+               bool startedIn = false;
+               if(listPhaseTimeShallowCloned.Count >= 1)
+               {
+                       PhaseTime ptFirst = (PhaseTime) listPhaseTimeShallowCloned[0];
+                       if(ptFirst.IsContact)
+                               startedIn = true;
+               }
+
+               // 3) add elements to the list
+               LogB.Information("InListForPainting foreach:");
+               bool firstTrack = true;
                foreach(PhaseTime pt in listPhaseTimeShallowCloned)
                {
+                       LogB.Information(pt.ToString());
                        if(pt.IsContact)
                                startInMS = currentMS;
                        else if(startInMS >= 0)
+                       {
                                list_in.Add(startInMS/1000.0 + ":" + currentMS/1000.0); //in seconds
+                               if(startedIn && firstTrack)
+                               {
+                                       currentMS = 0; //reset currentMS in order to synchronize correctly
+                                       firstTrack = false;
+                               }
+                       }
 
                        currentMS += Convert.ToInt32(pt.Duration);
                }


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