diff --git a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs index 6268d0750..f17c79699 100644 --- a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs +++ b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs @@ -22,6 +22,8 @@ namespace TBF.BenchControl.Sequences public override string ToString() { return "Sequences.MainSeq"; } + bool benchFilled; + int simultWithPurgingCount; Generic.IComponentCfg simultWithPurgingCfg; IList simultWithPurgingTests; @@ -78,8 +80,15 @@ namespace TBF.BenchControl.Sequences /// Constructor public MainSeq() { + benchFilled = false; + + simultWithPurgingCount = 0; + simultWithPurgingCfg = null; simultWithPurgingTests = new List(); simultWithPurgingParams = new List(); + + simultWithEvacuationCount = 0; + simultWithEvacuationCfg = null; simultWithEvacuationTests = new List(); simultWithEvacuationParams = new List(); } @@ -97,17 +106,6 @@ namespace TBF.BenchControl.Sequences IList e; Selection selection; - bool benchFilled = false; - - simultWithPurgingCount = 0; - simultWithPurgingCfg = null; - simultWithPurgingTests.Clear(); - simultWithPurgingParams.Clear(); - - simultWithEvacuationCount = 0; - simultWithEvacuationCfg = null; - simultWithEvacuationTests.Clear(); - simultWithEvacuationParams.Clear(); StateMachine.LoadProcedure(true); // TODO: Implement as an operation so that the worker thread is not blocked @@ -466,7 +464,15 @@ namespace TBF.BenchControl.Sequences selection = MakeSelection(MKSelContext.InsideProcedure); /// if (selection == Selection.PurgeBegin) goto fill_the_bench; - if (selection == Selection.PurgeEnd) goto evacuation; + if (selection == Selection.PurgeEnd) + { + switch (DoEvacuation(purgeEnd)) + { + case Event.Error: goto error; + case Event.UiCmdStop: goto stop; + default: goto select_cycle_or_test; + } + } if (selection == Selection.Break) { StateMachine.ControlBoard.ManualUIAllowed = true; @@ -950,61 +956,18 @@ namespace TBF.BenchControl.Sequences StateMachine.ControlBoard.ManualUIAllowed = true; - if (simultWithEvacuationCount > 0) + switch (DoEvacuation(purgeEnd)) { - /// Open iPerlCommunicationForm - ProcessData.RegisterReaders = StateMachine.GetMetersPath(simultWithEvacuationTests[0]).RegisterReaders; - Program.MainWnd.Invoke(new iPerlCommFormDlgt(OpenIPerlCommForm), new object[] { this, simultWithEvacuationCfg, simultWithEvacuationTests, simultWithEvacuationParams }); + case Event.Error: goto error; + case Event.UiCmdStop: goto stop; + default: break; } - - //-------------------------------------------------------- - switch (Transition(purgeEnd, TransitionContext.PurgeEnd)) - { - case Event.Error: - if (simultWithEvacuationCount > 0) CloseIPerlCommForm(); - goto error; - case Event.UiCmdStop: - if (simultWithEvacuationCount > 0) CloseIPerlCommForm(); - goto stop; - default: - break; - } - - if (simultWithEvacuationCount > 0) - { - /// - /// 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 as GenericDevices.IHasCompleted).Completed; - } - while (!completed); - } - - modelessDlg = null; - } - - benchFilled = false; - Bridge.Bench2UI(ButtonsEtc.ShowBenchEmpty); - Bridge.OnProcedureCompleted(this, new ProcedureCompletedEventArgs(StateMachine.Procedure)); + + Bridge.OnProcedureCompleted(this, new ProcedureCompletedEventArgs(StateMachine.Procedure)); goto select_procedure; + stop_within_cycle: //-------------------------------- State.Create("MainSeq : Turning IDLE -> Closing the valves") @@ -1516,5 +1479,73 @@ namespace TBF.BenchControl.Sequences simultWithEvacuationCount++; } } + + + /// + /// Executes steps of a evacuation sequence + /// + /// + /// Event.Done Transition sequence completed OK + /// Event.UiCmdStop Transition sequence interrupted by the STOP on-screen button + /// Event.Error Error (e.g. RegulValveTimeOut returned by Run() of SetRegulValvePositionOp) + /// + Event DoEvacuation(TransitionSequence purgeEnd) + { + IList e; + + if (simultWithEvacuationCount > 0) + { + /// Open iPerlCommunicationForm + ProcessData.RegisterReaders = StateMachine.GetMetersPath(simultWithEvacuationTests[0]).RegisterReaders; + Program.MainWnd.Invoke(new iPerlCommFormDlgt(OpenIPerlCommForm), new object[] { this, simultWithEvacuationCfg, simultWithEvacuationTests, simultWithEvacuationParams }); + } + + //-------------------------------------------------------- + switch (Transition(purgeEnd, TransitionContext.PurgeEnd)) + { + case Event.Error: + if (simultWithEvacuationCount > 0) CloseIPerlCommForm(); + return Event.Error; + case Event.UiCmdStop: + if (simultWithEvacuationCount > 0) CloseIPerlCommForm(); + return Event.UiCmdStop; + default: + break; + } + + if (simultWithEvacuationCount > 0) + { + /// + /// 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(); + return Event.UiCmdStop; + } + + completed = (modelessDlg as GenericDevices.IHasCompleted).Completed; + } + while (!completed); + } + + modelessDlg = null; + } + + benchFilled = false; + Bridge.Bench2UI(ButtonsEtc.ShowBenchEmpty); + + return Event.Done; + } } } diff --git a/TestBenchFramework/Properties/AssemblyInfo.cs b/TestBenchFramework/Properties/AssemblyInfo.cs index af1cd54f9..b4d233a17 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.14.595.1")] -[assembly: AssemblyFileVersion("2.14.595.1")] +[assembly: AssemblyVersion("2.14.596.1")] +[assembly: AssemblyFileVersion("2.14.596.1")]