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

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