diff --git a/TBF/BenchControl/Sequences/Statistics.cs b/TBF/BenchControl/Sequences/Statistics.cs index 94aa6f94d..edae1889f 100644 --- a/TBF/BenchControl/Sequences/Statistics.cs +++ b/TBF/BenchControl/Sequences/Statistics.cs @@ -164,31 +164,41 @@ namespace TBF.BenchControl.Sequences /// true when 'fileterdValue' is valid bool ApplyFilter(double value, out double filteredValue) { - filteredValue = value; - - if (FilterSize == 0) return true; /// no filter -> input value is passed to output + if (FilterSize == 0) + { + /// No filter => Pass the input value to the output + filteredValue = value; + return true; + } - /// Shift values in FIFO buffer, put the new value into fifo[0] + /// Shift values in FIFO buffer, calculate the sum double sum = 0; for (int i = FilterSize - 1; i > 0; i--) { - sorted[i] = fifo[i] = fifo[i - 1]; + fifo[i] = fifo[i - 1]; sum += fifo[i]; } - sorted[0] = fifo[0] = value; + /// Insert the current value into FIFO, add it to the sum + fifo[0] = value; sum += value; + + fifoCount++; if (fifoCount < FilterSize) { - return false; + /// FIFO not filled yet => Pass the input value to the output + filteredValue = value; + return false; } else { - if (MedianFilter) + /// FIFO already filled => Apply filter + if (MedianFilter) { + for (int i = 0; i < FilterSize; i++) sorted[i] = fifo[i]; Array.Sort(sorted); #if false filteredValue = sorted[FilterSize / 2]; diff --git a/TBF/Properties/AssemblyInfo.cs b/TBF/Properties/AssemblyInfo.cs index d2c67f2f4..bb94afe54 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.972.0")] -[assembly: AssemblyFileVersion("2.18.972.0")] +[assembly: AssemblyVersion("2.18.975.0")] +[assembly: AssemblyFileVersion("2.18.975.0")]