From d4b20876b227dded33ff6721807aa39e74c0e77e Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Wed, 17 Aug 2016 12:24:24 +0200 Subject: [PATCH] All FixedStart, FlyingStart and FlyingStartMassCollection methods reorganised, common sequences used, ver. 2.9.337 --- .../BenchControl/TbfComponents.cs | 19 +- .../CombinedMeters/CombinedMetersSeq.cs | 607 ---------------- .../FixedStartAdvancedSeq.cs | 2 +- .../{TestMethod.cs => Single/Component.cs} | 12 +- .../Factory.cs} | 14 +- .../FixedStartCombinedMetersSeq.cs | 644 ----------------- .../Compound/Component.cs} | 20 +- .../Compound/Factory.cs} | 14 +- .../FixedStartMassCollectionSeq.cs | 119 +++- .../HeatMeters/Component.cs | 41 ++ .../HeatMeters/Factory.cs | 26 + .../HeatMeters/TestMethodCfg.cs | 38 +- .../HeatMeters/TestMethodCfgCtrl.cs | 71 ++ .../HeatMeters/TestMethodCfgCtrl.designer.cs | 86 +++ .../HeatMeters}/TestMethodCfgCtrl.resx | 0 .../HeatMeters/TestParams.cs} | 16 +- .../{TestMethod.cs => Single/Component.cs} | 20 +- .../Factory.cs} | 14 +- .../Compound/Component.cs} | 20 +- .../Compound/Factory.cs} | 14 +- .../FlyingStart/Compound/TestMethodCfg.cs | 47 ++ .../Compound}/TestMethodCfgCtrl.cs | 4 +- .../Compound}/TestMethodCfgCtrl.designer.cs | 4 +- .../Compound}/TestMethodCfgCtrl.resx | 0 .../FlyingStart/Compound/TestParams.cs | 112 +++ .../TestMethods/FlyingStart/FlyingStartSeq.cs | 105 +-- .../HeatMeters/Component.cs} | 22 +- .../FlyingStart/HeatMeters/Factory.cs | 26 + .../FlyingStart/HeatMeters/TestMethodCfg.cs | 47 ++ .../HeatMeters}/TestMethodCfgCtrl.cs | 4 +- .../HeatMeters/TestMethodCfgCtrl.designer.cs | 4 +- .../HeatMeters/TestMethodCfgCtrl.resx | 120 ++++ .../FlyingStart/HeatMeters/TestParams.cs | 112 +++ .../{TestMethod.cs => Single/Component.cs} | 20 +- .../Factory.cs} | 14 +- .../Compound}/CombinedTestParams.cs | 4 +- .../Compound/Component.cs | 42 ++ .../Compound/Factory.cs | 26 + .../Compound}/TestMethodCfg.cs | 12 +- .../Compound/TestMethodCfgCtrl.cs | 71 ++ .../Compound/TestMethodCfgCtrl.designer.cs | 86 +++ .../Compound/TestMethodCfgCtrl.resx | 120 ++++ .../FlyingStartMassCollectionSeq.cs | 277 ++++--- .../HeatMeters/Component.cs | 41 ++ .../HeatMeters/Factory.cs | 26 + .../HeatMeters/TestMethodCfg.cs | 47 ++ .../HeatMeters/TestMethodCfgCtrl.cs | 71 ++ .../HeatMeters/TestMethodCfgCtrl.designer.cs | 86 +++ .../HeatMeters/TestMethodCfgCtrl.resx | 120 ++++ .../HeatMeters/TestParams.cs | 112 +++ .../Single/Component.cs | 38 + .../Factory.cs} | 14 +- .../FlyingStartMassCollection/TestMethod.cs | 36 - .../TestMethods/HeatMeters/HeatMetersSeq.cs | 673 ------------------ .../HeatMeters/TestMethodFactory.cs | 26 - .../TestMethod.cs | 2 +- .../iPerlCommunication/TestMethod.cs | 2 +- TestBenchFramework/ProcedureDlg.cs | 2 +- TestBenchFramework/Properties/AssemblyInfo.cs | 4 +- TestBenchFramework/TBF.csproj | 102 ++- 60 files changed, 2136 insertions(+), 2342 deletions(-) delete mode 100644 TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs rename TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/{TestMethod.cs => Single/Component.cs} (72%) rename TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/{TestMethodFactory.cs => Single/Factory.cs} (52%) delete mode 100644 TestBenchFramework/BenchControl/TestMethods/FixedStartCombinedMeters/FixedStartCombinedMetersSeq.cs rename TestBenchFramework/BenchControl/TestMethods/{FixedStartCombinedMeters/TestMethod.cs => FixedStartMassCollection/Compound/Component.cs} (50%) rename TestBenchFramework/BenchControl/TestMethods/{FixedStartCombinedMeters/TestMethodFactory.cs => FixedStartMassCollection/Compound/Factory.cs} (52%) create mode 100644 TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/HeatMeters/Component.cs create mode 100644 TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/HeatMeters/Factory.cs rename TestBenchFramework/BenchControl/TestMethods/{ => FixedStartMassCollection}/HeatMeters/TestMethodCfg.cs (54%) create mode 100644 TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/HeatMeters/TestMethodCfgCtrl.cs create mode 100644 TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/HeatMeters/TestMethodCfgCtrl.designer.cs rename TestBenchFramework/BenchControl/TestMethods/{CombinedMeters => FixedStartMassCollection/HeatMeters}/TestMethodCfgCtrl.resx (100%) rename TestBenchFramework/BenchControl/TestMethods/{HeatMeters/HeatTestParams.cs => FixedStartMassCollection/HeatMeters/TestParams.cs} (81%) rename TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/{TestMethod.cs => Single/Component.cs} (50%) rename TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/{TestMethodFactory.cs => Single/Factory.cs} (52%) rename TestBenchFramework/BenchControl/TestMethods/{CombinedMeters/TestMethod.cs => FlyingStart/Compound/Component.cs} (53%) rename TestBenchFramework/BenchControl/TestMethods/{CombinedMeters/TestMethodFactory.cs => FlyingStart/Compound/Factory.cs} (51%) create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStart/Compound/TestMethodCfg.cs rename TestBenchFramework/BenchControl/TestMethods/{HeatMeters => FlyingStart/Compound}/TestMethodCfgCtrl.cs (92%) rename TestBenchFramework/BenchControl/TestMethods/{CombinedMeters => FlyingStart/Compound}/TestMethodCfgCtrl.designer.cs (95%) rename TestBenchFramework/BenchControl/TestMethods/{HeatMeters => FlyingStart/Compound}/TestMethodCfgCtrl.resx (100%) create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStart/Compound/TestParams.cs rename TestBenchFramework/BenchControl/TestMethods/{HeatMeters/TestMethod.cs => FlyingStart/HeatMeters/Component.cs} (53%) create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStart/HeatMeters/Factory.cs create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStart/HeatMeters/TestMethodCfg.cs rename TestBenchFramework/BenchControl/TestMethods/{CombinedMeters => FlyingStart/HeatMeters}/TestMethodCfgCtrl.cs (92%) rename TestBenchFramework/BenchControl/TestMethods/{ => FlyingStart}/HeatMeters/TestMethodCfgCtrl.designer.cs (95%) create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStart/HeatMeters/TestMethodCfgCtrl.resx create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStart/HeatMeters/TestParams.cs rename TestBenchFramework/BenchControl/TestMethods/FlyingStart/{TestMethod.cs => Single/Component.cs} (51%) rename TestBenchFramework/BenchControl/TestMethods/FlyingStart/{TestMethodFactory.cs => Single/Factory.cs} (53%) rename TestBenchFramework/BenchControl/TestMethods/{CombinedMeters => FlyingStartMassCollection/Compound}/CombinedTestParams.cs (95%) create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/Compound/Component.cs create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/Compound/Factory.cs rename TestBenchFramework/BenchControl/TestMethods/{CombinedMeters => FlyingStartMassCollection/Compound}/TestMethodCfg.cs (81%) create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/Compound/TestMethodCfgCtrl.cs create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/Compound/TestMethodCfgCtrl.designer.cs create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/Compound/TestMethodCfgCtrl.resx create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/HeatMeters/Component.cs create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/HeatMeters/Factory.cs create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/HeatMeters/TestMethodCfg.cs create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/HeatMeters/TestMethodCfgCtrl.cs create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/HeatMeters/TestMethodCfgCtrl.designer.cs create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/HeatMeters/TestMethodCfgCtrl.resx create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/HeatMeters/TestParams.cs create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/Single/Component.cs rename TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/{TestMethodFactory.cs => Single/Factory.cs} (59%) delete mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/TestMethod.cs delete mode 100644 TestBenchFramework/BenchControl/TestMethods/HeatMeters/HeatMetersSeq.cs delete mode 100644 TestBenchFramework/BenchControl/TestMethods/HeatMeters/TestMethodFactory.cs diff --git a/TestBenchFramework/BenchControl/TbfComponents.cs b/TestBenchFramework/BenchControl/TbfComponents.cs index 9431f1a35..17ee57e05 100644 --- a/TestBenchFramework/BenchControl/TbfComponents.cs +++ b/TestBenchFramework/BenchControl/TbfComponents.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2013-2015 Sensus Metering Systems +/// Copyright (c) 2013-2016 Sensus Metering Systems /// using System.Collections.Generic; using Config.Entities; @@ -20,7 +20,6 @@ namespace TBF.BenchControl Factories.Add(new BenchInfo.Munich.ComponentFactory()); Factories.Add(new BenchInfo.Polska.ComponentFactory()); Factories.Add(new Cameras.CameraRoi.CameraRoiFactory()); - Factories.Add(new TestMethods.CombinedMeters.TestMethodFactory()); Factories.Add(new TestMethods.CombinedWithDetection.TestMethodFactory()); Factories.Add(new Elde.ControlBoardFactory()); Factories.Add(new DataEntry.Combined.EntryFormFactory()); @@ -32,18 +31,22 @@ namespace TBF.BenchControl Factories.Add(new DataEntry.Standard24.EntryFormFactory()); Factories.Add(new DataEntry.Standard48.EntryFormFactory()); Factories.Add(new Elde.Diverter.DiverterFactory()); - Factories.Add(new TestMethods.FixedStartAdvanced.TestMethodFactory()); /// FixedStartAdvanced - Factories.Add(new TestMethods.FixedStartCombinedMeters.TestMethodFactory()); - Factories.Add(new TestMethods.FixedStartMassCollection.TestMethodFactory()); /// FixedStartMassCollection Factories.Add(new Elde.FixedStartRegisterReader.RegisterReaderFactory()); Factories.Add(new Elde.FlowMeter.FlowMeterFactory()); Factories.Add(new Elde.FlowMeterTwins.FlowMeterFactory()); - Factories.Add(new TestMethods.FlyingStart.TestMethodFactory()); - Factories.Add(new TestMethods.FlyingStartMassCollection.TestMethodFactory()); + Factories.Add(new TestMethods.FixedStartMassCollection.Single.Factory()); + Factories.Add(new TestMethods.FixedStartMassCollection.Compound.Factory()); + Factories.Add(new TestMethods.FixedStartMassCollection.HeatMeters.Factory()); + Factories.Add(new TestMethods.FixedStartAdvanced.Single.Factory()); + Factories.Add(new TestMethods.FlyingStart.Single.Factory()); + Factories.Add(new TestMethods.FlyingStart.Compound.Factory()); + Factories.Add(new TestMethods.FlyingStart.HeatMeters.Factory()); + Factories.Add(new TestMethods.FlyingStartMassCollection.Single.Factory()); + Factories.Add(new TestMethods.FlyingStartMassCollection.Compound.Factory()); + Factories.Add(new TestMethods.FlyingStartMassCollection.HeatMeters.Factory()); Factories.Add(new DataEntry.WMStates.EntryFormFactory()); Factories.Add(new Ambient.Comet.Factory()); Factories.Add(new Ambient.Greco.Factory()); - Factories.Add(new TestMethods.HeatMeters.TestMethodFactory()); /// HeatMeters Factories.Add(new Cameras.IdcCamera.IdcCameraFactory()); Factories.Add(new WaterMeters.iPerl.WaterMeterFactory()); /// iPerl Factories.Add(new TestMethods.iPerlCommunication.TestMethodFactory()); /// iPerlCommunication diff --git a/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs b/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs deleted file mode 100644 index 47811c466..000000000 --- a/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedMetersSeq.cs +++ /dev/null @@ -1,607 +0,0 @@ -/// -/// Copyright (c) 2013-2015 Sensus Metering Systems -/// -using System; -using System.Collections.Generic; -using System.Text; -using log4net; -using TBF.BenchControl; -using TBF.Boxes; -using TBF.Resources; -using TBF.UiBridge; - -namespace TBF.BenchControl.TestMethods.CombinedMeters -{ - public class CombinedMetersSeq : Sequences.SequenceBase - { - private static readonly ILog log = LogManager.GetLogger(typeof(CombinedMetersSeq)); - - /// - /// Flying start mass collection method sequence for combined meter - /// - /// Test entity - /// - /// 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 - /// - public IList Execute(Config.Entities.Test test, CombinedTestParams testParams) - { - Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; - - IList e = new List(); /// Events from currently running operations - Event retVal = Event.Done; - checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state - processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this); - - LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse; - int totalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f); - - int repetitionNr = 1; /// First test: repetitionNr = 1 - - //==================================== - // Transition or SetRoute - Start - //==================================== - switch (Transition(transitionBefore, TransitionContext.BeforeTest)) - { - 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, totalPulses)); - string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr); - TestStartTime = DateTime.Now; - TestProgressEventArgs.SetEstimatedTimes(new int[] { 1, 1, 1, 30, Convert.ToInt32(test.TstTime) + 15, 0, 0 }); - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.JustStarted)); - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - int flowSetTime0 = StateMachine.Time; - - //------------------------------------------------ - Bridge.OnActivity(this, Strings.Checking_tank_capacity); - //------------------------------------------------ - bool tankEmptyingInProgress = test.Emptying; - - if (!tankEmptyingInProgress) /// 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 : Checking available tank capacity") - .AddOperation(checkUiOp) - .AddOperation(outPath.Balance.ReadMassOp(ref Mass)) - .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.BalanceDone)); - - float estimatedEndMass = Mass.Val + test.Volume; - if (estimatedEndMass >= outPath.Balance.Capacity * Constants.TankFullFactor) - { - tankEmptyingInProgress = true; - } - } - /// - if (tankEmptyingInProgress) - { - State.Create("SequenceBase : Opening the emptying valve") - .AddOperation(checkUiOp) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(outPath.EmptyTankValve, null)) - .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.ValvesSet)); - } - - - if (inPath.Pump != null) - { - //------------------------------------------------ - Bridge.OnActivity(this, Strings.Starting_the_pump); - //------------------------------------------------ - if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower); - /// - State.Create("CombinedMeters : Starting the pump") - .AddOperation(checkUiOp) - .AddOperation(cBrd.SetValvesOp(inPath.Pump, null)) - .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - - if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } - } - while (!e.Contains(Event.ValvesSet)); - } - - - if (test.TimePump2StartV > 0) - { - State.Create("CombinedMeters : Waiting after the pump started") - .AddOperation(checkUiOp) - .AddOperation(new Operations.TimerOp(test.TimePump2StartV)) - .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - - if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } - } - while (!e.Contains(Event.TimerExpired)); - } - - - if (benchPath.StopBFValve != null) - { - State.Create("CombinedMeters : Opening the stop backflow valve") - .AddOperation(checkUiOp) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(benchPath.StopBFValve, null)) - .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } - if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } - } - while (!e.Contains(Event.ValvesSet)); - } - - - if (test.TimeBeforeFlow > 0) - { - State.Create("CombinedMeters : Waiting before flow setting process starts") - .AddOperation(checkUiOp) - .AddOperation(new Operations.TimerOp(test.TimeBeforeFlow)) - .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - - if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } - } - while (!e.Contains(Event.TimerExpired)); - } - - - setting_flow: - - //------------------------------------------------ - Bridge.OnActivity(this, Strings.Setting_the_flow); - //------------------------------------------------ - State.Create("CombinedMeters : Setting the flow") - .AddOperation(checkUiOp) - .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) - .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, outPath.PidCoef, RefFlow, 990)) /// timeout = 16.5 min. - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - - if (e.Contains(Event.OpArgumentError)) { retVal = Event.OpArgumentError; goto stopTest; } - if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } - if (e.Contains(Event.RegulValveTimeOut)) - { - Bridge.OnError(this, Strings.Timeout); - retVal = Event.Done; - goto stopTest; - } - if (e.Contains(Event.Next)) goto flow_set; - } - while (!e.Contains(Event.FlowReached)); - - - flow_set: - - int flowSetTime = StateMachine.Time - flowSetTime0; - float currentFlow = RefFlow.Val; - - /// Extract cameras from the current sensors path, add operations to the detection state - IList measureOperations = new List(); - for (int i = 0; i < sensPath.RegisterReaders.Length; i++) - { - GenericDevices.ICameraRoi cameraRoi = sensPath.RegisterReaders[i] as GenericDevices.ICameraRoi; - if (cameraRoi != null) measureOperations.Add(cameraRoi.MeasureOp()); - } - - - if (tankEmptyingInProgress) - { - //------------------------------------------------ - Bridge.OnActivity(this, Strings.Closing_the_tank); - //------------------------------------------------ - - /// - /// Make sure tank emptying completed - /// - switch (EmptyTheTank(outPath.EmptyTankValve, outPath.Balance)) - { - case Event.Error: { retVal = Event.Error; goto stopTest; } - case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } - } - - tankEmptyingInProgress = false; - } - - - if (test.TimeFlow2Mass > 0) - { - State.Create("CombinedMeters : Waiting before 1st mass measurement") - .AddOperation(checkUiOp) - .AddOperation(cBrd.UpdateTankWeightOp()) - .AddOperation(new Operations.TimerOp(test.TimeFlow2Mass)) - .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.TimerExpired)); - } - - - //------------------------------------------------ - Bridge.OnActivity(this, Strings.Measuring_the_weight); - //------------------------------------------------ - - LogProcessHeader(processDataLogger, "Start mass"); - - State.Create("CombinedMeters : Measuring the start mass") - .AddOperation(checkUiOp) - .AddOperation(benchPath.TempIn.ReadTempOp(ref TempIn)) - .AddOperation(benchPath.TempOut.ReadTempOp(ref TempOut)) - .AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv)) - .AddOperation(benchPath.PressIn.ReadPressureOp(ref PressureUp)) - .AddOperation(benchPath.PressOut.ReadPressureOp(ref PressureDown)) - .AddOperation((StateMachine.Ambient != null) - ? StateMachine.Ambient.ReadAmbientOp(AmbientTemp, AmbientPressure, AmbientHumidity) : null) - .AddOperations(measureOperations) - .AddOperation(outPath.Balance.ReadStableMassOp(ref StartMass, test.MassRepeats, test.MassSpread, test.MassMethod)) - .AddOperation(cBrd.UpdateTankWeightOp()) - .AddOperation(processDataLoggingOp) - .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.BalanceDone)); - - LogProcessHeader(processDataLogger, "Measurement"); - - log.WarnFormat("Start mass = {0}kg", StartMass); - Mass.Val = StartMass.Val; - - //------------------------------------------------ - Bridge.OnActivity(this, Strings.Test_in_progress); - //------------------------------------------------ - State.Create("CombinedMeters : Starting the test") - .AddOperation(checkUiOp) - .AddOperation(benchPath.TempIn.ReadTempOp(ref TempIn)) - .AddOperation(benchPath.TempOut.ReadTempOp(ref TempOut)) - .AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv)) - .AddOperation(benchPath.PressIn.ReadPressureOp(ref PressureUp)) - .AddOperation(benchPath.PressOut.ReadPressureOp(ref PressureDown)) - .AddOperation((StateMachine.Ambient != null) - ? StateMachine.Ambient.ReadAmbientOp(AmbientTemp, AmbientPressure, AmbientHumidity) : null) - .AddOperations(measureOperations) - .AddOperation(cBrd.UpdateTankWeightOp()) - .AddOperation(processDataLoggingOp) - .AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Diverter | Elde.TestMethods.Synchro, - test.Qfrom, test.Qto, totalPulses, (float)test.TolerRed)) - .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.MeasurementStarted)); - - /// Measurement loop - preparation - readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders); - - int estimtdEndTime = StateMachine.Time + (int)test.TstTime; - ClearAllStatistics(); - - /// Measurement loop - begin - State.Create("Read water meters") - .AddOperation(checkUiOp) - .AddOperations(measureOperations) - .AddOperation(readRegistersOp) - .AddOperation(benchPath.TempIn.ReadTempOp(ref TempIn)) - .AddOperation(benchPath.TempOut.ReadTempOp(ref TempOut)) - .AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv)) - .AddOperation(benchPath.PressIn.ReadPressureOp(ref PressureUp)) - .AddOperation(benchPath.PressOut.ReadPressureOp(ref PressureDown)) - .AddOperation(outPath.Balance.ReadMassOp(ref Mass)) - .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) - .AddOperation((StateMachine.Ambient != null) - ? StateMachine.Ambient.ReadAmbientOp(AmbientTemp, AmbientPressure, AmbientHumidity) - : null) - .AddOperation(cBrd.QueryMeasurementEndOp()) - .AddOperation(processDataLoggingOp) - .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.MeasurementCompleted)) goto test_completed; - - //------------------------------------------------ - int remainingTime = Math.Max(estimtdEndTime - StateMachine.Time, 0); - if (remainingTime > 60) - { - Bridge.OnActivity(this, string.Format("{0} ... {1} {2} {3} {4}", Strings.Test_in_progress, remainingTime / 60, "min", remainingTime % 60, Strings.sec)); - } - else - { - Bridge.OnActivity(this, string.Format("{0} ... {1} s", Strings.Test_in_progress, remainingTime)); - } - //------------------------------------------------ - - UpdateAllStatistics(); - RefFreq.Val = cBrd.ReferenceFreq; - RefFlow.Val = cBrd.ReferenceFlow; - - Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.Test)); - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Test)); - } - while (true); - /// Measurement loop - end - - test_completed: - //------------------------------------------------ - Bridge.OnActivity(this, Strings.Measuring_the_weight); - //------------------------------------------------ - State.Create("CombinedMeters : Waiting before the 2nd mass measurement") - .AddOperation(checkUiOp) - .AddOperation(benchPath.TempIn.ReadTempOp(ref TempIn)) - .AddOperation(benchPath.TempOut.ReadTempOp(ref TempOut)) - .AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv)) - .AddOperation(benchPath.PressIn.ReadPressureOp(ref PressureUp)) - .AddOperation(benchPath.PressOut.ReadPressureOp(ref PressureDown)) - .AddOperation(readRegistersOp) - .AddOperation((StateMachine.Ambient != null) - ? StateMachine.Ambient.ReadAmbientOp(AmbientTemp, AmbientPressure, AmbientHumidity) : null) - .AddOperation(outPath.Balance.ReadMassOp(ref Mass)) - .AddOperation(cBrd.UpdateTankWeightOp()) - .AddOperation(processDataLoggingOp) - .AddOperation(new Operations.TimerOp(test.TimeStop2Mass)) - .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.TimerExpired)); - - LogProcessHeader(processDataLogger, "End mass"); - - State.Create("CombinedMeters : Measuring the end mass") - .AddOperation(checkUiOp) - .AddOperation(benchPath.TempIn.ReadTempOp(ref TempIn)) - .AddOperation(benchPath.TempOut.ReadTempOp(ref TempOut)) - .AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv)) - .AddOperation(benchPath.PressIn.ReadPressureOp(ref PressureUp)) - .AddOperation(benchPath.PressOut.ReadPressureOp(ref PressureDown)) - .AddOperation(readRegistersOp) - .AddOperation((StateMachine.Ambient != null) - ? StateMachine.Ambient.ReadAmbientOp(AmbientTemp, AmbientPressure, AmbientHumidity) : null) - .AddOperation(outPath.Balance.ReadStableMassOp(ref EndMass, test.MassRepeats, test.MassSpread, test.MassMethod)) - .AddOperation(cBrd.UpdateTankWeightOp()) - .AddOperation(processDataLoggingOp) - .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.BalanceDone)); - /// - log.WarnFormat("End mass = {0}kg", EndMass); - TestEndTime = DateTime.Now; - - //------------------------------------------------ - Bridge.OnActivity(this, Strings.Test_completed); - //------------------------------------------------ - - /// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results - if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stopTest; - - /// - /// Populate TestResult data entity with data - /// - Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part); - - if (tstRslt != null) - { - /// Auxiliary results - tstRslt.AmbientTempAve = AmbientTempStat.Average; - tstRslt.AmbientPressAve = AmbientPressureStat.Average; - tstRslt.AmbientHumiAve = AmbientHumidityStat.Average; - tstRslt.PressUpAvrg = PressureUpStat.Average; - tstRslt.PressUpStart = PressureUpStat.First; - tstRslt.PressUpEnd = PressureUpStat.Last; - tstRslt.PressUpMin = PressureUpStat.Min; - tstRslt.PressUpMax = PressureUpStat.Max; - tstRslt.PressDownAvrg = PressureDownStat.Average; - tstRslt.PressDownStart = PressureDownStat.First; - tstRslt.PressDownEnd = PressureDownStat.Last; - tstRslt.PressDownMin = PressureDownStat.Min; - tstRslt.PressDownMax = PressureDownStat.Max; - tstRslt.TempInAvrg = TempInStat.Average; - tstRslt.TempInStart = TempInStat.First; - tstRslt.TempInEnd = TempInStat.Last; - tstRslt.TempInMin = TempInStat.Min; - tstRslt.TempInMax = TempInStat.Max; - tstRslt.TempOutAvrg = TempOutStat.Average; - tstRslt.TempOutStart = TempOutStat.First; - tstRslt.TempOutEnd = TempOutStat.Last; - tstRslt.TempOutMin = TempOutStat.Min; - tstRslt.TempOutMax = TempOutStat.Max; - tstRslt.TempDivAvrg = TempDivStat.Average; - tstRslt.TempDivStart = TempDivStat.First; - tstRslt.TempDivEnd = TempDivStat.Last; - tstRslt.TempDivMin = TempDivStat.Min; - tstRslt.TempDivMax = TempDivStat.Max; - tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3] - tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3] - tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivAvrg); /// [kg/m3] - - /// Main results - tstRslt.StartTime = TestStartTime; - tstRslt.EndTime = TestEndTime; - tstRslt.FlowSetTime = flowSetTime; - tstRslt.TestTime = cBrd.TTime; /// [s] measurement time - tstRslt.PulsesMaster = Convert.ToDouble(cBrd.EtPulses(0)); /// Pulses of the master flow meter (test total) - tstRslt.MassStartRaw = StartMass.Val; - tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections); - tstRslt.MassEndRaw = EndMass.Val; - tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections); - tstRslt.FlowMass = 3600.0 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.TestTime; /// [kg/h] - tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; /// [m3/h] - tstRslt.VolumeCTV = 1001.03 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.DensityOut; /// [l] 1001.03f is because density is in [kg/m3] - tstRslt.VolumeMaster = LtrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter - tstRslt.ConstMaster = LtrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster; /// Corrected master pulses per liter - tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV); - - tstRslt.FlowMin = (tstRslt.VolumeMaster != 0) ? (float)(RefFlowStat.Min * tstRslt.VolumeCTV / tstRslt.VolumeMaster) : RefFlowStat.Min; - tstRslt.FlowMax = (tstRslt.VolumeMaster != 0) ? (float)(RefFlowStat.Max * tstRslt.VolumeCTV / tstRslt.VolumeMaster) : RefFlowStat.Max; - - for (int i = 0; i < BatchRslts.WMPositionsCount; i++) - { - if (test.Part != 0 && test.Part != Utils.PartNr(i + 1, BatchRslts.Batch.Compound)) continue; - - Results.Entities.MeterTestRslt mainMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.CompoundMain); - Results.Entities.MeterTestRslt auxMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.CompoundAux); - - for (int isAux = 0; isAux <= 1; isAux++) /// 0=main, 1=aux - { - GenericDevices.IRegisterReader regReader = sensPath.RegisterReaders[2 * i + isAux]; - Results.Entities.MeterTestRslt meterRslt = (isAux == 0) ? mainMeterRslt : auxMeterRslt; - - if (meterRslt != null && regReader != null) - { - meterRslt.PulsesPerLiter = regReader.PulsesPerLtr; - - /// Optionally supress pulses from the large water meter - meterRslt.PulsesMeter = (isAux == 0 && testParams.SupressTrills) ? 0 : Convert.ToDouble(regReader.WMPulses); - meterRslt.PulsesMaster = Convert.ToDouble(regReader.WMRefPulses); - - meterRslt.TestTime = tstRslt.TestTime; - meterRslt.VolumeStart = 0; - meterRslt.VolumeEnd = 0; - meterRslt.VolumeRef = tstRslt.VolumeCTV; - meterRslt.VolumeMeter = meterRslt.PulsesMeter * regReader.LtrsPerPulse; /// liter - - if (meterRslt.PulsesMaster != 0) - { - meterRslt.VolumeMeter *= (tstRslt.PulsesMaster / meterRslt.PulsesMaster); - } - - meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, tstRslt.VolumeCTV); /// Main/Aux meter error is not usedfor evaluation - } - } - - Results.Entities.MeterTestRslt compoundMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Compound); - - if (compoundMeterRslt != null && mainMeterRslt != null && auxMeterRslt != null) - { - compoundMeterRslt.VolumeRef = tstRslt.VolumeCTV; - compoundMeterRslt.VolumeMeter = mainMeterRslt.VolumeMeter + auxMeterRslt.VolumeMeter; - compoundMeterRslt.PulsesMaster = tstRslt.PulsesMaster; - compoundMeterRslt.TestTime = tstRslt.TestTime; - compoundMeterRslt.Error = Formulas.ErrorFromVolumes(compoundMeterRslt.VolumeMeter, compoundMeterRslt.VolumeRef); - compoundMeterRslt.Passed = (compoundMeterRslt.Error >= test.ErrLimLo + test.Uncertainty) - && (compoundMeterRslt.Error <= test.ErrLimHi - test.Uncertainty); - mainMeterRslt.Passed = auxMeterRslt.Passed = compoundMeterRslt.Passed; - mainMeterRslt.TestDone = auxMeterRslt.TestDone = compoundMeterRslt.TestDone = true; - } - } - - tstRslt.Components = Results.Entities.Components - .UpdateList(BatchRslts.ComponentsList, - new Results.Entities.Components((BenchInfo != null) ? BenchInfo.TestBenchId : 1, - (BenchInfo != null) ? BenchInfo.TestBenchName : "testbench", - inPath.Pump != null ? inPath.Pump.Name : string.Empty, - outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty, - outPath.Balance != null ? outPath.Balance.Name : string.Empty, - outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty, - outPath.Diverter != null ? outPath.Diverter.Name : string.Empty)); - - /// Update results - Bridge.OnTestCompleted(this, new TestCompletedEventArgs(testName, tstRslt)); - } - - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.TransitionAfter)); - - /// Append the results to the CSV-file - allResults.Info(TestResult2CsvLine(testName, test.Part)); - - if (++repetitionNr <= test.Repeats) - { - goto loop; - } - - stopTest: - - ///----------------------/// - /// Quit this sequence /// - ///----------------------/// - - State.Create("CombinedMeters : Stopping diverter, gate, etc.") - .AddOperation(checkUiOp) - .AddOperation(cBrd.StopPreviousOp()) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; } - } - while (!e.Contains(Event.PreviousStopped)); - - /// Transition sequence at the end of test - /// Prevent overwriting 'retVal' in case it was set to non-default value earlier - switch (Transition(transitionAfter, (retVal == Event.Done) ? TransitionContext.AfterTest : TransitionContext.Stop)) - { - case Event.Error: { if (retVal == Event.Done) retVal = Event.Error; break; } - case Event.UiCmdStop: { if (retVal == Event.Done) retVal = Event.UiCmdStop; break; } - } - - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Completed)); - - /// Create a list with one item 'retVal' (default is Event.Done) and return it - IList retList = new List(1); - retList.Add(retVal); - return retList; - } - } -} diff --git a/TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs index 1732a3c54..413f2f63d 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2015 Sensus Metering Systems +/// Copyright (c) 2016 Sensus Metering Systems /// using System; using System.Collections.Generic; diff --git a/TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/TestMethod.cs b/TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/Single/Component.cs similarity index 72% rename from TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/TestMethod.cs rename to TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/Single/Component.cs index 6235d5913..0a75d03ba 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/TestMethod.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/Single/Component.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2015 Sensus Metering Systems +/// Copyright (c) 2016 Sensus Metering Systems /// using System; using System.Collections.Generic; @@ -7,22 +7,22 @@ using log4net; using Config.Entities; using TBF.BenchControl; -namespace TBF.BenchControl.TestMethods.FixedStartAdvanced +namespace TBF.BenchControl.TestMethods.FixedStartAdvanced.Single { - public class TestMethod : ComponentBase, GenericDevices.ITestMethod + public class Component : ComponentBase, GenericDevices.ITestMethod { - private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod)); + private static readonly ILog log = LogManager.GetLogger(typeof(Component)); public override string ToString() { return string.Format("TestMethods.FixedStartAdvanced({0})", Cfg.ToString(1)); } public bool Evaluate(Test test) { return true; } public bool Publish(Test test) { return true; } public bool CanTest(MetersKind meters) { return meters == MetersKind.Single; } - public TestMethod() + public Component() { } - public TestMethod(Generic.IComponentCfg cfg) + public Component(Generic.IComponentCfg cfg) : base(cfg) { log.Debug(this.ToString()); diff --git a/TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/TestMethodFactory.cs b/TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/Single/Factory.cs similarity index 52% rename from TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/TestMethodFactory.cs rename to TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/Single/Factory.cs index a09b781c1..870686d3b 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/TestMethodFactory.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FixedStartAdvanced/Single/Factory.cs @@ -5,19 +5,19 @@ using System.Collections.Generic; using TBF.BenchControl.Generic; using TBF.BenchControl.Configs.NameOnly; -namespace TBF.BenchControl.TestMethods.FixedStartAdvanced +namespace TBF.BenchControl.TestMethods.FixedStartAdvanced.Single { - public class TestMethodFactory : IComponentFactory + public class Factory : IComponentFactory { - public string ClassName { get { return "FixedStartAdvanced"; } } + public string ClassName { get { return this.GetType().Namespace.Substring(17); } } - public void ResetStaticProperties() { TestMethod.ResetStaticProperties(); } + public void ResetStaticProperties() { Component.ResetStaticProperties(); } - public IComponent DummyComponent() { return new TestMethod(); } + public IComponent DummyComponent() { return new Component(); } - public IComponent GetComponent(IComponentCfg cfg, IList components) { return new TestMethod(cfg); } + public IComponent GetComponent(IComponentCfg cfg, IList components) { return new Component(cfg); } - public IComponentCfg DefaultConfig() { return new TestMethodCfg("FixedStartAdvanced", this); } + public IComponentCfg DefaultConfig() { return new TestMethodCfg(this.GetType().Namespace.Substring(29), this); } public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) { diff --git a/TestBenchFramework/BenchControl/TestMethods/FixedStartCombinedMeters/FixedStartCombinedMetersSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FixedStartCombinedMeters/FixedStartCombinedMetersSeq.cs deleted file mode 100644 index fe9dd3450..000000000 --- a/TestBenchFramework/BenchControl/TestMethods/FixedStartCombinedMeters/FixedStartCombinedMetersSeq.cs +++ /dev/null @@ -1,644 +0,0 @@ -/// -/// Copyright (c) 2013-2015 Sensus Metering Systems -/// -using System; -using System.Collections.Generic; -using System.Text; -using log4net; -using TBF.BenchControl; -using TBF.Boxes; -using TBF.Resources; -using TBF.UiBridge; - -namespace TBF.BenchControl.TestMethods.FixedStartCombinedMeters -{ - public class FixedStartCombinedMetersSeq : Sequences.SequenceBase - { - private static readonly ILog log = LogManager.GetLogger(typeof(FixedStartCombinedMetersSeq)); - - /// - /// Flying start mass collection method sequence - /// - /// Test entity - /// - /// 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 - /// - public IList Execute(Config.Entities.Test test) - { - Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; - - IList e = new List(); /// Events from currently running operations - Event retVal = Event.Done; - checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state - - LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse; /// [ltr/pulse], nominal flow in [m3/h] - - /// Notes: - /// float timeHr = volumeLtr / (1000.0f * targetFlow); - /// float timeSec = 3600.0f * timeHr; - /// int refPulses = (int)(timeSec * (2000.0f * targetFlow / pOut.FlowMeter.NominalFlow)); - int totalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f); - - processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this); - - float[] wmBeginStates = new float[Config.Data.WMsCount]; - float[] wmEndStates = new float[Config.Data.WMsCount]; - - int repetitionNr = 1; /// First test: repetitionNr=1 - - //==================================== - // Transition or SetRoute - Start - //==================================== - switch (Transition(transitionBefore, TransitionContext.BeforeTest)) - { - 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, totalPulses)); - string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr); - TestStartTime = DateTime.Now; - TestProgressEventArgs.SetEstimatedTimes(new int[] { 1, 1, 1, 30, Convert.ToInt32(test.TstTime) + 15, 0, 0 }); - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.JustStarted)); - - - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - int flowSetTime0 = StateMachine.Time; - - //------------------------------------------------ - Bridge.OnActivity(this, Strings.Setting_the_flow); - //------------------------------------------------ - if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower); - - State.Create("FixedStartCombinedMeters : Starting the pump") - .AddOperation(checkUiOp) - .AddOperation(new Operations.TimerOp(5)) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - - if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; } - } - while (!e.Contains(Event.TimerExpired)); - - - State.Create("FixedStartCombinedMeters : Starting the pump") - .AddOperation(checkUiOp) - .AddOperation(cBrd.SetValvesOp(inPath.Pump, null)) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - - if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; } - } - while (!e.Contains(Event.ValvesSet)); - - - 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("FixedStartCombinedMeters : Measuring the mass of water in the tank") - .AddOperation(checkUiOp) - .AddOperation(outPath.Balance.ReadMassOp(ref Mass)) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - - if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } - if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; } - } - while (!e.Contains(Event.BalanceDone)); - - float estimatedEndMass = Mass.Val + test.Volume; - if (estimatedEndMass < outPath.Balance.Capacity * Constants.TankFullFactor) - { - goto set_flow; /// Enough room in the tank -> skip emptying - } - } - - /// - /// Empty the water tank - /// - switch (EmptyTheTank(outPath.EmptyTankValve, outPath.Balance)) - { - case Event.Error: { retVal = Event.Error; goto stopTest; } - case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } - } - - set_flow: - - //------------------------------------------------ - Bridge.OnActivity(this, Strings.Setting_the_flow); - //------------------------------------------------ - if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower); - State.Create("FixedStartCombinedMeters : Starting the pump") - .AddOperation(checkUiOp) - .AddOperation(cBrd.SetValvesOp(inPath.Pump, null)) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - - if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; } - } - while (!e.Contains(Event.ValvesSet)); - - //-------------------------------- - State.Create("FixedStartCombinedMeters : Setting the flow") - .AddOperation(checkUiOp) - .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, outPath.PidCoef, RefFlow, 600)) /// timeout = 10 min. - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - - if (e.Contains(Event.OpArgumentError)) { retVal = Event.OpArgumentError; goto stopTest; } - if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; } - if (e.Contains(Event.RegulValveTimeOut)) - { - Bridge.OnError(this, Strings.Timeout); - retVal = Event.Done; - goto stopTest; - } - if (e.Contains(Event.Next)) goto flow_set; - } - while (!e.Contains(Event.FlowReached)); - - flow_set: - int flowSetTime = StateMachine.Time - flowSetTime0; - - //------------------------------------------------ - Bridge.OnActivity(this, Strings.Stopping_flow_for_the_fixed_start); - //------------------------------------------------ - State.Create("FixedStartCombinedMeters : Closing the start/stop valve before the fixed start test") - .AddOperation(checkUiOp) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(null, outPath.StartValve)) - .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } - } - while (!e.Contains(Event.ValvesSet)); - - - int time = StateMachine.Time; - float currentFlow = RefFlow.Val; - - - /// Extract cameras from the current sensors path, add operations to the detection state - IList measureOperations = new List(); - for (int i = 0; i < sensPath.RegisterReaders.Length; i++) - { - GenericDevices.ICameraRoi cameraRoi = sensPath.RegisterReaders[i] as GenericDevices.ICameraRoi; - if (cameraRoi != null) measureOperations.Add(cameraRoi.MeasureOp()); - } - - - /// - /// Enter watermeter begin states here - /// - GenericDevices.IHasWMStatesForm dataEntryCmpnt = - TbfComponents.FindComponent(StateMachine.Procedure.DataEntry) as GenericDevices.IHasWMStatesForm; - if (dataEntryCmpnt != null) - { - Bridge.OnActivity(this, Strings.Enter_water_meter_data); - State.Create("FixedStartCombinedMeters : Enter begin-state") - .AddOperation((dataEntryCmpnt as GenericDevices.IHasWMStatesForm).ShowTestStartFormOp()) - .AddOperation(checkUiOp) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; } - } - while (!e.Contains(Event.ModelessFormClosed)); - - for (int i = 0; i < Config.Data.WMsCount; i++) - { - BenchControl.Elde.FixedStartRegisterReader.RegisterReader registerReader = - sensPath.RegisterReaders[i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader; - - if (registerReader != null) registerReader.BeginWMState = dataEntryCmpnt.WMStartState(i); - } - } - - - //------------------------------------------------ - Bridge.OnActivity(this, Strings.Measuring_the_weight); - //------------------------------------------------ - State.Create("FixedStartCombinedMeters : Measuring the start mass") - .AddOperation(checkUiOp) - .AddOperation(benchPath.TempIn.ReadTempOp(ref TempIn)) - .AddOperation(benchPath.TempOut.ReadTempOp(ref TempOut)) - .AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv)) - .AddOperation(benchPath.PressIn.ReadPressureOp(ref PressureUp)) - .AddOperation(benchPath.PressOut.ReadPressureOp(ref PressureDown)) - .AddOperation((StateMachine.Ambient != null) - ? StateMachine.Ambient.ReadAmbientOp(AmbientTemp, AmbientPressure, AmbientHumidity) : null) - .AddOperations(measureOperations) - .AddOperation(outPath.Balance.ReadStableMassOp(ref StartMass, test.MassRepeats, test.MassSpread, test.MassMethod)) - .AddOperation(cBrd.UpdateTankWeightOp()) - .AddOperation(processDataLoggingOp) - .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.BalanceDone)); - - Mass.Val = StartMass.Val; - - //------------------------------------------------ - Bridge.OnActivity(this, Strings.Test_in_progress); - //------------------------------------------------ - State.Create("FixedStartCombinedMeters : Starting the test") - .AddOperation(checkUiOp) - .AddOperations(measureOperations) - .AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Diverter | Elde.TestMethods.Synchro, - test.Qfrom, test.Qto, 2 * totalPulses, (float)test.TolerRed)) - .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.MeasurementStarted)); - - - State.Create("FixedStartCombinedMeters : Opening the start/stop valve at the beginning of the fixed start test") - .AddOperation(checkUiOp) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(outPath.StartValve, null)) - .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } - } - while (!e.Contains(Event.ValvesSet)); - - - /// Measurement loop - preparation - readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders); - queryEnd1 = cBrd.QueryMeasurementEndOp(); - queryEnd2 = cBrd.QueryMeasurementEndOp(); - - ClearAllStatistics(); - int estimtdEndTime = StateMachine.Time + (int)test.TstTime; - - /// Measurement loop - begin - do - { - //-------------------------------- - switch (ReadRegistersTempPressAmbient(measureOperations, true)) - { - case Event.Error: - retVal = Event.Error; - goto stopTest; - - case Event.UiCmdStop: - retVal = Event.UiCmdStop; - goto stopTest; - - case Event.MeasurementCompleted: - goto test_completed; - } - - int remainingTime = Math.Max(estimtdEndTime - StateMachine.Time, 0); - if (remainingTime > 60) - { - Bridge.OnActivity(this, string.Format("{0} ... {1} {2} {3} {4}", Strings.Test_in_progress, remainingTime / 60, "min", remainingTime % 60, Strings.sec)); - } - else - { - Bridge.OnActivity(this, string.Format("{0} ... {1} s", Strings.Test_in_progress, remainingTime)); - } - - UpdateAllStatistics(); - RefFreq.Val = cBrd.ReferenceFreq; - RefFlow.Val = cBrd.ReferenceFlow; - - /// TODO: Reimplement - //for (int i = 0; i < Config.Data.CompoundWMsCount; i++) - //{ - // data.TestResult.CombinedMeters[i].VolumeMeter = data.TestResult.Meters[2 * i].VolumeMeter - // + data.TestResult.Meters[2 * i + 1].VolumeMeter; - // if (data.Volume.Valid) - // { - // data.TestResult.CombinedMeters[i].VolumeErrorPct = - // Formulas.ErrorFromVolumes(data.TestResult.CombinedMeters[i].VolumeMeter, data.Volume.Val); - // } - //} - Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.Test)); - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Test)); - } - while (cBrd.EtPulses(0) < totalPulses); - /// Measurement loop - end - - test_completed: - - State.Create("FixedStartCombinedMeters : Closing the start/stop valve at the end of the fixed start test") - .AddOperation(checkUiOp) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(null, outPath.StartValve)) - .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } - } - while (e.Contains(Event.ValvesBusy)); - - - State.Create("FixedStartCombinedMeters : Waiting before 2nd mass measurement") - .AddOperation(checkUiOp) - .AddOperation(benchPath.TempIn.ReadTempOp(ref TempIn)) - .AddOperation(benchPath.TempOut.ReadTempOp(ref TempOut)) - .AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv)) - .AddOperation(benchPath.PressIn.ReadPressureOp(ref PressureUp)) - .AddOperation(benchPath.PressOut.ReadPressureOp(ref PressureDown)) - .AddOperation((StateMachine.Ambient != null) - ? StateMachine.Ambient.ReadAmbientOp(AmbientTemp, AmbientPressure, AmbientHumidity) : null) - .AddOperation(outPath.Balance.ReadMassOp(ref Mass)) - .AddOperation(cBrd.UpdateTankWeightOp()) - .AddOperation(processDataLoggingOp) - .AddOperation(new Operations.TimerOp(test.TimeStop2Mass)) - .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.TimerExpired)); - - - //------------------------------------------------ - Bridge.OnActivity(this, Strings.Measuring_the_weight); - //------------------------------------------------ - State.Create("FixedStartCombinedMeters : Measuring the end mass") - .AddOperation(checkUiOp) - .AddOperation(benchPath.TempIn.ReadTempOp(ref TempIn)) - .AddOperation(benchPath.TempOut.ReadTempOp(ref TempOut)) - .AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv)) - .AddOperation(benchPath.PressIn.ReadPressureOp(ref PressureUp)) - .AddOperation(benchPath.PressOut.ReadPressureOp(ref PressureDown)) - .AddOperation((StateMachine.Ambient != null) - ? StateMachine.Ambient.ReadAmbientOp(AmbientTemp, AmbientPressure, AmbientHumidity) : null) - .AddOperation(outPath.Balance.ReadStableMassOp(ref EndMass, test.MassRepeats, test.MassSpread, test.MassMethod)) - .AddOperation(cBrd.UpdateTankWeightOp()) - .AddOperation(processDataLoggingOp) - .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.BalanceDone)); - /// - TestEndTime = DateTime.Now; - - - State.Create("FixedStartCombinedMeters : Stopping diverter, gate, etc.") - .AddOperation(checkUiOp) - .AddOperation(cBrd.StopPreviousOp()) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; } - } - while (!e.Contains(Event.PreviousStopped)); - - - double massStart = Formulas.CorrectedValue(StartMass.Val, outPath.Balance.Corrections); - double massEnd = Formulas.CorrectedValue(EndMass.Val, outPath.Balance.Corrections); - double densityOut = Formulas.WaterDensityFromTemp(TempOutStat.Average); /// [kg/m3] - double volumeCTV = 1.00103f * 1000.0f * (massEnd - massStart) / densityOut; - - /// - /// Enter watermeter end states here - /// - if (dataEntryCmpnt != null) - { - Bridge.OnActivity(this, Strings.Enter_water_meter_data); - State.Create("FixedStartCombinedMeters : Enter end-state") - .AddOperation(dataEntryCmpnt.ShowTestEndFormOp(volumeCTV, test.ErrLimLo + test.Uncertainty, - test.ErrLimHi - test.Uncertainty)) - .AddOperation(checkUiOp) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; } - } - while (!e.Contains(Event.ModelessFormClosed)); - - - for (int i = 0; i < Config.Data.CompoundWMsCount * 2; i++) - { - BenchControl.Elde.FixedStartRegisterReader.RegisterReader registerReader = - sensPath.RegisterReaders[i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader; - - if (registerReader != null) registerReader.EndWMState = dataEntryCmpnt.WMEndState(i); - } - } - - - //------------------------------------------------ - Bridge.OnActivity(this, Strings.Test_completed); - //------------------------------------------------ - - /// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results - if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stopTest; - - /// - /// Populate TestResult data entity with data - /// - Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part); - - if (tstRslt != null) - { - /// Auxiliary results - tstRslt.AmbientTempAve = AmbientTempStat.Average; - tstRslt.AmbientPressAve = AmbientPressureStat.Average; - tstRslt.AmbientHumiAve = AmbientHumidityStat.Average; - tstRslt.PressUpAvrg = PressureUpStat.Average; - tstRslt.PressUpStart = PressureUpStat.First; - tstRslt.PressUpEnd = PressureUpStat.Last; - tstRslt.PressUpMin = PressureUpStat.Min; - tstRslt.PressUpMax = PressureUpStat.Max; - tstRslt.PressDownAvrg = PressureDownStat.Average; - tstRslt.PressDownStart = PressureDownStat.First; - tstRslt.PressDownEnd = PressureDownStat.Last; - tstRslt.PressDownMin = PressureDownStat.Min; - tstRslt.PressDownMax = PressureDownStat.Max; - tstRslt.TempInAvrg = TempInStat.Average; - tstRslt.TempInStart = TempInStat.First; - tstRslt.TempInEnd = TempInStat.Last; - tstRslt.TempInMin = TempInStat.Min; - tstRslt.TempInMax = TempInStat.Max; - tstRslt.TempOutAvrg = TempOutStat.Average; - tstRslt.TempOutStart = TempOutStat.First; - tstRslt.TempOutEnd = TempOutStat.Last; - tstRslt.TempOutMin = TempOutStat.Min; - tstRslt.TempOutMax = TempOutStat.Max; - tstRslt.TempDivAvrg = TempDivStat.Average; - tstRslt.TempDivStart = TempDivStat.First; - tstRslt.TempDivEnd = TempDivStat.Last; - tstRslt.TempDivMin = TempDivStat.Min; - tstRslt.TempDivMax = TempDivStat.Max; - tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3] - tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3] - tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivAvrg); /// [kg/m3] - - /// Main results - tstRslt.StartTime = TestStartTime; - tstRslt.EndTime = TestEndTime; - tstRslt.FlowSetTime = flowSetTime; - tstRslt.TestTime = cBrd.TTime; /// [s] measurement time - tstRslt.PulsesMaster = Convert.ToDouble(cBrd.EtPulses(0)); /// Pulses of the master flow meter (test total) - tstRslt.MassStartRaw = StartMass.Val; - tstRslt.MassStart = massStart; - tstRslt.MassEndRaw = EndMass.Val; - tstRslt.MassEnd = massEnd; - tstRslt.FlowMass = 3600.0 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.TestTime; /// [kg/h] - tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; /// [l/h] - tstRslt.VolumeMaster = LtrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter - tstRslt.VolumeCTV = volumeCTV; /// [l] 1000.0f is because density is in [kg/m3] - tstRslt.ConstMaster = LtrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster; /// Corrected master pulses per liter - tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV); - - tstRslt.FlowMin = (tstRslt.VolumeMaster != 0) ? (float)(RefFlowStat.Min * tstRslt.VolumeCTV / tstRslt.VolumeMaster) : RefFlowStat.Min; - tstRslt.FlowMax = (tstRslt.VolumeMaster != 0) ? (float)(RefFlowStat.Max * tstRslt.VolumeCTV / tstRslt.VolumeMaster) : RefFlowStat.Max; - - for (int i = 0; i < BatchRslts.WMPositionsCount; i++) - { - if (test.Part != 0 && test.Part != Utils.PartNr(i + 1, BatchRslts.Batch.Compound)) continue; - - Results.Entities.MeterTestRslt mainMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.CompoundMain); - Results.Entities.MeterTestRslt auxMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.CompoundAux); - - for (int isAux = 0; isAux <= 1; isAux++) /// 0=main, 1=aux - { - Results.Entities.MeterTestRslt meterRslt = (isAux == 0) ? mainMeterRslt : auxMeterRslt; - BenchControl.Elde.FixedStartRegisterReader.RegisterReader regReader = - sensPath.RegisterReaders[2 * i + isAux] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader; - - if (meterRslt != null && regReader != null) - { - meterRslt.PulsesPerLiter = 1.0f; - meterRslt.VolumeStart = regReader.BeginWMState; /// [l] - meterRslt.VolumeEnd = regReader.EndWMState; /// [l] - meterRslt.VolumeMeter = meterRslt.VolumeEnd - meterRslt.VolumeStart; /// [l] - meterRslt.VolumeRef = tstRslt.VolumeCTV; /// [l] - meterRslt.PulsesMeter = meterRslt.VolumeMeter; - meterRslt.PulsesMaster = tstRslt.PulsesMaster; - meterRslt.TestTime = tstRslt.TestTime; - meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef); /// Not used for evaluation - } - } - - Results.Entities.MeterTestRslt compoundMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Compound); - - if (compoundMeterRslt != null && mainMeterRslt != null && auxMeterRslt != null) - { - compoundMeterRslt.VolumeRef = tstRslt.VolumeCTV; /// [l] must be calculated before main & aux. meter error - compoundMeterRslt.VolumeMeter = mainMeterRslt.VolumeMeter + auxMeterRslt.VolumeMeter; - compoundMeterRslt.PulsesMaster = tstRslt.PulsesMaster; - compoundMeterRslt.TestTime = tstRslt.TestTime; - compoundMeterRslt.Error = Formulas.ErrorFromVolumes(compoundMeterRslt.VolumeMeter, compoundMeterRslt.VolumeRef); - compoundMeterRslt.Passed = (compoundMeterRslt.Error >= test.ErrLimLo + test.Uncertainty) - && (compoundMeterRslt.Error <= test.ErrLimHi - test.Uncertainty); - mainMeterRslt.Passed = auxMeterRslt.Passed = compoundMeterRslt.Passed; - mainMeterRslt.TestDone = auxMeterRslt.TestDone = compoundMeterRslt.TestDone = true; - } - } - - tstRslt.Components = Results.Entities.Components - .UpdateList(BatchRslts.ComponentsList, - new Results.Entities.Components((BenchInfo != null) ? BenchInfo.TestBenchId : 1, - (BenchInfo != null) ? BenchInfo.TestBenchName : "testbench", - inPath.Pump != null ? inPath.Pump.Name : string.Empty, - outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty, - outPath.Balance != null ? outPath.Balance.Name : string.Empty, - outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty, - outPath.Diverter != null ? outPath.Diverter.Name : string.Empty)); - - /// Update results - Bridge.OnTestCompleted(this, new TestCompletedEventArgs(testName, tstRslt)); - } - - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.TransitionAfter)); - - /// Append the results to the CSV-file - allResults.Info(TestResult2CsvLine(testName, test.Part)); - - - if (++repetitionNr <= test.Repeats) - { - goto loop; - } - - - stopTest: - - ///----------------------/// - /// Quit this sequence /// - ///----------------------/// - - State.Create("FixedStartCombinedMeters : Stopping diverter, gate, etc.") - .AddOperation(checkUiOp) - .AddOperation(cBrd.StopPreviousOp()) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; } - } - while (!e.Contains(Event.PreviousStopped)); - - /// Transition sequence at the end of test - /// Prevent overwriting 'retVal' in case it was set to non-default value earlier - switch (Transition(transitionAfter, (retVal == Event.Done) ? TransitionContext.AfterTest : TransitionContext.Stop)) - { - case Event.Error: { if (retVal == Event.Done) retVal = Event.Error; break; } - case Event.UiCmdStop: { if (retVal == Event.Done) retVal = Event.UiCmdStop; break; } - } - - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Completed)); - - /// Create a list with one item 'retVal' (default is Event.Done) and return it - IList retList = new List(1); - retList.Add(retVal); - return retList; - } - } -} diff --git a/TestBenchFramework/BenchControl/TestMethods/FixedStartCombinedMeters/TestMethod.cs b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/Compound/Component.cs similarity index 50% rename from TestBenchFramework/BenchControl/TestMethods/FixedStartCombinedMeters/TestMethod.cs rename to TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/Compound/Component.cs index 4bd2321ec..10ef0d206 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FixedStartCombinedMeters/TestMethod.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/Compound/Component.cs @@ -1,28 +1,30 @@ /// -/// Copyright (c) 2013-2015 Sensus Metering Systems +/// Copyright (c) 2013-2016 Sensus Metering Systems /// using System; using System.Collections.Generic; using log4net; using Config.Entities; -using TBF.BenchControl; -namespace TBF.BenchControl.TestMethods.FixedStartCombinedMeters +namespace TBF.BenchControl.TestMethods.FixedStartMassCollection.Compound { - public class TestMethod : ComponentBase, GenericDevices.ITestMethod + public class Component : ComponentBase, GenericDevices.ITestMethod { - private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod)); - public override string ToString() { return string.Format("TestMethods.FixedStartMassCollection({0})", Cfg.ToString(1)); } + private static readonly ILog log = LogManager.GetLogger(typeof(Component)); + public override string ToString() + { + return string.Format("{0}({1})", this.GetType().Namespace.Substring(17), Cfg.ToString(1)); + } public bool Evaluate(Test test) { return true; } public bool Publish(Test test) { return true; } public bool CanTest(MetersKind meters) { return meters == MetersKind.Combined; } - public TestMethod() + public Component() { } - public TestMethod(Generic.IComponentCfg cfg) + public Component(Generic.IComponentCfg cfg) : base(cfg) { log.Debug(this.ToString()); @@ -30,7 +32,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartCombinedMeters public IList Execute(Test test) { - return (new FixedStartCombinedMetersSeq()).Execute(test); + return (new FixedStartMassCollectionSeq()).Execute(test, true, null); } } } diff --git a/TestBenchFramework/BenchControl/TestMethods/FixedStartCombinedMeters/TestMethodFactory.cs b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/Compound/Factory.cs similarity index 52% rename from TestBenchFramework/BenchControl/TestMethods/FixedStartCombinedMeters/TestMethodFactory.cs rename to TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/Compound/Factory.cs index 035421872..697f79128 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FixedStartCombinedMeters/TestMethodFactory.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/Compound/Factory.cs @@ -5,19 +5,19 @@ using System.Collections.Generic; using TBF.BenchControl.Generic; using TBF.BenchControl.Configs.NameOnly; -namespace TBF.BenchControl.TestMethods.FixedStartCombinedMeters +namespace TBF.BenchControl.TestMethods.FixedStartMassCollection.Compound { - public class TestMethodFactory : IComponentFactory + public class Factory : IComponentFactory { - public string ClassName { get { return "FixedStartCombinedMeters"; } } + public string ClassName { get { return this.GetType().Namespace.Substring(17); } } - public void ResetStaticProperties() { TestMethod.ResetStaticProperties(); } + public void ResetStaticProperties() { Component.ResetStaticProperties(); } - public IComponent DummyComponent() { return new TestMethod(); } + public IComponent DummyComponent() { return new Component(); } - public IComponent GetComponent(IComponentCfg cfg, IList components) { return new TestMethod(cfg); } + public IComponent GetComponent(IComponentCfg cfg, IList components) { return new Component(cfg); } - public IComponentCfg DefaultConfig() { return new TestMethodCfg("FixedStartCombinedMeters", this); } + public IComponentCfg DefaultConfig() { return new TestMethodCfg(this.GetType().Namespace.Substring(29), this); } public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) { diff --git a/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs index ff753a05c..1ac14e461 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs @@ -26,7 +26,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection /// Event.OpArgumentError . Target flow is out of range /// Event.Error . . . . . . Unspecified error /// - public IList Execute(Config.Entities.Test test) + public IList Execute(Config.Entities.Test test, bool compound, HeatMeters.TestParams heatMetersTestParams) { Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; @@ -344,6 +344,21 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection RefFreq.Val = cBrd.ReferenceFreq; RefFlow.Val = cBrd.ReferenceFlow; + if (compound) + { + /// TODO: Reimplement for combined meters + //for (int i = 0; i < Config.Data.CompoundWMsCount; i++) + //{ + // data.TestResult.CombinedMeters[i].VolumeMeter = data.TestResult.Meters[2 * i].VolumeMeter + // + data.TestResult.Meters[2 * i + 1].VolumeMeter; + // if (data.Volume.Valid) + // { + // data.TestResult.CombinedMeters[i].VolumeErrorPct = + // Formulas.ErrorFromVolumes(data.TestResult.CombinedMeters[i].VolumeMeter, data.Volume.Val); + // } + //} + } + Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.Test)); Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Test)); } @@ -528,28 +543,88 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection tstRslt.FlowMin = (tstRslt.VolumeMaster != 0) ? (float)(RefFlowStat.Min * tstRslt.VolumeCTV / tstRslt.VolumeMaster) : RefFlowStat.Min; tstRslt.FlowMax = (tstRslt.VolumeMaster != 0) ? (float)(RefFlowStat.Max * tstRslt.VolumeCTV / tstRslt.VolumeMaster) : RefFlowStat.Max; - for (int i = 0; i < BatchRslts.WMPositionsCount; i++) - { - if (test.Part != 0 && test.Part != Utils.PartNr(i + 1, BatchRslts.Batch.Compound)) continue; - - Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single); - BenchControl.Elde.FixedStartRegisterReader.RegisterReader regReader = - sensPath.RegisterReaders[i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader; - - if (meterRslt != null && regReader != null) + if (compound) + { + /// + /// Compound meters + /// + for (int i = 0; i < BatchRslts.WMPositionsCount; i++) { - meterRslt.PulsesPerLiter = 1.0f; - meterRslt.VolumeStart = regReader.BeginWMState; - meterRslt.VolumeEnd = regReader.EndWMState; - meterRslt.VolumeMeter = meterRslt.VolumeEnd - meterRslt.VolumeStart; - meterRslt.VolumeRef = tstRslt.VolumeCTV; /// liter - meterRslt.PulsesMeter = meterRslt.VolumeMeter; - meterRslt.PulsesMaster = tstRslt.PulsesMaster; - meterRslt.TestTime = tstRslt.TestTime; - meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef); - meterRslt.Passed = (meterRslt.Error >= test.ErrLimLo + test.Uncertainty) - && (meterRslt.Error <= test.ErrLimHi - test.Uncertainty); - meterRslt.TestDone = true; + if (test.Part != 0 && test.Part != Utils.PartNr(i + 1, BatchRslts.Batch.Compound)) continue; + + Results.Entities.MeterTestRslt mainMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.CompoundMain); + Results.Entities.MeterTestRslt auxMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.CompoundAux); + + for (int isAux = 0; isAux <= 1; isAux++) /// 0=main, 1=aux + { + Results.Entities.MeterTestRslt meterRslt = (isAux == 0) ? mainMeterRslt : auxMeterRslt; + BenchControl.Elde.FixedStartRegisterReader.RegisterReader regReader = + sensPath.RegisterReaders[2 * i + isAux] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader; + + if (meterRslt != null && regReader != null) + { + meterRslt.PulsesPerLiter = 1.0f; + meterRslt.VolumeStart = regReader.BeginWMState; /// [l] + meterRslt.VolumeEnd = regReader.EndWMState; /// [l] + meterRslt.VolumeMeter = meterRslt.VolumeEnd - meterRslt.VolumeStart; /// [l] + meterRslt.VolumeRef = tstRslt.VolumeCTV; /// [l] + meterRslt.PulsesMeter = meterRslt.VolumeMeter; + meterRslt.PulsesMaster = tstRslt.PulsesMaster; + meterRslt.TestTime = tstRslt.TestTime; + meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef); /// Not used for evaluation + } + } + + Results.Entities.MeterTestRslt compoundMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Compound); + + if (compoundMeterRslt != null && mainMeterRslt != null && auxMeterRslt != null) + { + compoundMeterRslt.VolumeRef = tstRslt.VolumeCTV; /// [l] must be calculated before main & aux. meter error + compoundMeterRslt.VolumeMeter = mainMeterRslt.VolumeMeter + auxMeterRslt.VolumeMeter; + compoundMeterRslt.PulsesMaster = tstRslt.PulsesMaster; + compoundMeterRslt.TestTime = tstRslt.TestTime; + compoundMeterRslt.Error = Formulas.ErrorFromVolumes(compoundMeterRslt.VolumeMeter, compoundMeterRslt.VolumeRef); + compoundMeterRslt.Passed = (compoundMeterRslt.Error >= test.ErrLimLo + test.Uncertainty) + && (compoundMeterRslt.Error <= test.ErrLimHi - test.Uncertainty); + mainMeterRslt.Passed = auxMeterRslt.Passed = compoundMeterRslt.Passed; + mainMeterRslt.TestDone = auxMeterRslt.TestDone = compoundMeterRslt.TestDone = true; + } + } + } + else if (heatMetersTestParams != null) + { + /// + /// Heat meters + /// + } + else + { + /// + /// Single meters + /// + for (int i = 0; i < BatchRslts.WMPositionsCount; i++) + { + if (test.Part != 0 && test.Part != Utils.PartNr(i + 1, BatchRslts.Batch.Compound)) continue; + + Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single); + BenchControl.Elde.FixedStartRegisterReader.RegisterReader regReader = + sensPath.RegisterReaders[i] as BenchControl.Elde.FixedStartRegisterReader.RegisterReader; + + if (meterRslt != null && regReader != null) + { + meterRslt.PulsesPerLiter = 1.0f; + meterRslt.VolumeStart = regReader.BeginWMState; + meterRslt.VolumeEnd = regReader.EndWMState; + meterRslt.VolumeMeter = meterRslt.VolumeEnd - meterRslt.VolumeStart; + meterRslt.VolumeRef = tstRslt.VolumeCTV; /// liter + meterRslt.PulsesMeter = meterRslt.VolumeMeter; + meterRslt.PulsesMaster = tstRslt.PulsesMaster; + meterRslt.TestTime = tstRslt.TestTime; + meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef); + meterRslt.Passed = (meterRslt.Error >= test.ErrLimLo + test.Uncertainty) + && (meterRslt.Error <= test.ErrLimHi - test.Uncertainty); + meterRslt.TestDone = true; + } } } diff --git a/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/HeatMeters/Component.cs b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/HeatMeters/Component.cs new file mode 100644 index 000000000..015e27198 --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/HeatMeters/Component.cs @@ -0,0 +1,41 @@ +/// +/// Copyright (c) 2013-2016 Sensus Metering Systems +/// +using System; +using System.Collections.Generic; +using log4net; +using Config.Entities; + +namespace TBF.BenchControl.TestMethods.FixedStartMassCollection.HeatMeters +{ + public class Component : ComponentBase, GenericDevices.ITestMethod + { + private static readonly ILog log = LogManager.GetLogger(typeof(Component)); + public override string ToString() + { + return string.Format("{0}({1})", this.GetType().Namespace.Substring(17), Cfg.ToString(1)); + } + + readonly TestMethodCfg testMethodCfg; + + public bool Evaluate(Test test) { return true; } + public bool Publish(Test test) { return true; } + public bool CanTest(MetersKind meters) { return meters == MetersKind.HeatMeter; } + + public Component() + { + } + + public Component(Generic.IComponentCfg cfg) + : base(cfg) + { + testMethodCfg = cfg as TestMethodCfg; + log.Debug(this.ToString()); + } + + public IList Execute(Test test) + { + return (new FixedStartMassCollectionSeq()).Execute(test, false, testMethodCfg.TestParams); + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/HeatMeters/Factory.cs b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/HeatMeters/Factory.cs new file mode 100644 index 000000000..40f1237f4 --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/HeatMeters/Factory.cs @@ -0,0 +1,26 @@ +/// +/// Copyright (c) 2013-2016 Sensus Metering Systems +/// +using System.Collections.Generic; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.TestMethods.FixedStartMassCollection.HeatMeters +{ + public class Factory : IComponentFactory + { + public string ClassName { get { return this.GetType().Namespace.Substring(17); } } + + public void ResetStaticProperties() { Component.ResetStaticProperties(); } + + public IComponent DummyComponent() { return new Component(); } + + public IComponent GetComponent(IComponentCfg cfg, IList components) { return new Component(cfg); } + + public IComponentCfg DefaultConfig() { return new TestMethodCfg(this.GetType().Namespace.Substring(29), this); } + + public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) + { + return ComponentCfgBase.CreateFromDbEntity(typeof(TestMethodCfg), component, this); + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/HeatMeters/TestMethodCfg.cs b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/HeatMeters/TestMethodCfg.cs similarity index 54% rename from TestBenchFramework/BenchControl/TestMethods/HeatMeters/TestMethodCfg.cs rename to TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/HeatMeters/TestMethodCfg.cs index 1ba517262..fb227f6a7 100644 --- a/TestBenchFramework/BenchControl/TestMethods/HeatMeters/TestMethodCfg.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/HeatMeters/TestMethodCfg.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2016 Sensus Metering Systems +/// Copyright (c) 2013-2016 Sensus Metering Systems /// using System; using System.Collections.Generic; @@ -8,7 +8,7 @@ using System.Xml.Serialization; using Config.Entities; using TBF.BenchControl.Generic; -namespace TBF.BenchControl.TestMethods.HeatMeters +namespace TBF.BenchControl.TestMethods.FixedStartMassCollection.HeatMeters { public class TestMethodCfg : ComponentCfgBase, Generic.IComponentCfg { @@ -16,32 +16,32 @@ namespace TBF.BenchControl.TestMethods.HeatMeters /// Test parameters [XmlIgnore] - public HeatTestParams TestParams; + public TestParams TestParams; public override IParamsProvider GetTestParams() { return TestParams; } public override IParamsProvider CreateTestParams(Test test) { - HeatTestParams testParams = new HeatTestParams(); + TestParams testParams = new TestParams(); testParams.UpdateTestParams(Name, test); return testParams; } /// Private parameterless constructor invoked by all other (public) constructors TestMethodCfg() - { - Name = "HeatMeters"; - ParentName = string.Empty; - TestParams = new HeatTestParams(); - } + { + TestParams = new TestParams(); + } - public TestMethodCfg(IComponentFactory factory) - : this() - { - this.Factory = factory; - } + public TestMethodCfg(string name, IComponentFactory factory) + : this() + { + Name = name; + Factory = factory; + ParentName = string.Empty; + } - public string ToString(int i) - { - return string.Format("Name={0}", Name); - } - } + public string ToString(int i) + { + return string.Format("Name={0}", Name); + } + } } diff --git a/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/HeatMeters/TestMethodCfgCtrl.cs b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/HeatMeters/TestMethodCfgCtrl.cs new file mode 100644 index 000000000..0fdee794c --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/HeatMeters/TestMethodCfgCtrl.cs @@ -0,0 +1,71 @@ +/// +/// Copyright (c) 2013-2016 Sensus Metering Systems +/// +using System; +using System.Windows.Forms; +using log4net; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.TestMethods.FixedStartMassCollection.HeatMeters +{ + public partial class TestMethodCfgCtrl : UserControl, IComponentCfgCtrl + { + static readonly ILog log = LogManager.GetLogger(typeof(TestMethodCfgCtrl)); + + public bool ShowMore { get { return false; } } + + TestMethodCfg config; + public IComponentCfg Config + { + get { return config as IComponentCfg; } + set + { + config = value as TestMethodCfg; + Redraw(); + } + } + + public TestMethodCfgCtrl() + { + InitializeComponent(); + } + + private void EntryFormCfgCtrl_Load(object sender, EventArgs e) + { + Redraw(); + } + + public void Closing() + { + } + + void Redraw() + { + if (config == null) return; /// Control was not loaded, settings were not changed + classNameLabel.Text = config.Factory.ClassName; + nameTextBox.Text = config.Name; + } + + public void Unlock() + { + nameTextBox.Enabled = true; + } + + public CfgUpdateFlags VerifyCfg(ref string message) + { + CfgUpdateFlags flags = CfgUpdateFlags.None; + return flags; + } + + public CfgUpdateFlags UpdateCfg() + { + CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd; + + if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed + + config.Name = nameTextBox.Text; + + return flags; + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/HeatMeters/TestMethodCfgCtrl.designer.cs b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/HeatMeters/TestMethodCfgCtrl.designer.cs new file mode 100644 index 000000000..aa80b5115 --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/HeatMeters/TestMethodCfgCtrl.designer.cs @@ -0,0 +1,86 @@ +/// +/// Copyright (c) 2013-2016 Sensus Metering Systems +/// +namespace TBF.BenchControl.TestMethods.FixedStartMassCollection.HeatMeters +{ + partial class TestMethodCfgCtrl + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.nameTextBox = new System.Windows.Forms.TextBox(); + this.nameLabel = new System.Windows.Forms.Label(); + this.classNameLabel = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // nameTextBox + // + this.nameTextBox.Enabled = false; + this.nameTextBox.Location = new System.Drawing.Point(137, 57); + this.nameTextBox.Name = "nameTextBox"; + this.nameTextBox.Size = new System.Drawing.Size(130, 20); + this.nameTextBox.TabIndex = 5; + // + // nameLabel + // + this.nameLabel.AutoSize = true; + this.nameLabel.Location = new System.Drawing.Point(27, 60); + this.nameLabel.Name = "nameLabel"; + this.nameLabel.Size = new System.Drawing.Size(35, 13); + this.nameLabel.TabIndex = 4; + this.nameLabel.Text = "Name"; + // + // classNameLabel + // + this.classNameLabel.AutoSize = true; + this.classNameLabel.Location = new System.Drawing.Point(134, 33); + this.classNameLabel.Name = "classNameLabel"; + this.classNameLabel.Size = new System.Drawing.Size(83, 13); + this.classNameLabel.TabIndex = 3; + this.classNameLabel.Text = "ComonentName"; + // + // BasicPrinterCfgCtrl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.nameTextBox); + this.Controls.Add(this.nameLabel); + this.Controls.Add(this.classNameLabel); + this.Name = "BasicPrinterCfgCtrl"; + this.Size = new System.Drawing.Size(300, 200); + this.Load += new System.EventHandler(this.EntryFormCfgCtrl_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox nameTextBox; + private System.Windows.Forms.Label nameLabel; + private System.Windows.Forms.Label classNameLabel; + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/TestMethodCfgCtrl.resx b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/HeatMeters/TestMethodCfgCtrl.resx similarity index 100% rename from TestBenchFramework/BenchControl/TestMethods/CombinedMeters/TestMethodCfgCtrl.resx rename to TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/HeatMeters/TestMethodCfgCtrl.resx diff --git a/TestBenchFramework/BenchControl/TestMethods/HeatMeters/HeatTestParams.cs b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/HeatMeters/TestParams.cs similarity index 81% rename from TestBenchFramework/BenchControl/TestMethods/HeatMeters/HeatTestParams.cs rename to TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/HeatMeters/TestParams.cs index aefceb6bc..f1ea8a7af 100644 --- a/TestBenchFramework/BenchControl/TestMethods/HeatMeters/HeatTestParams.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/HeatMeters/TestParams.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2016 Sensus Metering Systems +/// Copyright (c) 2013-2016 Sensus Metering Systems /// using System; using System.IO; @@ -9,9 +9,9 @@ using Config.Entities; using TBF.BenchControl.Generic; using TBF.Resources; -namespace TBF.BenchControl.TestMethods.HeatMeters +namespace TBF.BenchControl.TestMethods.FixedStartMassCollection.HeatMeters { - public class HeatTestParams : TestParamsBase, IParamsProvider, ITestParams + public class TestParams : TestParamsBase, IParamsProvider, ITestParams { public bool SupressTrills; /// Main meter readings are ignored during test (suitable for small flows) @@ -64,14 +64,14 @@ namespace TBF.BenchControl.TestMethods.HeatMeters return false; } - void CopyContentTo(HeatTestParams prms) + void CopyContentTo(TestParams prms) { prms.SupressTrills = this.SupressTrills; } public IParamsProvider Clone() { - HeatTestParams pars = new HeatTestParams(); + TestParams pars = new TestParams(); CopyContentTo(pars); return pars; } @@ -81,7 +81,7 @@ namespace TBF.BenchControl.TestMethods.HeatMeters if (dbEntity == null) return; try { - HeatTestParams tmp = (HeatTestParams)(new XmlSerializer(typeof(HeatTestParams))) + TestParams tmp = (TestParams)(new XmlSerializer(typeof(TestParams))) .Deserialize(new StringReader(dbEntity.Parameters)); testParamsEntity = dbEntity; @@ -98,11 +98,11 @@ namespace TBF.BenchControl.TestMethods.HeatMeters /// /// Parameterless constructor initializes the parameters /// - public HeatTestParams() + public TestParams() { } - public HeatTestParams(ComponentTest testParamsEntity, string componentName, Test test) + public TestParams(ComponentTest testParamsEntity, string componentName, Test test) { this.testParamsEntity = testParamsEntity; this.componentName = componentName; diff --git a/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/TestMethod.cs b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/Single/Component.cs similarity index 50% rename from TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/TestMethod.cs rename to TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/Single/Component.cs index 1551bb733..1d04ef8cf 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/TestMethod.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/Single/Component.cs @@ -1,28 +1,30 @@ /// -/// Copyright (c) 2013-2015 Sensus Metering Systems +/// Copyright (c) 2013-2016 Sensus Metering Systems /// using System; using System.Collections.Generic; using log4net; using Config.Entities; -using TBF.BenchControl; -namespace TBF.BenchControl.TestMethods.FixedStartMassCollection +namespace TBF.BenchControl.TestMethods.FixedStartMassCollection.Single { - public class TestMethod : ComponentBase, GenericDevices.ITestMethod + public class Component : ComponentBase, GenericDevices.ITestMethod { - private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod)); - public override string ToString() { return string.Format("TestMethods.FixedStartMassCollection({0})", Cfg.ToString(1)); } + private static readonly ILog log = LogManager.GetLogger(typeof(Component)); + public override string ToString() + { + return string.Format("{0}({1})", this.GetType().Namespace.Substring(17), Cfg.ToString(1)); + } public bool Evaluate(Test test) { return true; } public bool Publish(Test test) { return true; } public bool CanTest(MetersKind meters) { return meters == MetersKind.Single; } - public TestMethod() + public Component() { } - public TestMethod(Generic.IComponentCfg cfg) + public Component(Generic.IComponentCfg cfg) : base(cfg) { log.Debug(this.ToString()); @@ -30,7 +32,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection public IList Execute(Test test) { - return (new FixedStartMassCollectionSeq()).Execute(test); + return (new FixedStartMassCollectionSeq()).Execute(test, false, null); } } } diff --git a/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/TestMethodFactory.cs b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/Single/Factory.cs similarity index 52% rename from TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/TestMethodFactory.cs rename to TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/Single/Factory.cs index 2f207c743..aba42036f 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/TestMethodFactory.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FixedStartMassCollection/Single/Factory.cs @@ -5,19 +5,19 @@ using System.Collections.Generic; using TBF.BenchControl.Generic; using TBF.BenchControl.Configs.NameOnly; -namespace TBF.BenchControl.TestMethods.FixedStartMassCollection +namespace TBF.BenchControl.TestMethods.FixedStartMassCollection.Single { - public class TestMethodFactory : IComponentFactory + public class Factory : IComponentFactory { - public string ClassName { get { return "FixedStartMassCollection"; } } + public string ClassName { get { return this.GetType().Namespace.Substring(17); } } - public void ResetStaticProperties() { TestMethod.ResetStaticProperties(); } + public void ResetStaticProperties() { Component.ResetStaticProperties(); } - public IComponent DummyComponent() { return new TestMethod(); } + public IComponent DummyComponent() { return new Component(); } - public IComponent GetComponent(IComponentCfg cfg, IList components) { return new TestMethod(cfg); } + public IComponent GetComponent(IComponentCfg cfg, IList components) { return new Component(cfg); } - public IComponentCfg DefaultConfig() { return new TestMethodCfg("FixedStartMassCollection", this); } + public IComponentCfg DefaultConfig() { return new TestMethodCfg(this.GetType().Namespace.Substring(29), this); } public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) { diff --git a/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/TestMethod.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/Compound/Component.cs similarity index 53% rename from TestBenchFramework/BenchControl/TestMethods/CombinedMeters/TestMethod.cs rename to TestBenchFramework/BenchControl/TestMethods/FlyingStart/Compound/Component.cs index 274f5da08..77e9865e0 100644 --- a/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/TestMethod.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/Compound/Component.cs @@ -1,18 +1,20 @@ /// -/// Copyright (c) 2013-2015 Sensus Metering Systems +/// Copyright (c) 2013-2016 Sensus Metering Systems /// using System; using System.Collections.Generic; using log4net; using Config.Entities; -using TBF.BenchControl; -namespace TBF.BenchControl.TestMethods.CombinedMeters +namespace TBF.BenchControl.TestMethods.FlyingStart.Compound { - public class TestMethod : ComponentBase, GenericDevices.ITestMethod + public class Component : ComponentBase, GenericDevices.ITestMethod { - private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod)); - public override string ToString() { return string.Format("TestMethods.CombinedMeters({0})", Cfg.ToString(1)); } + private static readonly ILog log = LogManager.GetLogger(typeof(Component)); + public override string ToString() + { + return string.Format("{0}({1})", this.GetType().Namespace.Substring(17), Cfg.ToString(1)); + } readonly TestMethodCfg testMethodCfg; @@ -20,11 +22,11 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters public bool Publish(Test test) { return true; } public bool CanTest(MetersKind meters) { return meters == MetersKind.Combined; } - public TestMethod() + public Component() { } - public TestMethod(Generic.IComponentCfg cfg) + public Component(Generic.IComponentCfg cfg) : base(cfg) { testMethodCfg = cfg as TestMethodCfg; @@ -33,7 +35,7 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters public IList Execute(Test test) { - return (new CombinedMetersSeq()).Execute(test, testMethodCfg.TestParams); + return (new FlyingStartSeq()).Execute(test, testMethodCfg.TestParams, null); } } } diff --git a/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/TestMethodFactory.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/Compound/Factory.cs similarity index 51% rename from TestBenchFramework/BenchControl/TestMethods/CombinedMeters/TestMethodFactory.cs rename to TestBenchFramework/BenchControl/TestMethods/FlyingStart/Compound/Factory.cs index e4d4e8c5e..6e0a814e6 100644 --- a/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/TestMethodFactory.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/Compound/Factory.cs @@ -4,19 +4,19 @@ using System.Collections.Generic; using TBF.BenchControl.Generic; -namespace TBF.BenchControl.TestMethods.CombinedMeters +namespace TBF.BenchControl.TestMethods.FlyingStart.Compound { - public class TestMethodFactory : IComponentFactory + public class Factory : IComponentFactory { - public string ClassName { get { return "CombinedMeters"; } } + public string ClassName { get { return this.GetType().Namespace.Substring(17); } } - public void ResetStaticProperties() { TestMethod.ResetStaticProperties(); } + public void ResetStaticProperties() { Component.ResetStaticProperties(); } - public IComponent DummyComponent() { return new TestMethod(); } + public IComponent DummyComponent() { return new Component(); } - public IComponent GetComponent(IComponentCfg cfg, IList components) { return new TestMethod(cfg); } + public IComponent GetComponent(IComponentCfg cfg, IList components) { return new Component(cfg); } - public IComponentCfg DefaultConfig() { return new TestMethodCfg(this); } + public IComponentCfg DefaultConfig() { return new TestMethodCfg(this.GetType().Namespace.Substring(29), this); } public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) { diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStart/Compound/TestMethodCfg.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/Compound/TestMethodCfg.cs new file mode 100644 index 000000000..d43a1e502 --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/Compound/TestMethodCfg.cs @@ -0,0 +1,47 @@ +/// +/// Copyright (c) 2013-2016 Sensus Metering Systems +/// +using System; +using System.Collections.Generic; +using System.IO; +using System.Xml.Serialization; +using Config.Entities; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.TestMethods.FlyingStart.Compound +{ + public class TestMethodCfg : ComponentCfgBase, Generic.IComponentCfg + { + public IComponentCfgCtrl GetControl() { return new TestMethodCfgCtrl(); } + + /// Test parameters + [XmlIgnore] + public TestParams TestParams; + public override IParamsProvider GetTestParams() { return TestParams; } + public override IParamsProvider CreateTestParams(Test test) + { + TestParams testParams = new TestParams(); + testParams.UpdateTestParams(Name, test); + return testParams; + } + + /// Private parameterless constructor invoked by all other (public) constructors + TestMethodCfg() + { + TestParams = new TestParams(); + } + + public TestMethodCfg(string name, IComponentFactory factory) + : this() + { + Name = name; + Factory = factory; + ParentName = string.Empty; + } + + public string ToString(int i) + { + return string.Format("Name={0}", Name); + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/HeatMeters/TestMethodCfgCtrl.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/Compound/TestMethodCfgCtrl.cs similarity index 92% rename from TestBenchFramework/BenchControl/TestMethods/HeatMeters/TestMethodCfgCtrl.cs rename to TestBenchFramework/BenchControl/TestMethods/FlyingStart/Compound/TestMethodCfgCtrl.cs index e05395951..b6ed30a8a 100644 --- a/TestBenchFramework/BenchControl/TestMethods/HeatMeters/TestMethodCfgCtrl.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/Compound/TestMethodCfgCtrl.cs @@ -1,12 +1,12 @@ /// -/// Copyright (c) 2016 Sensus Metering Systems +/// Copyright (c) 2013-2016 Sensus Metering Systems /// using System; using System.Windows.Forms; using log4net; using TBF.BenchControl.Generic; -namespace TBF.BenchControl.TestMethods.HeatMeters +namespace TBF.BenchControl.TestMethods.FlyingStart.Compound { public partial class TestMethodCfgCtrl : UserControl, IComponentCfgCtrl { diff --git a/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/TestMethodCfgCtrl.designer.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/Compound/TestMethodCfgCtrl.designer.cs similarity index 95% rename from TestBenchFramework/BenchControl/TestMethods/CombinedMeters/TestMethodCfgCtrl.designer.cs rename to TestBenchFramework/BenchControl/TestMethods/FlyingStart/Compound/TestMethodCfgCtrl.designer.cs index b3c252a8c..0e0e263cd 100644 --- a/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/TestMethodCfgCtrl.designer.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/Compound/TestMethodCfgCtrl.designer.cs @@ -1,7 +1,7 @@ /// -/// Copyright (c) 2013-2015 Sensus Metering Systems +/// Copyright (c) 2013-2016 Sensus Metering Systems /// -namespace TBF.BenchControl.TestMethods.CombinedMeters +namespace TBF.BenchControl.TestMethods.FlyingStart.Compound { partial class TestMethodCfgCtrl { diff --git a/TestBenchFramework/BenchControl/TestMethods/HeatMeters/TestMethodCfgCtrl.resx b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/Compound/TestMethodCfgCtrl.resx similarity index 100% rename from TestBenchFramework/BenchControl/TestMethods/HeatMeters/TestMethodCfgCtrl.resx rename to TestBenchFramework/BenchControl/TestMethods/FlyingStart/Compound/TestMethodCfgCtrl.resx diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStart/Compound/TestParams.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/Compound/TestParams.cs new file mode 100644 index 000000000..da44a6965 --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/Compound/TestParams.cs @@ -0,0 +1,112 @@ +/// +/// Copyright (c) 2013-2016 Sensus Metering Systems +/// +using System; +using System.IO; +using System.Text; +using System.Xml.Serialization; +using Config.Entities; +using TBF.BenchControl.Generic; +using TBF.Resources; + +namespace TBF.BenchControl.TestMethods.FlyingStart.Compound +{ + public class TestParams : TestParamsBase, IParamsProvider, ITestParams + { + public bool SupressTrills; /// Main meter readings are ignored during test (suitable for small flows) + + public override void InitializeAll() + { + SupressTrills = false; + } + + + string[] paramNames = new string[] + { + Strings.SupressWMTrills, + }; + public override string ParamName(int i) { return paramNames[i]; } + public override int ParamsCount() { return paramNames.Length; } + + public override string ToString(int i) + { + switch (i) + { + case 0: return (SupressTrills ? Strings.yes : Strings.no); + default: return string.Empty; + } + } + + public void UpdateParam(int i, string strValue) + { + switch (i) + { + case 0: SupressTrills = strValue.Equals(Strings.yes); return; + default: return; + } + } + + public bool ValidateParam(int i, string strValue, out string message) + { + message = string.Empty; + + switch (i) + { + case 0: + if (strValue.Equals(Strings.yes) || strValue.Equals(Strings.no)) return true; + break; + default: + message = "Invalid index"; + return false; + } + + message = ParamName(i) + " is invalid"; + return false; + } + + void CopyContentTo(TestParams prms) + { + prms.SupressTrills = this.SupressTrills; + } + + public IParamsProvider Clone() + { + TestParams pars = new TestParams(); + CopyContentTo(pars); + return pars; + } + + public override void UpdateTestParams(ComponentTest dbEntity) + { + if (dbEntity == null) return; + try + { + TestParams tmp = (TestParams)(new XmlSerializer(typeof(TestParams))) + .Deserialize(new StringReader(dbEntity.Parameters)); + + testParamsEntity = dbEntity; + componentName = dbEntity.CmpntName; + test = dbEntity.Test; + + tmp.CopyContentTo(this); + } + catch + { + } + } + + /// + /// Parameterless constructor initializes the parameters + /// + public TestParams() + { + } + + public TestParams(ComponentTest testParamsEntity, string componentName, Test test) + { + this.testParamsEntity = testParamsEntity; + this.componentName = componentName; + this.test = test; + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs index 2e4c89434..032c4f812 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/FlyingStartSeq.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2013-2015 Sensus Metering Systems +/// Copyright (c) 2013-2016 Sensus Metering Systems /// using System; using System.Collections.Generic; @@ -26,7 +26,9 @@ namespace TBF.BenchControl.TestMethods.FlyingStart /// Event.OpArgumentError . Target flow is out of range /// Event.Error . . . . . . Unspecified error /// - public IList Execute(Config.Entities.Test test) + public IList Execute(Config.Entities.Test test, + Compound.TestParams compoundTestParams, + HeatMeters.TestParams heatMetersTestParams) { Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; @@ -276,51 +278,70 @@ namespace TBF.BenchControl.TestMethods.FlyingStart tstRslt.FlowMin = (tstRslt.VolumeMaster != 0) ? (float)(RefFlowStat.Min * tstRslt.VolumeCTV / tstRslt.VolumeMaster) : RefFlowStat.Min; tstRslt.FlowMax = (tstRslt.VolumeMaster != 0) ? (float)(RefFlowStat.Max * tstRslt.VolumeCTV / tstRslt.VolumeMaster) : RefFlowStat.Max; - for (int i = 0; i < BatchRslts.WMPositionsCount; i++) - { - if (test.Part != 0 && test.Part != Utils.PartNr(i + 1, BatchRslts.Batch.Compound)) continue; - - Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single); - GenericDevices.IRegisterReader regReader = sensPath.RegisterReaders[i]; - WaterMeters.iPerl.WaterMeter iPerl = regReader as WaterMeters.iPerl.WaterMeter; - - if (meterRslt != null && regReader != null) + if (compoundTestParams != null) + { + /// + /// Compound meters + /// + /// TODO + } + else if (heatMetersTestParams != null) + { + /// + /// Heat meters + /// + } + else + { + /// + /// Single meters + /// + for (int i = 0; i < BatchRslts.WMPositionsCount; i++) { - meterRslt.PulsesPerLiter = regReader.PulsesPerLtr; - meterRslt.PulsesMeter = Convert.ToDouble(regReader.WMPulses); - meterRslt.PulsesMaster = Convert.ToDouble(regReader.WMRefPulses); + if (test.Part != 0 && test.Part != Utils.PartNr(i + 1, BatchRslts.Batch.Compound)) continue; - if (iPerl != null) + Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single); + GenericDevices.IRegisterReader regReader = sensPath.RegisterReaders[i]; + WaterMeters.iPerl.WaterMeter iPerl = regReader as WaterMeters.iPerl.WaterMeter; + + if (meterRslt != null && regReader != null) { - meterRslt.TimestampStart = iPerl.TimestampSecStart; - meterRslt.TimestampEnd = iPerl.NoSamples ? (iPerl.TimestampSecStart + tstRslt.TestTime) : iPerl.TimestampSecEnd; - meterRslt.TestTime = iPerl.NoSamples ? tstRslt.TestTime : (meterRslt.TimestampEnd - meterRslt.TimestampStart); - meterRslt.VolumeStart = iPerl.VolumeLtrStart; /// liter - meterRslt.VolumeEnd = iPerl.VolumeLtrEnd; /// liter - meterRslt.VolumeMeter = Math.Abs(iPerl.VolumeLtrEnd - iPerl.VolumeLtrStart); - meterRslt.VolumeRef = tstRslt.VolumeCTV * meterRslt.TestTime / tstRslt.TestTime; - iPerl.VolumeLtrRef = meterRslt.VolumeRef; -#if IPERLST || IPERLST_SPECIAL - meterRslt.WaterMeter.CalibFactor = (iPerl.CalibrationStruct != null) ? iPerl.CalibrationStruct.Calibration : 0; + meterRslt.PulsesPerLiter = regReader.PulsesPerLtr; + meterRslt.PulsesMeter = Convert.ToDouble(regReader.WMPulses); + meterRslt.PulsesMaster = Convert.ToDouble(regReader.WMRefPulses); + + if (iPerl != null) + { + meterRslt.TimestampStart = iPerl.TimestampSecStart; + meterRslt.TimestampEnd = iPerl.NoSamples ? (iPerl.TimestampSecStart + tstRslt.TestTime) : iPerl.TimestampSecEnd; + meterRslt.TestTime = iPerl.NoSamples ? tstRslt.TestTime : (meterRslt.TimestampEnd - meterRslt.TimestampStart); + meterRslt.VolumeStart = iPerl.VolumeLtrStart; /// liter + meterRslt.VolumeEnd = iPerl.VolumeLtrEnd; /// liter + meterRslt.VolumeMeter = Math.Abs(iPerl.VolumeLtrEnd - iPerl.VolumeLtrStart); + meterRslt.VolumeRef = tstRslt.VolumeCTV * meterRslt.TestTime / tstRslt.TestTime; + iPerl.VolumeLtrRef = meterRslt.VolumeRef; + #if IPERLST || IPERLST_SPECIAL + meterRslt.WaterMeter.CalibFactor = (iPerl.CalibrationStruct != null) ? iPerl.CalibrationStruct.Calibration : 0; meterRslt.WaterMeter.Q2Correction = iPerl.Q2CorrectionFactor; -#endif - iPerl.LastTestResult2 = iPerl.LastTestResult; /// Save shift previous test result - iPerl.LastTestResult = meterRslt; /// Save this test result - iPerl.NominalTestFlow = 500.0 * (test.Qfrom + test.Qto); /// Ave. + convert to liter/hour - } - else - { - meterRslt.TestTime = tstRslt.TestTime; /// TODO: Malo by sa citat z dosky - meterRslt.VolumeStart = 0; - meterRslt.VolumeEnd = 0; - meterRslt.VolumeMeter = meterRslt.PulsesMeter * regReader.LtrsPerPulse; /// liter - meterRslt.VolumeRef = meterRslt.PulsesMaster * tstRslt.ConstMaster; /// liter - } + #endif + iPerl.LastTestResult2 = iPerl.LastTestResult; /// Save shift previous test result + iPerl.LastTestResult = meterRslt; /// Save this test result + iPerl.NominalTestFlow = 500.0 * (test.Qfrom + test.Qto); /// Ave. + convert to liter/hour + } + else + { + meterRslt.TestTime = tstRslt.TestTime; /// TODO: Malo by sa citat z dosky + meterRslt.VolumeStart = 0; + meterRslt.VolumeEnd = 0; + meterRslt.VolumeMeter = meterRslt.PulsesMeter * regReader.LtrsPerPulse; /// liter + meterRslt.VolumeRef = meterRslt.PulsesMaster * tstRslt.ConstMaster; /// liter + } - meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef); - meterRslt.Passed = (meterRslt.Error >= test.ErrLimLo + test.Uncertainty) - && (meterRslt.Error <= test.ErrLimHi - test.Uncertainty); - meterRslt.TestDone = true; + meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef); + meterRslt.Passed = (meterRslt.Error >= test.ErrLimLo + test.Uncertainty) + && (meterRslt.Error <= test.ErrLimHi - test.Uncertainty); + meterRslt.TestDone = true; + } } } diff --git a/TestBenchFramework/BenchControl/TestMethods/HeatMeters/TestMethod.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/HeatMeters/Component.cs similarity index 53% rename from TestBenchFramework/BenchControl/TestMethods/HeatMeters/TestMethod.cs rename to TestBenchFramework/BenchControl/TestMethods/FlyingStart/HeatMeters/Component.cs index 12f5e19e2..fd8dbc5df 100644 --- a/TestBenchFramework/BenchControl/TestMethods/HeatMeters/TestMethod.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/HeatMeters/Component.cs @@ -1,18 +1,20 @@ /// -/// Copyright (c) 2016 Sensus Metering Systems +/// Copyright (c) 2013-2016 Sensus Metering Systems /// using System; using System.Collections.Generic; using log4net; using Config.Entities; -using TBF.BenchControl; -namespace TBF.BenchControl.TestMethods.HeatMeters +namespace TBF.BenchControl.TestMethods.FlyingStart.HeatMeters { - public class TestMethod : ComponentBase, GenericDevices.ITestMethod + public class Component : ComponentBase, GenericDevices.ITestMethod { - private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod)); - public override string ToString() { return string.Format("TestMethods.HeatMeters({0})", Cfg.ToString(1)); } + private static readonly ILog log = LogManager.GetLogger(typeof(Component)); + public override string ToString() + { + return string.Format("{0}({1})", this.GetType().Namespace.Substring(17), Cfg.ToString(1)); + } readonly TestMethodCfg testMethodCfg; @@ -20,20 +22,20 @@ namespace TBF.BenchControl.TestMethods.HeatMeters public bool Publish(Test test) { return true; } public bool CanTest(MetersKind meters) { return meters == MetersKind.HeatMeter; } - public TestMethod() + public Component() { } - public TestMethod(Generic.IComponentCfg cfg) + public Component(Generic.IComponentCfg cfg) : base(cfg) - { + { testMethodCfg = cfg as TestMethodCfg; log.Debug(this.ToString()); } public IList Execute(Test test) { - return (new HeatMetersSeq()).Execute(test, testMethodCfg.TestParams); + return (new FlyingStartSeq()).Execute(test, null, testMethodCfg.TestParams); } } } diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStart/HeatMeters/Factory.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/HeatMeters/Factory.cs new file mode 100644 index 000000000..34da203ac --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/HeatMeters/Factory.cs @@ -0,0 +1,26 @@ +/// +/// Copyright (c) 2013-2016 Sensus Metering Systems +/// +using System.Collections.Generic; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.TestMethods.FlyingStart.HeatMeters +{ + public class Factory : IComponentFactory + { + public string ClassName { get { return this.GetType().Namespace.Substring(17); } } + + public void ResetStaticProperties() { Component.ResetStaticProperties(); } + + public IComponent DummyComponent() { return new Component(); } + + public IComponent GetComponent(IComponentCfg cfg, IList components) { return new Component(cfg); } + + public IComponentCfg DefaultConfig() { return new TestMethodCfg(this.GetType().Namespace.Substring(29), this); } + + public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) + { + return ComponentCfgBase.CreateFromDbEntity(typeof(TestMethodCfg), component, this); + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStart/HeatMeters/TestMethodCfg.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/HeatMeters/TestMethodCfg.cs new file mode 100644 index 000000000..8617305bb --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/HeatMeters/TestMethodCfg.cs @@ -0,0 +1,47 @@ +/// +/// Copyright (c) 2013-2016 Sensus Metering Systems +/// +using System; +using System.Collections.Generic; +using System.IO; +using System.Xml.Serialization; +using Config.Entities; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.TestMethods.FlyingStart.HeatMeters +{ + public class TestMethodCfg : ComponentCfgBase, Generic.IComponentCfg + { + public IComponentCfgCtrl GetControl() { return new TestMethodCfgCtrl(); } + + /// Test parameters + [XmlIgnore] + public TestParams TestParams; + public override IParamsProvider GetTestParams() { return TestParams; } + public override IParamsProvider CreateTestParams(Test test) + { + TestParams testParams = new TestParams(); + testParams.UpdateTestParams(Name, test); + return testParams; + } + + /// Private parameterless constructor invoked by all other (public) constructors + TestMethodCfg() + { + TestParams = new TestParams(); + } + + public TestMethodCfg(string name, IComponentFactory factory) + : this() + { + Name = name; + Factory = factory; + ParentName = string.Empty; + } + + public string ToString(int i) + { + return string.Format("Name={0}", Name); + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/TestMethodCfgCtrl.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/HeatMeters/TestMethodCfgCtrl.cs similarity index 92% rename from TestBenchFramework/BenchControl/TestMethods/CombinedMeters/TestMethodCfgCtrl.cs rename to TestBenchFramework/BenchControl/TestMethods/FlyingStart/HeatMeters/TestMethodCfgCtrl.cs index 0e85b5436..7fc8b493f 100644 --- a/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/TestMethodCfgCtrl.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/HeatMeters/TestMethodCfgCtrl.cs @@ -1,12 +1,12 @@ /// -/// Copyright (c) 2013-2015 Sensus Metering Systems +/// Copyright (c) 2013-2016 Sensus Metering Systems /// using System; using System.Windows.Forms; using log4net; using TBF.BenchControl.Generic; -namespace TBF.BenchControl.TestMethods.CombinedMeters +namespace TBF.BenchControl.TestMethods.FlyingStart.HeatMeters { public partial class TestMethodCfgCtrl : UserControl, IComponentCfgCtrl { diff --git a/TestBenchFramework/BenchControl/TestMethods/HeatMeters/TestMethodCfgCtrl.designer.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/HeatMeters/TestMethodCfgCtrl.designer.cs similarity index 95% rename from TestBenchFramework/BenchControl/TestMethods/HeatMeters/TestMethodCfgCtrl.designer.cs rename to TestBenchFramework/BenchControl/TestMethods/FlyingStart/HeatMeters/TestMethodCfgCtrl.designer.cs index 8ceab0b3a..9c17f60f4 100644 --- a/TestBenchFramework/BenchControl/TestMethods/HeatMeters/TestMethodCfgCtrl.designer.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/HeatMeters/TestMethodCfgCtrl.designer.cs @@ -1,7 +1,7 @@ /// -/// Copyright (c) 2016 Sensus Metering Systems +/// Copyright (c) 2013-2016 Sensus Metering Systems /// -namespace TBF.BenchControl.TestMethods.HeatMeters +namespace TBF.BenchControl.TestMethods.FlyingStart.HeatMeters { partial class TestMethodCfgCtrl { diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStart/HeatMeters/TestMethodCfgCtrl.resx b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/HeatMeters/TestMethodCfgCtrl.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/HeatMeters/TestMethodCfgCtrl.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStart/HeatMeters/TestParams.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/HeatMeters/TestParams.cs new file mode 100644 index 000000000..74ea5566d --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/HeatMeters/TestParams.cs @@ -0,0 +1,112 @@ +/// +/// Copyright (c) 2013-2016 Sensus Metering Systems +/// +using System; +using System.IO; +using System.Text; +using System.Xml.Serialization; +using Config.Entities; +using TBF.BenchControl.Generic; +using TBF.Resources; + +namespace TBF.BenchControl.TestMethods.FlyingStart.HeatMeters +{ + public class TestParams : TestParamsBase, IParamsProvider, ITestParams + { + public bool SupressTrills; /// Main meter readings are ignored during test (suitable for small flows) + + public override void InitializeAll() + { + SupressTrills = false; + } + + + string[] paramNames = new string[] + { + Strings.SupressWMTrills, + }; + public override string ParamName(int i) { return paramNames[i]; } + public override int ParamsCount() { return paramNames.Length; } + + public override string ToString(int i) + { + switch (i) + { + case 0: return (SupressTrills ? Strings.yes : Strings.no); + default: return string.Empty; + } + } + + public void UpdateParam(int i, string strValue) + { + switch (i) + { + case 0: SupressTrills = strValue.Equals(Strings.yes); return; + default: return; + } + } + + public bool ValidateParam(int i, string strValue, out string message) + { + message = string.Empty; + + switch (i) + { + case 0: + if (strValue.Equals(Strings.yes) || strValue.Equals(Strings.no)) return true; + break; + default: + message = "Invalid index"; + return false; + } + + message = ParamName(i) + " is invalid"; + return false; + } + + void CopyContentTo(TestParams prms) + { + prms.SupressTrills = this.SupressTrills; + } + + public IParamsProvider Clone() + { + TestParams pars = new TestParams(); + CopyContentTo(pars); + return pars; + } + + public override void UpdateTestParams(ComponentTest dbEntity) + { + if (dbEntity == null) return; + try + { + TestParams tmp = (TestParams)(new XmlSerializer(typeof(TestParams))) + .Deserialize(new StringReader(dbEntity.Parameters)); + + testParamsEntity = dbEntity; + componentName = dbEntity.CmpntName; + test = dbEntity.Test; + + tmp.CopyContentTo(this); + } + catch + { + } + } + + /// + /// Parameterless constructor initializes the parameters + /// + public TestParams() + { + } + + public TestParams(ComponentTest testParamsEntity, string componentName, Test test) + { + this.testParamsEntity = testParamsEntity; + this.componentName = componentName; + this.test = test; + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStart/TestMethod.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/Single/Component.cs similarity index 51% rename from TestBenchFramework/BenchControl/TestMethods/FlyingStart/TestMethod.cs rename to TestBenchFramework/BenchControl/TestMethods/FlyingStart/Single/Component.cs index 2ce4ac27f..f320dac3c 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FlyingStart/TestMethod.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/Single/Component.cs @@ -1,28 +1,30 @@ /// -/// Copyright (c) 2013-2015 Sensus Metering Systems +/// Copyright (c) 2013-2016 Sensus Metering Systems /// using System; using System.Collections.Generic; using log4net; using Config.Entities; -using TBF.BenchControl; -namespace TBF.BenchControl.TestMethods.FlyingStart +namespace TBF.BenchControl.TestMethods.FlyingStart.Single { - public class TestMethod : ComponentBase, GenericDevices.ITestMethod + public class Component : ComponentBase, GenericDevices.ITestMethod { - private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod)); - public override string ToString() { return string.Format("TestMethods.FlyingStart({0})", Cfg.ToString(1)); } + private static readonly ILog log = LogManager.GetLogger(typeof(Component)); + public override string ToString() + { + return string.Format("{0}({1})", this.GetType().Namespace.Substring(17), Cfg.ToString(1)); + } public bool Evaluate(Test test) { return true; } public bool Publish(Test test) { return true; } public bool CanTest(MetersKind meters) { return meters == MetersKind.Single; } - public TestMethod() + public Component() { } - public TestMethod(Generic.IComponentCfg cfg) + public Component(Generic.IComponentCfg cfg) : base(cfg) { log.Debug(this.ToString()); @@ -30,7 +32,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStart public IList Execute(Test test) { - return (new FlyingStartSeq()).Execute(test); + return (new FlyingStartSeq()).Execute(test, null, null); } } } diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStart/TestMethodFactory.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/Single/Factory.cs similarity index 53% rename from TestBenchFramework/BenchControl/TestMethods/FlyingStart/TestMethodFactory.cs rename to TestBenchFramework/BenchControl/TestMethods/FlyingStart/Single/Factory.cs index 91b87527c..799004a1e 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FlyingStart/TestMethodFactory.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStart/Single/Factory.cs @@ -5,19 +5,19 @@ using System.Collections.Generic; using TBF.BenchControl.Generic; using TBF.BenchControl.Configs.NameOnly; -namespace TBF.BenchControl.TestMethods.FlyingStart +namespace TBF.BenchControl.TestMethods.FlyingStart.Single { - public class TestMethodFactory : IComponentFactory + public class Factory : IComponentFactory { - public string ClassName { get { return "FlyingStart"; } } + public string ClassName { get { return this.GetType().Namespace.Substring(17); } } - public void ResetStaticProperties() { TestMethod.ResetStaticProperties(); } + public void ResetStaticProperties() { Component.ResetStaticProperties(); } - public IComponent DummyComponent() { return new TestMethod(); } + public IComponent DummyComponent() { return new Component(); } - public IComponent GetComponent(IComponentCfg cfg, IList components) { return new TestMethod(cfg); } + public IComponent GetComponent(IComponentCfg cfg, IList components) { return new Component(cfg); } - public IComponentCfg DefaultConfig() { return new TestMethodCfg("FlyingStart", this); } + public IComponentCfg DefaultConfig() { return new TestMethodCfg(this.GetType().Namespace.Substring(29), this); } public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) { diff --git a/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedTestParams.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/Compound/CombinedTestParams.cs similarity index 95% rename from TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedTestParams.cs rename to TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/Compound/CombinedTestParams.cs index 36b40b9ed..1260757f7 100644 --- a/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/CombinedTestParams.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/Compound/CombinedTestParams.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2013-2015 Sensus Metering Systems +/// Copyright (c) 2013-2016 Sensus Metering Systems /// using System; using System.IO; @@ -9,7 +9,7 @@ using Config.Entities; using TBF.BenchControl.Generic; using TBF.Resources; -namespace TBF.BenchControl.TestMethods.CombinedMeters +namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection.Compound { public class CombinedTestParams : TestParamsBase, IParamsProvider, ITestParams { diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/Compound/Component.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/Compound/Component.cs new file mode 100644 index 000000000..6225b297c --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/Compound/Component.cs @@ -0,0 +1,42 @@ +/// +/// Copyright (c) 2013-2016 Sensus Metering Systems +/// +using System; +using System.Collections.Generic; +using log4net; +using Config.Entities; +using TBF.BenchControl.TestMethods.FlyingStartMassCollection; + +namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection.Compound +{ + public class Component : ComponentBase, GenericDevices.ITestMethod + { + private static readonly ILog log = LogManager.GetLogger(typeof(Component)); + public override string ToString() + { + return string.Format("{0}({1})", this.GetType().Namespace.Substring(17), Cfg.ToString(1)); + } + + readonly TestMethodCfg testMethodCfg; + + public bool Evaluate(Test test) { return true; } + public bool Publish(Test test) { return true; } + public bool CanTest(MetersKind meters) { return meters == MetersKind.Combined; } + + public Component() + { + } + + public Component(Generic.IComponentCfg cfg) + : base(cfg) + { + testMethodCfg = cfg as TestMethodCfg; + log.Debug(this.ToString()); + } + + public IList Execute(Test test) + { + return (new FlyingStartMassCollectionSeq()).Execute(test, testMethodCfg.TestParams, null); + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/Compound/Factory.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/Compound/Factory.cs new file mode 100644 index 000000000..b52e434a6 --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/Compound/Factory.cs @@ -0,0 +1,26 @@ +/// +/// Copyright (c) 2013-2016 Sensus Metering Systems +/// +using System.Collections.Generic; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection.Compound +{ + public class Factory : IComponentFactory + { + public string ClassName { get { return this.GetType().Namespace.Substring(17); } } + + public void ResetStaticProperties() { Component.ResetStaticProperties(); } + + public IComponent DummyComponent() { return new Component(); } + + public IComponent GetComponent(IComponentCfg cfg, IList components) { return new Component(cfg); } + + public IComponentCfg DefaultConfig() { return new TestMethodCfg(this.GetType().Namespace.Substring(29), this); } + + public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) + { + return ComponentCfgBase.CreateFromDbEntity(typeof(TestMethodCfg), component, this); + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/TestMethodCfg.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/Compound/TestMethodCfg.cs similarity index 81% rename from TestBenchFramework/BenchControl/TestMethods/CombinedMeters/TestMethodCfg.cs rename to TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/Compound/TestMethodCfg.cs index 01899ef1e..bfe9537e6 100644 --- a/TestBenchFramework/BenchControl/TestMethods/CombinedMeters/TestMethodCfg.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/Compound/TestMethodCfg.cs @@ -8,7 +8,7 @@ using System.Xml.Serialization; using Config.Entities; using TBF.BenchControl.Generic; -namespace TBF.BenchControl.TestMethods.CombinedMeters +namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection.Compound { public class TestMethodCfg : ComponentCfgBase, Generic.IComponentCfg { @@ -28,16 +28,16 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters /// Private parameterless constructor invoked by all other (public) constructors TestMethodCfg() { - Name = "CombinedMeters"; - ParentName = string.Empty; TestParams = new CombinedTestParams(); } - public TestMethodCfg(IComponentFactory factory) + public TestMethodCfg(string name, IComponentFactory factory) : this() { - this.Factory = factory; - } + Name = name; + Factory = factory; + ParentName = string.Empty; + } public string ToString(int i) { diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/Compound/TestMethodCfgCtrl.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/Compound/TestMethodCfgCtrl.cs new file mode 100644 index 000000000..4c9f01207 --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/Compound/TestMethodCfgCtrl.cs @@ -0,0 +1,71 @@ +/// +/// Copyright (c) 2013-2016 Sensus Metering Systems +/// +using System; +using System.Windows.Forms; +using log4net; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection.Compound +{ + public partial class TestMethodCfgCtrl : UserControl, IComponentCfgCtrl + { + static readonly ILog log = LogManager.GetLogger(typeof(TestMethodCfgCtrl)); + + public bool ShowMore { get { return false; } } + + TestMethodCfg config; + public IComponentCfg Config + { + get { return config as IComponentCfg; } + set + { + config = value as TestMethodCfg; + Redraw(); + } + } + + public TestMethodCfgCtrl() + { + InitializeComponent(); + } + + private void EntryFormCfgCtrl_Load(object sender, EventArgs e) + { + Redraw(); + } + + public void Closing() + { + } + + void Redraw() + { + if (config == null) return; /// Control was not loaded, settings were not changed + classNameLabel.Text = config.Factory.ClassName; + nameTextBox.Text = config.Name; + } + + public void Unlock() + { + nameTextBox.Enabled = true; + } + + public CfgUpdateFlags VerifyCfg(ref string message) + { + CfgUpdateFlags flags = CfgUpdateFlags.None; + return flags; + } + + public CfgUpdateFlags UpdateCfg() + { + CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd; + + if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed + + config.Name = nameTextBox.Text; + + return flags; + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/Compound/TestMethodCfgCtrl.designer.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/Compound/TestMethodCfgCtrl.designer.cs new file mode 100644 index 000000000..e1239b63d --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/Compound/TestMethodCfgCtrl.designer.cs @@ -0,0 +1,86 @@ +/// +/// Copyright (c) 2013-2016 Sensus Metering Systems +/// +namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection.Compound +{ + partial class TestMethodCfgCtrl + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.nameTextBox = new System.Windows.Forms.TextBox(); + this.nameLabel = new System.Windows.Forms.Label(); + this.classNameLabel = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // nameTextBox + // + this.nameTextBox.Enabled = false; + this.nameTextBox.Location = new System.Drawing.Point(137, 57); + this.nameTextBox.Name = "nameTextBox"; + this.nameTextBox.Size = new System.Drawing.Size(130, 20); + this.nameTextBox.TabIndex = 5; + // + // nameLabel + // + this.nameLabel.AutoSize = true; + this.nameLabel.Location = new System.Drawing.Point(27, 60); + this.nameLabel.Name = "nameLabel"; + this.nameLabel.Size = new System.Drawing.Size(35, 13); + this.nameLabel.TabIndex = 4; + this.nameLabel.Text = "Name"; + // + // classNameLabel + // + this.classNameLabel.AutoSize = true; + this.classNameLabel.Location = new System.Drawing.Point(134, 33); + this.classNameLabel.Name = "classNameLabel"; + this.classNameLabel.Size = new System.Drawing.Size(83, 13); + this.classNameLabel.TabIndex = 3; + this.classNameLabel.Text = "ComonentName"; + // + // BasicPrinterCfgCtrl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.nameTextBox); + this.Controls.Add(this.nameLabel); + this.Controls.Add(this.classNameLabel); + this.Name = "BasicPrinterCfgCtrl"; + this.Size = new System.Drawing.Size(300, 200); + this.Load += new System.EventHandler(this.EntryFormCfgCtrl_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox nameTextBox; + private System.Windows.Forms.Label nameLabel; + private System.Windows.Forms.Label classNameLabel; + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/Compound/TestMethodCfgCtrl.resx b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/Compound/TestMethodCfgCtrl.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/Compound/TestMethodCfgCtrl.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs index 25af2e0cf..f9e43dc5a 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs @@ -12,9 +12,9 @@ using TBF.UiBridge; namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection { - public class FlyingStartCollectionMethodSeq : Sequences.SequenceBase + public class FlyingStartMassCollectionSeq : Sequences.SequenceBase { - private static readonly ILog log = LogManager.GetLogger(typeof(FlyingStartCollectionMethodSeq)); + private static readonly ILog log = LogManager.GetLogger(typeof(FlyingStartMassCollectionSeq)); /// /// Flying start mass collection method sequence @@ -26,7 +26,9 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection /// Event.OpArgumentError . Target flow is out of range /// Event.Error . . . . . . Unspecified error /// - public IList Execute(Config.Entities.Test test) + public IList Execute(Config.Entities.Test test, + Compound.CombinedTestParams compoundTestParams, + HeatMeters.TestParams heatMetersTestParams) { Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; @@ -91,7 +93,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection /// if (tankEmptyingInProgress) { - State.Create("SequenceBase : Opening the emptying valve") + State.Create("FlyingStartMassCollection : Opening the emptying valve") .AddOperation(checkUiOp) .AddOperation(StateMachine.ControlBoard.SetValvesOp(outPath.EmptyTankValve, null)) .EnterState(); @@ -502,126 +504,185 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection tstRslt.FlowMin = (tstRslt.VolumeMaster != 0) ? (float)(RefFlowStat.Min * tstRslt.VolumeCTV / tstRslt.VolumeMaster) : RefFlowStat.Min; tstRslt.FlowMax = (tstRslt.VolumeMaster != 0) ? (float)(RefFlowStat.Max * tstRslt.VolumeCTV / tstRslt.VolumeMaster) : RefFlowStat.Max; - for (int i = 0; i < BatchRslts.WMPositionsCount; i++) - { - if (test.Part != 0 && test.Part != Utils.PartNr(i + 1, BatchRslts.Batch.Compound)) continue; + if (compoundTestParams != null) + { + /// + /// Compound meters + /// + for (int i = 0; i < BatchRslts.WMPositionsCount; i++) + { + if (test.Part != 0 && test.Part != Utils.PartNr(i + 1, BatchRslts.Batch.Compound)) continue; - if (BatchRslts.Batch.Compound) - { - /// - /// Compound meters - /// - Results.Entities.MeterTestRslt mainMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.CompoundMain); - Results.Entities.MeterTestRslt auxMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.CompoundAux); + Results.Entities.MeterTestRslt mainMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.CompoundMain); + Results.Entities.MeterTestRslt auxMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.CompoundAux); - for (int isAux = 0; isAux <= 1; isAux++) /// 0=main, 1=aux - { - GenericDevices.IRegisterReader regReader = sensPath.RegisterReaders[2 * i + isAux]; - Results.Entities.MeterTestRslt meterRslt = (isAux == 0) ? mainMeterRslt : auxMeterRslt; + for (int isAux = 0; isAux <= 1; isAux++) /// 0=main, 1=aux + { + GenericDevices.IRegisterReader regReader = sensPath.RegisterReaders[2 * i + isAux]; + Results.Entities.MeterTestRslt meterRslt = (isAux == 0) ? mainMeterRslt : auxMeterRslt; - if (meterRslt != null && regReader != null) - { - meterRslt.PulsesPerLiter = regReader.PulsesPerLtr; + if (meterRslt != null && regReader != null) + { + meterRslt.PulsesPerLiter = regReader.PulsesPerLtr; - /// Optionally supress pulses from the large water meter - meterRslt.PulsesMeter = Convert.ToDouble(regReader.WMPulses); - meterRslt.PulsesMaster = Convert.ToDouble(regReader.WMRefPulses); + /// Optionally supress pulses from the large water meter + meterRslt.PulsesMeter = (isAux == 0 && compoundTestParams.SupressTrills) ? 0 : Convert.ToDouble(regReader.WMPulses); + meterRslt.PulsesMaster = Convert.ToDouble(regReader.WMRefPulses); - meterRslt.TestTime = tstRslt.TestTime; - meterRslt.VolumeStart = 0; - meterRslt.VolumeEnd = 0; - meterRslt.VolumeRef = tstRslt.VolumeCTV; - meterRslt.VolumeMeter = meterRslt.PulsesMeter * regReader.LtrsPerPulse; /// liter + meterRslt.TestTime = tstRslt.TestTime; + meterRslt.VolumeStart = 0; + meterRslt.VolumeEnd = 0; + meterRslt.VolumeRef = tstRslt.VolumeCTV; + meterRslt.VolumeMeter = meterRslt.PulsesMeter * regReader.LtrsPerPulse; /// liter - if (meterRslt.PulsesMaster != 0) - { - meterRslt.VolumeMeter *= (tstRslt.PulsesMaster / meterRslt.PulsesMaster); - } + if (meterRslt.PulsesMaster != 0) + { + meterRslt.VolumeMeter *= (tstRslt.PulsesMaster / meterRslt.PulsesMaster); + } - meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, tstRslt.VolumeCTV); /// Main/Aux meter error is not usedfor evaluation - } - } + meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, tstRslt.VolumeCTV); /// Main/Aux meter error is not usedfor evaluation + } + } - Results.Entities.MeterTestRslt compoundMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Compound); + Results.Entities.MeterTestRslt compoundMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Compound); - if (compoundMeterRslt != null && mainMeterRslt != null && auxMeterRslt != null) - { - compoundMeterRslt.VolumeRef = tstRslt.VolumeCTV; - compoundMeterRslt.VolumeMeter = mainMeterRslt.VolumeMeter + auxMeterRslt.VolumeMeter; - compoundMeterRslt.PulsesMaster = tstRslt.PulsesMaster; - compoundMeterRslt.TestTime = tstRslt.TestTime; - compoundMeterRslt.Error = Formulas.ErrorFromVolumes(compoundMeterRslt.VolumeMeter, compoundMeterRslt.VolumeRef); - compoundMeterRslt.Passed = (compoundMeterRslt.Error >= test.ErrLimLo + test.Uncertainty) - && (compoundMeterRslt.Error <= test.ErrLimHi - test.Uncertainty); - mainMeterRslt.Passed = auxMeterRslt.Passed = compoundMeterRslt.Passed; - mainMeterRslt.TestDone = auxMeterRslt.TestDone = compoundMeterRslt.TestDone = true; - } - } -#if HEAT_METERS_SUPPORT - else if (BatchRslts.Batch.HeatMeter) - { - /// - /// Heat meters - /// - } -#endif - else - { - /// MetersKind.Single meters - Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single); - GenericDevices.IRegisterReader regReader = sensPath.RegisterReaders[i]; - WaterMeters.iPerl.WaterMeter iPerl = regReader as WaterMeters.iPerl.WaterMeter; + if (compoundMeterRslt != null && mainMeterRslt != null && auxMeterRslt != null) + { + compoundMeterRslt.VolumeRef = tstRslt.VolumeCTV; + compoundMeterRslt.VolumeMeter = mainMeterRslt.VolumeMeter + auxMeterRslt.VolumeMeter; + compoundMeterRslt.PulsesMaster = tstRslt.PulsesMaster; + compoundMeterRslt.TestTime = tstRslt.TestTime; + compoundMeterRslt.Error = Formulas.ErrorFromVolumes(compoundMeterRslt.VolumeMeter, compoundMeterRslt.VolumeRef); + compoundMeterRslt.Passed = (compoundMeterRslt.Error >= test.ErrLimLo + test.Uncertainty) + && (compoundMeterRslt.Error <= test.ErrLimHi - test.Uncertainty); + mainMeterRslt.Passed = auxMeterRslt.Passed = compoundMeterRslt.Passed; + mainMeterRslt.TestDone = auxMeterRslt.TestDone = compoundMeterRslt.TestDone = true; + } + } + } + else if (heatMetersTestParams != null) + { + /// + /// Heat meters + /// + } + else + { + /// + /// Single meters + /// + for (int i = 0; i < BatchRslts.WMPositionsCount; i++) + { + if (test.Part != 0 && test.Part != Utils.PartNr(i + 1, BatchRslts.Batch.Compound)) continue; - if (meterRslt != null && regReader != null) - { - meterRslt.PulsesPerLiter = regReader.PulsesPerLtr; - meterRslt.PulsesMeter = Convert.ToDouble(regReader.WMPulses); - meterRslt.PulsesMaster = Convert.ToDouble(regReader.WMRefPulses); + if (BatchRslts.Batch.Compound) + { + /// + /// Compound meters + /// + Results.Entities.MeterTestRslt mainMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.CompoundMain); + Results.Entities.MeterTestRslt auxMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.CompoundAux); - if (iPerl != null) - { - meterRslt.TimestampStart = iPerl.TimestampSecStart; - meterRslt.TimestampEnd = iPerl.NoSamples ? (iPerl.TimestampSecStart + tstRslt.TestTime) : iPerl.TimestampSecEnd; - meterRslt.TestTime = iPerl.NoSamples ? tstRslt.TestTime : (meterRslt.TimestampEnd - meterRslt.TimestampStart); - meterRslt.VolumeStart = iPerl.VolumeLtrStart; /// liter - meterRslt.VolumeEnd = iPerl.VolumeLtrEnd; /// liter - meterRslt.VolumeMeter = Math.Abs(iPerl.VolumeLtrEnd - iPerl.VolumeLtrStart); - meterRslt.VolumeRef = tstRslt.VolumeCTV * meterRslt.TestTime / tstRslt.TestTime; - iPerl.VolumeLtrRef = meterRslt.VolumeRef; + for (int isAux = 0; isAux <= 1; isAux++) /// 0=main, 1=aux + { + GenericDevices.IRegisterReader regReader = sensPath.RegisterReaders[2 * i + isAux]; + Results.Entities.MeterTestRslt meterRslt = (isAux == 0) ? mainMeterRslt : auxMeterRslt; + + if (meterRslt != null && regReader != null) + { + meterRslt.PulsesPerLiter = regReader.PulsesPerLtr; + + /// Optionally supress pulses from the large water meter + meterRslt.PulsesMeter = Convert.ToDouble(regReader.WMPulses); + meterRslt.PulsesMaster = Convert.ToDouble(regReader.WMRefPulses); + + meterRslt.TestTime = tstRslt.TestTime; + meterRslt.VolumeStart = 0; + meterRslt.VolumeEnd = 0; + meterRslt.VolumeRef = tstRslt.VolumeCTV; + meterRslt.VolumeMeter = meterRslt.PulsesMeter * regReader.LtrsPerPulse; /// liter + + if (meterRslt.PulsesMaster != 0) + { + meterRslt.VolumeMeter *= (tstRslt.PulsesMaster / meterRslt.PulsesMaster); + } + + meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, tstRslt.VolumeCTV); /// Main/Aux meter error is not usedfor evaluation + } + } + + Results.Entities.MeterTestRslt compoundMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Compound); + + if (compoundMeterRslt != null && mainMeterRslt != null && auxMeterRslt != null) + { + compoundMeterRslt.VolumeRef = tstRslt.VolumeCTV; + compoundMeterRslt.VolumeMeter = mainMeterRslt.VolumeMeter + auxMeterRslt.VolumeMeter; + compoundMeterRslt.PulsesMaster = tstRslt.PulsesMaster; + compoundMeterRslt.TestTime = tstRslt.TestTime; + compoundMeterRslt.Error = Formulas.ErrorFromVolumes(compoundMeterRslt.VolumeMeter, compoundMeterRslt.VolumeRef); + compoundMeterRslt.Passed = (compoundMeterRslt.Error >= test.ErrLimLo + test.Uncertainty) + && (compoundMeterRslt.Error <= test.ErrLimHi - test.Uncertainty); + mainMeterRslt.Passed = auxMeterRslt.Passed = compoundMeterRslt.Passed; + mainMeterRslt.TestDone = auxMeterRslt.TestDone = compoundMeterRslt.TestDone = true; + } + } + else + { + /// MetersKind.Single meters + Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single); + GenericDevices.IRegisterReader regReader = sensPath.RegisterReaders[i]; + WaterMeters.iPerl.WaterMeter iPerl = regReader as WaterMeters.iPerl.WaterMeter; + + if (meterRslt != null && regReader != null) + { + meterRslt.PulsesPerLiter = regReader.PulsesPerLtr; + meterRslt.PulsesMeter = Convert.ToDouble(regReader.WMPulses); + meterRslt.PulsesMaster = Convert.ToDouble(regReader.WMRefPulses); + + if (iPerl != null) + { + meterRslt.TimestampStart = iPerl.TimestampSecStart; + meterRslt.TimestampEnd = iPerl.NoSamples ? (iPerl.TimestampSecStart + tstRslt.TestTime) : iPerl.TimestampSecEnd; + meterRslt.TestTime = iPerl.NoSamples ? tstRslt.TestTime : (meterRslt.TimestampEnd - meterRslt.TimestampStart); + meterRslt.VolumeStart = iPerl.VolumeLtrStart; /// liter + meterRslt.VolumeEnd = iPerl.VolumeLtrEnd; /// liter + meterRslt.VolumeMeter = Math.Abs(iPerl.VolumeLtrEnd - iPerl.VolumeLtrStart); + meterRslt.VolumeRef = tstRslt.VolumeCTV * meterRslt.TestTime / tstRslt.TestTime; + iPerl.VolumeLtrRef = meterRslt.VolumeRef; #if IPERLST || IPERLST_SPECIAL - meterRslt.WaterMeter.CalibFactor = (iPerl.CalibrationStruct != null) ? iPerl.CalibrationStruct.Calibration : 0; + meterRslt.WaterMeter.CalibFactor = (iPerl.CalibrationStruct != null) ? iPerl.CalibrationStruct.Calibration : 0; meterRslt.WaterMeter.Q2Correction = iPerl.Q2CorrectionFactor; #endif - iPerl.LastTestResult2 = iPerl.LastTestResult; /// Save shift previous test result - iPerl.LastTestResult = meterRslt; /// Save this test result - iPerl.NominalTestFlow = 500.0 * (test.Qfrom + test.Qto); /// Ave. + convert to liter/hour - } - else - { - meterRslt.TestTime = tstRslt.TestTime; /// TODO: Malo by sa citat z dosky - meterRslt.VolumeStart = 0; /// liter - meterRslt.VolumeEnd = 0; /// liter - meterRslt.VolumeMeter = meterRslt.PulsesMeter * regReader.LtrsPerPulse; /// liter - meterRslt.VolumeRef = meterRslt.PulsesMaster * tstRslt.ConstMaster; /// liter - } + iPerl.LastTestResult2 = iPerl.LastTestResult; /// Save shift previous test result + iPerl.LastTestResult = meterRslt; /// Save this test result + iPerl.NominalTestFlow = 500.0 * (test.Qfrom + test.Qto); /// Ave. + convert to liter/hour + } + else + { + meterRslt.TestTime = tstRslt.TestTime; /// TODO: Malo by sa citat z dosky + meterRslt.VolumeStart = 0; /// liter + meterRslt.VolumeEnd = 0; /// liter + meterRslt.VolumeMeter = meterRslt.PulsesMeter * regReader.LtrsPerPulse; /// liter + meterRslt.VolumeRef = meterRslt.PulsesMaster * tstRslt.ConstMaster; /// liter + } - meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef); - meterRslt.Passed = (meterRslt.Error >= test.ErrLimLo + test.Uncertainty) - && (meterRslt.Error <= test.ErrLimHi - test.Uncertainty); - meterRslt.TestDone = true; - } - } + meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef); + meterRslt.Passed = (meterRslt.Error >= test.ErrLimLo + test.Uncertainty) + && (meterRslt.Error <= test.ErrLimHi - test.Uncertainty); + meterRslt.TestDone = true; + } + } + } + } - tstRslt.Components = Results.Entities.Components - .UpdateList(BatchRslts.ComponentsList, - new Results.Entities.Components((BenchInfo != null) ? BenchInfo.TestBenchId : 1, - (BenchInfo != null) ? BenchInfo.TestBenchName : "testbench", - inPath.Pump != null ? inPath.Pump.Name : string.Empty, - outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty, - outPath.Balance != null ? outPath.Balance.Name : string.Empty, - outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty, - outPath.Diverter != null ? outPath.Diverter.Name : string.Empty)); - } + tstRslt.Components = Results.Entities.Components.UpdateList(BatchRslts.ComponentsList, + new Results.Entities.Components((BenchInfo != null) ? BenchInfo.TestBenchId : 1, + (BenchInfo != null) ? BenchInfo.TestBenchName : "testbench", + inPath.Pump != null ? inPath.Pump.Name : string.Empty, + outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty, + outPath.Balance != null ? outPath.Balance.Name : string.Empty, + outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty, + outPath.Diverter != null ? outPath.Diverter.Name : string.Empty)); /// Update results Bridge.OnTestCompleted(this, new TestCompletedEventArgs(testName, tstRslt)); diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/HeatMeters/Component.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/HeatMeters/Component.cs new file mode 100644 index 000000000..4453b2bc0 --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/HeatMeters/Component.cs @@ -0,0 +1,41 @@ +/// +/// Copyright (c) 2013-2016 Sensus Metering Systems +/// +using System; +using System.Collections.Generic; +using log4net; +using Config.Entities; + +namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection.HeatMeters +{ + public class Component : ComponentBase, GenericDevices.ITestMethod + { + private static readonly ILog log = LogManager.GetLogger(typeof(Component)); + public override string ToString() + { + return string.Format("{0}({1})", this.GetType().Namespace.Substring(17), Cfg.ToString(1)); + } + + readonly TestMethodCfg testMethodCfg; + + public bool Evaluate(Test test) { return true; } + public bool Publish(Test test) { return true; } + public bool CanTest(MetersKind meters) { return meters == MetersKind.HeatMeter; } + + public Component() + { + } + + public Component(Generic.IComponentCfg cfg) + : base(cfg) + { + testMethodCfg = cfg as TestMethodCfg; + log.Debug(this.ToString()); + } + + public IList Execute(Test test) + { + return (new FlyingStartMassCollectionSeq()).Execute(test, null, testMethodCfg.TestParams); + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/HeatMeters/Factory.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/HeatMeters/Factory.cs new file mode 100644 index 000000000..48a900344 --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/HeatMeters/Factory.cs @@ -0,0 +1,26 @@ +/// +/// Copyright (c) 2013-2016 Sensus Metering Systems +/// +using System.Collections.Generic; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection.HeatMeters +{ + public class Factory : IComponentFactory + { + public string ClassName { get { return this.GetType().Namespace.Substring(17); } } + + public void ResetStaticProperties() { Component.ResetStaticProperties(); } + + public IComponent DummyComponent() { return new Component(); } + + public IComponent GetComponent(IComponentCfg cfg, IList components) { return new Component(cfg); } + + public IComponentCfg DefaultConfig() { return new TestMethodCfg(this.GetType().Namespace.Substring(29), this); } + + public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) + { + return ComponentCfgBase.CreateFromDbEntity(typeof(TestMethodCfg), component, this); + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/HeatMeters/TestMethodCfg.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/HeatMeters/TestMethodCfg.cs new file mode 100644 index 000000000..aeb1b0d2c --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/HeatMeters/TestMethodCfg.cs @@ -0,0 +1,47 @@ +/// +/// Copyright (c) 2013-2016 Sensus Metering Systems +/// +using System; +using System.Collections.Generic; +using System.IO; +using System.Xml.Serialization; +using Config.Entities; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection.HeatMeters +{ + public class TestMethodCfg : ComponentCfgBase, Generic.IComponentCfg + { + public IComponentCfgCtrl GetControl() { return new TestMethodCfgCtrl(); } + + /// Test parameters + [XmlIgnore] + public TestParams TestParams; + public override IParamsProvider GetTestParams() { return TestParams; } + public override IParamsProvider CreateTestParams(Test test) + { + TestParams testParams = new TestParams(); + testParams.UpdateTestParams(Name, test); + return testParams; + } + + /// Private parameterless constructor invoked by all other (public) constructors + TestMethodCfg() + { + TestParams = new TestParams(); + } + + public TestMethodCfg(string name, IComponentFactory factory) + : this() + { + Name = name; + Factory = factory; + ParentName = string.Empty; + } + + public string ToString(int i) + { + return string.Format("Name={0}", Name); + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/HeatMeters/TestMethodCfgCtrl.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/HeatMeters/TestMethodCfgCtrl.cs new file mode 100644 index 000000000..0c000c6bc --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/HeatMeters/TestMethodCfgCtrl.cs @@ -0,0 +1,71 @@ +/// +/// Copyright (c) 2013-2016 Sensus Metering Systems +/// +using System; +using System.Windows.Forms; +using log4net; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection.HeatMeters +{ + public partial class TestMethodCfgCtrl : UserControl, IComponentCfgCtrl + { + static readonly ILog log = LogManager.GetLogger(typeof(TestMethodCfgCtrl)); + + public bool ShowMore { get { return false; } } + + TestMethodCfg config; + public IComponentCfg Config + { + get { return config as IComponentCfg; } + set + { + config = value as TestMethodCfg; + Redraw(); + } + } + + public TestMethodCfgCtrl() + { + InitializeComponent(); + } + + private void EntryFormCfgCtrl_Load(object sender, EventArgs e) + { + Redraw(); + } + + public void Closing() + { + } + + void Redraw() + { + if (config == null) return; /// Control was not loaded, settings were not changed + classNameLabel.Text = config.Factory.ClassName; + nameTextBox.Text = config.Name; + } + + public void Unlock() + { + nameTextBox.Enabled = true; + } + + public CfgUpdateFlags VerifyCfg(ref string message) + { + CfgUpdateFlags flags = CfgUpdateFlags.None; + return flags; + } + + public CfgUpdateFlags UpdateCfg() + { + CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd; + + if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed + + config.Name = nameTextBox.Text; + + return flags; + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/HeatMeters/TestMethodCfgCtrl.designer.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/HeatMeters/TestMethodCfgCtrl.designer.cs new file mode 100644 index 000000000..54a4c59e6 --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/HeatMeters/TestMethodCfgCtrl.designer.cs @@ -0,0 +1,86 @@ +/// +/// Copyright (c) 2013-2016 Sensus Metering Systems +/// +namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection.HeatMeters +{ + partial class TestMethodCfgCtrl + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.nameTextBox = new System.Windows.Forms.TextBox(); + this.nameLabel = new System.Windows.Forms.Label(); + this.classNameLabel = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // nameTextBox + // + this.nameTextBox.Enabled = false; + this.nameTextBox.Location = new System.Drawing.Point(137, 57); + this.nameTextBox.Name = "nameTextBox"; + this.nameTextBox.Size = new System.Drawing.Size(130, 20); + this.nameTextBox.TabIndex = 5; + // + // nameLabel + // + this.nameLabel.AutoSize = true; + this.nameLabel.Location = new System.Drawing.Point(27, 60); + this.nameLabel.Name = "nameLabel"; + this.nameLabel.Size = new System.Drawing.Size(35, 13); + this.nameLabel.TabIndex = 4; + this.nameLabel.Text = "Name"; + // + // classNameLabel + // + this.classNameLabel.AutoSize = true; + this.classNameLabel.Location = new System.Drawing.Point(134, 33); + this.classNameLabel.Name = "classNameLabel"; + this.classNameLabel.Size = new System.Drawing.Size(83, 13); + this.classNameLabel.TabIndex = 3; + this.classNameLabel.Text = "ComonentName"; + // + // BasicPrinterCfgCtrl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.nameTextBox); + this.Controls.Add(this.nameLabel); + this.Controls.Add(this.classNameLabel); + this.Name = "BasicPrinterCfgCtrl"; + this.Size = new System.Drawing.Size(300, 200); + this.Load += new System.EventHandler(this.EntryFormCfgCtrl_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox nameTextBox; + private System.Windows.Forms.Label nameLabel; + private System.Windows.Forms.Label classNameLabel; + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/HeatMeters/TestMethodCfgCtrl.resx b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/HeatMeters/TestMethodCfgCtrl.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/HeatMeters/TestMethodCfgCtrl.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/HeatMeters/TestParams.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/HeatMeters/TestParams.cs new file mode 100644 index 000000000..3fdd8b017 --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/HeatMeters/TestParams.cs @@ -0,0 +1,112 @@ +/// +/// Copyright (c) 2013-2016 Sensus Metering Systems +/// +using System; +using System.IO; +using System.Text; +using System.Xml.Serialization; +using Config.Entities; +using TBF.BenchControl.Generic; +using TBF.Resources; + +namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection.HeatMeters +{ + public class TestParams : TestParamsBase, IParamsProvider, ITestParams + { + public bool SupressTrills; /// Main meter readings are ignored during test (suitable for small flows) + + public override void InitializeAll() + { + SupressTrills = false; + } + + + string[] paramNames = new string[] + { + Strings.SupressWMTrills, + }; + public override string ParamName(int i) { return paramNames[i]; } + public override int ParamsCount() { return paramNames.Length; } + + public override string ToString(int i) + { + switch (i) + { + case 0: return (SupressTrills ? Strings.yes : Strings.no); + default: return string.Empty; + } + } + + public void UpdateParam(int i, string strValue) + { + switch (i) + { + case 0: SupressTrills = strValue.Equals(Strings.yes); return; + default: return; + } + } + + public bool ValidateParam(int i, string strValue, out string message) + { + message = string.Empty; + + switch (i) + { + case 0: + if (strValue.Equals(Strings.yes) || strValue.Equals(Strings.no)) return true; + break; + default: + message = "Invalid index"; + return false; + } + + message = ParamName(i) + " is invalid"; + return false; + } + + void CopyContentTo(TestParams prms) + { + prms.SupressTrills = this.SupressTrills; + } + + public IParamsProvider Clone() + { + TestParams pars = new TestParams(); + CopyContentTo(pars); + return pars; + } + + public override void UpdateTestParams(ComponentTest dbEntity) + { + if (dbEntity == null) return; + try + { + TestParams tmp = (TestParams)(new XmlSerializer(typeof(TestParams))) + .Deserialize(new StringReader(dbEntity.Parameters)); + + testParamsEntity = dbEntity; + componentName = dbEntity.CmpntName; + test = dbEntity.Test; + + tmp.CopyContentTo(this); + } + catch + { + } + } + + /// + /// Parameterless constructor initializes the parameters + /// + public TestParams() + { + } + + public TestParams(ComponentTest testParamsEntity, string componentName, Test test) + { + this.testParamsEntity = testParamsEntity; + this.componentName = componentName; + this.test = test; + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/Single/Component.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/Single/Component.cs new file mode 100644 index 000000000..9357e272c --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/Single/Component.cs @@ -0,0 +1,38 @@ +/// +/// Copyright (c) 2013-2016 Sensus Metering Systems +/// +using System; +using System.Collections.Generic; +using log4net; +using Config.Entities; + +namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection.Single +{ + public class Component : ComponentBase, GenericDevices.ITestMethod + { + private static readonly ILog log = LogManager.GetLogger(typeof(Component)); + public override string ToString() + { + return string.Format("{0}({1})", this.GetType().Namespace.Substring(17), Cfg.ToString(1)); + } + + public bool Evaluate(Test test) { return true; } + public bool Publish(Test test) { return true; } + public bool CanTest(MetersKind meters) { return meters == MetersKind.Single; } + + public Component() + { + } + + public Component(Generic.IComponentCfg cfg) + : base(cfg) + { + log.Debug(this.ToString()); + } + + public IList Execute(Test test) + { + return (new FlyingStartMassCollectionSeq()).Execute(test, null, null); + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/TestMethodFactory.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/Single/Factory.cs similarity index 59% rename from TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/TestMethodFactory.cs rename to TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/Single/Factory.cs index 66ec254e8..0b0fede5a 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/TestMethodFactory.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/Single/Factory.cs @@ -5,19 +5,19 @@ using System.Collections.Generic; using TBF.BenchControl.Generic; using TBF.BenchControl.Configs.NameOnly; -namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection +namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection.Single { - public class TestMethodFactory : IComponentFactory + public class Factory : IComponentFactory { - public string ClassName { get { return "Flying-Start-Collection"; } } + public string ClassName { get { return this.GetType().Namespace.Substring(17); } } - public void ResetStaticProperties() { TestMethod.ResetStaticProperties(); } + public void ResetStaticProperties() { Component.ResetStaticProperties(); } - public IComponent DummyComponent() { return new TestMethod(); } + public IComponent DummyComponent() { return new Component(); } - public IComponent GetComponent(IComponentCfg cfg, IList components) { return new TestMethod(cfg); } + public IComponent GetComponent(IComponentCfg cfg, IList components) { return new Component(cfg); } - public IComponentCfg DefaultConfig() { return new TestMethodCfg("FlyingStartCollection", this); } + public IComponentCfg DefaultConfig() { return new TestMethodCfg(this.GetType().Namespace.Substring(29), this); } public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) { diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/TestMethod.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/TestMethod.cs deleted file mode 100644 index a952e86d9..000000000 --- a/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/TestMethod.cs +++ /dev/null @@ -1,36 +0,0 @@ -/// -/// Copyright (c) 2013-2015 Sensus Metering Systems -/// -using System; -using System.Collections.Generic; -using log4net; -using Config.Entities; -using TBF.BenchControl; - -namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection -{ - public class TestMethod : ComponentBase, GenericDevices.ITestMethod - { - private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod)); - public override string ToString() { return string.Format("TestMethods.FlyingStartMassCollection({0})", Cfg.ToString(1)); } - - public bool Evaluate(Test test) { return true; } - public bool Publish(Test test) { return true; } - public bool CanTest(MetersKind meters) { return true; } - - public TestMethod() - { - } - - public TestMethod(Generic.IComponentCfg cfg) - : base(cfg) - { - log.Debug(this.ToString()); - } - - public IList Execute(Test test) - { - return (new FlyingStartCollectionMethodSeq()).Execute(test); - } - } -} diff --git a/TestBenchFramework/BenchControl/TestMethods/HeatMeters/HeatMetersSeq.cs b/TestBenchFramework/BenchControl/TestMethods/HeatMeters/HeatMetersSeq.cs deleted file mode 100644 index 41585ed39..000000000 --- a/TestBenchFramework/BenchControl/TestMethods/HeatMeters/HeatMetersSeq.cs +++ /dev/null @@ -1,673 +0,0 @@ -/// -/// Copyright (c) 2016 Sensus Metering Systems -/// -using System; -using System.Collections.Generic; -using System.Text; -using log4net; -using TBF.BenchControl; -using TBF.Boxes; -using TBF.Resources; -using TBF.UiBridge; - -namespace TBF.BenchControl.TestMethods.HeatMeters -{ - public class HeatMetersSeq : Sequences.SequenceBase - { - private static readonly ILog log = LogManager.GetLogger(typeof(HeatMetersSeq)); - - /// - /// Flying start mass collection method sequence - /// - /// Test entity - /// - /// 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 - /// - public IList Execute(Config.Entities.Test test, HeatTestParams testParams) - { - Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; - - IList e = new List(); /// Events from currently running operations - Event retVal = Event.Done; - checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state - processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this); - - LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse; - int totalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f); - - int repetitionNr = 1; /// First test: repetitionNr = 1 - - //==================================== - // Transition or SetRoute - Start - //==================================== - switch (Transition(transitionBefore, TransitionContext.BeforeTest)) - { - 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, totalPulses)); - string testName = Results.Utils.GetTestName(test.Name, test.Repeats, repetitionNr); - TestStartTime = DateTime.Now; - TestProgressEventArgs.SetEstimatedTimes(new int[] { 1, 1, 1, 30, Convert.ToInt32(test.TstTime) + 15, 0, 0 }); - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.JustStarted)); - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - int flowSetTime0 = StateMachine.Time; - - //------------------------------------------------ - Bridge.OnActivity(this, Strings.Checking_tank_capacity); - //------------------------------------------------ - bool tankEmptyingInProgress = test.Emptying; - - if (!tankEmptyingInProgress) /// If condition met => skip measuring and force emptying - { - /// - /// Measure the weight and skip emptying if there is enough room in the tank - /// - State.Create("HeatMeters : Checking available tank capacity") - .AddOperation(checkUiOp) - .AddOperation(outPath.Balance.ReadMassOp(ref Mass)) - .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.BalanceDone)); - - float estimatedEndMass = Mass.Val + test.Volume; - if (estimatedEndMass >= outPath.Balance.Capacity * Constants.TankFullFactor) - { - tankEmptyingInProgress = true; - } - } - /// - if (tankEmptyingInProgress) - { - State.Create("SequenceBase : Opening the emptying valve") - .AddOperation(checkUiOp) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(outPath.EmptyTankValve, null)) - .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.ValvesSet)); - } - - - if (inPath.Pump != null) - { - //------------------------------------------------ - Bridge.OnActivity(this, Strings.Starting_the_pump); - //------------------------------------------------ - if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower); - /// - State.Create("HeatMeters : Starting the pump") - .AddOperation(checkUiOp) - .AddOperation(cBrd.SetValvesOp(inPath.Pump, null)) - .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - - if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } - } - while (!e.Contains(Event.ValvesSet)); - } - - - if (test.TimePump2StartV > 0) - { - State.Create("HeatMeters : Waiting after the pump started") - .AddOperation(checkUiOp) - .AddOperation(new Operations.TimerOp(test.TimePump2StartV)) - .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - - if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } - } - while (!e.Contains(Event.TimerExpired)); - } - - - if (benchPath.StopBFValve != null) - { - State.Create("HeatMeters : Opening the stop backflow valve") - .AddOperation(checkUiOp) - .AddOperation(StateMachine.ControlBoard.SetValvesOp(benchPath.StopBFValve, null)) - .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } - if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } - } - while (!e.Contains(Event.ValvesSet)); - } - - - if (test.TimeBeforeFlow > 0) - { - State.Create("HeatMeters : Waiting before flow setting process starts") - .AddOperation(checkUiOp) - .AddOperation(new Operations.TimerOp(test.TimeBeforeFlow)) - .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - - if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } - } - while (!e.Contains(Event.TimerExpired)); - } - - - setting_flow: - - //------------------------------------------------ - Bridge.OnActivity(this, Strings.Setting_the_flow); - //------------------------------------------------ - State.Create("HeatMeters : Setting the flow") - .AddOperation(checkUiOp) - .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) - .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, outPath.PidCoef, RefFlow, 990)) /// timeout = 16.5 min. - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); - - if (e.Contains(Event.OpArgumentError)) { retVal = Event.OpArgumentError; goto stopTest; } - if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } - if (e.Contains(Event.RegulValveTimeOut)) - { - Bridge.OnError(this, Strings.Timeout); - retVal = Event.Done; - goto stopTest; - } - if (e.Contains(Event.Next)) goto flow_set; - } - while (!e.Contains(Event.FlowReached)); - - - flow_set: - - int flowSetTime = StateMachine.Time - flowSetTime0; - float currentFlow = RefFlow.Val; - - /// Extract cameras from the current sensors path, add operations to the detection state - IList measureOperations = new List(); - for (int i = 0; i < sensPath.RegisterReaders.Length; i++) - { - GenericDevices.ICameraRoi cameraRoi = sensPath.RegisterReaders[i] as GenericDevices.ICameraRoi; - if (cameraRoi != null) measureOperations.Add(cameraRoi.MeasureOp()); - } - - - if (tankEmptyingInProgress) - { - //------------------------------------------------ - Bridge.OnActivity(this, Strings.Closing_the_tank); - //------------------------------------------------ - - /// - /// Make sure tank emptying completed - /// - switch (EmptyTheTank(outPath.EmptyTankValve, outPath.Balance)) - { - case Event.Error: { retVal = Event.Error; goto stopTest; } - case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } - } - - tankEmptyingInProgress = false; - } - - if (test.TimeFlow2Mass > 0) - { - State.Create("HeatMeters : Waiting before 1st mass measurement") - .AddOperation(checkUiOp) - .AddOperation(cBrd.UpdateTankWeightOp()) - .AddOperation(new Operations.TimerOp(test.TimeFlow2Mass)) - .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.TimerExpired)); - } - - - //------------------------------------------------ - Bridge.OnActivity(this, Strings.Measuring_the_weight); - //------------------------------------------------ - - LogProcessHeader(processDataLogger, "Start mass"); - - State.Create("HeatMeters : Measuring the start mass") - .AddOperation(checkUiOp) - .AddOperation(benchPath.TempIn.ReadTempOp(ref TempIn)) - .AddOperation(benchPath.TempOut.ReadTempOp(ref TempOut)) - .AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv)) - .AddOperation(benchPath.PressIn.ReadPressureOp(ref PressureUp)) - .AddOperation(benchPath.PressOut.ReadPressureOp(ref PressureDown)) - .AddOperation((StateMachine.Ambient != null) - ? StateMachine.Ambient.ReadAmbientOp(AmbientTemp, AmbientPressure, AmbientHumidity) : null) - .AddOperations(measureOperations) - .AddOperation(outPath.Balance.ReadStableMassOp(ref StartMass, test.MassRepeats, test.MassSpread, test.MassMethod)) - .AddOperation(cBrd.UpdateTankWeightOp()) - .AddOperation(processDataLoggingOp) - .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.BalanceDone)); - - LogProcessHeader(processDataLogger, "Measurement"); - - log.WarnFormat("Start mass = {0}kg", StartMass); - Mass.Val = StartMass.Val; - - //------------------------------------------------ - Bridge.OnActivity(this, Strings.Test_in_progress); - //------------------------------------------------ - State.Create("HeatMeters : Starting the test") - .AddOperation(checkUiOp) - .AddOperation(benchPath.TempIn.ReadTempOp(ref TempIn)) - .AddOperation(benchPath.TempOut.ReadTempOp(ref TempOut)) - .AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv)) - .AddOperation(benchPath.PressIn.ReadPressureOp(ref PressureUp)) - .AddOperation(benchPath.PressOut.ReadPressureOp(ref PressureDown)) - .AddOperation((StateMachine.Ambient != null) - ? StateMachine.Ambient.ReadAmbientOp(AmbientTemp, AmbientPressure, AmbientHumidity) : null) - .AddOperations(measureOperations) - .AddOperation(Operations.EnthalpyCalculationOp.GetOp(Enthalpy, heatMetersPath)) - .AddOperation(cBrd.UpdateTankWeightOp()) - .AddOperation(processDataLoggingOp) - .AddOperation(cBrd.StartMeasurementOp(outPath, Elde.TestMethods.Diverter | Elde.TestMethods.Synchro, - test.Qfrom, test.Qto, totalPulses, (float)test.TolerRed)) - .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.MeasurementStarted)); - - - foreach (var rr in sensPath.RegisterReaders) - { - if (rr is WaterMeters.iPerl.WaterMeter) (rr as WaterMeters.iPerl.WaterMeter).TestName = test.Name; - } - - - /// Measurement loop - preparation - readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders); - - int estimtdEndTime = StateMachine.Time + (int)test.TstTime; - ClearAllStatistics(); - - /// Measurement loop - begin - State.Create("Read water meters") - .AddOperation(checkUiOp) - .AddOperations(measureOperations) - .AddOperation(readRegistersOp) - .AddOperation(benchPath.TempIn.ReadTempOp(ref TempIn)) - .AddOperation(benchPath.TempOut.ReadTempOp(ref TempOut)) - .AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv)) - .AddOperation(benchPath.PressIn.ReadPressureOp(ref PressureUp)) - .AddOperation(benchPath.PressOut.ReadPressureOp(ref PressureDown)) - .AddOperation(outPath.Balance.ReadMassOp(ref Mass)) - .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) - .AddOperation((StateMachine.Ambient != null) - ? StateMachine.Ambient.ReadAmbientOp(AmbientTemp, AmbientPressure, AmbientHumidity) - : null) - .AddOperation(cBrd.QueryMeasurementEndOp()) - .AddOperation(processDataLoggingOp) - .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.MeasurementCompleted)) goto test_completed; - - //------------------------------------------------ - int remainingTime = Math.Max(estimtdEndTime - StateMachine.Time, 0); - if (remainingTime > 60) - { - Bridge.OnActivity(this, string.Format("{0} ... {1} {2} {3} {4}", Strings.Test_in_progress, remainingTime / 60, "min", remainingTime % 60, Strings.sec)); - } - else - { - Bridge.OnActivity(this, string.Format("{0} ... {1} s", Strings.Test_in_progress, remainingTime)); - } - //------------------------------------------------ - - UpdateAllStatistics(); - RefFreq.Val = cBrd.ReferenceFreq; - RefFlow.Val = cBrd.ReferenceFlow; - - Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.Test)); - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Test)); - } - while (true); - /// Measurement loop - end - - test_completed: - //------------------------------------------------ - Bridge.OnActivity(this, Strings.Measuring_the_weight); - //------------------------------------------------ - State.Create("HeatMeters : Waiting before the 2nd mass measurement") - .AddOperation(checkUiOp) - .AddOperation(benchPath.TempIn.ReadTempOp(ref TempIn)) - .AddOperation(benchPath.TempOut.ReadTempOp(ref TempOut)) - .AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv)) - .AddOperation(benchPath.PressIn.ReadPressureOp(ref PressureUp)) - .AddOperation(benchPath.PressOut.ReadPressureOp(ref PressureDown)) - .AddOperation(readRegistersOp) - .AddOperation((StateMachine.Ambient != null) - ? StateMachine.Ambient.ReadAmbientOp(AmbientTemp, AmbientPressure, AmbientHumidity) : null) - .AddOperation(outPath.Balance.ReadMassOp(ref Mass)) - .AddOperation(cBrd.UpdateTankWeightOp()) - .AddOperation(processDataLoggingOp) - .AddOperation(new Operations.TimerOp(test.TimeStop2Mass)) - .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.TimerExpired)); - - LogProcessHeader(processDataLogger, "End mass"); - - State.Create("HeatMeters : Measuring the end mass") - .AddOperation(checkUiOp) - .AddOperation(benchPath.TempIn.ReadTempOp(ref TempIn)) - .AddOperation(benchPath.TempOut.ReadTempOp(ref TempOut)) - .AddOperation(outPath.TempDiv.ReadTempOp(ref TempDiv)) - .AddOperation(benchPath.PressIn.ReadPressureOp(ref PressureUp)) - .AddOperation(benchPath.PressOut.ReadPressureOp(ref PressureDown)) - .AddOperation(readRegistersOp) - .AddOperation((StateMachine.Ambient != null) - ? StateMachine.Ambient.ReadAmbientOp(AmbientTemp, AmbientPressure, AmbientHumidity) : null) - .AddOperation(outPath.Balance.ReadStableMassOp(ref EndMass, test.MassRepeats, test.MassSpread, test.MassMethod)) - .AddOperation(cBrd.UpdateTankWeightOp()) - .AddOperation(processDataLoggingOp) - .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.BalanceDone)); - /// - log.WarnFormat("End mass = {0}kg", EndMass); - TestEndTime = DateTime.Now; - - //------------------------------------------------ - Bridge.OnActivity(this, Strings.Test_completed); - //------------------------------------------------ - - /// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results - if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stopTest; - - /// - /// Populate TestResult data entity with data - /// - Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part); - - if (tstRslt != null) - { - /// Auxiliary results - tstRslt.AmbientTempAve = AmbientTempStat.Average; - tstRslt.AmbientPressAve = AmbientPressureStat.Average; - tstRslt.AmbientHumiAve = AmbientHumidityStat.Average; - tstRslt.PressUpAvrg = PressureUpStat.Average; - tstRslt.PressUpStart = PressureUpStat.First; - tstRslt.PressUpEnd = PressureUpStat.Last; - tstRslt.PressUpMin = PressureUpStat.Min; - tstRslt.PressUpMax = PressureUpStat.Max; - tstRslt.PressDownAvrg = PressureDownStat.Average; - tstRslt.PressDownStart = PressureDownStat.First; - tstRslt.PressDownEnd = PressureDownStat.Last; - tstRslt.PressDownMin = PressureDownStat.Min; - tstRslt.PressDownMax = PressureDownStat.Max; - tstRslt.TempInAvrg = TempInStat.Average; - tstRslt.TempInStart = TempInStat.First; - tstRslt.TempInEnd = TempInStat.Last; - tstRslt.TempInMin = TempInStat.Min; - tstRslt.TempInMax = TempInStat.Max; - tstRslt.TempOutAvrg = TempOutStat.Average; - tstRslt.TempOutStart = TempOutStat.First; - tstRslt.TempOutEnd = TempOutStat.Last; - tstRslt.TempOutMin = TempOutStat.Min; - tstRslt.TempOutMax = TempOutStat.Max; - tstRslt.TempDivAvrg = TempDivStat.Average; - tstRslt.TempDivStart = TempDivStat.First; - tstRslt.TempDivEnd = TempDivStat.Last; - tstRslt.TempDivMin = TempDivStat.Min; - tstRslt.TempDivMax = TempDivStat.Max; - tstRslt.DensityIn = Formulas.WaterDensityFromTemp(tstRslt.TempInAvrg); /// [kg/m3] - tstRslt.DensityOut = Formulas.WaterDensityFromTemp(tstRslt.TempOutAvrg); /// [kg/m3] - tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivAvrg); /// [kg/m3] - - /// Main results - tstRslt.StartTime = TestStartTime; - tstRslt.EndTime = TestEndTime; - tstRslt.FlowSetTime = flowSetTime; - tstRslt.TestTime = cBrd.TTime; /// [s] measurement time - tstRslt.PulsesMaster = Convert.ToDouble(cBrd.EtPulses(0)); /// Pulses of the master flow meter (test total) - tstRslt.MassStartRaw = StartMass.Val; - tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Balance.Corrections); - tstRslt.MassEndRaw = EndMass.Val; - tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Balance.Corrections); - tstRslt.FlowMass = 3600.0 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.TestTime; /// [kg/h] - tstRslt.FlowVolume = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; /// [m3/h] - tstRslt.VolumeCTV = 1001.03 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.DensityOut; /// [l] 1000.0f is because density is in [kg/m3] - tstRslt.VolumeMaster = LtrPerRefPulse * tstRslt.PulsesMaster; /// [l] volume from the master flow meter - tstRslt.ConstMaster = LtrPerRefPulse * tstRslt.VolumeCTV / tstRslt.VolumeMaster; /// Corrected master pulses per liter - tstRslt.ErrorMaster = Formulas.ErrorFromVolumes(tstRslt.VolumeMaster, tstRslt.VolumeCTV); - - tstRslt.FlowMin = (tstRslt.VolumeMaster != 0) ? (float)(RefFlowStat.Min * tstRslt.VolumeCTV / tstRslt.VolumeMaster) : RefFlowStat.Min; - tstRslt.FlowMax = (tstRslt.VolumeMaster != 0) ? (float)(RefFlowStat.Max * tstRslt.VolumeCTV / tstRslt.VolumeMaster) : RefFlowStat.Max; - - for (int i = 0; i < BatchRslts.WMPositionsCount; i++) - { - if (test.Part != 0 && test.Part != Utils.PartNr(i + 1, BatchRslts.Batch.Compound)) continue; - - if (BatchRslts.Batch.Compound) - { - /// - /// Compound meters - /// - Results.Entities.MeterTestRslt mainMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.CompoundMain); - Results.Entities.MeterTestRslt auxMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.CompoundAux); - - for (int isAux = 0; isAux <= 1; isAux++) /// 0=main, 1=aux - { - GenericDevices.IRegisterReader regReader = sensPath.RegisterReaders[2 * i + isAux]; - Results.Entities.MeterTestRslt meterRslt = (isAux == 0) ? mainMeterRslt : auxMeterRslt; - - if (meterRslt != null && regReader != null) - { - meterRslt.PulsesPerLiter = regReader.PulsesPerLtr; - - /// Optionally supress pulses from the large water meter - meterRslt.PulsesMeter = Convert.ToDouble(regReader.WMPulses); - meterRslt.PulsesMaster = Convert.ToDouble(regReader.WMRefPulses); - - meterRslt.TestTime = tstRslt.TestTime; - meterRslt.VolumeStart = 0; - meterRslt.VolumeEnd = 0; - meterRslt.VolumeRef = tstRslt.VolumeCTV; - meterRslt.VolumeMeter = meterRslt.PulsesMeter * regReader.LtrsPerPulse; /// liter - - if (meterRslt.PulsesMaster != 0) - { - meterRslt.VolumeMeter *= (tstRslt.PulsesMaster / meterRslt.PulsesMaster); - } - - meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, tstRslt.VolumeCTV); /// Main/Aux meter error is not usedfor evaluation - } - } - - Results.Entities.MeterTestRslt compoundMeterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Compound); - - if (compoundMeterRslt != null && mainMeterRslt != null && auxMeterRslt != null) - { - compoundMeterRslt.VolumeRef = tstRslt.VolumeCTV; - compoundMeterRslt.VolumeMeter = mainMeterRslt.VolumeMeter + auxMeterRslt.VolumeMeter; - compoundMeterRslt.PulsesMaster = tstRslt.PulsesMaster; - compoundMeterRslt.TestTime = tstRslt.TestTime; - compoundMeterRslt.Error = Formulas.ErrorFromVolumes(compoundMeterRslt.VolumeMeter, compoundMeterRslt.VolumeRef); - compoundMeterRslt.Passed = (compoundMeterRslt.Error >= test.ErrLimLo + test.Uncertainty) - && (compoundMeterRslt.Error <= test.ErrLimHi - test.Uncertainty); - mainMeterRslt.Passed = auxMeterRslt.Passed = compoundMeterRslt.Passed; - mainMeterRslt.TestDone = auxMeterRslt.TestDone = compoundMeterRslt.TestDone = true; - } - } -#if HEAT_METERS_SUPPORT - else if (BatchRslts.Batch.HeatMeter) - { - /// - /// Heat meters - /// - } -#endif - else - { - /// MetersKind.Single meters - Results.Entities.MeterTestRslt meterRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.Single); - GenericDevices.IRegisterReader regReader = sensPath.RegisterReaders[i]; - WaterMeters.iPerl.WaterMeter iPerl = regReader as WaterMeters.iPerl.WaterMeter; - - if (meterRslt != null && regReader != null) - { - meterRslt.PulsesPerLiter = regReader.PulsesPerLtr; - meterRslt.PulsesMeter = Convert.ToDouble(regReader.WMPulses); - meterRslt.PulsesMaster = Convert.ToDouble(regReader.WMRefPulses); - - if (iPerl != null) - { - meterRslt.TimestampStart = iPerl.TimestampSecStart; - meterRslt.TimestampEnd = iPerl.NoSamples ? (iPerl.TimestampSecStart + tstRslt.TestTime) : iPerl.TimestampSecEnd; - meterRslt.TestTime = iPerl.NoSamples ? tstRslt.TestTime : (meterRslt.TimestampEnd - meterRslt.TimestampStart); - meterRslt.VolumeStart = iPerl.VolumeLtrStart; /// liter - meterRslt.VolumeEnd = iPerl.VolumeLtrEnd; /// liter - meterRslt.VolumeMeter = Math.Abs(iPerl.VolumeLtrEnd - iPerl.VolumeLtrStart); - meterRslt.VolumeRef = tstRslt.VolumeCTV * meterRslt.TestTime / tstRslt.TestTime; - iPerl.VolumeLtrRef = meterRslt.VolumeRef; -#if IPERLST || IPERLST_SPECIAL - meterRslt.WaterMeter.CalibFactor = (iPerl.CalibrationStruct != null) ? iPerl.CalibrationStruct.Calibration : 0; - meterRslt.WaterMeter.Q2Correction = iPerl.Q2CorrectionFactor; -#endif - iPerl.LastTestResult2 = iPerl.LastTestResult; /// Save shift previous test result - iPerl.LastTestResult = meterRslt; /// Save this test result - iPerl.NominalTestFlow = 500.0 * (test.Qfrom + test.Qto); /// Ave. + convert to liter/hour - } - else - { - meterRslt.TestTime = tstRslt.TestTime; /// TODO: Malo by sa citat z dosky - meterRslt.VolumeStart = 0; /// liter - meterRslt.VolumeEnd = 0; /// liter - meterRslt.VolumeMeter = meterRslt.PulsesMeter * regReader.LtrsPerPulse; /// liter - meterRslt.VolumeRef = meterRslt.PulsesMaster * tstRslt.ConstMaster; /// liter - } - - meterRslt.Error = Formulas.ErrorFromVolumes(meterRslt.VolumeMeter, meterRslt.VolumeRef); - meterRslt.Passed = (meterRslt.Error >= test.ErrLimLo + test.Uncertainty) - && (meterRslt.Error <= test.ErrLimHi - test.Uncertainty); - meterRslt.TestDone = true; - } - } - - tstRslt.Components = Results.Entities.Components - .UpdateList(BatchRslts.ComponentsList, - new Results.Entities.Components((BenchInfo != null) ? BenchInfo.TestBenchId : 1, - (BenchInfo != null) ? BenchInfo.TestBenchName : "testbench", - inPath.Pump != null ? inPath.Pump.Name : string.Empty, - outPath.FlowMeter != null ? outPath.FlowMeter.Name : string.Empty, - outPath.Balance != null ? outPath.Balance.Name : string.Empty, - outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty, - outPath.Diverter != null ? outPath.Diverter.Name : string.Empty)); - } - - /// Update results - Bridge.OnTestCompleted(this, new TestCompletedEventArgs(testName, tstRslt)); - } - - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.TransitionAfter)); - - /// Append the results to the CSV-file - allResults.Info(TestResult2CsvLine(testName, test.Part)); - - if (++repetitionNr <= test.Repeats) - { - goto loop; - } - - stopTest: - - ///----------------------/// - /// Quit this sequence /// - ///----------------------/// - - State.Create("HeatMeters : Stopping diverter, gate, etc.") - .AddOperation(checkUiOp) - .AddOperation(cBrd.StopPreviousOp()) - .EnterState(); - do - { - e = StateMachine.WaitRunDevsRunOps(); - if (TestAndLogUiCmdStop(test,e)) { retVal = Event.UiCmdStop; goto stopTest; } - } - while (!e.Contains(Event.PreviousStopped)); - - /// Transition sequence at the end of test - /// Prevent overwriting 'retVal' in case it was set to non-default value earlier - switch (Transition(transitionAfter, (retVal == Event.Done) ? TransitionContext.AfterTest : TransitionContext.Stop)) - { - case Event.Error: { if (retVal == Event.Done) retVal = Event.Error; break; } - case Event.UiCmdStop: { if (retVal == Event.Done) retVal = Event.UiCmdStop; break; } - } - - Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Completed)); - - /// Create a list with one item 'retVal' (default is Event.Done) and return it - IList retList = new List(1); - retList.Add(retVal); - return retList; - } - } -} diff --git a/TestBenchFramework/BenchControl/TestMethods/HeatMeters/TestMethodFactory.cs b/TestBenchFramework/BenchControl/TestMethods/HeatMeters/TestMethodFactory.cs deleted file mode 100644 index b098a163d..000000000 --- a/TestBenchFramework/BenchControl/TestMethods/HeatMeters/TestMethodFactory.cs +++ /dev/null @@ -1,26 +0,0 @@ -/// -/// Copyright (c) 2016 Sensus Metering Systems -/// -using System.Collections.Generic; -using TBF.BenchControl.Generic; - -namespace TBF.BenchControl.TestMethods.HeatMeters -{ - public class TestMethodFactory : IComponentFactory - { - public string ClassName { get { return "HeatMeters"; } } - - public void ResetStaticProperties() { TestMethod.ResetStaticProperties(); } - - public IComponent DummyComponent() { return new TestMethod(); } - - public IComponent GetComponent(IComponentCfg cfg, IList components) { return new TestMethod(cfg); } - - public IComponentCfg DefaultConfig() { return new TestMethodCfg(this); } - - public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) - { - return ComponentCfgBase.CreateFromDbEntity(typeof(TestMethodCfg), component, this); - } - } -} diff --git a/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/TestMethod.cs b/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/TestMethod.cs index b225f4fc7..b74567770 100644 --- a/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/TestMethod.cs +++ b/TestBenchFramework/BenchControl/TestMethods/ReferenceFlowmeterCalibration/TestMethod.cs @@ -16,7 +16,7 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration public bool Evaluate(Test test) { return false; } public bool Publish(Test test) { return false; } - public bool CanTest(MetersKind meters) { return true; } + public bool CanTest(MetersKind meters) { return meters != MetersKind.HeatMeter; } public TestMethod() { diff --git a/TestBenchFramework/BenchControl/TestMethods/iPerlCommunication/TestMethod.cs b/TestBenchFramework/BenchControl/TestMethods/iPerlCommunication/TestMethod.cs index 4d4db2bf7..5710616b6 100644 --- a/TestBenchFramework/BenchControl/TestMethods/iPerlCommunication/TestMethod.cs +++ b/TestBenchFramework/BenchControl/TestMethods/iPerlCommunication/TestMethod.cs @@ -43,7 +43,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication return false; } - public bool CanTest(MetersKind meters) { return true; } + public bool CanTest(MetersKind meters) { return meters == MetersKind.Single; } public TestMethod() { diff --git a/TestBenchFramework/ProcedureDlg.cs b/TestBenchFramework/ProcedureDlg.cs index cbf0635dc..4dc4ddb91 100644 --- a/TestBenchFramework/ProcedureDlg.cs +++ b/TestBenchFramework/ProcedureDlg.cs @@ -1652,7 +1652,7 @@ namespace TBF if (selectedMethod is BenchControl.TestMethods.PMaxTest.TestMethod) goto pressure_label; if (selectedMethod is BenchControl.TestMethods.LeakTest.TestMethod) goto pressure_label; - if (selectedMethod is BenchControl.TestMethods.HeatMeters.TestMethod) goto heat_meters_label; + if (selectedMethod.CanTest(MetersKind.HeatMeter)) goto heat_meters_label; flowLabel: switch (flowDlg.ShowDialog()) diff --git a/TestBenchFramework/Properties/AssemblyInfo.cs b/TestBenchFramework/Properties/AssemblyInfo.cs index d2d792519..89f04936b 100644 --- a/TestBenchFramework/Properties/AssemblyInfo.cs +++ b/TestBenchFramework/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("2.9.336.1")] -[assembly: AssemblyFileVersion("2.9.336.1")] +[assembly: AssemblyVersion("2.9.337.1")] +[assembly: AssemblyFileVersion("2.9.337.1")] diff --git a/TestBenchFramework/TBF.csproj b/TestBenchFramework/TBF.csproj index 7b3d0427a..885c870c0 100644 --- a/TestBenchFramework/TBF.csproj +++ b/TestBenchFramework/TBF.csproj @@ -504,22 +504,66 @@ WMErrorsForm24.cs - - - - - - - - - - + + + + + + + + UserControl - + TestMethodCfgCtrl.cs - + + + + + + + + + UserControl + + + TestMethodCfgCtrl.cs + + + + + + + UserControl + + + TestMethodCfgCtrl.cs + + + + + + + + UserControl + + + TestMethodCfgCtrl.cs + + + + + + + UserControl + + + TestMethodCfgCtrl.cs + + + + @@ -959,17 +1003,6 @@ UserControl - - - - - - UserControl - - - TestMethodCfgCtrl.cs - - @@ -982,15 +1015,9 @@ - - - - - - @@ -1681,13 +1708,22 @@ RoiDetectionCfgCtrl.cs - - TestMethodCfgCtrl.cs - TestMethodCfgCtrl.cs - + + TestMethodCfgCtrl.cs + + + TestMethodCfgCtrl.cs + + + TestMethodCfgCtrl.cs + + + TestMethodCfgCtrl.cs + + TestMethodCfgCtrl.cs