diff --git a/TestBenchFramework/BenchControl/Events.cs b/TestBenchFramework/BenchControl/Events.cs
index 4c04c945e..4707bb9a9 100644
--- a/TestBenchFramework/BenchControl/Events.cs
+++ b/TestBenchFramework/BenchControl/Events.cs
@@ -21,17 +21,6 @@
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 db22571da..63b1a69c1 100644
--- a/TestBenchFramework/BenchControl/Sequences/MainSeq.cs
+++ b/TestBenchFramework/BenchControl/Sequences/MainSeq.cs
@@ -208,8 +208,9 @@ namespace TBF.BenchControl.Sequences
//--------------------------------------------------------------
e = testMethodSequence.Execute(test);
- if (e.Contains(Event.Error)) goto error;
- if (e.Contains(Event.UiCmdStop)) goto stop;
+ if (e.Contains(Event.Error)) goto error;
+ if (e.Contains(Event.OpArgumentError)) goto config_error;
+ if (e.Contains(Event.UiCmdStop)) goto stop;
}
TimeEstimateBeginRpts += (test.Repeats * TimeEstimateOneTest);
@@ -238,8 +239,9 @@ namespace TBF.BenchControl.Sequences
//--------------------------------------------------------------
e = testMethodSequence.Execute(test);
- if (e.Contains(Event.Error)) goto error;
- if (e.Contains(Event.UiCmdStop)) goto stop;
+ if (e.Contains(Event.Error)) goto error;
+ if (e.Contains(Event.OpArgumentError)) goto config_error;
+ if (e.Contains(Event.UiCmdStop)) goto stop;
}
}
diff --git a/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs b/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs
index 1ebb02b73..c17a19567 100644
--- a/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs
+++ b/TestBenchFramework/BenchControl/Sequences/SequenceBase.cs
@@ -204,12 +204,12 @@ namespace TBF.BenchControl.Sequences
protected static FloatBox[] WMVolumes;
protected static FloatBox[] WMErrors;
- protected static IntBox refCount = new IntBox() { Name = "RefCount" };
- protected static FloatBox refFreq = new FloatBox() { Name = "RefFreq", Format = "F2" };
- protected static FloatBox refFlow = new FloatBox() { Name = "RefFlow", Format = "F2" };
- protected static FloatBox mass = new FloatBox() { Name = "Mass", Format = "F1" };
+ protected static IntBox refCount = new IntBox() { Name = "RefCount" };
+ protected static FloatBox refFreq = new FloatBox() { Name = "RefFreq", Format = "F2" };
+ protected static FloatBox refFlow = new FloatBox() { Name = "RefFlow", Format = "F2" };
+ protected static FloatBox mass = new FloatBox() { Name = "Mass", Format = "F1" };
protected static FloatBox startMass = new FloatBox() { Name = "Start Mass", Format = "F1" };
- protected static FloatBox endMass = new FloatBox() { Name = "End Mass", Format = "F1" };
+ protected static FloatBox endMass = new FloatBox() { Name = "End Mass", Format = "F1" };
///
/// To clear process values at the beginning of each test
@@ -307,11 +307,28 @@ namespace TBF.BenchControl.Sequences
return Event.Done;
}
+
///
- /// Executes steps of a transition sequence.
+ /// Passed as an argument to Transition(sequence, context)
+ ///
+ public enum TransitionContext
+ {
+ PurgeBegin,
+ PurgeEnd,
+ TestStart,
+ TestEnd,
+ }
+
+ ///
+ /// Executes steps of a transition sequence
///
/// TransitionSequence entity
- /// Event.Done, Event.Error or Event.UiCmdStop
+ /// Calling context (see above)
+ ///
+ /// 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)
+ ///
protected Event Transition(Entities.TransitionSequence transitionSequence, TransitionContext context)
{
IList e;
diff --git a/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs b/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs
index 74d371c70..218b0f1ff 100644
--- a/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs
+++ b/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs
@@ -15,7 +15,16 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
private static readonly ILog allResults = LogManager.GetLogger("AllResults");
private static readonly ILog summaryResults = LogManager.GetLogger("SummaryResults");
-
+ ///
+ /// Flying start mass collection method sequence for combined meter
+ ///
+ /// Test entity
+ ///
+ /// Event.Done . . . . . . . OK
+ /// Event.UiCmdStop . . . . Stopped by the user using the on-screen button STOP
+ /// Event.OpArgumentError . Target flow is out of range
+ /// Event.Error . . . . . . Unspecified error
+ ///
public IList Execute(Entities.Test test)
{
Elde.ControlBoardDev cBrd = StateMachine.ControlBoard;
@@ -24,53 +33,39 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
int[] lastWMPulses = new int[Program.WMsCount];
IList e; /// Events from currently running operations
-
- //--------------------------------
- State.Create("CombinedMeters : Stopping diverter, gate, etc.")
- .AddOperation(checkUiOp)
- .AddOperation(cBrd.StopPreviousOp())
- .EnterState();
- do
- {
- e = StateMachine.WaitRunDevsRunOps();
- if (e.Contains(Event.UiCmdStop)) goto stop;
- }
- while (!e.Contains(Event.PreviousStopped));
-
+ Event retVal = Event.Done;
/// Notes:
/// float timeHr = volumeLtr / (1000.0f * targetFlow);
/// float timeSec = 3600.0f * timeHr;
- /// uint refPulses = (uint)(timeSec * (2000.0f * targetFlow / pOut.FlowMeter.NominalFlow));
+ /// int refPulses = (int)(timeSec * (2000.0f * targetFlow / pOut.FlowMeter.NominalFlow));
int totalPulses = (int)(7200.0f * test.Volume / outPath.FlowMeter.NominalFlow); /// Nominal flow in [m3/h]
float ltrPerRefPulse = outPath.FlowMeter.NominalFlow / 7200.0f; /// [ltr/pulse]
///
- /// Meters path is required for the following:
- readRegisters1 = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders, ref WMPulses, ref WMRefPulses);
- readRegisters2 = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders, ref WMPulses, ref WMRefPulses);
-
int repetitionNr = 1; /// First test: repetitionNr=1
//====================================
// Transition or SetRoute - Start
//====================================
switch (Transition(transitionStart, TransitionContext.TestStart))
- {
- case Event.Error: goto error;
- case Event.UiCmdStop: goto stop;
- }
+ {
+ case Event.Error: { retVal = Event.Error; goto stopTest; }
+ case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
+ }
//====================================
loop:
/// Start the test, initialize test results
- Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, (int)totalPulses));
+ Bridge.OnTestSelected(this, new TestSelectedEventArgs(test, repetitionNr, inPath, benchPath, outPath, sensPath, totalPulses));
Entities.TestResult tstRslt = new Entities.TestResult(test, repetitionNr, Entities.MetersKind.Combined);
- if (!test.Emptying) /// Do not skip emptying if test.Emptying==true
+ if (!test.Emptying) /// If condition met => skip measuring and force emptying
{
- //--------------------------------
+ ///
+ /// Measure the weight and skip emptying if there is enough room in the tank
+ ///
State.Create("CombinedMeters : Measuring the mass of water in the tank")
.AddOperation(checkUiOp)
.AddOperation(outPath.Balance.ReadMassOp(ref mass))
@@ -78,8 +73,8 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
do
{
e = StateMachine.WaitRunDevsRunOps();
- if (e.Contains(Event.Error)) goto error;
- if (e.Contains(Event.UiCmdStop)) goto stop;
+ if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
+ if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.BalanceDone));
@@ -90,11 +85,13 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
}
}
- // Empty the water tank
+ ///
+ /// Empty the water tank
+ ///
switch (EmptyTheTank(outPath.EmptyTankValve, outPath.Balance))
{
- case Event.Error: goto error;
- case Event.UiCmdStop: goto stop;
+ case Event.Error: { retVal = Event.Error; goto stopTest; }
+ case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
}
set_flow:
@@ -118,9 +115,9 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, cBrd, flowSetTime, progress));
- if (e.Contains(Event.UiCmdStop)) goto stop;
- }
- while (!e.Contains(Event.ValvesSet));
+ if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
+ }
+ while (!e.Contains(Event.ValvesSet));
//--------------------------------
State.Create("CombinedMeters : Setting the flow")
@@ -135,12 +132,15 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, cBrd, flowSetTime, progress));
- if (e.Contains(Event.UiCmdStop)) goto stop;
- if (e.Contains(Event.RegulValveTimeOut)) goto error;
+ if (e.Contains(Event.OpArgumentError)) { retVal = Event.OpArgumentError; goto stopTest; }
+ if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
+ if (e.Contains(Event.RegulValveTimeOut)) { retVal = Event.Error; goto stopTest; }
+ if (e.Contains(Event.Next)) goto flow_set;
}
while (!e.Contains(Event.FlowReached));
- int time = StateMachine.Time;
+ flow_set:
+ int time = StateMachine.Time;
float currentFlow = refFlow.Val;
/// Extract cameras from the current sensors path, add operations to the detection state
@@ -162,8 +162,8 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
do
{
e = StateMachine.WaitRunDevsRunOps();
- if (e.Contains(Event.Error)) goto error;
- if (e.Contains(Event.UiCmdStop)) goto stop;
+ if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
+ if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.BalanceDone));
@@ -182,18 +182,18 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
do
{
e = StateMachine.WaitRunDevsRunOps();
- if (e.Contains(Event.Error)) goto error;
- if (e.Contains(Event.UiCmdStop)) goto stop;
+ if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
+ if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.MeasurementStarted));
- ///
/// Measurement loop - preparation
- ///
+ readRegisters1 = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders, ref WMPulses, ref WMRefPulses);
+ readRegisters2 = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders, ref WMPulses, ref WMRefPulses);
queryEnd1 = cBrd.QueryMeasurementEndOp();
queryEnd2 = cBrd.QueryMeasurementEndOp();
- bool firstTime = true; /// Used to reset sums for averaging
+ bool firstTime = true; /// To reset sums for averaging
ResetAveragedData();
/// Measurement loop - begin
@@ -202,9 +202,9 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
//--------------------------------
switch(ReadRegistersTempPressAmbient(measureOperations, true))
{
- case Event.Error: goto error;
- case Event.UiCmdStop: goto stop;
- case Event.MeasurementCompleted: goto measurement_completed;
+ case Event.Error: { retVal = Event.Error; goto stopTest; }
+ case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
+ case Event.MeasurementCompleted: goto test_completed;
}
if (firstTime)
@@ -228,6 +228,9 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
refFreq.Val = cBrd.ReferenceFreq;
refFlow.Val = cBrd.ReferenceFlow;
+ tstRslt.AmbientTempAve = airTemperature.Val;
+ tstRslt.AmbientPressAve = airPressure.Val;
+ tstRslt.AmbientHumiAve = airHumidity.Val;
string logstr = string.Format("E={0} f={1} q={2}", cBrd.EtPulses(0), cBrd.ReferenceFreq,
cBrd.ReferenceFlow * outPath.FlowMeter.NominalFlow);
@@ -245,8 +248,7 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
}
/// Measurement loop - end
-
- measurement_completed:
+ test_completed:
//------------------------------------------------
Bridge.OnActivity(this, Strings.Measuring_the_weight);
@@ -254,46 +256,22 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
State.Create("CombinedMeters : Measuring the end mass")
.AddOperation(checkUiOp)
.AddOperation(outPath.Balance.ReadStableMassOp(ref endMass, 5))
+ .AddOperation(cBrd.UpdateTankWeightOp())
.EnterState();
do
{
e = StateMachine.WaitRunDevsRunOps();
- if (e.Contains(Event.Error)) goto error;
- if (e.Contains(Event.UiCmdStop)) goto stop;
+ if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
+ if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.BalanceDone));
///
tstRslt.MassEndRaw = endMass.Val;
tstRslt.TimeEnd = DateTime.Now;
- //------------------------------------------------
- Bridge.OnActivity(this, Strings.Test_completed);
- //------------------------------------------------
- State.Create("CombinedMeters : Stopping the pump")
- .AddOperation(checkUiOp)
- .AddOperation((inPath != null && inPath.Pump is GenericDevices.IPumpFM) ? (inPath.Pump as GenericDevices.IPumpFM).TurnOff() : null)
- .AddOperation(cBrd.SetValvesOp(null, inPath.Pump))
- .AddOperation(cBrd.UpdateTankWeightOp())
- .EnterState();
- do
- {
- e = StateMachine.WaitRunDevsRunOps();
- if (e.Contains(Event.UiCmdStop)) goto stop;
- }
- while (!e.Contains(Event.ValvesSet));
-
-
- //--------------------------------
- State.Create("CombinedMeters : Stopping diverter, gate, etc.")
- .AddOperation(checkUiOp)
- .AddOperation(cBrd.StopPreviousOp())
- .EnterState();
- do
- {
- e = StateMachine.WaitRunDevsRunOps();
- if (e.Contains(Event.UiCmdStop)) goto stop;
- }
- while (!e.Contains(Event.PreviousStopped));
+ //------------------------------------------------
+ Bridge.OnActivity(this, Strings.Test_completed);
+ //------------------------------------------------
///
/// Populate TestRasult data entity with data
@@ -384,75 +362,42 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
FluentCommon.SaveToDb(StateMachine.WtSession, tstRslt);
+
if (++repetitionNr <= test.Repeats)
{
goto loop;
}
- ///----------------------///
- /// Quit this sequence ///
- ///----------------------///
- /// Stop the pump
- State.Create("CombinedMeters : Test(s) completed -> Closing the valves")
- .AddOperation(checkUiOp)
- .AddOperation(cBrd.SetValvesOp(null, inPath.Pump))
- .AddOperation((inPath != null && inPath.Pump is GenericDevices.IPumpFM) ? (inPath.Pump as GenericDevices.IPumpFM).TurnOff() : null)
+ stopTest:
+
+ ///----------------------///
+ /// Quit this sequence ///
+ ///----------------------///
+
+ State.Create("FlyingStartCollectionMethod : Stopping diverter, gate, etc.")
+ .AddOperation(checkUiOp)
+ .AddOperation(cBrd.StopPreviousOp())
.EnterState();
- do {
- e = StateMachine.WaitRunDevsRunOps();
- if (e.Contains(Event.Error)) goto error;
- }
- while (!e.Contains(Event.ValvesSet) || ((inPath.Pump is GenericDevices.IPumpFM) && !e.Contains(Event.TurnPumpOnOffDone)));
+ do
+ {
+ e = StateMachine.WaitRunDevsRunOps();
+ if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
+ }
+ while (!e.Contains(Event.PreviousStopped));
- /// Transition or SetRoute - End
+ /// Transition sequence at the end of test
+ /// Prevent overwriting 'retVal' in case it was set to non-default value earlier
switch (Transition(transitionStop, TransitionContext.TestEnd))
- {
- case Event.Error: goto error;
- case Event.UiCmdStop: goto stop;
- }
-
- /// Create the return value - a list with one event Event.Done - and return
- IList retval = new List();
- retval.Add(Event.Done);
- return retval;
-
- //====================================
- stop:
-
- State.Create("CombinedMeters : User selected STOP -> Closing the valves")
- .AddOperation(checkUiOp)
- .AddOperation((inPath != null && inPath.Pump is GenericDevices.IPumpFM) ? (inPath.Pump as GenericDevices.IPumpFM).TurnOff() : null)
- .AddOperation(cBrd.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose))
- .EnterState();
- do
{
- e = StateMachine.WaitRunDevsRunOps();
- if (e.Contains(Event.Error)) goto error;
+ case Event.Error: { if (retVal == Event.Done) retVal = Event.Error; break; }
+ case Event.UiCmdStop: { if (retVal == Event.Done) retVal = Event.UiCmdStop; break; }
}
- while (!e.Contains(Event.ValvesSet));
- IList retval2 = new List();
- retval2.Add(Event.UiCmdStop);
- return retval2;
-
- //====================================
- error:
- State.Create("CombinedMeters : ERROR -> Closing the valves")
- .AddOperation(checkUiOp)
- .AddOperation((inPath != null && inPath.Pump is GenericDevices.IPumpFM) ? (inPath.Pump as GenericDevices.IPumpFM).TurnOff() : null)
- .AddOperation(cBrd.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose))
- .EnterState();
- do
- {
- e = StateMachine.WaitRunDevsRunOps();
- if (e.Contains(Event.Error)) goto error;
- }
- while (!e.Contains(Event.ValvesSet));
-
- IList retval3 = new List();
- retval3.Add(Event.Error);
- return retval3;
+ /// Create a list with one item 'retVal' (default is Event.Done) and return it
+ IList retList = new List();
+ retList.Add(retVal);
+ return retList;
}
}
}
diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs
index 30583be9c..1df12fe3d 100644
--- a/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs
+++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartCollectionMethod/FlyingStartCollectionMethodSeq.cs
@@ -2,6 +2,8 @@
using System.Collections.Generic;
using System.Text;
using log4net;
+using TBF.BenchControl;
+using TBF.Boxes;
using TBF.Resources;
using TBF.UiBridge;
@@ -13,7 +15,16 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
private static readonly ILog allResults = LogManager.GetLogger("AllResults");
private static readonly ILog summaryResults = LogManager.GetLogger("SummaryResults");
-
+ ///
+ /// Flying start mass collection method sequence
+ ///
+ /// Test entity
+ ///
+ /// Event.Done . . . . . . . OK
+ /// Event.UiCmdStop . . . . Stopped by the user using the on-screen button STOP
+ /// Event.OpArgumentError . Target flow is out of range
+ /// Event.Error . . . . . . Unspecified error
+ ///
public IList Execute(Entities.Test test)
{
Elde.ControlBoardDev cBrd = StateMachine.ControlBoard;
@@ -22,6 +33,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
checkUiOp = new Operations.CheckUIOp(true);
IList e; /// Events from currently running operations
+ Event retVal = Event.Done;
/// Notes:
/// float timeHr = volumeLtr / (1000.0f * targetFlow);
@@ -38,9 +50,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
//====================================
switch (Transition(transitionStart, TransitionContext.TestStart))
{
- case Event.Error: goto error;
- case Event.UiCmdStop: goto stopTestAndRunningWater;
- default: break;
+ case Event.Error: { retVal = Event.Error; goto stopTest; }
+ case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
}
//====================================
@@ -50,7 +61,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
Entities.TestResult tstRslt = new Entities.TestResult(test, repetitionNr, Entities.MetersKind.Single);
- if (!test.Emptying) /// If condition met skip measuring and force emptying
+ if (!test.Emptying) /// If condition met => skip measuring and force emptying
{
///
/// Measure the weight and skip emptying if there is enough room in the tank
@@ -62,8 +73,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
do
{
e = StateMachine.WaitRunDevsRunOps();
- if (e.Contains(Event.Error)) goto error;
- if (e.Contains(Event.UiCmdStop)) goto stopTestAndRunningWater;
+ if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
+ if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.BalanceDone));
@@ -79,8 +90,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
///
switch (EmptyTheTank(outPath.EmptyTankValve, outPath.Balance))
{
- case Event.Error: goto error;
- case Event.UiCmdStop: goto stopTestAndRunningWater;
+ case Event.Error: { retVal = Event.Error; goto stopTest; }
+ case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
}
set_flow:
@@ -104,14 +115,14 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, cBrd, flowSetTime, progress));
- if (e.Contains(Event.UiCmdStop)) goto stopTestAndRunningWater;
+ if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.ValvesSet));
//--------------------------------
State.Create("FlyingStartCollectionMethod : Setting the flow")
.AddOperation(checkUiOp)
- .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, refFlow, 600)) /// timeout = 10 min.
+ .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, refFlow, 600)) /// timeout = 10 min.
.EnterState();
do
{
@@ -121,10 +132,10 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
float progress = Formulas.TestProgress(flowSetTime, estFlowSetTime, test.TstTime);
Bridge.OnTestProgress(this, GetTestProgressData(test, tstRslt, cBrd, flowSetTime, progress));
- if (e.Contains(Event.UiCmdStop)) goto stopTestAndRunningWater;
- if (e.Contains(Event.OpArgumentError))
- if (e.Contains(Event.RegulValveTimeOut)) goto error;
- if (e.Contains(Event.Next)) goto flow_set;
+ if (e.Contains(Event.OpArgumentError)) { retVal = Event.OpArgumentError; goto stopTest; }
+ if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
+ if (e.Contains(Event.RegulValveTimeOut)) { retVal = Event.Error; goto stopTest; }
+ if (e.Contains(Event.Next)) goto flow_set;
}
while (!e.Contains(Event.FlowReached));
@@ -151,8 +162,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
do
{
e = StateMachine.WaitRunDevsRunOps();
- if (e.Contains(Event.Error)) goto error;
- if (e.Contains(Event.UiCmdStop)) goto stopTestAndRunningWater;
+ if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
+ if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.BalanceDone));
@@ -171,8 +182,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
do
{
e = StateMachine.WaitRunDevsRunOps();
- if (e.Contains(Event.Error)) goto error;
- if (e.Contains(Event.UiCmdStop)) goto stopTestAndRunningWater;
+ if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
+ if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.MeasurementStarted));
@@ -182,7 +193,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
queryEnd1 = cBrd.QueryMeasurementEndOp();
queryEnd2 = cBrd.QueryMeasurementEndOp();
- bool firstTime = true;
+ bool firstTime = true; /// To reset sums for averaging
ResetAveragedData();
/// Measurement loop - begin
@@ -191,8 +202,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
//--------------------------------
switch (ReadRegistersTempPressAmbient(measureOperations, true))
{
- case Event.Error: goto error;
- case Event.UiCmdStop: goto stopTestAndRunningWater;
+ case Event.Error: { retVal = Event.Error; goto stopTest; }
+ case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; }
case Event.MeasurementCompleted: goto test_completed;
}
@@ -215,11 +226,12 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
AccumulateAveragedData();
+ refFreq.Val = cBrd.ReferenceFreq;
+ refFlow.Val = cBrd.ReferenceFlow;
tstRslt.AmbientTempAve = airTemperature.Val;
tstRslt.AmbientPressAve = airPressure.Val;
tstRslt.AmbientHumiAve = airHumidity.Val;
-
string logstr = string.Format("E={0} f={1} q={2}", cBrd.EtPulses(0), cBrd.ReferenceFreq,
cBrd.ReferenceFlow * outPath.FlowMeter.NominalFlow);
for (int i = 0; i < Program.WMsCount; i++)
@@ -247,8 +259,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
do
{
e = StateMachine.WaitRunDevsRunOps();
- if (e.Contains(Event.Error)) goto error;
- if (e.Contains(Event.UiCmdStop)) goto stopTestAndRunningWater;
+ if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
+ if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.BalanceDone));
///
@@ -341,11 +353,13 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
goto loop;
}
+
+ stopTest:
+
///----------------------///
/// Quit this sequence ///
///----------------------///
- //--------------------------------
State.Create("FlyingStartCollectionMethod : Stopping diverter, gate, etc.")
.AddOperation(checkUiOp)
.AddOperation(cBrd.StopPreviousOp())
@@ -353,42 +367,22 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
do
{
e = StateMachine.WaitRunDevsRunOps();
- if (e.Contains(Event.UiCmdStop)) goto stopTestAndRunningWater;
+ if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (!e.Contains(Event.PreviousStopped));
- stopTestAndRunningWater:
-
/// Transition sequence at the end of test
+ /// Prevent overwriting 'retVal' in case it was set to non-default value earlier
switch (Transition(transitionStop, TransitionContext.TestEnd))
{
- case Event.Error: goto error;
- case Event.UiCmdStop: goto stopTestAndRunningWater;
+ case Event.Error: { if (retVal == Event.Done) retVal = Event.Error; break; }
+ case Event.UiCmdStop: { if (retVal == Event.Done) retVal = Event.UiCmdStop; break; }
}
- /// Create the return value - a list with one event Event.Done - and return
- IList retval = new List();
- retval.Add(Event.Done);
- return retval;
-
- //====================================
- error:
- cBrd.SetFMFreq(0, 0); /// Stop FM controlled pumps
- State.Create("FlyingStartCollectionMethod : ERROR -> Closing the valves")
- .AddOperation(checkUiOp)
- .AddOperation((inPath != null && inPath.Pump is GenericDevices.IPumpFM) ? (inPath.Pump as GenericDevices.IPumpFM).TurnOff() : null)
- .AddOperation(cBrd.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose))
- .EnterState();
- do
- {
- e = StateMachine.WaitRunDevsRunOps();
- if (e.Contains(Event.Error)) goto error;
- }
- while (!e.Contains(Event.ValvesSet));
-
- IList retval3 = new List();
- retval3.Add(Event.Error);
- return retval3;
+ /// Create a list with one item 'retVal' (default is Event.Done) and return it
+ IList retList = new List();
+ retList.Add(retVal);
+ return retList;
}
}
}