FlowMeterTriplet (for RumMob) added, ver. 2.17.770

This commit is contained in:
Milan Hanajik 2017-12-18 13:35:29 +01:00
parent 3e1013fc12
commit 7859ce582a
10 changed files with 587 additions and 3 deletions

View File

@ -18,7 +18,7 @@ namespace TBF.BenchControl.Elde.FlowMeter
public int Idx1 { get { return flowMeterCfg.Idx1; } }
public float NominalFlow { get { return flowMeterCfg.NominalFlow; } }
public float LtrPerPulse { get { return flowMeterCfg.NominalFlow / 7200.0f; } }
public float LtrPerPulse { get { return flowMeterCfg.NominalFlow / 7200.0f; } } /// Nominal frequency is 2000 Hz
public float LtrPerPulseCorrected(double flow)
{

View File

@ -0,0 +1,75 @@
///
/// Copyright (c) 2017 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using TBF.Boxes;
namespace TBF.BenchControl.Elde.FlowMeterTriplet
{
public class FlowMeter : ComponentBase, GenericDevices.IFlowMeter
{
private static readonly ILog log = LogManager.GetLogger(typeof(FlowMeter));
public override string ToString() { return string.Format("FlowMeter({0})", Cfg.ToString(1)); }
readonly FlowMeterCfg flowMeterCfg;
readonly ControlBoardDev controlBoard;
public int Idx1 { get { return flowMeterCfg.Idx1; } }
public float NominalFlow { get { return flowMeterCfg.NominalFlow; } }
public float LtrPerPulse { get { return flowMeterCfg.NominalFlow / 21600.0f; } } /// Nominal frequency is 6000 Hz
public float LtrPerPulseCorrected(double flow)
{
if (flow < 0.1 * NominalFlow) return LtrPerPulse; /// No correction for small flow
/// Apply correction
double correctedFlow = BenchControl.Formulas.CorrectedValue(flow, Corrections);
return (float)(LtrPerPulse * correctedFlow / flow);
}
public FlowMeter()
{
}
public FlowMeter(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
: base(cfg)
{
flowMeterCfg = cfg as FlowMeterCfg;
controlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components);
if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent");
/// Prepare data for SendCalibData() control board component method
if (Idx1 >= controlBoard.EtCalib.Length) throw new Exception("Flowmeter " + Name + " parameter 'Idx1' is out of range");
controlBoard.EtCalib[Idx1] = flowMeterCfg.NominalFlow;
log.Debug(this.ToString());
}
public double ReadFlow() { return controlBoard.ReferenceFlow; }
public double ReadFrequency() { return controlBoard.ReferenceFreq; }
/// <summary>
/// Events: FlowDone, Error
/// </summary>
/// <param name="flow">Reference to a variable for the flow in Bar</param>
/// <returns>ReadFlowOp instance reference casted to IOperaton</returns>
public IOperation ReadFlowOp(ref DoubleBox flow)
{
return new ReadFlowOp(this, controlBoard, ref flow);
}
/// <summary>
/// Events: flowDone, Error
/// </summary>
/// <param name="flow">Reference to a variable for the flow in Bar</param>
/// <param name="flowDone">Event returned when measurement done</param>
/// <returns>ReadFlowOp instance reference casted to IOperaton</returns>
public IOperation ReadFlowOp(ref DoubleBox flow, Event flowDone)
{
return new ReadFlowOp(this, controlBoard, ref flow, flowDone);
}
}
}

View File

@ -0,0 +1,70 @@
///
/// Copyright (c) 2017 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.Elde.FlowMeterTriplet
{
public class FlowMeterCfg : ComponentCfgBase, GenericDevices.ICalibInfoCfg, IChildComponentCfg
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(FlowMeterCfg) })[0];
protected override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl() { return new FlowMeterCfgCtrl(); }
///
/// Serialized parameters
///
public int Idx1; /// 1..7
public float NominalFlow; /// Nominal flow in m3/h at output frequency 6000 Hz (= 3 * 2000 Hz)
/// Calibration info serialized parameters displayed in Metrology tab page
string calibCertificateNr;
DateTime calibDate;
DateTime calibValidDate;
public string CalibCertificateNr
{
get { return calibCertificateNr; }
set { calibCertificateNr = value; }
}
public DateTime CalibDate
{
get { return calibDate; }
set { calibDate = value; }
}
public DateTime CalibValidDate
{
get { return calibValidDate; }
set { calibValidDate = value; }
}
/// Private parameterless constructor invoked by all other (public) constructors
FlowMeterCfg()
{
Name = "FlowMeter";
ParentName = "CB";
Idx1 = 1;
NominalFlow = 1;
}
public FlowMeterCfg(IComponentFactory factory)
: this()
{
this.Factory = factory;
}
public string ToString(int i)
{
return string.Format("Name={0}, Parent={1}, Idx1={2}, NominalFlow={3}",
Name,
(string.IsNullOrEmpty(ParentName) ? "-" : ParentName),
Idx1,
NominalFlow);
}
}
}

