From 8da5512eb04b097fa5cd7c7a88fbe4668f75b9b7 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Tue, 4 Jan 2022 18:10:44 +0100 Subject: [PATCH] enum FillState in Common.Enums, FillState ProcessData.FillState introduced and used in TBF.Rig.Sequences. --- Common/Enums.cs | 11 +++++++++++ TBF/Rig/Sequences/MainSeq.cs | 12 +++++++----- TBF/Rig/Sequences/MainSeqUtils.cs | 29 +++++++++++++++-------------- TBF/Rig/Sequences/ProcessData.cs | 8 ++++++++ TBF/Rig/Sequences/SequenceBase.cs | 25 +++++++++++++++---------- 5 files changed, 56 insertions(+), 29 deletions(-) diff --git a/Common/Enums.cs b/Common/Enums.cs index e17be3110..cb9e11366 100644 --- a/Common/Enums.cs +++ b/Common/Enums.cs @@ -350,6 +350,17 @@ namespace Common Count } + /// + /// State of water filled in the test bench. + /// + public enum FillState + { + Unknown, /// Test bench fill state is unknown + Empty, /// Test bench is empty, no water + Full, /// Test bench is full of water + Count + } + public enum MeretProtocol { [Description("")] Undefined, diff --git a/TBF/Rig/Sequences/MainSeq.cs b/TBF/Rig/Sequences/MainSeq.cs index 2eeb42bb1..b86e9f85c 100644 --- a/TBF/Rig/Sequences/MainSeq.cs +++ b/TBF/Rig/Sequences/MainSeq.cs @@ -25,8 +25,6 @@ namespace TBF.Rig.Sequences public override string ToString() { return "Sequences.MainSeq"; } - bool benchFilled; - int simultWithPurgingCount; Generic.IComponentCfg simultWithPurgingCfg; Generic.IProcedureParams simultWithPurgingProcParams; @@ -132,7 +130,7 @@ namespace TBF.Rig.Sequences /// public MainSeq() { - benchFilled = false; + FillState = FillState.Unknown; simultWithPurgingCount = 0; simultWithPurgingCfg = null; @@ -521,7 +519,10 @@ namespace TBF.Rig.Sequences { goto assume_bench_filled; } - else if ((selection == Selection.Cycle && benchFilled) || (selection == Selection.RestoreBatch) || (selection == Selection.RestoreAndFixBatch) || (selection == Selection.RestoreInterruptedSession)) + else if ((selection == Selection.Cycle && FillState == FillState.Full) || + (selection == Selection.RestoreBatch) || + (selection == Selection.RestoreAndFixBatch) || + (selection == Selection.RestoreInterruptedSession)) { /// /// Always ask a question in case of a restored batch @@ -608,7 +609,7 @@ namespace TBF.Rig.Sequences assume_bench_filled: - benchFilled = true; + FillState = FillState.Full; Bridge.Bench2UI(ButtonsEtc.ShowBenchFilled); if ((selection == Selection.Cycle) || (selection == Selection.RestoreBatch) || (selection == Selection.RestoreAndFixBatch)) @@ -726,6 +727,7 @@ namespace TBF.Rig.Sequences if (selection == Selection.PurgeBegin) goto fill_the_bench; if (selection == Selection.PurgeEnd) { + FillState = FillState.Unknown; /// Enfoce evacuation switch (DoEvacuation(purgeEnd)) { case Event.Error: goto error; diff --git a/TBF/Rig/Sequences/MainSeqUtils.cs b/TBF/Rig/Sequences/MainSeqUtils.cs index 539ec6958..778a653d0 100644 --- a/TBF/Rig/Sequences/MainSeqUtils.cs +++ b/TBF/Rig/Sequences/MainSeqUtils.cs @@ -789,31 +789,32 @@ namespace TBF.Rig.Sequences var firstRR = ProcessData.RegisterReaders.FirstOrDefault(x => x != null); if (firstRR is TBF.Rig.TestMethods.iPerlCommunication.iPerlHead.IperlHead) { - Program.MainWnd.Invoke(new CommunicationFormDlgt(OpenIPerlCommForm), - new object[] { this, simultWithEvacuationCfg, simultWithEvacuationProcParams, simultWithEvacuationTests, simultWithEvacuationTestParams }); + Program.MainWnd.Invoke(new CommunicationFormDlgt(OpenIPerlCommForm), + new object[] { this, simultWithEvacuationCfg, simultWithEvacuationProcParams, simultWithEvacuationTests, simultWithEvacuationTestParams }); } else if (firstRR is TBF.Rig.RegisterReaders.S640Stream.S640Stream) { Program.MainWnd.Invoke(new CommunicationFormDlgt(OpenS640CommForm), - new object[] { this, simultWithEvacuationCfg, simultWithEvacuationProcParams, simultWithEvacuationTests, simultWithEvacuationTestParams }); + new object[] { this, simultWithEvacuationCfg, simultWithEvacuationProcParams, simultWithEvacuationTests, simultWithEvacuationTestParams }); } } //-------------------------------------------------------- - benchFilled = false; /// because evacuation sequence started - /// - switch (Transition(purgeEnd, TransitionContext.PurgeEnd)) + if (FillState != FillState.Empty) { - case Event.Error: - if (simultWithEvacuationCount > 0) CloseCommunicationForm(); - return Event.Error; + switch (Transition(purgeEnd, TransitionContext.PurgeEnd)) + { + case Event.Error: + if (simultWithEvacuationCount > 0) CloseCommunicationForm(); + return Event.Error; - case Event.UiCmdStop: - if (simultWithEvacuationCount > 0) CloseCommunicationForm(); - return Event.UiCmdStop; + case Event.UiCmdStop: + if (simultWithEvacuationCount > 0) CloseCommunicationForm(); + return Event.UiCmdStop; - default: - break; + default: + break; + } } if (simultWithEvacuationCount > 0) diff --git a/TBF/Rig/Sequences/ProcessData.cs b/TBF/Rig/Sequences/ProcessData.cs index c287befc8..7d12d5b7c 100644 --- a/TBF/Rig/Sequences/ProcessData.cs +++ b/TBF/Rig/Sequences/ProcessData.cs @@ -74,6 +74,13 @@ namespace TBF.Rig.Sequences public static IList RawTestInfos; /// Incomplete raw test infos from Oracle DB public static Results.Output.SensusTestInfo[] CompleteTestInfos; /// Complete TBF test infos obtained as a best mathch + /// + /// State of water filled in the test bench. + /// Updated by Transition(sequence, context) + /// when context == TransitionContext.PurgeBegin + /// or context == TransitionContext.PurgeEnd + /// + public static FillState FillState; static ProcessData() { @@ -85,6 +92,7 @@ namespace TBF.Rig.Sequences IsQ2PreCorrectionCalculated = false; CalculatedQ2PreCorrectionLR = 0; CalculatedQ2PreCorrectionRL = 0; + FillState = FillState.Unknown; ComponentsWithMeasuredVal = new List(); ComponentsWithSetpoint = new List(); diff --git a/TBF/Rig/Sequences/SequenceBase.cs b/TBF/Rig/Sequences/SequenceBase.cs index 18c672bfa..39725c413 100644 --- a/TBF/Rig/Sequences/SequenceBase.cs +++ b/TBF/Rig/Sequences/SequenceBase.cs @@ -380,6 +380,9 @@ namespace TBF.Rig.Sequences default: message = "Transition"; break; } + if (context == TransitionContext.PurgeBegin && FillState != FillState.Full) FillState = FillState.Unknown; + if (context == TransitionContext.PurgeEnd && FillState != FillState.Empty) FillState = FillState.Unknown; + if (transitionSequence == null) { /// @@ -393,11 +396,9 @@ namespace TBF.Rig.Sequences State.Create("SequenceBase : Transition : TestEnd - Default action") .AddOperation(checkUiOp) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DefaultValvesOpen, - StateMachine.DefaultValvesClose)) + .AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose)) .EnterState(); - do - { + do { e = StateMachine.WaitRunDevsRunOps(); if (TestAndLogUiCmdStop(e)) return Event.UiCmdStop; } @@ -445,7 +446,7 @@ namespace TBF.Rig.Sequences { ISequenceCondition seqCondition = TbfComponents.FindComponent(fields[0]) as ISequenceCondition; int condID; - if ((seqCondition != null) && int.TryParse(fields[1], out condID)) + if ((seqCondition != null) && int.TryParse(fields[1], out condID)) { conditionOperation = seqCondition.ConditionOp(condID); } @@ -643,7 +644,7 @@ namespace TBF.Rig.Sequences while (e.Contains(Event.ValvesBusy)); } } - else if ((context == TransitionContext.AfterTestWithOverlap) && (nextInPath != null) && (nextBenchPath != null) && (nextOutPath != null)) + else if (context == TransitionContext.AfterTestWithOverlap && nextInPath != null && nextBenchPath != null && nextOutPath != null) { log.WarnFormat("Transition(., context={0}), overlapped action (next flow regulation)", context); @@ -696,10 +697,14 @@ namespace TBF.Rig.Sequences if (errorFlag) return Event.Error; - else if (stopFlag) - return Event.UiCmdStop; - else - return Event.Done; + else if (stopFlag) + return Event.UiCmdStop; + else + { + if (context == TransitionContext.PurgeBegin) FillState = FillState.Full; + if (context == TransitionContext.PurgeEnd) FillState = FillState.Empty; + return Event.Done; + } }