WaterMeters.Munich with the smallest nr. of process parameters added.

This commit is contained in:
Milan Hanajik 2016-05-20 00:10:16 +02:00
parent ec82370934
commit 775d3c67a4
10 changed files with 671 additions and 3 deletions

View File

@ -79,9 +79,11 @@ namespace Config.Entities
public enum Medium
{
[Description("")] NotSpecified,
ColdWater,
HotWater,
}
Count
}
public enum Mounting
{

View File

@ -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
}
/// <summary>

View File

@ -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
{
}
}
/// <summary>
/// Parameterless constructor initializes the parameters
/// </summary>
public ProcParams()
{
}
public ProcParams(ComponentProcedure procParamsEntity, string componentName, Procedure procedure)
{
this.procedureParamsEntity = procParamsEntity;
this.componentName = componentName;
this.procedure = procedure;
}
}
}

View File

@ -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
{
/// <summary>
/// This component = instance of this class is a placeholder for a combined main watermeter
/// </summary>
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;
/// <summary>WaterMeter type (product name) and producer</summary>
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; } }
/// <summary>Pipe diameter [mm]</summary>
public float DN { get { return 0; } }
/// <summary>Build lenght [mm]</summary>
public float L { get { return 0; } }
public Mounting Mounting { get { return Config.Entities.Mounting.NotSpecified; } }
/// <summary>Nominal water flow in [m3/h]</summary>
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; } }
/// <summary>Metrological class, etc</summary>
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; } }
/// <summary>WaterMeter approval information or signature</summary>
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; } }
/// <summary>Water: cold / hot</summary>
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;
}
}
}

View File

@ -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<IComponent> components) { return new WaterMeter(this); }
public IComponentCfgCtrl GetControl() { return new WaterMeterCfgCtrl(); }
/// <summary> Procedure parameters </summary>
[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);
}
}
}

View File

@ -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;
}
}
}

View File

@ -0,0 +1,86 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
namespace TBF.BenchControl.WaterMeters.Munich
{
partial class WaterMeterCfgCtrl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -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);
}
}
}

View File

@ -530,6 +530,16 @@
<DependentUpon>WaterMeterCfgCtrl.cs</DependentUpon>
</Compile>
<Compile Include="BenchControl\WaterMeters\iPerl\WaterMeterFactory.cs" />
<Compile Include="BenchControl\WaterMeters\Munich\ProcParams.cs" />
<Compile Include="BenchControl\WaterMeters\Munich\WaterMeter.cs" />
<Compile Include="BenchControl\WaterMeters\Munich\WaterMeterCfg.cs" />
<Compile Include="BenchControl\WaterMeters\Munich\WaterMeterCfgCtrl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="BenchControl\WaterMeters\Munich\WaterMeterCfgCtrl.designer.cs">
<DependentUpon>WaterMeterCfgCtrl.cs</DependentUpon>
</Compile>
<Compile Include="BenchControl\WaterMeters\Munich\WaterMeterFactory.cs" />
<Compile Include="BenchControl\WaterMeters\WaterMeter\ProcParams.cs" />
<Compile Include="BenchControl\WaterMeters\WaterMeter\WaterMeter.cs" />
<Compile Include="BenchControl\WaterMeters\WaterMeter\WaterMeterCfg.cs" />
@ -1712,6 +1722,9 @@
<EmbeddedResource Include="BenchControl\WaterMeters\iPerl\WaterMeterCfgCtrl.resx">
<DependentUpon>WaterMeterCfgCtrl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="BenchControl\WaterMeters\Munich\WaterMeterCfgCtrl.resx">
<DependentUpon>WaterMeterCfgCtrl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="BenchControl\WaterMeters\WaterMeter\WaterMeterCfgCtrl.resx">
<DependentUpon>WaterMeterCfgCtrl.cs</DependentUpon>
</EmbeddedResource>