From 0c72e76ecc0d6c705ec7b5f92d36d67feeb836ea Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Wed, 29 May 2019 08:43:13 +0200 Subject: [PATCH] TestMethods.LeakTest : Test parameters IsPumpRunning, MaxPressureDrop and MaxMassIncrease added. --- .../TestMethods/LeakTest/LeakTestParams.cs | 51 +++-- .../TestMethods/LeakTest/LeakTestSeq.cs | 201 +++++++++++++----- TBF/Resources/Strings.Designer.cs | 36 ++++ TBF/Resources/Strings.resx | 12 ++ 4 files changed, 236 insertions(+), 64 deletions(-) diff --git a/TBF/BenchControl/TestMethods/LeakTest/LeakTestParams.cs b/TBF/BenchControl/TestMethods/LeakTest/LeakTestParams.cs index 9c0d914c5..b699bf804 100644 --- a/TBF/BenchControl/TestMethods/LeakTest/LeakTestParams.cs +++ b/TBF/BenchControl/TestMethods/LeakTest/LeakTestParams.cs @@ -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() diff --git a/TBF/BenchControl/TestMethods/LeakTest/LeakTestSeq.cs b/TBF/BenchControl/TestMethods/LeakTest/LeakTestSeq.cs index aa22ea5b6..a68812a8d 100644 --- a/TBF/BenchControl/TestMethods/LeakTest/LeakTestSeq.cs +++ b/TBF/BenchControl/TestMethods/LeakTest/LeakTestSeq.cs @@ -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 /// public IList Execute(Config.Entities.Test test, int repetitionNr, bool isLastRepetition, LeakTestParams testParams) { - IList 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.ConfigurationError }; + } + + if (testParams.MaxMassIncrease > 0) + { + scale = outPath.Scale as IScale; + if (scale == null) + { + Bridge.OnError(this, Strings.Missing_a_scale); + return new List { Event.ConfigurationError }; + } + } + + IList 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; } diff --git a/TBF/Resources/Strings.Designer.cs b/TBF/Resources/Strings.Designer.cs index 72d2d76df..98a7c7b8c 100644 --- a/TBF/Resources/Strings.Designer.cs +++ b/TBF/Resources/Strings.Designer.cs @@ -2364,6 +2364,24 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Max. mass increase [kg]. + /// + internal static string Max_mass_increase_kg { + get { + return ResourceManager.GetString("Max_mass_increase_kg", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Max. pressure drop [bar]. + /// + internal static string Max_pressure_drop_bar { + get { + return ResourceManager.GetString("Max_pressure_drop_bar", resourceCulture); + } + } + /// /// Looks up a localized string similar to (max. _X_ alphanumeric characters). /// @@ -2526,6 +2544,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Missing a pressure meter. + /// + internal static string Missing_a_pressure_meter { + get { + return ResourceManager.GetString("Missing_a_pressure_meter", resourceCulture); + } + } + /// /// Looks up a localized string similar to Missing a scale. /// @@ -3462,6 +3489,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Pump is running. + /// + internal static string Pump_is_running { + get { + return ResourceManager.GetString("Pump_is_running", resourceCulture); + } + } + /// /// Looks up a localized string similar to Pump power [%]. /// diff --git a/TBF/Resources/Strings.resx b/TBF/Resources/Strings.resx index 9b7f5f956..2723e9e73 100644 --- a/TBF/Resources/Strings.resx +++ b/TBF/Resources/Strings.resx @@ -1990,4 +1990,16 @@ Evaporation + + Max. mass increase [kg] + + + Max. pressure drop [bar] + + + Pump is running + + + Missing a pressure meter + \ No newline at end of file