TestMethods.LeakTest : Test parameters IsPumpRunning, MaxPressureDrop and MaxMassIncrease added.

This commit is contained in:
Milan Hanajik
2019-05-29 15:31:11 +02:00
parent 6226e069eb
commit 0c72e76ecc
4 changed files with 236 additions and 64 deletions
@@ -10,6 +10,7 @@ using TBF.BenchControl;
using TBF.Boxes;
using TBF.Resources;
using TBF.UiBridge;
using TBF.BenchControl.GenericDevices;
namespace TBF.BenchControl.TestMethods.LeakTest
{
@@ -29,7 +30,25 @@ namespace TBF.BenchControl.TestMethods.LeakTest
/// </returns>
public IList<Event> Execute(Config.Entities.Test test, int repetitionNr, bool isLastRepetition, LeakTestParams testParams)
{
IList<Event> e ; /// Events from currently running operations
IScale scale = null;
if ((testParams.MaxPressureDrop != 0) && (benchPath.PressMtrDown == null))
{
Bridge.OnError(this, Strings.Missing_a_pressure_meter);
return new List<Event> { Event.ConfigurationError };
}
if (testParams.MaxMassIncrease > 0)
{
scale = outPath.Scale as IScale;
if (scale == null)
{
Bridge.OnError(this, Strings.Missing_a_scale);
return new List<Event> { Event.ConfigurationError };
}
}
IList<Event> e; /// Events from currently running operations
Event retVal = Event.Done;
Elde.ControlBoardDev cBrd = StateMachine.ControlBoard;
checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state
@@ -133,9 +152,6 @@ namespace TBF.BenchControl.TestMethods.LeakTest
pressure_set:
StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr, 0);
UpdateAllStatistics(StateMachine.Time);
startTime = StateMachine.Time;
int estimtdEndTime = startTime + testParams.DurationPMax;
@@ -154,8 +170,6 @@ namespace TBF.BenchControl.TestMethods.LeakTest
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; }
UpdateAllStatistics(StateMachine.Time);
int remainingTime = Math.Max(estimtdEndTime - StateMachine.Time, 0);
if (remainingTime > 60)
{
@@ -168,56 +182,83 @@ namespace TBF.BenchControl.TestMethods.LeakTest
}
while (e.Contains(Event.TimerBusy));
closing_valve:
//------------------------------------------------
Bridge.OnActivity(this, Strings.Closing_valve_Pump_off);
//------------------------------------------------
State.Create(string.Format("{0}({1}) : Closing the valve", test.Method, test.Name))
.AddOperation(checkUiOp)
///------------------------------------------------------
Bridge.OnActivity(this, Strings.Closing_valve_Pump_off);
///------------------------------------------------------
State.Create(string.Format("{0}({1}) : Closing the valve", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
.AddOperation(new TBF.BenchControl.Elde.SetValvesOp(cBrd, true, outPath))
.EnterState();
do {
e = StateMachine.WaitRunDevsRunOps();
.EnterState();
do {
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; }
UpdateAllStatistics(StateMachine.Time);
}
while (e.Contains(Event.ValvesBusy));
valve_closed:
if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOff();
State.Create(string.Format("{0}({1}) : Closing the valve", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
.AddOperation(cBrd.SetValvesOp(null, inPath.Pump))
.EnterState();
do {
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; }
UpdateAllStatistics(StateMachine.Time);
}
while (e.Contains(Event.ValvesBusy));
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (e.Contains(Event.ValvesBusy));
pump_is_off:
if (!testParams.IsPumpRunning)
{
/// testParams.IsPumpRunning==false => Close the pump at the beginning of the leak part of the test
TestStartTime = DateTime.Now;
startTime = StateMachine.Time;
if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOff();
State.Create(string.Format("{0}({1}) : Stopping the pump", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
.AddOperation(cBrd.SetValvesOp(null, inPath.Pump))
.EnterState();
do {
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (e.Contains(Event.ValvesBusy));
}
TestStartTime = DateTime.Now;
startTime = StateMachine.Time;
estimtdEndTime = startTime + testParams.DurationLeak;
StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr, 0);
//------------------------------------------------
StartNewStatistics(StateMachine.Time, BatchRslts.Batch.BatchNr, test.Name, repetitionNr, 0);
UpdateAllStatistics(StateMachine.Time);
if (testParams.MaxMassIncrease > 0)
{
//-----------------------------------------------------
Bridge.OnActivity(this, Strings.Measuring_the_weight);
//-----------------------------------------------------
State.Create(string.Format("{0}({1}) : Measuring the start mass", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
.AddOperation(scale.ReadStableMassOp(ref StartMass, test.MassRepeats, test.MassSpread, test.MassMethod))
.AddOperation(new Operations.TimerOp(StableMassMsrmntTimeoutSec))
.EnterState();
do {
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
if (e.Contains(Event.TimerExpired))
{
Bridge.OnError(this, Strings.Mass_measurement_timeout);
retVal = Event.RecoverableError;
goto stopTest;
}
UpdateAllStatistics(StateMachine.Time);
}
while (!e.Contains(Event.BalanceDone));
}
///------------------------------------------------
Bridge.OnActivity(this, Strings.Test_in_progress);
//------------------------------------------------
///------------------------------------------------
State.Create(string.Format("{0}({1}) : Starting the test", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
@@ -229,7 +270,7 @@ namespace TBF.BenchControl.TestMethods.LeakTest
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; }
UpdateAllStatistics(StateMachine.Time);
UpdateAllStatistics(StateMachine.Time);
int remainingTime = Math.Max(estimtdEndTime - StateMachine.Time, 0);
if (remainingTime > 60)
@@ -243,12 +284,61 @@ namespace TBF.BenchControl.TestMethods.LeakTest
}
while (e.Contains(Event.TimerBusy));
///
/// Measurement loop - end
///
if (testParams.MaxMassIncrease > 0)
{
//-----------------------------------------------------
Bridge.OnActivity(this, Strings.Measuring_the_weight);
//-----------------------------------------------------
State.Create(string.Format("{0}({1}) : Measuring the end mass", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
.AddOperation(scale.ReadStableMassOp(ref EndMass, test.MassRepeats, test.MassSpread, test.MassMethod))
.AddOperation(new Operations.TimerOp(StableMassMsrmntTimeoutSec))
.EnterState();
do {
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
if (e.Contains(Event.TimerExpired))
{
Bridge.OnError(this, Strings.Mass_measurement_timeout);
retVal = Event.RecoverableError;
goto stopTest;
}
test_completed:
UpdateAllStatistics(StateMachine.Time);
}
while (!e.Contains(Event.BalanceDone));
}
///
/// Test_completed
///
StopRecordingStatistics();
if (testParams.IsPumpRunning)
{
/// testParams.IsPumpRunning==true => Close the pump at the end of the leak part of the test
if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOff();
State.Create(string.Format("{0}({1}) : Stopping the pump", test.Method, test.Name))
.AddOperation(checkUiOp)
.AddOperations(readTempPressOps)
.AddOperation(cBrd.SetValvesOp(null, inPath.Pump))
.EnterState();
do {
e = StateMachine.WaitRunDevsRunOps();
if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; }
if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; }
}
while (e.Contains(Event.ValvesBusy));
}
//------------------------------------------------
Bridge.OnActivity(this, Strings.Test_completed);
//------------------------------------------------
@@ -266,6 +356,7 @@ namespace TBF.BenchControl.TestMethods.LeakTest
if (tstRslt != null)
{
UpdateTempPressDensAmb(tstRslt);
tstRslt.DensityDiv = 0;
/// Main results
@@ -291,6 +382,14 @@ namespace TBF.BenchControl.TestMethods.LeakTest
tstRslt.ErrorFlagsMd = (ErrorFlagsComp != null) ? (sbyte)ErrorFlagsComp.Mode : (sbyte)0;
tstRslt.ErrorFlags = 0;
bool pressureDropPassed = (testParams.MaxPressureDrop != 0) ? ((testParams.MaxPressureDrop > 0) ? (PressDownStat.First - PressDownStat.Last < testParams.MaxPressureDrop)
: (PressDownStat.First - PressDownStat.Last > testParams.MaxPressureDrop))
: true;
bool massIncreasePassed = (testParams.MaxMassIncrease > 0) ? (EndMass.Val - StartMass.Val < testParams.MaxMassIncrease) : true;
bool leakPassed = pressureDropPassed && massIncreasePassed;
for (int i = 0; i < BatchRslts.WMPositionsCount; i++)
{
if (!test.IsPartCompatible(Utils.PartNr(i + 1, BatchRslts.Batch.Compound))) continue;
@@ -303,7 +402,7 @@ namespace TBF.BenchControl.TestMethods.LeakTest
{
meterRslt.TestTime = tstRslt.TestTime;
meterRslt.Error = 0;
meterRslt.Passed = true;
meterRslt.Passed = leakPassed;
meterRslt.TestDone = true;
tstRslt.TestDone = true;
}
@@ -321,7 +420,7 @@ namespace TBF.BenchControl.TestMethods.LeakTest
{
meterRslt.TestTime = tstRslt.TestTime;
meterRslt.Error = 0;
meterRslt.Passed = true;
meterRslt.Passed = leakPassed;
}
}
@@ -331,7 +430,7 @@ namespace TBF.BenchControl.TestMethods.LeakTest
{
compoundMeterRslt.TestTime = tstRslt.TestTime;
compoundMeterRslt.Error = 0;
compoundMeterRslt.Passed = true;
compoundMeterRslt.Passed = leakPassed;
mainMeterRslt.TestDone = auxMeterRslt.TestDone = compoundMeterRslt.TestDone = true;
tstRslt.TestDone = true;
}