[chronojump] At execute run instead of empty list -> update startPos
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] At execute run instead of empty list -> update startPos
- Date: Tue, 27 Mar 2018 08:19:55 +0000 (UTC)
commit 03d0d04ea260fc4a6b99d4b1a68b2cb088485e16
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Mar 27 10:18:54 2018 +0200
At execute run instead of empty list -> update startPos
.../photocells-double-contact-workflow.dia | Bin 9171 -> 9168 bytes
.../photocells-double-contact-workflow.png | Bin 182157 -> 182431 bytes
src/execute/run.cs | 2 +-
src/execute/runObjects.cs | 63 +++++++++++++-------
4 files changed, 42 insertions(+), 23 deletions(-)
---
diff --git a/diagrams/processes/photocells-double-contact-workflow.dia
b/diagrams/processes/photocells-double-contact-workflow.dia
index dc43d56..f710fad 100644
Binary files a/diagrams/processes/photocells-double-contact-workflow.dia and
b/diagrams/processes/photocells-double-contact-workflow.dia differ
diff --git a/diagrams/processes/photocells-double-contact-workflow.png
b/diagrams/processes/photocells-double-contact-workflow.png
index 18a592e..b545a7e 100644
Binary files a/diagrams/processes/photocells-double-contact-workflow.png and
b/diagrams/processes/photocells-double-contact-workflow.png differ
diff --git a/src/execute/run.cs b/src/execute/run.cs
index ce38782..913e4e9 100644
--- a/src/execute/run.cs
+++ b/src/execute/run.cs
@@ -872,7 +872,7 @@ public class RunIntervalExecute : RunExecute
{
double myTrackTime = 0;
if(runDC.UseDoubleContacts())
- myTrackTime = runDC.GetTrackTimeInSecondsAndEmptyLists(); //will come in seconds
+ myTrackTime = runDC.GetTrackTimeInSecondsAndUpdateStartPos(); //will come in seconds
else {
//note in double contacts mode timestamp can have added DCFlightTimes and
DCContactTimes. So contact time is not only on lastTc
myTrackTime = lastTc + lastTf/1000.0;
diff --git a/src/execute/runObjects.cs b/src/execute/runObjects.cs
index 9919b66..b4e80a0 100644
--- a/src/execute/runObjects.cs
+++ b/src/execute/runObjects.cs
@@ -59,9 +59,14 @@ public class RunPhaseInfoManage
{
private List<RunPhaseInfo> list;
+ //TCs and TFs before startPos have been added as tracks
+ //do not count again in track operations
+ private int startPos;
+
public RunPhaseInfoManage ()
{
list = new List<RunPhaseInfo>();
+ startPos = 0;
}
public void Add (RunPhaseInfo rpi)
@@ -71,6 +76,7 @@ public class RunPhaseInfoManage
public int GetPosOfBiggestTC ()
{
+ LogB.Information("startPos at GetPosOfBiggestTC: " + startPos.ToString());
//if there's no tc, return -1, track duration will be tf duration
//if there's one tc, return -1, track duration will be tc+tf duration
if(countTCs() < 2)
@@ -83,7 +89,8 @@ public class RunPhaseInfoManage
int posBiggest = 0;
foreach(RunPhaseInfo rpi in list)
{
- if(pos > 0 && rpi.IsContact() && rpi.Duration > max) //pos > 0 to not allow first tc
to be the biggest
+ //pos > startPos +1 to not allow first tc to be the biggest
+ if(pos > startPos +1 && rpi.IsContact() && rpi.Duration > max)
{
max = rpi.Duration;
posBiggest = pos;
@@ -97,35 +104,38 @@ public class RunPhaseInfoManage
//if pos == -1 return all
public double SumUntilPos(int pos)
{
+ int countStart = 0;
double sum = 0;
- if(pos == -1) {
+ if(pos == -1)
+ {
foreach(RunPhaseInfo rpi in list)
- sum += rpi.Duration;
+ if(countStart ++ >= startPos)
+ sum += rpi.Duration;
} else {
- int count = 0;
+ int countEnd = 0;
foreach(RunPhaseInfo rpi in list)
- if(count ++ < pos)
+ {
+ if(countStart >= startPos && countEnd < pos)
sum += rpi.Duration;
+
+ countStart ++;
+ countEnd ++;
+ }
}
return sum;
}
-
- //if pos == -1 empty all
- public void EmtpyListUntilPos(int pos)
+
+ public void UpdateStartPos (int bigTCPosition)
{
- if(pos == -1)
- list = new List<RunPhaseInfo>();
- else {
- List<RunPhaseInfo> listNew = new List<RunPhaseInfo>();
- int count = 0;
- foreach(RunPhaseInfo rpi in list)
- if(count ++ >= pos)
- listNew.Add(rpi);
+ //if bigTCPosition == -1 , startPos will be one element more than list
+ //else bigTCPosition is the pos of the tc that cut the track. This tc has to be added on next
track
- list = listNew;
- }
+ if(bigTCPosition == -1)
+ startPos = list.Count;
+ else
+ startPos = bigTCPosition;
}
public string PrintList()
@@ -139,9 +149,10 @@ public class RunPhaseInfoManage
private int countTCs()
{
+ int countStart = 0;
int count = 0;
foreach(RunPhaseInfo rpi in list)
- if(rpi.IsContact())
+ if(countStart ++ >= startPos && rpi.IsContact())
count ++;
return count;
@@ -150,6 +161,11 @@ public class RunPhaseInfoManage
public int LastPositionOfList {
get { return list.Count -1; }
}
+
+ //to debug
+ public int StartPos {
+ get { return startPos; }
+ }
}
//manage double contacts in runs
@@ -202,7 +218,7 @@ public class RunDoubleContact
}
//this wait will be done by C#
- public double GetTrackTimeInSecondsAndEmptyLists()
+ public double GetTrackTimeInSecondsAndUpdateStartPos()
{
double trackTime = 0;
/*
@@ -230,8 +246,10 @@ public class RunDoubleContact
int bigTCPosition = rpim.GetPosOfBiggestTC();
double sum = rpim.SumUntilPos(bigTCPosition);
- LogB.Information(string.Format("\n----------------\ngetDCBiggestTC, list: {0}, bigTCPosition:
{1}, sum: {2}", rpim.PrintList(), bigTCPosition, sum));
+ LogB.Information(string.Format("\n----------------\ngetDCBiggestTC, list: {0}, startPos: {1},
bigTCPosition: {2}, sum: {3}",
+ rpim.PrintList(), rpim.StartPos, bigTCPosition, sum));
+ //fix problem of a tc + tf lower than checkTime
if(sum < checkTime)
{
while (sum < checkTime && bigTCPosition +2 <= rpim.LastPositionOfList)
@@ -242,7 +260,8 @@ public class RunDoubleContact
}
}
- rpim.EmtpyListUntilPos(bigTCPosition);
+ //rpim.EmptyListUntilPos(bigTCPosition);
+ rpim.UpdateStartPos(bigTCPosition);
return sum;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]