diff --git a/Config/Entities/Enums.cs b/Config/Entities/Enums.cs index 530c4daef..89777c67d 100644 --- a/Config/Entities/Enums.cs +++ b/Config/Entities/Enums.cs @@ -79,9 +79,11 @@ namespace Config.Entities public enum Medium { + [Description("")] NotSpecified, ColdWater, HotWater, - } + Count + } public enum Mounting { diff --git a/TestBenchFramework/BenchControl/TbfComponents.cs b/TestBenchFramework/BenchControl/TbfComponents.cs index 4d1e097b0..c97134e0d 100644 --- a/TestBenchFramework/BenchControl/TbfComponents.cs +++ b/TestBenchFramework/BenchControl/TbfComponents.cs @@ -78,8 +78,9 @@ namespace TBF.BenchControl Factories.Add(new Elde.TempMeterInternal.TempMeterFactory()); Factories.Add(new Elde.Valve.ValveFactory()); Factories.Add(new Elde.ValveEx.ValveFactory()); - Factories.Add(new WaterMeters.WaterMeter.WaterMeterFactory()); /// WaterMeter - Factories.Add(new ResultsPrinters.Zapiska.PrinterFactory()); /// Zapiska + Factories.Add(new WaterMeters.Munich.WaterMeterFactory()); /// WaterMeter + Factories.Add(new WaterMeters.WaterMeter.WaterMeterFactory()); /// WaterMeter + Factories.Add(new ResultsPrinters.Zapiska.PrinterFactory()); /// Zapiska } /// diff --git a/TestBenchFramework/BenchControl/WaterMeters/Munich/ProcParams.cs b/TestBenchFramework/BenchControl/WaterMeters/Munich/ProcParams.cs new file mode 100644 index 000000000..811076e3b --- /dev/null +++ b/TestBenchFramework/BenchControl/WaterMeters/Munich/ProcParams.cs @@ -0,0 +1,189 @@ +/// +/// Copyright (c) 2016 Sensus Metering Systems +/// +using System; +using System.IO; +using System.Text; +using System.Xml.Serialization; +using Config.Entities; +using TBF.BenchControl.Generic; +using TBF.Resources; + +namespace TBF.BenchControl.WaterMeters.Munich +{ + public class ProcParams : ProcedureParamsBase, IParamsProvider, IProcedureParams + { + public string ProductName; /// Znak fabryczny (PL) + public string Producer; /// Producent (PL), Hersteller (D) + public float DN; + + public float L; /// stavebná dĺžka [mm] + public Mounting Mounting; + public float Qn; /// [m3/h] + + public string MetrologicalClass; /// Metr. Klasse + public string ApprovalInfo; /// Zulassungszeichen, WE (PL) + public float PulsesPerLtr; /// Target low limit of the flow increase or decrease + + + public override void InitializeAll() + { + ProductName = string.Empty; + Producer = string.Empty; + DN = 0; + + L = 0; + Mounting = Mounting.NotSpecified; + Qn = 2.5f; + + MetrologicalClass = "A"; + ApprovalInfo = string.Empty; + PulsesPerLtr = 1.0f; + } + + string[] paramNames = new string[] + { + Strings.Product_name, + Strings.Producer, + "DN", + + Strings.L, + Strings.Mounting, + Strings.Qn, + + Strings.Metrological_class, + Strings.Approval_info, + Strings.PulsesPerLtr, + }; + 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 ProductName; + case 1: return Producer; + case 2: return DN.ToString(); + + case 3: return L.ToString(); + case 4: return Mounting.ToDescription(); + case 5: return Qn.ToString(); + + case 6: return MetrologicalClass; + case 7: return ApprovalInfo; + case 8: return PulsesPerLtr.ToString(); + + default: return string.Empty; + } + } + + public void UpdateParam(int i, string strValue) + { + switch (i) + { + case 0: ProductName = strValue; return; + case 1: Producer = strValue; return; + case 2: DN = Utils.ParseUFloat(strValue); return; + + case 3: L = Utils.ParseUFloat(strValue); return; + case 4: + for (Mounting m = 0; m < Mounting.Count; m++) + { + if (m.ToDescription().Equals(strValue)) { Mounting = m; return; } + } + break; + case 5: Qn = Utils.ParseUFloat(strValue); return; + + case 6: MetrologicalClass = strValue; return; + case 7: ApprovalInfo = strValue; return; + case 8: PulsesPerLtr = Utils.ParseUFloat(strValue); return; + + default: return; + } + } + + public bool ValidateParam(int i, string strValue, out string message) + { + message = string.Empty; + + float dummy; + switch (i) + { + case 0: /// ProductName + case 1: /// Producer + case 6: /// MetrologicalClass + case 7: /// ApprovalInfo + return true; + case 2: /// DN + case 3: /// L + case 5: /// Qn + case 8: /// PulsesPerLtr + if (Utils.TryParseUFloat(strValue, out dummy)) return true; + break; + case 4: + for (Mounting tc = 0; tc < Mounting.Count; tc++) if (tc.ToDescription().Equals(strValue)) return true; + break; + default: + message = "Invalid index"; + return false; + } + + message = ParamName(i) + " is invalid"; + return false; + } + + void CopyContentTo(ProcParams prms) + { + prms.ProductName = this.ProductName; + prms.Producer = this.Producer; + prms.DN = this.DN; + prms.L = this.L; + prms.Mounting = this.Mounting; + prms.Qn = this.Qn; + prms.MetrologicalClass = this.MetrologicalClass; + prms.ApprovalInfo = this.ApprovalInfo; + prms.PulsesPerLtr = this.PulsesPerLtr; + } + + public IParamsProvider Clone() + { + ProcParams pars = new ProcParams(); + CopyContentTo(pars); + return pars; + } + + public override void UpdateProcedureParams(ComponentProcedure dbEntity) + { + if (dbEntity == null) return; + try + { + ProcParams tmp = (ProcParams)(new XmlSerializer(typeof(ProcParams))) + .Deserialize(new StringReader(dbEntity.Parameters)); + + procedureParamsEntity = dbEntity; + componentName = dbEntity.CmpntName; + procedure = dbEntity.Procedure; + + tmp.CopyContentTo(this); + } + catch + { + } + } + + /// + /// Parameterless constructor initializes the parameters + /// + public ProcParams() + { + } + + public ProcParams(ComponentProcedure procParamsEntity, string componentName, Procedure procedure) + { + this.procedureParamsEntity = procParamsEntity; + this.componentName = componentName; + this.procedure = procedure; + } + } +} diff --git a/TestBenchFramework/BenchControl/WaterMeters/Munich/WaterMeter.cs b/TestBenchFramework/BenchControl/WaterMeters/Munich/WaterMeter.cs new file mode 100644 index 000000000..62ee3b429 --- /dev/null +++ b/TestBenchFramework/BenchControl/WaterMeters/Munich/WaterMeter.cs @@ -0,0 +1,112 @@ +/// +/// Copyright (c) 2016 Sensus Metering Systems +/// +using System; +using System.Collections.Generic; +using log4net; +using TBF.BenchControl; +using Config.Entities; + +namespace TBF.BenchControl.WaterMeters.Munich +{ + /// + /// This component = instance of this class is a placeholder for a combined main watermeter + /// + public class WaterMeter : ComponentBase, GenericDevices.IWaterMeter + { + private static readonly ILog log = LogManager.GetLogger(typeof(WaterMeter)); + public override string ToString() { return string.Format("WaterMeter({0})", Cfg.ToString(1)); } + + readonly WaterMeterCfg waterMeterCfg; + + /// WaterMeter type (product name) and producer + public string ProductName { get { return waterMeterCfg.ProcParams.ProductName; } } + public string Producer { get { return waterMeterCfg.ProcParams.Producer; } } + + public double PulsesPerLtr { get { return (double)waterMeterCfg.ProcParams.PulsesPerLtr; } } + + /// Pipe diameter [mm] + public float DN { get { return 0; } } + + /// Build lenght [mm] + public float L { get { return 0; } } + + public Mounting Mounting { get { return Config.Entities.Mounting.NotSpecified; } } + + /// Nominal water flow in [m3/h] + public float Q4_Qmax { get { return 0; } } + public float Q3_Qn { get { return waterMeterCfg. ProcParams.Qn; } } + public float Q2_Qt { get { return 0; } } + public float Q1_Qmin { get { return 0; } } + + /// Metrological class, etc + public string MetrologicalClass { get { return waterMeterCfg.ProcParams.MetrologicalClass; } } + public TemperatureClass TemperatureClass { get { return Config.Entities.TemperatureClass.NotSpecified; } } + public PressureLossClass PressureLossClass { get { return Config.Entities.PressureLossClass.NotSpecified; } } + public MaxAdmissiblePressure MaxAdmissiblePressure { get { return Config.Entities.MaxAdmissiblePressure.NotSpecified; } } + public FlowProfileSensitivityClass FlowProfileSensitivityClass { get { return Config.Entities.FlowProfileSensitivityClass.NotSpecified; } } + + /// WaterMeter approval information or signature + public string ApprovalInfo { get { return waterMeterCfg.ProcParams.ApprovalInfo; } } + public string Certificate { get { return string.Empty; } } + + public string Text1 { get { return string.Empty; } } + public string Text2 { get { return string.Empty; } } + public string Text3 { get { return string.Empty; } } + public string Text4 { get { return string.Empty; } } + public string Text5 { get { return string.Empty; } } + + /// Water: cold / hot + public Config.Entities.Medium WaterTemp { get { return Config.Entities.Medium.NotSpecified; } } + + /// Properties set by the Begin and the End form + public string SerialNr + { + get { return serialNr; } + set { serialNr = value; } + } + string serialNr; + + public string EndState + { + get { return endState; } + set { endState = value; } + } + string endState; + + public string BeginState + { + get { return beginState; } + set { beginState = value; } + } + string beginState; + + public bool Disabled + { + get { return disabled; } + set { disabled = value; } + } + bool disabled; + + public WaterMeter() + { + ClearData(); + } + + public WaterMeter(WaterMeterCfg cfg) + : base(cfg) + { + ClearData(); + waterMeterCfg = cfg; + log.Debug(this.ToString()); + } + + public void ClearData() + { + serialNr = string.Empty; + endState = string.Empty; + beginState = string.Empty; + disabled = false; + } + } +} diff --git a/TestBenchFramework/BenchControl/WaterMeters/Munich/WaterMeterCfg.cs b/TestBenchFramework/BenchControl/WaterMeters/Munich/WaterMeterCfg.cs new file mode 100644 index 000000000..d423548b8 --- /dev/null +++ b/TestBenchFramework/BenchControl/WaterMeters/Munich/WaterMeterCfg.cs @@ -0,0 +1,49 @@ +/// +/// Copyright (c) 2016 Sensus Metering Systems +/// +using System; +using System.Collections.Generic; +using System.IO; +using System.Xml.Serialization; +using Config.Entities; +using TBF.BenchControl.Generic; +using TBF.Resources; + +namespace TBF.BenchControl.WaterMeters.Munich +{ + public class WaterMeterCfg : ComponentCfgBase, Generic.IComponentCfg + { + public IComponent GetComponent(IList components) { return new WaterMeter(this); } + public IComponentCfgCtrl GetControl() { return new WaterMeterCfgCtrl(); } + + /// Procedure parameters + [XmlIgnore] + public ProcParams ProcParams; + public override IParamsProvider GetProcedureParams() { return ProcParams; } + public override IParamsProvider CreateProcedureParams(Procedure procedure) + { + ProcParams procParams = new ProcParams(); + procParams.UpdateProcedureParams(Name, procedure); + return procParams; + } + + /// Private parameterless constructor invoked by all other (public) constructors + WaterMeterCfg() + { + Name = "WM"; + ParentName = string.Empty; + ProcParams = new ProcParams(); + } + + public WaterMeterCfg(IComponentFactory factory) + : this() + { + this.Factory = factory; + } + + public string ToString(int i) + { + return string.Format("Name={0}", Name); + } + } +} diff --git a/TestBenchFramework/BenchControl/WaterMeters/Munich/WaterMeterCfgCtrl.cs b/TestBenchFramework/BenchControl/WaterMeters/Munich/WaterMeterCfgCtrl.cs new file mode 100644 index 000000000..f81069f2a --- /dev/null +++ b/TestBenchFramework/BenchControl/WaterMeters/Munich/WaterMeterCfgCtrl.cs @@ -0,0 +1,73 @@ +/// +/// Copyright (c) 2016 Sensus Metering Systems +/// +using System; +using System.Windows.Forms; +using log4net; +using TBF.BenchControl.Generic; +using TBF.Resources; + +namespace TBF.BenchControl.WaterMeters.Munich +{ + public partial class WaterMeterCfgCtrl : UserControl, IComponentCfgCtrl + { + static readonly ILog log = LogManager.GetLogger(typeof(WaterMeterCfgCtrl)); + + public bool ShowMore { get { return false; } } + + WaterMeterCfg config; + public IComponentCfg Config + { + get { return config as IComponentCfg; } + set + { + config = value as WaterMeterCfg; + Redraw(); + } + } + + public WaterMeterCfgCtrl() + { + InitializeComponent(); + } + + private void WaterMeterCfgCtrl_Load(object sender, EventArgs e) + { + nameLabel.Text = Strings.Name; + 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/WaterMeters/Munich/WaterMeterCfgCtrl.designer.cs b/TestBenchFramework/BenchControl/WaterMeters/Munich/WaterMeterCfgCtrl.designer.cs new file mode 100644 index 000000000..9b9992737 --- /dev/null +++ b/TestBenchFramework/BenchControl/WaterMeters/Munich/WaterMeterCfgCtrl.designer.cs @@ -0,0 +1,86 @@ +/// +/// Copyright (c) 2013-2015 Sensus Metering Systems +/// +namespace TBF.BenchControl.WaterMeters.Munich +{ + partial class WaterMeterCfgCtrl + { + /// + /// 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(135, 55); + 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(25, 58); + 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(132, 31); + this.classNameLabel.Name = "classNameLabel"; + this.classNameLabel.Size = new System.Drawing.Size(60, 13); + this.classNameLabel.TabIndex = 3; + this.classNameLabel.Text = "ClassName"; + // + // WaterMeterCfgCtrl + // + 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 = "WaterMeterCfgCtrl"; + this.Size = new System.Drawing.Size(300, 200); + this.Load += new System.EventHandler(this.WaterMeterCfgCtrl_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/WaterMeters/Munich/WaterMeterCfgCtrl.resx b/TestBenchFramework/BenchControl/WaterMeters/Munich/WaterMeterCfgCtrl.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/TestBenchFramework/BenchControl/WaterMeters/Munich/WaterMeterCfgCtrl.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/WaterMeters/Munich/WaterMeterFactory.cs b/TestBenchFramework/BenchControl/WaterMeters/Munich/WaterMeterFactory.cs new file mode 100644 index 000000000..b913f555f --- /dev/null +++ b/TestBenchFramework/BenchControl/WaterMeters/Munich/WaterMeterFactory.cs @@ -0,0 +1,23 @@ +/// +/// Copyright (c) 2016 Sensus Metering Systems +/// +using TBF.BenchControl.Generic; + +namespace TBF.BenchControl.WaterMeters.Munich +{ + public class WaterMeterFactory : IComponentFactory + { + public string ClassName { get { return this.GetType().Namespace.Substring(17); } } + + public void ResetStaticProperties() { WaterMeter.ResetStaticProperties(); } + + public IComponent DummyComponent() { return new WaterMeter(); } + + public IComponentCfg DefaultConfig() { return new WaterMeterCfg(this); } + + public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component) + { + return ComponentCfgBase.CreateFromDbEntity(typeof(WaterMeterCfg), component, this); + } + } +} diff --git a/TestBenchFramework/TBF.csproj b/TestBenchFramework/TBF.csproj index 0c796c39c..ece856c4d 100644 --- a/TestBenchFramework/TBF.csproj +++ b/TestBenchFramework/TBF.csproj @@ -530,6 +530,16 @@ WaterMeterCfgCtrl.cs + + + + + UserControl + + + WaterMeterCfgCtrl.cs + + @@ -1712,6 +1722,9 @@ WaterMeterCfgCtrl.cs + + WaterMeterCfgCtrl.cs + WaterMeterCfgCtrl.cs