From bd9c3aa5e25e7f25c797299456766c2cdf9c210e Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Fri, 9 Nov 2018 15:56:22 +0100 Subject: [PATCH] Q2 correction for Suez (RL, LR) modified, 'Q2 correction check Q2bc Q2ac' test method implemented. --- .../iPerlCommunicationForm.cs | 16 +- .../iPerlCommunicationParams.cs | 1 + .../iPerlCommunicationSeq.cs | 167 +++++++++++++++++- 3 files changed, 177 insertions(+), 7 deletions(-) diff --git a/TBF/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationForm.cs b/TBF/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationForm.cs index 33645a9f3..271d1d7bf 100644 --- a/TBF/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationForm.cs +++ b/TBF/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationForm.cs @@ -1869,12 +1869,24 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication q2CorrRL = (byte)((int)Math.Round(q2Correction) & 0x000000FF); q2CorrLR = (byte)((int)Math.Round(q2Correction) & 0x000000FF); } - else if (q2CorrType == Q2CorrType.RL) + else if (q2CorrType == Q2CorrType.RL) /// SUEZ { + if (Math.Abs(ihead.Q2ErrWOCorrection) <= 0.5) + { + resultStr = string.Format("Q2 correction = 0 (writing bypassed)"); + return CommErr.None; + } + q2CorrRL = (byte)((int)Math.Round(q2Correction) & 0x000000FF); } - else if (q2CorrType == Q2CorrType.LR) + else if (q2CorrType == Q2CorrType.LR) /// SUEZ { + if (Math.Abs(ihead.Q2ErrWOCorrection) <= 0.5) + { + resultStr = string.Format("Q2 correction = 0 (writing bypassed)"); + return CommErr.None; + } + q2CorrLR = (byte)((int)Math.Round(q2Correction) & 0x000000FF); } diff --git a/TBF/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationParams.cs b/TBF/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationParams.cs index 9228b0213..72b967015 100644 --- a/TBF/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationParams.cs +++ b/TBF/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationParams.cs @@ -60,6 +60,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication retVal.Add(iPerlCommunicationForm.WriteQ2CorrectionRLStr); retVal.Add(iPerlCommunicationForm.WriteQ2CorrectionLRStr); retVal.Add("Q2 corrected from Q2adj"); + retVal.Add("Q2 correction check Q2bc Q2ac"); retVal.Add(iPerlCommunicationForm.SetActiveModeStr); retVal.Add("---"); retVal.Add(iPerlCommunicationForm.Reset2HzCorrectionStr); diff --git a/TBF/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationSeq.cs b/TBF/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationSeq.cs index c32adeb59..358ef734e 100644 --- a/TBF/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationSeq.cs +++ b/TBF/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationSeq.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2015-2016 Sensus Metering Systems +/// Copyright (c) 2015-2018 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; @@ -57,6 +57,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, false); const string Q2correctedFromCmd = "q2 corrected from "; + const string Q2correctionCheckCmd = "q2 correction check "; const string Hz2correctedFromCmd = "2Hz corrected from "; if (testParams.Activity.ToLower().Contains(Q2correctedFromCmd)) @@ -77,7 +78,28 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication rList.Add(Event.Done); return rList; } - //else if (testParams.Activity.ToLower().Contains(Hz2correctedFromCmd)) + else if (testParams.Activity.ToLower().Contains(Q2correctionCheckCmd)) + { + TestProgressEventArgs.SetEstimatedTimes(new int[] { 0, 0, 0, 30, 0, 30, 0, 0 }); + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, Config.Entities.Progress.JustStarted)); + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, Config.Entities.Progress.FlowSetting)); + + string[] testNames = testParams.Activity.Substring(Q2correctionCheckCmd.Length).Split(new char[] { ' ' }); + + if (testNames.Length >= 2) + { + CheckQ2Correction(test.Name, testNames[0], testNames[1]); + } + + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, Config.Entities.Progress.Completed)); + Bridge.OnTestCompleted(this, new TestCompletedEventArgs(test.Name, ProcessData.BatchRslts.GetTestRslt(test.Name, 0))); + allResults.Info(TestResult2CsvLine(test.Name, 0)); /// Append the results to the CSV-file + + IList rList = new List(1); + rList.Add(Event.Done); + return rList; + } + //else if (testParams.Activity.ToLower().Contains(Hz2correctedFromCmd)) //{ // TestProgressEventArgs.SetEstimatedTimes(new int[] { 0, 0, 0, 30, 0, 30, 0, 0 }); // Bridge.OnTestProgress(this, new TestProgressEventArgs(test, Config.Entities.Progress.JustStarted)); @@ -183,8 +205,8 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication /// /// Virtually apply Q2 correction to a test used for the correction calculation. /// - /// Q2Adj test result - /// Virtual Q2 test result + /// This test name + /// Name of Q2 test done before Q2 correction (Q2adj) /// Assuming this test does not have multiple parts (part = 0) void MakeQ2CorrectedFrom(string testName, string oriTestName) { @@ -322,5 +344,140 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication } } } - } + + + /// + /// Check results of 2 tests: before Q2 correction and after Q2 correction. + /// Evaluate whether Q2 correction works OK. + /// + /// This test name + /// Name of Q2 test done before correction + /// Name of Q2 test done after correction + /// Assuming these tests do not have multiple parts (part = 0) + void CheckQ2Correction(string testName, string testNameQ2bc, string testNameQ2ac) + { + Results.Entities.TestRslt tstRslt = ProcessData.BatchRslts.GetTestRslt(testName, 0); + Results.Entities.TestRslt testRsltQ2bc = ProcessData.BatchRslts.GetTestRslt(testNameQ2bc, 0); + Results.Entities.TestRslt testRsltQ2ac = ProcessData.BatchRslts.GetTestRslt(testNameQ2ac, 0); + + if ((tstRslt == null) || (testRsltQ2bc == null) || (testRsltQ2ac == null)) return; + + tstRslt.Components = testRsltQ2ac.Components; + + /// Auxiliary results, as in SequenceBase.UpdateTemoPressDensAmb() + tstRslt.AmbTempMean = testRsltQ2ac.AmbTempMean; + tstRslt.AmbTempStart = testRsltQ2ac.AmbTempStart; + tstRslt.AmbTempEnd = testRsltQ2ac.AmbTempEnd; + tstRslt.AmbTempMin = testRsltQ2ac.AmbTempMin; + tstRslt.AmbTempMax = testRsltQ2ac.AmbTempMax; + tstRslt.AmbPressMean = testRsltQ2ac.AmbPressMean; + tstRslt.AmbPressStart = testRsltQ2ac.AmbPressStart; + tstRslt.AmbPressEnd = testRsltQ2ac.AmbPressEnd; + tstRslt.AmbPressMin = testRsltQ2ac.AmbPressMin; + tstRslt.AmbPressMax = testRsltQ2ac.AmbPressMax; + tstRslt.AmbHumiMean = testRsltQ2ac.AmbHumiMean; + tstRslt.AmbHumiStart = testRsltQ2ac.AmbHumiStart; + tstRslt.AmbHumiEnd = testRsltQ2ac.AmbHumiEnd; + tstRslt.AmbHumiMin = testRsltQ2ac.AmbHumiMin; + tstRslt.AmbHumiMax = testRsltQ2ac.AmbHumiMax; + tstRslt.PressUpMean = testRsltQ2ac.PressUpMean; + tstRslt.PressUpStart = testRsltQ2ac.PressUpStart; + tstRslt.PressUpEnd = testRsltQ2ac.PressUpEnd; + tstRslt.PressUpMin = testRsltQ2ac.PressUpMin; + tstRslt.PressUpMax = testRsltQ2ac.PressUpMax; + tstRslt.PressDownMean = testRsltQ2ac.PressDownMean; + tstRslt.PressDownStart = testRsltQ2ac.PressDownStart; + tstRslt.PressDownEnd = testRsltQ2ac.PressDownEnd; + tstRslt.PressDownMin = testRsltQ2ac.PressDownMin; + tstRslt.PressDownMax = testRsltQ2ac.PressDownMax; + tstRslt.PressDeltaMean = testRsltQ2ac.PressDeltaMean; + tstRslt.PressDeltaStart = testRsltQ2ac.PressDeltaStart; + tstRslt.PressDeltaEnd = testRsltQ2ac.PressDeltaEnd; + tstRslt.PressDeltaMin = testRsltQ2ac.PressDeltaMin; + tstRslt.PressDeltaMax = testRsltQ2ac.PressDeltaMax; + tstRslt.TempUpMean = testRsltQ2ac.TempUpMean; + tstRslt.TempUpStart = testRsltQ2ac.TempUpStart; + tstRslt.TempUpEnd = testRsltQ2ac.TempUpEnd; + tstRslt.TempUpMin = testRsltQ2ac.TempUpMin; + tstRslt.TempUpMax = testRsltQ2ac.TempUpMax; + tstRslt.TempDownMean = testRsltQ2ac.TempDownMean; + tstRslt.TempDownStart = testRsltQ2ac.TempDownStart; + tstRslt.TempDownEnd = testRsltQ2ac.TempDownEnd; + tstRslt.TempDownMin = testRsltQ2ac.TempDownMin; + tstRslt.TempDownMax = testRsltQ2ac.TempDownMax; + tstRslt.TempDivMean = testRsltQ2ac.TempDivMean; + tstRslt.TempDivStart = testRsltQ2ac.TempDivStart; + tstRslt.TempDivEnd = testRsltQ2ac.TempDivEnd; + tstRslt.TempDivMin = testRsltQ2ac.TempDivMin; + tstRslt.TempDivMax = testRsltQ2ac.TempDivMax; + tstRslt.DensityIn = testRsltQ2ac.DensityIn; + tstRslt.DensityLine = testRsltQ2ac.DensityLine; + tstRslt.DensityDiv = testRsltQ2ac.DensityDiv; + + tstRslt.StartTime = testRsltQ2ac.StartTime; + tstRslt.EndTime = testRsltQ2ac.EndTime; + tstRslt.FlowSetTime = testRsltQ2ac.FlowSetTime; + tstRslt.TestTime = testRsltQ2ac.TestTime; + tstRslt.PulsesMaster = testRsltQ2ac.PulsesMaster; + tstRslt.ConstMasterRaw = testRsltQ2ac.ConstMasterRaw; + tstRslt.ConstMaster = testRsltQ2ac.ConstMaster; + tstRslt.MassStartRaw = testRsltQ2ac.MassStartRaw; + tstRslt.MassStart = testRsltQ2ac.MassStart; + tstRslt.MassEndRaw = testRsltQ2ac.MassEndRaw; + tstRslt.MassEnd = testRsltQ2ac.MassEnd; + tstRslt.Buoyancy = testRsltQ2ac.Buoyancy; + tstRslt.FlowMass = testRsltQ2ac.FlowMass; + tstRslt.FlowVolume = testRsltQ2ac.FlowVolume; + tstRslt.VolumeCTV = testRsltQ2ac.VolumeCTV; + tstRslt.VolumeMaster = testRsltQ2ac.VolumeMaster; + tstRslt.ErrorMaster = testRsltQ2ac.ErrorMaster; + + tstRslt.FlowMean = testRsltQ2ac.FlowMean; + tstRslt.FlowMin = testRsltQ2ac.FlowMin; + tstRslt.FlowMax = testRsltQ2ac.FlowMax; + + tstRslt.Custom1 = testRsltQ2ac.Custom1; + tstRslt.Custom2 = testRsltQ2ac.Custom2; + tstRslt.Custom3 = testRsltQ2ac.Custom3; + tstRslt.Custom4 = testRsltQ2ac.Custom4; + tstRslt.Custom5 = testRsltQ2ac.Custom5; + tstRslt.Custom6 = testRsltQ2ac.Custom6; + tstRslt.Custom7 = testRsltQ2ac.Custom7; + tstRslt.Custom8 = testRsltQ2ac.Custom8; + + for (int i = 0; i < ProcessData.BatchRslts.WMPositionsCount; i++) + { + Results.Entities.MeterTestRslt meterRslt = ProcessData.BatchRslts.GetMeterTestRslt(testName, i, CompoundMeterId.Single); + Results.Entities.MeterTestRslt meterRsltQ2bc = ProcessData.BatchRslts.GetMeterTestRslt(testNameQ2bc, i, CompoundMeterId.Single); + Results.Entities.MeterTestRslt meterRsltQ2ac = ProcessData.BatchRslts.GetMeterTestRslt(testNameQ2ac, i, CompoundMeterId.Single); + + if ((meterRslt != null) && (meterRsltQ2bc != null) && (meterRsltQ2ac != null)) + { + meterRslt.PulsesMeter = meterRsltQ2ac.PulsesMeter; + meterRslt.PulsesMaster = meterRsltQ2ac.PulsesMaster; + meterRslt.PulsesPerLiter = meterRsltQ2ac.PulsesPerLiter; + meterRslt.VolumeRef = meterRsltQ2ac.VolumeRef; + meterRslt.TestTime = meterRsltQ2ac.TestTime; + meterRslt.VolumeStart = meterRsltQ2ac.VolumeStart; + meterRslt.VolumeEnd = meterRsltQ2ac.VolumeEnd; + meterRslt.VolumeMeter = meterRsltQ2ac.VolumeMeter; + meterRslt.Error = meterRsltQ2ac.Error; + meterRslt.TestDone = meterRsltQ2ac.TestDone; + tstRslt.TestDone = true; + + if (((meterRsltQ2bc.Error < -0.5f) && (meterRsltQ2ac.Error < meterRsltQ2bc.Error)) || + ((meterRsltQ2bc.Error > +0.5f) && (meterRsltQ2ac.Error > meterRsltQ2bc.Error))) + { + /// Q2 correction check failed + meterRslt.Passed = false; + } + else + { + /// Q2 correction check passed + meterRslt.Passed = meterRsltQ2ac.Passed; + } + } + } + } + } }