iPerlCommunication simultaneously with purging, STOP button function fixed, version 1.5.106
This commit is contained in:
@@ -5,6 +5,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using log4net;
|
||||
using TBF.UiBridge;
|
||||
using TBF.BenchControl;
|
||||
using TBF.BenchControl.Operations;
|
||||
using TBF.BenchControl.GenericDevices;
|
||||
using TBF.Boxes;
|
||||
@@ -19,6 +20,39 @@ namespace TBF.BenchControl.Sequences
|
||||
public override string ToString() { return "Sequences.MainSeq"; }
|
||||
|
||||
|
||||
|
||||
System.Windows.Forms.Form modelessDlg;
|
||||
///
|
||||
delegate void iPerlCommFormDlgt(MainSeq myRef, Generic.IComponentCfg cfg, IList<Generic.ITestParams> multiTestParams);
|
||||
///
|
||||
void OpenIPerlCommForm(MainSeq myRef, Generic.IComponentCfg cfg, IList<Generic.ITestParams> multiTestParams)
|
||||
{
|
||||
/// 1st argument
|
||||
IList<GenericDevices.IWaterMeter> wMtrs = new List<GenericDevices.IWaterMeter>();
|
||||
foreach (var rr in sensPath.RegisterReaders)
|
||||
{
|
||||
if (rr is GenericDevices.IWaterMeter) wMtrs.Add(rr as GenericDevices.IWaterMeter);
|
||||
}
|
||||
|
||||
/// 2nd argument
|
||||
TestMethods.iPerlCommunication.TestMethodCfg iPerlCfg = cfg as TestMethods.iPerlCommunication.TestMethodCfg;
|
||||
|
||||
/// 3rd argument
|
||||
IList<TestMethods.iPerlCommunication.iPerlCommunicationParams> iPerlCommParams = new List<TestMethods.iPerlCommunication.iPerlCommunicationParams>();
|
||||
foreach (var tp in multiTestParams) iPerlCommParams.Add(tp as TestMethods.iPerlCommunication.iPerlCommunicationParams);
|
||||
|
||||
myRef.modelessDlg = new TestMethods.iPerlCommunication.iPerlCommunicationForm(wMtrs, iPerlCfg, iPerlCommParams);
|
||||
myRef.modelessDlg.Show();
|
||||
}
|
||||
|
||||
void CloseIPerlCommForm()
|
||||
{
|
||||
UiBridge.Bridge.OnCloseModelessForm(this, null);
|
||||
modelessDlg = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary> Constructor </summary>
|
||||
public MainSeq()
|
||||
{
|
||||
@@ -39,6 +73,10 @@ namespace TBF.BenchControl.Sequences
|
||||
Selection selection;
|
||||
bool benchFilled = false;
|
||||
|
||||
int simultWithPurgingCount = 0;
|
||||
Generic.IComponentCfg simultWithPurgingCfg;
|
||||
IList<Generic.ITestParams> simultWithPurgingParams;
|
||||
|
||||
StateMachine.LoadProcedure(true); // TODO: Implement as an operation so that the worker thread is not blocked
|
||||
|
||||
Bridge.Bench2UI(ButtonsEtc.StopBtnEn);
|
||||
@@ -211,13 +249,85 @@ namespace TBF.BenchControl.Sequences
|
||||
|
||||
fill_the_bench:
|
||||
|
||||
/// Purge - Begin
|
||||
switch (Transition(purgeBegin, TransitionContext.PurgeBegin))
|
||||
///
|
||||
/// Analyze whether there are steps (e.g. iPerl communication) to be done simultaneously with purging
|
||||
///
|
||||
simultWithPurgingCount = 0;
|
||||
simultWithPurgingCfg = null;
|
||||
simultWithPurgingParams = new List<Generic.ITestParams>();
|
||||
foreach (var test in StateMachine.Tests)
|
||||
{
|
||||
case Event.Error: goto error;
|
||||
case Event.UiCmdStop: goto stop;
|
||||
Generic.IComponent testMethodComp = TbfComponents.FindComponent(test.Method);
|
||||
|
||||
ISimultTestMethod simultTest = testMethodComp as ISimultTestMethod;
|
||||
if (simultTest == null) break;
|
||||
|
||||
sensPath = StateMachine.GetMetersPath(test);
|
||||
testMethodComp.Cfg.UpdateTestParams(test);
|
||||
|
||||
if (!simultTest.SimultWithPrevious ||
|
||||
((simultWithPurgingCount > 0) && (simultTest.Cfg != simultWithPurgingCfg)))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (simultWithPurgingCount == 0) simultWithPurgingCfg = simultTest.Cfg;
|
||||
|
||||
simultWithPurgingParams.Add(testMethodComp.Cfg.GetTestParams() as Generic.ITestParams);
|
||||
|
||||
simultWithPurgingCount++;
|
||||
}
|
||||
|
||||
if (simultWithPurgingCount > 0)
|
||||
{
|
||||
/// Make sure the entry form is closed
|
||||
if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stop;
|
||||
|
||||
OpenIPerlCommForm(this, simultWithPurgingCfg, simultWithPurgingParams);
|
||||
}
|
||||
|
||||
///
|
||||
/// Purging @ cycle start
|
||||
///
|
||||
Event evt = Transition(purgeBegin, TransitionContext.PurgeBegin);
|
||||
///
|
||||
switch (evt)
|
||||
{
|
||||
case Event.Error:
|
||||
if (simultWithPurgingCount > 0) CloseIPerlCommForm();
|
||||
goto error;
|
||||
case Event.UiCmdStop:
|
||||
if (simultWithPurgingCount > 0) CloseIPerlCommForm();
|
||||
goto stop;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
///
|
||||
/// Wait until iPerl communications are completed
|
||||
///
|
||||
bool completed = (modelessDlg is GenericDevices.IHasCompleted)
|
||||
&& (modelessDlg as GenericDevices.IHasCompleted).Completed;
|
||||
if (!completed)
|
||||
{
|
||||
State.Create("MainSeq : Wait until the entry form is closed")
|
||||
.AddOperation(checkUiOp)
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.UiCmdStop))
|
||||
{
|
||||
CloseIPerlCommForm();
|
||||
goto stop;
|
||||
}
|
||||
|
||||
completed = (modelessDlg is GenericDevices.IHasCompleted)
|
||||
&& (modelessDlg as GenericDevices.IHasCompleted).Completed;
|
||||
}
|
||||
while (!completed);
|
||||
}
|
||||
|
||||
|
||||
assume_bench_filled:
|
||||
|
||||
benchFilled = true;
|
||||
@@ -253,9 +363,11 @@ namespace TBF.BenchControl.Sequences
|
||||
if (selection == Selection.Cycle)
|
||||
{
|
||||
TimeEstimateTotal = 0;
|
||||
foreach (var test in StateMachine.Tests)
|
||||
{
|
||||
TimeEstimateTotal += (test.Repeats * (test.TstTime + 10.0f));
|
||||
for (int i = simultWithPurgingCount; i < StateMachine.Tests.Count; i++)
|
||||
{
|
||||
Entities.Test test = StateMachine.Tests[i];
|
||||
|
||||
TimeEstimateTotal += (test.Repeats * (test.TstTime + 10.0f));
|
||||
|
||||
/// Try to fetch all test paths and transitions
|
||||
/// to detect configuration errors as early as possible.
|
||||
@@ -271,18 +383,20 @@ namespace TBF.BenchControl.Sequences
|
||||
}
|
||||
|
||||
TimeEstimateBeginRpts = 0;
|
||||
foreach (var test in StateMachine.Tests)
|
||||
{
|
||||
/// Fetch the test paths and transitions
|
||||
string errorMsg;
|
||||
if (!StateMachine.GetPaths(test, out inPath, out benchPath,
|
||||
out outPath, out sensPath,
|
||||
out transitionBefore, out transitionAfter,
|
||||
out errorMsg))
|
||||
{
|
||||
UiBridge.Bridge.OnError(this, errorMsg);
|
||||
for (int i = simultWithPurgingCount; i < StateMachine.Tests.Count; i++)
|
||||
{
|
||||
Entities.Test test = StateMachine.Tests[i];
|
||||
|
||||
/// Fetch the test paths and transitions
|
||||
string errorMsg;
|
||||
if (!StateMachine.GetPaths(test, out inPath, out benchPath,
|
||||
out outPath, out sensPath,
|
||||
out transitionBefore, out transitionAfter,
|
||||
out errorMsg))
|
||||
{
|
||||
UiBridge.Bridge.OnError(this, errorMsg);
|
||||
goto select_cycle_or_test;
|
||||
}
|
||||
}
|
||||
|
||||
/// Update format for the water mass
|
||||
mass.Format = outPath.Balance.Format;
|
||||
@@ -290,20 +404,20 @@ namespace TBF.BenchControl.Sequences
|
||||
endMass.Format = outPath.Balance.Format;
|
||||
|
||||
TimeEstimateOneTest = test.TstTime + 10.0f;
|
||||
//--------------------------------------------------------------
|
||||
//--------------------------------------------------------------
|
||||
ITestMethod testMethodSequence = TbfComponents.FindComponent(test.Method) as ITestMethod;
|
||||
if (testMethodSequence != null && testMethodSequence.CanTest(StateMachine.Procedure.MetersKind))
|
||||
{
|
||||
StateMachine.LoadTestParams(test);
|
||||
|
||||
if (BenchInfo != null && sensPath.RegisterReaders != null)
|
||||
{
|
||||
foreach (var rr in sensPath.RegisterReaders)
|
||||
if (rr is WaterMeters.iPerl.WaterMeter)
|
||||
(rr as WaterMeters.iPerl.WaterMeter).BenchName = BenchInfo.TestBenchId;
|
||||
}
|
||||
if (BenchInfo != null && sensPath.RegisterReaders != null)
|
||||
{
|
||||
foreach (var rr in sensPath.RegisterReaders)
|
||||
if (rr is WaterMeters.iPerl.WaterMeter)
|
||||
(rr as WaterMeters.iPerl.WaterMeter).BenchName = BenchInfo.TestBenchId;
|
||||
}
|
||||
|
||||
e = testMethodSequence.Execute(test);
|
||||
e = testMethodSequence.Execute(test);
|
||||
|
||||
if (e.Contains(Event.ConfigurationError)) goto select_cycle_or_test;
|
||||
if (e.Contains(Event.Error)) goto error;
|
||||
|
||||
Reference in New Issue
Block a user