[chronojump] Photocells show which photocell made the contact on RunExecuteInspector



commit 2be39a7af5bb57438ee441b67f74876d6a4e2cc2
Author: Xavier de Blas <xaviblas gmail com>
Date:   Sun Aug 22 12:35:59 2021 +0200

    Photocells show which photocell made the contact on RunExecuteInspector

 src/execute/event.cs      |  8 +++++++-
 src/execute/run.cs        | 20 +++++++++++---------
 src/execute/runObjects.cs |  9 +++++----
 3 files changed, 23 insertions(+), 14 deletions(-)
---
diff --git a/src/execute/event.cs b/src/execute/event.cs
index 53fda7ba9..3ed08053d 100644
--- a/src/execute/event.cs
+++ b/src/execute/event.cs
@@ -657,14 +657,17 @@ public class PhaseTime
        }
 }
 
+//currently only used for photocells
 public class InOut
 {
+       private int photocell; // -1 on regular photocells (all the same)
        private bool contactIn;
        private DateTime dt;
        private string message;
 
-       public InOut (bool contactIn, DateTime dt, string message)
+       public InOut (int photocell, bool contactIn, DateTime dt, string message)
        {
+               this.photocell = photocell;
                this.contactIn = contactIn;
                this.dt = dt;
                this.message = message;
@@ -673,6 +676,9 @@ public class InOut
        public override string ToString()
        {
                string str = "\n- ";
+               if(photocell >= 0)
+                       str += string.Format("[{0}] ", photocell);
+
                if(contactIn)
                        str += "IN / ";
                else
diff --git a/src/execute/run.cs b/src/execute/run.cs
index 64165c5c4..69f07a8da 100644
--- a/src/execute/run.cs
+++ b/src/execute/run.cs
@@ -284,6 +284,7 @@ public class RunExecute : EventExecute
                success = false;
                timerCount = 0;
                lastTc = 0;
+               int photocell = -1; //-1 is valid for not inalambric and for start capture on inalambrics
                //firstTrackDone = false;
 
                double timestamp = 0;
@@ -303,7 +304,7 @@ public class RunExecute : EventExecute
                                checkDoubleContactMode,
                                checkDoubleContactTime
                                );
-               runEI.ChangePhase(RunExecuteInspector.Phases.START);
+               runEI.ChangePhase(photocell, RunExecuteInspector.Phases.START);
 
                //initialize runDC
                runDC = new RunDoubleContact(
@@ -344,7 +345,7 @@ LogB.Information("going to call photocellWirelessCapture.CaptureStart ()");
                                        LogB.Information("waitEvent 3");
                                        PhotocellWirelessEvent pwe = 
photocellWirelessCapture.PhotocellWirelessCaptureReadNext();
                                        LogB.Information("wait_event pwe: " + pwe.ToString());
-                                       //TODO: photocell = pwe.photocell;
+                                       photocell = pwe.photocell;
                                        timestamp = pwe.timeMs - timestampAccumulated; //photocell does not 
send splittime, sends absolute time
                                        timestampAccumulated += timestamp;
 
@@ -395,11 +396,11 @@ LogB.Information("going to call photocellWirelessCapture.CaptureStart ()");
                                                        //run starts
                                                        LogB.Information("\ninitializeTimer at has_arrived");
                                                        initializeTimer(); //timerCount = 0
-                                                       runEI.ChangePhase(RunExecuteInspector.Phases.IN,
+                                                       runEI.ChangePhase(photocell, 
RunExecuteInspector.Phases.IN,
                                                                "TimerStart");
                                                } else {
                                                        runPhase = runPhases.PLATFORM_INI_NO_TIME;
-                                                       runEI.ChangePhase(RunExecuteInspector.Phases.IN,
+                                                       runEI.ChangePhase(photocell, 
RunExecuteInspector.Phases.IN,
                                                                "No timer start until leave plaform");
                                                }
 
@@ -430,7 +431,7 @@ LogB.Information("going to call photocellWirelessCapture.CaptureStart ()");
                                                        needCallTrackDone = true;
                                                }
 
-                                               runEI.ChangePhase(RunExecuteInspector.Phases.IN,
+                                               runEI.ChangePhase(photocell, RunExecuteInspector.Phases.IN,
                                                                string.Format("Arrived (preparing track) 
timestamp: {0}", Math.Round(timestamp, 3)));
 
                                                runPTL.AddTF(timestamp);
@@ -460,7 +461,7 @@ LogB.Information("going to call photocellWirelessCapture.CaptureStart ()");
                                                //run starts
                                                LogB.Information("\ninitializeTimer at has_lifted");
                                                initializeTimer(); //timerCount = 0
-                                               runEI.ChangePhase(RunExecuteInspector.Phases.OUT, "Timer 
start");
+                                               runEI.ChangePhase(photocell, RunExecuteInspector.Phases.OUT, 
"Timer start");
 
                                                /*
                                                 * Stored the TC because we need it to decide
@@ -482,7 +483,7 @@ LogB.Information("going to call photocellWirelessCapture.CaptureStart ()");
                                                if(speedStartArrival)
                                                {
                                                        lastTc = timestamp / 1000.0;
-                                                       runEI.ChangePhase(RunExecuteInspector.Phases.OUT,
+                                                       runEI.ChangePhase(photocell, 
RunExecuteInspector.Phases.OUT,
                                                                string.Format("SpeedStartArrival, tc = {0}", 
Math.Round(lastTc, 3)));
                                                        runDC.DoneTC(timestamp, true);
                                                        runPTL.AddTC(timestamp);
@@ -491,7 +492,7 @@ LogB.Information("going to call photocellWirelessCapture.CaptureStart ()");
                                                feedbackMessage = "";
                                                needShowFeedbackMessage = true; 
                                        } else {
-                                               runEI.ChangePhase(RunExecuteInspector.Phases.OUT,
+                                               runEI.ChangePhase(photocell, RunExecuteInspector.Phases.OUT,
                                                                string.Format("SpeedStartArrival, timestamp = 
{0}", timestamp));
 
                                                if(runDC.UseDoubleContacts())
@@ -692,7 +693,8 @@ LogB.Information("going to call photocellWirelessCapture.CaptureStart ()");
                if(trackTime == 0)
                        return false; //helps to fix display of a contact time bigger than double contact 
time * 1.5
 
-               runEI.ChangePhase(RunExecuteInspector.Phases.IN,
+               //maybe this -1 on wireless should be an static variable: lastPhotocell, that can replace the 
photocell used on waitEvent 
+               runEI.ChangePhase(-1, RunExecuteInspector.Phases.IN,
                                string.Format("; timestamp: {0}; <b>trackTime: {1}</b>",
                                        Math.Round(lastTf/1000.0, 3), Math.Round(trackTime, 3)));
 
diff --git a/src/execute/runObjects.cs b/src/execute/runObjects.cs
index 66bab9473..60b6d5e4a 100644
--- a/src/execute/runObjects.cs
+++ b/src/execute/runObjects.cs
@@ -766,11 +766,12 @@ public class RunExecuteInspector
 
        //public methods
 
-       public void ChangePhase(Phases phase)
+       //photocell = -1 for not inalambric photocells
+       public void ChangePhase(int photocell, Phases phase)
        {
-               ChangePhase(phase, "");
+               ChangePhase(photocell, phase, "");
        }
-       public void ChangePhase(Phases phase, string message)
+       public void ChangePhase(int photocell, Phases phase, string message)
        {
                DateTime dt = DateTime.Now;
 
@@ -780,7 +781,7 @@ public class RunExecuteInspector
                        dtEnded = dt;
                else // (phase == Phases.IN || phases == Phases.OUT)
                {
-                       InOut inOut = new InOut(phase == Phases.IN, dt, message);
+                       InOut inOut = new InOut(photocell, phase == Phases.IN, dt, message);
                        listInOut.Add(inOut);
                        //listInOut.Add(new InOut(phase == Phases.IN, dt, message));
                }


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