S640Comm.Start/End proc. params in More section, MainSeq invokes CommForm depending on RegReader type, ver. 2.26.1768

This commit is contained in:
Milan Hanajik 2021-10-05 07:24:04 +02:00
parent 0b8d51daba
commit 4a820af389
4 changed files with 127 additions and 37 deletions

View File

@ -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<Config.Entities.Test> simultWithPurgingTests;
IList<Generic.ITestParams> simultWithPurgingParams;
Generic.IProcedureParams simultWithPurgingProcParams;
IList<Config.Entities.Test> simultWithPurgingTests;
IList<Generic.ITestParams> simultWithPurgingTestParams;
int simultWithEvacuationCount;
Generic.IComponentCfg simultWithEvacuationCfg;
IList<Config.Entities.Test> simultWithEvacuationTests;
IList<Generic.ITestParams> simultWithEvacuationParams;
Generic.IProcedureParams simultWithEvacuationProcParams;
IList<Config.Entities.Test> simultWithEvacuationTests;
IList<Generic.ITestParams> simultWithEvacuationTestParams;
System.Windows.Forms.Form modelessDlg;
///
delegate void iPerlCommFormDlgt(MainSeq myRef, Generic.IComponentCfg cfg, IList<Test> tests, IList<Generic.ITestParams> multiTestParams);
///
void OpenIPerlCommForm(MainSeq myRef, Generic.IComponentCfg cfg, IList<Test> tests, IList<Generic.ITestParams> multiTestParams)
///
delegate void CommunicationFormDlgt(MainSeq myRef, Generic.IComponentCfg cfg, Generic.IProcedureParams procParams, IList<Test> tests, IList<Generic.ITestParams> multiTestParams);
///
void OpenIPerlCommForm(MainSeq myRef, Generic.IComponentCfg cfg, Generic.IProcedureParams procParams, IList<Test> tests, IList<Generic.ITestParams> 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<Test> tests, IList<Generic.ITestParams> 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<TestMethods.S640Communication.S640Activity> activities = new List<TestMethods.S640Communication.S640Activity>();
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<Config.Entities.Test>();
simultWithPurgingParams = new List<Generic.ITestParams>();
simultWithPurgingTestParams = new List<Generic.ITestParams>();
simultWithEvacuationCount = 0;
simultWithEvacuationCfg = null;
simultWithEvacuationProcParams = null;
simultWithEvacuationTests = new List<Config.Entities.Test>();
simultWithEvacuationParams = new List<Generic.ITestParams>();
simultWithEvacuationTestParams = new List<Generic.ITestParams>();
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<IRegReader>(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;
}

View File

@ -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<IRegReader>(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;
}

View File

@ -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")]

View File

@ -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);
}