diff --git a/TBF/BenchControl/TestMethods/iPerlCommunication/iPerlHead/FlowDirectionDetection.cs b/TBF/BenchControl/TestMethods/iPerlCommunication/iPerlHead/FlowDirectionDetection.cs index 4cf86494a..9b6d3c9a6 100644 --- a/TBF/BenchControl/TestMethods/iPerlCommunication/iPerlHead/FlowDirectionDetection.cs +++ b/TBF/BenchControl/TestMethods/iPerlCommunication/iPerlHead/FlowDirectionDetection.cs @@ -8,14 +8,16 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead { public class FlowDirectionDetection { - readonly int fifoSize; + const int FIFO_SIZE = 64; /// 8 sec. @ 8Hz + const double MAX_OPTO_DROPOUT = 4.5; /// sec. - Int64[] volumeRawFifo; /// Volume FIFO buffer - Int64[] timestampFifo; /// Timestamp FIFO buffer - int fifoCount; /// Number of valid FIFO items - int fifoIx; /// Index of the next FIFO item - DateTime lastFifoWriteTime; /// Time of the last write to FIFO + Int64[] volumeRawFifo; /// Volume FIFO buffer + Int64[] timestampFifo; /// Timestamp FIFO buffer + + int fifoCount; /// Number of valid FIFO items + int fifoIx; /// Index of the next FIFO item + DateTime lastFifoWriteTime; /// Time of the last write to FIFO /// /// Sums for linear regression calculation @@ -26,11 +28,10 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead decimal sumY; decimal N; - public FlowDirectionDetection(int fifoSize) + public FlowDirectionDetection() { - this.fifoSize = fifoSize; - volumeRawFifo = new Int64[fifoSize]; - timestampFifo = new Int64[fifoSize]; + volumeRawFifo = new Int64[FIFO_SIZE]; + timestampFifo = new Int64[FIFO_SIZE]; ClearFifo(); } @@ -62,7 +63,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead /// /// Update sums for linear regression calculation /// - if (fifoCount == fifoSize) + if (fifoCount == FIFO_SIZE) { /// Buffer is already full, the oldest item will be re-written sumXX -= timestampFifo[fifoIx] * timestampFifo[fifoIx]; @@ -82,8 +83,8 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead /// volumeRawFifo[fifoIx] = volumeRaw; timestampFifo[fifoIx] = timestamp; - fifoIx = (fifoIx + 1) % fifoSize; - fifoCount = Math.Min(fifoCount + 1, fifoSize); + fifoIx = (fifoIx + 1) % FIFO_SIZE; + fifoCount = Math.Min(fifoCount + 1, FIFO_SIZE); lastFifoWriteTime = DateTime.Now; } @@ -94,7 +95,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead /// true when data valid public bool AreFifoDataValid() { - return (DateTime.Now.Subtract(lastFifoWriteTime).TotalSeconds <= 2.5) && (fifoCount == fifoSize); + return (DateTime.Now.Subtract(lastFifoWriteTime).TotalSeconds <= MAX_OPTO_DROPOUT) && (fifoCount == FIFO_SIZE); } diff --git a/TBF/BenchControl/TestMethods/iPerlCommunication/iPerlHead/IperlHead.cs b/TBF/BenchControl/TestMethods/iPerlCommunication/iPerlHead/IperlHead.cs index 4f19171a4..09ac02022 100644 --- a/TBF/BenchControl/TestMethods/iPerlCommunication/iPerlHead/IperlHead.cs +++ b/TBF/BenchControl/TestMethods/iPerlCommunication/iPerlHead/IperlHead.cs @@ -24,8 +24,6 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead private static readonly ILog log = LogManager.GetLogger(typeof(IperlHead)); public override string ToString() { return string.Format("iPerl({0})", Cfg.ToString(1)); } - const int FifoSize = 32; /// 4s @ 8Hz - readonly IperlHeadCfg iperlHeadCfg; public int RfidComPortNr { get { return iperlHeadCfg.RfidComPortNr; } } @@ -354,7 +352,6 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead /// /// Timestamp from the opto telegram /// - bool lastTimestampValid; private Int64 lastTimestamp; private double timestampSec; private double timestampSec0; @@ -393,7 +390,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead public IperlHead(Generic.IComponentCfg cfg) : base(cfg) { - flowDirectionDetection = new FlowDirectionDetection(FifoSize); + flowDirectionDetection = new FlowDirectionDetection(); ClearData(); diff --git a/TBF/Properties/AssemblyInfo.cs b/TBF/Properties/AssemblyInfo.cs index 32ac37b22..198552a01 100644 --- a/TBF/Properties/AssemblyInfo.cs +++ b/TBF/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("2.18.1085.0")] -[assembly: AssemblyFileVersion("2.18.1085.0")] +[assembly: AssemblyVersion("2.18.1086.0")] +[assembly: AssemblyFileVersion("2.18.1086.0")]