diff --git a/TBF/Properties/AssemblyInfo.cs b/TBF/Properties/AssemblyInfo.cs index 50e641e09..d9224fb94 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.33.2111.0")] -[assembly: AssemblyFileVersion("2.33.2111.0")] +[assembly: AssemblyVersion("2.33.2112.0")] +[assembly: AssemblyFileVersion("2.33.2112.0")] diff --git a/TBF/Rig/Output/DB/SensusOracle/Database.cs b/TBF/Rig/Output/DB/SensusOracle/Database.cs index b32505ed2..d73849e38 100644 --- a/TBF/Rig/Output/DB/SensusOracle/Database.cs +++ b/TBF/Rig/Output/DB/SensusOracle/Database.cs @@ -16,6 +16,7 @@ using Config.Entities; using Results.Output; using System.Text; using Events.Entities; +using Results; namespace TBF.Rig.Output.DB.SensusOracle { @@ -394,10 +395,42 @@ namespace TBF.Rig.Output.DB.SensusOracle currentOpState = OpState.None; } - #if ORACLE_DB + void GetTestInofFromProcedure(string logCaption) + { + /// + /// Select or create appropriate test infos + /// + IList testsToSave = new List(); + int maxPruefungsNr = 0; + foreach (var td in Sequences.ProcessData.BatchRslts.Batch.Tests) + { + for (int repNr = 1; repNr <= td.Repeats; repNr++) + { + int testId = td.OraId + (td.Repeats - repNr) * td.OraIdRepetMulti; + if (testId != 0) + { + testsToSave.Add(new LUTestData(td, repNr)); + if (Math.Abs(testId) > maxPruefungsNr) maxPruefungsNr = Math.Abs(testId); + } + } + } + LUTestData[] testsToSaveArr = testsToSave.ToArray(); + Array.Sort(testsToSaveArr, new LUTestDataComparer()); + completeTestInfo = testsToSaveArr; + + log.WarnFormat("{0} selected test infos:", logCaption); + foreach (var cti in completeTestInfo) + { + log.WarnFormat(" ID={0} Rev={1} Test={2} PrfNrDB={3} QBzDB={4}", + wmTypeId, wmTypeRevision, cti.TestName, cti.Id, cti.Designation); + } + } + public Retv ReadStartInfoFromDB(OracleConnection conn) { + GetTestInofFromProcedure("ReadStartInfoFromDB"); /// Create appropriate test infos + bool anyError = false; try { @@ -420,9 +453,9 @@ namespace TBF.Rig.Output.DB.SensusOracle return anyError ? Retv.Error : Retv.OK; } - /// - /// Read start info of one water meter from the database - /// + /// + /// Read start info of one water meter from the database + /// /// Oracke DB connection /// Water meter entity /// Retv.OK when successful, Retv.Error on error @@ -790,35 +823,7 @@ namespace TBF.Rig.Output.DB.SensusOracle throw new Exception(string.Format("Cannot save batch {0} to Oracle, missing entry in VT_WZTYP_SD", bat.BatchNr)); } - /// - /// Select or create appropriate test infos - /// - IList testsToSave = new List(); - int maxPruefungsNr = 0; - double totalTestTime = 0; - foreach (var td in bat.Tests) - { - for (int repNr = 1; repNr <= td.Repeats; repNr++) - { - int testId = td.OraId + (td.Repeats - repNr) * td.OraIdRepetMulti; - if (testId != 0) - { - 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()); - completeTestInfo = testsToSaveArr; - - foreach (var cti in completeTestInfo) - { - log.WarnFormat("Selected test info : ID={0} Rev={1} Test={2} PrfNrDB={3} QBzDB={4}", - wmTypeId, wmTypeRevision, cti.TestName, cti.Id, cti.Designation); - } - + GetTestInofFromProcedure("SaveBatchData"); /// Create appropriate test infos if (dbCfg.DebugLevel == DebugMode.Normal) { diff --git a/TBF/Rig/TestMethods/iPerlCommunication/iPerlCommunicationForm.cs b/TBF/Rig/TestMethods/iPerlCommunication/iPerlCommunicationForm.cs index 295ac8d16..8091d28db 100644 --- a/TBF/Rig/TestMethods/iPerlCommunication/iPerlCommunicationForm.cs +++ b/TBF/Rig/TestMethods/iPerlCommunication/iPerlCommunicationForm.cs @@ -24,6 +24,8 @@ using Sensus.iPerl.RfidCom.Helper; using Sensus.iPerl.RfidCom.Model.Enums; using Sensus.iPerl.RfidCom.Services; using Sensus.iPerl.RfidCom.Structures; +using Results.Entities; +using Results; namespace TBF.Rig.TestMethods.iPerlCommunication { @@ -100,6 +102,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication public const string DewaReworkLRStr = "DEWA rework L-R"; public const string StartTestingSealedMetersStr = "Start testing sealed meters"; public const string EndTestingSealedMetersStr = "End testing sealed meters"; + public const string SimulateCmd = "simulate "; public static Color DisabledColor = Color.DarkGray; public static Color OptoAndDirOKColor = Color.Green; @@ -746,7 +749,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication int count = 0; for (int wmNr0 = 0; wmNr0 < iperlHeads.Count; wmNr0++) { - Results.Entities.WaterMeter wm = (ProcessData.BatchRslts.Batch.WaterMeters != null && ProcessData.BatchRslts.Batch.WaterMeters.Count > wmNr0) + WaterMeter wm = (ProcessData.BatchRslts.Batch.WaterMeters != null && ProcessData.BatchRslts.Batch.WaterMeters.Count > wmNr0) ? ProcessData.BatchRslts.Batch.WaterMeters[wmNr0] : null; IperlHead ihead = iperlHeads[wmNr0]; @@ -794,7 +797,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication { wmFound = true; - Results.Entities.WaterMeter wm = null; + WaterMeter wm = null; if (ProcessData.BatchRslts.Batch.WaterMeters != null) { foreach (var w in ProcessData.BatchRslts.Batch.WaterMeters) @@ -857,6 +860,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication else if (currentActivity.ToLower() == DewaReworkLRStr.ToLower()) error = DewaRework(ihead, wm, FlowDir.L_R, ref resultStr); else if (currentActivity.ToLower().Contains(StartTestingSealedMetersStr.ToLower())) error = StartTestingSealedMeter(ihead, wm, ref resultStr); else if (currentActivity.ToLower().Contains(EndTestingSealedMetersStr.ToLower())) error = EndTestingSealedMeter(ihead, wm, ref resultStr); + else if (currentActivity.ToLower().Contains(SimulateCmd.ToLower())) error = Simulate(ihead, wm, ref resultStr); #endif else { @@ -955,7 +959,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication /// Water meter object /// String passed to caller /// true on success - static CommErr ReadConfiguration(IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr) + static CommErr ReadConfiguration(IperlHead ihead, WaterMeter wm, ref string resultStr) { /// /// The activity is "Read configuration" (this enables the watermeter, resets error flag) @@ -1145,7 +1149,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication /// Water meter object /// String passed to caller /// true on success - static CommErr ReadCalibration(IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr) + static CommErr ReadCalibration(IperlHead ihead, WaterMeter wm, ref string resultStr) { if (ihead.CommFailed) return CommErr.CommFailed; @@ -1179,7 +1183,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication /// Water meter object /// String passed to caller /// true on success - static CommErr ReadCalibrationV4(IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr) + static CommErr ReadCalibrationV4(IperlHead ihead, WaterMeter wm, ref string resultStr) { if (ihead.CommFailed) return CommErr.CommFailed; @@ -1217,7 +1221,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication /// Water meter object /// String passed to caller /// true on success - static CommErr WriteCalibrationFactor(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr) + static CommErr WriteCalibrationFactor(int threadId, IperlHead ihead, WaterMeter wm, ref string resultStr) { if (ihead.CommFailed || (ihead.CalibrationStruct == null)) return CommErr.CommFailed; @@ -1352,7 +1356,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication /// Water meter object /// String passed to caller /// true on success - static CommErr WriteCalibrationV4Factors(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr) + static CommErr WriteCalibrationV4Factors(int threadId, IperlHead ihead, WaterMeter wm, ref string resultStr) { if (ihead.CommFailed || (ihead.CalibrationStructV4 == null)) return CommErr.CommFailed; @@ -1513,7 +1517,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication /// Water meter /// TestData (name and repetitions) /// (1) selected MeterTestRslt or (2) average of repeated MTR-s or (3) null when at least one MTR is missing - static Results.Entities.MeterTestRslt GetAverageTestRslt(Results.Entities.WaterMeter wm, Results.Entities.TestData testData) + static Results.Entities.MeterTestRslt GetAverageTestRslt(WaterMeter wm, Results.Entities.TestData testData) { Results.Entities.MeterTestRslt avgTestRslt; @@ -1545,7 +1549,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication /// Water meter object /// String passed to caller /// true on success - static CommErr NormalizeCalibrationFactor(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr) + static CommErr NormalizeCalibrationFactor(int threadId, IperlHead ihead, WaterMeter wm, ref string resultStr) { if (ihead.CommFailed || (ihead.CalibrationStruct == null)) return CommErr.CommFailed; @@ -1614,7 +1618,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication /// Water meter object /// String passed to caller /// true on success - static CommErr NormalizeCalibrationV4Factors(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr) + static CommErr NormalizeCalibrationV4Factors(int threadId, IperlHead ihead, WaterMeter wm, ref string resultStr) { if (ihead.CommFailed || (ihead.CalibrationStructV4 == null)) return CommErr.CommFailed; @@ -1684,7 +1688,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication /// Water meter object /// String passed to caller /// true on success - static CommErr ReadQ2Correction(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr) + static CommErr ReadQ2Correction(int threadId, IperlHead ihead, WaterMeter wm, ref string resultStr) { if (ihead.CommFailed) return CommErr.CommFailed; @@ -1715,7 +1719,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication /// Water meter object /// String passed to caller /// true on success - static CommErr ResetQ2Correction(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr) + static CommErr ResetQ2Correction(int threadId, IperlHead ihead, WaterMeter wm, ref string resultStr) { return WriteQ2Corrections(threadId, ihead, wm, ref resultStr, 0, 0); } @@ -1727,7 +1731,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication /// Water meter object /// String passed to caller /// true on success - static CommErr WriteDefaultQ2Corrections(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr) + static CommErr WriteDefaultQ2Corrections(int threadId, IperlHead ihead, WaterMeter wm, ref string resultStr) { if (ihead.CommFailed) return CommErr.CommFailed; @@ -1783,7 +1787,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication /// Water meter object /// String passed to caller /// true on success - static CommErr WriteQ2Corrections(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr, int factorLR, int factorRL) + static CommErr WriteQ2Corrections(int threadId, IperlHead ihead, WaterMeter wm, ref string resultStr, int factorLR, int factorRL) { if (ihead.CommFailed) return CommErr.CommFailed; @@ -1828,7 +1832,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication } - static CommErr InitOrReadQ2Corrections(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr) + static CommErr InitOrReadQ2Corrections(int threadId, IperlHead ihead, WaterMeter wm, ref string resultStr) { if (ihead.CommFailed) return CommErr.CommFailed; if (wm.Pruefindex == 0) return CommErr.CommFailed; /// Unknown pruefindex @@ -1892,7 +1896,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication /// Water meter object /// String passed to caller /// true on success - static CommErr Reset2HzCorrection(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr) + static CommErr Reset2HzCorrection(int threadId, IperlHead ihead, WaterMeter wm, ref string resultStr) { if (ihead.CommFailed) return CommErr.CommFailed; @@ -1950,7 +1954,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication /// Water meter object /// String passed to caller /// true on success - static CommErr CalculateAndWriteQ2Corrections(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, + static CommErr CalculateAndWriteQ2Corrections(int threadId, IperlHead ihead, WaterMeter wm, Test test, ref string resultStr, Q2CorrType q2CorrType, string restOfLine) { var args = string.IsNullOrEmpty(restOfLine) ? new string[0] : restOfLine.Split(new char[] { ' ' }); @@ -2301,7 +2305,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication /// Water meter object /// String passed to caller /// true on success - static CommErr Write2HzCorrection(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr) + static CommErr Write2HzCorrection(int threadId, IperlHead ihead, WaterMeter wm, ref string resultStr) { if (ihead.CommFailed) return CommErr.CommFailed; @@ -2371,7 +2375,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication /// Arrow direction /// String passed to caller /// true on success - static CommErr DewaRework(IperlHead ihead, Results.Entities.WaterMeter wm, FlowDir flowDir, ref string resultStr) + static CommErr DewaRework(IperlHead ihead, WaterMeter wm, FlowDir flowDir, ref string resultStr) { if (ihead.CommFailed) return CommErr.CommFailed; @@ -2453,7 +2457,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication /// Water meter object /// String passed to caller /// true on success - static CommErr StartTestingSealedMeter(IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr) + static CommErr StartTestingSealedMeter(IperlHead ihead, WaterMeter wm, ref string resultStr) { if (ihead.CommFailed) return CommErr.CommFailed; @@ -2523,7 +2527,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication /// Water meter object /// String passed to caller /// true on success - static CommErr EndTestingSealedMeter(IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr) + static CommErr EndTestingSealedMeter(IperlHead ihead, WaterMeter wm, ref string resultStr) { if (ihead.CommFailed) return CommErr.CommFailed; @@ -2574,7 +2578,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication } } - static CommErr GetQ2PreCorrectionsFormRest(int threadId, IperlHead ihead, Results.Entities.WaterMeter wm, ref string resultStr) + static CommErr GetQ2PreCorrectionsFormRest(int threadId, IperlHead ihead, WaterMeter wm, ref string resultStr) { if (!ProcessData.IsQ2PreCorrectionCalculated) { @@ -2601,6 +2605,27 @@ namespace TBF.Rig.TestMethods.iPerlCommunication return CommErr.None; } + static CommErr Simulate(IperlHead ihead, WaterMeter wm, ref string resultStr) + { + string[] arguments = multiTestParams[currentActivityStep].Activity.Split(new char[] { ' ' }); + + if (arguments.Length < 2 || arguments[1].ToLower() != "iperls") return CommErr.None; + + if (ihead.CommFailed) return CommErr.CommFailed; + + string[] pcbNrs = new string[] { "831232435539", "831232435562", + "831232435587", "831232432141", + "831232432497", "831232763641" }; + + if (wm.WMPosition > 0 && wm.WMPosition <= pcbNrs.Length) + { + ihead.SerialNr = wm.SerialNr = pcbNrs[wm.WMPosition - 1]; + } + + resultStr = string.Format("PCB Nr. = {0}", wm.SerialNr ?? ""); + return CommErr.None; + } + #endif /// IPERL #endregion diff --git a/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHead.cs b/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHead.cs index 76d99f765..75aa00a96 100644 --- a/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHead.cs +++ b/TBF/Rig/TestMethods/iPerlCommunication/iPerlHead/IperlHead.cs @@ -68,10 +68,17 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead { get { - if (ConfigStruct != null) return ConfigStruct.GetPcbNrString(); - else return string.Empty; + if (ConfigStruct != null) + return ConfigStruct.GetPcbNrString(); + else if (simulatedPcbNr != null) + return simulatedPcbNr; + else + return string.Empty; + } + set + { + simulatedPcbNr = value; } - set { } } public bool Disabled; @@ -152,6 +159,8 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead public double WMVolume { get { return wmVolume; } } public double WMTestTime { get { return wmTestTime; } } + string simulatedPcbNr = null; + int wmPulses; int wmRefPulses; double beginWMState; @@ -462,6 +471,8 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead Q2CorrRL = 0; Q2CorrLR = 0; + simulatedPcbNr = null; + dataStreamState = DataStreamState.Flush; currentFlowDir = InitFlowDir;