[chronojump] run double contacts manage more than one track on same chunk of data
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] run double contacts manage more than one track on same chunk of data
- Date: Fri, 13 Apr 2018 22:58:40 +0000 (UTC)
commit d5961680172b31ef916e55d0a87e1ede5ae441bf
Author: Xavier de Blas <xaviblas gmail com>
Date: Sat Apr 14 00:57:19 2018 +0200
run double contacts manage more than one track on same chunk of data
src/execute/event.cs | 1 +
src/execute/run.cs | 18 +++++++++-
src/execute/runObjects.cs | 83 ++++++++++++++++++++++++---------------------
3 files changed, 62 insertions(+), 40 deletions(-)
---
diff --git a/src/execute/event.cs b/src/execute/event.cs
index 590ee6f..5167f9c 100644
--- a/src/execute/event.cs
+++ b/src/execute/event.cs
@@ -235,6 +235,7 @@ public class EventExecute
}
Thread.Sleep (50);
+ //Thread.Sleep (25);
//LogB.Debug(thread.ThreadState.ToString());
return true;
}
diff --git a/src/execute/run.cs b/src/execute/run.cs
index 88095ca..5473e24 100644
--- a/src/execute/run.cs
+++ b/src/execute/run.cs
@@ -447,6 +447,7 @@ public class RunExecute : EventExecute
//LogB.Information("In lastTfCheckTimeEnded()");
TimeSpan span = DateTime.Now - timerLastTf;
if(span.TotalMilliseconds > checkDoubleContactTime * 1.5)
+// if(span.TotalMilliseconds > checkDoubleContactTime * 1.1) //TODO: try different values
{
timerLastTf = DateTime.Now;
LogB.Information("lastTfCheckTimeEnded: success");
@@ -462,7 +463,13 @@ public class RunExecute : EventExecute
//and use static variables where needed
protected override void trackDone()
{
- LogB.Information("In trackDone()");
+ LogB.Information("In trackDone() A");
+
+ runDC.TrackDoneHasToBeCalledAgain = false;
+ if(success)
+ return;
+
+ LogB.Information("In trackDone() B");
//double myTrackTime = 0;
if(runDC.UseDoubleContacts())
{
@@ -521,6 +528,14 @@ public class RunExecute : EventExecute
Math.Round(lastTf/1000.0, 3), Math.Round(trackTime, 3)));
trackDoneRunSpecificStuff();
+
+ /*
+ * searching GetPosOfBiggestTC maybe two different tracks found
+ * so call this method again to process the other
+ */
+ if(! success && runDC.TrackDoneHasToBeCalledAgain)
+ trackDone();
+
}
protected virtual void trackDoneRunSpecificStuff ()
@@ -909,6 +924,7 @@ public class RunIntervalExecute : RunExecute
needUpdateGraphType = eventType.RUNINTERVAL;
needUpdateGraph = true;
+ //fakeButtonUpdateGraph.Click();
//put button_finish as sensitive when first jump is done (there's something recordable)
if(tracks == 1)
diff --git a/src/execute/runObjects.cs b/src/execute/runObjects.cs
index 003a37f..a1d1f10 100644
--- a/src/execute/runObjects.cs
+++ b/src/execute/runObjects.cs
@@ -57,6 +57,7 @@ public class RunPhaseInfo
//manage RunPhaseInfo list
public class RunPhaseInfoManage
{
+ public bool TrackDoneHasToBeCalledAgain;
private List<RunPhaseInfo> list;
//TCs and TFs before startPos have been added as tracks
@@ -67,6 +68,7 @@ public class RunPhaseInfoManage
{
list = new List<RunPhaseInfo>();
startPos = 0;
+ TrackDoneHasToBeCalledAgain = false;
}
/*
@@ -189,32 +191,54 @@ public class RunPhaseInfoManage
}
*/
- public int GetPosOfBiggestTC (bool started)
+ public int GetPosOfBiggestTC (bool started, int checkTime)
{
LogB.Information("startPos at GetPosOfBiggestTC: " + startPos.ToString());
+ TrackDoneHasToBeCalledAgain = false;
//Read below message: "Message oneTCAfterTheTf"
if(countTCs() == 1 && oneTCAfterTheTf())
return startPos +1;
- /*
- * if there's more than one tc, return the pos of bigger tc,
- * but first tc cannot be the biggest,
- * because first tc will be always added (and first tf)
- */
double max = 0;
int pos = 0;
int posBiggest = 0;
+ double lastTcDuration = 0;
+
foreach(RunPhaseInfo rpi in list)
{
- if(rpi.IsContact() && rpi.Duration > max)
+ /*
+ * first time we need to know if first TC is greater than the others
+ * but once started, we care for endings of each track,
+ * do not use the first value because it's the TC of previous track
+ */
+ if( (started && pos >= startPos +1) || (! started && pos >= startPos) )
{
/*
- * first time we need to know if first TC is greater than the others
- * but once started, we care for endings of each track,
- * do not use the first value because it's the TC of previous track
+ * record tc duration as lastTcDuration and add to td duration to see if is
greater than checktime
+ * this allows to return biggest_tc of one track without messing with next
track that maybe is captured
+ * this happens because double contacts is eg: 300 and trackDone is calle at
300 * 1,5
+ * But then trackDone has to be called again!
*/
- if( (started && pos >= startPos +1) || (! started && pos >= startPos) )
+ if(rpi.IsContact())
+ lastTcDuration = rpi.Duration;
+ else if(! rpi.IsContact() && lastTcDuration + rpi.Duration > checkTime)
+ {
+ //check if there's another track in this set
+ for(int i = pos + 2; i < list.Count; i += 2)
+ {
+ RunPhaseInfo tcRPI = (RunPhaseInfo) list[i-1];
+ RunPhaseInfo tfRPI = (RunPhaseInfo) list[i];
+
+ if(tcRPI.Duration + tfRPI.Duration > checkTime)
+ TrackDoneHasToBeCalledAgain = true;
+ }
+
+ return posBiggest;
+ }
+
+ //record posBiggest position
+ if(rpi.IsContact() && rpi.Duration > max)
{
max = rpi.Duration;
posBiggest = pos;
@@ -334,6 +358,7 @@ public class RunDoubleContact
{
public bool SpeedStart; //comes with speed or started in contact with the photocell
public bool FirstTrackDone; //the manage of speedStartArrival has been done
+ public bool TrackDoneHasToBeCalledAgain;
private Constants.DoubleContact mode;
private int checkTime;
@@ -361,6 +386,7 @@ public class RunDoubleContact
rpim = new RunPhaseInfoManage();
listCaptureThread = new List<RunPhaseInfo>();
FirstTrackDone = false;
+ TrackDoneHasToBeCalledAgain = false;
}
//public methods ---------------------------------------
@@ -420,39 +446,18 @@ public class RunDoubleContact
return isDC;
}
- /*
- public int GetStartPosition()
+ public int GetPosOfBiggestTC(bool started)
{
- //count TCs coming from double contacts at start
- int countDC_TCsAtStart = rpim.IsStartDoubleContact(SpeedStart, checkTime);
- //should work for many double contacts at start
- LogB.Information(string.Format("IsStartDoubleContact: {0}", countDC_TCsAtStart));
-// FirstTrackDone = true;
+ int pos = rpim.GetPosOfBiggestTC(started, checkTime);
- if(countDC_TCsAtStart > 0)
+ if(rpim.TrackDoneHasToBeCalledAgain)
{
- LogB.Information(" GetStartPosition A ");
- rpim.UpdateStartPos(countDC_TCsAtStart);
-
- return countDC_TCsAtStart;
+ TrackDoneHasToBeCalledAgain = true;
+ //rpim.TrackDoneHasToBeCalledAgain = false;
}
- else if(! SpeedStart)
- {
- LogB.Information(" GetStartPosition B ");
- return 0;
- }
-
- LogB.Information(" GetStartPosition C ");
- return 0;
- }
- */
-
- public int GetPosOfBiggestTC(bool started)
- {
- //return rpim.GetPosOfBiggestTC();
- int pos = rpim.GetPosOfBiggestTC(started);
- LogB.Information(string.Format("GetPosOfBiggestTC list: {0}, pos: {1}", rpim.PrintList(),
pos));
+ LogB.Information(string.Format("GetPosOfBiggestTC list: {0}, pos: {1}, hasToBeCaledAgain:
{2}",
+ rpim.PrintList(), pos, TrackDoneHasToBeCalledAgain));
return pos;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]