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:
@@ -21,17 +21,6 @@
|
||||
Warning = 0x02, /// Some settings in the user control are suspicious, can be set after user confirmation
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Passed as an argument to function executing transition sequences
|
||||
/// </summary>
|
||||
public enum TransitionContext
|
||||
{
|
||||
PurgeBegin,
|
||||
PurgeEnd,
|
||||
TestStart,
|
||||
TestEnd,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// StateMachine events (issued by operations, IOperation derived classes)
|
||||
/// </summary>
|
||||
|
||||
@@ -209,6 +209,7 @@ namespace TBF.BenchControl.Sequences
|
||||
e = testMethodSequence.Execute(test);
|
||||
|
||||
if (e.Contains(Event.Error)) goto error;
|
||||
if (e.Contains(Event.OpArgumentError)) goto config_error;
|
||||
if (e.Contains(Event.UiCmdStop)) goto stop;
|
||||
}
|
||||
|
||||
@@ -239,6 +240,7 @@ namespace TBF.BenchControl.Sequences
|
||||
e = testMethodSequence.Execute(test);
|
||||
|
||||
if (e.Contains(Event.Error)) goto error;
|
||||
if (e.Contains(Event.OpArgumentError)) goto config_error;
|
||||
if (e.Contains(Event.UiCmdStop)) goto stop;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,11 +307,28 @@ namespace TBF.BenchControl.Sequences
|
||||
return Event.Done;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Executes steps of a transition sequence.
|
||||
/// Passed as an argument to Transition(sequence, context)
|
||||
/// </summary>
|
||||
public enum TransitionContext
|
||||
{
|
||||
PurgeBegin,
|
||||
PurgeEnd,
|
||||
TestStart,
|
||||
TestEnd,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes steps of a transition sequence
|
||||
/// </summary>
|
||||
/// <param name="transitionSequence">TransitionSequence entity</param>
|
||||
/// <returns>Event.Done, Event.Error or Event.UiCmdStop</returns>
|
||||
/// <param name="context">Calling context (see above)</param>
|
||||
/// <returns>
|
||||
/// 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)
|
||||
/// </returns>
|
||||
protected Event Transition(Entities.TransitionSequence transitionSequence, TransitionContext context)
|
||||
{
|
||||
IList<Event> e;
|
||||
|
||||
@@ -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");
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Flying start mass collection method sequence for combined meter
|
||||
/// </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;
|
||||
@@ -24,32 +33,16 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
|
||||
int[] lastWMPulses = new int[Program.WMsCount];
|
||||
|
||||
IList<Event> 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
|
||||
|
||||
//====================================
|
||||
@@ -57,20 +50,22 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
|
||||
//====================================
|
||||
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,7 +115,7 @@ 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.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
}
|
||||
while (!e.Contains(Event.ValvesSet));
|
||||
|
||||
@@ -135,11 +132,14 @@ 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));
|
||||
|
||||
flow_set:
|
||||
int time = StateMachine.Time;
|
||||
float currentFlow = refFlow.Val;
|
||||
|
||||
@@ -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,12 +256,13 @@ 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));
|
||||
///
|
||||
@@ -269,31 +272,6 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
|
||||
//------------------------------------------------
|
||||
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));
|
||||
|
||||
///
|
||||
/// 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;
|
||||
}
|
||||
|
||||
|
||||
stopTest:
|
||||
|
||||
///----------------------///
|
||||
/// Quit this sequence ///
|
||||
///----------------------///
|
||||
|
||||
/// Stop the pump
|
||||
State.Create("CombinedMeters : Test(s) completed -> Closing the valves")
|
||||
State.Create("FlyingStartCollectionMethod : Stopping diverter, gate, etc.")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(cBrd.SetValvesOp(null, inPath.Pump))
|
||||
.AddOperation((inPath != null && inPath.Pump is GenericDevices.IPumpFM) ? (inPath.Pump as GenericDevices.IPumpFM).TurnOff() : null)
|
||||
.AddOperation(cBrd.StopPreviousOp())
|
||||
.EnterState();
|
||||
do {
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.Error)) goto error;
|
||||
if (e.Contains(Event.UiCmdStop)) { retVal = Event.UiCmdStop; goto stopTest; }
|
||||
}
|
||||
while (!e.Contains(Event.ValvesSet) || ((inPath.Pump is GenericDevices.IPumpFM) && !e.Contains(Event.TurnPumpOnOffDone)));
|
||||
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;
|
||||
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;
|
||||
|
||||
//====================================
|
||||
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;
|
||||
}
|
||||
while (!e.Contains(Event.ValvesSet));
|
||||
|
||||
IList<Event> retval2 = new List<Event>();
|
||||
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<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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+46
-52
@@ -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,7 +115,7 @@ 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));
|
||||
|
||||
@@ -121,9 +132,9 @@ 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.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user