View File

@ -0,0 +1,156 @@
///
/// Copyright (c) 2017 Sensus Slovensko a.s.
///
namespace TBF.BenchControl.Elde.FlowMeterTriplet
{
partial class FlowMeterCfgCtrl
{
/// <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.positionTextBox = new System.Windows.Forms.TextBox();
this.positionLabel = new System.Windows.Forms.Label();
this.parentNameLabel = new System.Windows.Forms.Label();
this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label();
this.nominalFlowTextBox = new System.Windows.Forms.TextBox();
this.nominalFlowLabel = new System.Windows.Forms.Label();
this.parentNameComboBox = new System.Windows.Forms.ComboBox();
this.SuspendLayout();
//
// positionTextBox
//
this.positionTextBox.Enabled = false;
this.positionTextBox.Location = new System.Drawing.Point(224, 113);
this.positionTextBox.Name = "positionTextBox";
this.positionTextBox.Size = new System.Drawing.Size(46, 20);
this.positionTextBox.TabIndex = 6;
//
// positionLabel
//
this.positionLabel.AutoSize = true;
this.positionLabel.Location = new System.Drawing.Point(30, 116);
this.positionLabel.Name = "positionLabel";
this.positionLabel.Size = new System.Drawing.Size(44, 13);
this.positionLabel.TabIndex = 5;
this.positionLabel.Text = "Position";
//
// parentNameLabel
//
this.parentNameLabel.AutoSize = true;
this.parentNameLabel.Location = new System.Drawing.Point(30, 90);
this.parentNameLabel.Name = "parentNameLabel";
this.parentNameLabel.Size = new System.Drawing.Size(69, 13);
this.parentNameLabel.TabIndex = 3;
this.parentNameLabel.Text = "Parent Name";
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(140, 61);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(130, 20);
this.nameTextBox.TabIndex = 2;
//
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(30, 64);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 1;
this.nameLabel.Text = "Name";
//
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(137, 37);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 0;
this.classNameLabel.Text = "ComonentName";
//
// nominalFlowTextBox
//
this.nominalFlowTextBox.Enabled = false;
this.nominalFlowTextBox.Location = new System.Drawing.Point(224, 138);
this.nominalFlowTextBox.Name = "nominalFlowTextBox";
this.nominalFlowTextBox.Size = new System.Drawing.Size(46, 20);
this.nominalFlowTextBox.TabIndex = 8;
//
// nominalFlowLabel
//
this.nominalFlowLabel.AutoSize = true;
this.nominalFlowLabel.Location = new System.Drawing.Point(30, 141);
this.nominalFlowLabel.Name = "nominalFlowLabel";
this.nominalFlowLabel.Size = new System.Drawing.Size(174, 13);
this.nominalFlowLabel.TabIndex = 7;
this.nominalFlowLabel.Text = "Nominal flow (=sum) [m3/h @6kHz]";
//
// parentNameComboBox
//
this.parentNameComboBox.Enabled = false;
this.parentNameComboBox.FormattingEnabled = true;
this.parentNameComboBox.Location = new System.Drawing.Point(140, 87);
this.parentNameComboBox.Name = "parentNameComboBox";
this.parentNameComboBox.Size = new System.Drawing.Size(130, 21);
this.parentNameComboBox.TabIndex = 4;
//
// FlowMeterCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.parentNameComboBox);
this.Controls.Add(this.nominalFlowTextBox);
this.Controls.Add(this.nominalFlowLabel);
this.Controls.Add(this.positionTextBox);
this.Controls.Add(this.positionLabel);
this.Controls.Add(this.parentNameLabel);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "FlowMeterCfgCtrl";
this.Size = new System.Drawing.Size(300, 200);
this.Load += new System.EventHandler(this.FlowMeterCfgCtrl_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox positionTextBox;
private System.Windows.Forms.Label positionLabel;
private System.Windows.Forms.Label parentNameLabel;
private System.Windows.Forms.TextBox nameTextBox;
private System.Windows.Forms.Label nameLabel;
private System.Windows.Forms.Label classNameLabel;
private System.Windows.Forms.TextBox nominalFlowTextBox;
private System.Windows.Forms.Label nominalFlowLabel;
private System.Windows.Forms.ComboBox parentNameComboBox;
}
}

View File

@ -0,0 +1,124 @@
///
/// Copyright (c) 2017 Sensus Slovensko a.s.
///
using System;
using System.Globalization;
using System.Windows.Forms;
using log4net;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.Elde.FlowMeterTriplet
{
public partial class FlowMeterCfgCtrl : UserControl, IComponentCfgCtrl
{
static readonly ILog log = LogManager.GetLogger(typeof(FlowMeterCfgCtrl));
ComponentParametersDlg parent;
public bool ShowMore { get { return false; } }
FlowMeterCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as FlowMeterCfg;
Redraw();
}
}
public FlowMeterCfgCtrl()
{
InitializeComponent();
}
private void FlowMeterCfgCtrl_Load(object sender, EventArgs e)
{
parent = ParentForm as ComponentParametersDlg;
if (parent == null) return;
if (parent.TbfComponents != null)
{
foreach (var cmpnt in parent.TbfComponents)
{
if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Elde.ControlBoardFactory)
{
parentNameComboBox.Items.Add(cmpnt.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;
parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName;
positionTextBox.Text = config.Idx1.ToString();
nominalFlowTextBox.Text = config.NominalFlow.ToString();
}
public void Unlock()
{
nameTextBox.Enabled = true;
parentNameComboBox.Enabled = true;
positionTextBox.Enabled = true;
nominalFlowTextBox.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
int dummy;
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Parent Name'";
}
#if MALTA_WSD25
if (!int.TryParse(positionTextBox.Text, out dummy) || dummy < 0 || dummy > 8)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Idx1' should be between 0 and 8";
}
#else
if (!int.TryParse(positionTextBox.Text, out dummy) || dummy < 1 || dummy > 7)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Idx1' should be between 1 and 7";
}
#endif
float fdummy;
if (!Utils.TryParseUFloat(nominalFlowTextBox.Text, out fdummy) || fdummy < 0.01 || fdummy > 1600)
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Nominal flow' should be between 0.01 and 1600";
}
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;
config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
config.Idx1 = int.Parse(positionTextBox.Text);
Utils.TryParseUFloat(nominalFlowTextBox.Text, out config.NominalFlow);
return flags;
}
}
}

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,26 @@
///
/// Copyright (c) 2017 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.Elde.FlowMeterTriplet
{
public class FlowMeterFactory : IComponentFactory
{
public string ClassName { get { return "FlowMeterTriplet"; } }
public void ResetStaticProperties() { FlowMeter.ResetStaticProperties(); }
public IComponent DummyComponent() { return new FlowMeter(); }
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new FlowMeter(cfg, components); }
public IComponentCfg DefaultConfig() { return new FlowMeterCfg(this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(FlowMeterCfg.Serializer, component, this);
}
}
}

