From 54a28aa8bf51fd035f5dc3103e9f4fc9ebea57a0 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Thu, 20 Feb 2020 13:23:07 +0100 Subject: [PATCH] Generate CompleteTestInfos from Procedure in case Oracle DB is off, ver. 2.25.1427 --- Results/Output/SensusTestInfo.cs | 87 +++++++++++++++++++ .../Output/FileWriters/IperlLogger/Writer.cs | 13 ++- TBF/BenchControl/Sequences/MainSeq.cs | 2 + .../iPerlCommunication/iPerlHead/IperlHead.cs | 25 +++--- TBF/Properties/AssemblyInfo.cs | 4 +- 5 files changed, 116 insertions(+), 15 deletions(-) diff --git a/Results/Output/SensusTestInfo.cs b/Results/Output/SensusTestInfo.cs index 23acfa346..580ea8e40 100644 --- a/Results/Output/SensusTestInfo.cs +++ b/Results/Output/SensusTestInfo.cs @@ -417,6 +417,93 @@ namespace Results.Output } } + /// + /// Generate a array of SensusTestInfo objects representing the procedure. + /// Multiple parts of the same test (with the same name) generate only one SensusTestInfo object. + /// + /// Procedure entity + /// Array of SensusTestInfo objects + public static SensusTestInfo[] CreateFromProcedure(Config.Entities.Procedure procedure) + { + /// + /// Count the number of different tests. + /// Multiple parts of the same test (same name) are counted only once. + /// + IList listOfHydroTests = new List(); + foreach (var test in procedure.Tests) + { + if (!test.Method.ToLower().Contains("iperlcommunication")) + { + for (int repNr = 1; repNr <= test.Repeats; repNr++) + { + string fullTestNameWoPart = (test.Repeats == 1) ? test.Name : string.Format("{0} ({1}/{2})", test.Name, repNr, test.Repeats); + if (!listOfHydroTests.Contains(fullTestNameWoPart)) + { + listOfHydroTests.Add(fullTestNameWoPart); + } + } + } + } + + SensusTestInfo[] stiArray = new SensusTestInfo[listOfHydroTests.Count]; + int ix = 0; + int luID = listOfHydroTests.Count; + listOfHydroTests.Clear(); + + foreach (var test in procedure.Tests) + { + if (!test.Method.ToLower().Contains("iperlcommunication")) + { + for (int repNr = 1; repNr <= test.Repeats; repNr++) + { + string fullTestNameWoPart = (test.Repeats == 1) ? test.Name : string.Format("{0} ({1}/{2})", test.Name, repNr, test.Repeats); + if (!listOfHydroTests.Contains(fullTestNameWoPart)) + { + listOfHydroTests.Add(fullTestNameWoPart); + stiArray[ix++] = CreateFromTest(test, repNr, luID--, fullTestNameWoPart); + } + } + } + } + + return stiArray; + } + + public static SensusTestInfo CreateFromTest(Config.Entities.Test test, int repetitionNr, int luID, string fullTestNameWoPart) + { + bool isQ4Q3 = test.Name.ToLower().Contains("q4") || + test.Name.ToLower().Contains("q3") || + test.Name.ToLower().Contains("qmax") || + test.Name.ToLower().Contains("qn"); + + bool isQ2Q1 = test.Name.ToLower().Contains("q2") || + test.Name.ToLower().Contains("q1") || + test.Name.ToLower().Contains("qt") || + test.Name.ToLower().Contains("qmin"); + + /// Range.R90_100 or Range.R100_110 (flow range in % of a target flow) + Range range = isQ4Q3 ? Range.R90_100 : (isQ2Q1 ? Range.R100_110 : Range.R95_105); + + return new SensusTestInfo() + { + TestName = fullTestNameWoPart, /// Test name in TBF procedures + PruefungsNrDB = luID, /// Identification of a flow + QBezeichnungDB = fullTestNameWoPart, /// Flow name in Oracle database + PruefungsNrOpto = luID, /// Identification of a flow - string form for log files + QBezeichnungOpto = luID.ToString("D02"), /// Flow name in Oracle database + PruefungsNrLog = luID, /// Identification of a flow + QBezeichnungLog = fullTestNameWoPart, /// Flow name in Oracle database + Range = range, + Flow = (range == Range.R100_110) ? test.Qfrom : (range == Range.R90_100) ? test.Qto : (test.Qfrom + test.Qto) / 2, + TestTime = (int)Math.Round(test.TstTime), + ErrLimLoFromDB = test.ErrLimLo, + ErrLimHiFromDB = test.ErrLimHi, + Uncertainty = test.Uncertainty, + TestMethod = test.Method, + }; + } + + public override string ToString() { return string.Format("{0} DB={1}/'{2}' Opto={3}/'{4}' Log={5}/'{6}'/{7}", TestName, PruefungsNrDB, QBezeichnungDB, PruefungsNrOpto, QBezeichnungOpto, PruefungsNrLog, QBezeichnungLog, Range); diff --git a/TBF/BenchControl/Output/FileWriters/IperlLogger/Writer.cs b/TBF/BenchControl/Output/FileWriters/IperlLogger/Writer.cs index 60da9a77c..2b24232a8 100644 --- a/TBF/BenchControl/Output/FileWriters/IperlLogger/Writer.cs +++ b/TBF/BenchControl/Output/FileWriters/IperlLogger/Writer.cs @@ -180,13 +180,20 @@ namespace TBF.BenchControl.Output.FileWriters.IperlLogger Results.Entities.WaterMeter wm0 = null; foreach (var wm in batch.WaterMeters) { - if ((wm != null) && (wm.CompleteTestInfos != null) && (wm.WaterMeterData != null)) - //if ((wm != null) && wm.PassedFromTests()) + if (wm != null && wm.WaterMeterData != null) { - wm0 = wm; + wm0 = wm; + if (wm0.CompleteTestInfos == null) + { + wm0.CompleteTestInfos = (TBF.BenchControl.Sequences.ProcessData.CompleteTestInfos != null) + ? TBF.BenchControl.Sequences.ProcessData.CompleteTestInfos + : Results.Output.SensusTestInfo.CreateFromProcedure(StateMachine.Procedure); + } + break; } } + if (wm0 == null) { log.Error("Not a single watermeter in the batch"); diff --git a/TBF/BenchControl/Sequences/MainSeq.cs b/TBF/BenchControl/Sequences/MainSeq.cs index 4477787ea..c1d71b499 100644 --- a/TBF/BenchControl/Sequences/MainSeq.cs +++ b/TBF/BenchControl/Sequences/MainSeq.cs @@ -351,6 +351,8 @@ namespace TBF.BenchControl.Sequences IsQ2PreCorrectionCalculated = false; CalculatedQ2PreCorrectionLR = 0; CalculatedQ2PreCorrectionRL = 0; + RawTestInfos = null; + CompleteTestInfos = null; } diff --git a/TBF/BenchControl/TestMethods/iPerlCommunication/iPerlHead/IperlHead.cs b/TBF/BenchControl/TestMethods/iPerlCommunication/iPerlHead/IperlHead.cs index 79c075b03..af9516f17 100644 --- a/TBF/BenchControl/TestMethods/iPerlCommunication/iPerlHead/IperlHead.cs +++ b/TBF/BenchControl/TestMethods/iPerlCommunication/iPerlHead/IperlHead.cs @@ -381,18 +381,18 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead ClearData(); optoSerialPortParsingEnabled = false; + /// Allocate memory for opto-data from iPerl + optoData = new OptoTelegramRaw[MaxOptoDataCount]; + for (int i = 0; i < MaxOptoDataCount; i++) optoData[i] = new OptoTelegramRaw(); + + toBeFlushed = new OptoTelegramRaw(); + + synchronized = false; + synchronized2 = false; + partOfTelegram = string.Empty; + if (DebugLevel == DebugMode.Normal) { - /// Allocate memory for opto-data from iPerl - optoData = new OptoTelegramRaw[MaxOptoDataCount]; - for (int i = 0; i < MaxOptoDataCount; i++) optoData[i] = new OptoTelegramRaw(); - - toBeFlushed = new OptoTelegramRaw(); - - synchronized = false; - synchronized2 = false; - partOfTelegram = string.Empty; - /// Prepare serial port optoSerialPort = new SerialPort(string.Format("COM{0}", iperlHeadCfg.OptoComPortNr), 9600, Parity.None, 8, StopBits.One); @@ -556,6 +556,11 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead string wmPosition = Name.Substring(5); /// WMPosition is extracted from a component name in form 'iPerl#' if (wmPosition.Length == 1) wmPosition = "0" + wmPosition; + if (StateMachine.Procedure != null && Sequences.ProcessData.CompleteTestInfos == null) + { + Sequences.ProcessData.CompleteTestInfos = Results.Output.SensusTestInfo.CreateFromProcedure(StateMachine.Procedure); + } + Results.Output.SensusTestInfo[] testInfos = Sequences.ProcessData.CompleteTestInfos; optoDataLogFileName = null; /// diff --git a/TBF/Properties/AssemblyInfo.cs b/TBF/Properties/AssemblyInfo.cs index e98424e44..1dbf46b78 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.25.1420.0")] -[assembly: AssemblyFileVersion("2.25.1420.0")] +[assembly: AssemblyVersion("2.25.1427.0")] +[assembly: AssemblyFileVersion("2.25.1427.0")]