From d640a2f4b615e6d7b1ca0d8b16febf0191dafdaf Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Mon, 15 Jan 2018 16:53:27 +0100 Subject: [PATCH] FlyingStartFirstRepetWithMassColl test method, 'ConstMaster' and 'ErrorMaster' from the 1st rep. used in remaining reps., ver. 2.17.775 --- .../BenchControl/TbfComponents.cs | 5 +- .../Compound/Component.cs | 40 + .../Compound/Factory.cs | 26 + .../Compound/TestMethodCfg.cs | 50 + .../Compound/TestMethodCfgCtrl.cs | 71 + .../Compound/TestMethodCfgCtrl.designer.cs | 86 ++ .../Compound/TestMethodCfgCtrl.resx | 120 ++ .../Compound/TestParams.cs | 119 ++ .../FlyingStartFirstRepetWithMassCollSeq.cs | 1143 +++++++++++++++++ .../HeatMeters/Component.cs | 40 + .../HeatMeters/Factory.cs | 26 + .../HeatMeters/TestMethodCfg.cs | 50 + .../HeatMeters/TestMethodCfgCtrl.cs | 71 + .../HeatMeters/TestMethodCfgCtrl.designer.cs | 86 ++ .../HeatMeters/TestMethodCfgCtrl.resx | 120 ++ .../HeatMeters/TestParams.cs | 197 +++ .../Single/Component.cs | 37 + .../Single/Factory.cs | 27 + .../FlyingStartMassCollectionSeq.cs | 18 +- TestBenchFramework/Properties/AssemblyInfo.cs | 4 +- TestBenchFramework/TBF.csproj | 29 + 21 files changed, 2353 insertions(+), 12 deletions(-) create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Compound/Component.cs create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Compound/Factory.cs create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Compound/TestMethodCfg.cs create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Compound/TestMethodCfgCtrl.cs create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Compound/TestMethodCfgCtrl.designer.cs create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Compound/TestMethodCfgCtrl.resx create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Compound/TestParams.cs create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/FlyingStartFirstRepetWithMassCollSeq.cs create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/HeatMeters/Component.cs create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/HeatMeters/Factory.cs create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/HeatMeters/TestMethodCfg.cs create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/HeatMeters/TestMethodCfgCtrl.cs create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/HeatMeters/TestMethodCfgCtrl.designer.cs create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/HeatMeters/TestMethodCfgCtrl.resx create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/HeatMeters/TestParams.cs create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Single/Component.cs create mode 100644 TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Single/Factory.cs diff --git a/TestBenchFramework/BenchControl/TbfComponents.cs b/TestBenchFramework/BenchControl/TbfComponents.cs index 2fbefcb20..c182833c7 100644 --- a/TestBenchFramework/BenchControl/TbfComponents.cs +++ b/TestBenchFramework/BenchControl/TbfComponents.cs @@ -59,7 +59,10 @@ namespace TBF.BenchControl Factories.Add(new TestMethods.FlyingStartMassCollection.Single.Factory()); Factories.Add(new TestMethods.FlyingStartMassCollection.Compound.Factory()); Factories.Add(new TestMethods.FlyingStartMassCollection.HeatMeters.Factory()); - Factories.Add(new TestMethods.GrabImage.Factory()); + Factories.Add(new TestMethods.FlyingStartFirstRepetWithMassColl.Single.Factory()); + Factories.Add(new TestMethods.FlyingStartFirstRepetWithMassColl.Compound.Factory()); + Factories.Add(new TestMethods.FlyingStartFirstRepetWithMassColl.HeatMeters.Factory()); + Factories.Add(new TestMethods.GrabImage.Factory()); Factories.Add(new TestMethods.LeakTest.TestMethodFactory()); Factories.Add(new TestMethods.LiveStream.Factory()); Factories.Add(new TestMethods.OuterLoop.Start.Factory()); diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Compound/Component.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Compound/Component.cs new file mode 100644 index 000000000..a8b528e1f --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Compound/Component.cs @@ -0,0 +1,40 @@ +/// +/// Copyright (c) 2018 Sensus Slovensko a.s. +/// +using System; +using System.Collections.Generic; +using log4net; +using Config.Entities; + +namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl.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)); + } + + public bool CanTest(MetersKind meters) { return meters == MetersKind.Combined; } + public bool DoTransitions() { return true; } + + readonly TestMethodCfg testMethodCfg; + + public Component() + { + } + + public Component(Generic.IComponentCfg cfg) + : base(cfg) + { + testMethodCfg = cfg as TestMethodCfg; + log.Debug(this.ToString()); + } + + public IList Execute(Test test, int repetNr, bool isLastRepetition) + { + return (new FlyingStartFirstRepetWithMassCollSeq()).Execute(test, repetNr, isLastRepetition, testMethodCfg.TestParams, null, DebugLevel); + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Compound/Factory.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Compound/Factory.cs new file mode 100644 index 000000000..12593527b --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Compound/Factory.cs @@ -0,0 +1,26 @@ +/// +/// Copyright (c) 2018 Sensus Slovensko a.s. +/// +using System.Collections.Generic; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl.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(TestMethodCfg.Serializer, component, this); + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Compound/TestMethodCfg.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Compound/TestMethodCfg.cs new file mode 100644 index 000000000..1e836bcea --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Compound/TestMethodCfg.cs @@ -0,0 +1,50 @@ +/// +/// Copyright (c) 2018 Sensus Slovensko a.s. +/// +using System; +using System.Collections.Generic; +using System.IO; +using System.Xml.Serialization; +using Config.Entities; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl.Compound +{ + public class TestMethodCfg : ComponentCfgBase, Generic.IComponentCfg + { + public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(TestMethodCfg) })[0]; + protected override XmlSerializer GetSerializer() { return Serializer; } + + 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(true); + testParams.UpdateTestParams(Name, test); + return testParams; + } + + /// Private parameterless constructor invoked by all other (public) constructors + TestMethodCfg() + { + TestParams = new TestParams(true); + } + + 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/FlyingStartFirstRepetWithMassColl/Compound/TestMethodCfgCtrl.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Compound/TestMethodCfgCtrl.cs new file mode 100644 index 000000000..8cf4a6dc2 --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Compound/TestMethodCfgCtrl.cs @@ -0,0 +1,71 @@ +/// +/// Copyright (c) 2018 Sensus Slovensko a.s. +/// +using System; +using System.Windows.Forms; +using log4net; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl.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/FlyingStartFirstRepetWithMassColl/Compound/TestMethodCfgCtrl.designer.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Compound/TestMethodCfgCtrl.designer.cs new file mode 100644 index 000000000..0477a001e --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Compound/TestMethodCfgCtrl.designer.cs @@ -0,0 +1,86 @@ +/// +/// Copyright (c) 2018 Sensus Slovensko a.s. +/// +namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl.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/FlyingStartFirstRepetWithMassColl/Compound/TestMethodCfgCtrl.resx b/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Compound/TestMethodCfgCtrl.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/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/FlyingStartFirstRepetWithMassColl/Compound/TestParams.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Compound/TestParams.cs new file mode 100644 index 000000000..e5754f6ef --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Compound/TestParams.cs @@ -0,0 +1,119 @@ +/// +/// Copyright (c) 2018 Sensus Slovensko a.s. +/// +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.FlyingStartFirstRepetWithMassColl.Compound +{ + public class TestParams : TestParamsBase, IParamsProvider, ITestParams + { + public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(TestParams) })[0]; + protected override XmlSerializer GetSerializer() { return Serializer; } + + 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 = Serializer.Deserialize(new StringReader(dbEntity.Parameters)) as TestParams; + + testParamsEntity = dbEntity; + componentName = dbEntity.CmpntName; + test = dbEntity.Test; + + if (tmp != null) tmp.CopyContentTo(this); + } + catch + { + } + } + + /// + /// Parameterless constructor initializes the parameters + /// + public TestParams() + { + } + + public TestParams(bool initialize) + { + if (initialize) InitializeAll(); + } + + public TestParams(ComponentTest testParamsEntity, string componentName, Test test) + { + this.testParamsEntity = testParamsEntity; + this.componentName = componentName; + this.test = test; + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/FlyingStartFirstRepetWithMassCollSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/FlyingStartFirstRepetWithMassCollSeq.cs new file mode 100644 index 000000000..ad6b71504 --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/FlyingStartFirstRepetWithMassCollSeq.cs @@ -0,0 +1,1143 @@ +/// +/// Copyright (c) 2018 Sensus Slovensko a.s. +/// +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.FlyingStartFirstRepetWithMassColl +{ + public class FlyingStartFirstRepetWithMassCollSeq : Sequences.SequenceBase + { + private static readonly ILog log = LogManager.GetLogger(typeof(FlyingStartFirstRepetWithMassCollSeq)); + + /// + /// 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, int repetitionNr, bool isLastRepetition, + Compound.TestParams compoundTestParams, + HeatMeters.TestParams heatMetersTestParams, + Config.Entities.DebugMode debugLevel) + { + IList e = new List(); /// Events from currently running operations + Event retVal = Event.Done; + checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state + + float switchTimeStart = 0.001f; /// in seconds, initial value is 1 ms + float switchTimeEnd = 0.001f; /// in seconds, initial value is 1 ms + FloatBox switchTimeStartLo = new FloatBox(0.001f); + FloatBox switchTimeStartHi = new FloatBox(0.002f); + FloatBox switchTimeEndLo = new FloatBox(0.001f); + FloatBox switchTimeEndHi = new FloatBox(0.002f); + + if (debugLevel == Config.Entities.DebugMode.Simulate) + { + /// + /// Test method simulation + /// + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); + + if (compoundTestParams != null) + { + if (test.Name.ToLower().Contains("nok")) MakeSimulatedCompound(test.Name, 1, 1, 0, 4.7f, 0.9f); + else MakeSimulatedCompound(test.Name, 1, 1, 0, 0.7f, 1.0f); + } + else if (heatMetersTestParams != null) + { + MakeSimulatedHeatMeters(test.Name, 1, 1, 0, 1.5f, 1000000, heatMetersTestParams.ErrorLimitLo, heatMetersTestParams.ErrorLimitHi, heatMetersTestParams.EvaluateVolume); + } + else + { + float errorPctBase = -1.0f; + if (test.Name.ToLower().Contains("q3")) errorPctBase = -0.5f; + else if (test.Name.ToLower().Contains("q2")) errorPctBase = 0.5f; + else if (test.Name.ToLower().Contains("q1")) errorPctBase = -5.1f; + + MakeSimulated(test.Name, test.Repeats, repetitionNr, 0, errorPctBase + repetitionNr * 0.1f); + } + + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Completed)); + Bridge.OnTestCompleted(this, new TestCompletedEventArgs(test.Name, BatchRslts.GetTestRslt(Results.Utils.GetTestName(test.Name, 1, 1), 0))); + allResults.Info(TestResult2CsvLine(test.Name, 0)); /// Append the results to the CSV-file + + for (int i = 0; i < Config.Data.WMsCount; i++) + { + TestMethods.iPerlCommunication.iPerlHead.IperlHead iPerl = ((sensPath.RegisterReaders != null) && (i < sensPath.RegisterReaders.Length)) + ? (sensPath.RegisterReaders[i] as TestMethods.iPerlCommunication.iPerlHead.IperlHead) + : null; + if (iPerl != null) + { + /// TODO: Reimplement + //iPerl.LastTestResult = meterRslt; /// Save this water meter test result to iPerl WM + iPerl.NominalTestFlowLph = 500.0 * (double)(test.Qfrom + test.Qto); /// Ave. + convert to liter/hour + } + } + + //------------------------------------------------------------------- + Bridge.OnActivity(this, string.Format("{0} Simulation", test.Name)); + //------------------------------------------------------------------- + + State.Create(string.Format("{0}({1}) : Simulation", test.Method, test.Name)) + .AddOperation(checkUiOp) + .EnterState(); + e = StateMachine.WaitRunDevsRunOps(); + + if (TestAndLogUiCmdStop(test, e)) retVal = Event.UiCmdStop; + + /// Create a list with one item 'retVal' (default is Event.Done) and return it + IList retListSim = new List(1); + retListSim.Add(retVal); + return retListSim; + } + + + Elde.ControlBoardDev cBrd = StateMachine.ControlBoard; + processDataLoggingOp = new TBF.BenchControl.Operations.ProcessDataLoggingOp(processDataLogger, this, heatMetersTestParams != null); + + LtrPerRefPulse = outPath.FlowMeter.LtrPerPulse; + int totalPulses = (int)(test.Volume / LtrPerRefPulse + 0.5f); + + if (test.Volume > outPath.Scale.Capacity * Constants.TankFullFactor) + { + Bridge.OnError(this, Strings.Test_volume_exceeds_the_scale_capacity); + retVal = Event.UiCmdStop; + goto stopTestWOStoppingDivGateEtc; + } + + //==================================== + 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; + + bool drainTheTank = (repetitionNr == 1) ? test.DoDraining : false; + + if (repetitionNr == 1) + { + //------------------------------------------------ + Bridge.OnActivity(this, Strings.Checking_tank_capacity); + //------------------------------------------------ + + if (!drainTheTank) /// If condition met => skip measuring and force emptying + { + /// + /// Measure the weight and skip emptying if there is enough room in the tank + /// + State.Create(string.Format("{0}({1}) : Checking available tank capacity", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperation(outPath.Scale.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)); + + double estimatedEndMass = Mass.Val + test.Volume; + if (estimatedEndMass >= outPath.Scale.Capacity * Constants.TankFullFactor) + { + drainTheTank = true; + } + } + /// + if (drainTheTank) + { + #if BERLIN + switch (DrainTheTank(outPath.Scale.DrainValve, outPath.Scale)) + { + case Event.Error: { retVal = Event.Error; goto stopTest; } + case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } + } + + drainTheTank = false; + #else + State.Create(string.Format("{0}({1}) : Open the drain valve", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperation(StateMachine.ControlBoard.SetValvesOp(outPath.Scale.DrainValve, 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.ValvesBusy)); + #endif + } + } + + /// + /// Optionally display prompt to emerge temperature meters to appropriate baths for heat meters test + /// + IOperation heatMetersPromptOp = null; + if (heatMetersTestParams != null && !string.IsNullOrEmpty(heatMetersTestParams.Prompt)) + { + /// Make sure the CycleBeginForm is closed + if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stopTest; + + heatMetersPromptOp = new Operations.MessageBoxOp(heatMetersTestParams.Prompt); + } + + + //------------------------------------------------ + Bridge.OnActivity(this, Strings.Starting_the_pump); + //------------------------------------------------ + + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.FlowSetting)); + int flowSetTime0 = StateMachine.Time; + + if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOn(test.PumpPower); + /// + State.Create(string.Format("{0}({1}) : Starting the pump", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) +// .AddOperation(new Operations.SetAllRegulValvesOp(inPath.RegulValves, inPath.RegulValvesPct, 60)) + .AddOperation(heatMetersPromptOp) + .AddOperation(inPath.Pump != null ? cBrd.SetValvesOp(inPath.Pump, null) : 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; } + if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } + } + while (e.Contains(Event.ValvesBusy) /* || !e.Contains(Event.AllPositionsReached)*/); + + + if (test.TimePump2StartV > 0) + { + State.Create(string.Format("{0}({1}) : Waiting after the pump started", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperation(new Operations.TimerOp(test.TimePump2StartV)) + .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) + .AddOperation(heatMetersPromptOp) + .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(string.Format("{0}({1}) : Opening the stop backflow valve", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperation(StateMachine.ControlBoard.SetValvesOp(benchPath.StopBFValve, null)) + .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) + .AddOperation(heatMetersPromptOp) + .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(string.Format("{0}({1}) : Waiting before flow setting process starts", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperation(new Operations.TimerOp(test.TimeBeforeFlow)) + .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) + .AddOperation(heatMetersPromptOp) + .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(string.Format("{0}({1}) : Setting the flow", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) + .AddOperation(outPath.RegulValve.SetFlowOp(outPath.FlowMeter, test.Qfrom, test.Qto, outPath.PidCoef, RefFlow, 990)) /// timeout = 16.5 min. + .AddOperation(heatMetersPromptOp) + .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; + double currentFlow = RefFlow.Val; + + if (heatMetersTestParams != null && heatMetersPath != null) + { + //--------------------------------------------------- + Bridge.OnActivity(this, Strings.Setting_temperature); + //--------------------------------------------------- + + int lastTimeSec = StateMachine.Time; + double Tw_last = 0; + double Tc_last = 0; + + State.Create(string.Format("{0}({1}) : Check temperature stabilized.", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperation(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1)) + .AddOperation(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2)) + .AddOperation(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1)) + .AddOperation(heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2)) + .AddOperation(heatMetersPromptOp) + .EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + if (e.Contains(Event.Next)) goto temperature_set; + + if (TempRefHi1.Val != 0 && TempRefHi2.Val != 0 && TempRefLo1.Val != 0 && TempRefLo2.Val != 0) + { + if (StateMachine.Time - lastTimeSec > 10 || StateMachine.Time - lastTimeSec < 0) + { + double Tw = (TempRefHi1.Val + TempRefHi2.Val) / 2; + double Tc = (TempRefLo1.Val + TempRefLo2.Val) / 2; + if (heatMetersTestParams.TempWarmLo <= Tw && Tw <= heatMetersTestParams.TempWarmHi && + heatMetersTestParams.TempColdLo <= Tc && Tc <= heatMetersTestParams.TempColdHi && + Math.Abs(Tw - Tw_last) <= heatMetersTestParams.ChangeInTimeWarm && + Math.Abs(Tc - Tc_last) <= heatMetersTestParams.ChangeInTimeCold && + Math.Abs(TempRefHi1.Val - TempRefHi2.Val) <= heatMetersTestParams.DeltaTempWarm && + Math.Abs(TempRefLo1.Val - TempRefLo2.Val) <= heatMetersTestParams.DeltaTempCold) + { + goto temperature_set; + } + + lastTimeSec = StateMachine.Time; + Tw_last = Tw; + Tc_last = Tc; + } + } + } + while (true); + } + else if (test.DoControlWaterTemp && benchPath.TempMtrUp != null && benchPath.TempMtrDown != null) + { + //--------------------------------------------------- + Bridge.OnActivity(this, Strings.Setting_temperature); + //--------------------------------------------------- + + State.Create(string.Format("{0}({1}) : Wait until the water temperature is within limits", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperation(benchPath.TempMtrUp.ReadTempOp(ref TempUp)) + .AddOperation(benchPath.TempMtrDown.ReadTempOp(ref TempDown)) + .EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + if (e.Contains(Event.Next)) goto temperature_set; + + if (TempUp.Val >= test.TempLimLo && TempUp.Val <= test.TempLimHi && + TempDown.Val >= test.TempLimLo && TempDown.Val <= test.TempLimHi) + { + goto temperature_set; + } + } + while (true); + } + + temperature_set: + + /// + /// Prepare cameras, ROI-s and measurementOperations + /// + + /// Find successfully detected ROI-s + IList rois = new List(); + foreach (var rr in sensPath.RegisterReaders) + { + GenericDevices.IRoi roi = rr as GenericDevices.IRoi; + if (roi != null && roi.Detected) + { + rois.Add(roi); + } + } + + /// Find cameras + IList cameras = new List(); + foreach (var roi in rois) + { + if (roi.Camera != null && !cameras.Contains(roi.Camera)) + { + roi.Camera.ClearRoiParams(); + cameras.Add(roi.Camera); + } + } + + /// Register ROI-parameters to cameras + foreach (var roi in rois) roi.RegisterRoiToCamera(); + + /// Prepare measurementOperations + IList measureOperations = new List(); + foreach (var camera in cameras) measureOperations.Add(camera.MeasurementOp()); + + + if (repetitionNr == 1) + { + if (drainTheTank) + { + //------------------------------------------------ + Bridge.OnActivity(this, Strings.Closing_the_tank); + //------------------------------------------------ + + /// + /// Make sure tank draining completed + /// + IList extraOps = new List(); + if (heatMetersPath != null) + { + extraOps.Add(heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1)); + extraOps.Add(heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2)); + extraOps.Add(heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1)); + extraOps.Add(heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2)); + } + switch (DrainTheTank(outPath.Scale.DrainValve, outPath.Scale, extraOps)) + { + case Event.Error: { retVal = Event.Error; goto stopTest; } + case Event.UiCmdStop: { retVal = Event.UiCmdStop; goto stopTest; } + } + + drainTheTank = false; + } + else + { + /// Close the drain valve anyway + State.Create(string.Format("{0}({1}) : Close the drain valve", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperation(StateMachine.ControlBoard.SetValvesOp(null, outPath.Scale.DrainValve)) + .EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); + if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } + if (TestAndLogUiCmdStop(test, e)) { retVal = Event.UiCmdStop; goto stopTest; } + } + while (e.Contains(Event.ValvesBusy)); + } + + //------------------------------------------------ + Bridge.OnActivity(this, Strings.Measuring_the_weight); + //------------------------------------------------ + + if (test.TimeFlow2Mass > 0) + { + State.Create(string.Format("{0}({1}) : Waiting before 1st mass measurement", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1)) + .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2)) + .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1)) + .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2)) + .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)); + } + + LogProcessDataTestInfo(processDataLogger, test.Procedure.Name, test.Name); + + if (heatMetersPath == null) LogProcessDataHeader(processDataLogger, "Start mass"); + else LogProcessDataHeaderHeatMeters(processDataLogger, "Start mass"); + + State.Create(string.Format("{0}({1}) : Measuring the start mass", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperations(measureOperations) + .AddOperation(benchPath.TempMtrUp == null ? null : benchPath.TempMtrUp.ReadTempOp(ref TempUp)) + .AddOperation(benchPath.TempMtrDown == null ? null : benchPath.TempMtrDown.ReadTempOp(ref TempDown)) + .AddOperation(outPath.TempDiv == null ? null : outPath.TempDiv.ReadTempOp(ref TempDiv)) + .AddOperation(benchPath.PressMtrUp == null ? null : benchPath.PressMtrUp.ReadPressureOp(ref PressUp)) + .AddOperation(benchPath.PressMtrDown == null ? null : benchPath.PressMtrDown.ReadPressureOp(ref PressDown)) + .AddOperation(benchPath.PressMtrDelta == null ? null : benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta)) + .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1)) + .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2)) + .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1)) + .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2)) + .AddOperation((StateMachine.Ambient != null) + ? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null) + .AddOperation(outPath.Scale.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)); + + log.WarnFormat("Start mass = {0}kg", StartMass); + Mass.Val = StartMass.Val; + } + + + if (heatMetersPath == null) LogProcessDataHeader(processDataLogger, "Measurement"); + else LogProcessDataHeaderHeatMeters(processDataLogger, "Measurement"); + + //------------------------------------------------ + Bridge.OnActivity(this, Strings.Test_in_progress); + //------------------------------------------------ + State.Create(string.Format("{0}({1}) : Starting the test", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperations(measureOperations) + .AddOperation(benchPath.TempMtrUp == null ? null : benchPath.TempMtrUp.ReadTempOp(ref TempUp)) + .AddOperation(benchPath.TempMtrDown == null ? null : benchPath.TempMtrDown.ReadTempOp(ref TempDown)) + .AddOperation(outPath.TempDiv == null ? null : outPath.TempDiv.ReadTempOp(ref TempDiv)) + .AddOperation(benchPath.PressMtrUp == null ? null : benchPath.PressMtrUp.ReadPressureOp(ref PressUp)) + .AddOperation(benchPath.PressMtrDown == null ? null : benchPath.PressMtrDown.ReadPressureOp(ref PressDown)) + .AddOperation(benchPath.PressMtrDelta == null ? null : benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta)) + .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1)) + .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2)) + .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1)) + .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2)) + .AddOperation((StateMachine.Ambient != null) + ? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null) + .AddOperation(cBrd.UpdateTankWeightOp()) + .AddOperation(processDataLoggingOp) + .AddOperation(cBrd.StartMeasurementOp(outPath, (repetitionNr == 1) ? Elde.TestMethods.Diverter | Elde.TestMethods.Synchro : 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 TestMethods.iPerlCommunication.iPerlHead.IperlHead) + { + (rr as TestMethods.iPerlCommunication.iPerlHead.IperlHead).TestName = test.Name; + } + } + + + /// Measurement loop - preparation + readRegistersOp = new Operations.ReadMoreRegistersOp(sensPath.RegisterReaders); + queryEnd1 = cBrd.QueryMeasurementEndOp(); /// ??? + + int estimtdEndTime = StateMachine.Time + (int)test.TstTime; + ClearAllStatistics(StateMachine.Time); + + if (repetitionNr == 1) + { + /// Read the diverter switch time + switchTimeStart = 0.001f * (float)cBrd.DivTime(0); + log.WarnFormat("Diverter switch time on test start = {0} ms", cBrd.DivTime(0)); + } + + /// Measurement loop - begin + State.Create(string.Format("{0}({1}) : Reading watermeters", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperations(measureOperations) + .AddOperation(readRegistersOp) + .AddOperation(benchPath.TempMtrUp == null ? null : benchPath.TempMtrUp.ReadTempOp(ref TempUp)) + .AddOperation(benchPath.TempMtrDown == null ? null : benchPath.TempMtrDown.ReadTempOp(ref TempDown)) + .AddOperation(outPath.TempDiv == null ? null : outPath.TempDiv.ReadTempOp(ref TempDiv)) + .AddOperation(benchPath.PressMtrUp == null ? null : benchPath.PressMtrUp.ReadPressureOp(ref PressUp)) + .AddOperation(benchPath.PressMtrDown == null ? null : benchPath.PressMtrDown.ReadPressureOp(ref PressDown)) + .AddOperation(benchPath.PressMtrDelta == null ? null : benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta)) + .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1)) + .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2)) + .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1)) + .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2)) + .AddOperation((repetitionNr == 1) ? outPath.Scale.ReadMassOp(ref Mass) : null) + .AddOperation((repetitionNr == 1) ? StateMachine.ControlBoard.UpdateTankWeightOp() : null) + .AddOperation((repetitionNr == 1) ? cBrd.ReadDiverterTransitionOp(2, 4, switchTimeStartLo, switchTimeStartHi) : null) + .AddOperation((StateMachine.Ambient != null) + ? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) + : null) + .AddOperation(queryEnd1) + .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)); + } + //------------------------------------------------ + + RefFreq.Val = cBrd.ReferenceFreq; + RefFlow.Val = cBrd.ReferenceFlow; + + UpdateAllStatistics(StateMachine.Time); + + if (heatMetersTestParams != null) + { + if (lastEnergyUpdateTime == 0) + { + lastEnergyUpdateTime = StateMachine.Time; + } + else + { + //double deltaTime = (double)(StateMachine.Time - lastEnergyUpdateTime); + double T_in = (TempRefHi1.Val + TempRefHi2.Val) / 2; /// [°C] + double T_out = (TempRefLo1.Val + TempRefLo2.Val) / 2; /// [°C] + double deltaVolume = LtrPerRefPulse * RefPulsesDelta; /// [l] + double deltaEnergy = (0.001 * deltaVolume) * (T_in - T_out) * Formulas.HeatCoefficientWater(16, T_in, T_out, heatMetersTestParams.FlowMeasuredAtHiTempPipe); /// [J] = [m3] * [K] * [J/(m3 K)] + Energy.Update(deltaEnergy); + VolumeForEnergy.Update(deltaVolume); + lastEnergyUpdateTime = StateMachine.Time; + } + } + + Bridge.OnProcessData(this, new ProcessDataEventArgs(test, repetitionNr, Config.Entities.Progress.Test)); + Bridge.OnTestProgress(this, new TestProgressEventArgs(test, repetitionNr, Config.Entities.Progress.Test)); + } + while (!e.Contains(Event.Next)); /// 'Next' button can be used in Debug version + + /// Measurement loop - end + + test_completed: + + if (repetitionNr == 1) + { + /// + /// (Berlin:) Water is stopped immediately after the test and before the 2nd mass measurement in case: + /// - no 'transition sequence after test' is used + /// - this is the last (or the only) test repetition or test is a part of an 'outer loop' + /// + if (isLastRepetition && transitionAfter == null) + { + if (inPath.Pump is GenericDevices.IPumpFM) (inPath.Pump as GenericDevices.IPumpFM).TurnOff(); + + State.Create("SequenceBase : Transition : TestEnd - Default action") + .AddOperation(checkUiOp) + .AddOperation(new MettlerToledo.KeepReadingMassesOp()) + .AddOperation(StateMachine.ControlBoard.UpdateTankWeightOp()) + .AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DefaultValvesOpen, + StateMachine.DefaultValvesClose)) + .EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); + if (e.Contains(Event.Error)) { retVal = Event.Error; goto stopTest; } + if (TestAndLogUiCmdStop(e)) { retVal = Event.UiCmdStop; goto stopTest; } + } + while (!e.Contains(Event.ValvesSet)); + } + + //------------------------------------------------ + Bridge.OnActivity(this, Strings.Measuring_the_weight); + //------------------------------------------------ + State.Create(string.Format("{0}({1}) : Waiting before the 2nd mass measurement", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperation(benchPath.TempMtrUp == null ? null : benchPath.TempMtrUp.ReadTempOp(ref TempUp)) + .AddOperation(benchPath.TempMtrDown == null ? null : benchPath.TempMtrDown.ReadTempOp(ref TempDown)) + .AddOperation(outPath.TempDiv == null ? null : outPath.TempDiv.ReadTempOp(ref TempDiv)) + .AddOperation(benchPath.PressMtrUp == null ? null : benchPath.PressMtrUp.ReadPressureOp(ref PressUp)) + .AddOperation(benchPath.PressMtrDown == null ? null : benchPath.PressMtrDown.ReadPressureOp(ref PressDown)) + .AddOperation(benchPath.PressMtrDelta == null ? null : benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta)) + .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1)) + .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2)) + .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1)) + .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2)) + .AddOperation((StateMachine.Ambient != null) + ? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null) + .AddOperation(outPath.Scale.ReadMassOp(ref Mass)) + .AddOperation(cBrd.UpdateTankWeightOp()) + .AddOperation(cBrd.ReadDiverterTransitionOp(2, 4, switchTimeEndLo, switchTimeEndHi)) + .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) || !e.Contains(Event.BalanceDone)); + + + if (heatMetersPath == null) LogProcessDataHeader(processDataLogger, "End mass"); + else LogProcessDataHeaderHeatMeters(processDataLogger, "End mass"); + + /// Read the diverter switch time + switchTimeEnd = 0.001f * (float)cBrd.DivTime(0); + log.WarnFormat("Diverter switch time on test end = {0} ms", cBrd.DivTime(0)); + + State.Create(string.Format("{0}({1}) : Measuring the end mass", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperation(benchPath.TempMtrUp == null ? null : benchPath.TempMtrUp.ReadTempOp(ref TempUp)) + .AddOperation(benchPath.TempMtrDown == null ? null : benchPath.TempMtrDown.ReadTempOp(ref TempDown)) + .AddOperation(outPath.TempDiv == null ? null : outPath.TempDiv.ReadTempOp(ref TempDiv)) + .AddOperation(benchPath.PressMtrUp == null ? null : benchPath.PressMtrUp.ReadPressureOp(ref PressUp)) + .AddOperation(benchPath.PressMtrDown == null ? null : benchPath.PressMtrDown.ReadPressureOp(ref PressDown)) + .AddOperation(benchPath.PressMtrDelta == null ? null : benchPath.PressMtrDelta.ReadPressureOp(ref PressDelta)) + .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefWarm1.ReadTempOp(ref TempRefHi1)) + .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefWarm2.ReadTempOp(ref TempRefHi2)) + .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold1.ReadTempOp(ref TempRefLo1)) + .AddOperation(heatMetersPath == null ? null : heatMetersPath.TMeterRefCold2.ReadTempOp(ref TempRefLo2)) + .AddOperation((StateMachine.Ambient != null) + ? StateMachine.Ambient.ReadAmbientOp(AmbTemp, AmbPress, AmbHumi) : null) + .AddOperation(outPath.Scale.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); + } + + //------------------------------------------------ + Bridge.OnActivity(this, Strings.Test_completed); + //------------------------------------------------ + + TestEndTime = DateTime.Now; + + /// Make sure the CycleBeginForm is closed so that water meter data (s/n) can be copied into results + if (heatMetersPromptOp == null) + { + if (UIFlowControl.Stop == WaitBeginFormClosed()) goto stopTest; + } + + /// + /// Populate TestResult data entity with data + /// + Results.Entities.TestRslt tstRslt = BatchRslts.GetTestRslt(testName, test.Part); + + if (tstRslt != null) + { + UpdateTempPressDensAmb(tstRslt); + + /// 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.FlowVolume = 3.6 * LtrPerRefPulse * tstRslt.PulsesMaster / tstRslt.TestTime; /// [m3/h] + /// + tstRslt.Buoyancy = Formulas.Buoyancy(); + if (repetitionNr == 1) + { + tstRslt.MassStartRaw = StartMass.Val; + tstRslt.MassStart = Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Scale.Corrections); + tstRslt.MassEndRaw = EndMass.Val; + tstRslt.MassEnd = Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Scale.Corrections); + tstRslt.FlowMass = 3600.0 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.TestTime; /// [kg/h] + double density = Formulas.WaterDensityFromTemp((tstRslt.TempUpMean + tstRslt.TempDownMean) / 2.0); + tstRslt.VolumeCTV = 1000.0 * tstRslt.Buoyancy * (tstRslt.MassEnd - tstRslt.MassStart) / density; /// [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.DiverterStart = Math.Abs(switchTimeStartHi.Val - switchTimeStartLo.Val); + tstRslt.DivStart10 = switchTimeStartLo.Val; + tstRslt.DivStart50 = switchTimeStart; + tstRslt.DivStart90 = switchTimeStartHi.Val; + tstRslt.DiverterEnd = Math.Abs(switchTimeEndLo.Val - switchTimeEndHi.Val); + tstRslt.DivEnd90 = switchTimeEndHi.Val; + tstRslt.DivEnd50 = switchTimeEnd; + tstRslt.DivEnd10 = switchTimeEndLo.Val; + log.DebugFormat("Diverter switch time [s]: Start: {0}({1} {2} {3}) End: {4}({5} {6} {7})", + tstRslt.DiverterStart, tstRslt.DivStart10, tstRslt.DivStart50, tstRslt.DivStart90, + tstRslt.DiverterEnd, tstRslt.DivEnd90, tstRslt.DivEnd50, tstRslt.DivEnd10); + + tstRslt.ErrorFlagsMd = (ErrorFlagsComp != null) ? (sbyte)ErrorFlagsComp.Mode : (sbyte)0; + tstRslt.ErrorFlags = (ErrorFlagsComp != null) ? ErrorFlagsComp.GetErrorFlags(tstRslt, true, false, tstRslt.DiverterStart, tstRslt.DiverterEnd) : 0; + } + else + { + Results.Entities.TestRslt tstResRepet1 = BatchRslts.GetTestRslt(Results.Utils.GetTestName(test.Name, test.Repeats, 1), test.Part); + + tstRslt.MassStartRaw = 0; + tstRslt.MassStart = 0; + tstRslt.MassEndRaw = 0; + tstRslt.MassEnd = 0; + tstRslt.FlowMass = 0; + tstRslt.ConstMaster = tstResRepet1.ConstMaster; /// Master constant ( pulses per liter) from the first repetition (=against the scale) + tstRslt.VolumeMaster = tstRslt.ConstMaster * tstRslt.PulsesMaster; /// [l] volume from the master flow meter + tstRslt.VolumeCTV = tstRslt.VolumeMaster; /// [l] 1000.0f is because density is in [kg/m3] + tstRslt.ErrorMaster = tstResRepet1.ErrorMaster; /// Cannot be determined without a mass measurement + + tstRslt.DiverterStart = 0; + tstRslt.DivStart10 = 0; + tstRslt.DivStart50 = 0; + tstRslt.DivStart90 = 0; + tstRslt.DiverterEnd = 0; + tstRslt.DivEnd90 = 0; + tstRslt.DivEnd50 = 0; + tstRslt.DivEnd10 = 0; + + tstRslt.ErrorFlagsMd = (ErrorFlagsComp != null) ? (sbyte)ErrorFlagsComp.Mode : (sbyte)0; + tstRslt.ErrorFlags = (ErrorFlagsComp != null) ? ErrorFlagsComp.GetErrorFlags(tstRslt, false, false, 0, 0) : 0; + } /// [kg/h] + + tstRslt.FlowMean = (float)RefFlowStat.Average; + tstRslt.FlowStart = (float)RefFlowStat.First; + tstRslt.FlowEnd = (float)RefFlowStat.Last; + tstRslt.FlowMin = (float)RefFlowStat.Min; + tstRslt.FlowMax = (float)RefFlowStat.Max; + + + 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; + + 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 && 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 + + 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.GetErrLimLo(tstRslt.FlowMean) + test.Uncertainty) + && (compoundMeterRslt.Error <= test.GetErrLimHi(tstRslt.FlowMean) - test.Uncertainty) + && (tstRslt.ErrorFlags == 0 || tstRslt.ErrorFlagsMode() != Config.Entities.ErrorFlagsMode.On); + mainMeterRslt.Passed = auxMeterRslt.Passed = compoundMeterRslt.Passed; + mainMeterRslt.TestDone = auxMeterRslt.TestDone = compoundMeterRslt.TestDone = true; + tstRslt.TestDone = true; + } + } + } + else if (heatMetersTestParams != null) + { + /// + /// Heat meters + /// + tstRslt.RefEnergy = Energy.Sum * tstRslt.VolumeCTV / VolumeForEnergy.Sum; /// [J] = [J] * [l] / [l] + + tstRslt.Custom1 = (float)TempRefHiStat.Average; + tstRslt.Custom2 = (float)TempRefHiStat.First; + tstRslt.Custom3 = (float)TempRefHiStat.Last; + tstRslt.Custom4 = (float)TempRefHiStat.Min; + tstRslt.Custom5 = (float)TempRefHiStat.Max; + tstRslt.Custom6 = (float)TempRefLoStat.Average; + tstRslt.Custom7 = (float)TempRefLoStat.First; + tstRslt.Custom8 = (float)TempRefLoStat.Last; + tstRslt.Custom9 = (float)TempRefLoStat.Min; + tstRslt.Custom10 = (float)TempRefLoStat.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 volumeRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.HeatMeterVolume); + Results.Entities.MeterTestRslt energyRslt = BatchRslts.GetMeterTestRslt(testName, i, Config.Entities.CompoundMeterId.HeatMeterEnergy); + + BenchControl.GenericDevices.IRegisterReader volumeRegReader = + (sensPath.RegisterReaders.Length > 2 * i) ? sensPath.RegisterReaders[2 * i] : null; + + BenchControl.GenericDevices.IRegisterReader energyRegReader = + (sensPath.RegisterReaders.Length > 2 * i + 1) ? sensPath.RegisterReaders[2 * i + 1] : null; + + if (volumeRslt != null && volumeRegReader != null) + { + volumeRslt.PulsesPerLiter = volumeRegReader.PulsesPerLtr; /// [l ^ -1] + volumeRslt.PulsesMeter = Convert.ToDouble(volumeRegReader.WMPulses); + volumeRslt.PulsesMaster = Convert.ToDouble(volumeRegReader.WMRefPulses); + volumeRslt.VolumeStart = 0; + volumeRslt.VolumeEnd = 0; + volumeRslt.VolumeMeter = volumeRslt.PulsesMeter * volumeRegReader.LtrsPerPulse; /// [l] + volumeRslt.VolumeRef = volumeRslt.PulsesMaster * tstRslt.ConstMaster; /// [l] + volumeRslt.TestTime = tstRslt.TestTime; /// [s] + + volumeRslt.Error = Formulas.ErrorFromVolumes(volumeRslt.VolumeMeter, volumeRslt.VolumeRef); + volumeRslt.Passed = !heatMetersTestParams.EvaluateVolume || + ((volumeRslt.Error >= test.GetErrLimLo(tstRslt.FlowMean) + test.Uncertainty) && + (volumeRslt.Error <= test.GetErrLimHi(tstRslt.FlowMean) - test.Uncertainty) && + (tstRslt.ErrorFlags == 0 || tstRslt.ErrorFlagsMode() != Config.Entities.ErrorFlagsMode.On)); + volumeRslt.TestDone = true; + tstRslt.TestDone = true; + } + + if (energyRslt != null && energyRegReader != null) + { + energyRslt.PulsesPerLiter = energyRegReader.PulsesPerLtr; /// [kWh ^ -1] + energyRslt.PulsesMeter = Convert.ToDouble(energyRegReader.WMPulses); + energyRslt.PulsesMaster = Convert.ToDouble(energyRegReader.WMRefPulses); + energyRslt.VolumeStart = 0; + energyRslt.VolumeEnd = 0; + energyRslt.VolumeRef = tstRslt.RefEnergy * (energyRslt.PulsesMaster / tstRslt.PulsesMaster); /// [J] + energyRslt.VolumeMeter = energyRslt.PulsesMeter * Config.Units.ConvertFrom(Config.Unit.kWh, energyRegReader.LtrsPerPulse); /// [J] + energyRslt.TestTime = tstRslt.TestTime; /// [s] + + energyRslt.Error = Formulas.ErrorFromVolumes(energyRslt.VolumeMeter, energyRslt.VolumeRef); + energyRslt.Passed = (energyRslt.Error >= heatMetersTestParams.ErrorLimitLo) + && (energyRslt.Error <= heatMetersTestParams.ErrorLimitHi) + && (tstRslt.ErrorFlags == 0 || tstRslt.ErrorFlagsMode() != Config.Entities.ErrorFlagsMode.On); + energyRslt.TestDone = true; + tstRslt.TestDone = true; + } + } + } + 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); + GenericDevices.IRegisterReader regReader = sensPath.RegisterReaders[i]; + TestMethods.iPerlCommunication.iPerlHead.IperlHead iPerl = regReader as TestMethods.iPerlCommunication.iPerlHead.IperlHead; + GenericDevices.IRoi cameraRoi = regReader as GenericDevices.IRoi; + + if (meterRslt != null && regReader != null) + { + meterRslt.PulsesPerLiter = regReader.PulsesPerLtr; + meterRslt.PulsesMeter = Convert.ToDouble(regReader.WMPulses); + meterRslt.PulsesMaster = Convert.ToDouble(regReader.WMRefPulses); + + if (iPerl != null) + { + if (iPerl.ResultCode != 0 && (meterRslt.WaterMeter.ResultCode & (int)Results.Entities.ResultCode.OptoErrorCodeMask) == 0) + { + meterRslt.WaterMeter.ResultCode |= iPerl.ResultCode; + } + + 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 IPERL + meterRslt.WaterMeter.CalibFactor = (iPerl.CalibrationStruct != null) ? iPerl.CalibrationStruct.Calibration : 0; + meterRslt.WaterMeter.Q2Correction = iPerl.Q2Correction; + meterRslt.WaterMeter.Q2CorrRFlow = iPerl.Q2CorrRFlow; + meterRslt.WaterMeter.Q2CorrLFlow = iPerl.Q2CorrLFlow; +#endif + iPerl.LastTestResult2 = iPerl.LastTestResult; /// Save shift previous test result + iPerl.LastTestResult = meterRslt; /// Save this test result + iPerl.NominalTestFlowLph = 500.0 * (test.Qfrom + test.Qto); /// Ave. + convert to liter/hour + } + else if (cameraRoi != null) + { + meterRslt.TimestampStart = cameraRoi.TimestampStart; /// second + meterRslt.TimestampEnd = cameraRoi.TimestampEnd; /// second + meterRslt.TestTime = cameraRoi.TimestampEnd - cameraRoi.TimestampStart; /// second + + meterRslt.VolumeStart = cameraRoi.VolumeStart; /// liter + meterRslt.VolumeEnd = cameraRoi.VolumeEnd; /// liter + meterRslt.VolumeMeter = cameraRoi.VolumeEnd - cameraRoi.VolumeStart; /// liter + + meterRslt.VolumeRef = tstRslt.VolumeCTV * meterRslt.TestTime / tstRslt.TestTime; + } + 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); + +#if TEST_MODE + if (!BatchRslts.IsProduction() && + ((test.Name.ToLower().Contains("q2") && Math.Abs(meterRslt.Error) > 2.0 && Math.Abs(meterRslt.Error) <= 4.0) || + (test.Name.ToLower().Contains("q1") && Math.Abs(meterRslt.Error) > 5.0 && Math.Abs(meterRslt.Error) <= 10.0))) + { + meterRslt.KorrErrQ = meterRslt.Error; + meterRslt.Error /= 2.0; + meterRslt.VolumeMeter = (1.0 + meterRslt.Error / 100.0) * meterRslt.VolumeRef; + meterRslt.PulsesMeter = meterRslt.VolumeMeter * regReader.PulsesPerLtr; + + if (meterRslt.VolumeEnd > meterRslt.VolumeStart) + { + meterRslt.VolumeEnd = meterRslt.VolumeStart + meterRslt.VolumeMeter; + } + else if (meterRslt.VolumeEnd < meterRslt.VolumeStart) + { + meterRslt.VolumeEnd = meterRslt.VolumeStart - meterRslt.VolumeMeter; + } + } + else + { + meterRslt.KorrErrQ = 0; + } +#endif + + meterRslt.Passed = (meterRslt.Error >= test.GetErrLimLo(tstRslt.FlowMean) + test.Uncertainty) + && (meterRslt.Error <= test.GetErrLimHi(tstRslt.FlowMean) - test.Uncertainty) + && (tstRslt.ErrorFlags == 0 || tstRslt.ErrorFlagsMode() != Config.Entities.ErrorFlagsMode.On); + meterRslt.TestDone = true; + tstRslt.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.Scale != null ? outPath.Scale.Name : string.Empty, + outPath.RegulValve != null ? outPath.RegulValve.Name : string.Empty, + outPath.Diverter != null ? outPath.Diverter.Name : string.Empty)); + + /// Update water meter error flags + if (ErrorFlagsComp != null) + { + for (int i = 0; i < BatchRslts.WMPositionsCount; i++) + { + if (BatchRslts.WaterMeters[i] != null) + { + BatchRslts.WaterMeters[i].ErrorFlags = ErrorFlagsComp.GetWMtrErrorFlags(BatchRslts.WaterMeters[i].MeterTestRslts); + } + } + } + + /// 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)); + + + stopTest: + + /// + /// Quit this sequence + /// + if (isLastRepetition || retVal == Event.UiCmdStop || retVal == Event.OpArgumentError + || retVal == Event.Error || retVal == Event.ConfigurationError) + { + State.Create(string.Format("{0}({1}) : Stopping diverter, gate, etc.", test.Method, test.Name)) + .AddOperation(checkUiOp) + .AddOperation(cBrd.StopPreviousOp()) + .EnterState(); + do + { + e = StateMachine.WaitRunDevsRunOps(); + if (TestAndLogUiCmdStop(test, e)) { if (retVal == Event.Done) retVal = Event.UiCmdStop; break; } + } + while (!e.Contains(Event.PreviousStopped)); + } + + stopTestWOStoppingDivGateEtc: + + /// 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/FlyingStartFirstRepetWithMassColl/HeatMeters/Component.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/HeatMeters/Component.cs new file mode 100644 index 000000000..8ba9537ba --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/HeatMeters/Component.cs @@ -0,0 +1,40 @@ +/// +/// Copyright (c) 2018 Sensus Slovensko a.s. +/// +using System; +using System.Collections.Generic; +using log4net; +using Config.Entities; + +namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl.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)); + } + + public bool CanTest(MetersKind meters) { return meters == MetersKind.HeatMeter; } + public bool DoTransitions() { return true; } + + readonly TestMethodCfg testMethodCfg; + + public Component() + { + } + + public Component(Generic.IComponentCfg cfg) + : base(cfg) + { + testMethodCfg = cfg as TestMethodCfg; + log.Debug(this.ToString()); + } + + public IList Execute(Test test, int repetNr, bool isLastRepetition) + { + return (new FlyingStartFirstRepetWithMassCollSeq()).Execute(test, repetNr, isLastRepetition, null, testMethodCfg.TestParams, DebugLevel); + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/HeatMeters/Factory.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/HeatMeters/Factory.cs new file mode 100644 index 000000000..bf2541a1a --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/HeatMeters/Factory.cs @@ -0,0 +1,26 @@ +/// +/// Copyright (c) 2018 Sensus Slovensko a.s. +/// +using System.Collections.Generic; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl.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(TestMethodCfg.Serializer, component, this); + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/HeatMeters/TestMethodCfg.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/HeatMeters/TestMethodCfg.cs new file mode 100644 index 000000000..a7d44c170 --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/HeatMeters/TestMethodCfg.cs @@ -0,0 +1,50 @@ +/// +/// Copyright (c) 2018 Sensus Slovensko a.s. +/// +using System; +using System.Collections.Generic; +using System.IO; +using System.Xml.Serialization; +using Config.Entities; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl.HeatMeters +{ + public class TestMethodCfg : ComponentCfgBase, Generic.IComponentCfg + { + public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(TestMethodCfg) })[0]; + protected override XmlSerializer GetSerializer() { return Serializer; } + + 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(true); + testParams.UpdateTestParams(Name, test); + return testParams; + } + + /// Private parameterless constructor invoked by all other (public) constructors + TestMethodCfg() + { + TestParams = new TestParams(true); + } + + 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/FlyingStartFirstRepetWithMassColl/HeatMeters/TestMethodCfgCtrl.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/HeatMeters/TestMethodCfgCtrl.cs new file mode 100644 index 000000000..763b78ac1 --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/HeatMeters/TestMethodCfgCtrl.cs @@ -0,0 +1,71 @@ +/// +/// Copyright (c) 2018 Sensus Slovensko a.s. +/// +using System; +using System.Windows.Forms; +using log4net; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl.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/FlyingStartFirstRepetWithMassColl/HeatMeters/TestMethodCfgCtrl.designer.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/HeatMeters/TestMethodCfgCtrl.designer.cs new file mode 100644 index 000000000..048729f05 --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/HeatMeters/TestMethodCfgCtrl.designer.cs @@ -0,0 +1,86 @@ +/// +/// Copyright (c) 2018 Sensus Slovensko a.s. +/// +namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl.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/FlyingStartFirstRepetWithMassColl/HeatMeters/TestMethodCfgCtrl.resx b/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/HeatMeters/TestMethodCfgCtrl.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/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/FlyingStartFirstRepetWithMassColl/HeatMeters/TestParams.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/HeatMeters/TestParams.cs new file mode 100644 index 000000000..b6488e73a --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/HeatMeters/TestParams.cs @@ -0,0 +1,197 @@ +/// +/// Copyright (c) 2018 Sensus Slovensko a.s. +/// +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.FlyingStartFirstRepetWithMassColl.HeatMeters +{ + public class TestParams : TestParamsBase, IParamsProvider, ITestParams + { + public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(TestParams) })[0]; + protected override XmlSerializer GetSerializer() { return Serializer; } + + public float ErrorLimitLo; /// [%] + public float ErrorLimitHi; /// [%] + public bool EvaluateVolume; /// true = evaluate also the volume, false = evaluate only energy + public float TempWarmLo; /// Low limit for warm temperature [°C] + public float TempWarmHi; /// High limit for warm temperature [°C] + public float TempColdLo; /// Low limit for cold temperature [°C] + public float TempColdHi; /// High limit for cold temperature [°C] + public bool FlowMeasuredAtHiTempPipe; /// true = flow measured at high temp. pipe, false = flow measured at low temp. pipe + public float DeltaTempWarm; + public float DeltaTempCold; + public float ChangeInTimeWarm; + public float ChangeInTimeCold; + public string Prompt; + + public override void InitializeAll() + { + FlowMeasuredAtHiTempPipe = false; + } + + + string[] paramNames = new string[] + { + Strings.Err_limit_neg_pct_chdr, + Strings.Err_limit_pos_pct_chdr, + Strings.Evaluate_volume, + "T hi min", + "T hi max", + "T lo min", + "T lo max", + "Flow measured at high temp.pipe", + "Delta T warm", + "Delta T cold", + "Change in time T warm", + "Change in time T cold", + Strings.Prompt, + }; + 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 ErrorLimitLo.ToString(); + case 1: return ErrorLimitHi.ToString(); + case 2: return (EvaluateVolume ? Strings.yes : Strings.no); + case 3: return TempWarmLo.ToString(); + case 4: return TempWarmHi.ToString(); + case 5: return TempColdLo.ToString(); + case 6: return TempColdHi.ToString(); + case 7: return (FlowMeasuredAtHiTempPipe ? Strings.yes : Strings.no); + case 8: return DeltaTempWarm.ToString(); + case 9: return DeltaTempCold.ToString(); + case 10: return ChangeInTimeWarm.ToString(); + case 11: return ChangeInTimeCold.ToString(); + case 12: return Prompt; + default: return string.Empty; + } + } + + public void UpdateParam(int i, string strValue) + { + switch (i) + { + case 0: ErrorLimitLo = Utils.ParseSFloat(strValue); return; + case 1: ErrorLimitHi = Utils.ParseSFloat(strValue); return; + case 2: EvaluateVolume = strValue.Equals(Strings.yes); return; + case 3: TempWarmLo = Utils.ParseSFloat(strValue); return; + case 4: TempWarmHi = Utils.ParseSFloat(strValue); return; + case 5: TempColdLo = Utils.ParseSFloat(strValue); return; + case 6: TempColdHi = Utils.ParseSFloat(strValue); return; + case 7: FlowMeasuredAtHiTempPipe = strValue.Equals(Strings.yes); return; + case 8: DeltaTempWarm = Utils.ParseUFloat(strValue); return; + case 9: DeltaTempCold = Utils.ParseUFloat(strValue); return; + case 10: ChangeInTimeWarm = Utils.ParseUFloat(strValue); return; + case 11: ChangeInTimeCold = Utils.ParseUFloat(strValue); return; + case 12: Prompt = strValue; return; + default: return; + } + } + + public bool ValidateParam(int i, string strValue, out string message) + { + message = string.Empty; + float dummy; + + switch (i) + { + case 0: + case 1: + case 3: + case 4: + case 5: + case 6: + if (Utils.TryParseSFloat(strValue, out dummy)) return true; + break; + case 2: + case 7: + if (strValue.Equals(Strings.yes) || strValue.Equals(Strings.no)) return true; + break; + case 8: + case 9: + case 10: + case 11: + if (Utils.TryParseUFloat(strValue, out dummy)) return true; + break; + case 12: + return true; + default: + message = "Invalid index"; + return false; + } + + message = ParamName(i) + " is invalid"; + return false; + } + + void CopyContentTo(TestParams prms) + { + prms.ErrorLimitLo = ErrorLimitLo; + prms.ErrorLimitHi = ErrorLimitHi; + prms.EvaluateVolume = EvaluateVolume; + prms.TempWarmLo = TempWarmLo; + prms.TempWarmHi = TempWarmHi; + prms.TempColdLo = TempColdLo; + prms.TempColdHi = TempColdHi; + prms.FlowMeasuredAtHiTempPipe = FlowMeasuredAtHiTempPipe; + prms.DeltaTempWarm = DeltaTempWarm; + prms.DeltaTempCold = DeltaTempCold; + prms.ChangeInTimeWarm = ChangeInTimeWarm; + prms.ChangeInTimeCold = ChangeInTimeCold; + prms.Prompt = Prompt; + } + + public IParamsProvider Clone() + { + TestParams pars = new TestParams(); + CopyContentTo(pars); + return pars; + } + + public override void UpdateTestParams(ComponentTest dbEntity) + { + if (dbEntity == null) return; + try + { + TestParams tmp = Serializer.Deserialize(new StringReader(dbEntity.Parameters)) as TestParams; + + testParamsEntity = dbEntity; + componentName = dbEntity.CmpntName; + test = dbEntity.Test; + + if (tmp != null) tmp.CopyContentTo(this); + } + catch + { + } + } + + /// + /// Parameterless constructor initializes the parameters + /// + public TestParams() + { + } + + public TestParams(bool initialize) + { + if (initialize) InitializeAll(); + } + + public TestParams(ComponentTest testParamsEntity, string componentName, Test test) + { + this.testParamsEntity = testParamsEntity; + this.componentName = componentName; + this.test = test; + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Single/Component.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Single/Component.cs new file mode 100644 index 000000000..e2245a5ef --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Single/Component.cs @@ -0,0 +1,37 @@ +/// +/// Copyright (c) 2018 Sensus Slovensko a.s. +/// +using System; +using System.Collections.Generic; +using log4net; +using Config.Entities; + +namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl.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 CanTest(MetersKind meters) { return meters == MetersKind.Single; } + public bool DoTransitions() { return true; } + + public Component() + { + } + + public Component(Generic.IComponentCfg cfg) + : base(cfg) + { + log.Debug(this.ToString()); + } + + public IList Execute(Test test, int repetNr, bool isLastRepetition) + { + return (new FlyingStartFirstRepetWithMassCollSeq()).Execute(test, repetNr, isLastRepetition, null, null, DebugLevel); + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Single/Factory.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Single/Factory.cs new file mode 100644 index 000000000..e5e80834f --- /dev/null +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartFirstRepetWithMassColl/Single/Factory.cs @@ -0,0 +1,27 @@ +/// +/// Copyright (c) 2018 Sensus Slovensko a.s. +/// +using System.Collections.Generic; +using TBF.BenchControl.Generic; +using TBF.BenchControl.Configs.NameOnly; + +namespace TBF.BenchControl.TestMethods.FlyingStartFirstRepetWithMassColl.Single +{ + 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(TestMethodCfg.Serializer, component, this); + } + } +} diff --git a/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs index 87b5bcbb7..3f8dea039 100644 --- a/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs +++ b/TestBenchFramework/BenchControl/TestMethods/FlyingStartMassCollection/FlyingStartMassCollectionSeq.cs @@ -113,7 +113,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection { Bridge.OnError(this, Strings.Test_volume_exceeds_the_scale_capacity); retVal = Event.UiCmdStop; - goto stopTestWOTransitionAfter; + goto stopTestWOStoppingDivGateEtc; } //==================================== @@ -965,13 +965,13 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection } 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; + 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 IPERL meterRslt.WaterMeter.CalibFactor = (iPerl.CalibrationStruct != null) ? iPerl.CalibrationStruct.Calibration : 0; meterRslt.WaterMeter.Q2Correction = iPerl.Q2Correction; @@ -1089,7 +1089,7 @@ namespace TBF.BenchControl.TestMethods.FlyingStartMassCollection while (!e.Contains(Event.PreviousStopped)); } - stopTestWOTransitionAfter: + stopTestWOStoppingDivGateEtc: /// Create a list with one item 'retVal' (default is Event.Done) and return it IList retList = new List(1); diff --git a/TestBenchFramework/Properties/AssemblyInfo.cs b/TestBenchFramework/Properties/AssemblyInfo.cs index a31e44033..3895d7f19 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.17.772.0")] -[assembly: AssemblyFileVersion("2.17.772.0")] +[assembly: AssemblyVersion("2.17.775.0")] +[assembly: AssemblyFileVersion("2.17.775.0")] diff --git a/TestBenchFramework/TBF.csproj b/TestBenchFramework/TBF.csproj index 8f77cbf22..100ad0fcf 100644 --- a/TestBenchFramework/TBF.csproj +++ b/TestBenchFramework/TBF.csproj @@ -913,6 +913,29 @@ + + + + + UserControl + + + TestMethodCfgCtrl.cs + + + + + + + + UserControl + + + TestMethodCfgCtrl.cs + + + + @@ -2276,6 +2299,12 @@ TestMethodCfgCtrl.cs + + TestMethodCfgCtrl.cs + + + TestMethodCfgCtrl.cs + GrabImageCfgCtrl.cs