View File

@ -42,6 +42,7 @@ namespace TBF.BenchControl
Factories.Add(new Elde.Diverter.DiverterFactory());
Factories.Add(new Elde.FlowMeter.FlowMeterFactory());
Factories.Add(new Elde.FlowMeterTwins.FlowMeterFactory());
Factories.Add(new Elde.FlowMeterTriplet.FlowMeterFactory());
Factories.Add(new TestMethods.Adjustment.Factory());
Factories.Add(new TestMethods.CombinedWithDetection.TestMethodFactory());
Factories.Add(new TestMethods.Endurance.Factory());

View File

@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("2.17.769.0")]
[assembly: AssemblyFileVersion("2.17.769.0")]
[assembly: AssemblyVersion("2.17.770.0")]
[assembly: AssemblyFileVersion("2.17.770.0")]

View File

@ -466,6 +466,15 @@
<Compile Include="BenchControl\Elde\CoverTest\Factory.cs" />
<Compile Include="BenchControl\Elde\Diverter\Handlers.cs" />
<Compile Include="BenchControl\Elde\Diverter\SwitchDiverterOp.cs" />
<Compile Include="BenchControl\Elde\FlowMeterTriplet\FlowMeter.cs" />
<Compile Include="BenchControl\Elde\FlowMeterTriplet\FlowMeterCfg.cs" />
<Compile Include="BenchControl\Elde\FlowMeterTriplet\FlowMeterCfgCtrl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="BenchControl\Elde\FlowMeterTriplet\FlowMeterCfgCtrl.designer.cs">
<DependentUpon>FlowMeterCfgCtrl.cs</DependentUpon>
</Compile>
<Compile Include="BenchControl\Elde\FlowMeterTriplet\FlowMeterFactory.cs" />
<Compile Include="BenchControl\Elde\PressureMeterInternal\PressureMeter.cs" />
<Compile Include="BenchControl\Elde\PressureMeterInternal\PressureMeterCfg.cs" />
<Compile Include="BenchControl\Elde\PressureMeterInternal\PressureMeterCfgCtrl.cs">
@ -2108,6 +2117,9 @@
<EmbeddedResource Include="BenchControl\Elde\FixedStartRegisterReader\RegisterReaderCfgCtrl.resx">
<DependentUpon>RegisterReaderCfgCtrl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="BenchControl\Elde\FlowMeterTriplet\FlowMeterCfgCtrl.resx">
<DependentUpon>FlowMeterCfgCtrl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="BenchControl\Elde\FlowMeterTwins\FlowMeterCfgCtrl.resx">
<DependentUpon>FlowMeterCfgCtrl.cs</DependentUpon>
</EmbeddedResource>