From 765637ce2d9bb37cb2856fb39c6258b228714998 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Fri, 3 Aug 2018 10:57:38 +0200 Subject: [PATCH] TestMethods.PulsesTest : (1) Fixes in forms, (2) MinPulsesCount test parameter introduced, ver. 2.18.977 --- .../TestMethods/PulsesTest/PulsesTestSeq.cs | 8 +- .../TestMethods/PulsesTest/TestMethod.cs | 7 +- .../TestMethods/PulsesTest/TestMethodCfg.cs | 49 +++++++ .../PulsesTest/TestMethodCfgCtrl.cs | 69 ++++++++++ .../PulsesTest/TestMethodCfgCtrl.designer.cs | 86 +++++++++++++ .../PulsesTest/TestMethodCfgCtrl.resx | 120 ++++++++++++++++++ .../TestMethods/PulsesTest/TestParams.cs | 120 ++++++++++++++++++ .../TestMethods/PulsesTest/WMPulsesForm.cs | 7 +- .../TestMethods/PulsesTest/WMPulsesForm12.cs | 7 +- .../TestMethods/PulsesTest/WMPulsesForm24.cs | 8 +- TBF/Properties/AssemblyInfo.cs | 4 +- TBF/TBF.csproj | 11 ++ TBF/UiBridge/PulsesTestInProgressEventArgs.cs | 6 +- 13 files changed, 480 insertions(+), 22 deletions(-) create mode 100644 TBF/BenchControl/TestMethods/PulsesTest/TestMethodCfg.cs create mode 100644 TBF/BenchControl/TestMethods/PulsesTest/TestMethodCfgCtrl.cs create mode 100644 TBF/BenchControl/TestMethods/PulsesTest/TestMethodCfgCtrl.designer.cs create mode 100644 TBF/BenchControl/TestMethods/PulsesTest/TestMethodCfgCtrl.resx create mode 100644 TBF/BenchControl/TestMethods/PulsesTest/TestParams.cs diff --git a/TBF/BenchControl/TestMethods/PulsesTest/PulsesTestSeq.cs b/TBF/BenchControl/TestMethods/PulsesTest/PulsesTestSeq.cs index 94806f6be..7205706a4 100644 --- a/TBF/BenchControl/TestMethods/PulsesTest/PulsesTestSeq.cs +++ b/TBF/BenchControl/TestMethods/PulsesTest/PulsesTestSeq.cs @@ -17,8 +17,6 @@ namespace TBF.BenchControl.TestMethods.PulsesTest { private static readonly ILog log = LogManager.GetLogger(typeof(PulseOutputsTestSeq)); - const double PulsesLimitLo = 5; - System.Windows.Forms.Form modelessDlg; /// delegate void ErrorsFormDlgt(PulseOutputsTestSeq myRef, IList waterMeters); @@ -55,7 +53,7 @@ namespace TBF.BenchControl.TestMethods.PulsesTest /// Event.OpArgumentError . Target flow is out of range /// Event.Error . . . . . . Unspecified error /// - public IList Execute(Test test, int repetitionNr, bool isLastRepetition, DebugMode mode) + public IList Execute(Test test, int repetitionNr, bool isLastRepetition, TestParams testParams, DebugMode mode) { float simulatedError = 4.5f; /// % @@ -419,7 +417,7 @@ namespace TBF.BenchControl.TestMethods.PulsesTest meterRslt.VolumeRef = meterRslt.PulsesMaster * tstRslt.ConstMaster; /// liter meterRslt.TestTime = cBrd.ImpulseTime(i + 1); meterRslt.Error = 0; - meterRslt.Passed = (meterRslt.PulsesMeter >= PulsesLimitLo); + meterRslt.Passed = (meterRslt.PulsesMeter >= (double)testParams.MinPulsesCount); meterRslt.TestDone = true; tstRslt.TestDone = true; } @@ -455,7 +453,7 @@ namespace TBF.BenchControl.TestMethods.PulsesTest /// Update modeless dialog error information - Bridge.OnPulsesTestInProgress(this, new PulsesTestInProgressEventArgs(testName, PulsesLimitLo)); + Bridge.OnPulsesTestInProgress(this, new PulsesTestInProgressEventArgs(testName, (double)testParams.MinPulsesCount)); /// Test 'Quit' if ((modelessDlg is GenericDevices.IHasCompleted) && !(modelessDlg as GenericDevices.IHasCompleted).Completed) diff --git a/TBF/BenchControl/TestMethods/PulsesTest/TestMethod.cs b/TBF/BenchControl/TestMethods/PulsesTest/TestMethod.cs index adb859867..474d615b3 100644 --- a/TBF/BenchControl/TestMethods/PulsesTest/TestMethod.cs +++ b/TBF/BenchControl/TestMethods/PulsesTest/TestMethod.cs @@ -17,6 +17,8 @@ namespace TBF.BenchControl.TestMethods.PulsesTest public bool CanTest(MetersKind meters) { return meters == MetersKind.Single; } public bool DoTransitions() { return true; } + readonly TestMethodCfg testMethodCfg; + public TestMethod() { } @@ -24,12 +26,13 @@ namespace TBF.BenchControl.TestMethods.PulsesTest public TestMethod(Generic.IComponentCfg cfg) : base(cfg) { - log.Debug(this.ToString()); + testMethodCfg = cfg as TestMethodCfg; + log.Debug(this.ToString()); } public IList Execute(Test test, int repetNr, bool isLastRepetition) { - return (new PulseOutputsTestSeq()).Execute(test, repetNr, isLastRepetition, DebugLevel); + return (new PulseOutputsTestSeq()).Execute(test, repetNr, isLastRepetition, testMethodCfg.TestParams, DebugLevel); } } } diff --git a/TBF/BenchControl/TestMethods/PulsesTest/TestMethodCfg.cs b/TBF/BenchControl/TestMethods/PulsesTest/TestMethodCfg.cs new file mode 100644 index 000000000..e50bb0796 --- /dev/null +++ b/TBF/BenchControl/TestMethods/PulsesTest/TestMethodCfg.cs @@ -0,0 +1,49 @@ +/// +/// 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.PulsesTest +{ + public class TestMethodCfg : ComponentCfgBase, Generic.IComponentCfg + { + public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(TestMethodCfg) })[0]; + public override XmlSerializer GetSerializer() { return Serializer; } + + public IComponentCfgCtrl GetControl() { return new TestMethodCfgCtrl(); } + + /// Test parameters + [XmlIgnore] + public TestParams TestParams; + public override IParamsProvider GetRuntimeTestParamsProvider() { return TestParams; } + public override IParamsProvider CreateTestParamsProvider() { return new TestParams(true); } + public override IParamsProvider GetUITestParamsProvider(Test test) + { + return (test.Method == Name) ? base.GetUITestParamsProvider(test) : null; + } + + /// Private parameterless constructor invoked by all other (public) constructors + TestMethodCfg() + { + TestParams = new TestParams(true); + } + + public TestMethodCfg(string name, IComponentFactory factory) + : this() + { + Name = name; + ParentName = string.Empty; + Factory = factory; + } + + public string ToString(int i) + { + return string.Format("Name={0}", Name); + } + } +} diff --git a/TBF/BenchControl/TestMethods/PulsesTest/TestMethodCfgCtrl.cs b/TBF/BenchControl/TestMethods/PulsesTest/TestMethodCfgCtrl.cs new file mode 100644 index 000000000..c5c300e94 --- /dev/null +++ b/TBF/BenchControl/TestMethods/PulsesTest/TestMethodCfgCtrl.cs @@ -0,0 +1,69 @@ +/// +/// Copyright (c) 2013-2015 Sensus Metering Systems +/// +using System; +using System.Windows.Forms; +using Config.Entities; +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.TestMethods.PulsesTest +{ + public partial class TestMethodCfgCtrl : UserControl, IComponentCfgCtrl + { + 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/TBF/BenchControl/TestMethods/PulsesTest/TestMethodCfgCtrl.designer.cs b/TBF/BenchControl/TestMethods/PulsesTest/TestMethodCfgCtrl.designer.cs new file mode 100644 index 000000000..819f75530 --- /dev/null +++ b/TBF/BenchControl/TestMethods/PulsesTest/TestMethodCfgCtrl.designer.cs @@ -0,0 +1,86 @@ +/// +/// Copyright (c) 2013-2015 Sensus Metering Systems +/// +namespace TBF.BenchControl.TestMethods.PulsesTest +{ + 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/TBF/BenchControl/TestMethods/PulsesTest/TestMethodCfgCtrl.resx b/TBF/BenchControl/TestMethods/PulsesTest/TestMethodCfgCtrl.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/TBF/BenchControl/TestMethods/PulsesTest/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/TBF/BenchControl/TestMethods/PulsesTest/TestParams.cs b/TBF/BenchControl/TestMethods/PulsesTest/TestParams.cs new file mode 100644 index 000000000..e1ae198b8 --- /dev/null +++ b/TBF/BenchControl/TestMethods/PulsesTest/TestParams.cs @@ -0,0 +1,120 @@ +/// +/// 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.PulsesTest +{ + public class TestParams : TestParamsBase, IParamsProvider, ITestParams + { + public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(TestParams) })[0]; + public override XmlSerializer GetSerializer() { return Serializer; } + + public int MinPulsesCount; /// Minimum number of pulses for a test to pass + + public override void InitializeAll() + { + MinPulsesCount = 3; + } + + + string[] paramNames = new string[] + { + "Min. pulses count", + }; + 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 MinPulsesCount.ToString(); + default: return string.Empty; + } + } + + public CfgUpdateFlags UpdateParam(int i, string strValue) + { + switch (i) + { + case 0: MinPulsesCount = int.Parse(strValue); return CfgUpdateFlags.None; + default: return CfgUpdateFlags.None; + } + } + + public bool ValidateParam(int i, string strValue, out string message) + { + message = string.Empty; + + int iDummy; + switch (i) + { + case 0: + if (int.TryParse(strValue, out iDummy) && (iDummy > 0)) return true; + break; + default: + message = "Invalid index"; + return false; + } + + message = ParamName(i) + " is invalid"; + return false; + } + + void CopyContentTo(TestParams prms) + { + prms.MinPulsesCount = this.MinPulsesCount; + } + + public IParamsProvider Clone() + { + TestParams pars = new TestParams(); + CopyContentTo(pars); + return pars; + } + + public override void UpdateFromDbEntity(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/TBF/BenchControl/TestMethods/PulsesTest/WMPulsesForm.cs b/TBF/BenchControl/TestMethods/PulsesTest/WMPulsesForm.cs index e882426f5..bca9b3a01 100644 --- a/TBF/BenchControl/TestMethods/PulsesTest/WMPulsesForm.cs +++ b/TBF/BenchControl/TestMethods/PulsesTest/WMPulsesForm.cs @@ -26,7 +26,7 @@ namespace TBF.BenchControl.TestMethods.PulsesTest /// Updated in OnAdjustmentInProgress() /// double[] pulsesCount; /// Created in constructor - double limitLo; + double minPulsesCount; /// /// Set to 'true' when the form closes @@ -60,6 +60,7 @@ namespace TBF.BenchControl.TestMethods.PulsesTest ControlBox = false; completed = false; + minPulsesCount = 1; /// Must be >0 so that initially the indication is RED /// Attach to 'AdjustmentInProgress' handler UiBridge.Bridge.PulsesTestInProgressHandler += delegate(object sender, UiBridge.PulsesTestInProgressEventArgs args) @@ -120,7 +121,7 @@ namespace TBF.BenchControl.TestMethods.PulsesTest void OnPulsesTestInProgress(object sender, UiBridge.PulsesTestInProgressEventArgs args) { string testName = args.TestName; - limitLo = args.LimitLo; + minPulsesCount = args.MinPulsesCount; Results.Entities.TestRslt tr = TBF.BenchControl.Sequences.ProcessData.BatchRslts.GetTestRslt(testName, 0); @@ -154,7 +155,7 @@ namespace TBF.BenchControl.TestMethods.PulsesTest { if (!disabled[i]) { - PaintOne(graphics, rects[i], pulsesCount[i], limitLo); + PaintOne(graphics, rects[i], pulsesCount[i], minPulsesCount); } } } diff --git a/TBF/BenchControl/TestMethods/PulsesTest/WMPulsesForm12.cs b/TBF/BenchControl/TestMethods/PulsesTest/WMPulsesForm12.cs index ab1513f10..3ef7fb45f 100644 --- a/TBF/BenchControl/TestMethods/PulsesTest/WMPulsesForm12.cs +++ b/TBF/BenchControl/TestMethods/PulsesTest/WMPulsesForm12.cs @@ -31,7 +31,7 @@ namespace TBF.BenchControl.TestMethods.PulsesTest /// Updated in OnAdjustmentInProgress() /// double[] pulsesCount; /// Created in constructor - double limitLo; + double minPulsesCount; /// /// Set to 'true' when the form closes @@ -70,6 +70,7 @@ namespace TBF.BenchControl.TestMethods.PulsesTest } completed = false; + minPulsesCount = 1; /// Must be >0 so that initially the indication is RED /// Attach to 'AdjustmentInProgress' handler UiBridge.Bridge.PulsesTestInProgressHandler += delegate(object sender, UiBridge.PulsesTestInProgressEventArgs args) @@ -161,7 +162,7 @@ namespace TBF.BenchControl.TestMethods.PulsesTest void OnPulsesTestInProgress(object sender, UiBridge.PulsesTestInProgressEventArgs args) { string testName = args.TestName; - limitLo = args.LimitLo; + minPulsesCount = args.MinPulsesCount; Results.Entities.TestRslt tr = TBF.BenchControl.Sequences.ProcessData.BatchRslts.GetTestRslt(testName, 0); @@ -192,7 +193,7 @@ namespace TBF.BenchControl.TestMethods.PulsesTest { if (!disabled[i]) { - PaintOne(graphics, rects[i], pulsesCount[i], limitLo); + PaintOne(graphics, rects[i], pulsesCount[i], minPulsesCount); } } } diff --git a/TBF/BenchControl/TestMethods/PulsesTest/WMPulsesForm24.cs b/TBF/BenchControl/TestMethods/PulsesTest/WMPulsesForm24.cs index fcaa57318..37c31c7f3 100644 --- a/TBF/BenchControl/TestMethods/PulsesTest/WMPulsesForm24.cs +++ b/TBF/BenchControl/TestMethods/PulsesTest/WMPulsesForm24.cs @@ -31,7 +31,7 @@ namespace TBF.BenchControl.TestMethods.PulsesTest /// Updated in OnAdjustmentInProgress() /// double[] pulsesCount; /// Created in constructor - double limitLo; + double minPulsesCount; /// /// Set to 'true' when the form closes @@ -76,7 +76,7 @@ namespace TBF.BenchControl.TestMethods.PulsesTest } completed = false; - limitLo = 5; + minPulsesCount = 1; /// Must be >0 so that initially the indication is RED /// Attach to 'AdjustmentInProgress' handler UiBridge.Bridge.PulsesTestInProgressHandler += delegate(object sender, UiBridge.PulsesTestInProgressEventArgs args) @@ -175,7 +175,7 @@ namespace TBF.BenchControl.TestMethods.PulsesTest void OnPulsesTestInProgress(object sender, UiBridge.PulsesTestInProgressEventArgs args) { string testName = args.TestName; - limitLo = args.LimitLo; + minPulsesCount = args.MinPulsesCount; Results.Entities.TestRslt tr = TBF.BenchControl.Sequences.ProcessData.BatchRslts.GetTestRslt(testName, 0); @@ -206,7 +206,7 @@ namespace TBF.BenchControl.TestMethods.PulsesTest { if (!disabled[i]) { - PaintOne(graphics, rects[i], pulsesCount[i], limitLo); + PaintOne(graphics, rects[i], pulsesCount[i], minPulsesCount); } } } diff --git a/TBF/Properties/AssemblyInfo.cs b/TBF/Properties/AssemblyInfo.cs index fd4d97ffb..e5ac61b1e 100644 --- a/TBF/Properties/AssemblyInfo.cs +++ b/TBF/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("2.18.976.0")] -[assembly: AssemblyFileVersion("2.18.976.0")] +[assembly: AssemblyVersion("2.18.977.0")] +[assembly: AssemblyFileVersion("2.18.977.0")] diff --git a/TBF/TBF.csproj b/TBF/TBF.csproj index 6f563ddef..e2c5b31a7 100644 --- a/TBF/TBF.csproj +++ b/TBF/TBF.csproj @@ -1153,9 +1153,17 @@ + + + + UserControl + + + TestMethodCfgCtrl.cs + Form @@ -2465,6 +2473,9 @@ CfgCtrl.cs + + TestMethodCfgCtrl.cs + WMPulsesForm.cs diff --git a/TBF/UiBridge/PulsesTestInProgressEventArgs.cs b/TBF/UiBridge/PulsesTestInProgressEventArgs.cs index 9a48b0510..51cbfa8f7 100644 --- a/TBF/UiBridge/PulsesTestInProgressEventArgs.cs +++ b/TBF/UiBridge/PulsesTestInProgressEventArgs.cs @@ -9,12 +9,12 @@ namespace TBF.UiBridge public class PulsesTestInProgressEventArgs : EventArgs { public string TestName; - public double LimitLo; + public double MinPulsesCount; - public PulsesTestInProgressEventArgs(string testName, double limitLo) + public PulsesTestInProgressEventArgs(string testName, double minPulsesCount) { this.TestName = testName; - this.LimitLo = limitLo; + this.MinPulsesCount = minPulsesCount; } } }