From 74f8c447831a5392dda9be9cf54fdaf5a22cb26f Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Wed, 18 Sep 2019 09:09:00 +0200 Subject: [PATCH] Config.Data.RealDensity etc., DataContainers.Density and Buoyancy components, related metrology tabs modified/created. --- Config/Data.cs | 6 +- Config/Formulas.cs | 37 ++--- Results/WMeterRsltItemSpec.cs | 6 +- .../BenchInfo/Munich/Component.cs | 47 ------- .../BenchInfo/Munich/ComponentCfg.cs | 48 ------- .../BenchInfo/Munich/ComponentCfgCtrl.cs | 88 ------------ .../Munich/ComponentCfgCtrl.designer.cs | 132 ------------------ .../BackupAndSecurityOptions}/Component.cs | 11 +- .../BackupAndSecurityOptions}/ComponentCfg.cs | 2 +- .../ComponentFactory.cs | 2 +- .../BenchInfo/Extended/Component.cs | 2 +- .../BenchInfo/Extended/ComponentCfg.cs | 2 +- .../BenchInfo/Extended/ComponentFactory.cs | 2 +- .../BenchInfo/iPerl/Component.cs | 2 +- .../BenchInfo/iPerl/ComponentCfg.cs | 2 +- .../BenchInfo/iPerl/ComponentFactory.cs | 2 +- .../DataContainers/Buoyancy/Component.cs | 39 ++++++ .../DataContainers/Buoyancy/ComponentCfg.cs | 118 ++++++++++++++++ .../Buoyancy/ComponentFactory.cs | 26 ++++ .../DataContainers/Density/Component.cs | 42 ++++++ .../DataContainers/Density/ComponentCfg.cs | 128 +++++++++++++++++ .../Density}/ComponentFactory.cs | 11 +- .../DataEntry/iPerl/CycleBeginningForm.cs | 4 +- .../GenericDevices/IBackupAndSecurity.cs | 17 --- TBF/BenchControl/Sequences/MainSeq.cs | 4 +- TBF/BenchControl/Sequences/ProcessData.cs | 1 - TBF/BenchControl/Sequences/SequenceBase.cs | 41 +++--- TBF/BenchControl/StateMachine.cs | 3 +- TBF/BenchControl/TbfComponents.cs | 9 +- .../FixedStartAdvancedSeq.cs | 4 +- .../FixedStartDeferredEvaluationSeq.cs | 4 +- .../FixedStartMassCollectionSeq.cs | 4 +- .../iPerlCommunicationSeq.cs | 4 +- TBF/LocalSettings.cs | 17 --- TBF/Resources/Strings.Designer.cs | 11 +- TBF/Resources/Strings.resx | 5 +- TBF/TBF.csproj | 46 +++--- TBF/UI/Bench/Metrology/MetrologyDlg.cs | 42 ++++-- .../Bench/Metrology/MetrologyDlgBalanceTab.cs | 6 +- .../MetrologyDlgBuoyancyTab.Designer.cs | 97 +++++++++++++ .../Metrology/MetrologyDlgBuoyancyTab.cs | 132 ++++++++++++++++++ .../Metrology/MetrologyDlgBuoyancyTab.resx} | 0 .../Bench/Metrology/MetrologyDlgDensityTab.cs | 59 +++++--- .../Metrology/MetrologyDlgPressMeterTab.cs | 6 +- .../Metrology/MetrologyDlgTempMeterTab.cs | 6 +- TBF/UI/Process/ProcessTabPageCtrl24.cs | 4 +- TBF/UI/Process/ProcessTabPageCtrl48.cs | 4 +- TBF/UI/Process/ProcessTabPageCtrl6.cs | 4 +- TBF/UI/Process/ProcessTabPageExCtrl.cs | 4 +- 49 files changed, 782 insertions(+), 511 deletions(-) delete mode 100644 TBF/BenchControl/BenchInfo/Munich/Component.cs delete mode 100644 TBF/BenchControl/BenchInfo/Munich/ComponentCfg.cs delete mode 100644 TBF/BenchControl/BenchInfo/Munich/ComponentCfgCtrl.cs delete mode 100644 TBF/BenchControl/BenchInfo/Munich/ComponentCfgCtrl.designer.cs rename TBF/BenchControl/{BackupAndSecurity/Default => DataContainers/BackupAndSecurityOptions}/Component.cs (67%) rename TBF/BenchControl/{BackupAndSecurity/Default => DataContainers/BackupAndSecurityOptions}/ComponentCfg.cs (98%) rename TBF/BenchControl/{BackupAndSecurity/Default => DataContainers/BackupAndSecurityOptions}/ComponentFactory.cs (92%) rename TBF/BenchControl/{ => DataContainers}/BenchInfo/Extended/Component.cs (95%) rename TBF/BenchControl/{ => DataContainers}/BenchInfo/Extended/ComponentCfg.cs (99%) rename TBF/BenchControl/{ => DataContainers}/BenchInfo/Extended/ComponentFactory.cs (92%) rename TBF/BenchControl/{ => DataContainers}/BenchInfo/iPerl/Component.cs (96%) rename TBF/BenchControl/{ => DataContainers}/BenchInfo/iPerl/ComponentCfg.cs (99%) rename TBF/BenchControl/{ => DataContainers}/BenchInfo/iPerl/ComponentFactory.cs (93%) create mode 100644 TBF/BenchControl/DataContainers/Buoyancy/Component.cs create mode 100644 TBF/BenchControl/DataContainers/Buoyancy/ComponentCfg.cs create mode 100644 TBF/BenchControl/DataContainers/Buoyancy/ComponentFactory.cs create mode 100644 TBF/BenchControl/DataContainers/Density/Component.cs create mode 100644 TBF/BenchControl/DataContainers/Density/ComponentCfg.cs rename TBF/BenchControl/{BenchInfo/Munich => DataContainers/Density}/ComponentFactory.cs (63%) delete mode 100644 TBF/BenchControl/GenericDevices/IBackupAndSecurity.cs create mode 100644 TBF/UI/Bench/Metrology/MetrologyDlgBuoyancyTab.Designer.cs create mode 100644 TBF/UI/Bench/Metrology/MetrologyDlgBuoyancyTab.cs rename TBF/{BenchControl/BenchInfo/Munich/ComponentCfgCtrl.resx => UI/Bench/Metrology/MetrologyDlgBuoyancyTab.resx} (100%) diff --git a/Config/Data.cs b/Config/Data.cs index 9e6df3a55..34dd6e534 100644 --- a/Config/Data.cs +++ b/Config/Data.cs @@ -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; + } } diff --git a/Config/Formulas.cs b/Config/Formulas.cs index ba6199e50..212c03eb0 100644 --- a/Config/Formulas.cs +++ b/Config/Formulas.cs @@ -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; + /// /// Constructor @@ -153,9 +162,9 @@ namespace Config /// /// Temperature in [°C] /// Density in [kg/m3] - 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()); } /// @@ -163,7 +172,7 @@ namespace Config /// /// Temperature in [°C] /// Density in [kg/m3] - 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; - } } } diff --git a/Results/WMeterRsltItemSpec.cs b/Results/WMeterRsltItemSpec.cs index 926a43a10..d1254c5ac 100644 --- a/Results/WMeterRsltItemSpec.cs +++ b/Results/WMeterRsltItemSpec.cs @@ -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; /// diff --git a/TBF/BenchControl/BenchInfo/Munich/Component.cs b/TBF/BenchControl/BenchInfo/Munich/Component.cs deleted file mode 100644 index 53da1d20b..000000000 --- a/TBF/BenchControl/BenchInfo/Munich/Component.cs +++ /dev/null @@ -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 -{ - /// - /// Holds information identifying the test bench. - /// - 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()); - } - } -} diff --git a/TBF/BenchControl/BenchInfo/Munich/ComponentCfg.cs b/TBF/BenchControl/BenchInfo/Munich/ComponentCfg.cs deleted file mode 100644 index fe7d53696..000000000 --- a/TBF/BenchControl/BenchInfo/Munich/ComponentCfg.cs +++ /dev/null @@ -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 -{ - /// - /// Holds information identifying the test bench - serializable configuration. - /// - 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); - } - } -} diff --git a/TBF/BenchControl/BenchInfo/Munich/ComponentCfgCtrl.cs b/TBF/BenchControl/BenchInfo/Munich/ComponentCfgCtrl.cs deleted file mode 100644 index da08cf690..000000000 --- a/TBF/BenchControl/BenchInfo/Munich/ComponentCfgCtrl.cs +++ /dev/null @@ -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; - } - } -} diff --git a/TBF/BenchControl/BenchInfo/Munich/ComponentCfgCtrl.designer.cs b/TBF/BenchControl/BenchInfo/Munich/ComponentCfgCtrl.designer.cs deleted file mode 100644 index d714ecd60..000000000 --- a/TBF/BenchControl/BenchInfo/Munich/ComponentCfgCtrl.designer.cs +++ /dev/null @@ -1,132 +0,0 @@ -/// -/// Copyright (c) 2013-2015 Sensus Metering Systems -/// -namespace TBF.BenchControl.BenchInfo.Munich -{ - partial class ComponentCfgCtrl - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.nameTextBox = new System.Windows.Forms.TextBox(); - this.nameLabel = new System.Windows.Forms.Label(); - this.classNameLabel = new System.Windows.Forms.Label(); - this.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; - } -} diff --git a/TBF/BenchControl/BackupAndSecurity/Default/Component.cs b/TBF/BenchControl/DataContainers/BackupAndSecurityOptions/Component.cs similarity index 67% rename from TBF/BenchControl/BackupAndSecurity/Default/Component.cs rename to TBF/BenchControl/DataContainers/BackupAndSecurityOptions/Component.cs index 7d45e20e7..1cceb3fe1 100644 --- a/TBF/BenchControl/BackupAndSecurity/Default/Component.cs +++ b/TBF/BenchControl/DataContainers/BackupAndSecurityOptions/Component.cs @@ -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 { /// /// Holds backup and security options. /// - 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()); } diff --git a/TBF/BenchControl/BackupAndSecurity/Default/ComponentCfg.cs b/TBF/BenchControl/DataContainers/BackupAndSecurityOptions/ComponentCfg.cs similarity index 98% rename from TBF/BenchControl/BackupAndSecurity/Default/ComponentCfg.cs rename to TBF/BenchControl/DataContainers/BackupAndSecurityOptions/ComponentCfg.cs index 5b3b4162c..53777d178 100644 --- a/TBF/BenchControl/BackupAndSecurity/Default/ComponentCfg.cs +++ b/TBF/BenchControl/DataContainers/BackupAndSecurityOptions/ComponentCfg.cs @@ -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 { /// /// Holds backup and security options - serializable configuration. diff --git a/TBF/BenchControl/BackupAndSecurity/Default/ComponentFactory.cs b/TBF/BenchControl/DataContainers/BackupAndSecurityOptions/ComponentFactory.cs similarity index 92% rename from TBF/BenchControl/BackupAndSecurity/Default/ComponentFactory.cs rename to TBF/BenchControl/DataContainers/BackupAndSecurityOptions/ComponentFactory.cs index a491f092e..b02d82cf2 100644 --- a/TBF/BenchControl/BackupAndSecurity/Default/ComponentFactory.cs +++ b/TBF/BenchControl/DataContainers/BackupAndSecurityOptions/ComponentFactory.cs @@ -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 { diff --git a/TBF/BenchControl/BenchInfo/Extended/Component.cs b/TBF/BenchControl/DataContainers/BenchInfo/Extended/Component.cs similarity index 95% rename from TBF/BenchControl/BenchInfo/Extended/Component.cs rename to TBF/BenchControl/DataContainers/BenchInfo/Extended/Component.cs index 2c95e465f..b6468ef34 100644 --- a/TBF/BenchControl/BenchInfo/Extended/Component.cs +++ b/TBF/BenchControl/DataContainers/BenchInfo/Extended/Component.cs @@ -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 { /// /// Holds information identifying the test bench. diff --git a/TBF/BenchControl/BenchInfo/Extended/ComponentCfg.cs b/TBF/BenchControl/DataContainers/BenchInfo/Extended/ComponentCfg.cs similarity index 99% rename from TBF/BenchControl/BenchInfo/Extended/ComponentCfg.cs rename to TBF/BenchControl/DataContainers/BenchInfo/Extended/ComponentCfg.cs index 93baff9ae..0f9ca42f5 100644 --- a/TBF/BenchControl/BenchInfo/Extended/ComponentCfg.cs +++ b/TBF/BenchControl/DataContainers/BenchInfo/Extended/ComponentCfg.cs @@ -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 { /// /// Holds information identifying the test bench - serializable configuration. diff --git a/TBF/BenchControl/BenchInfo/Extended/ComponentFactory.cs b/TBF/BenchControl/DataContainers/BenchInfo/Extended/ComponentFactory.cs similarity index 92% rename from TBF/BenchControl/BenchInfo/Extended/ComponentFactory.cs rename to TBF/BenchControl/DataContainers/BenchInfo/Extended/ComponentFactory.cs index a2330c01b..211cdc434 100644 --- a/TBF/BenchControl/BenchInfo/Extended/ComponentFactory.cs +++ b/TBF/BenchControl/DataContainers/BenchInfo/Extended/ComponentFactory.cs @@ -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 { diff --git a/TBF/BenchControl/BenchInfo/iPerl/Component.cs b/TBF/BenchControl/DataContainers/BenchInfo/iPerl/Component.cs similarity index 96% rename from TBF/BenchControl/BenchInfo/iPerl/Component.cs rename to TBF/BenchControl/DataContainers/BenchInfo/iPerl/Component.cs index c5de0fad6..189bf08d6 100644 --- a/TBF/BenchControl/BenchInfo/iPerl/Component.cs +++ b/TBF/BenchControl/DataContainers/BenchInfo/iPerl/Component.cs @@ -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 { /// /// Holds information identifying the test bench. diff --git a/TBF/BenchControl/BenchInfo/iPerl/ComponentCfg.cs b/TBF/BenchControl/DataContainers/BenchInfo/iPerl/ComponentCfg.cs similarity index 99% rename from TBF/BenchControl/BenchInfo/iPerl/ComponentCfg.cs rename to TBF/BenchControl/DataContainers/BenchInfo/iPerl/ComponentCfg.cs index f20b600b1..d6ebbafd8 100644 --- a/TBF/BenchControl/BenchInfo/iPerl/ComponentCfg.cs +++ b/TBF/BenchControl/DataContainers/BenchInfo/iPerl/ComponentCfg.cs @@ -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 { /// /// Holds information identifying the test bench - serializable configuration. diff --git a/TBF/BenchControl/BenchInfo/iPerl/ComponentFactory.cs b/TBF/BenchControl/DataContainers/BenchInfo/iPerl/ComponentFactory.cs similarity index 93% rename from TBF/BenchControl/BenchInfo/iPerl/ComponentFactory.cs rename to TBF/BenchControl/DataContainers/BenchInfo/iPerl/ComponentFactory.cs index 13498dd05..d0d533a58 100644 --- a/TBF/BenchControl/BenchInfo/iPerl/ComponentFactory.cs +++ b/TBF/BenchControl/DataContainers/BenchInfo/iPerl/ComponentFactory.cs @@ -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 { diff --git a/TBF/BenchControl/DataContainers/Buoyancy/Component.cs b/TBF/BenchControl/DataContainers/Buoyancy/Component.cs new file mode 100644 index 000000000..c44d2de6e --- /dev/null +++ b/TBF/BenchControl/DataContainers/Buoyancy/Component.cs @@ -0,0 +1,39 @@ +/// +/// Copyright (c) 2019 Sensus Slovensko a.s. +/// +using System; +using log4net; + +namespace TBF.BenchControl.DataContainers.Buoyancy +{ + /// + /// Holds measured (true) buoyancy value. + /// + 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()); + } + } +} diff --git a/TBF/BenchControl/DataContainers/Buoyancy/ComponentCfg.cs b/TBF/BenchControl/DataContainers/Buoyancy/ComponentCfg.cs new file mode 100644 index 000000000..7e5cbd28b --- /dev/null +++ b/TBF/BenchControl/DataContainers/Buoyancy/ComponentCfg.cs @@ -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 +{ + /// + /// Holds backup and security options - serializable configuration. + /// + 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 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 + } + } +} diff --git a/TBF/BenchControl/DataContainers/Buoyancy/ComponentFactory.cs b/TBF/BenchControl/DataContainers/Buoyancy/ComponentFactory.cs new file mode 100644 index 000000000..735e7c59d --- /dev/null +++ b/TBF/BenchControl/DataContainers/Buoyancy/ComponentFactory.cs @@ -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 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); + } + } +} diff --git a/TBF/BenchControl/DataContainers/Density/Component.cs b/TBF/BenchControl/DataContainers/Density/Component.cs new file mode 100644 index 000000000..ab49cda6d --- /dev/null +++ b/TBF/BenchControl/DataContainers/Density/Component.cs @@ -0,0 +1,42 @@ +/// +/// Copyright (c) 2019 Sensus Slovensko a.s. +/// +using System; +using log4net; + +namespace TBF.BenchControl.DataContainers.Density +{ + /// + /// Holds measured (true) density value. + /// + 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()); + } + } +} diff --git a/TBF/BenchControl/DataContainers/Density/ComponentCfg.cs b/TBF/BenchControl/DataContainers/Density/ComponentCfg.cs new file mode 100644 index 000000000..c34b68ea5 --- /dev/null +++ b/TBF/BenchControl/DataContainers/Density/ComponentCfg.cs @@ -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 +{ + /// + /// Holds backup and security options - serializable configuration. + /// + 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 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 + } + } +} diff --git a/TBF/BenchControl/BenchInfo/Munich/ComponentFactory.cs b/TBF/BenchControl/DataContainers/Density/ComponentFactory.cs similarity index 63% rename from TBF/BenchControl/BenchInfo/Munich/ComponentFactory.cs rename to TBF/BenchControl/DataContainers/Density/ComponentFactory.cs index f863e6f08..87aee75c2 100644 --- a/TBF/BenchControl/BenchInfo/Munich/ComponentFactory.cs +++ b/TBF/BenchControl/DataContainers/Density/ComponentFactory.cs @@ -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 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); } } } diff --git a/TBF/BenchControl/DataEntry/iPerl/CycleBeginningForm.cs b/TBF/BenchControl/DataEntry/iPerl/CycleBeginningForm.cs index d0a272108..3617e61b1 100644 --- a/TBF/BenchControl/DataEntry/iPerl/CycleBeginningForm.cs +++ b/TBF/BenchControl/DataEntry/iPerl/CycleBeginningForm.cs @@ -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)) { diff --git a/TBF/BenchControl/GenericDevices/IBackupAndSecurity.cs b/TBF/BenchControl/GenericDevices/IBackupAndSecurity.cs deleted file mode 100644 index 05f07e948..000000000 --- a/TBF/BenchControl/GenericDevices/IBackupAndSecurity.cs +++ /dev/null @@ -1,17 +0,0 @@ -/// -/// Copyright (c) 2019 Sensus Slovensko a.s. -/// -using Config.Entities; -using TBF.BenchControl.Generic; - -namespace TBF.BenchControl.GenericDevices -{ - /// - /// Backup and security options - /// - public interface IBackupAndSecurity : IComponent - { - int MinPasswdLength { get; } - int PasswdExpirationPeriodDays { get; } - } -} diff --git a/TBF/BenchControl/Sequences/MainSeq.cs b/TBF/BenchControl/Sequences/MainSeq.cs index 5220aab40..1626acef2 100644 --- a/TBF/BenchControl/Sequences/MainSeq.cs +++ b/TBF/BenchControl/Sequences/MainSeq.cs @@ -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())); } diff --git a/TBF/BenchControl/Sequences/ProcessData.cs b/TBF/BenchControl/Sequences/ProcessData.cs index 572edc1b8..5a5addbd8 100644 --- a/TBF/BenchControl/Sequences/ProcessData.cs +++ b/TBF/BenchControl/Sequences/ProcessData.cs @@ -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; diff --git a/TBF/BenchControl/Sequences/SequenceBase.cs b/TBF/BenchControl/Sequences/SequenceBase.cs index 84432cbd1..b8be7f061 100644 --- a/TBF/BenchControl/Sequences/SequenceBase.cs +++ b/TBF/BenchControl/Sequences/SequenceBase.cs @@ -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(); diff --git a/TBF/BenchControl/StateMachine.cs b/TBF/BenchControl/StateMachine.cs index 1be934bb7..75b079bbb 100644 --- a/TBF/BenchControl/StateMachine.cs +++ b/TBF/BenchControl/StateMachine.cs @@ -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; diff --git a/TBF/BenchControl/TbfComponents.cs b/TBF/BenchControl/TbfComponents.cs index 3dd6ecca6..cb24355f7 100644 --- a/TBF/BenchControl/TbfComponents.cs +++ b/TBF/BenchControl/TbfComponents.cs @@ -15,10 +15,11 @@ namespace TBF.BenchControl { Factories = new List(); - 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()); diff --git a/TBF/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs b/TBF/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs index 3eea392b2..8688f4f64 100644 --- a/TBF/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs +++ b/TBF/BenchControl/TestMethods/FixedStartAdvanced/FixedStartAdvancedSeq.cs @@ -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; diff --git a/TBF/BenchControl/TestMethods/FixedStartDeferredEvaluation/FixedStartDeferredEvaluationSeq.cs b/TBF/BenchControl/TestMethods/FixedStartDeferredEvaluation/FixedStartDeferredEvaluationSeq.cs index ab2ee88c2..0ed886b20 100644 --- a/TBF/BenchControl/TestMethods/FixedStartDeferredEvaluation/FixedStartDeferredEvaluationSeq.cs +++ b/TBF/BenchControl/TestMethods/FixedStartDeferredEvaluation/FixedStartDeferredEvaluationSeq.cs @@ -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; diff --git a/TBF/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs b/TBF/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs index 41e2d47d8..4a9e21164 100644 --- a/TBF/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs +++ b/TBF/BenchControl/TestMethods/FixedStartMassCollection/FixedStartMassCollectionSeq.cs @@ -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; diff --git a/TBF/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationSeq.cs b/TBF/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationSeq.cs index 63307b50c..49995997c 100644 --- a/TBF/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationSeq.cs +++ b/TBF/BenchControl/TestMethods/iPerlCommunication/iPerlCommunicationSeq.cs @@ -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); diff --git a/TBF/LocalSettings.cs b/TBF/LocalSettings.cs index 634734c7b..3fc26d3df 100644 --- a/TBF/LocalSettings.cs +++ b/TBF/LocalSettings.cs @@ -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 /// public void Save() { - UpdateResultsOutputData(); - try { #if false @@ -423,16 +416,6 @@ namespace TBF } - /// - /// To be able to have RealDensity and AtTemperatire in reports. - /// - void UpdateResultsOutputData() - { - Results.WMeterRsltItemSpec.RealDensity = this.RealDensity; - Results.WMeterRsltItemSpec.AtTemperature = this.AtTemperature; - } - - /// /// Updates history stored in a string array by a new latest string. /// diff --git a/TBF/Resources/Strings.Designer.cs b/TBF/Resources/Strings.Designer.cs index ae06bceea..72b730725 100644 --- a/TBF/Resources/Strings.Designer.cs +++ b/TBF/Resources/Strings.Designer.cs @@ -2095,7 +2095,7 @@ namespace TBF.Resources { } /// - /// 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.. /// internal static string Invalid_buoyancy_parameter_Correct_pls { get { @@ -2112,6 +2112,15 @@ namespace TBF.Resources { } } + /// + /// Looks up a localized string similar to Invalid density parameters.\r\nCorrect them please.. + /// + internal static string Invalid_density_parameter_Correct_pls { + get { + return ResourceManager.GetString("Invalid_density_parameter_Correct_pls", resourceCulture); + } + } + /// /// Looks up a localized string similar to Invalid password. /// diff --git a/TBF/Resources/Strings.resx b/TBF/Resources/Strings.resx index 541d811bc..7ec5826dc 100644 --- a/TBF/Resources/Strings.resx +++ b/TBF/Resources/Strings.resx @@ -1154,7 +1154,7 @@ Continue in the cycle after this test? - At least one of Buoyancy parameters is invalid,\r\ncorrect it please. + Buoyancy is invalid, correct it please. Invalid calibration information. Correct it please. @@ -2062,4 +2062,7 @@ No info available + + Invalid density parameters.\r\nCorrect them please. + \ No newline at end of file diff --git a/TBF/TBF.csproj b/TBF/TBF.csproj index 7d73cbda1..83753ce39 100644 --- a/TBF/TBF.csproj +++ b/TBF/TBF.csproj @@ -158,24 +158,6 @@ AmbientCfgCtrl.cs - - - - - - - - - - - - - UserControl - - - ComponentCfgCtrl.cs - - Form @@ -198,6 +180,21 @@ ComponentCfgCtrl.cs + + + + + + + + + + + + + + + Form @@ -597,7 +594,6 @@ ValveCfgCtrl.cs - @@ -2006,6 +2002,12 @@ MetrologyDlgBalanceTab.cs + + UserControl + + + MetrologyDlgBuoyancyTab.cs + UserControl @@ -2383,9 +2385,6 @@ AmbientCfgCtrl.cs - - ComponentCfgCtrl.cs - ComponentParametersDlg.cs @@ -3031,6 +3030,9 @@ MetrologyDlgBalanceTab.cs + + MetrologyDlgBuoyancyTab.cs + MetrologyDlgDensityTab.cs diff --git a/TBF/UI/Bench/Metrology/MetrologyDlg.cs b/TBF/UI/Bench/Metrology/MetrologyDlg.cs index e91f6ba5d..2d5f6134d 100644 --- a/TBF/UI/Bench/Metrology/MetrologyDlg.cs +++ b/TBF/UI/Bench/Metrology/MetrologyDlg.cs @@ -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); } diff --git a/TBF/UI/Bench/Metrology/MetrologyDlgBalanceTab.cs b/TBF/UI/Bench/Metrology/MetrologyDlgBalanceTab.cs index 59d694d4e..b0c44675d 100644 --- a/TBF/UI/Bench/Metrology/MetrologyDlgBalanceTab.cs +++ b/TBF/UI/Bench/Metrology/MetrologyDlgBalanceTab.cs @@ -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) { diff --git a/TBF/UI/Bench/Metrology/MetrologyDlgBuoyancyTab.Designer.cs b/TBF/UI/Bench/Metrology/MetrologyDlgBuoyancyTab.Designer.cs new file mode 100644 index 000000000..94ddd698e --- /dev/null +++ b/TBF/UI/Bench/Metrology/MetrologyDlgBuoyancyTab.Designer.cs @@ -0,0 +1,97 @@ +/// +/// Copyright (c) 2013-2015 Senus Slovensko a.s. +/// +namespace TBF.UI.Bench.Metrology +{ + partial class MetrologyDlgBuoyancyTab + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.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; + } +} diff --git a/TBF/UI/Bench/Metrology/MetrologyDlgBuoyancyTab.cs b/TBF/UI/Bench/Metrology/MetrologyDlgBuoyancyTab.cs new file mode 100644 index 000000000..01ff78df4 --- /dev/null +++ b/TBF/UI/Bench/Metrology/MetrologyDlgBuoyancyTab.cs @@ -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)); + + /// + /// Component entity that has a list of 'measurement-correction' pairs + /// to be updated in the database on OK. + /// + public Component MeterEntity + { + get { return meterEntity; } + set { meterEntity = value; } + } + Component meterEntity; + + /// + /// Buoyancy configuration + /// + public BenchControl.DataContainers.Buoyancy.ComponentCfg BuoyancyCfg; + + /// + /// A list of 'measurement-correction' pairs to be deleted from the database on OK. + /// + public IList ToBeRemoved + { + get { return toBeRemoved; } + set { toBeRemoved = value; } + } + IList toBeRemoved; + + MetrologyDlg parent; + bool unlocked; + + public MetrologyDlgBuoyancyTab() + { + InitializeComponent(); + toBeRemoved = new List(); + 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 renmInfo) + { + return string.Empty; + } + + public void UpdateRelatedItems(Dictionary renameInfo) + { + } + } +} diff --git a/TBF/BenchControl/BenchInfo/Munich/ComponentCfgCtrl.resx b/TBF/UI/Bench/Metrology/MetrologyDlgBuoyancyTab.resx similarity index 100% rename from TBF/BenchControl/BenchInfo/Munich/ComponentCfgCtrl.resx rename to TBF/UI/Bench/Metrology/MetrologyDlgBuoyancyTab.resx diff --git a/TBF/UI/Bench/Metrology/MetrologyDlgDensityTab.cs b/TBF/UI/Bench/Metrology/MetrologyDlgDensityTab.cs index 78166b680..b64812642 100644 --- a/TBF/UI/Bench/Metrology/MetrologyDlgDensityTab.cs +++ b/TBF/UI/Bench/Metrology/MetrologyDlgDensityTab.cs @@ -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 /// public Component MeterEntity { - get { return null; } - set { } - } + get { return meterEntity; } + set { meterEntity = value; } + } + Component meterEntity; + + /// + /// Density configuration + /// + public BenchControl.DataContainers.Density.ComponentCfg DensityCfg; /// /// 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() diff --git a/TBF/UI/Bench/Metrology/MetrologyDlgPressMeterTab.cs b/TBF/UI/Bench/Metrology/MetrologyDlgPressMeterTab.cs index 5f4e95d24..e1058b835 100644 --- a/TBF/UI/Bench/Metrology/MetrologyDlgPressMeterTab.cs +++ b/TBF/UI/Bench/Metrology/MetrologyDlgPressMeterTab.cs @@ -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) { diff --git a/TBF/UI/Bench/Metrology/MetrologyDlgTempMeterTab.cs b/TBF/UI/Bench/Metrology/MetrologyDlgTempMeterTab.cs index 9ef457e1d..694088dfb 100644 --- a/TBF/UI/Bench/Metrology/MetrologyDlgTempMeterTab.cs +++ b/TBF/UI/Bench/Metrology/MetrologyDlgTempMeterTab.cs @@ -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) { diff --git a/TBF/UI/Process/ProcessTabPageCtrl24.cs b/TBF/UI/Process/ProcessTabPageCtrl24.cs index 26d2e941e..b9198e919 100644 --- a/TBF/UI/Process/ProcessTabPageCtrl24.cs +++ b/TBF/UI/Process/ProcessTabPageCtrl24.cs @@ -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"); diff --git a/TBF/UI/Process/ProcessTabPageCtrl48.cs b/TBF/UI/Process/ProcessTabPageCtrl48.cs index d28684e62..79c8d23f7 100644 --- a/TBF/UI/Process/ProcessTabPageCtrl48.cs +++ b/TBF/UI/Process/ProcessTabPageCtrl48.cs @@ -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"); diff --git a/TBF/UI/Process/ProcessTabPageCtrl6.cs b/TBF/UI/Process/ProcessTabPageCtrl6.cs index 5b4653f8f..c12648b33 100644 --- a/TBF/UI/Process/ProcessTabPageCtrl6.cs +++ b/TBF/UI/Process/ProcessTabPageCtrl6.cs @@ -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"); diff --git a/TBF/UI/Process/ProcessTabPageExCtrl.cs b/TBF/UI/Process/ProcessTabPageExCtrl.cs index a8b207c55..f79b93e11 100644 --- a/TBF/UI/Process/ProcessTabPageExCtrl.cs +++ b/TBF/UI/Process/ProcessTabPageExCtrl.cs @@ -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");