FlyingStart...Seq and CombinedMetersSeq sequences cleaned-up:

- Stop should work OK
- Target flow is tested and config error is shown in case it's NOK
- TestEnd sequence executed on Error
This commit is contained in:
Milan Hanajik
2014-08-15 14:32:03 +02:00
parent 596667a67e
commit ea59dd0932
5 changed files with 159 additions and 212 deletions
@@ -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");
/// <summary>
/// Flying start mass collection method sequence
/// </summary>
/// <param name="test">Test entity</param>
/// <returns>
/// 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
/// </returns>
public IList<Event> Execute(Entities.Test test)
{
Elde.ControlBoardDev cBrd = StateMachine.ControlBoard;
@@ -22,6 +33,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
checkUiOp = new Operations.CheckUIOp(true);
IList<Event> 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<Event> retval = new List<Event>();
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<Event> retval3 = new List<Event>();
retval3.Add(Event.Error);
return retval3;
/// Create a list with one item 'retVal' (default is Event.Done) and return it
IList<Event> retList = new List<Event>();
retList.Add(retVal);
return retList;
}
}
}