From a4331c8267c7ea51d0960db39b674bf0b0b32b73 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Tue, 19 Jan 2016 17:38:09 +0100 Subject: [PATCH] Fixes occasional problem/crash for an iPearl test with Parts when iPearls are activated after 'End', version 2.1.190. --- .../BenchControl/DataEntry/iPerl/EntryForm.cs | 2 +- .../BenchControl/Sequences/MainSeq.cs | 35 +++--- .../BenchControl/Sequences/SequenceBase.cs | 2 +- .../iPerlCommunicationForm.cs | 107 +++++++++--------- .../iPerlCommunicationSeq.cs | 20 +--- TestBenchFramework/Properties/AssemblyInfo.cs | 4 +- 6 files changed, 75 insertions(+), 95 deletions(-) diff --git a/TestBenchFramework/BenchControl/DataEntry/iPerl/EntryForm.cs b/TestBenchFramework/BenchControl/DataEntry/iPerl/EntryForm.cs index 11d27c21c..07c5e9f72 100644 --- a/TestBenchFramework/BenchControl/DataEntry/iPerl/EntryForm.cs +++ b/TestBenchFramework/BenchControl/DataEntry/iPerl/EntryForm.cs @@ -13,7 +13,7 @@ namespace TBF.BenchControl.DataEntry.iPerl public class EntryForm : ComponentBase, IOperation, IDataEntry, IHasCycleBeginForm, IHasCycleEndForm, IHasWMStatesForm { private static readonly ILog log = LogManager.GetLogger(typeof(EntryForm)); - public override string ToString() { return string.Format("DataEntry.Standard24({0})", Cfg.ToString(1)); } + public override string ToString() { return string.Format("DataEntry.iPerl({0})", Cfg.ToString(1)); } readonly EntryFormCfg entryFormCfg; diff --git a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs index 3447d4651..a1baf4d0e 100644 --- a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs +++ b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs @@ -24,29 +24,22 @@ namespace TBF.BenchControl.Sequences System.Windows.Forms.Form modelessDlg; /// - delegate void iPerlCommFormDlgt(MainSeq myRef, Generic.IComponentCfg cfg, IList testNames, IList multiTestParams); + delegate void iPerlCommFormDlgt(MainSeq myRef, Generic.IComponentCfg cfg, IList tests, IList multiTestParams); /// - void OpenIPerlCommForm(MainSeq myRef, Generic.IComponentCfg cfg, IList testNames, IList multiTestParams) + void OpenIPerlCommForm(MainSeq myRef, Generic.IComponentCfg cfg, IList tests, IList multiTestParams) { try { - /// 1st argument - IList wMtrs = new List(); - foreach (var rr in sensPath.RegisterReaders) - { - if (rr is GenericDevices.IWaterMeter) wMtrs.Add(rr as GenericDevices.IWaterMeter); - } - - /// 2nd argument + /// 1nd argument TestMethods.iPerlCommunication.TestMethodCfg iPerlCfg = cfg as TestMethods.iPerlCommunication.TestMethodCfg; - /// 3rd argument: as is + /// 2rd argument: as is - /// 4th argument + /// 3th argument IList iPerlCommParams = new List(); foreach (var tp in multiTestParams) iPerlCommParams.Add(tp as TestMethods.iPerlCommunication.iPerlCommunicationParams); - myRef.modelessDlg = new TestMethods.iPerlCommunication.iPerlCommunicationForm(wMtrs, iPerlCfg, testNames, iPerlCommParams); + myRef.modelessDlg = new TestMethods.iPerlCommunication.iPerlCommunicationForm(iPerlCfg, tests, iPerlCommParams); myRef.modelessDlg.Show(); } catch (Exception e) @@ -92,12 +85,12 @@ namespace TBF.BenchControl.Sequences int simultWithPurgingCount = 0; Generic.IComponentCfg simultWithPurgingCfg = null; - IList simultWithPurgingNames = new List(); + IList simultWithPurgingTests = new List(); IList simultWithPurgingParams = new List(); int simultWithEvacuationCount = 0; Generic.IComponentCfg simultWithEvacuationCfg = null; - IList simultWithEvacuationNames = new List(); + IList simultWithEvacuationTests = new List(); IList simultWithEvacuationParams = new List(); StateMachine.LoadProcedure(true); // TODO: Implement as an operation so that the worker thread is not blocked @@ -317,7 +310,7 @@ namespace TBF.BenchControl.Sequences /// simultWithPurgingCount = 0; simultWithPurgingCfg = null; - simultWithPurgingNames.Clear(); + simultWithPurgingTests.Clear(); simultWithPurgingParams.Clear(); /// foreach (var test in StateMachine.Tests) @@ -341,7 +334,7 @@ namespace TBF.BenchControl.Sequences break; } - simultWithPurgingNames.Add(test.Name); + simultWithPurgingTests.Add(test); simultWithPurgingParams.Add(testMethodComp.Cfg.GetTestParams().Clone() as Generic.ITestParams); simultWithPurgingCount++; } @@ -351,7 +344,7 @@ namespace TBF.BenchControl.Sequences /// simultWithEvacuationCount = 0; simultWithEvacuationCfg = null; - simultWithEvacuationNames.Clear(); + simultWithEvacuationTests.Clear(); simultWithEvacuationParams.Clear(); /// for (int i = StateMachine.Tests.Count - 1; i >= simultWithPurgingCount; i--) @@ -377,7 +370,7 @@ namespace TBF.BenchControl.Sequences break; } - simultWithEvacuationNames.Insert(0, test.Name); + simultWithEvacuationTests.Insert(0, test); simultWithEvacuationParams.Insert(0, testMethodComp.Cfg.GetTestParams().Clone() as Generic.ITestParams); simultWithEvacuationCount++; } @@ -389,7 +382,7 @@ namespace TBF.BenchControl.Sequences if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stop; /// Open iPerlCommunicationForm - Program.MainWnd.Invoke(new iPerlCommFormDlgt(OpenIPerlCommForm), new object[] { this, simultWithPurgingCfg, simultWithPurgingNames, simultWithPurgingParams }); + Program.MainWnd.Invoke(new iPerlCommFormDlgt(OpenIPerlCommForm), new object[] { this, simultWithPurgingCfg, simultWithPurgingTests, simultWithPurgingParams }); } /// @@ -706,7 +699,7 @@ namespace TBF.BenchControl.Sequences if (simultWithEvacuationCount > 0) { /// Open iPerlCommunicationForm - Program.MainWnd.Invoke(new iPerlCommFormDlgt(OpenIPerlCommForm), new object[] { this, simultWithEvacuationCfg, simultWithEvacuationNames, simultWithEvacuationParams }); + Program.MainWnd.Invoke(new iPerlCommFormDlgt(OpenIPerlCommForm), new object[] { this, simultWithEvacuationCfg, simultWithEvacuationTests, simultWithEvacuationParams }); } //-------------------------------------------------------- diff --git a/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs b/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs index 7af397879..d892a3f45 100644 --- a/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs +++ b/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs @@ -67,7 +67,7 @@ namespace TBF.BenchControl.Sequences protected static BenchControl.FeedingPath inPath; protected static BenchControl.BenchPath benchPath; protected static BenchControl.OutputPath outPath; - protected static BenchControl.MetersPath sensPath; + public static BenchControl.MetersPath sensPath; protected static TransitionSequence transitionBefore; protected static TransitionSequence transitionAfter; diff --git a/TestBenchFramework/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationForm.cs b/TestBenchFramework/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationForm.cs index 3b750f7a9..10f9f4996 100644 --- a/TestBenchFramework/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationForm.cs +++ b/TestBenchFramework/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationForm.cs @@ -250,7 +250,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication bool formCompleted; /// Number of text boxes for serial numbers - public readonly int WaterMetersCount; + public int WaterMetersCount; int textBoxesCount; @@ -267,7 +267,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication /// RFID multiplexer PCB / RFID serial port and worker thread related variables /// static TestMethodCfg cfg; - static IList testNames; + static IList tests; static IList multiTestParams; @@ -368,24 +368,56 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication /// - /// Constructor with a list of watermeters. - /// Creates a list of iPerl-s, re-shuffles UI conrols and allocates 'disabled' array. + /// Constructor for one iPerlCommunication 'test' /// /// Number of text boxes for serial numbers - public iPerlCommunicationForm(IList waterMeters, TestMethodCfg cfg) + public iPerlCommunicationForm(TestMethodCfg cfg, Test test, iPerlCommunicationParams testParams) + : this() + { + iPerlCommunicationForm.cfg = cfg; + iPerlCommunicationForm.tests = new List(); + iPerlCommunicationForm.tests.Add(test); + iPerlCommunicationForm.multiTestParams = new List(); + iPerlCommunicationForm.multiTestParams.Add(testParams); + + SequenceBase.sensPath = StateMachine.GetMetersPath(test); + activityLabel.Text = testParams.Activity; + + ConstructorCommon(); + } + + /// + /// Constructor for multiple iPerlCommunication 'tests' + /// + /// Number of text boxes for serial numbers + public iPerlCommunicationForm(TestMethodCfg cfg, IList tests, IList multiTestParams) : this() { iPerlCommunicationForm.cfg = cfg; + iPerlCommunicationForm.tests = tests; + iPerlCommunicationForm.multiTestParams = multiTestParams; - this.WaterMetersCount = waterMeters.Count; - iPerlCommunicationForm.waterMeters = new List(); - /// - foreach (var wm in waterMeters) + if (multiTestParams.Count > 0) { - WaterMeters.iPerl.WaterMeter iPerl = wm as WaterMeters.iPerl.WaterMeter; - iPerlCommunicationForm.waterMeters.Add(iPerl); + SequenceBase.sensPath = StateMachine.GetMetersPath(tests[0]); + activityLabel.Text = multiTestParams[0].Activity; } + ConstructorCommon(); + } + + + void ConstructorCommon() + { + waterMeters = new List(); + foreach (var rr in SequenceBase.sensPath.RegisterReaders) + { + WaterMeters.iPerl.WaterMeter iPerl = rr as WaterMeters.iPerl.WaterMeter; + if (iPerl != null) waterMeters.Add(iPerl); + } + + WaterMetersCount = waterMeters.Count; + ShuffleTextBoxes(this.WaterMetersCount, Config.Data.LineSize); /// @@ -416,39 +448,6 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication if (iPerl.Group > lastGroup) lastGroup = iPerl.Group; } } - - - /// - /// Constructor for one iPerlCommunication 'test' - /// - /// Number of text boxes for serial numbers - public iPerlCommunicationForm(IList waterMeters, TestMethodCfg cfg, - string testName, iPerlCommunicationParams testParams) - : this(waterMeters, cfg) - { - iPerlCommunicationForm.testNames = new List(); - iPerlCommunicationForm.testNames.Add(testName); - iPerlCommunicationForm.multiTestParams = new List(); - iPerlCommunicationForm.multiTestParams.Add(testParams); - - activityLabel.Text = testParams.Activity; - } - - - /// - /// Constructor for multiple iPerlCommunication 'tests' - /// - /// Number of text boxes for serial numbers - public iPerlCommunicationForm(IList waterMeters, TestMethodCfg cfg, - IList testNames, IList multiTestParams) - : this(waterMeters, cfg) - { - iPerlCommunicationForm.testNames = testNames; - iPerlCommunicationForm.multiTestParams = multiTestParams; - - if (multiTestParams.Count > 0) activityLabel.Text = multiTestParams[0].Activity; - } - /// /// Make sure the layout of labels/text boxes on the screen @@ -546,7 +545,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication CommCompletedHandler = null; AllCompletedHandler = null; - UpdateRfidCommResult(testNames); /// TODO: Pass the test info in a correct way + UpdateRfidCommResult(tests); /// TODO: Pass the test info in a correct way TBF.UiBridge.Bridge.OnTestCompleted(this, new TBF.UiBridge.TestCompletedEventArgs(StateMachine.Tests[0].Name, 0)); @@ -600,7 +599,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication iPerlCommunicationParams testParams = multiTestParams[i]; TBF.UiBridge.TestProgressEventArgs.SetEstimatedTimes(new int[] { 0, 0, 10, 140, 0, 0, 0 }); - TBF.UiBridge.Bridge.OnTestProgress(null, new TBF.UiBridge.TestProgressEventArgs(testNames[i], Config.Entities.Progress.JustStarted)); + TBF.UiBridge.Bridge.OnTestProgress(null, new TBF.UiBridge.TestProgressEventArgs(tests[i], Config.Entities.Progress.JustStarted)); string activity = testParams.Activity; /// Current activity @@ -668,7 +667,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication break; } wmNr++; - TBF.UiBridge.Bridge.OnTestProgress(null, new TBF.UiBridge.TestProgressEventArgs(testNames[i], Config.Entities.Progress.FlowSetting)); + TBF.UiBridge.Bridge.OnTestProgress(null, new TBF.UiBridge.TestProgressEventArgs(tests[i], Config.Entities.Progress.FlowSetting)); } if (!wmFound) @@ -682,7 +681,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication if (stopWorkerThreads) break; } /// for (int group - TBF.UiBridge.Bridge.OnTestProgress(null, new TBF.UiBridge.TestProgressEventArgs(testNames[i], Config.Entities.Progress.Completed)); + TBF.UiBridge.Bridge.OnTestProgress(null, new TBF.UiBridge.TestProgressEventArgs(tests[i], Config.Entities.Progress.Completed)); activityStep++; if (stopWorkerThreads) break; @@ -1183,19 +1182,19 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication /// Update test result representing RFID communication success/failure /// /// - void UpdateRfidCommResult(IList testNames) + void UpdateRfidCommResult(IList tests) { DateTime endTime = DateTime.Now; int testTime = StateMachine.Time - startTimeSec; - if (!testNames.Contains(StateMachine.Tests[0].Name)) + if (!tests.Contains(StateMachine.Tests[0])) { - testNames.Insert(0, StateMachine.Tests[0].Name); /// Add RFID test as th 1st item + tests.Insert(0, StateMachine.Tests[0]); /// Add RFID test as the 1st item } - foreach (var testName in testNames) + foreach (var test in tests) { - Results.Entities.TestRslt tstRslt = ProcessData.BatchRslts.GetTestRslt(testName, 0); + Results.Entities.TestRslt tstRslt = ProcessData.BatchRslts.GetTestRslt(test.Name, test.Part); if (tstRslt != null) { @@ -1210,7 +1209,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication for (int i = 0; i < Math.Min(ProcessData.BatchRslts.WMPositionsCount, waterMeters.Count); i++) { Results.Entities.MeterTestRslt meterRslt = - ProcessData.BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single); + ProcessData.BatchRslts.GetMeterTestRslt(test.Name, i, Config.Entities.CompoundMeterId.Single); WaterMeters.iPerl.WaterMeter iPerl = waterMeters[i] as WaterMeters.iPerl.WaterMeter; diff --git a/TestBenchFramework/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationSeq.cs b/TestBenchFramework/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationSeq.cs index 2578b3d31..87f532d2b 100644 --- a/TestBenchFramework/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationSeq.cs @@ -21,23 +21,11 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication System.Windows.Forms.Form modelessDlg; /// - delegate void iPerlCommFormDlgt(iPerlCommunicationSeq myRef, TestMethodCfg cfg, string testName, iPerlCommunicationParams testParams); + delegate void iPerlCommFormDlgt(iPerlCommunicationSeq myRef, TestMethodCfg cfg, Test test, iPerlCommunicationParams testParams); /// - void OpenIPerlCommForm(iPerlCommunicationSeq myRef, TestMethodCfg cfg, string testName, iPerlCommunicationParams testParams) + void OpenIPerlCommForm(iPerlCommunicationSeq myRef, TestMethodCfg cfg, Test test, iPerlCommunicationParams testParams) { - StringBuilder sb = new StringBuilder(); - IList wMtrs = new List(); - foreach (var rr in sensPath.RegisterReaders) - { - if (rr is GenericDevices.IWaterMeter) - { - GenericDevices.IWaterMeter wm = rr as GenericDevices.IWaterMeter; - wMtrs.Add(wm); - sb.AppendFormat(" {0}", wm.Name); - } - } - log.ErrorFormat("OpenIPerlCommForm(wms:{0})", sb); - myRef.modelessDlg = new iPerlCommunicationForm(WaterMeters, cfg, testName, testParams); + myRef.modelessDlg = new iPerlCommunicationForm(cfg, test, testParams); myRef.modelessDlg.Show(); } @@ -135,7 +123,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication /// /// Show the modeless dialog with error indication /// - Program.MainWnd.Invoke(new iPerlCommFormDlgt(OpenIPerlCommForm), new object[] { this, cfg, test.Name, testParams }); + Program.MainWnd.Invoke(new iPerlCommFormDlgt(OpenIPerlCommForm), new object[] { this, cfg, test, testParams }); //------------------------------------------------ Bridge.OnActivity(this, Strings.iPerl_Communication_in_progress); diff --git a/TestBenchFramework/Properties/AssemblyInfo.cs b/TestBenchFramework/Properties/AssemblyInfo.cs index 5ef2aecb6..9a31382e3 100644 --- a/TestBenchFramework/Properties/AssemblyInfo.cs +++ b/TestBenchFramework/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("2.1.188.1")] -[assembly: AssemblyFileVersion("2.1.188.1")] +[assembly: AssemblyVersion("2.1.190.1")] +[assembly: AssemblyFileVersion("2.1.190.1")]