From 4a820af389a5e589b75fe0bae9687015584dbeba Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Tue, 5 Oct 2021 07:24:04 +0200 Subject: [PATCH] S640Comm.Start/End proc. params in More section, MainSeq invokes CommForm depending on RegReader type, ver. 2.26.1768 --- TBF/BenchControl/Sequences/MainSeq.cs | 113 ++++++++++++++++----- TBF/BenchControl/Sequences/MainSeqUtils.cs | 45 ++++++-- TBF/Properties/AssemblyInfo.cs | 4 +- TBF/UI/Procedures/ProcedureDlg.cs | 2 + 4 files changed, 127 insertions(+), 37 deletions(-) diff --git a/TBF/BenchControl/Sequences/MainSeq.cs b/TBF/BenchControl/Sequences/MainSeq.cs index b3b1d690c..eac4ea2b9 100644 --- a/TBF/BenchControl/Sequences/MainSeq.cs +++ b/TBF/BenchControl/Sequences/MainSeq.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Linq; using log4net; using NHibernate; using Common; @@ -28,19 +29,21 @@ namespace TBF.BenchControl.Sequences int simultWithPurgingCount; Generic.IComponentCfg simultWithPurgingCfg; - IList simultWithPurgingTests; - IList simultWithPurgingParams; + Generic.IProcedureParams simultWithPurgingProcParams; + IList simultWithPurgingTests; + IList simultWithPurgingTestParams; int simultWithEvacuationCount; Generic.IComponentCfg simultWithEvacuationCfg; - IList simultWithEvacuationTests; - IList simultWithEvacuationParams; + Generic.IProcedureParams simultWithEvacuationProcParams; + IList simultWithEvacuationTests; + IList simultWithEvacuationTestParams; System.Windows.Forms.Form modelessDlg; - /// - delegate void iPerlCommFormDlgt(MainSeq myRef, Generic.IComponentCfg cfg, IList tests, IList multiTestParams); - /// - void OpenIPerlCommForm(MainSeq myRef, Generic.IComponentCfg cfg, IList tests, IList multiTestParams) + /// + delegate void CommunicationFormDlgt(MainSeq myRef, Generic.IComponentCfg cfg, Generic.IProcedureParams procParams, IList tests, IList multiTestParams); + /// + void OpenIPerlCommForm(MainSeq myRef, Generic.IComponentCfg cfg, Generic.IProcedureParams procParams, IList tests, IList multiTestParams) { try { @@ -68,12 +71,58 @@ namespace TBF.BenchControl.Sequences log.Fatal("--------------------------------------"); } } - /// - void CloseIPerlCommForm() - { - UiBridge.Bridge.OnCloseModelessForm(this, null); - modelessDlg = null; - } + /// + void OpenS640CommForm(MainSeq myRef, Generic.IComponentCfg cfg, Generic.IProcedureParams procParams, IList tests, IList multiTestParams) + { + try + { + TestMethods.S640Communication.S640Activity activity; /// 1st argument + TBF.BenchControl.TestMethods.S640Communication.I640Cfg config; /// 2nd argument + if (cfg is TestMethods.S640Communication.S640StartCfg) + { + activity = TestMethods.S640Communication.S640Activity.Start; + config = (cfg as TestMethods.S640Communication.S640StartCfg); + } + else if (cfg is TestMethods.S640Communication.S640EndCfg) + { + activity = TestMethods.S640Communication.S640Activity.End; + config = (cfg as TestMethods.S640Communication.S640EndCfg); + } + else + { + return; + } + + /// 1st argument + IList activities = new List(); + foreach (var t in tests) + { + activities.Add(activity); + } + /// 2nd argument: as is + /// 3rd argument: as is + + myRef.modelessDlg = new TestMethods.S640Communication.S640CommForm(activities, config, procParams, tests); + myRef.modelessDlg.Show(); + } + catch (Exception e) + { + log.FatalFormat("---------------( MainSeq : OpenIperlCommForm crashed !!! )---------------"); + log.FatalFormat("Message : {0}", e.Message); + if (e.InnerException != null) + { + log.FatalFormat("InnerMessage : {0}", e.InnerException.Message); + } + log.FatalFormat("StackTrace : {0}{1}", Environment.NewLine, e.StackTrace); + log.Fatal("--------------------------------------"); + } + } + /// + void CloseCommunicationForm() + { + UiBridge.Bridge.OnCloseModelessForm(this, null); + modelessDlg = null; + } @@ -86,13 +135,15 @@ namespace TBF.BenchControl.Sequences simultWithPurgingCount = 0; simultWithPurgingCfg = null; + simultWithPurgingProcParams = null; simultWithPurgingTests = new List(); - simultWithPurgingParams = new List(); + simultWithPurgingTestParams = new List(); simultWithEvacuationCount = 0; simultWithEvacuationCfg = null; + simultWithEvacuationProcParams = null; simultWithEvacuationTests = new List(); - simultWithEvacuationParams = new List(); + simultWithEvacuationTestParams = new List(); checkUiOp = new CheckUIOp(true); /// Running in almost all states } @@ -226,7 +277,7 @@ namespace TBF.BenchControl.Sequences try { - using (ISession localSession = TBF.DB.CreateSession(Common.DBKind.Config)) + using (ISession localSession = TBF.DB.CreateSession(DBKind.Config)) { StateMachine.LoadPathsAndTransitions(localSession); } @@ -238,10 +289,10 @@ namespace TBF.BenchControl.Sequences { /// User has chosen to restore an interrupted session and necessary conditions are met - /// TODO: Repeate twice for Common.DBKind.Config and Common.DBKind.RemoteConfig + /// TODO: Repeate twice for DBKind.Config and DBKind.RemoteConfig using (ISession remoteOrLocalSession = TBF.DB.CreateSession(isRemoteIntProc ? - Common.DBKind.RemoteConfig : - Common.DBKind.Config)) + DBKind.RemoteConfig : + DBKind.Config)) { StateMachine.LoadProcedure(remoteOrLocalSession, interruptedProcedureName, isRemoteIntProc); StateMachine.LoadProcedureParams(StateMachine.Procedure); @@ -268,10 +319,10 @@ namespace TBF.BenchControl.Sequences } } - /// TODO: Repeate twice for Common.DBKind.Config and Common.DBKind.RemoteConfig + /// TODO: Repeate twice for DBKind.Config and DBKind.RemoteConfig using (ISession remoteOrLocalSession = TBF.DB.CreateSession(Bridge.SelectedProcedure.IsRemote ? - Common.DBKind.RemoteConfig : - Common.DBKind.Config)) + DBKind.RemoteConfig : + DBKind.Config)) { StateMachine.LoadProcedure(remoteOrLocalSession, Bridge.SelectedProcedure.Name, Bridge.SelectedProcedure.IsRemote, testsInside); StateMachine.LoadProcedureParams(StateMachine.Procedure); @@ -475,7 +526,15 @@ namespace TBF.BenchControl.Sequences /// Open iPerlCommunicationForm ProcessData.RegisterReaders = StateMachine.GetMetersPath(simultWithPurgingTests[0]).RegisterReaders; - Program.MainWnd.Invoke(new iPerlCommFormDlgt(OpenIPerlCommForm), new object[] { this, simultWithPurgingCfg, simultWithPurgingTests, simultWithPurgingParams }); + var firstRR = ProcessData.RegisterReaders.FirstOrDefault(x => x != null); + if (firstRR is TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead.IperlHead) + { + Program.MainWnd.Invoke(new CommunicationFormDlgt(OpenIPerlCommForm), new object[] { this, simultWithPurgingCfg, simultWithPurgingProcParams, simultWithPurgingTests, simultWithPurgingTestParams }); + } + else if (firstRR is TBF.BenchControl.RegisterReaders.S640Stream.S640Stream) + { + Program.MainWnd.Invoke(new CommunicationFormDlgt(OpenS640CommForm), new object[] { this, simultWithPurgingCfg, simultWithPurgingProcParams, simultWithPurgingTests, simultWithPurgingTestParams }); + } } /// @@ -485,10 +544,10 @@ namespace TBF.BenchControl.Sequences switch (evt) { case Event.Error: - if (simultWithPurgingCount > 0) CloseIPerlCommForm(); + if (simultWithPurgingCount > 0) CloseCommunicationForm(); goto error; case Event.UiCmdStop: - if (simultWithPurgingCount > 0) CloseIPerlCommForm(); + if (simultWithPurgingCount > 0) CloseCommunicationForm(); goto stop; default: break; @@ -513,7 +572,7 @@ namespace TBF.BenchControl.Sequences e = StateMachine.WaitRunDevsRunOps(); if (e.Contains(Event.UiCmdStop)) { - CloseIPerlCommForm(); + CloseCommunicationForm(); goto stop; } diff --git a/TBF/BenchControl/Sequences/MainSeqUtils.cs b/TBF/BenchControl/Sequences/MainSeqUtils.cs index ab776cdcd..913cec5ab 100644 --- a/TBF/BenchControl/Sequences/MainSeqUtils.cs +++ b/TBF/BenchControl/Sequences/MainSeqUtils.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Threading; using Common; using Config.Entities; @@ -696,8 +697,9 @@ namespace TBF.BenchControl.Sequences /// simultWithPurgingCount = 0; simultWithPurgingCfg = null; + simultWithPurgingProcParams = null; simultWithPurgingTests.Clear(); - simultWithPurgingParams.Clear(); + simultWithPurgingTestParams.Clear(); /// foreach (var ti in StateMachine.TestInstances) { @@ -714,6 +716,7 @@ namespace TBF.BenchControl.Sequences if (simultWithPurgingCount == 0) { simultWithPurgingCfg = simultTest.Cfg; + simultWithPurgingProcParams = simultWithPurgingCfg.GetRuntimeProcParamsProvider() as Generic.IProcedureParams; } else if (simultTest.Cfg != simultWithPurgingCfg) { @@ -721,7 +724,14 @@ namespace TBF.BenchControl.Sequences } simultWithPurgingTests.Add(ti.Test); - simultWithPurgingParams.Add(testMethodComp.Cfg.GetRuntimeTestParamsProvider().Clone() as Generic.ITestParams); + if (testMethodComp.Cfg.GetRuntimeTestParamsProvider() != null) + { + simultWithPurgingTestParams.Add(testMethodComp.Cfg.GetRuntimeTestParamsProvider().Clone() as Generic.ITestParams); + } + else + { + simultWithPurgingTestParams.Add(null); + } simultWithPurgingCount++; } @@ -730,8 +740,9 @@ namespace TBF.BenchControl.Sequences /// simultWithEvacuationCount = 0; simultWithEvacuationCfg = null; + simultWithEvacuationProcParams = null; simultWithEvacuationTests.Clear(); - simultWithEvacuationParams.Clear(); + simultWithEvacuationTestParams.Clear(); /// for (int i = StateMachine.TestInstances.Length - 1; i >= simultWithPurgingCount; i--) { @@ -750,6 +761,7 @@ namespace TBF.BenchControl.Sequences if (simultWithEvacuationCount == 0) { simultWithEvacuationCfg = simultTest.Cfg; + simultWithEvacuationProcParams = simultWithEvacuationCfg.GetRuntimeProcParamsProvider() as Generic.IProcedureParams; } else if (simultTest.Cfg != simultWithEvacuationCfg) { @@ -757,7 +769,14 @@ namespace TBF.BenchControl.Sequences } simultWithEvacuationTests.Insert(0, test); - simultWithEvacuationParams.Insert(0, testMethodComp.Cfg.GetRuntimeTestParamsProvider().Clone() as Generic.ITestParams); + if (testMethodComp.Cfg.GetRuntimeTestParamsProvider() != null) + { + simultWithEvacuationTestParams.Insert(0, testMethodComp.Cfg.GetRuntimeTestParamsProvider().Clone() as Generic.ITestParams); + } + else + { + simultWithEvacuationTestParams.Insert(0, null); + } simultWithEvacuationCount++; } } @@ -778,7 +797,17 @@ namespace TBF.BenchControl.Sequences { /// Open iPerlCommunicationForm ProcessData.RegisterReaders = StateMachine.GetMetersPath(simultWithEvacuationTests[0]).RegisterReaders; - Program.MainWnd.Invoke(new iPerlCommFormDlgt(OpenIPerlCommForm), new object[] { this, simultWithEvacuationCfg, simultWithEvacuationTests, simultWithEvacuationParams }); + var firstRR = ProcessData.RegisterReaders.FirstOrDefault(x => x != null); + if (firstRR is TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead.IperlHead) + { + Program.MainWnd.Invoke(new CommunicationFormDlgt(OpenIPerlCommForm), + new object[] { this, simultWithEvacuationCfg, simultWithEvacuationProcParams, simultWithEvacuationTests, simultWithEvacuationTestParams }); + } + else if (firstRR is TBF.BenchControl.RegisterReaders.S640Stream.S640Stream) + { + Program.MainWnd.Invoke(new CommunicationFormDlgt(OpenS640CommForm), + new object[] { this, simultWithEvacuationCfg, simultWithEvacuationProcParams, simultWithEvacuationTests, simultWithEvacuationTestParams }); + } } //-------------------------------------------------------- @@ -787,11 +816,11 @@ namespace TBF.BenchControl.Sequences switch (Transition(purgeEnd, TransitionContext.PurgeEnd)) { case Event.Error: - if (simultWithEvacuationCount > 0) CloseIPerlCommForm(); + if (simultWithEvacuationCount > 0) CloseCommunicationForm(); return Event.Error; case Event.UiCmdStop: - if (simultWithEvacuationCount > 0) CloseIPerlCommForm(); + if (simultWithEvacuationCount > 0) CloseCommunicationForm(); return Event.UiCmdStop; default: @@ -815,7 +844,7 @@ namespace TBF.BenchControl.Sequences e = StateMachine.WaitRunDevsRunOps(); if (e.Contains(Event.UiCmdStop)) { - CloseIPerlCommForm(); + CloseCommunicationForm(); return Event.UiCmdStop; } diff --git a/TBF/Properties/AssemblyInfo.cs b/TBF/Properties/AssemblyInfo.cs index 21e439a7b..e823868cb 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.26.1767.0")] -[assembly: AssemblyFileVersion("2.26.1767.0")] +[assembly: AssemblyVersion("2.26.1768.0")] +[assembly: AssemblyFileVersion("2.26.1768.0")] diff --git a/TBF/UI/Procedures/ProcedureDlg.cs b/TBF/UI/Procedures/ProcedureDlg.cs index db8132af3..edaf12b71 100644 --- a/TBF/UI/Procedures/ProcedureDlg.cs +++ b/TBF/UI/Procedures/ProcedureDlg.cs @@ -329,6 +329,8 @@ namespace TBF.UI.Procedures foreach (var cmpnt in TbfComponents) { if (cmpnt is TBF.BenchControl.Output.DB.SensusOracle.Database) other.Add(cmpnt); + if (cmpnt is TBF.BenchControl.TestMethods.S640Communication.S640Start) other.Add(cmpnt); + if (cmpnt is TBF.BenchControl.TestMethods.S640Communication.S640End) other.Add(cmpnt); if (cmpnt is TBF.BenchControl.Modbus.Easytherm.Easytherm) other.Add(cmpnt); if (cmpnt is TBF.BenchControl.Modbus.Novus.Novus) other.Add(cmpnt); }