Config.Data.RealDensity etc., DataContainers.Density and Buoyancy components, related metrology tabs modified/created.

This commit is contained in:
Milan Hanajik 2019-09-18 09:09:00 +02:00
parent 0468b5a1f5
commit 74f8c44783
49 changed files with 782 additions and 511 deletions

View File

@ -110,5 +110,9 @@ namespace Config
/// Database related: This object reference is set after a successful user login
///
public static DatabaseSettings CurrentBench;
}
public static double RealDensity = 0; /// true water density [kg/m3]
public static double AtTemperature = 0; /// measured at temperature [°C]
public static double Buoyancy = 0;
}
}

View File

@ -11,14 +11,23 @@ namespace Config
{
private static readonly ILog log = LogManager.GetLogger(typeof(Formulas));
///
/// Tables to calculate specific enthalpy
///
private static readonly int[] Ii;
private static readonly int[] Ji;
private static readonly double[] ni;
private static readonly double[] Di;
///
/// Wrappers
///
public static double RealDensity() { return Data.RealDensity; }
public static double AtTemperature() { return Data.AtTemperature; }
public static double Buoyancy() { return Data.Buoyancy; }
/// Private tables with coeficients to calculate specific enthalpy
static readonly int[] Ii;
static readonly int[] Ji;
static readonly double[] ni;
/// Private table with coeficients to calculate temperature of a platinum thermometer
static readonly double[] Di;
/// <summary>
/// Constructor
@ -153,9 +162,9 @@ namespace Config
/// </summary>
/// <param name="t">Temperature in [°C]</param>
/// <returns>Density in [kg/m3]</returns>
public static double WaterDensityFromTemp(double t, double realDensity, double atTemperature)
public static double WaterDensityFromTemp(double t)
{
return DistilledWaterDensityFromTemp(t) + DensityCorrection(realDensity, atTemperature);
return DistilledWaterDensityFromTemp(t) + DensityCorrection(RealDensity(), AtTemperature());
}
/// <summary>
@ -163,7 +172,7 @@ namespace Config
/// </summary>
/// <param name="t">Temperature in [°C]</param>
/// <returns>Density in [kg/m3]</returns>
public static double WaterDensityFromTempPress(double temp, double pressure, double realDensity, double atTemperature)
public static double WaterDensityFromTempPress(double temp, double pressure)
{
double x0 = 5.08821E-10;
double x1 = 1.2639418;
@ -173,7 +182,7 @@ namespace Config
double theta = temp / 100.0;
double B = x0 * (((x3 * theta + x2) * theta + x1) * theta + 1) / (1 + x4 * theta);
return WaterDensityFromTemp(temp, realDensity, atTemperature) * (1 + B * Config.Units.ConvertTo(Config.Unit.Pa, pressure));
return WaterDensityFromTemp(temp) * (1 + B * Config.Units.ConvertTo(Config.Unit.Pa, pressure));
}
@ -394,11 +403,5 @@ namespace Config
return (-(R0 * A) + Math.Sqrt(R0 * R0 * A * A - 4 * R0 * B * (R0 - R))) / (2 * R0 * B);
}
public static double Buoyancy()
{
return 1.00103;
}
}
}

View File

@ -44,8 +44,10 @@ namespace Results
}
public static double RealDensity;
public static double AtTemperature;
/// This is to show RealDensity and AtTemperatire in reports.
public static double RealDensity; /// true water density [kg/m3]
public static double AtTemperature; /// measured at temperature [°C]
public static double Buoyancy;
///

View File

@ -1,47 +0,0 @@
///
/// Copyright (c) 2013-2018 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using log4net;
using Config.Entities;
using TBF.BenchControl;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.BenchInfo.Munich
{
/// <summary>
/// Holds information identifying the test bench.
/// </summary>
public class Component : ComponentBase, GenericDevices.IBenchInfo
{
private static readonly ILog log = LogManager.GetLogger(typeof(Component));
public override string ToString() { return string.Format("BenchInfo({0})", Cfg.ToString(1)); }
readonly ComponentCfg benchInfoCfg;
public string TestBenchName { get { return benchInfoCfg.TestBenchName; } }
public int TestBenchId { get { return benchInfoCfg.TestBenchId; } }
public string Address1 { get { return string.Empty; } }
public string Address2 { get { return string.Empty; } }
public string Address3 { get { return string.Empty; } }
public string Address4 { get { return string.Empty; } }
public string Address5 { get { return string.Empty; } }
public RemoteDBUse RemoteDBUse { get { return RemoteDBUse.LocalDBOnly; } }
#if ORACLE_DB
public int MaxTestIndex { get { return 0; } }
#endif
public Component()
{
}
public Component(Generic.IComponentCfg cfg)
: base(cfg)
{
benchInfoCfg = cfg as ComponentCfg;
log.Debug(this.ToString());
}
}
}

View File

@ -1,48 +0,0 @@
///
/// Copyright (c) 2013-2016 Sensus Metering Systems
/// Author: Milan Hanajík
///
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.BenchInfo.Munich
{
/// <summary>
/// Holds information identifying the test bench - serializable configuration.
/// </summary>
public class ComponentCfg : ComponentCfgBase, Generic.IComponentCfg
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(ComponentCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl() { return new ComponentCfgCtrl(); }
///
/// Serialized parameters
///
public string TestBenchName;
public int TestBenchId;
/// Private parameterless constructor invoked by all other (public) constructors
ComponentCfg()
{
Name = "BenchInfo";
ParentName = string.Empty;
TestBenchName = "1";
TestBenchId = 1;
}
public ComponentCfg(IComponentFactory factory)
: this()
{
this.Factory = factory;
}
public string ToString(int i)
{
return string.Format("Name={0}, Bench name={1}, Bench Id={2}", Name, TestBenchName, TestBenchId);
}
}
}

View File

@ -1,88 +0,0 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Author: Milan Hanajík
///
using System;
using System.Windows.Forms;
using Config.Entities;
using TBF.BenchControl.Generic;
using TBF.Resources;
namespace TBF.BenchControl.BenchInfo.Munich
{
public partial class ComponentCfgCtrl : UserControl, IComponentCfgCtrl
{
public bool ShowMore { get { return false; } }
ComponentCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as ComponentCfg;
Redraw();
}
}
public ComponentCfgCtrl()
{
InitializeComponent();
}
private void EntryFormCfgCtrl_Load(object sender, EventArgs e)
{
nameLabel.Text = Strings.Name;
benchNameLabel.Text = Strings.Test_bench_name;
benchIdLabel.Text = Strings.Test_bench_number;
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;
benchNameTextBox.Text = config.TestBenchName;
benchIdTextBox.Text = config.TestBenchId.ToString();
}
public void Unlock()
{
nameTextBox.Enabled = true;
benchNameTextBox.Enabled = true;
benchIdTextBox.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
int dummy;
if (!int.TryParse(benchIdTextBox.Text, out dummy) || dummy < 0)
{
flags = CfgUpdateFlags.Error;
message = string.Format("Invalid {0} parameter", Strings.Test_bench_number);
}
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.TestBenchName = benchNameTextBox.Text;
config.TestBenchId = int.Parse(benchIdTextBox.Text);
return flags;
}
}
}

View File

