iPerlHead : FLow filtering by FIRFilterFlow() corrected, ver. 2.18.1109
This commit is contained in:
@@ -2,17 +2,12 @@
|
||||
/// Copyright (c) 2015-2018 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Ports;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using log4net;
|
||||
using Config.Entities;
|
||||
using TBF.BenchControl;
|
||||
using TBF.BenchControl.Generic;
|
||||
using TBF.BenchControl.Output;
|
||||
using TBF.Resources;
|
||||
|
||||
namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
{
|
||||
@@ -25,9 +20,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
public override string ToString() { return string.Format("iPerl({0})", Cfg.ToString(1)); }
|
||||
|
||||
|
||||
const int MaxOptoDataCount = 40000;
|
||||
const int StartOptoDataCount = MaxOptoDataCount / 2;
|
||||
const int EndOptoDataCount = MaxOptoDataCount - StartOptoDataCount;
|
||||
public const int MaxOptoDataCount = 40000;
|
||||
public const int StartOptoDataCount = MaxOptoDataCount / 2;
|
||||
public const int EndOptoDataCount = MaxOptoDataCount - StartOptoDataCount;
|
||||
|
||||
|
||||
readonly IperlHeadCfg iperlHeadCfg;
|
||||
@@ -631,17 +626,21 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
OptoTelegramRaw.TestStartTimestampDec = optoData[TestStartTelegramIx].TimestampDec();
|
||||
}
|
||||
|
||||
if ((TestEndTelegramIx > 0) && (TestEndTelegramIx < MaxOptoDataCount) && (optoData[TestEndTelegramIx].Flags == OptoTelegramFlags.OK))
|
||||
if (optoData[OptoTelegramRaw.BufferIdx(TestEndTelegramIx)].Flags == OptoTelegramFlags.OK)
|
||||
{
|
||||
optoData[TestEndTelegramIx].Flags = OptoTelegramFlags.OK_TestEnd;
|
||||
}
|
||||
else if ((TestEndTelegramIx >= MaxOptoDataCount) && optoData[(TestEndTelegramIx - MaxOptoDataCount) % EndOptoDataCount + StartOptoDataCount].Flags == OptoTelegramFlags.OK)
|
||||
{
|
||||
optoData[(TestEndTelegramIx - MaxOptoDataCount) % EndOptoDataCount + StartOptoDataCount].Flags = OptoTelegramFlags.OK_TestEnd;
|
||||
optoData[OptoTelegramRaw.BufferIdx(TestEndTelegramIx)].Flags = OptoTelegramFlags.OK_TestEnd;
|
||||
}
|
||||
|
||||
StopParsingOptoSerialPort();
|
||||
OptoTelegramRaw.FIRFilterFlow(optoData, Math.Min(optoDataCount, MaxOptoDataCount));
|
||||
if (optoDataCount <= MaxOptoDataCount)
|
||||
{
|
||||
OptoTelegramRaw.FIRFilterFlow(optoData, 0, optoDataCount - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
OptoTelegramRaw.FIRFilterFlow(optoData, 0, StartOptoDataCount - 1);
|
||||
OptoTelegramRaw.FIRFilterFlow(optoData, (optoDataCount - EndOptoDataCount), optoDataCount - 1);
|
||||
}
|
||||
SaveOptoData();
|
||||
|
||||
if (TestStartTelegramIx == 0 || optoDataCount < 100)
|
||||
@@ -698,11 +697,11 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
optoLogFile.WriteLine(" ...");
|
||||
|
||||
/// Second part of the buffer is an overflowed circular buffer
|
||||
optoLogFile.WriteLine(optoData[(optoDataCount - MaxOptoDataCount) % EndOptoDataCount + StartOptoDataCount].ToString(scalFact, null));
|
||||
optoLogFile.WriteLine(optoData[OptoTelegramRaw.BufferIdx(optoDataCount)].ToString(scalFact, null));
|
||||
for (int i = optoDataCount - EndOptoDataCount + 1; i < optoDataCount; i++)
|
||||
{
|
||||
optoLogFile.WriteLine(optoData[(i - StartOptoDataCount) % EndOptoDataCount + StartOptoDataCount]
|
||||
.ToString(scalFact, optoData[(i - 1 - StartOptoDataCount) % EndOptoDataCount + StartOptoDataCount]));
|
||||
optoLogFile.WriteLine(optoData[OptoTelegramRaw.BufferIdx(i)]
|
||||
.ToString(scalFact, optoData[OptoTelegramRaw.BufferIdx(i - 1)]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -791,7 +790,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
/// CR+LF found
|
||||
if (optoState == OptoState.Read)
|
||||
{
|
||||
int bufferIx = (optoDataCount < MaxOptoDataCount) ? optoDataCount : ((optoDataCount - MaxOptoDataCount) % EndOptoDataCount + StartOptoDataCount);
|
||||
int bufferIx = OptoTelegramRaw.BufferIdx(optoDataCount);
|
||||
|
||||
if (pos < OptoTelegramRaw.Length - 2)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user