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
@@ -1,9 +1,8 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Copyright (c) 2013-2019 Sensus Slovensko a.s.
///
using System;
using System.IO;
using System.Text;
using System.Xml.Serialization;
using Config.Entities;
using TBF.BenchControl.Generic;
@@ -16,17 +15,23 @@ namespace TBF.BenchControl.TestMethods.LeakTest
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(LeakTestParams) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public float PressureLo; /// Presure range low limit in [bar]
public float PressureHi; /// Presure range high limit in [bar]
public int DurationPMax; /// Duration of PMax test in [s]
public int DurationLeak; /// Duration of Leak test in [s]
public float PressureLo; /// [bar] Presure range low limit
public float PressureHi; /// [bar] Presure range high limit
public int DurationPMax; /// [s] Duration of PMax test
public int DurationLeak; /// [s] Duration of Leak test
public bool IsPumpRunning; /// true = pump is running during complete test
public float MaxPressureDrop; /// [bar] Max. drop of pressure at the end of test, 0 disables pressure drop test
public float MaxMassIncrease; /// [kg] Max. increase of the mass on the scale at the end of test, 0 disables mass increase test
public override void InitializeAll()
{
PressureLo = 5.0f; /// [bar]
PressureHi = 6.0f; /// [bar]
DurationPMax = 10;
DurationLeak = 60;
DurationPMax = 10; /// [s]
DurationLeak = 60; /// [s]
IsPumpRunning = false;
MaxPressureDrop = 0; /// [bar]
MaxMassIncrease = 0; /// [kg]
}
@@ -36,6 +41,10 @@ namespace TBF.BenchControl.TestMethods.LeakTest
Strings.Pressure_hi_bar,
Strings.Duration_PMax_s,
Strings.Duration_Leak_s,
Strings.Pump_is_running,
Strings.Max_pressure_drop_bar,
Strings.Max_mass_increase_kg,
};
public override string ParamName(int i) { return paramNames[i]; }
public override int ParamsCount() { return paramNames.Length; }
@@ -44,10 +53,13 @@ namespace TBF.BenchControl.TestMethods.LeakTest
{
switch (i)
{
case 0: return PressureLo.ToString(); /// [bar]
case 1: return PressureHi.ToString(); /// [bar]
case 0: return PressureLo.ToString();
case 1: return PressureHi.ToString();
case 2: return DurationPMax.ToString();
case 3: return DurationLeak.ToString();
case 4: return IsPumpRunning ? Strings.yes : Strings.no;
case 5: return MaxPressureDrop.ToString();
case 6: return MaxMassIncrease.ToString();
default: return string.Empty;
}
}
@@ -57,9 +69,12 @@ namespace TBF.BenchControl.TestMethods.LeakTest
switch (i)
{
case 0: PressureLo = Utils.ParseUFloat(strValue); return CfgUpdateFlags.None;
case 1: PressureHi = Utils.ParseSFloat(strValue); return CfgUpdateFlags.None;
case 1: PressureHi = Utils.ParseUFloat(strValue); return CfgUpdateFlags.None;
case 2: DurationPMax = int.Parse(strValue); return CfgUpdateFlags.None;
case 3: DurationLeak = int.Parse(strValue); return CfgUpdateFlags.None;
case 4: IsPumpRunning = strValue.Equals(Strings.yes); return CfgUpdateFlags.None;
case 5: MaxPressureDrop = Utils.ParseSFloat(strValue); return CfgUpdateFlags.None;
case 6: MaxMassIncrease = Utils.ParseUFloat(strValue); return CfgUpdateFlags.None;
default: return CfgUpdateFlags.None;
}
}
@@ -74,13 +89,20 @@ namespace TBF.BenchControl.TestMethods.LeakTest
{
case 0:
case 1:
if (Utils.TryParseUFloat(strValue, out dummy)) return true;
case 6:
if (Utils.TryParseUFloat(strValue, out dummy)) return true;
break;
case 2:
case 3:
if (int.TryParse(strValue, out iDummy)) return true;
break;
default:
case 4:
if (strValue.Equals(Strings.yes) || strValue.Equals(Strings.no)) return true;
break;
case 5:
if (Utils.TryParseSFloat(strValue, out dummy)) return true;
break;
default:
message = "Invalid index";
return false;
}
@@ -95,6 +117,9 @@ namespace TBF.BenchControl.TestMethods.LeakTest
prms.PressureHi = this.PressureHi;
prms.DurationPMax = this.DurationPMax;
prms.DurationLeak = this.DurationLeak;
prms.IsPumpRunning = this.IsPumpRunning;
prms.MaxPressureDrop = this.MaxPressureDrop;
prms.MaxMassIncrease = this.MaxMassIncrease;
}
public IParamsProvider Clone()
@@ -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;
}
+36
View File
@@ -2364,6 +2364,24 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Max. mass increase [kg].
/// </summary>
internal static string Max_mass_increase_kg {
get {
return ResourceManager.GetString("Max_mass_increase_kg", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Max. pressure drop [bar].
/// </summary>
internal static string Max_pressure_drop_bar {
get {
return ResourceManager.GetString("Max_pressure_drop_bar", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to (max. _X_ alphanumeric characters).
/// </summary>
@@ -2526,6 +2544,15 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Missing a pressure meter.
/// </summary>
internal static string Missing_a_pressure_meter {
get {
return ResourceManager.GetString("Missing_a_pressure_meter", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Missing a scale.
/// </summary>
@@ -3462,6 +3489,15 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Pump is running.
/// </summary>
internal static string Pump_is_running {
get {
return ResourceManager.GetString("Pump_is_running", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Pump power [%].
/// </summary>
+12
View File
@@ -1990,4 +1990,16 @@
<data name="Evaporation" xml:space="preserve">
<value>Evaporation</value>
</data>
<data name="Max_mass_increase_kg" xml:space="preserve">
<value>Max. mass increase [kg]</value>
</data>
<data name="Max_pressure_drop_bar" xml:space="preserve">
<value>Max. pressure drop [bar]</value>
</data>
<data name="Pump_is_running" xml:space="preserve">
<value>Pump is running</value>
</data>
<data name="Missing_a_pressure_meter" xml:space="preserve">
<value>Missing a pressure meter</value>
</data>
</root>