Sequences cleaned-up
This commit is contained in:
+102
-134
@@ -23,19 +23,6 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
|
||||
|
||||
IList<Event> e; /// Events from currently running operations
|
||||
|
||||
//--------------------------------
|
||||
State.Create("FlyingStartCollectionMethod : Stopping diverter, gate, etc.")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(cBrd.StopPreviousOp())
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.UiCmdStop)) goto stopTest;
|
||||
}
|
||||
while (!e.Contains(Event.PreviousStopped));
|
||||
|
||||
|
||||
/// Notes:
|
||||
/// float timeHr = volumeLtr / (1000.0f * targetFlow);
|
||||
/// float timeSec = 3600.0f * timeHr;
|
||||
@@ -54,7 +41,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
|
||||
switch (Transition(transitionStart, "FlyingStartCollectionMethod : " + Strings.Test_start_sequence_i_n))
|
||||
{
|
||||
case Event.Error: goto error;
|
||||
case Event.UiCmdStop: goto stopTest;
|
||||
case Event.UiCmdStop: goto stopTestAndRunningWater;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -68,7 +55,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.UiCmdStop)) goto stopTest;
|
||||
if (e.Contains(Event.UiCmdStop)) goto stopTestAndRunningWater;
|
||||
}
|
||||
while (!e.Contains(Event.ValvesSet));
|
||||
}
|
||||
@@ -80,9 +67,11 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
|
||||
Entities.TestResult tstRslt = new Entities.TestResult(test, repetitionNr, Entities.MetersKind.Single);
|
||||
|
||||
|
||||
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("FlyingStartCollectionMethod : Measuring the mass of water in the tank")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(outPath.Balance.ReadMassOp(ref mass))
|
||||
@@ -91,7 +80,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.Error)) goto error;
|
||||
if (e.Contains(Event.UiCmdStop)) goto stopTest;
|
||||
if (e.Contains(Event.UiCmdStop)) goto stopTestAndRunningWater;
|
||||
}
|
||||
while (!e.Contains(Event.BalanceDone));
|
||||
|
||||
@@ -102,11 +91,13 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
|
||||
}
|
||||
}
|
||||
|
||||
// Empty the water tank
|
||||
///
|
||||
/// Empty the water tank
|
||||
///
|
||||
switch (EmptyTheTank(outPath.EmptyTankValve, outPath.Balance))
|
||||
{
|
||||
case Event.Error: goto error;
|
||||
case Event.UiCmdStop: goto stopTest;
|
||||
case Event.UiCmdStop: goto stopTestAndRunningWater;
|
||||
}
|
||||
|
||||
set_flow:
|
||||
@@ -130,7 +121,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 stopTest;
|
||||
if (e.Contains(Event.UiCmdStop)) goto stopTestAndRunningWater;
|
||||
}
|
||||
while (!e.Contains(Event.ValvesSet));
|
||||
|
||||
@@ -147,7 +138,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 stopTest;
|
||||
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;
|
||||
@@ -178,7 +169,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.Error)) goto error;
|
||||
if (e.Contains(Event.UiCmdStop)) goto stopTest;
|
||||
if (e.Contains(Event.UiCmdStop)) goto stopTestAndRunningWater;
|
||||
}
|
||||
while (!e.Contains(Event.BalanceDone));
|
||||
|
||||
@@ -198,7 +189,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.Error)) goto error;
|
||||
if (e.Contains(Event.UiCmdStop)) goto stopTest;
|
||||
if (e.Contains(Event.UiCmdStop)) goto stopTestAndRunningWater;
|
||||
}
|
||||
while (!e.Contains(Event.MeasurementStarted));
|
||||
|
||||
@@ -218,8 +209,8 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
|
||||
switch (ReadRegistersTempPressAmbient(measureOperations, true))
|
||||
{
|
||||
case Event.Error: goto error;
|
||||
case Event.UiCmdStop: goto stopTest;
|
||||
case Event.MeasurementCompleted: goto measurement_completed;
|
||||
case Event.UiCmdStop: goto stopTestAndRunningWater;
|
||||
case Event.MeasurementCompleted: goto test_completed;
|
||||
}
|
||||
|
||||
if (firstTime)
|
||||
@@ -260,7 +251,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
|
||||
}
|
||||
/// Measurement loop - end
|
||||
|
||||
measurement_completed:
|
||||
test_completed:
|
||||
|
||||
//------------------------------------------------
|
||||
Bridge.OnActivity(this, Strings.Measuring_the_weight);
|
||||
@@ -274,86 +265,60 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.Error)) goto error;
|
||||
if (e.Contains(Event.UiCmdStop)) goto stopTest;
|
||||
if (e.Contains(Event.UiCmdStop)) goto stopTestAndRunningWater;
|
||||
}
|
||||
while (!e.Contains(Event.BalanceDone));
|
||||
///
|
||||
tstRslt.MassEndRaw = endMass.Val;
|
||||
tstRslt.TimeEnd = DateTime.Now;
|
||||
|
||||
//------------------------------------------------
|
||||
Bridge.OnActivity(this, Strings.Test_completed);
|
||||
//------------------------------------------------
|
||||
cBrd.SetFMFreq(0, 0); /// Stop FM controlled pumps
|
||||
State.Create("FlyingStartCollectionMethod : 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 stopTest;
|
||||
}
|
||||
while (!e.Contains(Event.ValvesSet));
|
||||
|
||||
|
||||
//--------------------------------
|
||||
State.Create("FlyingStartCollectionMethod : Stopping diverter, gate, etc.")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(cBrd.StopPreviousOp())
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.UiCmdStop)) goto stopTest;
|
||||
}
|
||||
while (!e.Contains(Event.PreviousStopped));
|
||||
//------------------------------------------------
|
||||
Bridge.OnActivity(this, Strings.Test_completed);
|
||||
//------------------------------------------------
|
||||
|
||||
///
|
||||
/// Populate TestResult data entity with data
|
||||
/// Populate TestResult data entity with data
|
||||
///
|
||||
tstRslt.TimeEnd = DateTime.Now;
|
||||
tstRslt.TimeEnd = DateTime.Now;
|
||||
UpdateTestRsltWithAveragedData(tstRslt);
|
||||
tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections);
|
||||
tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections);
|
||||
tstRslt.MassDiff = tstRslt.MassEnd - tstRslt.MassStart;
|
||||
tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3]
|
||||
tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3]
|
||||
tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivAvrg); /// [kg/m3]
|
||||
tstRslt.Time = cBrd.TTime; /// [s] measurement time
|
||||
tstRslt.FlowMass = 3600.0f * tstRslt.MassDiff / tstRslt.Time; /// [kg/h]
|
||||
tstRslt.FlowVolume = 3600.0f * ltrPerRefPulse * cBrd.EtPulses(0) / tstRslt.Time; /// [l/h]
|
||||
tstRslt.VolumeCTV = 1.00103f * 1000.0f * tstRslt.MassDiff / tstRslt.DensityOut; /// [l] 1000.0f is because density is in [kg/m3]
|
||||
tstRslt.VolumeMaster = ltrPerRefPulse * cBrd.EtPulses(0); /// [l] volume from the master flow meter
|
||||
tstRslt.PulsesMaster = cBrd.EtPulses(0); /// Pulses of the master flow meter (test total)
|
||||
tstRslt.ConstMaster = ltrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster;
|
||||
/// Corrected master pulses per liter
|
||||
if (tstRslt.VolumeCTV <= float.Epsilon)
|
||||
{
|
||||
tstRslt.ErrorMaster = 0.1f;
|
||||
}
|
||||
else
|
||||
{
|
||||
tstRslt.ErrorMaster = 100 * (tstRslt.VolumeMaster - tstRslt.VolumeCTV) / tstRslt.VolumeCTV;
|
||||
}
|
||||
tstRslt.TimeDivStart0 = 0;
|
||||
tstRslt.TimeDivStart1 = 0;
|
||||
tstRslt.TimeDivStart2 = 0;
|
||||
tstRslt.TimeDivStart3 = 0;
|
||||
tstRslt.TimeDivStart4 = 0;
|
||||
tstRslt.TimeDivStart5 = 0;
|
||||
tstRslt.TimeDivEnd0 = 0;
|
||||
tstRslt.TimeDivEnd1 = 0;
|
||||
tstRslt.TimeDivEnd2 = 0;
|
||||
tstRslt.TimeDivEnd3 = 0;
|
||||
tstRslt.TimeDivEnd4 = 0;
|
||||
tstRslt.TimeDivEnd5 = 0;
|
||||
for (int i = 0; i < Program.WMsCount; i++)
|
||||
{
|
||||
if (sensPath.RegisterReaders[i] != null)
|
||||
{
|
||||
tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections);
|
||||
tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections);
|
||||
tstRslt.MassDiff = tstRslt.MassEnd - tstRslt.MassStart;
|
||||
tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3]
|
||||
tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3]
|
||||
tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivAvrg); /// [kg/m3]
|
||||
tstRslt.Time = cBrd.TTime; /// [s] measurement time
|
||||
tstRslt.FlowMass = 3600.0f * tstRslt.MassDiff / tstRslt.Time; /// [kg/h]
|
||||
tstRslt.FlowVolume = 3600.0f * ltrPerRefPulse * cBrd.EtPulses(0) / tstRslt.Time; /// [l/h]
|
||||
tstRslt.VolumeCTV = 1.00103f * 1000.0f * tstRslt.MassDiff / tstRslt.DensityOut; /// [l] 1000.0f is because density is in [kg/m3]
|
||||
tstRslt.VolumeMaster = ltrPerRefPulse * cBrd.EtPulses(0); /// [l] volume from the master flow meter
|
||||
tstRslt.PulsesMaster = cBrd.EtPulses(0); /// Pulses of the master flow meter (test total)
|
||||
tstRslt.ConstMaster = ltrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster;
|
||||
/// Corrected master pulses per liter
|
||||
if (tstRslt.VolumeCTV <= float.Epsilon)
|
||||
{
|
||||
tstRslt.ErrorMaster = 0.1f;
|
||||
}
|
||||
else
|
||||
{
|
||||
tstRslt.ErrorMaster = 100 * (tstRslt.VolumeMaster - tstRslt.VolumeCTV) / tstRslt.VolumeCTV;
|
||||
}
|
||||
tstRslt.TimeDivStart0 = 0;
|
||||
tstRslt.TimeDivStart1 = 0;
|
||||
tstRslt.TimeDivStart2 = 0;
|
||||
tstRslt.TimeDivStart3 = 0;
|
||||
tstRslt.TimeDivStart4 = 0;
|
||||
tstRslt.TimeDivStart5 = 0;
|
||||
tstRslt.TimeDivEnd0 = 0;
|
||||
tstRslt.TimeDivEnd1 = 0;
|
||||
tstRslt.TimeDivEnd2 = 0;
|
||||
tstRslt.TimeDivEnd3 = 0;
|
||||
tstRslt.TimeDivEnd4 = 0;
|
||||
tstRslt.TimeDivEnd5 = 0;
|
||||
for (int i = 0; i < Program.WMsCount; i++)
|
||||
{
|
||||
if (sensPath.RegisterReaders[i] != null)
|
||||
{
|
||||
tstRslt.Meters[i].SerialNr = "wm" + (i + 1).ToString();
|
||||
tstRslt.Meters[i].VolumeStart = 0; /// liter
|
||||
tstRslt.Meters[i].VolumeEnd = 0; /// liter
|
||||
@@ -376,7 +341,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
|
||||
tstRslt.Meters[i].Passed = (tstRslt.ErrLimLo <= tstRslt.Meters[i].VolumeErrorPct) && (tstRslt.Meters[i].VolumeErrorPct <= tstRslt.ErrLimHi);
|
||||
}
|
||||
}
|
||||
/// Add data - end
|
||||
/// Add data - end
|
||||
|
||||
AddOrOverwriteResult(tstRslt);
|
||||
|
||||
@@ -385,36 +350,40 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
|
||||
/// Append the results to the CSV-file
|
||||
allResults.Info(TestResult2CsvLine(tstRslt, cBrd.EtPulses(0)));
|
||||
|
||||
FluentCommon.SaveToDb(StateMachine.WtSession, tstRslt);
|
||||
FluentCommon.SaveToDb(StateMachine.WtSession, tstRslt);
|
||||
|
||||
if (++repetitionNr <= test.Repeats)
|
||||
{
|
||||
goto loop;
|
||||
}
|
||||
|
||||
///----------------------///
|
||||
/// Quit this sequence ///
|
||||
///----------------------///
|
||||
|
||||
/// Stop the pump
|
||||
State.Create("FlyingStartCollectionMethod : Test(s) completed -> Stopping the pump")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(cBrd.SetValvesOp(null, inPath.Pump))
|
||||
.AddOperation((inPath.Pump is GenericDevices.IPumpFM) ? (inPath.Pump as GenericDevices.IPumpFM).TurnOff() : null)
|
||||
.EnterState();
|
||||
do {
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.Error)) goto error;
|
||||
if (++repetitionNr <= test.Repeats)
|
||||
{
|
||||
goto loop;
|
||||
}
|
||||
while (!e.Contains(Event.ValvesSet) || ((inPath.Pump is GenericDevices.IPumpFM) && !e.Contains(Event.TurnPumpOnOffDone)));
|
||||
|
||||
|
||||
///----------------------///
|
||||
/// Quit this sequence ///
|
||||
///----------------------///
|
||||
|
||||
//--------------------------------
|
||||
State.Create("FlyingStartCollectionMethod : Stopping diverter, gate, etc.")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(cBrd.StopPreviousOp())
|
||||
.EnterState();
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.UiCmdStop)) goto stopTestAndRunningWater;
|
||||
}
|
||||
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 stopTest;
|
||||
case Event.UiCmdStop: goto stopTestAndRunningWater;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -423,35 +392,34 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(cBrd.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose))
|
||||
.EnterState();
|
||||
do {
|
||||
do
|
||||
{
|
||||
e = StateMachine.WaitRunDevsRunOps();
|
||||
if (e.Contains(Event.Error)) goto error;
|
||||
}
|
||||
while (!e.Contains(Event.ValvesSet));
|
||||
}
|
||||
|
||||
/// 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;
|
||||
|
||||
//====================================
|
||||
stopTest:
|
||||
State.Create("FlyingStartCollectionMethod : User selected STOP -> Closing the valves")
|
||||
///--------------------------------
|
||||
/// Stop the pump
|
||||
cBrd.SetFMFreq(0, 0); /// Stop FM controlled pumps
|
||||
State.Create("FlyingStartCollectionMethod : Test(s) completed -> Stopping the pump")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation((inPath != null && inPath.Pump is GenericDevices.IPumpFM) ? (inPath.Pump as GenericDevices.IPumpFM).TurnOff() : null)
|
||||
.AddOperation(cBrd.SetValvesOp(StateMachine.DefaultValvesOpen, StateMachine.DefaultValvesClose))
|
||||
.AddOperation((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.Error)) goto error;
|
||||
}
|
||||
while (!e.Contains(Event.ValvesSet));
|
||||
while (!e.Contains(Event.ValvesSet) || ((inPath.Pump is GenericDevices.IPumpFM) && !e.Contains(Event.TurnPumpOnOffDone)));
|
||||
|
||||
IList<Event> retval2 = new List<Event>();
|
||||
retval2.Add(Event.UiCmdStop);
|
||||
return retval2;
|
||||
/// 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:
|
||||
|
||||
Reference in New Issue
Block a user