diff --git a/Results/BatchResults.cs b/Results/BatchResults.cs index 46bc881a8..74fdc2464 100644 --- a/Results/BatchResults.cs +++ b/Results/BatchResults.cs @@ -105,6 +105,7 @@ namespace Results foreach (var ti in procedure.GetTestInstances()) { TestData td = TestData.UpdateList(d.TestDataList, new TestData(ti.Test)); + if (!d.Batch.Tests.Contains(td)) d.Batch.Tests.Add(td); /// Create an empty test result and add it to the list TestRslt tr = new TestRslt(d.Batch, td, ti.Test.Part, ti.Repetition); diff --git a/TBF/Rig/Output/FileWriters/IperlLogger/ProcParams.cs b/TBF/Rig/Output/FileWriters/IperlLogger/ProcParams.cs deleted file mode 100644 index 5d8ab49f1..000000000 --- a/TBF/Rig/Output/FileWriters/IperlLogger/ProcParams.cs +++ /dev/null @@ -1,178 +0,0 @@ -/// -/// Copyright (c) 2022 Sensus Slovensko a.s. -/// -using System; -using System.Collections.Generic; -using System.IO; -using System.Xml.Serialization; -using log4net; -using Common; -using Config.Entities; -using TBF.Rig.Generic; - -namespace TBF.Rig.Output.FileWriters.IperlLogger -{ - public class ProcParams : ProcedureParamsBase, IParamsProvider, IProcedureParams - { - private static readonly ILog log = LogManager.GetLogger(typeof(ProcParams)); - - public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(ProcParams) })[0]; - public override XmlSerializer GetSerializer() { return Serializer; } - - public DesigMode DesigMode; /// 0 - public Results.Output.LogType DesigType; /// 1 - - public override void InitializeAll() - { - DesigMode = DesigMode.Based_on_procedure; /// 0 - DesigType = Results.Output.LogType.Just_Q3Q2Q1; /// 1 - } - - string[] paramNames = new string[] - { - "Designation Mode", /// 0 - "Designation when mode is 'As_specified'", /// 1 - }; - public override string ParamName(int i) { return paramNames[i]; } - public override int ParamsCount() { return paramNames.Length; } - - public override ICollection ParamValues(int i) - { - IList retVal = new List(); - - switch (i) - { - case 0: - for (DesigMode md = 0; md < DesigMode.Count; md++) retVal.Add(md.ToString()); - return retVal; - - case 1: - for (Results.Output.LogType wm = 0; wm < Results.Output.LogType.Count; wm++) retVal.Add(wm.ToString()); - return retVal; - - default: - return null; - } - } - - public override string ToString(int i) - { - switch (i) - { - case 0: return DesigMode.ToString(); - case 1: return DesigType.ToString(); - default: return string.Empty; - } - } - - /// Retrieves parameters from UI controls - public CfgUpdateFlags UpdateParam(int i, string strValue) - { - switch (i) - { - case 0: - for (DesigMode db = 0; db < DesigMode.Count; db++) - { - if (db.ToString() == strValue) - { - DesigMode = db; - return CfgUpdateFlags.None; - } - } - break; - - case 1: - for (Results.Output.LogType wm = 0; wm < Results.Output.LogType.Count; wm++) - { - if (wm.ToString() == strValue) - { - DesigType = wm; - return CfgUpdateFlags.None; - } - } - break; - } - - return CfgUpdateFlags.None; - } - - /// Verifies whether strings in UI controls represent valid parameters - public bool ValidateParam(int i, string strValue, out string message) - { - message = string.Empty; - - switch (i) - { - case 0: - for (DesigMode db = 0; db < DesigMode.Count; db++) - { - if (db.ToString() == strValue) return true; - } - break; - - case 1: - for (Results.Output.LogType wm = 0; wm < Results.Output.LogType.Count; wm++) - { - if (wm.ToString() == strValue) return true; - } - break; - - default: - message = "Invalid index"; - return false; - } - - message = ParamName(i) + " is invalid"; - return false; - } - - void CopyContentTo(ProcParams prms) - { - prms.DesigMode = DesigMode; - prms.DesigType = DesigType; - } - - public IParamsProvider Clone() - { - ProcParams pars = new ProcParams(); - CopyContentTo(pars); - return pars; - } - - public override void UpdateFromDbEntity(ComponentProcedure dbEntity) - { - if (dbEntity == null) return; - try - { - ProcParams tmp = Serializer.Deserialize(new StringReader(dbEntity.Parameters)) as ProcParams; - - procedureParamsEntity = dbEntity; - componentName = dbEntity.CmpntName; - procedure = dbEntity.Procedure; - - if (tmp != null) tmp.CopyContentTo(this); - } - catch (Exception exc) - { - log.ErrorFormat("Failed to UpdateFromDbEntity({0}): {1}", dbEntity, exc.Message); - } - } - - - public ProcParams() - { - } - - public ProcParams(bool initialize) - { - if (initialize) InitializeAll(); - } - - public ProcParams(ComponentProcedure procedureParamsEntity, string componentName, Procedure procedure) - { - this.procedureParamsEntity = procedureParamsEntity; - this.componentName = componentName; - this.procedure = procedure; - } - } -} diff --git a/TBF/Rig/Output/FileWriters/IperlLogger/Writer.cs b/TBF/Rig/Output/FileWriters/IperlLogger/Writer.cs index 157dc4280..7430d5f1b 100644 --- a/TBF/Rig/Output/FileWriters/IperlLogger/Writer.cs +++ b/TBF/Rig/Output/FileWriters/IperlLogger/Writer.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2018-2021 Sensus Slovensko a.s. +/// Copyright (c) 2018-2022 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; @@ -29,8 +29,6 @@ namespace TBF.Rig.Output.FileWriters.IperlLogger WriterCfg writerCfg; - public DesigMode DesigMode { get { return (writerCfg == null || writerCfg.ProcParams == null) ? DesigMode.Based_on_procedure : writerCfg.ProcParams.DesigMode; } } - public LogType DesigType { get { return (writerCfg == null || writerCfg.ProcParams == null) ? LogType.Just_Q3Q2Q1 : writerCfg.ProcParams.DesigType; } } enum CurrentOp { @@ -199,68 +197,63 @@ namespace TBF.Rig.Output.FileWriters.IperlLogger public Retv WriteLogsToDisk(TextWriter logger, Batch batch) { -#if TURA_IPERL || TURA_IPERL_NEW || TURA_SPECIAL +#if ORACLE_DB /// - /// Obtain one representative water meter + /// Obtain data of one water meter /// - WaterMeter wm0 = batch.WaterMeters.FirstOrDefault(x => (x != null && !x.Disabled && x.WaterMeterData != null)); - if (wm0 == null) + WaterMeter firstWM = batch.WaterMeters.FirstOrDefault(x => (x != null && !x.Disabled && x.WaterMeterData != null)); + if (firstWM == null) { log.Error("Not a single watermeter in the batch"); return Retv.Error; /// Not a single watermeter in the batch } - WaterMeterData wmData = wm0.WaterMeterData; + WaterMeterData wmData = firstWM.WaterMeterData; /// /// Select or create appropriate test infos /// - Results.Output.SensusTestInfo[] testInfos = Sequences.ProcessData.CompleteTestInfos; - /// - if (DesigMode == DesigMode.Based_on_procedure && StateMachine.Procedure != null) - { - testInfos = Results.Output.SensusTestInfo.CreateFromProcedure(StateMachine.Procedure); - } - if (testInfos == null) - { - log.Error("CompleteTestInfos is null"); - return Retv.Error; /// No test infos - } - log.Warn("Using CompleteTestInfos:"); - foreach (var cti in testInfos) - { - log.WarnFormat(" Test={0} PrfNrDB={1} QBzDB={2} PrfNrOpto={3} QBzOpto={4} PrfNrLog={5} QBzLog={6} Range={7}", - cti.TestName, cti.PruefungsNrDB, cti.QBezeichnungDB, cti.PruefungsNrOpto, - cti.QBezeichnungOpto, cti.PruefungsNrLog, cti.QBezeichnungLog, cti.Range); - } - - /// - /// Select water meter test results - /// - MeterTestRslt[] wm0trs = new MeterTestRslt[testInfos.Length]; - double totalTestTime = 0; + IList testsToSave = new List(); int maxPruefungsNr = 0; - for (int j = 0; j < testInfos.Length; j++) + double totalTestTime = 0; + foreach (var td in batch.Tests) { - if (testInfos[j].PruefungsNrLog != 0) + for (int repNr = 1; repNr <= td.Repeats; repNr++) { - if (Math.Abs(testInfos[j].PruefungsNrLog) > maxPruefungsNr) maxPruefungsNr = Math.Abs(testInfos[j].PruefungsNrLog); - - wm0trs[j] = wm0.GetMeterTestRslt(testInfos[j].TestName); - - if (wm0trs[j] != null) + int testId = td.OraId + repNr * td.OraIdRepetMulti; + if (testId != 0) { - totalTestTime += wm0trs[j].TargetTime(); - } - else - { - log.ErrorFormat("Missing test result for test {0}", testInfos[j].TestName); - return Retv.Error; /// Missing test result for one of specified tests + testsToSave.Add(new LUTestData(td, repNr)); + if (Math.Abs(testId) > maxPruefungsNr) maxPruefungsNr = Math.Abs(testId); + totalTestTime += td.TargetTime; } } } + LUTestData[] testsToSaveArr = testsToSave.ToArray(); + Array.Sort(testsToSaveArr, new LUTestDataComparer()); + /// Make a log + foreach (var ltd in testsToSaveArr) + { + log.WarnFormat(" Test={0} Repetition={1} Id={2} Designation={3}", ltd.TData.Name, ltd.RepNr, ltd.Id, ltd.Designation); + } + /// + /// Check whether the test results are complete, quit on error + /// + MeterTestRslt[] firstWMTestRslts = new MeterTestRslt[testsToSaveArr.Length]; + foreach (var ltd in testsToSaveArr) + { + if (firstWM.GetMeterTestRslt(ltd.TestName) == null) + { + log.ErrorFormat("Missing test result for test {0}", ltd.TestName); + return Retv.Error; /// Missing test result for one of specified tests + } + } + + /// + /// Save the log file + /// logger.WriteLine("[Wasserzähler-Daten]"); logger.WriteLine(string.Format("PruefPunkte={0}", (maxPruefungsNr > 15) ? 20 : ((maxPruefungsNr > 10) ? 15 : ((maxPruefungsNr > 5) ? 10 : 5)))); logger.WriteLine(string.Format("Typ={0}", batch.ProcedureName)); /// iP 020 Q3_4 R160 A XXXX @@ -269,45 +262,29 @@ namespace TBF.Rig.Output.FileWriters.IperlLogger logger.WriteLine(string.Format("Qn={0}", wmData.Q3_Qn.ToString("F1", Program.AltCulture))); logger.WriteLine(string.Format("Impulsrate=1")); logger.WriteLine(string.Format("WZid={0}", wmData.WMTypeId)); - logger.WriteLine(string.Format("RevWzTyp={0}", wm0.WMTypeRevision)); + logger.WriteLine(string.Format("RevWzTyp={0}", firstWM.WMTypeRevision)); logger.WriteLine(string.Format("RevPruefstandWzTyp=2")); - for (int j = 0; j < testInfos.Length; j++) + foreach (var ltd in testsToSaveArr) { - if (testInfos[j].PruefungsNrLog != 0) - { - string fId = testInfos[j].PruefungsNrLog.ToString((testInfos[j].PruefungsNrLog > 0) ? "D2" : "D1"); - string qBz = testInfos[j].QBezeichnungLog; - Results.Entities.MeterTestRslt wm0r = wm0trs[j]; - bool pb_100_110 = (testInfos[j].Range == Range.R100_110); + string fId = ltd.Id.ToString((ltd.Id > 0) ? "D2" : "D1"); + string qBz = ltd.Designation; + var td = ltd.TData; + bool pb_100_110 = (Math.Abs(td.Qtg - td.Qfrom) < Math.Abs(td.Qto - td.Qtg)); - if (wm0r != null) - { - /// An existing test - logger.WriteLine(string.Format("Durchfluss{0}={1}", fId, Units.ConvertTo(Unit.lph, (wm0r.Qfrom() + wm0r.Qto()) / 2).ToString("F1", Program.AltCulture))); - logger.WriteLine(string.Format("Prüfzeit{0}={1}", fId, wm0r.TargetTime().ToString("F0"))); - logger.WriteLine(string.Format("Prüfbereich100_110{0}={1}", fId, (pb_100_110 ? 1 : 0))); - logger.WriteLine(string.Format("PrüfbereichMin{0}={1}", fId, (pb_100_110 ? 100 : 90))); - logger.WriteLine(string.Format("PrüfbereichMax{0}={1}", fId, (pb_100_110 ? 110 : 100))); - logger.WriteLine(string.Format("QBezeichnung{0}={1}", fId, qBz)); - if (testInfos[j].PruefungsNrLog > 0) - { - /// Test is not an adjustment - logger.WriteLine(string.Format("PosFehlergrenze{0}={1}", fId, (wm0r.ErrLimHi() - wm0r.Uncertainty()).ToString("F1", Program.AltCulture))); - logger.WriteLine(string.Format("NegFehlergrenze{0}={1}", fId, (wm0r.ErrLimLo() + wm0r.Uncertainty()).ToString("F1", Program.AltCulture))); - logger.WriteLine(string.Format("PosFehlergrenzeWarm{0}=0,0", fId)); - logger.WriteLine(string.Format("NegFehlergrenzeWarm{0}=0,0", fId)); - } - } - else - { - logger.WriteLine(string.Format("Durchfluss{0}=0,0", fId)); - logger.WriteLine(string.Format("Prüfzeit{0}=0", fId)); - logger.WriteLine(string.Format("Prüfbereich100_110{0}=0", fId)); - logger.WriteLine(string.Format("PrüfbereichMin{0}=0", fId)); - logger.WriteLine(string.Format("PrüfbereichMax{0}=0", fId)); - logger.WriteLine(string.Format("QBezeichnung{0}=", fId)); - } + logger.WriteLine(string.Format("Durchfluss{0}={1}", fId, Units.ConvertTo(Unit.lph, (td.Qfrom + td.Qto) / 2).ToString("F1", Program.AltCulture))); + logger.WriteLine(string.Format("Prüfzeit{0}={1}", fId, td.TargetTime.ToString("F0"))); + logger.WriteLine(string.Format("Prüfbereich100_110{0}={1}", fId, (pb_100_110 ? 1 : 0))); + logger.WriteLine(string.Format("PrüfbereichMin{0}={1}", fId, (pb_100_110 ? 100 : 90))); + logger.WriteLine(string.Format("PrüfbereichMax{0}={1}", fId, (pb_100_110 ? 110 : 100))); + logger.WriteLine(string.Format("QBezeichnung{0}={1}", fId, qBz)); + if (ltd.Id > 0) + { + /// Test is not an adjustment + logger.WriteLine(string.Format("PosFehlergrenze{0}={1}", fId, (td.ErrLimHi - td.ErrLimMargin).ToString("F1", Program.AltCulture))); + logger.WriteLine(string.Format("NegFehlergrenze{0}={1}", fId, (td.ErrLimLo + td.ErrLimMargin).ToString("F1", Program.AltCulture))); + logger.WriteLine(string.Format("PosFehlergrenzeWarm{0}=0,0", fId)); + logger.WriteLine(string.Format("NegFehlergrenzeWarm{0}=0,0", fId)); } } @@ -348,14 +325,11 @@ namespace TBF.Rig.Output.FileWriters.IperlLogger else { bool testRsltIsMissing = false; - Results.Entities.MeterTestRslt[] wmtrs = new Results.Entities.MeterTestRslt[testInfos.Length]; - for (int j = 0; j < testInfos.Length; j++) + Results.Entities.MeterTestRslt[] wmtrs = new Results.Entities.MeterTestRslt[testsToSaveArr.Length]; + for (int j = 0; j < testsToSaveArr.Length; j++) { - if (testInfos[j].PruefungsNrLog != 0) - { - wmtrs[j] = wMtr.GetMeterTestRslt(testInfos[j].TestName); - if (wmtrs[j] == null) testRsltIsMissing = true; /// Missing test result for one of specified tests - } + wmtrs[j] = wMtr.GetMeterTestRslt(testsToSaveArr[j].TestName); + if (wmtrs[j] == null) testRsltIsMissing = true; /// Missing test result for one of specified tests } logger.WriteLine(); @@ -377,12 +351,12 @@ namespace TBF.Rig.Output.FileWriters.IperlLogger logger.WriteLine(string.Format("PrüfIndex={0}", wMtr.Pruefindex)); /// 7301 logger.WriteLine(string.Format("GeprüftIndex=1")); /// 1 - for (int j = 0; j < testInfos.Length; j++) + for (int j = 0; j < testsToSaveArr.Length; j++) { - if (testInfos[j].PruefungsNrLog != 0) + if (testsToSaveArr[j].Id != 0) { Results.Entities.MeterTestRslt mtr = wmtrs[j]; - string flID = testInfos[j].PruefungsNrLog.ToString((testInfos[j].PruefungsNrLog > 0) ? "D2" : "D1"); + string flID = testsToSaveArr[j].Id.ToString((testsToSaveArr[j].Id > 0) ? "D2" : "D1"); if (mtr != null) { @@ -451,22 +425,19 @@ namespace TBF.Rig.Output.FileWriters.IperlLogger logger.WriteLine(string.Format("Dichtprüfung={0}", 0)); /// 1 - foreach (var cti in testInfos) + foreach (var ltd in testsToSaveArr) { - if (cti.PruefungsNrLog != 0) - { - string pNrStr = cti.PruefungsNrLog.ToString((cti.PruefungsNrLog > 0) ? "D2" : "D1"); - Results.Entities.TestRslt tr = wm0.GetTestRslt(cti.TestName); + string pNrStr = ltd.Id.ToString((ltd.Id > 0) ? "D2" : "D1"); + Results.Entities.TestRslt tr = firstWM.GetTestRslt(ltd.TestName); - if (tr != null) - { - logger.WriteLine(string.Format("Q{0}_geprüft=1", pNrStr)); - WriteOneToDisk(logger, pNrStr, tr); - } - else - { - logger.WriteLine(string.Format("Q{0}_geprüft=0", pNrStr)); - } + if (tr != null) + { + logger.WriteLine(string.Format("Q{0}_geprüft=1", pNrStr)); + WriteOneToDisk(logger, pNrStr, tr); + } + else + { + logger.WriteLine(string.Format("Q{0}_geprüft=0", pNrStr)); } } diff --git a/TBF/Rig/Output/FileWriters/IperlLogger/WriterCfg.cs b/TBF/Rig/Output/FileWriters/IperlLogger/WriterCfg.cs index 526ebdddc..875e80976 100644 --- a/TBF/Rig/Output/FileWriters/IperlLogger/WriterCfg.cs +++ b/TBF/Rig/Output/FileWriters/IperlLogger/WriterCfg.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2018 Sensus Slovensko a.s. +/// Copyright (c) 2018-2022 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; @@ -23,17 +23,8 @@ namespace TBF.Rig.Output.FileWriters.IperlLogger public bool MonthFolders; public bool DayFolders; - /// Procedure parameters - [XmlIgnore] - public ProcParams ProcParams; - public override IParamsProvider GetRuntimeProcParamsProvider() { return ProcParams; } - public override IParamsProvider CreateProcParamsProvider() { return new ProcParams(true); } - /// Private parameterless constructor invoked by all other (public) constructors - WriterCfg() - { - ProcParams = new ProcParams(true); - } + WriterCfg() { } public WriterCfg(string name, IComponentFactory factory) : this() diff --git a/TBF/Rig/Output/LUTestData.cs b/TBF/Rig/Output/LUTestData.cs new file mode 100644 index 000000000..b79c9d556 --- /dev/null +++ b/TBF/Rig/Output/LUTestData.cs @@ -0,0 +1,36 @@ +/// +/// Copyright (c) 2022 Sensus Slovensko a.s. +/// +using System; +using Results.Entities; + +namespace TBF.Rig.Output +{ + public class LUTestData + { + public TestData TData; + public int RepNr; + public string TestName; /// Expanded TBF test name + public int Id; /// PruefungsNr + public string Designation; /// QBezeichnung + + public LUTestData(TestData tData, int repNr) + { + TData = tData; + RepNr = repNr; + TestName = Common.Utils.GetTestName(tData.Name, tData.Repeats, repNr); + Id = tData.OraId + repNr * tData.OraIdRepetMulti; + if (string.IsNullOrEmpty(tData.OraDesignation)) + { + Designation = Common.Utils.GetTestName(tData.Name, tData.Repeats, repNr); + } + else + { + var designations = tData.OraDesignation.Split(new char[] { '~' }); + Designation = (designations.Length > repNr - 1) + ? designations[repNr - 1] /// Name is from 'OraDesignation' parameter + : Common.Utils.GetTestName(tData.Name, tData.Repeats, repNr); /// Name is from test name and repetition nr. + } + } + } +} diff --git a/TBF/Rig/Output/LUTestDataComparer.cs b/TBF/Rig/Output/LUTestDataComparer.cs new file mode 100644 index 000000000..0b8b7e2ee --- /dev/null +++ b/TBF/Rig/Output/LUTestDataComparer.cs @@ -0,0 +1,38 @@ +/// +/// Copyright (c) 2022 Sensus Slovensko a.s. +/// +using System; +using System.Collections; +using System.Windows.Forms; + +namespace TBF.Rig.Output +{ + public class LUTestDataComparer : IComparer + { + SortOrder order; + + public LUTestDataComparer() + { + order = SortOrder.Ascending; + } + + public LUTestDataComparer(SortOrder order) + { + this.order = order; + } + + // test.RawDataId + repetitionNr * test.RawDataIdRepetMulti + public int Compare(object x, object y) + { + var trX = x as LUTestData; + var trY = y as LUTestData; + if (trX == null || trY == null) return 0; + + int idX = trX.TData.OraId + trX.RepNr * trX.TData.OraIdRepetMulti; + int idY = trY.TData.OraId + trY.RepNr * trY.TData.OraIdRepetMulti; + int valX = (idX > 0) ? int.MaxValue - idX : idX; + int valY = (idY > 0) ? int.MaxValue - idY : idY; + return order == SortOrder.Descending ? (valY - valX) : (valX - valY); + } + } +} diff --git a/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHead.cs b/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHead.cs index 486d1f0e7..242548506 100644 --- a/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHead.cs +++ b/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHead.cs @@ -285,12 +285,11 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead /// /// Currently executed test /// Currently executed repetition number - public void TestIsGoingToStartSoon(Test test, int repetitionNr) + public void TestIsGoingToStartSoon(Test _test, int _repetitionNr) { /// Store/update values to be used as a part of the opto-data log file name - testName = test.Name; - testRepeats = test.Repeats; - this.repetitionNr = repetitionNr; + this.test = _test; + this.repetitionNr = _repetitionNr; if (IsDataStreamProcessing()) { @@ -326,8 +325,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead } } /// - string testName; - int testRepeats; + Test test; int repetitionNr; @@ -660,20 +658,24 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead // // log.DebugFormat("Feature vector calculation end, save opto-file start: {0:HH:mm:ss.fff}", DateTime.Now); - string relativeDirectory = Path.Combine(StateMachine.CycleStartTimeStamp.ToString("yy"), - StateMachine.CycleStartTimeStamp.ToString("MM"), - StateMachine.CycleStartTimeStamp.ToString("dd")); - string directory = Path.Combine(OptoDataDirectory, relativeDirectory); - string fileName = DetermineExtraDataFileName(); - if (!string.IsNullOrEmpty(fileName)) + if (test.RawDataId + repetitionNr * test.RawDataIdRepetMulti != 0) { - if (SaveOptoDataToFile(directory, fileName)) + string relativeDirectory = Path.Combine(StateMachine.CycleStartTimeStamp.ToString("yy"), + StateMachine.CycleStartTimeStamp.ToString("MM"), + StateMachine.CycleStartTimeStamp.ToString("dd")); + string fileName = DetermineExtraDataFileName(); + if (SaveOptoDataToFile(Path.Combine(OptoDataDirectory, relativeDirectory), fileName)) { extraDataPath = Path.Combine(relativeDirectory, fileName); } - } - log.WarnFormat("IperlHeadd.Stop() startIx={0} endIx={1} optoData.Len={2} filename={3}", startIx, endIx, optoData.Length, !string.IsNullOrEmpty(fileName) ? fileName : ""); + log.WarnFormat("IperlHead.Stop() startIx={0} endIx={1} len={2} raw data file = {3}", + startIx, endIx, optoData.Length, fileName); + } + else + { + log.WarnFormat("IperlHead.Stop() startIx={0} endIx={1} len={2} no raw data file", startIx, endIx, optoData.Length); + } if (TestStartTelegramIx == 0 || optoDataCount < 100) { @@ -740,36 +742,21 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead string DetermineExtraDataFileName() { /// - /// Select or create appropriate test infos - /// - Results.Output.SensusTestInfo[] testInfos = Sequences.ProcessData.CompleteTestInfos; - /// - if ((ProcessData.OracleDB != null && ProcessData.OracleDB.DesigMode == DesigMode.Based_on_procedure) || - (testInfos == null && StateMachine.Procedure != null)) - { - testInfos = Results.Output.SensusTestInfo.CreateFromProcedure(StateMachine.Procedure); - } - - /// - /// Select or create appropriate 'qBezeichnung' - /// - string fullTestName = Results.Utils.GetTestName(testName, testRepeats, repetitionNr); - var ti = testInfos.FirstOrDefault(x => x.PruefungsNrOpto != 0 && x.TestName == fullTestName); - string qBezeichnung = (ti == null) ? fullTestName /// No appropriate TestInfo found => set default opto data file name - : string.IsNullOrEmpty(ti.QBezeichnungOpto) ? ti.PruefungsNrOpto.ToString("D2") - : ti.QBezeichnungOpto; - /// - /// Get other required pieces of information + /// Get required pieces of information /// string pcbNr = (ConfigStruct != null) ? ConfigStruct.GetPcbNrString() : "UnknownPcbNr"; string wmPosition = Name.Substring(5); /// WMPosition is extracted from a component name in form 'iPerl#' if (wmPosition.Length == 1) wmPosition = "0" + wmPosition; string cycleStartTime = StateMachine.CycleStartTimeStamp.ToString("HH_mm_ss"); - + string[] designations = string.IsNullOrEmpty(test.RawDataDesignation) ? new string[0] : test.RawDataDesignation.Split(new char[] { '~' }); + string designation = string.IsNullOrEmpty(test.RawDataDesignation) + ? (test.RawDataId + repetitionNr * test.RawDataIdRepetMulti).ToString("D2") /// Name is generated from Id + : (designations.Length > repetitionNr - 1) ? designations[repetitionNr - 1] /// Name is from 'RawDataDesignation' parameter + : string.Format("{0}{1}", test.Name, repetitionNr); /// Name is form test name and repetition nr. /// /// Return the file name - /// - return string.Format("{0}_{1}_{2}_{3}.txt", pcbNr, wmPosition, qBezeichnung, cycleStartTime); + /// + return string.Format("{0}_{1}_{2}_{3}.txt", pcbNr, wmPosition, designation, cycleStartTime); } @@ -779,7 +766,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead bool SaveOptoDataToFile(string directory, string fileName) { string fullFileName = Path.Combine(directory, fileName); - log.WarnFormat("Saving {0} opto data to {1}", Name, fullFileName); + log.WarnFormat("Saving {0} raw data to {1}", Name, fullFileName); try { @@ -953,7 +940,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead { /// CR+LF was found && (pos >= OptoTelegramRaw.Length - 2) && the telegram is OK flowDirectionDetection.WriteToFifo(volumeRawExtLast, timestampExtLast); - OptoTelegramRreceived(optoDataCount, synchronized2, volumeRawExtLast, timestampExtLast); + OptoTelegramReceived(optoDataCount, synchronized2, volumeRawExtLast, timestampExtLast); synchronized2 = synchronized; allRcvd = allRcvd.Substring(pos + 2); } @@ -1003,7 +990,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead } - void OptoTelegramRreceived(int currentIx, bool async, Int64 volumeRawExt, Int64 timestampRawExt) + void OptoTelegramReceived(int currentIx, bool async, Int64 volumeRawExt, Int64 timestampRawExt) { currentTelegramIx = currentIx; diff --git a/TBF/TBF.csproj b/TBF/TBF.csproj index db938cf48..451ccb1e3 100644 --- a/TBF/TBF.csproj +++ b/TBF/TBF.csproj @@ -1064,7 +1064,6 @@ ArchiverCfgCtrl.cs - @@ -1110,6 +1109,8 @@ HeaderFooterDlg.cs + +