@ -1,132 +0,0 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
namespace TBF.BenchControl.BenchInfo.Munich
{
partial class ComponentCfgCtrl
{
/// <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.benchNameLabel = new System.Windows.Forms.Label();
this.benchNameTextBox = new System.Windows.Forms.TextBox();
this.benchIdTextBox = new System.Windows.Forms.TextBox();
this.benchIdLabel = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(140, 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(137, 31);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(60, 13);
this.classNameLabel.TabIndex = 3;
this.classNameLabel.Text = "ClassName";
//
// benchNameLabel
//
this.benchNameLabel.AutoSize = true;
this.benchNameLabel.Location = new System.Drawing.Point(25, 84);
this.benchNameLabel.Name = "benchNameLabel";
this.benchNameLabel.Size = new System.Drawing.Size(90, 13);
this.benchNameLabel.TabIndex = 6;
this.benchNameLabel.Text = "Test bench name";
//
// benchNameTextBox
//
this.benchNameTextBox.Enabled = false;
this.benchNameTextBox.Location = new System.Drawing.Point(140, 81);
this.benchNameTextBox.Name = "benchNameTextBox";
this.benchNameTextBox.Size = new System.Drawing.Size(67, 20);
this.benchNameTextBox.TabIndex = 7;
//
// benchIdTextBox
//
this.benchIdTextBox.Enabled = false;
this.benchIdTextBox.Location = new System.Drawing.Point(140, 107);
this.benchIdTextBox.Name = "benchIdTextBox";
this.benchIdTextBox.Size = new System.Drawing.Size(67, 20);
this.benchIdTextBox.TabIndex = 9;
//
// benchIdLabel
//
this.benchIdLabel.AutoSize = true;
this.benchIdLabel.Location = new System.Drawing.Point(25, 110);
this.benchIdLabel.Name = "benchIdLabel";
this.benchIdLabel.Size = new System.Drawing.Size(99, 13);
this.benchIdLabel.TabIndex = 8;
this.benchIdLabel.Text = "Test bench number";
//
// ComponentCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.benchIdTextBox);
this.Controls.Add(this.benchIdLabel);
this.Controls.Add(this.benchNameTextBox);
this.Controls.Add(this.benchNameLabel);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "ComponentCfgCtrl";
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;
private System.Windows.Forms.Label benchNameLabel;
private System.Windows.Forms.TextBox benchNameTextBox;
private System.Windows.Forms.TextBox benchIdTextBox;
private System.Windows.Forms.Label benchIdLabel;
}
}

View File

@ -2,18 +2,17 @@
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using Users;
using log4net;
namespace TBF.BenchControl.BackupAndSecurity.Default
namespace TBF.BenchControl.DataContainers.BackupAndSecurityOptions
{
/// <summary>
/// Holds backup and security options.
/// </summary>
public class Component : ComponentBase, GenericDevices.IBackupAndSecurity
public class Component : ComponentBase
{
private static readonly ILog log = LogManager.GetLogger(typeof(Component));
public override string ToString() { return string.Format("BackupAndSecurity.Default({0})", Cfg.ToString(1)); }
public override string ToString() { return string.Format("{0}({1})", this.GetType().Namespace.Substring(32), Cfg.ToString(1)); }
readonly ComponentCfg myCfg;
@ -29,8 +28,8 @@ namespace TBF.BenchControl.BackupAndSecurity.Default
{
myCfg = cfg as ComponentCfg;
GlobalData.MinPasswdLength = myCfg.MinPasswdLength;
GlobalData.PasswdExpirationPeriodDays = myCfg.PasswdExpirationPeriodDays;
Users.GlobalData.MinPasswdLength = myCfg.MinPasswdLength;
Users.GlobalData.PasswdExpirationPeriodDays = myCfg.PasswdExpirationPeriodDays;
log.Debug(this.ToString());
}

View File

@ -7,7 +7,7 @@ using System.Xml.Serialization;
using Config.Entities;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.BackupAndSecurity.Default
namespace TBF.BenchControl.DataContainers.BackupAndSecurityOptions
{
/// <summary>
/// Holds backup and security options - serializable configuration.

View File

@ -4,7 +4,7 @@
using System.Collections.Generic;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.BackupAndSecurity.Default
namespace TBF.BenchControl.DataContainers.BackupAndSecurityOptions
{
public class ComponentFactory : IComponentFactory
{

View File

@ -9,7 +9,7 @@ using Config.Entities;
using TBF.BenchControl;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.BenchInfo.Extended
namespace TBF.BenchControl.DataContainers.BenchInfo.Extended
{
/// <summary>
/// Holds information identifying the test bench.

View File

@ -7,7 +7,7 @@ using System.Xml.Serialization;
using Config.Entities;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.BenchInfo.Extended
namespace TBF.BenchControl.DataContainers.BenchInfo.Extended
{
/// <summary>
/// Holds information identifying the test bench - serializable configuration.

View File

@ -4,7 +4,7 @@
using System.Collections.Generic;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.BenchInfo.Extended
namespace TBF.BenchControl.DataContainers.BenchInfo.Extended
{
public class ComponentFactory : IComponentFactory
{

View File

@ -9,7 +9,7 @@ using Config.Entities;
using TBF.BenchControl;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.BenchInfo.iPerl
namespace TBF.BenchControl.DataContainers.BenchInfo.iPerl
{
/// <summary>
/// Holds information identifying the test bench.

View File

@ -8,7 +8,7 @@ using Config.Entities;
using TBF.BenchControl.Generic;
using TBF.Resources;
namespace TBF.BenchControl.BenchInfo.iPerl
namespace TBF.BenchControl.DataContainers.BenchInfo.iPerl
{
/// <summary>
/// Holds information identifying the test bench - serializable configuration.

View File

@ -4,7 +4,7 @@
using System.Collections.Generic;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.BenchInfo.iPerl
namespace TBF.BenchControl.DataContainers.BenchInfo.iPerl
{
public class ComponentFactory : IComponentFactory
{

View File

@ -0,0 +1,39 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using log4net;
namespace TBF.BenchControl.DataContainers.Buoyancy
{
/// <summary>
/// Holds measured (true) buoyancy value.
/// </summary>
public class Component : ComponentBase
{
private static readonly ILog log = LogManager.GetLogger(typeof(Component));
public override string ToString() { return string.Format("{0}({1})", this.GetType().Namespace.Substring(32), Cfg.ToString(1)); }
readonly ComponentCfg myCfg;
public double Buoyancy { get { return myCfg.Buoyancy; } }
public Component()
{
}
public Component(Generic.IComponentCfg cfg)
: base(cfg)
{
myCfg = cfg as ComponentCfg;
/// This is to use data in formulas
Config.Data.Buoyancy = Buoyancy;
/// This is to have data in reports
Results.WMeterRsltItemSpec.Buoyancy = Buoyancy;
log.Debug(this.ToString());
}
}
}

View File

@ -0,0 +1,118 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using Config.Entities;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.DataContainers.Buoyancy
{
/// <summary>
/// Holds backup and security options - serializable configuration.
/// </summary>
public class ComponentCfg : ComponentCfgBase, Generic.IComponentCfg, Config.Entities.IParamsProvider
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(ComponentCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl() { return new Configs.ParamsProvider.ComponentCfgCtrl(this, null); }
///
/// Serialized parameters
///
public double Buoyancy;
/// Private parameterless constructor invoked by all other (public) constructors
ComponentCfg() {}
public ComponentCfg(string name, IComponentFactory factory)
: this()
{
Name = name;
Factory = factory;
ParentName = string.Empty;
InitializeAll();
}
public string ComponentName { get { return Name; } }
public void InitializeAll()
{
Buoyancy = 1.00103;
}
string[] paramNames = new string[]
{
"Buoyancy",
};
public string ParamName(int i) { return paramNames[i]; }
public int ParamsCount() { return paramNames.Length; }
public IList<string> ParamValues(int i)
{
return null;
}
public string ToString(int i)
{
if (i == -1)
{
return string.Format("{0}: Buoyancy = {1}", Name, Buoyancy);
}
switch (i)
{
case 0: return Buoyancy.ToString();
default: return string.Empty;
}
}
public CfgUpdateFlags UpdateParam(int i, string strValue)
{
switch (i)
{
case 0: Buoyancy = Utils.ParseUDouble(strValue); return CfgUpdateFlags.RestartRqrd;
default: return CfgUpdateFlags.None;
}
}
public bool ValidateParam(int i, string strValue, out string message)
{
message = string.Empty;
double dummy;
switch (i)
{
case 0:
/// Real number between 0.8 and 1.2 expected
if (Utils.TryParseUDouble(strValue, out dummy) && (dummy >= 0.8) && (dummy <= 1.2)) return true;
break;
default:
message = "Invalid index";
return false;
}
message = ParamName(i) + " is invalid";
return false;
}
void CopyContentTo(ComponentCfg prms)
{
prms.Buoyancy = this.Buoyancy;
}
public Config.Entities.IParamsProvider Clone()
{
ComponentCfg pars = new ComponentCfg();
CopyContentTo(pars);
return pars;
}
public bool UpdateEmbeddedDbEntity()
{
return true; /// =OK, do nothing
}
}
}

View File

@ -0,0 +1,26 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.DataContainers.Buoyancy
{
public class ComponentFactory : 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<IComponent> components) { return new Component(cfg); }
public IComponentCfg DefaultConfig() { return new ComponentCfg(this.GetType().Namespace.Substring(32), this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(ComponentCfg.Serializer, component, this);
}
}
}

View File

@ -0,0 +1,42 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using log4net;
namespace TBF.BenchControl.DataContainers.Density
{
/// <summary>
/// Holds measured (true) density value.
/// </summary>
public class Component : ComponentBase
{
private static readonly ILog log = LogManager.GetLogger(typeof(Component));
public override string ToString() { return string.Format("{0}({1})", this.GetType().Namespace.Substring(32), Cfg.ToString(1)); }
readonly ComponentCfg myCfg;
public double RealDensity { get { return myCfg.RealDensity; } }
public double AtTemperature { get { return myCfg.AtTemperature; } }
public Component()
{
}
public Component(Generic.IComponentCfg cfg)
: base(cfg)
{
myCfg = cfg as ComponentCfg;
/// This is to use data in formulas
Config.Data.RealDensity = RealDensity;
Config.Data.AtTemperature = AtTemperature;
/// This is to have data in reports
Results.WMeterRsltItemSpec.RealDensity = RealDensity;
Results.WMeterRsltItemSpec.AtTemperature = AtTemperature;
log.Debug(this.ToString());
}
}
}

View File

@ -0,0 +1,128 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using Config.Entities;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.DataContainers.Density
{
/// <summary>
/// Holds backup and security options - serializable configuration.
/// </summary>
public class ComponentCfg : ComponentCfgBase, Generic.IComponentCfg, Config.Entities.IParamsProvider
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(ComponentCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl() { return new Configs.ParamsProvider.ComponentCfgCtrl(this, null); }
///
/// Serialized parameters
///
public double RealDensity;
public double AtTemperature;
/// Private parameterless constructor invoked by all other (public) constructors
ComponentCfg() {}
public ComponentCfg(string name, IComponentFactory factory)
: this()
{
Name = name;
Factory = factory;
ParentName = string.Empty;
InitializeAll();
}
public string ComponentName { get { return Name; } }
public void InitializeAll()
{
RealDensity = 998.2008; /// kg/m3
AtTemperature = 20.0; /// °C
}
string[] paramNames = new string[]
{
"True density [kg/m3]",
"@temperature [°C]",
};
public string ParamName(int i) { return paramNames[i]; }
public int ParamsCount() { return paramNames.Length; }
public IList<string> ParamValues(int i)
{
return null;
}
public string ToString(int i)
{
if (i == -1)
{
return string.Format("{0}: True density = {1} kg/m3 measured @temperature {2} °C", Name, RealDensity, AtTemperature);
}
switch (i)
{
case 0: return RealDensity.ToString();
case 1: return AtTemperature.ToString();
default: return string.Empty;
}
}
public CfgUpdateFlags UpdateParam(int i, string strValue)
{
switch (i)
{
case 0: RealDensity = Utils.ParseUDouble(strValue); return CfgUpdateFlags.RestartRqrd;
case 1: AtTemperature = Utils.ParseUDouble(strValue); return CfgUpdateFlags.RestartRqrd;
default: return CfgUpdateFlags.None;
}
}
public bool ValidateParam(int i, string strValue, out string message)
{
message = string.Empty;
double dummy;
switch (i)
{
case 0:
/// Real number between 800 and 1200 kg/m3 expected
if (Utils.TryParseUDouble(strValue, out dummy) && (dummy >= 800) && (dummy <= 1200)) return true;
break;
case 1:
/// Real number above 0 expected
if (Utils.TryParseUDouble(strValue, out dummy) && (dummy >= 0)) return true;
break;
default:
message = "Invalid index";
return false;
}
message = ParamName(i) + " is invalid";
return false;
}
void CopyContentTo(ComponentCfg prms)
{
prms.RealDensity = this.RealDensity;
prms.AtTemperature = this.AtTemperature;
}
public Config.Entities.IParamsProvider Clone()
{
ComponentCfg pars = new ComponentCfg();
CopyContentTo(pars);
return pars;
}
public bool UpdateEmbeddedDbEntity()
{
return true; /// =OK, do nothing
}
}
}

View File

@ -1,15 +1,14 @@
///
/// Copyright (c) 2013-2016 Sensus Metering Systems
/// Author: Milan Hanajík
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using System.Collections.Generic;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.BenchInfo.Munich
namespace TBF.BenchControl.DataContainers.Density
{
public class ComponentFactory : IComponentFactory
{
public string ClassName { get { return "Bench-ID"; } }
public string ClassName { get { return this.GetType().Namespace.Substring(17); } }
public void ResetStaticProperties() { Component.ResetStaticProperties(); }
@ -17,11 +16,11 @@ namespace TBF.BenchControl.BenchInfo.Munich
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Component(cfg); }
public IComponentCfg DefaultConfig() { return new ComponentCfg(this); }
public IComponentCfg DefaultConfig() { return new ComponentCfg(this.GetType().Namespace.Substring(32), this); }
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
{
return ComponentCfgBase.CreateFromDbEntity(ComponentCfg.Serializer, component, this);
return ComponentCfgBase.CreateFromDbEntity(ComponentCfg.Serializer, component, this);
}
}
}

View File

@ -63,8 +63,8 @@ namespace TBF.BenchControl.DataEntry.iPerl
///
/// Draw an appropriate test bench picture
///
Config.Entities.Side side = (TBF.BenchControl.Sequences.ProcessData.BenchInfo is BenchInfo.iPerl.Component)
? (TBF.BenchControl.Sequences.ProcessData.BenchInfo as BenchInfo.iPerl.Component).Side
Config.Entities.Side side = (TBF.BenchControl.Sequences.ProcessData.BenchInfo is DataContainers.BenchInfo.iPerl.Component)
? (TBF.BenchControl.Sequences.ProcessData.BenchInfo as DataContainers.BenchInfo.iPerl.Component).Side
: Config.Entities.Side.Left;
if (reversedDirection && (side == Config.Entities.Side.Left))
{

View File

@ -1,17 +0,0 @@
///
/// Copyright (c) 2019 Sensus Slovensko a.s.
///
using Config.Entities;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.GenericDevices
{
/// <summary>
/// Backup and security options
/// </summary>
public interface IBackupAndSecurity : IComponent
{
int MinPasswdLength { get; }
int PasswdExpirationPeriodDays { get; }
}
}

View File

@ -1794,8 +1794,8 @@ namespace TBF.BenchControl.Sequences
StateMachine.Procedure,
waterMeterData,
waterMeterParts,
Formulas.DensityCorrection(Program.LocalSettings.RealDensity,
Program.LocalSettings.AtTemperature));
Formulas.DensityCorrection(Config.Formulas.RealDensity(),
Config.Formulas.AtTemperature()));
}

View File

@ -7,7 +7,6 @@ namespace TBF.BenchControl.Sequences
{
public class ProcessData
{
public static IBackupAndSecurity BackupAndSecurity;
public static IBenchInfo BenchInfo;
public static IErrorFlags ErrorFlagsComp;
public static Output.DB.SensusOracle.Database OracleDB;

View File

@ -960,17 +960,10 @@ namespace TBF.BenchControl.Sequences
tstRslt.TempDivEnd = (float)TempDivStat.Last;
tstRslt.TempDivMin = (float)TempDivStat.Min;
tstRslt.TempDivMax = (float)TempDivStat.Max;
tstRslt.DensityIn = Formulas.WaterDensityFromTempPress(tstRslt.TempUpMean,
tstRslt.PressUpMean,
Program.LocalSettings.RealDensity,
Program.LocalSettings.AtTemperature); /// [kg/m3]
tstRslt.DensityDiv = Formulas.WaterDensityFromTemp(tstRslt.TempDivMean,
Program.LocalSettings.RealDensity,
Program.LocalSettings.AtTemperature); /// [kg/m3]
tstRslt.DensityIn = Formulas.WaterDensityFromTempPress(tstRslt.TempUpMean, tstRslt.PressUpMean);
tstRslt.DensityDiv = Formulas.WaterDensityFromTempPress(tstRslt.TempDivMean, 0);
tstRslt.DensityLine = Formulas.WaterDensityFromTempPress((tstRslt.TempUpMean + tstRslt.TempDownMean) / 2,
(tstRslt.PressUpMean + tstRslt.PressDownMean) / 2,
Program.LocalSettings.RealDensity,
Program.LocalSettings.AtTemperature); /// [kg/m3]
(tstRslt.PressUpMean + tstRslt.PressDownMean) / 2);
}
@ -1059,8 +1052,8 @@ namespace TBF.BenchControl.Sequences
sb.Append(";"); sb.Append(" "); /// BB d_air: Hustota vzduchu: Sheet1 - K9
sb.Append(";"); sb.Append(tstRslt.Buoyancy); /// BC Buoyancy: Sheet1 - X9
sb.Append(";"); sb.Append(Program.LocalSettings.RealDensity); /// BD
sb.Append(";"); sb.Append(Program.LocalSettings.AtTemperature); /// BE
sb.Append(";"); sb.Append(Config.Formulas.RealDensity()); /// BD
sb.Append(";"); sb.Append(Config.Formulas.AtTemperature()); /// BE
sb.Append(";"); sb.Append(tstRslt.FlowMax); /// BF pipe expansion: teraz vynechat
sb.Append(";"); sb.Append(tstRslt.FlowMin); /// BG [kg/h] Qm
sb.Append(";"); sb.Append(tstRslt.FlowVolume); /// BH [l/h] Qv
@ -1300,9 +1293,9 @@ namespace TBF.BenchControl.Sequences
tstRslt.TempDownMax = 20.0f;
tstRslt.TempDivMax = 20.0f;
tstRslt.DensityIn = Program.LocalSettings.RealDensity;
tstRslt.DensityLine = Program.LocalSettings.RealDensity;
tstRslt.DensityDiv = Program.LocalSettings.RealDensity;
tstRslt.DensityIn = Config.Formulas.RealDensity();
tstRslt.DensityLine = Config.Formulas.RealDensity();
tstRslt.DensityDiv = Config.Formulas.RealDensity();
tstRslt.MethodClass = TbfComponents.FindComponent(test.Method).ClassName;
tstRslt.StartTime = DateTime.Now;
@ -1312,7 +1305,7 @@ namespace TBF.BenchControl.Sequences
tstRslt.PulsesMaster = (outPath.FlowMeter.LtrPerPulse > 1E-6) ? (1.0075 * tstRslt.TargetVolume() / outPath.FlowMeter.LtrPerPulse) : 1;
tstRslt.MassStartRaw = 0;
tstRslt.MassStart = Config.Formulas.CorrectedValue(tstRslt.MassStartRaw, outPath.Scale.Corrections);
tstRslt.MassEndRaw = tstRslt.TargetVolume() * Program.LocalSettings.RealDensity / 1000.0f;
tstRslt.MassEndRaw = tstRslt.TargetVolume() * Config.Formulas.RealDensity() / 1000.0f;
tstRslt.MassEnd = Config.Formulas.CorrectedValue(tstRslt.MassEndRaw, outPath.Scale.Corrections);
tstRslt.FlowMass = 3600.0 * (tstRslt.MassEnd - tstRslt.MassStart) / tstRslt.TestTime;
tstRslt.FlowVolume = 3.6 * outPath.FlowMeter.LtrPerPulse * tstRslt.PulsesMaster / tstRslt.TestTime;
@ -1393,11 +1386,11 @@ namespace TBF.BenchControl.Sequences
tstRslt.ConstMaster = LtrPerRefPulse;
tstRslt.MassStartRaw = 0;
tstRslt.MassStart = 0;
tstRslt.MassEndRaw = tstRslt.TargetVolume() * Program.LocalSettings.RealDensity / 1000.0f;
tstRslt.MassEndRaw = tstRslt.TargetVolume() * Config.Formulas.RealDensity() / 1000.0f;
tstRslt.MassEnd = tstRslt.MassEndRaw;
tstRslt.DensityIn = Program.LocalSettings.RealDensity;
tstRslt.DensityLine = Program.LocalSettings.RealDensity;
tstRslt.DensityDiv = Program.LocalSettings.RealDensity;
tstRslt.DensityIn = Config.Formulas.RealDensity();
tstRslt.DensityLine = Config.Formulas.RealDensity();
tstRslt.DensityDiv = Config.Formulas.RealDensity();
tstRslt.Buoyancy = Formulas.Buoyancy();
tstRslt.FlowMass = tstRslt.MassEnd / tstRslt.TargetTime();
tstRslt.FlowVolume = tstRslt.TargetVolume() / tstRslt.TargetTime();
@ -1522,11 +1515,11 @@ namespace TBF.BenchControl.Sequences
tstRslt.ConstMaster = LtrPerRefPulse;
tstRslt.MassStartRaw = 0;
tstRslt.MassStart = 0;
tstRslt.MassEndRaw = tstRslt.TargetVolume() * Program.LocalSettings.RealDensity / 1000.0f;
tstRslt.MassEndRaw = tstRslt.TargetVolume() * Config.Formulas.RealDensity() / 1000.0f;
tstRslt.MassEnd = tstRslt.MassEndRaw;
tstRslt.DensityIn = Program.LocalSettings.RealDensity;
tstRslt.DensityLine = Program.LocalSettings.RealDensity;
tstRslt.DensityDiv = Program.LocalSettings.RealDensity;
tstRslt.DensityIn = Config.Formulas.RealDensity();
tstRslt.DensityLine = Config.Formulas.RealDensity();
tstRslt.DensityDiv = Config.Formulas.RealDensity();
tstRslt.Buoyancy = Formulas.Buoyancy();
tstRslt.FlowMass = tstRslt.MassEnd / tstRslt.TargetTime();
tstRslt.FlowVolume = tstRslt.TargetVolume() / tstRslt.TargetTime();

View File

@ -228,7 +228,6 @@ namespace TBF.BenchControl
foreach (var cmpnt in components)
{
if (cmpnt is Elde.ControlBoardDev) ControlBoard = cmpnt as Elde.ControlBoardDev;
if (cmpnt is IBackupAndSecurity) ProcessData.BackupAndSecurity = cmpnt as IBackupAndSecurity;
if (cmpnt is IBenchInfo) ProcessData.BenchInfo = cmpnt as IBenchInfo;
if (cmpnt is IErrorFlags) ProcessData.ErrorFlagsComp = cmpnt as IErrorFlags;
if ((cmpnt is Output.DB.SensusOracle.Database) && (ProcessData.OracleDB == null))
@ -684,7 +683,7 @@ namespace TBF.BenchControl
return false;
}
if (Program.LocalSettings.RealDensity < 500.0f || Program.LocalSettings.RealDensity > 2000.0f)
if (Config.Formulas.RealDensity() < 500.0f || Config.Formulas.RealDensity() > 2000.0f)
{
errorMsg = string.Format("Density was not specified");
return false;

View File

@ -15,10 +15,11 @@ namespace TBF.BenchControl
{
Factories = new List<IComponentFactory>();
Factories.Add(new BackupAndSecurity.Default.ComponentFactory());
Factories.Add(new BenchInfo.Munich.ComponentFactory());
Factories.Add(new BenchInfo.Extended.ComponentFactory());
Factories.Add(new BenchInfo.iPerl.ComponentFactory());
Factories.Add(new DataContainers.BackupAndSecurityOptions.ComponentFactory());
Factories.Add(new DataContainers.BenchInfo.Extended.ComponentFactory());
Factories.Add(new DataContainers.BenchInfo.iPerl.ComponentFactory());
Factories.Add(new DataContainers.Buoyancy.ComponentFactory());
Factories.Add(new DataContainers.Density.ComponentFactory());
Factories.Add(new Elde.ControlBoardFactory());
Factories.Add(new Elde.CoverTest.Factory());
Factories.Add(new DataEntry.Combined.EntryFormFactory());

View File

@ -506,9 +506,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartAdvanced
double massStart = Config.Formulas.CorrectedValue(StartMass.Val, scale.Corrections);
double massEnd = Config.Formulas.CorrectedValue(EndMass.Val, scale.Corrections);
double densityOut = Config.Formulas.WaterDensityFromTempPress((TempUpStat.Average + TempDownStat.Average) / 2,
(PressUpStat.Average + PressDownStat.Average) / 2,
Program.LocalSettings.RealDensity,
Program.LocalSettings.AtTemperature); /// [kg/m3] ///
(PressUpStat.Average + PressDownStat.Average) / 2);
double buoyancy = Config.Formulas.Buoyancy();
double massOfEvaporatedWater = (double)(tMass2 - tMass1) * outPath.Scale.EvaporationRate(TempDivStat.Average);
double volumeCTV = 1000.0 * buoyancy * (massEnd - massStart + massOfEvaporatedWater) / densityOut;

View File

@ -814,9 +814,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartDeferredEvaluation
double massStart = Config.Formulas.CorrectedValue(StartMass.Val, scale.Corrections);
double massEnd = Config.Formulas.CorrectedValue(EndMass.Val, scale.Corrections);
double densityOut = Config.Formulas.WaterDensityFromTempPress((TempUpStat.Average + TempDownStat.Average) / 2,
(PressUpStat.Average + PressDownStat.Average) / 2,
Program.LocalSettings.RealDensity,
Program.LocalSettings.AtTemperature); /// [kg/m3] ///
(PressUpStat.Average + PressDownStat.Average) / 2);
double buoyancy = Config.Formulas.Buoyancy();
double massOfEvaporatedWater = (double)(tMass2 - tMass1) * outPath.Scale.EvaporationRate(TempDivStat.Average);
double volumeCTV = 1000.0 * buoyancy * (massEnd - massStart + massOfEvaporatedWater) / densityOut;

View File

@ -818,9 +818,7 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
double massStart = Config.Formulas.CorrectedValue(StartMass.Val, scale.Corrections);
double massEnd = Config.Formulas.CorrectedValue(EndMass.Val, scale.Corrections);
double densityOut = Config.Formulas.WaterDensityFromTempPress((TempUpStat.Average + TempDownStat.Average) / 2,
(PressUpStat.Average + PressDownStat.Average) / 2,
Program.LocalSettings.RealDensity,
Program.LocalSettings.AtTemperature); /// [kg/m3] ///
(PressUpStat.Average + PressDownStat.Average) / 2);
double buoyancy = Config.Formulas.Buoyancy();
double massOfEvaporatedWater = (double)(tMass2 - tMass1) * outPath.Scale.EvaporationRate(TempDivStat.Average);
double volumeCTV = 1000.0 * buoyancy * (massEnd - massStart + massOfEvaporatedWater) / densityOut;

View File

@ -99,8 +99,8 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
string[] args = testParams.Activity.Substring(IperlCheckCmd.Length).Split(new char[] { ' ' });
int maxTestIndex = (ProcessData.BenchInfo is BenchInfo.iPerl.Component)
? (ProcessData.BenchInfo as BenchInfo.iPerl.Component).MaxTestIndex
int maxTestIndex = (ProcessData.BenchInfo is DataContainers.BenchInfo.iPerl.Component)
? (ProcessData.BenchInfo as DataContainers.BenchInfo.iPerl.Component).MaxTestIndex
: int.MaxValue;
Results.Entities.TestRslt tstRslt = ProcessData.BatchRslts.GetTestRslt(test.Name, 0);

View File

@ -64,9 +64,6 @@ namespace TBF
public int LastProcedureNr;
public int BatchNr;
public double RealDensity; /// water density [kg/m3]
public double AtTemperature; /// measured at temperature [degree C]
public int RightPaneHorizSplitterDistance;
public int TopPaneVerticalSplitterDistance;
@ -337,7 +334,6 @@ namespace TBF
{
LocalSettings ls = serializer.Deserialize(reader) as LocalSettings;
log.WarnFormat("Succesfully loaded and decrypted from '{0}'", fileName);
ls.UpdateResultsOutputData();
return ls;
}
}
@ -353,7 +349,6 @@ namespace TBF
{
LocalSettings ls = serializer.Deserialize(reader) as LocalSettings;
log.WarnFormat("Succesfully loaded from '{0}'", fileName);
ls.UpdateResultsOutputData();
return ls;
}
}
@ -370,8 +365,6 @@ namespace TBF
/// </summary>
public void Save()
{
UpdateResultsOutputData();
try
{
#if false
@ -423,16 +416,6 @@ namespace TBF
}
/// <summary>
/// To be able to have RealDensity and AtTemperatire in reports.
/// </summary>
void UpdateResultsOutputData()
{
Results.WMeterRsltItemSpec.RealDensity = this.RealDensity;
Results.WMeterRsltItemSpec.AtTemperature = this.AtTemperature;
}
/// <summary>
/// Updates history stored in a string array by a new latest string.
/// </summary>

View File

@ -2095,7 +2095,7 @@ namespace TBF.Resources {
}
/// <summary>
/// Looks up a localized string similar to At least one of Buoyancy parameters is invalid,\r\ncorrect it please..
/// Looks up a localized string similar to Buoyancy is invalid, correct it please..
/// </summary>
internal static string Invalid_buoyancy_parameter_Correct_pls {
get {
@ -2112,6 +2112,15 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Invalid density parameters.\r\nCorrect them please..
/// </summary>
internal static string Invalid_density_parameter_Correct_pls {
get {
return ResourceManager.GetString("Invalid_density_parameter_Correct_pls", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Invalid password.
/// </summary>

View File

@ -1154,7 +1154,7 @@
<value>Continue in the cycle after this test?</value>
</data>
<data name="Invalid_buoyancy_parameter_Correct_pls" xml:space="preserve">
<value>At least one of Buoyancy parameters is invalid,\r\ncorrect it please.</value>
<value>Buoyancy is invalid, correct it please.</value>
</data>
<data name="Invalid_calib_info_Correct_pls" xml:space="preserve">
<value>Invalid calibration information. Correct it please.</value>
@ -2062,4 +2062,7 @@
<data name="No_info_available" xml:space="preserve">
<value>No info available</value>
</data>
<data name="Invalid_density_parameter_Correct_pls" xml:space="preserve">
<value>Invalid density parameters.\r\nCorrect them please.</value>
</data>
</root>

View File

@ -158,24 +158,6 @@
<DependentUpon>AmbientCfgCtrl.cs</DependentUpon>
</Compile>
<Compile Include="BenchControl\Ambient\Greco\Factory.cs" />
<Compile Include="BenchControl\BackupAndSecurity\Default\Component.cs" />
<Compile Include="BenchControl\BackupAndSecurity\Default\ComponentCfg.cs" />
<Compile Include="BenchControl\BackupAndSecurity\Default\ComponentFactory.cs" />
<Compile Include="BenchControl\BenchInfo\Extended\Component.cs" />
<Compile Include="BenchControl\BenchInfo\Extended\ComponentCfg.cs" />
<Compile Include="BenchControl\BenchInfo\Extended\ComponentFactory.cs" />
<Compile Include="BenchControl\BenchInfo\iPerl\Component.cs" />
<Compile Include="BenchControl\BenchInfo\iPerl\ComponentCfg.cs" />
<Compile Include="BenchControl\BenchInfo\iPerl\ComponentFactory.cs" />
<Compile Include="BenchControl\BenchInfo\Munich\Component.cs" />
<Compile Include="BenchControl\BenchInfo\Munich\ComponentCfg.cs" />
<Compile Include="BenchControl\BenchInfo\Munich\ComponentCfgCtrl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="BenchControl\BenchInfo\Munich\ComponentCfgCtrl.designer.cs">
<DependentUpon>ComponentCfgCtrl.cs</DependentUpon>
</Compile>
<Compile Include="BenchControl\BenchInfo\Munich\ComponentFactory.cs" />
<Compile Include="BenchControl\ComponentParametersDlg.cs">
<SubType>Form</SubType>
</Compile>
@ -198,6 +180,21 @@
<Compile Include="BenchControl\Configs\ParamsProvider\ComponentCfgCtrl.designer.cs">
<DependentUpon>ComponentCfgCtrl.cs</DependentUpon>
</Compile>
<Compile Include="BenchControl\DataContainers\BackupAndSecurityOptions\Component.cs" />
<Compile Include="BenchControl\DataContainers\BackupAndSecurityOptions\ComponentCfg.cs" />
<Compile Include="BenchControl\DataContainers\BackupAndSecurityOptions\ComponentFactory.cs" />
<Compile Include="BenchControl\DataContainers\BenchInfo\Extended\Component.cs" />
<Compile Include="BenchControl\DataContainers\BenchInfo\Extended\ComponentCfg.cs" />
<Compile Include="BenchControl\DataContainers\BenchInfo\Extended\ComponentFactory.cs" />
<Compile Include="BenchControl\DataContainers\BenchInfo\iPerl\Component.cs" />
<Compile Include="BenchControl\DataContainers\BenchInfo\iPerl\ComponentCfg.cs" />
<Compile Include="BenchControl\DataContainers\BenchInfo\iPerl\ComponentFactory.cs" />
<Compile Include="BenchControl\DataContainers\Buoyancy\Component.cs" />
<Compile Include="BenchControl\DataContainers\Buoyancy\ComponentCfg.cs" />
<Compile Include="BenchControl\DataContainers\Buoyancy\ComponentFactory.cs" />
<Compile Include="BenchControl\DataContainers\Density\Component.cs" />
<Compile Include="BenchControl\DataContainers\Density\ComponentCfg.cs" />
<Compile Include="BenchControl\DataContainers\Density\ComponentFactory.cs" />
<Compile Include="BenchControl\DataEntry\Combined\TestStartEndForm.cs">
<SubType>Form</SubType>
</Compile>
@ -597,7 +594,6 @@
<DependentUpon>ValveCfgCtrl.cs</DependentUpon>
</Compile>
<Compile Include="BenchControl\Elde\ValveEx\ValveFactory.cs" />
<Compile Include="BenchControl\GenericDevices\IBackupAndSecurity.cs" />
<Compile Include="BenchControl\GenericDevices\ICalibInfoCfg.cs" />
<Compile Include="BenchControl\GenericDevices\IEvaporation.cs" />
<Compile Include="BenchControl\GenericDevices\IParallelOutput.cs" />
@ -2006,6 +2002,12 @@
<Compile Include="UI\Bench\Metrology\MetrologyDlgBalanceTab.designer.cs">
<DependentUpon>MetrologyDlgBalanceTab.cs</DependentUpon>
</Compile>
<Compile Include="UI\Bench\Metrology\MetrologyDlgBuoyancyTab.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="UI\Bench\Metrology\MetrologyDlgBuoyancyTab.designer.cs">
<DependentUpon>MetrologyDlgBuoyancyTab.cs</DependentUpon>
</Compile>
<Compile Include="UI\Bench\Metrology\MetrologyDlgDensityTab.cs">
<SubType>UserControl</SubType>
</Compile>
@ -2383,9 +2385,6 @@
<EmbeddedResource Include="BenchControl\Ambient\Greco\AmbientCfgCtrl.resx">
<DependentUpon>AmbientCfgCtrl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="BenchControl\BenchInfo\Munich\ComponentCfgCtrl.resx">
<DependentUpon>ComponentCfgCtrl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="BenchControl\ComponentParametersDlg.resx">
<DependentUpon>ComponentParametersDlg.cs</DependentUpon>
</EmbeddedResource>
@ -3031,6 +3030,9 @@
<EmbeddedResource Include="UI\Bench\Metrology\MetrologyDlgBalanceTab.resx">
<DependentUpon>MetrologyDlgBalanceTab.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\Bench\Metrology\MetrologyDlgBuoyancyTab.resx">
<DependentUpon>MetrologyDlgBuoyancyTab.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\Bench\Metrology\MetrologyDlgDensityTab.resx">
<DependentUpon>MetrologyDlgDensityTab.cs</DependentUpon>
</EmbeddedResource>

View File

@ -60,19 +60,38 @@ namespace TBF.UI.Bench.Metrology
.OrderBy(x => x. ItemNr).Asc
.List();
// Density tab-page
fixedCount++;
TabPage dstyTabPage = new TabPage(" " + Strings.Density + " ");
MetrologyDlgDensityTab uiCtl = new MetrologyDlgDensityTab();
uiCtl.Dock = DockStyle.Fill;
dstyTabPage.Tag = uiCtl;
dstyTabPage.Controls.Add(uiCtl);
metrologyTabControl.TabPages.Add(dstyTabPage);
foreach (var cmpnt in cmpntEntities)
{
BenchControl.Generic.IComponentFactory factory = TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName);
/// Tab-page density
if (factory is BenchControl.DataContainers.Density.ComponentFactory)
{
fixedCount++;
TabPage tabPage = new TabPage(" " + Strings.Density + " ");
MetrologyDlgDensityTab uiControl = new MetrologyDlgDensityTab();
uiControl.MeterEntity = cmpnt;
uiControl.DensityCfg = factory.CmpntCfgFromCmpntEntity(cmpnt) as BenchControl.DataContainers.Density.ComponentCfg;
uiControl.Dock = DockStyle.Fill;
tabPage.Tag = uiControl;
tabPage.Controls.Add(uiControl);
metrologyTabControl.TabPages.Add(tabPage);
}
/// Tab-page buoyancy
if (factory is BenchControl.DataContainers.Buoyancy.ComponentFactory)
{
fixedCount++;
TabPage tabPage = new TabPage(" Buoyancy ");
MetrologyDlgBuoyancyTab uiControl = new MetrologyDlgBuoyancyTab();
uiControl.MeterEntity = cmpnt;
uiControl.BuoyancyCfg = factory.CmpntCfgFromCmpntEntity(cmpnt) as BenchControl.DataContainers.Buoyancy.ComponentCfg;
uiControl.Dock = DockStyle.Fill;
tabPage.Tag = uiControl;
tabPage.Controls.Add(uiControl);
metrologyTabControl.TabPages.Add(tabPage);
}
/// Tab-pages for scales
if (factory is BenchControl.MettlerToledo.Standard.BalanceFactory ||
factory is BenchControl.MettlerToledo.Standard.BalanceOldFactory ||
@ -216,10 +235,9 @@ namespace TBF.UI.Bench.Metrology
foreach (TabPage tabPage in metrologyTabControl.TabPages)
{
IMetrologyDlgTab tab = tabPage.Tag as IMetrologyDlgTab;
tab.OkBtnClicked();
if (!(tabPage.Tag is MetrologyDlgDensityTab))
if (tab != null)
{
tab.OkBtnClicked();
session.SaveOrUpdate(tab.MeterEntity);
foreach (var entity in tab.ToBeRemoved) session.Delete(entity);
}

View File

@ -190,7 +190,7 @@ namespace TBF.UI.Bench.Metrology
item.SubItems[3].Text = error.ToString(Config.Utils.SignificantDigitsToFmt(error, 5));
}
else
{
{
item.SubItems[3].Text = Strings.NaN;
}
@ -209,7 +209,7 @@ namespace TBF.UI.Bench.Metrology
item.SubItems[3].Text = error.ToString(Config.Utils.SignificantDigitsToFmt(error, 5));
}
else
{
{
item.SubItems[3].Text = Strings.NaN;
}
@ -221,7 +221,7 @@ namespace TBF.UI.Bench.Metrology
{
}
else
{
{
double measurement;
if (Utils.TryParseEDouble(item.SubItems[1].Text, out measurement) && measurement != 0)
{

View File

@ -0,0 +1,97 @@
///
/// Copyright (c) 2013-2015 Senus Slovensko a.s.
///
namespace TBF.UI.Bench.Metrology
{
partial class MetrologyDlgBuoyancyTab
{
/// <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.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.buoyancyTextBox = new System.Windows.Forms.TextBox();
this.buoyancyLabel = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.SuspendLayout();
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
this.splitContainer1.Name = "splitContainer1";
this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.buoyancyTextBox);
this.splitContainer1.Panel1.Controls.Add(this.buoyancyLabel);
this.splitContainer1.Size = new System.Drawing.Size(420, 300);
this.splitContainer1.SplitterDistance = 120;
this.splitContainer1.TabIndex = 1;
//
// buoyancyTextBox
//
this.buoyancyTextBox.Enabled = false;
this.buoyancyTextBox.Location = new System.Drawing.Point(189, 51);
this.buoyancyTextBox.Name = "buoyancyTextBox";
this.buoyancyTextBox.Size = new System.Drawing.Size(110, 20);
this.buoyancyTextBox.TabIndex = 1;
//
// buoyancyLabel
//
this.buoyancyLabel.AutoSize = true;
this.buoyancyLabel.Location = new System.Drawing.Point(41, 54);
this.buoyancyLabel.Name = "buoyancyLabel";
this.buoyancyLabel.Size = new System.Drawing.Size(54, 13);
this.buoyancyLabel.TabIndex = 0;
this.buoyancyLabel.Text = "Buoyancy";
//
// MetrologyDlgBuoyancyTab
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.splitContainer1);
this.Name = "MetrologyDlgBuoyancyTab";
this.Size = new System.Drawing.Size(420, 300);
this.Load += new System.EventHandler(this.MetrologyDlgBuoyancyTab_Load);
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.TextBox buoyancyTextBox;
private System.Windows.Forms.Label buoyancyLabel;
}
}

View File

@ -0,0 +1,132 @@
///
/// Copyright (c) 2013-2019 Senus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using log4net;
using Config.Entities;
using TBF.Resources;
namespace TBF.UI.Bench.Metrology
{
public partial class MetrologyDlgBuoyancyTab : UserControl, IMetrologyDlgTab
{
static readonly ILog log = LogManager.GetLogger(typeof(MetrologyDlgBuoyancyTab));
/// <summary>
/// Component entity that has a list of 'measurement-correction' pairs
/// to be updated in the database on OK.
/// </summary>
public Component MeterEntity
{
get { return meterEntity; }
set { meterEntity = value; }
}
Component meterEntity;
/// <summary>
/// Buoyancy configuration
/// </summary>
public BenchControl.DataContainers.Buoyancy.ComponentCfg BuoyancyCfg;
/// <summary>
/// A list of 'measurement-correction' pairs to be deleted from the database on OK.
/// </summary>
public IList<MeasurementCorrection> ToBeRemoved
{
get { return toBeRemoved; }
set { toBeRemoved = value; }
}
IList<MeasurementCorrection> toBeRemoved;
MetrologyDlg parent;
bool unlocked;
public MetrologyDlgBuoyancyTab()
{
InitializeComponent();
toBeRemoved = new List<MeasurementCorrection>();
unlocked = false;
}
private void MetrologyDlgBuoyancyTab_Load(object sender, System.EventArgs e)
{
if (meterEntity == null) return;
parent = ParentForm as MetrologyDlg;
/// Panel1
buoyancyLabel.Text = "Buoyancy";
/// Panel2
RefreshAll();
}
void RefreshAll()
{
buoyancyTextBox.Text = Config.Data.Buoyancy.ToString("F5");
}
public void Unlock()
{
unlocked = true;
buoyancyTextBox.Enabled = true;
}
public void OkBtnClicked()
{
if (BuoyancyCfg != null)
{
try
{
double buoyancy = Utils.ParseUDouble(buoyancyTextBox.Text);
global::Results.WMeterRsltItemSpec.Buoyancy =
Config.Data.Buoyancy = BuoyancyCfg.Buoyancy = buoyancy;
Component modified = BuoyancyCfg.CreateDbEntity();
MeterEntity.Parameters = modified.Parameters;
}
catch
{
MessageBox.Show(Strings.Invalid_buoyancy_parameter_Correct_pls,
Strings.Error,
MessageBoxButtons.OK,
MessageBoxIcon.Exclamation);
}
}
}
public void CancelBtnClicked()
{
}
public void AddOne()
{
}
public void RemoveSelected()
{
}
public void MoveUpSelected()
{
}
public void MoveDownSelected()
{
}
public string GetWarningsBeforeSaving(ref Dictionary<string, string> renmInfo)
{
return string.Empty;
}
public void UpdateRelatedItems(Dictionary<string, string> renameInfo)
{
}
}
}

View File

@ -1,9 +1,8 @@
///
/// Copyright (c) 2013-2017 Senus Slovensko a.s.
/// Copyright (c) 2013-2019 Senus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Windows.Forms;
using log4net;
using Config.Entities;
@ -21,9 +20,15 @@ namespace TBF.UI.Bench.Metrology
/// </summary>
public Component MeterEntity
{
get { return null; }
set { }
}
get { return meterEntity; }
set { meterEntity = value; }
}
Component meterEntity;
/// <summary>
/// Density configuration
/// </summary>
public BenchControl.DataContainers.Density.ComponentCfg DensityCfg;
/// <summary>
/// A list of 'measurement-correction' pairs to be deleted from the database on OK.
@ -47,7 +52,9 @@ namespace TBF.UI.Bench.Metrology
private void MetrologyDlgDensityTab_Load(object sender, System.EventArgs e)
{
parent = ParentForm as MetrologyDlg;
if (meterEntity == null) return;
parent = ParentForm as MetrologyDlg;
/// Panel1
densityLabel.Text = string.Format("{0} [{1}]", Strings.Density, Config.Unit.kgpm3.ToDescription());
@ -61,9 +68,9 @@ namespace TBF.UI.Bench.Metrology
void RefreshAll()
{
densityTextBox.Text = Program.LocalSettings.RealDensity.ToString("F4");
temperatureTextBox.Text = Program.LocalSettings.AtTemperature.ToString("F2");
densityCorrTextBox.Text = Config.Formulas.DensityCorrection(Program.LocalSettings.RealDensity, Program.LocalSettings.AtTemperature).ToString("F5");
densityTextBox.Text = Config.Data.RealDensity.ToString("F4");
temperatureTextBox.Text = Config.Data.AtTemperature.ToString("F2");
densityCorrTextBox.Text = Config.Formulas.DensityCorrection(Config.Data.RealDensity, Config.Data.AtTemperature).ToString("F5");
}
public void Unlock()
@ -76,16 +83,30 @@ namespace TBF.UI.Bench.Metrology
public void OkBtnClicked()
{
double tmp;
if (Utils.TryParseUDouble(densityTextBox.Text, out tmp))
{
Program.LocalSettings.RealDensity = tmp;
}
if (Utils.TryParseUDouble(temperatureTextBox.Text, out tmp))
{
Program.LocalSettings.AtTemperature = tmp;
}
Program.LocalSettings.Save();
if (DensityCfg != null)
{
try
{
double realDensity = Utils.ParseUDouble(densityTextBox.Text);
double atTemperature = Utils.ParseUDouble(temperatureTextBox.Text);
global::Results.WMeterRsltItemSpec.RealDensity =
Config.Data.RealDensity = DensityCfg.RealDensity = realDensity;
global::Results.WMeterRsltItemSpec.AtTemperature =
Config.Data.AtTemperature = DensityCfg.AtTemperature = atTemperature;
Component modified = DensityCfg.CreateDbEntity();
MeterEntity.Parameters = modified.Parameters;
}
catch
{
MessageBox.Show(Strings.Invalid_density_parameter_Correct_pls,
Strings.Error,
MessageBoxButtons.OK,
MessageBoxIcon.Exclamation);
}
}
}
public void CancelBtnClicked()

View File

@ -154,7 +154,7 @@ namespace TBF.UI.Bench.Metrology
item.SubItems[3].Text = error.ToString(Config.Utils.SignificantDigitsToFmt(error, 5));
}
else
{
{
item.SubItems[3].Text = Strings.NaN;
}
@ -173,7 +173,7 @@ namespace TBF.UI.Bench.Metrology
item.SubItems[3].Text = error.ToString(Config.Utils.SignificantDigitsToFmt(error, 5));
}
else
{
{
item.SubItems[3].Text = Strings.NaN;
}
@ -185,7 +185,7 @@ namespace TBF.UI.Bench.Metrology
{
}
else
{
{
double measurement;
if (Utils.TryParseEDouble(item.SubItems[1].Text, out measurement) && measurement != 0)
{

View File

@ -154,7 +154,7 @@ namespace TBF.UI.Bench.Metrology
item.SubItems[3].Text = error.ToString(Config.Utils.SignificantDigitsToFmt(error, 5));
}
else
{
{
item.SubItems[3].Text = Strings.NaN;
}
@ -173,7 +173,7 @@ namespace TBF.UI.Bench.Metrology
item.SubItems[3].Text = error.ToString(Config.Utils.SignificantDigitsToFmt(error, 5));
}
else
{
{
item.SubItems[3].Text = Strings.NaN;
}
@ -185,7 +185,7 @@ namespace TBF.UI.Bench.Metrology
{
}
else
{
{
double measurement;
if (Utils.TryParseEDouble(item.SubItems[1].Text, out measurement) && measurement != 0)
{

View File

@ -455,9 +455,7 @@ namespace TBF.UI.Process
double massDiff = ProcessData.Mass.Val - ProcessData.StartMass.Val;
massDiffLabel.Text = massDiff.ToString("F3");
double volumeCtv = 1000 * Config.Formulas.Buoyancy() * massDiff / Config.Formulas.WaterDensityFromTempPress((ProcessData.TempUp.Val + ProcessData.TempDown.Val) / 2,
(ProcessData.PressUp.Val + ProcessData.PressDown.Val) / 2,
Program.LocalSettings.RealDensity,
Program.LocalSettings.AtTemperature); /// [kg/m3]
(ProcessData.PressUp.Val + ProcessData.PressDown.Val) / 2);
volumeCtvLabel.Text = volumeCtv.ToString("F2");
double refError = Config.Formulas.ErrorFromVolumes(refVolume, volumeCtv);
refErrorLabel.Text = refError.ToString("F3");

View File

@ -484,9 +484,7 @@ namespace TBF.UI.Process
double massDiff = ProcessData.Mass.Val - ProcessData.StartMass.Val;
massDiffLabel.Text = massDiff.ToString("F3");
double volumeCtv = 1000 * Config.Formulas.Buoyancy() * massDiff / Config.Formulas.WaterDensityFromTempPress((ProcessData.TempUp.Val + ProcessData.TempDown.Val) / 2,
(ProcessData.PressUp.Val + ProcessData.PressDown.Val) / 2,
Program.LocalSettings.RealDensity,
Program.LocalSettings.AtTemperature); /// [kg/m3]
(ProcessData.PressUp.Val + ProcessData.PressDown.Val) / 2);
volumeCtvLabel.Text = volumeCtv.ToString("F2");
double refError = Config.Formulas.ErrorFromVolumes(refVolume, volumeCtv);
refErrorLabel.Text = refError.ToString("F3");

View File

@ -488,9 +488,7 @@ namespace TBF.UI.Process
double massDiff = ProcessData.Mass.Val - ProcessData.StartMass.Val;
massDiffLabel.Text = massDiff.ToString("F3");
double volumeCtv = 1000 * Config.Formulas.Buoyancy() * massDiff / Config.Formulas.WaterDensityFromTempPress((ProcessData.TempUp.Val + ProcessData.TempDown.Val) / 2,
(ProcessData.PressUp.Val + ProcessData.PressDown.Val) / 2,
Program.LocalSettings.RealDensity,
Program.LocalSettings.AtTemperature); /// [kg/m3]
(ProcessData.PressUp.Val + ProcessData.PressDown.Val) / 2);
volumeCtvLabel.Text = volumeCtv.ToString("F2");
double refError = Config.Formulas.ErrorFromVolumes(refVolume, volumeCtv);
refErrorLabel.Text = refError.ToString("F3");

View File

@ -455,9 +455,7 @@ namespace TBF.UI.Process
massDiffLabel.Text = massDiff.ToString("F3");
double volumeCtv = 1000 * Config.Formulas.Buoyancy() * massDiff
/ Config.Formulas.WaterDensityFromTempPress((ProcessData.TempUp.Val + ProcessData.TempDown.Val) / 2,
(ProcessData.PressUp.Val + ProcessData.PressDown.Val) / 2,
Program.LocalSettings.RealDensity,
Program.LocalSettings.AtTemperature); /// [kg/m3]
(ProcessData.PressUp.Val + ProcessData.PressDown.Val) / 2);
volumeCtvLabel.Text = volumeCtv.ToString("F2");
double refError = Config.Formulas.ErrorFromVolumes(refVolume, volumeCtv);
refErrorLabel.Text = refError.ToString("F3");