From 596667a67ee544ab2358831d4cd6362f14765e33 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Thu, 14 Aug 2014 09:05:40 +0200 Subject: [PATCH] Default action and stopping the FM-controlled pump moved to SequenceBase.Transition(sequence, context). Sequences cleaned-up. --- TestBenchFramework/BenchControl/Events.cs | 11 + .../BenchControl/Sequences/MainSeq.cs | 4 +- .../BenchControl/Sequences/SequenceBase.cs | 225 ++++++++++++------ .../CameraRoiDetection/RoiDetectionSeq.cs | 45 +--- .../CombinedMeters/CombinedMetersSeq.cs | 45 +--- .../CombinedWithDetectionSeq.cs | 45 +--- .../FlyingStartCollectionMethodSeq.cs | 66 +---- 7 files changed, 185 insertions(+), 256 deletions(-) diff --git a/TestBenchFramework/BenchControl/Events.cs b/TestBenchFramework/BenchControl/Events.cs index 4707bb9a9..4c04c945e 100644 --- a/TestBenchFramework/BenchControl/Events.cs +++ b/TestBenchFramework/BenchControl/Events.cs @@ -21,6 +21,17 @@ Warning = 0x02, /// Some settings in the user control are suspicious, can be set after user confirmation } + /// + /// Passed as an argument to function executing transition sequences + /// + public enum TransitionContext + { + PurgeBegin, + PurgeEnd, + TestStart, + TestEnd, + } + /// /// StateMachine events (issued by operations, IOperation derived classes) /// diff --git a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs index 90902e5dc..db22571da 100644 --- a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs +++ b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs @@ -130,7 +130,7 @@ namespace TBF.BenchControl.Sequences fill_the_bench: /// Purge - Begin - switch (Transition(purgeBegin, Strings.Purging_i_n)) + switch (Transition(purgeBegin, TransitionContext.PurgeBegin)) { case Event.Error: goto error; case Event.UiCmdStop: goto stop; @@ -340,7 +340,7 @@ namespace TBF.BenchControl.Sequences } /// Purge - End - switch (Transition(purgeEnd, Strings.Emptying_i_n)) + switch (Transition(purgeEnd, TransitionContext.PurgeEnd)) { case Event.Error: goto error; case Event.UiCmdStop: goto stop; diff --git a/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs b/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs index c7c85ade0..1ebb02b73 100644 --- a/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs +++ b/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs @@ -312,92 +312,159 @@ namespace TBF.BenchControl.Sequences /// /// TransitionSequence entity /// Event.Done, Event.Error or Event.UiCmdStop - protected Event Transition(Entities.TransitionSequence transitionSequence, string message) + protected Event Transition(Entities.TransitionSequence transitionSequence, TransitionContext context) { - if (transitionSequence == null) return Event.None; - - IList transitionSteps = StateMachine.WtSession - .CreateQuery("FROM TransitionStep WHERE TransitionSequence = :tsId ORDER BY ItemNr") - .SetParameter("tsId", transitionSequence.Id) - .List(); - IList e; - int stepsCount = transitionSteps.Count; - foreach (var step in transitionSteps) + + string message; + switch (context) { - //------------------------------------------------ - Bridge.OnActivity(this, string.Format(message, transitionSequence.Name, step.ItemNr + 1, stepsCount)); - //------------------------------------------------ + case TransitionContext.PurgeBegin: message = Strings.Purging_i_n; break; + case TransitionContext.PurgeEnd: message = Strings.Emptying_i_n; break; + case TransitionContext.TestStart: message = Strings.Test_start_sequence_i_n; break; + case TransitionContext.TestEnd: message = Strings.Test_stop_sequence_i_n; break; + default: message = "Transition"; break; + } - /// Get new regulation valve positions and calculate the number of valves to change - float[] allRegvPositions = Utils.RegulValvesPositions(step); - /// - IList rvPosOperations = new List(); - for (int i = 0; i < allRegvPositions.Length; i++) - { - if (allRegvPositions[i] >= 0) /// Negative value means no position change - { - rvPosOperations.Add(RegulValves[i].SetRegulValvePositionOp( - Math.Max(0, allRegvPositions[i] - 0.05f), Math.Min(100.0f, allRegvPositions[i] + 0.05f), 60)); - } - } - int changingRVsCount = rvPosOperations.Count; /// Number of RV-s with changing position in this step - - /// Duration must be at least the number of regulation valves to change seconds - int duration = Math.Max(step.Duration, changingRVsCount); - - /// - /// The first state updates all (regular) valves and the 1st regulation valve to be changed - /// Max. one regulation valve may be controlled in each sub-step (in each state) - /// - State oneStep = State.Create(string.Format("SequenceBase.Transition() : Step {0}.1/{1}", step.ItemNr + 1, stepsCount)) - .AddOperation(checkUiOp) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(Utils.ValvesOpen(step), Utils.ValvesClose(step))) - .AddOperation(new TimerOp((changingRVsCount <= 1) ? step.Duration : 1)); - - if (changingRVsCount > 0) - { - oneStep.AddOperation(rvPosOperations[0]); - } - oneStep.EnterState(); - - do { - e = StateMachine.WaitRunDevsRunOps(); - log.InfoFormat("RV1={0}% RV2={1}% RV3={2}% RV4={3}% RV5={4}%", StateMachine.ControlBoard.RValvePosition(1), - StateMachine.ControlBoard.RValvePosition(2), StateMachine.ControlBoard.RValvePosition(3), - StateMachine.ControlBoard.RValvePosition(4), StateMachine.ControlBoard.RValvePosition(5)); - if (e.Contains(Event.Error)) return Event.Error; - if (e.Contains(Event.RegulValveTimeOut)) return Event.Error; - if (e.Contains(Event.UiCmdStop)) return Event.UiCmdStop; + if (transitionSequence == null) + { + /// + /// Default action when no transition sequence is selected + /// + if (context == TransitionContext.TestStart) + { + State.Create("SequenceBase : Transition : TestStart - Default action") + .AddOperation(checkUiOp).AddOperation(StateMachine.ControlBoard + .SetValvesOp(GenericDevices.ValveBase.Merge(inPath.ValvesOpen, benchPath.ValvesOpen, outPath.ValvesOpen), + GenericDevices.ValveBase.Merge(inPath.ValvesClose, benchPath.ValvesClose, outPath.ValvesClose))) + .EnterState(); + do { + e = StateMachine.WaitRunDevsRunOps(); + if (e.Contains(Event.UiCmdStop)) return Event.UiCmdStop; + } + while (!e.Contains(Event.ValvesSet)); } - while (!e.Contains(Event.TimerExpired)); + else if (context == TransitionContext.TestEnd) + { + State.Create("SequenceBase : Transition : TestEnd - Default action") + .AddOperation(checkUiOp).AddOperation(StateMachine.ControlBoard + .SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose)) + .EnterState(); + do { + e = StateMachine.WaitRunDevsRunOps(); + if (e.Contains(Event.UiCmdStop)) return Event.UiCmdStop; + } + while (!e.Contains(Event.ValvesSet)); + } + } + else + { + /// + /// Execute an existing transition sequence + /// + IList transitionSteps = StateMachine.WtSession + .CreateQuery("FROM TransitionStep WHERE TransitionSequence = :tsId ORDER BY ItemNr") + .SetParameter("tsId", transitionSequence.Id) + .List(); - /// - /// Additional extra states the 2nd and all subsequent regulation valves to be changed - /// Max. one regulation valve may be controlled in each sub-step (in each state) - /// - for (int j = 1; j < changingRVsCount; j++) - { - /// The first state updating all plain valves and the 1st regulation valve - /// Max. one regulation valve may change in each step - State oneStepContinued = State.Create(string.Format("SequenceBase.Transition() : Step {0}.{2}/{1}", step.ItemNr + 1, stepsCount, j+1)) - .AddOperation(checkUiOp) - .AddOperation(new TimerOp((j == changingRVsCount - 1) ? (step.Duration - changingRVsCount + 1) : 1)); - for (int k = 0; k <= j; k++) { oneStepContinued.AddOperation(rvPosOperations[k]); } - oneStepContinued.EnterState(); + int stepsCount = transitionSteps.Count; + foreach (var step in transitionSteps) + { + //------------------------------------------------ + Bridge.OnActivity(this, string.Format(message, transitionSequence.Name, step.ItemNr + 1, stepsCount)); + //------------------------------------------------ - do - { - e = StateMachine.WaitRunDevsRunOps(); - log.InfoFormat("RV1={0}% RV2={1}% RV3={2}% RV4={3}% RV5={4}%", StateMachine.ControlBoard.RValvePosition(1), - StateMachine.ControlBoard.RValvePosition(2), StateMachine.ControlBoard.RValvePosition(3), - StateMachine.ControlBoard.RValvePosition(4), StateMachine.ControlBoard.RValvePosition(5)); - if (e.Contains(Event.Error)) return Event.Error; - if (e.Contains(Event.RegulValveTimeOut)) return Event.Error; - if (e.Contains(Event.UiCmdStop)) return Event.UiCmdStop; - } - while (!e.Contains(Event.TimerExpired)); - } + /// Get new regulation valve positions and calculate the number of valves to change + float[] allRegvPositions = Utils.RegulValvesPositions(step); + /// + IList rvPosOperations = new List(); + for (int i = 0; i < allRegvPositions.Length; i++) + { + if (allRegvPositions[i] >= 0) /// Negative value means no position change + { + rvPosOperations.Add(RegulValves[i].SetRegulValvePositionOp( + Math.Max(0, allRegvPositions[i] - 0.05f), Math.Min(100.0f, allRegvPositions[i] + 0.05f), 60)); + } + } + int changingRVsCount = rvPosOperations.Count; /// Number of RV-s with changing position in this step + + /// Duration must be at least the number of regulation valves to change seconds + int duration = Math.Max(step.Duration, changingRVsCount); + + /// + /// The first state updates all (regular) valves and the 1st regulation valve to be changed + /// Max. one regulation valve may be controlled in each sub-step (in each state) + /// + State oneStep = State.Create(string.Format("SequenceBase.Transition() : Step {0}.1/{1}", step.ItemNr + 1, stepsCount)) + .AddOperation(checkUiOp) + .AddOperation(StateMachine.ControlBoard.SetValvesOp(Utils.ValvesOpen(step), Utils.ValvesClose(step))) + .AddOperation(new TimerOp((changingRVsCount <= 1) ? step.Duration : 1)); + + if (changingRVsCount > 0) + { + oneStep.AddOperation(rvPosOperations[0]); + } + oneStep.EnterState(); + + do + { + e = StateMachine.WaitRunDevsRunOps(); + log.InfoFormat("RV1={0}% RV2={1}% RV3={2}% RV4={3}% RV5={4}%", StateMachine.ControlBoard.RValvePosition(1), + StateMachine.ControlBoard.RValvePosition(2), StateMachine.ControlBoard.RValvePosition(3), + StateMachine.ControlBoard.RValvePosition(4), StateMachine.ControlBoard.RValvePosition(5)); + if (e.Contains(Event.Error)) return Event.Error; + if (e.Contains(Event.RegulValveTimeOut)) return Event.Error; + if (e.Contains(Event.UiCmdStop)) return Event.UiCmdStop; + } + while (!e.Contains(Event.TimerExpired)); + + /// + /// Additional extra states the 2nd and all subsequent regulation valves to be changed + /// Max. one regulation valve may be controlled in each sub-step (in each state) + /// + for (int j = 1; j < changingRVsCount; j++) + { + /// The first state updating all plain valves and the 1st regulation valve + /// Max. one regulation valve may change in each step + State oneStepContinued = State.Create(string.Format("SequenceBase.Transition() : Step {0}.{2}/{1}", step.ItemNr + 1, stepsCount, j + 1)) + .AddOperation(checkUiOp) + .AddOperation(new TimerOp((j == changingRVsCount - 1) ? (step.Duration - changingRVsCount + 1) : 1)); + for (int k = 0; k <= j; k++) { oneStepContinued.AddOperation(rvPosOperations[k]); } + oneStepContinued.EnterState(); + + do + { + e = StateMachine.WaitRunDevsRunOps(); + log.InfoFormat("RV1={0}% RV2={1}% RV3={2}% RV4={3}% RV5={4}%", StateMachine.ControlBoard.RValvePosition(1), + StateMachine.ControlBoard.RValvePosition(2), StateMachine.ControlBoard.RValvePosition(3), + StateMachine.ControlBoard.RValvePosition(4), StateMachine.ControlBoard.RValvePosition(5)); + if (e.Contains(Event.Error)) return Event.Error; + if (e.Contains(Event.RegulValveTimeOut)) return Event.Error; + if (e.Contains(Event.UiCmdStop)) return Event.UiCmdStop; + } + while (!e.Contains(Event.TimerExpired)); + } + } + } + + if (context == TransitionContext.TestEnd) + { + /// + /// Stop the pump at the end of test + /// + StateMachine.ControlBoard.SetFMFreq(0, 0); /// Stop FM controlled pumps + State.Create("SequenceBase : Test(s) completed -> Stopping the pump") + .AddOperation(checkUiOp) + .AddOperation((inPath.Pump is GenericDevices.IPumpFM) ? (inPath.Pump as GenericDevices.IPumpFM).TurnOff() : null) + .AddOperation(StateMachine.ControlBoard.SetValvesOp(null, inPath.Pump)) + .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) + .EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); + if (e.Contains(Event.Error)) return Event.Error; + } + while (!e.Contains(Event.ValvesSet) || ((inPath.Pump is GenericDevices.IPumpFM) && !e.Contains(Event.TurnPumpOnOffDone))); } return Event.Done; diff --git a/TestBenchFramework/BenchControl/TestMethods/CameraRoiDetection/RoiDetectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/CameraRoiDetection/RoiDetectionSeq.cs index 8a0802ce1..a3903b46f 100644 --- a/TestBenchFramework/BenchControl/TestMethods/CameraRoiDetection/RoiDetectionSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/CameraRoiDetection/RoiDetectionSeq.cs @@ -43,28 +43,10 @@ namespace TBF.BenchControl.TestMethods.CameraRoiDetection //==================================== // Transition or SetRoute - Start //==================================== - if (transitionStart != null) + switch (Transition(transitionStart, TransitionContext.TestStart)) { - switch (Transition(transitionStart, "RoiDetection : " + Strings.Test_start_sequence_i_n)) - { - case Event.Error: goto error; - case Event.UiCmdStop: goto stop; - } - } - else - { - //-------------------------------- - State.Create("RoiDetection : Setting the route") - .AddOperation(checkUiOp) - .AddOperation(cBrd.SetValvesOp(GenericDevices.ValveBase.Merge(inPath.ValvesOpen, benchPath.ValvesOpen, outPath.ValvesOpen), - GenericDevices.ValveBase.Merge(inPath.ValvesClose, benchPath.ValvesClose, outPath.ValvesClose))) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.UiCmdStop)) goto stop; - } - while (!e.Contains(Event.ValvesSet)); + case Event.Error: goto error; + case Event.UiCmdStop: goto stop; } //------------------------------------------------ @@ -170,25 +152,10 @@ namespace TBF.BenchControl.TestMethods.CameraRoiDetection while (!e.Contains(Event.ValvesSet) || ((inPath.Pump is GenericDevices.IPumpFM) && !e.Contains(Event.TurnPumpOnOffDone))); /// Transition or SetRoute - End - if (transitionStop != null) + switch (Transition(transitionStop, TransitionContext.TestEnd)) { - switch (Transition(transitionStop, "RoiDetection : " + Strings.Test_stop_sequence_i_n)) - { - case Event.Error: goto error; - case Event.UiCmdStop: goto stop; - } - } - else - { - State.Create("RoiDetection : Detection completed -> Closing the valves") - .AddOperation(checkUiOp) - .AddOperation(cBrd.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose)) - .EnterState(); - do { - e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.Error)) goto error; - } - while (!e.Contains(Event.ValvesSet)); + case Event.Error: goto error; + case Event.UiCmdStop: goto stop; } /// Create the return value: a list with one event Event.Done diff --git a/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs b/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs index 3d0ef70b0..74d371c70 100644 --- a/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs @@ -55,28 +55,10 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters //==================================== // Transition or SetRoute - Start //==================================== - if (transitionStart != null) + switch (Transition(transitionStart, TransitionContext.TestStart)) { - switch (Transition(transitionStart, "CombinedMeters : " + Strings.Test_start_sequence_i_n)) - { - case Event.Error: goto error; - case Event.UiCmdStop: goto stop; - } - } - else - { - //-------------------------------- - State.Create("CombinedMeters : Setting the route") - .AddOperation(checkUiOp) - .AddOperation(cBrd.SetValvesOp(GenericDevices.ValveBase.Merge(inPath.ValvesOpen, benchPath.ValvesOpen, outPath.ValvesOpen), - GenericDevices.ValveBase.Merge(inPath.ValvesClose, benchPath.ValvesClose, outPath.ValvesClose))) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.UiCmdStop)) goto stop; - } - while (!e.Contains(Event.ValvesSet)); + case Event.Error: goto error; + case Event.UiCmdStop: goto stop; } //==================================== @@ -424,25 +406,10 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters while (!e.Contains(Event.ValvesSet) || ((inPath.Pump is GenericDevices.IPumpFM) && !e.Contains(Event.TurnPumpOnOffDone))); /// Transition or SetRoute - End - if (transitionStop != null) + switch (Transition(transitionStop, TransitionContext.TestEnd)) { - switch (Transition(transitionStop, "CombinedMeters : " + Strings.Test_stop_sequence_i_n)) - { - case Event.Error: goto error; - case Event.UiCmdStop: goto stop; - } - } - else - { - State.Create("CombinedMeters : Test(s) completed -> Closing the valves") - .AddOperation(checkUiOp) - .AddOperation(cBrd.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose)) - .EnterState(); - do { - e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.Error)) goto error; - } - while (!e.Contains(Event.ValvesSet)); + case Event.Error: goto error; + case Event.UiCmdStop: goto stop; } /// Create the return value - a list with one event Event.Done - and return diff --git a/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs index ba4f44269..964937f1c 100644 --- a/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/CombinedWithDetection/CombinedWithDetectionSeq.cs @@ -56,28 +56,10 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection //==================================== // Transition or SetRoute - Start //==================================== - if (transitionStart != null) + switch (Transition(transitionStart, TransitionContext.TestStart)) { - switch (Transition(transitionStart, "CombinedWithDetection : " + Strings.Test_start_sequence_i_n)) - { - case Event.Error: goto error; - case Event.UiCmdStop: goto stop; - } - } - else - { - //-------------------------------- - State.Create("CombinedWithDetection : Setting the route") - .AddOperation(checkUiOp) - .AddOperation(cBrd.SetValvesOp(GenericDevices.ValveBase.Merge(inPath.ValvesOpen, benchPath.ValvesOpen, outPath.ValvesOpen), - GenericDevices.ValveBase.Merge(inPath.ValvesClose, benchPath.ValvesClose, outPath.ValvesClose))) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.UiCmdStop)) goto stop; - } - while (!e.Contains(Event.ValvesSet)); + case Event.Error: goto error; + case Event.UiCmdStop: goto stop; } //==================================== @@ -642,25 +624,10 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection while (!e.Contains(Event.ValvesSet) || ((inPath.Pump is GenericDevices.IPumpFM) && !e.Contains(Event.TurnPumpOnOffDone))); /// Transition or SetRoute - End - if (transitionStop != null) + switch (Transition(transitionStop, TransitionContext.TestEnd)) { - switch (Transition(transitionStop, "CombinedWithDetection : " + Strings.Test_stop_sequence_i_n)) - { - case Event.Error: goto error; - case Event.UiCmdStop: goto stop; - } - } - else - { - State.Create("CombinedWithDetection : Test(s) completed -> Closing the valves") - .AddOperation(checkUiOp) - .AddOperation(cBrd.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose)) - .EnterState(); - do { - e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.Error)) goto error; - } - while (!e.Contains(Event.ValvesSet)); + case Event.Error: goto error; + case Event.UiCmdStop: goto stop; } /// Create the return value - a list with one event Event.Done - and return diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs index 71af0bd23..30583be9c 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs @@ -36,28 +36,11 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod //==================================== // Transition or SetRoute - Start //==================================== - if (transitionStart != null) + switch (Transition(transitionStart, TransitionContext.TestStart)) { - switch (Transition(transitionStart, "FlyingStartCollectionMethod : " + Strings.Test_start_sequence_i_n)) - { - case Event.Error: goto error; - case Event.UiCmdStop: goto stopTestAndRunningWater; - } - } - else - { - //-------------------------------- - State.Create("FlyingStartCollectionMethod : Setting the route") - .AddOperation(checkUiOp) - .AddOperation(cBrd.SetValvesOp(GenericDevices.ValveBase.Merge(inPath.ValvesOpen, benchPath.ValvesOpen, outPath.ValvesOpen), - GenericDevices.ValveBase.Merge(inPath.ValvesClose, benchPath.ValvesClose, outPath.ValvesClose))) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.UiCmdStop)) goto stopTestAndRunningWater; - } - while (!e.Contains(Event.ValvesSet)); + case Event.Error: goto error; + case Event.UiCmdStop: goto stopTestAndRunningWater; + default: break; } //==================================== @@ -374,47 +357,14 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod } while (!e.Contains(Event.PreviousStopped)); - stopTestAndRunningWater: - ///-------------------------------- - /// Transition or SetRoute - End - if (transitionStop != null) - { - switch (Transition(transitionStop, "FlyingStartCollectionMethod : " + Strings.Test_stop_sequence_i_n)) - { - case Event.Error: goto error; - case Event.UiCmdStop: goto stopTestAndRunningWater; - } - } - else - { - State.Create("FlyingStartCollectionMethod : Test(s) completed -> Closing the valves") - .AddOperation(checkUiOp) - .AddOperation(cBrd.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose)) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.Error)) goto error; - } - while (!e.Contains(Event.ValvesSet)); - } - ///-------------------------------- - /// Stop the pump - cBrd.SetFMFreq(0, 0); /// Stop FM controlled pumps - State.Create("FlyingStartCollectionMethod : Test(s) completed -> Stopping the pump") - .AddOperation(checkUiOp) - .AddOperation((inPath.Pump is GenericDevices.IPumpFM) ? (inPath.Pump as GenericDevices.IPumpFM).TurnOff() : null) - .AddOperation(cBrd.SetValvesOp(null, inPath.Pump)) - .AddOperation(cBrd.UpdateTankWeightOp()) - .EnterState(); - do + /// Transition sequence at the end of test + switch (Transition(transitionStop, TransitionContext.TestEnd)) { - e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.Error)) goto error; + case Event.Error: goto error; + case Event.UiCmdStop: goto stopTestAndRunningWater; } - while (!e.Contains(Event.ValvesSet) || ((inPath.Pump is GenericDevices.IPumpFM) && !e.Contains(Event.TurnPumpOnOffDone))); /// Create the return value - a list with one event Event.Done - and return IList retval = new List();