Custom units in MetrologyDlg tabs Balance, FlowMeter, PressMeter and TempMeter, ver. 3.3.1928
This commit is contained in:
parent
751f3b29bb
commit
01523d3765
@ -5,7 +5,7 @@ namespace Common
|
|||||||
public interface IMeasurementCorrection
|
public interface IMeasurementCorrection
|
||||||
{
|
{
|
||||||
int RangeIx { get; set; }
|
int RangeIx { get; set; }
|
||||||
float Measurement { get; set; }
|
double Measurement { get; set; }
|
||||||
float Correction { get; set; }
|
double Correction { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
///
|
///
|
||||||
/// Copyright (c) 2021 Sensus Slovensko a.s.
|
/// Copyright (c) 2021-2022 Sensus Slovensko a.s.
|
||||||
///
|
///
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
@ -14,6 +14,12 @@ namespace Common
|
|||||||
return string.Format("{0} ({1}/{2})", name, repetitionNr, repeats);
|
return string.Format("{0} ({1}/{2})", name, repetitionNr, repeats);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string ToNiceString(double value, int sigDigits)
|
||||||
|
{
|
||||||
|
string format = SignificantDigitsToFmt(value, sigDigits);
|
||||||
|
return (format == "F0") ? value.ToString("F0") : value.ToString(format).TrimEnd(new char[] { '0' });
|
||||||
|
}
|
||||||
|
|
||||||
public static string SignificantDigitsToFmt(double value, int sigDigits)
|
public static string SignificantDigitsToFmt(double value, int sigDigits)
|
||||||
{
|
{
|
||||||
if (sigDigits == 6)
|
if (sigDigits == 6)
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
///
|
///
|
||||||
/// Copyright (c) 2013-2021 Sensus Slovensko a.s.
|
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
|
||||||
///
|
///
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Config.Entities
|
namespace Config.Entities
|
||||||
{
|
{
|
||||||
public class MeasurementCorrection : Common.IMeasurementCorrection
|
public class MeasurementCorrection : Common.IMeasurementCorrection, IComparable<MeasurementCorrection>
|
||||||
{
|
{
|
||||||
public virtual int Id { get; protected set; }
|
public virtual int Id { get; protected set; }
|
||||||
public virtual int RangeIx { get; set; } /// 0..5
|
public virtual int RangeIx { get; set; } /// 0..5
|
||||||
public virtual float Measurement { get; set; }
|
public virtual double Measurement { get; set; }
|
||||||
public virtual float Correction { get; set; }
|
public virtual double Correction { get; set; }
|
||||||
|
|
||||||
public MeasurementCorrection()
|
public MeasurementCorrection()
|
||||||
{
|
{
|
||||||
@ -23,6 +23,11 @@ namespace Config.Entities
|
|||||||
RangeIx = rangeIx;
|
RangeIx = rangeIx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual int CompareTo(MeasurementCorrection other)
|
||||||
|
{
|
||||||
|
return (Measurement > other.Measurement) ? 1 : ((Measurement == other.Measurement) ? 0 : -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Calculates corrected value from a list of corrections by interpolation.
|
/// Calculates corrected value from a list of corrections by interpolation.
|
||||||
@ -76,5 +81,10 @@ namespace Config.Entities
|
|||||||
/// rawValue is above the highest value in the correction table
|
/// rawValue is above the highest value in the correction table
|
||||||
return corrections[corrections.Count - 1].Correction;
|
return corrections[corrections.Count - 1].Correction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return string.Format("{0} {1} ({2})", Measurement, Correction, RangeIx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
|||||||
// Build Number
|
// Build Number
|
||||||
// Revision
|
// Revision
|
||||||
//
|
//
|
||||||
[assembly: AssemblyVersion("3.2.1913.0")]
|
[assembly: AssemblyVersion("3.3.1928.0")]
|
||||||
[assembly: AssemblyFileVersion("3.2.1913.0")]
|
[assembly: AssemblyFileVersion("3.3.1928.0")]
|
||||||
|
|||||||
@ -3,7 +3,6 @@
|
|||||||
///
|
///
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using NHibernate;
|
using NHibernate;
|
||||||
using Common;
|
|
||||||
using Config.Entities;
|
using Config.Entities;
|
||||||
|
|
||||||
namespace TBF.UI.Bench.Metrology
|
namespace TBF.UI.Bench.Metrology
|
||||||
|
|||||||
@ -33,6 +33,8 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
{
|
{
|
||||||
this.cmpntNameLabel = new System.Windows.Forms.Label();
|
this.cmpntNameLabel = new System.Windows.Forms.Label();
|
||||||
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
||||||
|
this.unitLabel = new System.Windows.Forms.Label();
|
||||||
|
this.unitComboBox = new System.Windows.Forms.ComboBox();
|
||||||
this.calibrationGroupBox = new System.Windows.Forms.GroupBox();
|
this.calibrationGroupBox = new System.Windows.Forms.GroupBox();
|
||||||
this.calibExpirationDateTimePicker = new System.Windows.Forms.DateTimePicker();
|
this.calibExpirationDateTimePicker = new System.Windows.Forms.DateTimePicker();
|
||||||
this.calibDateTimePicker = new System.Windows.Forms.DateTimePicker();
|
this.calibDateTimePicker = new System.Windows.Forms.DateTimePicker();
|
||||||
@ -87,6 +89,8 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
//
|
//
|
||||||
// splitContainer1.Panel1
|
// splitContainer1.Panel1
|
||||||
//
|
//
|
||||||
|
this.splitContainer1.Panel1.Controls.Add(this.unitLabel);
|
||||||
|
this.splitContainer1.Panel1.Controls.Add(this.unitComboBox);
|
||||||
this.splitContainer1.Panel1.Controls.Add(this.calibrationGroupBox);
|
this.splitContainer1.Panel1.Controls.Add(this.calibrationGroupBox);
|
||||||
this.splitContainer1.Panel1.Controls.Add(this.buoancyGroupBox);
|
this.splitContainer1.Panel1.Controls.Add(this.buoancyGroupBox);
|
||||||
this.splitContainer1.Panel1.Controls.Add(this.nameGroupBox);
|
this.splitContainer1.Panel1.Controls.Add(this.nameGroupBox);
|
||||||
@ -99,6 +103,24 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
this.splitContainer1.SplitterDistance = 150;
|
this.splitContainer1.SplitterDistance = 150;
|
||||||
this.splitContainer1.TabIndex = 1;
|
this.splitContainer1.TabIndex = 1;
|
||||||
//
|
//
|
||||||
|
// unitLabel
|
||||||
|
//
|
||||||
|
this.unitLabel.AutoSize = true;
|
||||||
|
this.unitLabel.Location = new System.Drawing.Point(507, 116);
|
||||||
|
this.unitLabel.Name = "unitLabel";
|
||||||
|
this.unitLabel.Size = new System.Drawing.Size(68, 13);
|
||||||
|
this.unitLabel.TabIndex = 12;
|
||||||
|
this.unitLabel.Text = "Unit of mass:";
|
||||||
|
//
|
||||||
|
// unitComboBox
|
||||||
|
//
|
||||||
|
this.unitComboBox.FormattingEnabled = true;
|
||||||
|
this.unitComboBox.Location = new System.Drawing.Point(592, 113);
|
||||||
|
this.unitComboBox.Name = "unitComboBox";
|
||||||
|
this.unitComboBox.Size = new System.Drawing.Size(62, 21);
|
||||||
|
this.unitComboBox.TabIndex = 11;
|
||||||
|
this.unitComboBox.SelectedIndexChanged += new System.EventHandler(this.unitComboBox_SelectedIndexChanged);
|
||||||
|
//
|
||||||
// calibrationGroupBox
|
// calibrationGroupBox
|
||||||
//
|
//
|
||||||
this.calibrationGroupBox.Controls.Add(this.calibExpirationDateTimePicker);
|
this.calibrationGroupBox.Controls.Add(this.calibExpirationDateTimePicker);
|
||||||
@ -315,7 +337,7 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
// correctedLabel
|
// correctedLabel
|
||||||
//
|
//
|
||||||
this.correctedLabel.AutoSize = true;
|
this.correctedLabel.AutoSize = true;
|
||||||
this.correctedLabel.Location = new System.Drawing.Point(17, 40);
|
this.correctedLabel.Location = new System.Drawing.Point(11, 40);
|
||||||
this.correctedLabel.Name = "correctedLabel";
|
this.correctedLabel.Name = "correctedLabel";
|
||||||
this.correctedLabel.Size = new System.Drawing.Size(53, 13);
|
this.correctedLabel.Size = new System.Drawing.Size(53, 13);
|
||||||
this.correctedLabel.TabIndex = 3;
|
this.correctedLabel.TabIndex = 3;
|
||||||
@ -324,7 +346,7 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
// measuredLabel
|
// measuredLabel
|
||||||
//
|
//
|
||||||
this.measuredLabel.AutoSize = true;
|
this.measuredLabel.AutoSize = true;
|
||||||
this.measuredLabel.Location = new System.Drawing.Point(17, 18);
|
this.measuredLabel.Location = new System.Drawing.Point(11, 18);
|
||||||
this.measuredLabel.Name = "measuredLabel";
|
this.measuredLabel.Name = "measuredLabel";
|
||||||
this.measuredLabel.Size = new System.Drawing.Size(54, 13);
|
this.measuredLabel.Size = new System.Drawing.Size(54, 13);
|
||||||
this.measuredLabel.TabIndex = 2;
|
this.measuredLabel.TabIndex = 2;
|
||||||
@ -354,6 +376,7 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
this.Size = new System.Drawing.Size(668, 400);
|
this.Size = new System.Drawing.Size(668, 400);
|
||||||
this.Load += new System.EventHandler(this.MetrologyDlgBalanceTab_Load);
|
this.Load += new System.EventHandler(this.MetrologyDlgBalanceTab_Load);
|
||||||
this.splitContainer1.Panel1.ResumeLayout(false);
|
this.splitContainer1.Panel1.ResumeLayout(false);
|
||||||
|
this.splitContainer1.Panel1.PerformLayout();
|
||||||
this.splitContainer1.Panel2.ResumeLayout(false);
|
this.splitContainer1.Panel2.ResumeLayout(false);
|
||||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
|
||||||
this.splitContainer1.ResumeLayout(false);
|
this.splitContainer1.ResumeLayout(false);
|
||||||
@ -398,5 +421,7 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
private System.Windows.Forms.Label calibCertificateNrLabel;
|
private System.Windows.Forms.Label calibCertificateNrLabel;
|
||||||
private System.Windows.Forms.DateTimePicker calibExpirationDateTimePicker;
|
private System.Windows.Forms.DateTimePicker calibExpirationDateTimePicker;
|
||||||
private System.Windows.Forms.DateTimePicker calibDateTimePicker;
|
private System.Windows.Forms.DateTimePicker calibDateTimePicker;
|
||||||
|
private System.Windows.Forms.Label unitLabel;
|
||||||
|
private System.Windows.Forms.ComboBox unitComboBox;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
///
|
///
|
||||||
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
|
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
|
||||||
///
|
///
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -18,16 +18,18 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
{
|
{
|
||||||
static readonly ILog log = LogManager.GetLogger(typeof(MetrologyDlgBalanceTab));
|
static readonly ILog log = LogManager.GetLogger(typeof(MetrologyDlgBalanceTab));
|
||||||
|
|
||||||
|
public const int SignifDigits = 5;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Component entity that has a list of 'measurement-correction' pairs
|
/// Component entity that has a list of 'measurement-correction' pairs
|
||||||
/// to be updated in the database on OK.
|
/// to be updated in the database on OK.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Component meterEntity;
|
||||||
public Component MeterEntity
|
public Component MeterEntity
|
||||||
{
|
{
|
||||||
get { return meterEntity; }
|
get { return meterEntity; }
|
||||||
set { meterEntity = value; }
|
set { meterEntity = value; }
|
||||||
}
|
}
|
||||||
Component meterEntity;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Balance configuration (with buoyancy parameters)
|
/// Balance configuration (with buoyancy parameters)
|
||||||
@ -50,6 +52,8 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
Control correctionTextBox;
|
Control correctionTextBox;
|
||||||
Control errorTextBox;
|
Control errorTextBox;
|
||||||
|
|
||||||
|
Unit currentUnit;
|
||||||
|
|
||||||
public MetrologyDlgBalanceTab()
|
public MetrologyDlgBalanceTab()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -69,26 +73,41 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
|
|
||||||
Localize();
|
Localize();
|
||||||
|
|
||||||
/// Panel1
|
/// Panel1
|
||||||
cmpntNameLabel.Text = meterEntity.Name;
|
cmpntNameLabel.Text = meterEntity.Name;
|
||||||
measuredTextBox.Text = string.Empty;
|
|
||||||
correctedTextBox.Text = string.Empty;
|
for (Unit u = 0; u < Unit.Count; u++)
|
||||||
|
if (Units.IsMass(u))
|
||||||
|
unitComboBox.Items.Add(u.ToDescription());
|
||||||
|
|
||||||
/// Panel2
|
/// Panel2
|
||||||
this.Controls.Add(measurementTextBox = new TextBox());
|
this.Controls.Add(measurementTextBox = new TextBox());
|
||||||
this.Controls.Add(correctionTextBox = new TextBox());
|
this.Controls.Add(correctionTextBox = new TextBox());
|
||||||
this.Controls.Add(errorTextBox = new TextBox());
|
this.Controls.Add(errorTextBox = new TextBox());
|
||||||
|
|
||||||
|
currentUnit = TBF.Rig.Sequences.ProcessData.MassUnit;
|
||||||
|
unitComboBox.Text = currentUnit.ToDescription();
|
||||||
|
InitializeColumns(listViewEx, currentUnit);
|
||||||
|
RefreshAll();
|
||||||
|
|
||||||
listViewEx.SubItemClicked += new SubItemEventHandler(listViewEx_SubItemClicked);
|
listViewEx.SubItemClicked += new SubItemEventHandler(listViewEx_SubItemClicked);
|
||||||
listViewEx.SubItemEndEditing += new SubItemEndEditingEventHandler(listViewEx_SubItemEndEditing);
|
listViewEx.SubItemEndEditing += new SubItemEndEditingEventHandler(listViewEx_SubItemEndEditing);
|
||||||
|
unitComboBox.SelectedIndexChanged += new System.EventHandler(unitComboBox_SelectedIndexChanged);
|
||||||
|
}
|
||||||
|
|
||||||
listViewEx.Columns.Add(new ColumnHeader() { Text = Strings.Nr, Width = 60 });
|
void InitializeColumns(ListView lv, Unit unit)
|
||||||
listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [kg]", Strings.Mass), Width = 100 });
|
{
|
||||||
listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [g]", Strings.Correction), Width = 100 });
|
lv.Columns.Clear();
|
||||||
listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [%]", Strings.Error), Width = 100 });
|
lv.Columns.Add(new ColumnHeader() { Text = Strings.Nr, Width = 40 });
|
||||||
|
lv.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [{1}]", Strings.Mass, unit.ToDescription()), Width = 120 });
|
||||||
|
lv.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [{1}]", Strings.Correction, unit.ToDescription()), Width = 150 });
|
||||||
|
lv.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [%]", Strings.Error), Width = 100 });
|
||||||
|
|
||||||
RefreshAll();
|
measuredLabel.Text = string.Format("{0} [{1}]:", Strings.Measured, unit.ToDescription());
|
||||||
}
|
correctedLabel.Text = string.Format("{0} [{1}]:", Strings.Corrected, unit.ToDescription());
|
||||||
|
measuredTextBox.Text = string.Empty;
|
||||||
|
correctedTextBox.Text = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
void Localize()
|
void Localize()
|
||||||
{
|
{
|
||||||
@ -104,10 +123,7 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
buoyancyHumiLabel.Text = string.Format("{0} [%]", Strings.Ambient_humidity);
|
buoyancyHumiLabel.Text = string.Format("{0} [%]", Strings.Ambient_humidity);
|
||||||
airDensityLabel.Text = Strings.Air_density_kg_m3;
|
airDensityLabel.Text = Strings.Air_density_kg_m3;
|
||||||
weightStandardDensityLabel.Text = Strings.Ref_mass_dens_kg_m3;
|
weightStandardDensityLabel.Text = Strings.Ref_mass_dens_kg_m3;
|
||||||
|
|
||||||
testGroupBox.Text = Strings.Test_measured_corrected;
|
testGroupBox.Text = Strings.Test_measured_corrected;
|
||||||
measuredLabel.Text = Strings.Measured;
|
|
||||||
correctedLabel.Text = Strings.Corrected;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefreshAll()
|
void RefreshAll()
|
||||||
@ -134,8 +150,12 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
int nr = listViewEx.Items.Count + 1;
|
int nr = listViewEx.Items.Count + 1;
|
||||||
ListViewItem lvi = new ListViewItem(nr.ToString());
|
ListViewItem lvi = new ListViewItem(nr.ToString());
|
||||||
lvi.Tag = corr;
|
lvi.Tag = corr;
|
||||||
lvi.SubItems.Add(corr.Measurement.ToString());
|
lvi.SubItems.Add(Units.ConvertTo(currentUnit, corr.Measurement).ToString());
|
||||||
lvi.SubItems.Add((1000 * corr.Correction).ToString());
|
double trueValue = corr.Measurement + corr.Correction;
|
||||||
|
double difference = Units.IsDefaultUnit(currentUnit)
|
||||||
|
? corr.Correction
|
||||||
|
: Units.ConvertTo(currentUnit, trueValue) - Units.ConvertTo(currentUnit, corr.Measurement);
|
||||||
|
lvi.SubItems.Add(Common.Utils.ToNiceString(difference, SignifDigits));
|
||||||
|
|
||||||
if (corr.Measurement == 0)
|
if (corr.Measurement == 0)
|
||||||
{
|
{
|
||||||
@ -143,8 +163,8 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
double error = Formulas.ErrorFromVolumes(corr.Measurement, corr.Measurement + corr.Correction);
|
double error = Formulas.ErrorFromVolumes(corr.Measurement, trueValue);
|
||||||
lvi.SubItems.Add(error.ToString(Common.Utils.SignificantDigitsToFmt(error, 5)));
|
lvi.SubItems.Add(Common.Utils.ToNiceString(error, SignifDigits));
|
||||||
}
|
}
|
||||||
|
|
||||||
listViewEx.Items.Add(lvi);
|
listViewEx.Items.Add(lvi);
|
||||||
@ -167,13 +187,13 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
}
|
}
|
||||||
|
|
||||||
void listViewEx_SubItemEndEditing(object sender, SubItemEndEditingEventArgs e)
|
void listViewEx_SubItemEndEditing(object sender, SubItemEndEditingEventArgs e)
|
||||||
{
|
{
|
||||||
if (ParseItem(e.Item, e.SubItem, e.DisplayText)) return;
|
if (ParseItem(e.Item, e.SubItem, e.DisplayText)) return;
|
||||||
|
|
||||||
/// New value is NOK, revert the original text
|
/// New value is NOK, revert the original text
|
||||||
e.DisplayText = e.Item.Text;
|
e.DisplayText = e.Item.Text;
|
||||||
e.Cancel = true;
|
e.Cancel = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Parse text of a ListViewItem
|
/// Parse text of a ListViewItem
|
||||||
@ -181,18 +201,23 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
/// <returns>true = value parsed OK</returns>
|
/// <returns>true = value parsed OK</returns>
|
||||||
bool ParseItem(ListViewItem item, int subItem, string strValue)
|
bool ParseItem(ListViewItem item, int subItem, string strValue)
|
||||||
{
|
{
|
||||||
double dblValue = 0;
|
double oriMeasurement; /// Measurement in selected units
|
||||||
if (subItem == 1 && Utils.TryParseEDouble(strValue, out dblValue) && dblValue >= 0)
|
double measurement; /// Measurement in default units
|
||||||
|
double difference; /// Correction in selected unit
|
||||||
|
double correction; /// Correction in default unit
|
||||||
|
double error = 0;
|
||||||
|
|
||||||
|
if (subItem == 1 && Utils.TryParseEDouble(strValue, out oriMeasurement) && (measurement = Units.ConvertFrom(currentUnit, oriMeasurement)) >= 0)
|
||||||
{
|
{
|
||||||
(item.Tag as MeasurementCorrection).Measurement = (float)dblValue;
|
(item.Tag as MeasurementCorrection).Measurement = measurement;
|
||||||
|
|
||||||
/// Update error (if possible)
|
/// Update error (if possible)
|
||||||
double correction1000;
|
if (Utils.TryParseEDouble(item.SubItems[2].Text, out difference) && (measurement != 0))
|
||||||
if (Utils.TryParseEDouble(item.SubItems[2].Text, out correction1000) && (dblValue != 0))
|
|
||||||
{
|
{
|
||||||
double correction = correction1000 / 1000;
|
correction = Units.IsDefaultUnit(currentUnit) ? difference
|
||||||
double error = Formulas.ErrorFromVolumes(dblValue, dblValue + correction);
|
: Units.ConvertFrom(currentUnit, oriMeasurement + difference) - Units.ConvertFrom(currentUnit, oriMeasurement);
|
||||||
item.SubItems[3].Text = error.ToString(Common.Utils.SignificantDigitsToFmt(error, 5));
|
error = Formulas.ErrorFromVolumes(measurement, measurement + correction);
|
||||||
|
item.SubItems[3].Text = Common.Utils.ToNiceString(error, SignifDigits);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -201,39 +226,48 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (subItem == 2 && Utils.TryParseEDouble(strValue, out dblValue))
|
else if (subItem == 2 && Utils.TryParseEDouble(strValue, out difference))
|
||||||
{
|
{
|
||||||
double correctionInDefaultUnits = dblValue / 1000;
|
if (Utils.TryParseEDouble(item.SubItems[1].Text, out oriMeasurement))
|
||||||
(item.Tag as MeasurementCorrection).Correction = (float)correctionInDefaultUnits;
|
{
|
||||||
|
measurement = Units.ConvertFrom(currentUnit, oriMeasurement);
|
||||||
|
correction = Units.IsDefaultUnit(currentUnit) ? difference
|
||||||
|
: Units.ConvertFrom(currentUnit, oriMeasurement + difference) - Units.ConvertFrom(currentUnit, oriMeasurement);
|
||||||
|
(item.Tag as MeasurementCorrection).Correction = correction;
|
||||||
|
|
||||||
/// Update error (if possible)
|
/// Update error (if possible)
|
||||||
double measurement;
|
if (measurement != 0)
|
||||||
if (Utils.TryParseEDouble(item.SubItems[1].Text, out measurement) && (measurement != 0))
|
{
|
||||||
{
|
error = Formulas.ErrorFromVolumes(measurement, measurement + correction);
|
||||||
double error = Formulas.ErrorFromVolumes(measurement, measurement + correctionInDefaultUnits);
|
item.SubItems[3].Text = Common.Utils.ToNiceString(error, SignifDigits);
|
||||||
item.SubItems[3].Text = error.ToString(Common.Utils.SignificantDigitsToFmt(error, 5));
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
item.SubItems[3].Text = Strings.NaN;
|
||||||
item.SubItems[3].Text = Strings.NaN;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (subItem == 3 && ((strValue == Strings.NaN) || Utils.TryParseEDouble(strValue, out dblValue)))
|
else if (subItem == 3 && ((strValue == Strings.NaN) || Utils.TryParseEDouble(strValue, out error)))
|
||||||
{
|
{
|
||||||
if (strValue == Strings.NaN)
|
if (strValue == Strings.NaN)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
double measurement;
|
if (Utils.TryParseEDouble(item.SubItems[1].Text, out oriMeasurement) && (measurement = Units.ConvertFrom(currentUnit, oriMeasurement)) != 0)
|
||||||
if (Utils.TryParseEDouble(item.SubItems[1].Text, out measurement) && measurement != 0)
|
|
||||||
{
|
{
|
||||||
double correction = Formulas.CorrectionFromError(measurement, dblValue);
|
correction = Formulas.CorrectionFromError(measurement, error);
|
||||||
double correction1000 = 1000 * correction;
|
(item.Tag as MeasurementCorrection).Correction = correction;
|
||||||
item.SubItems[2].Text = correction1000.ToString(Common.Utils.SignificantDigitsToFmt(correction1000, 5));
|
difference = Units.IsDefaultUnit(currentUnit)
|
||||||
(item.Tag as MeasurementCorrection).Correction = (float)correction;
|
? correction
|
||||||
|
: Units.ConvertTo(currentUnit, measurement + correction) - oriMeasurement;
|
||||||
|
item.SubItems[2].Text = Common.Utils.ToNiceString(difference, SignifDigits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -373,18 +407,21 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
|
|
||||||
private void measuredTextBox_TextChanged(object sender, EventArgs e)
|
private void measuredTextBox_TextChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
float measured;
|
double measured;
|
||||||
if (float.TryParse(measuredTextBox.Text,
|
if (double.TryParse(measuredTextBox.Text,
|
||||||
NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowExponent,
|
NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowExponent,
|
||||||
CultureInfo.CurrentCulture,
|
CultureInfo.CurrentCulture,
|
||||||
out measured) ||
|
out measured) ||
|
||||||
float.TryParse(measuredTextBox.Text,
|
double.TryParse(measuredTextBox.Text,
|
||||||
NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowExponent,
|
NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowExponent,
|
||||||
CultureInfo.InvariantCulture,
|
CultureInfo.InvariantCulture,
|
||||||
out measured))
|
out measured))
|
||||||
{
|
{
|
||||||
double corrected = MeasurementCorrection.CorrectedValue(measured, meterEntity.Corrections);
|
var corrections = new List<MeasurementCorrection>();
|
||||||
correctedTextBox.Text = corrected.ToString();
|
foreach (var c in meterEntity.Corrections) corrections.Add(c);
|
||||||
|
corrections.Sort();
|
||||||
|
double corrected = MeasurementCorrection.CorrectedValue(Units.ConvertFrom(currentUnit, measured), corrections);
|
||||||
|
correctedTextBox.Text = Units.ConvertTo(currentUnit, corrected).ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -401,5 +438,20 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
{
|
{
|
||||||
session.SaveOrUpdate(MeterEntity);
|
session.SaveOrUpdate(MeterEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void unitComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
for (Unit u = 0; u < Unit.Count; u++)
|
||||||
|
{
|
||||||
|
if (u.ToDescription() == unitComboBox.Text)
|
||||||
|
{
|
||||||
|
currentUnit = u;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
InitializeColumns(listViewEx, currentUnit);
|
||||||
|
RefreshAll();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,7 +32,11 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
||||||
|
this.unitLabel = new System.Windows.Forms.Label();
|
||||||
|
this.unitComboBox = new System.Windows.Forms.ComboBox();
|
||||||
this.calibrationGroupBox = new System.Windows.Forms.GroupBox();
|
this.calibrationGroupBox = new System.Windows.Forms.GroupBox();
|
||||||
|
this.calibExpirationDateTimePicker = new System.Windows.Forms.DateTimePicker();
|
||||||
|
this.calibDateTimePicker = new System.Windows.Forms.DateTimePicker();
|
||||||
this.calibValidDateLabel = new System.Windows.Forms.Label();
|
this.calibValidDateLabel = new System.Windows.Forms.Label();
|
||||||
this.calibDateLabel = new System.Windows.Forms.Label();
|
this.calibDateLabel = new System.Windows.Forms.Label();
|
||||||
this.calibCertificateNrTextBox = new System.Windows.Forms.TextBox();
|
this.calibCertificateNrTextBox = new System.Windows.Forms.TextBox();
|
||||||
@ -47,8 +51,6 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
this.correctedLabel = new System.Windows.Forms.Label();
|
this.correctedLabel = new System.Windows.Forms.Label();
|
||||||
this.measuredLabel = new System.Windows.Forms.Label();
|
this.measuredLabel = new System.Windows.Forms.Label();
|
||||||
this.listViewEx = new Common.Forms.ListViewEx();
|
this.listViewEx = new Common.Forms.ListViewEx();
|
||||||
this.calibExpirationDateTimePicker = new System.Windows.Forms.DateTimePicker();
|
|
||||||
this.calibDateTimePicker = new System.Windows.Forms.DateTimePicker();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
|
||||||
this.splitContainer1.Panel1.SuspendLayout();
|
this.splitContainer1.Panel1.SuspendLayout();
|
||||||
this.splitContainer1.Panel2.SuspendLayout();
|
this.splitContainer1.Panel2.SuspendLayout();
|
||||||
@ -68,6 +70,8 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
//
|
//
|
||||||
// splitContainer1.Panel1
|
// splitContainer1.Panel1
|
||||||
//
|
//
|
||||||
|
this.splitContainer1.Panel1.Controls.Add(this.unitLabel);
|
||||||
|
this.splitContainer1.Panel1.Controls.Add(this.unitComboBox);
|
||||||
this.splitContainer1.Panel1.Controls.Add(this.calibrationGroupBox);
|
this.splitContainer1.Panel1.Controls.Add(this.calibrationGroupBox);
|
||||||
this.splitContainer1.Panel1.Controls.Add(this.nameGroupBox);
|
this.splitContainer1.Panel1.Controls.Add(this.nameGroupBox);
|
||||||
this.splitContainer1.Panel1.Controls.Add(this.testGroupBox);
|
this.splitContainer1.Panel1.Controls.Add(this.testGroupBox);
|
||||||
@ -79,6 +83,24 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
this.splitContainer1.SplitterDistance = 102;
|
this.splitContainer1.SplitterDistance = 102;
|
||||||
this.splitContainer1.TabIndex = 2;
|
this.splitContainer1.TabIndex = 2;
|
||||||
//
|
//
|
||||||
|
// unitLabel
|
||||||
|
//
|
||||||
|
this.unitLabel.AutoSize = true;
|
||||||
|
this.unitLabel.Location = new System.Drawing.Point(21, 76);
|
||||||
|
this.unitLabel.Name = "unitLabel";
|
||||||
|
this.unitLabel.Size = new System.Drawing.Size(63, 13);
|
||||||
|
this.unitLabel.TabIndex = 10;
|
||||||
|
this.unitLabel.Text = "Unit of flow:";
|
||||||
|
//
|
||||||
|
// unitComboBox
|
||||||
|
//
|
||||||
|
this.unitComboBox.FormattingEnabled = true;
|
||||||
|
this.unitComboBox.Location = new System.Drawing.Point(107, 73);
|
||||||
|
this.unitComboBox.Name = "unitComboBox";
|
||||||
|
this.unitComboBox.Size = new System.Drawing.Size(62, 21);
|
||||||
|
this.unitComboBox.TabIndex = 9;
|
||||||
|
this.unitComboBox.SelectedIndexChanged += new System.EventHandler(this.unitComboBox_SelectedIndexChanged);
|
||||||
|
//
|
||||||
// calibrationGroupBox
|
// calibrationGroupBox
|
||||||
//
|
//
|
||||||
this.calibrationGroupBox.Controls.Add(this.calibExpirationDateTimePicker);
|
this.calibrationGroupBox.Controls.Add(this.calibExpirationDateTimePicker);
|
||||||
@ -94,6 +116,26 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
this.calibrationGroupBox.TabStop = false;
|
this.calibrationGroupBox.TabStop = false;
|
||||||
this.calibrationGroupBox.Text = "Calibration";
|
this.calibrationGroupBox.Text = "Calibration";
|
||||||
//
|
//
|
||||||
|
// calibExpirationDateTimePicker
|
||||||
|
//
|
||||||
|
this.calibExpirationDateTimePicker.CustomFormat = "dd.MM.yyyy";
|
||||||
|
this.calibExpirationDateTimePicker.Enabled = false;
|
||||||
|
this.calibExpirationDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
|
||||||
|
this.calibExpirationDateTimePicker.Location = new System.Drawing.Point(140, 59);
|
||||||
|
this.calibExpirationDateTimePicker.Name = "calibExpirationDateTimePicker";
|
||||||
|
this.calibExpirationDateTimePicker.Size = new System.Drawing.Size(82, 20);
|
||||||
|
this.calibExpirationDateTimePicker.TabIndex = 19;
|
||||||
|
//
|
||||||
|
// calibDateTimePicker
|
||||||
|
//
|
||||||
|
this.calibDateTimePicker.CustomFormat = "dd.MM.yyyy";
|
||||||
|
this.calibDateTimePicker.Enabled = false;
|
||||||
|
this.calibDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
|
||||||
|
this.calibDateTimePicker.Location = new System.Drawing.Point(140, 37);
|
||||||
|
this.calibDateTimePicker.Name = "calibDateTimePicker";
|
||||||
|
this.calibDateTimePicker.Size = new System.Drawing.Size(82, 20);
|
||||||
|
this.calibDateTimePicker.TabIndex = 18;
|
||||||
|
//
|
||||||
// calibValidDateLabel
|
// calibValidDateLabel
|
||||||
//
|
//
|
||||||
this.calibValidDateLabel.AutoSize = true;
|
this.calibValidDateLabel.AutoSize = true;
|
||||||
@ -136,7 +178,7 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
this.nameGroupBox.Controls.Add(this.cmpntNameLabel);
|
this.nameGroupBox.Controls.Add(this.cmpntNameLabel);
|
||||||
this.nameGroupBox.Location = new System.Drawing.Point(16, 10);
|
this.nameGroupBox.Location = new System.Drawing.Point(16, 10);
|
||||||
this.nameGroupBox.Name = "nameGroupBox";
|
this.nameGroupBox.Name = "nameGroupBox";
|
||||||
this.nameGroupBox.Size = new System.Drawing.Size(160, 86);
|
this.nameGroupBox.Size = new System.Drawing.Size(160, 53);
|
||||||
this.nameGroupBox.TabIndex = 5;
|
this.nameGroupBox.TabIndex = 5;
|
||||||
this.nameGroupBox.TabStop = false;
|
this.nameGroupBox.TabStop = false;
|
||||||
this.nameGroupBox.Text = "Component";
|
this.nameGroupBox.Text = "Component";
|
||||||
@ -198,7 +240,7 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
// correctedLabel
|
// correctedLabel
|
||||||
//
|
//
|
||||||
this.correctedLabel.AutoSize = true;
|
this.correctedLabel.AutoSize = true;
|
||||||
this.correctedLabel.Location = new System.Drawing.Point(17, 40);
|
this.correctedLabel.Location = new System.Drawing.Point(11, 40);
|
||||||
this.correctedLabel.Name = "correctedLabel";
|
this.correctedLabel.Name = "correctedLabel";
|
||||||
this.correctedLabel.Size = new System.Drawing.Size(53, 13);
|
this.correctedLabel.Size = new System.Drawing.Size(53, 13);
|
||||||
this.correctedLabel.TabIndex = 3;
|
this.correctedLabel.TabIndex = 3;
|
||||||
@ -207,7 +249,7 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
// measuredLabel
|
// measuredLabel
|
||||||
//
|
//
|
||||||
this.measuredLabel.AutoSize = true;
|
this.measuredLabel.AutoSize = true;
|
||||||
this.measuredLabel.Location = new System.Drawing.Point(17, 18);
|
this.measuredLabel.Location = new System.Drawing.Point(11, 18);
|
||||||
this.measuredLabel.Name = "measuredLabel";
|
this.measuredLabel.Name = "measuredLabel";
|
||||||
this.measuredLabel.Size = new System.Drawing.Size(54, 13);
|
this.measuredLabel.Size = new System.Drawing.Size(54, 13);
|
||||||
this.measuredLabel.TabIndex = 2;
|
this.measuredLabel.TabIndex = 2;
|
||||||
@ -228,26 +270,6 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
this.listViewEx.View = System.Windows.Forms.View.Details;
|
this.listViewEx.View = System.Windows.Forms.View.Details;
|
||||||
this.listViewEx.SelectedIndexChanged += new System.EventHandler(this.listViewEx_SelectedIndexChanged);
|
this.listViewEx.SelectedIndexChanged += new System.EventHandler(this.listViewEx_SelectedIndexChanged);
|
||||||
//
|
//
|
||||||
// calibExpirationDateTimePicker
|
|
||||||
//
|
|
||||||
this.calibExpirationDateTimePicker.CustomFormat = "dd.MM.yyyy";
|
|
||||||
this.calibExpirationDateTimePicker.Enabled = false;
|
|
||||||
this.calibExpirationDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
|
|
||||||
this.calibExpirationDateTimePicker.Location = new System.Drawing.Point(140, 59);
|
|
||||||
this.calibExpirationDateTimePicker.Name = "calibExpirationDateTimePicker";
|
|
||||||
this.calibExpirationDateTimePicker.Size = new System.Drawing.Size(82, 20);
|
|
||||||
this.calibExpirationDateTimePicker.TabIndex = 19;
|
|
||||||
//
|
|
||||||
// calibDateTimePicker
|
|
||||||
//
|
|
||||||
this.calibDateTimePicker.CustomFormat = "dd.MM.yyyy";
|
|
||||||
this.calibDateTimePicker.Enabled = false;
|
|
||||||
this.calibDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
|
|
||||||
this.calibDateTimePicker.Location = new System.Drawing.Point(140, 37);
|
|
||||||
this.calibDateTimePicker.Name = "calibDateTimePicker";
|
|
||||||
this.calibDateTimePicker.Size = new System.Drawing.Size(82, 20);
|
|
||||||
this.calibDateTimePicker.TabIndex = 18;
|
|
||||||
//
|
|
||||||
// MetrologyDlgFlowMeterTab
|
// MetrologyDlgFlowMeterTab
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
@ -257,6 +279,7 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
this.Size = new System.Drawing.Size(650, 400);
|
this.Size = new System.Drawing.Size(650, 400);
|
||||||
this.Load += new System.EventHandler(this.MetrologyDlgFlowMeterTab_Load);
|
this.Load += new System.EventHandler(this.MetrologyDlgFlowMeterTab_Load);
|
||||||
this.splitContainer1.Panel1.ResumeLayout(false);
|
this.splitContainer1.Panel1.ResumeLayout(false);
|
||||||
|
this.splitContainer1.Panel1.PerformLayout();
|
||||||
this.splitContainer1.Panel2.ResumeLayout(false);
|
this.splitContainer1.Panel2.ResumeLayout(false);
|
||||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
|
||||||
this.splitContainer1.ResumeLayout(false);
|
this.splitContainer1.ResumeLayout(false);
|
||||||
@ -290,6 +313,8 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
private System.Windows.Forms.Label tempFromToLabel;
|
private System.Windows.Forms.Label tempFromToLabel;
|
||||||
private System.Windows.Forms.DateTimePicker calibExpirationDateTimePicker;
|
private System.Windows.Forms.DateTimePicker calibExpirationDateTimePicker;
|
||||||
private System.Windows.Forms.DateTimePicker calibDateTimePicker;
|
private System.Windows.Forms.DateTimePicker calibDateTimePicker;
|
||||||
|
private System.Windows.Forms.Label unitLabel;
|
||||||
|
private System.Windows.Forms.ComboBox unitComboBox;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
///
|
///
|
||||||
/// Copyright (c) 2013-2019 Sensus Slovensko a.s.
|
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
|
||||||
///
|
///
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -18,6 +18,8 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
{
|
{
|
||||||
static readonly ILog log = LogManager.GetLogger(typeof(MetrologyDlgFlowMeterTab));
|
static readonly ILog log = LogManager.GetLogger(typeof(MetrologyDlgFlowMeterTab));
|
||||||
|
|
||||||
|
public const int SignifDigits = 5;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Component entity that has a list of 'measurement-correction' pairs
|
/// Component entity that has a list of 'measurement-correction' pairs
|
||||||
/// to be updated in the database on OK.
|
/// to be updated in the database on OK.
|
||||||
@ -52,6 +54,7 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
readonly int rangeIx; /// 0 (no range) or 1..5 (range #)
|
readonly int rangeIx; /// 0 (no range) or 1..5 (range #)
|
||||||
readonly bool isLastFlowMeterRange; /// true when this is the last range of this flow meter.
|
readonly bool isLastFlowMeterRange; /// true when this is the last range of this flow meter.
|
||||||
/// This is to prevent double saving of the meter entity to a DB
|
/// This is to prevent double saving of the meter entity to a DB
|
||||||
|
Unit currentUnit;
|
||||||
|
|
||||||
public MetrologyDlgFlowMeterTab() : this(0, true) {}
|
public MetrologyDlgFlowMeterTab() : this(0, true) {}
|
||||||
|
|
||||||
@ -88,28 +91,39 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
pressFromToLabel.Text = string.Format("{0} {1} {2} {3} bar", Strings.from, CalibInfoCfg.GetPressLo(rangeIx), Strings.to, CalibInfoCfg.GetPressHi(rangeIx));
|
pressFromToLabel.Text = string.Format("{0} {1} {2} {3} bar", Strings.from, CalibInfoCfg.GetPressLo(rangeIx), Strings.to, CalibInfoCfg.GetPressHi(rangeIx));
|
||||||
}
|
}
|
||||||
|
|
||||||
testGroupBox.Text = Strings.Test_measured_corrected;
|
for (Unit u = 0; u < Unit.Count; u++)
|
||||||
measuredLabel.Text = Strings.Measured;
|
if (Units.IsFlow(u))
|
||||||
correctedLabel.Text = Strings.Corrected;
|
unitComboBox.Items.Add(u.ToDescription());
|
||||||
measuredTextBox.Text = string.Empty;
|
|
||||||
correctedTextBox.Text = string.Empty;
|
|
||||||
|
|
||||||
/// Panel2
|
/// Panel2
|
||||||
this.Controls.Add(measurementTextBox = new TextBox());
|
this.Controls.Add(measurementTextBox = new TextBox());
|
||||||
this.Controls.Add(correctionTextBox = new TextBox());
|
this.Controls.Add(correctionTextBox = new TextBox());
|
||||||
this.Controls.Add(errorTextBox = new TextBox());
|
this.Controls.Add(errorTextBox = new TextBox());
|
||||||
|
|
||||||
|
currentUnit = TBF.Rig.Sequences.ProcessData.FlowUnit;
|
||||||
|
unitComboBox.Text = currentUnit.ToDescription();
|
||||||
|
InitializeColumns(listViewEx, currentUnit);
|
||||||
|
RefreshAll(rangeIx);
|
||||||
|
|
||||||
listViewEx.SubItemClicked += new SubItemEventHandler(listViewEx_SubItemClicked);
|
listViewEx.SubItemClicked += new SubItemEventHandler(listViewEx_SubItemClicked);
|
||||||
listViewEx.SubItemEndEditing += new SubItemEndEditingEventHandler(listViewEx_SubItemEndEditing);
|
listViewEx.SubItemEndEditing += new SubItemEndEditingEventHandler(listViewEx_SubItemEndEditing);
|
||||||
|
unitComboBox.SelectedIndexChanged += new System.EventHandler(unitComboBox_SelectedIndexChanged);
|
||||||
listViewEx.Columns.Add(new ColumnHeader() { Text = Strings.Nr, Width = 60 });
|
|
||||||
listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [m3/h]", Strings.Flow), Width = 100 });
|
|
||||||
listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [l/h]", Strings.Correction), Width = 100 });
|
|
||||||
listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [%]", Strings.Error), Width = 100 });
|
|
||||||
|
|
||||||
RefreshAll(rangeIx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InitializeColumns(ListView lv, Unit unit)
|
||||||
|
{
|
||||||
|
lv.Columns.Clear();
|
||||||
|
lv.Columns.Add(new ColumnHeader() { Text = Strings.Nr, Width = 40 });
|
||||||
|
lv.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [{1}]", Strings.Flow, unit.ToDescription()), Width = 120 });
|
||||||
|
lv.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [{1}]", Strings.Correction, unit.ToDescription()), Width = 150 });
|
||||||
|
lv.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [%]", Strings.Error), Width = 100 });
|
||||||
|
|
||||||
|
measuredLabel.Text = string.Format("{0} [{1}]:", Strings.Measured, unit.ToDescription());
|
||||||
|
correctedLabel.Text = string.Format("{0} [{1}]:", Strings.Corrected, unit.ToDescription());
|
||||||
|
measuredTextBox.Text = string.Empty;
|
||||||
|
correctedTextBox.Text = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
void Localize()
|
void Localize()
|
||||||
{
|
{
|
||||||
nameGroupBox.Text = Strings.Component;
|
nameGroupBox.Text = Strings.Component;
|
||||||
@ -118,10 +132,7 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
calibCertificateNrLabel.Text = Strings.Certificate;
|
calibCertificateNrLabel.Text = Strings.Certificate;
|
||||||
calibDateLabel.Text = Strings.Date;
|
calibDateLabel.Text = Strings.Date;
|
||||||
calibValidDateLabel.Text = Strings.Valid_until;
|
calibValidDateLabel.Text = Strings.Valid_until;
|
||||||
|
|
||||||
testGroupBox.Text = Strings.Test_measured_corrected;
|
testGroupBox.Text = Strings.Test_measured_corrected;
|
||||||
measuredLabel.Text = Strings.Measured;
|
|
||||||
correctedLabel.Text = Strings.Corrected;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefreshAll(int rangeIx1)
|
void RefreshAll(int rangeIx1)
|
||||||
@ -145,8 +156,12 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
int nr = listViewEx.Items.Count + 1;
|
int nr = listViewEx.Items.Count + 1;
|
||||||
ListViewItem lvi = new ListViewItem(nr.ToString());
|
ListViewItem lvi = new ListViewItem(nr.ToString());
|
||||||
lvi.Tag = corr;
|
lvi.Tag = corr;
|
||||||
lvi.SubItems.Add(corr.Measurement.ToString());
|
lvi.SubItems.Add(Units.ConvertTo(currentUnit, corr.Measurement).ToString());
|
||||||
lvi.SubItems.Add((1000 * corr.Correction).ToString());
|
double trueValue = corr.Measurement + corr.Correction;
|
||||||
|
double difference = Units.IsDefaultUnit(currentUnit)
|
||||||
|
? corr.Correction
|
||||||
|
: Units.ConvertTo(currentUnit, trueValue) - Units.ConvertTo(currentUnit, corr.Measurement);
|
||||||
|
lvi.SubItems.Add(Common.Utils.ToNiceString(difference, SignifDigits));
|
||||||
|
|
||||||
if (corr.Measurement == 0)
|
if (corr.Measurement == 0)
|
||||||
{
|
{
|
||||||
@ -154,11 +169,11 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
double error = Formulas.ErrorFromVolumes(corr.Measurement, corr.Measurement + corr.Correction);
|
double error = Formulas.ErrorFromVolumes(corr.Measurement, trueValue);
|
||||||
lvi.SubItems.Add(error.ToString(Common.Utils.SignificantDigitsToFmt(error, 5)));
|
lvi.SubItems.Add(Common.Utils.ToNiceString(error, SignifDigits));
|
||||||
}
|
}
|
||||||
|
|
||||||
listViewEx.Items.Add(lvi);
|
listViewEx.Items.Add(lvi);
|
||||||
}
|
}
|
||||||
|
|
||||||
void listViewEx_SubItemClicked(object sender, SubItemEventArgs e)
|
void listViewEx_SubItemClicked(object sender, SubItemEventArgs e)
|
||||||
@ -175,16 +190,16 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
{
|
{
|
||||||
listViewEx.StartEditing(correctionTextBox, e.Item, e.SubItem);
|
listViewEx.StartEditing(correctionTextBox, e.Item, e.SubItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void listViewEx_SubItemEndEditing(object sender, SubItemEndEditingEventArgs e)
|
void listViewEx_SubItemEndEditing(object sender, SubItemEndEditingEventArgs e)
|
||||||
{
|
{
|
||||||
if (ParseItem(e.Item, e.SubItem, e.DisplayText)) return;
|
if (ParseItem(e.Item, e.SubItem, e.DisplayText)) return;
|
||||||
|
|
||||||
/// New value is NOK, revert the original text
|
/// New value is NOK, revert the original text
|
||||||
e.DisplayText = e.Item.Text;
|
e.DisplayText = e.Item.Text;
|
||||||
e.Cancel = true;
|
e.Cancel = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Parse text of a ListViewItem
|
/// Parse text of a ListViewItem
|
||||||
@ -192,18 +207,23 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
/// <returns>true = value parsed OK</returns>
|
/// <returns>true = value parsed OK</returns>
|
||||||
bool ParseItem(ListViewItem item, int subItem, string strValue)
|
bool ParseItem(ListViewItem item, int subItem, string strValue)
|
||||||
{
|
{
|
||||||
double dblValue = 0;
|
double oriMeasurement; /// Measurement in selected units
|
||||||
if (subItem == 1 && Utils.TryParseEDouble(strValue, out dblValue) && dblValue >= 0)
|
double measurement; /// Measurement in default units
|
||||||
|
double difference; /// Correction in selected unit
|
||||||
|
double correction; /// Correction in default unit
|
||||||
|
double error = 0;
|
||||||
|
|
||||||
|
if (subItem == 1 && Utils.TryParseEDouble(strValue, out oriMeasurement) && (measurement = Units.ConvertFrom(currentUnit, oriMeasurement)) >= 0)
|
||||||
{
|
{
|
||||||
(item.Tag as MeasurementCorrection).Measurement = (float)dblValue;
|
(item.Tag as MeasurementCorrection).Measurement = measurement;
|
||||||
|
|
||||||
/// Update error (if possible)
|
/// Update error (if possible)
|
||||||
double correction1000;
|
if (Utils.TryParseEDouble(item.SubItems[2].Text, out difference) && (measurement != 0))
|
||||||
if (Utils.TryParseEDouble(item.SubItems[2].Text, out correction1000) && (dblValue != 0))
|
|
||||||
{
|
{
|
||||||
double correction = correction1000 / 1000;
|
correction = Units.IsDefaultUnit(currentUnit) ? difference
|
||||||
double error = Formulas.ErrorFromVolumes(dblValue, dblValue + correction);
|
: Units.ConvertFrom(currentUnit, oriMeasurement + difference) - Units.ConvertFrom(currentUnit, oriMeasurement);
|
||||||
item.SubItems[3].Text = error.ToString(Common.Utils.SignificantDigitsToFmt(error, 5));
|
error = Formulas.ErrorFromVolumes(measurement, measurement + correction);
|
||||||
|
item.SubItems[3].Text = Common.Utils.ToNiceString(error, SignifDigits);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -212,39 +232,48 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (subItem == 2 && Utils.TryParseEDouble(strValue, out dblValue))
|
else if (subItem == 2 && Utils.TryParseEDouble(strValue, out difference))
|
||||||
{
|
{
|
||||||
double correctionInDefaultUnits = dblValue / 1000;
|
if (Utils.TryParseEDouble(item.SubItems[1].Text, out oriMeasurement))
|
||||||
(item.Tag as MeasurementCorrection).Correction = (float)correctionInDefaultUnits;
|
{
|
||||||
|
measurement = Units.ConvertFrom(currentUnit, oriMeasurement);
|
||||||
|
correction = Units.IsDefaultUnit(currentUnit) ? difference
|
||||||
|
: Units.ConvertFrom(currentUnit, oriMeasurement + difference) - Units.ConvertFrom(currentUnit, oriMeasurement);
|
||||||
|
(item.Tag as MeasurementCorrection).Correction = correction;
|
||||||
|
|
||||||
/// Update error (if possible)
|
/// Update error (if possible)
|
||||||
double measurement;
|
if (measurement != 0)
|
||||||
if (Utils.TryParseEDouble(item.SubItems[1].Text, out measurement) && (measurement != 0))
|
{
|
||||||
{
|
error = Formulas.ErrorFromVolumes(measurement, measurement + correction);
|
||||||
double error = Formulas.ErrorFromVolumes(measurement, measurement + correctionInDefaultUnits);
|
item.SubItems[3].Text = Common.Utils.ToNiceString(error, SignifDigits);
|
||||||
item.SubItems[3].Text = error.ToString(Common.Utils.SignificantDigitsToFmt(error, 5));
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
item.SubItems[3].Text = Strings.NaN;
|
||||||
item.SubItems[3].Text = Strings.NaN;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (subItem == 3 && ((strValue == Strings.NaN) || Utils.TryParseEDouble(strValue, out dblValue)))
|
else if (subItem == 3 && ((strValue == Strings.NaN) || Utils.TryParseEDouble(strValue, out error)))
|
||||||
{
|
{
|
||||||
if (strValue == Strings.NaN)
|
if (strValue == Strings.NaN)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
double measurement;
|
if (Utils.TryParseEDouble(item.SubItems[1].Text, out oriMeasurement) && (measurement = Units.ConvertFrom(currentUnit, oriMeasurement)) != 0)
|
||||||
if (Utils.TryParseEDouble(item.SubItems[1].Text, out measurement) && measurement != 0)
|
|
||||||
{
|
{
|
||||||
double correction = Formulas.CorrectionFromError(measurement, dblValue);
|
correction = Formulas.CorrectionFromError(measurement, error);
|
||||||
double correction1000 = 1000 * correction;
|
(item.Tag as MeasurementCorrection).Correction = correction;
|
||||||
item.SubItems[2].Text = correction1000.ToString(Common.Utils.SignificantDigitsToFmt(correction1000, 5));
|
difference = Units.IsDefaultUnit(currentUnit)
|
||||||
(item.Tag as MeasurementCorrection).Correction = (float)correction;
|
? correction
|
||||||
|
: Units.ConvertTo(currentUnit, measurement + correction) - oriMeasurement;
|
||||||
|
item.SubItems[2].Text = Common.Utils.ToNiceString(difference, SignifDigits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -370,18 +399,21 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
|
|
||||||
private void measuredTextBox_TextChanged(object sender, EventArgs e)
|
private void measuredTextBox_TextChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
float measured;
|
double measured;
|
||||||
if (float.TryParse(measuredTextBox.Text,
|
if (double.TryParse(measuredTextBox.Text,
|
||||||
NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowExponent,
|
NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowExponent,
|
||||||
CultureInfo.CurrentCulture,
|
CultureInfo.CurrentCulture,
|
||||||
out measured) ||
|
out measured) ||
|
||||||
float.TryParse(measuredTextBox.Text,
|
double.TryParse(measuredTextBox.Text,
|
||||||
NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowExponent,
|
NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowExponent,
|
||||||
CultureInfo.InvariantCulture,
|
CultureInfo.InvariantCulture,
|
||||||
out measured))
|
out measured))
|
||||||
{
|
{
|
||||||
double corrected = MeasurementCorrection.CorrectedValue(measured, meterEntity.Corrections);
|
var corrections = new List<MeasurementCorrection>();
|
||||||
correctedTextBox.Text = corrected.ToString();
|
foreach (var c in meterEntity.Corrections) if (c.RangeIx == rangeIx) corrections.Add(c);
|
||||||
|
corrections.Sort();
|
||||||
|
double corrected = MeasurementCorrection.CorrectedValue(Units.ConvertFrom(currentUnit, measured), corrections);
|
||||||
|
correctedTextBox.Text = Units.ConvertTo(currentUnit, corrected).ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,5 +435,20 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
session.SaveOrUpdate(MeterEntity);
|
session.SaveOrUpdate(MeterEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void unitComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
for (Unit u = 0; u < Unit.Count; u++)
|
||||||
|
{
|
||||||
|
if (u.ToDescription() == unitComboBox.Text)
|
||||||
|
{
|
||||||
|
currentUnit = u;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
InitializeColumns(listViewEx, currentUnit);
|
||||||
|
RefreshAll(rangeIx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,7 +32,11 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
||||||
|
this.unitLabel = new System.Windows.Forms.Label();
|
||||||
|
this.unitComboBox = new System.Windows.Forms.ComboBox();
|
||||||
this.calibrationGroupBox = new System.Windows.Forms.GroupBox();
|
this.calibrationGroupBox = new System.Windows.Forms.GroupBox();
|
||||||
|
this.calibExpirationDateTimePicker = new System.Windows.Forms.DateTimePicker();
|
||||||
|
this.calibDateTimePicker = new System.Windows.Forms.DateTimePicker();
|
||||||
this.calibValidDateLabel = new System.Windows.Forms.Label();
|
this.calibValidDateLabel = new System.Windows.Forms.Label();
|
||||||
this.calibDateLabel = new System.Windows.Forms.Label();
|
this.calibDateLabel = new System.Windows.Forms.Label();
|
||||||
this.calibCertificateNrTextBox = new System.Windows.Forms.TextBox();
|
this.calibCertificateNrTextBox = new System.Windows.Forms.TextBox();
|
||||||
@ -45,8 +49,6 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
this.componentLabel = new System.Windows.Forms.Label();
|
this.componentLabel = new System.Windows.Forms.Label();
|
||||||
this.cmpntNameLabel = new System.Windows.Forms.Label();
|
this.cmpntNameLabel = new System.Windows.Forms.Label();
|
||||||
this.listViewEx = new Common.Forms.ListViewEx();
|
this.listViewEx = new Common.Forms.ListViewEx();
|
||||||
this.calibExpirationDateTimePicker = new System.Windows.Forms.DateTimePicker();
|
|
||||||
this.calibDateTimePicker = new System.Windows.Forms.DateTimePicker();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
|
||||||
this.splitContainer1.Panel1.SuspendLayout();
|
this.splitContainer1.Panel1.SuspendLayout();
|
||||||
this.splitContainer1.Panel2.SuspendLayout();
|
this.splitContainer1.Panel2.SuspendLayout();
|
||||||
@ -65,6 +67,8 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
//
|
//
|
||||||
// splitContainer1.Panel1
|
// splitContainer1.Panel1
|
||||||
//
|
//
|
||||||
|
this.splitContainer1.Panel1.Controls.Add(this.unitLabel);
|
||||||
|
this.splitContainer1.Panel1.Controls.Add(this.unitComboBox);
|
||||||
this.splitContainer1.Panel1.Controls.Add(this.calibrationGroupBox);
|
this.splitContainer1.Panel1.Controls.Add(this.calibrationGroupBox);
|
||||||
this.splitContainer1.Panel1.Controls.Add(this.testGroupBox);
|
this.splitContainer1.Panel1.Controls.Add(this.testGroupBox);
|
||||||
this.splitContainer1.Panel1.Controls.Add(this.componentLabel);
|
this.splitContainer1.Panel1.Controls.Add(this.componentLabel);
|
||||||
@ -73,10 +77,28 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
// splitContainer1.Panel2
|
// splitContainer1.Panel2
|
||||||
//
|
//
|
||||||
this.splitContainer1.Panel2.Controls.Add(this.listViewEx);
|
this.splitContainer1.Panel2.Controls.Add(this.listViewEx);
|
||||||
this.splitContainer1.Size = new System.Drawing.Size(600, 300);
|
this.splitContainer1.Size = new System.Drawing.Size(650, 300);
|
||||||
this.splitContainer1.SplitterDistance = 110;
|
this.splitContainer1.SplitterDistance = 110;
|
||||||
this.splitContainer1.TabIndex = 2;
|
this.splitContainer1.TabIndex = 2;
|
||||||
//
|
//
|
||||||
|
// unitLabel
|
||||||
|
//
|
||||||
|
this.unitLabel.AutoSize = true;
|
||||||
|
this.unitLabel.Location = new System.Drawing.Point(14, 56);
|
||||||
|
this.unitLabel.Name = "unitLabel";
|
||||||
|
this.unitLabel.Size = new System.Drawing.Size(84, 13);
|
||||||
|
this.unitLabel.TabIndex = 10;
|
||||||
|
this.unitLabel.Text = "Unit of pressure:";
|
||||||
|
//
|
||||||
|
// unitComboBox
|
||||||
|
//
|
||||||
|
this.unitComboBox.FormattingEnabled = true;
|
||||||
|
this.unitComboBox.Location = new System.Drawing.Point(123, 53);
|
||||||
|
this.unitComboBox.Name = "unitComboBox";
|
||||||
|
this.unitComboBox.Size = new System.Drawing.Size(62, 21);
|
||||||
|
this.unitComboBox.TabIndex = 9;
|
||||||
|
this.unitComboBox.SelectedIndexChanged += new System.EventHandler(this.unitComboBox_SelectedIndexChanged);
|
||||||
|
//
|
||||||
// calibrationGroupBox
|
// calibrationGroupBox
|
||||||
//
|
//
|
||||||
this.calibrationGroupBox.Controls.Add(this.calibExpirationDateTimePicker);
|
this.calibrationGroupBox.Controls.Add(this.calibExpirationDateTimePicker);
|
||||||
@ -92,6 +114,26 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
this.calibrationGroupBox.TabStop = false;
|
this.calibrationGroupBox.TabStop = false;
|
||||||
this.calibrationGroupBox.Text = "Calibration";
|
this.calibrationGroupBox.Text = "Calibration";
|
||||||
//
|
//
|
||||||
|
// calibExpirationDateTimePicker
|
||||||
|
//
|
||||||
|
this.calibExpirationDateTimePicker.CustomFormat = "dd.MM.yyyy";
|
||||||
|
this.calibExpirationDateTimePicker.Enabled = false;
|
||||||
|
this.calibExpirationDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
|
||||||
|
this.calibExpirationDateTimePicker.Location = new System.Drawing.Point(117, 59);
|
||||||
|
this.calibExpirationDateTimePicker.Name = "calibExpirationDateTimePicker";
|
||||||
|
this.calibExpirationDateTimePicker.Size = new System.Drawing.Size(82, 20);
|
||||||
|
this.calibExpirationDateTimePicker.TabIndex = 19;
|
||||||
|
//
|
||||||
|
// calibDateTimePicker
|
||||||
|
//
|
||||||
|
this.calibDateTimePicker.CustomFormat = "dd.MM.yyyy";
|
||||||
|
this.calibDateTimePicker.Enabled = false;
|
||||||
|
this.calibDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
|
||||||
|
this.calibDateTimePicker.Location = new System.Drawing.Point(117, 37);
|
||||||
|
this.calibDateTimePicker.Name = "calibDateTimePicker";
|
||||||
|
this.calibDateTimePicker.Size = new System.Drawing.Size(82, 20);
|
||||||
|
this.calibDateTimePicker.TabIndex = 18;
|
||||||
|
//
|
||||||
// calibValidDateLabel
|
// calibValidDateLabel
|
||||||
//
|
//
|
||||||
this.calibValidDateLabel.AutoSize = true;
|
this.calibValidDateLabel.AutoSize = true;
|
||||||
@ -113,7 +155,7 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
// calibCertificateNrTextBox
|
// calibCertificateNrTextBox
|
||||||
//
|
//
|
||||||
this.calibCertificateNrTextBox.Enabled = false;
|
this.calibCertificateNrTextBox.Enabled = false;
|
||||||
this.calibCertificateNrTextBox.Location = new System.Drawing.Point(120, 15);
|
this.calibCertificateNrTextBox.Location = new System.Drawing.Point(117, 15);
|
||||||
this.calibCertificateNrTextBox.Name = "calibCertificateNrTextBox";
|
this.calibCertificateNrTextBox.Name = "calibCertificateNrTextBox";
|
||||||
this.calibCertificateNrTextBox.Size = new System.Drawing.Size(82, 20);
|
this.calibCertificateNrTextBox.Size = new System.Drawing.Size(82, 20);
|
||||||
this.calibCertificateNrTextBox.TabIndex = 11;
|
this.calibCertificateNrTextBox.TabIndex = 11;
|
||||||
@ -135,14 +177,14 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
this.testGroupBox.Controls.Add(this.measuredLabel);
|
this.testGroupBox.Controls.Add(this.measuredLabel);
|
||||||
this.testGroupBox.Location = new System.Drawing.Point(428, 12);
|
this.testGroupBox.Location = new System.Drawing.Point(428, 12);
|
||||||
this.testGroupBox.Name = "testGroupBox";
|
this.testGroupBox.Name = "testGroupBox";
|
||||||
this.testGroupBox.Size = new System.Drawing.Size(157, 86);
|
this.testGroupBox.Size = new System.Drawing.Size(200, 86);
|
||||||
this.testGroupBox.TabIndex = 4;
|
this.testGroupBox.TabIndex = 4;
|
||||||
this.testGroupBox.TabStop = false;
|
this.testGroupBox.TabStop = false;
|
||||||
this.testGroupBox.Text = "Test";
|
this.testGroupBox.Text = "Test";
|
||||||
//
|
//
|
||||||
// correctedTextBox
|
// correctedTextBox
|
||||||
//
|
//
|
||||||
this.correctedTextBox.Location = new System.Drawing.Point(74, 48);
|
this.correctedTextBox.Location = new System.Drawing.Point(115, 49);
|
||||||
this.correctedTextBox.Name = "correctedTextBox";
|
this.correctedTextBox.Name = "correctedTextBox";
|
||||||
this.correctedTextBox.ReadOnly = true;
|
this.correctedTextBox.ReadOnly = true;
|
||||||
this.correctedTextBox.Size = new System.Drawing.Size(73, 20);
|
this.correctedTextBox.Size = new System.Drawing.Size(73, 20);
|
||||||
@ -150,7 +192,7 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
//
|
//
|
||||||
// measuredTextBox
|
// measuredTextBox
|
||||||
//
|
//
|
||||||
this.measuredTextBox.Location = new System.Drawing.Point(74, 23);
|
this.measuredTextBox.Location = new System.Drawing.Point(115, 24);
|
||||||
this.measuredTextBox.Name = "measuredTextBox";
|
this.measuredTextBox.Name = "measuredTextBox";
|
||||||
this.measuredTextBox.Size = new System.Drawing.Size(73, 20);
|
this.measuredTextBox.Size = new System.Drawing.Size(73, 20);
|
||||||
this.measuredTextBox.TabIndex = 4;
|
this.measuredTextBox.TabIndex = 4;
|
||||||
@ -159,7 +201,7 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
// correctedLabel
|
// correctedLabel
|
||||||
//
|
//
|
||||||
this.correctedLabel.AutoSize = true;
|
this.correctedLabel.AutoSize = true;
|
||||||
this.correctedLabel.Location = new System.Drawing.Point(7, 51);
|
this.correctedLabel.Location = new System.Drawing.Point(7, 52);
|
||||||
this.correctedLabel.Name = "correctedLabel";
|
this.correctedLabel.Name = "correctedLabel";
|
||||||
this.correctedLabel.Size = new System.Drawing.Size(53, 13);
|
this.correctedLabel.Size = new System.Drawing.Size(53, 13);
|
||||||
this.correctedLabel.TabIndex = 3;
|
this.correctedLabel.TabIndex = 3;
|
||||||
@ -168,7 +210,7 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
// measuredLabel
|
// measuredLabel
|
||||||
//
|
//
|
||||||
this.measuredLabel.AutoSize = true;
|
this.measuredLabel.AutoSize = true;
|
||||||
this.measuredLabel.Location = new System.Drawing.Point(6, 30);
|
this.measuredLabel.Location = new System.Drawing.Point(7, 27);
|
||||||
this.measuredLabel.Name = "measuredLabel";
|
this.measuredLabel.Name = "measuredLabel";
|
||||||
this.measuredLabel.Size = new System.Drawing.Size(54, 13);
|
this.measuredLabel.Size = new System.Drawing.Size(54, 13);
|
||||||
this.measuredLabel.TabIndex = 2;
|
this.measuredLabel.TabIndex = 2;
|
||||||
@ -201,39 +243,19 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
this.listViewEx.GridLines = true;
|
this.listViewEx.GridLines = true;
|
||||||
this.listViewEx.Location = new System.Drawing.Point(0, 0);
|
this.listViewEx.Location = new System.Drawing.Point(0, 0);
|
||||||
this.listViewEx.Name = "listViewEx";
|
this.listViewEx.Name = "listViewEx";
|
||||||
this.listViewEx.Size = new System.Drawing.Size(600, 186);
|
this.listViewEx.Size = new System.Drawing.Size(650, 186);
|
||||||
this.listViewEx.TabIndex = 0;
|
this.listViewEx.TabIndex = 0;
|
||||||
this.listViewEx.UseCompatibleStateImageBehavior = false;
|
this.listViewEx.UseCompatibleStateImageBehavior = false;
|
||||||
this.listViewEx.View = System.Windows.Forms.View.Details;
|
this.listViewEx.View = System.Windows.Forms.View.Details;
|
||||||
this.listViewEx.SelectedIndexChanged += new System.EventHandler(this.listViewEx_SelectedIndexChanged);
|
this.listViewEx.SelectedIndexChanged += new System.EventHandler(this.listViewEx_SelectedIndexChanged);
|
||||||
//
|
//
|
||||||
// calibExpirationDateTimePicker
|
|
||||||
//
|
|
||||||
this.calibExpirationDateTimePicker.CustomFormat = "dd.MM.yyyy";
|
|
||||||
this.calibExpirationDateTimePicker.Enabled = false;
|
|
||||||
this.calibExpirationDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
|
|
||||||
this.calibExpirationDateTimePicker.Location = new System.Drawing.Point(120, 59);
|
|
||||||
this.calibExpirationDateTimePicker.Name = "calibExpirationDateTimePicker";
|
|
||||||
this.calibExpirationDateTimePicker.Size = new System.Drawing.Size(82, 20);
|
|
||||||
this.calibExpirationDateTimePicker.TabIndex = 19;
|
|
||||||
//
|
|
||||||
// calibDateTimePicker
|
|
||||||
//
|
|
||||||
this.calibDateTimePicker.CustomFormat = "dd.MM.yyyy";
|
|
||||||
this.calibDateTimePicker.Enabled = false;
|
|
||||||
this.calibDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
|
|
||||||
this.calibDateTimePicker.Location = new System.Drawing.Point(120, 37);
|
|
||||||
this.calibDateTimePicker.Name = "calibDateTimePicker";
|
|
||||||
this.calibDateTimePicker.Size = new System.Drawing.Size(82, 20);
|
|
||||||
this.calibDateTimePicker.TabIndex = 18;
|
|
||||||
//
|
|
||||||
// MetrologyDlgPressMeterTab
|
// MetrologyDlgPressMeterTab
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.Controls.Add(this.splitContainer1);
|
this.Controls.Add(this.splitContainer1);
|
||||||
this.Name = "MetrologyDlgPressMeterTab";
|
this.Name = "MetrologyDlgPressMeterTab";
|
||||||
this.Size = new System.Drawing.Size(600, 300);
|
this.Size = new System.Drawing.Size(650, 300);
|
||||||
this.Load += new System.EventHandler(this.MetrologyDlgPressMeterTab_Load);
|
this.Load += new System.EventHandler(this.MetrologyDlgPressMeterTab_Load);
|
||||||
this.splitContainer1.Panel1.ResumeLayout(false);
|
this.splitContainer1.Panel1.ResumeLayout(false);
|
||||||
this.splitContainer1.Panel1.PerformLayout();
|
this.splitContainer1.Panel1.PerformLayout();
|
||||||
@ -266,6 +288,8 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
private System.Windows.Forms.Label calibCertificateNrLabel;
|
private System.Windows.Forms.Label calibCertificateNrLabel;
|
||||||
private System.Windows.Forms.DateTimePicker calibExpirationDateTimePicker;
|
private System.Windows.Forms.DateTimePicker calibExpirationDateTimePicker;
|
||||||
private System.Windows.Forms.DateTimePicker calibDateTimePicker;
|
private System.Windows.Forms.DateTimePicker calibDateTimePicker;
|
||||||
|
private System.Windows.Forms.Label unitLabel;
|
||||||
|
private System.Windows.Forms.ComboBox unitComboBox;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
///
|
///
|
||||||
/// Copyright (c) 2013-2020 Sensus Slovensko a.s.
|
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
|
||||||
///
|
///
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -18,6 +18,8 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
{
|
{
|
||||||
static readonly ILog log = LogManager.GetLogger(typeof(MetrologyDlgPressMeterTab));
|
static readonly ILog log = LogManager.GetLogger(typeof(MetrologyDlgPressMeterTab));
|
||||||
|
|
||||||
|
public const int SignifDigits = 5;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Component entity that has a list of 'measurement-correction' pairs
|
/// Component entity that has a list of 'measurement-correction' pairs
|
||||||
/// to be updated in the database on OK.
|
/// to be updated in the database on OK.
|
||||||
@ -50,6 +52,8 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
Control correctionTextBox;
|
Control correctionTextBox;
|
||||||
Control errorTextBox;
|
Control errorTextBox;
|
||||||
|
|
||||||
|
Unit currentUnit;
|
||||||
|
|
||||||
public MetrologyDlgPressMeterTab()
|
public MetrologyDlgPressMeterTab()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -69,34 +73,46 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
|
|
||||||
Localize();
|
Localize();
|
||||||
|
|
||||||
/// Panel1
|
/// Panel1
|
||||||
cmpntNameLabel.Text = meterEntity.Name;
|
cmpntNameLabel.Text = meterEntity.Name;
|
||||||
|
|
||||||
|
for (Unit u = 0; u < Unit.Count; u++)
|
||||||
|
if (Units.IsPressure(u))
|
||||||
|
unitComboBox.Items.Add(u.ToDescription());
|
||||||
|
|
||||||
/// Panel2
|
/// Panel2
|
||||||
this.Controls.Add(measurementTextBox = new TextBox());
|
this.Controls.Add(measurementTextBox = new TextBox());
|
||||||
this.Controls.Add(correctionTextBox = new TextBox());
|
this.Controls.Add(correctionTextBox = new TextBox());
|
||||||
this.Controls.Add(errorTextBox = new TextBox());
|
this.Controls.Add(errorTextBox = new TextBox());
|
||||||
|
|
||||||
|
currentUnit = TBF.Rig.Sequences.ProcessData.PressUnit;
|
||||||
|
unitComboBox.Text = currentUnit.ToDescription();
|
||||||
|
InitializeColumns(listViewEx, currentUnit);
|
||||||
|
RefreshAll();
|
||||||
|
|
||||||
listViewEx.SubItemClicked += new SubItemEventHandler(listViewEx_SubItemClicked);
|
listViewEx.SubItemClicked += new SubItemEventHandler(listViewEx_SubItemClicked);
|
||||||
listViewEx.SubItemEndEditing += new SubItemEndEditingEventHandler(listViewEx_SubItemEndEditing);
|
listViewEx.SubItemEndEditing += new SubItemEndEditingEventHandler(listViewEx_SubItemEndEditing);
|
||||||
|
unitComboBox.SelectedIndexChanged += new System.EventHandler(this.unitComboBox_SelectedIndexChanged);
|
||||||
|
}
|
||||||
|
|
||||||
listViewEx.Columns.Add(new ColumnHeader() { Text = Strings.Nr, Width = 60 });
|
void InitializeColumns(ListView lv, Unit unit)
|
||||||
listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [bar]", Strings.Pressure), Width = 100 });
|
{
|
||||||
listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [mbar]", Strings.Correction), Width = 100 });
|
lv.Columns.Clear();
|
||||||
listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [%]", Strings.Error), Width = 100 });
|
lv.Columns.Add(new ColumnHeader() { Text = Strings.Nr, Width = 60 });
|
||||||
|
lv.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [{1}]", Strings.Pressure, unit.ToDescription()), Width = 100 });
|
||||||
|
lv.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [{1}]", Strings.Correction, unit.ToDescription()), Width = 100 });
|
||||||
|
lv.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [%]", Strings.Error), Width = 100 });
|
||||||
|
|
||||||
RefreshAll();
|
measuredLabel.Text = string.Format("{0} [{1}]:", Strings.Measured, unit.ToDescription());
|
||||||
}
|
correctedLabel.Text = string.Format("{0} [{1}]:", Strings.Corrected, unit.ToDescription());
|
||||||
|
measuredTextBox.Text = string.Empty;
|
||||||
|
correctedTextBox.Text = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
void Localize()
|
void Localize()
|
||||||
{
|
{
|
||||||
componentLabel.Text = Strings.Component;
|
componentLabel.Text = Strings.Component;
|
||||||
testGroupBox.Text = Strings.Test_measured_corrected;
|
testGroupBox.Text = Strings.Test_measured_corrected;
|
||||||
measuredLabel.Text = Strings.Measured;
|
|
||||||
correctedLabel.Text = Strings.Corrected;
|
|
||||||
measuredTextBox.Text = string.Empty;
|
|
||||||
correctedTextBox.Text = string.Empty;
|
|
||||||
|
|
||||||
calibrationGroupBox.Text = Strings.Calibration;
|
calibrationGroupBox.Text = Strings.Calibration;
|
||||||
calibCertificateNrLabel.Text = Strings.Certificate;
|
calibCertificateNrLabel.Text = Strings.Certificate;
|
||||||
calibDateLabel.Text = Strings.Date;
|
calibDateLabel.Text = Strings.Date;
|
||||||
@ -121,8 +137,12 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
int nr = listViewEx.Items.Count + 1;
|
int nr = listViewEx.Items.Count + 1;
|
||||||
ListViewItem lvi = new ListViewItem(nr.ToString());
|
ListViewItem lvi = new ListViewItem(nr.ToString());
|
||||||
lvi.Tag = corr;
|
lvi.Tag = corr;
|
||||||
lvi.SubItems.Add(corr.Measurement.ToString());
|
lvi.SubItems.Add(Units.ConvertTo(currentUnit, corr.Measurement).ToString());
|
||||||
lvi.SubItems.Add((1000 * corr.Correction).ToString());
|
double trueValue = corr.Measurement + corr.Correction;
|
||||||
|
double difference = Units.IsDefaultUnit(currentUnit)
|
||||||
|
? corr.Correction
|
||||||
|
: Units.ConvertTo(currentUnit, trueValue) - Units.ConvertTo(currentUnit, corr.Measurement);
|
||||||
|
lvi.SubItems.Add(Common.Utils.ToNiceString(difference, SignifDigits));
|
||||||
|
|
||||||
if (corr.Measurement == 0)
|
if (corr.Measurement == 0)
|
||||||
{
|
{
|
||||||
@ -130,8 +150,8 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
double error = Formulas.ErrorFromVolumes(corr.Measurement, corr.Measurement + corr.Correction);
|
double error = Formulas.ErrorFromVolumes(corr.Measurement, trueValue);
|
||||||
lvi.SubItems.Add(error.ToString(Common.Utils.SignificantDigitsToFmt(error, 5)));
|
lvi.SubItems.Add(Common.Utils.ToNiceString(error, SignifDigits));
|
||||||
}
|
}
|
||||||
|
|
||||||
listViewEx.Items.Add(lvi);
|
listViewEx.Items.Add(lvi);
|
||||||
@ -168,18 +188,23 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
/// <returns>true = value parsed OK</returns>
|
/// <returns>true = value parsed OK</returns>
|
||||||
bool ParseItem(ListViewItem item, int subItem, string strValue)
|
bool ParseItem(ListViewItem item, int subItem, string strValue)
|
||||||
{
|
{
|
||||||
double dblValue = 0;
|
double oriMeasurement; /// Measurement in selected units
|
||||||
if (subItem == 1 && Utils.TryParseEDouble(strValue, out dblValue) && dblValue >= 0)
|
double measurement; /// Measurement in default units
|
||||||
|
double difference; /// Correction in selected unit
|
||||||
|
double correction; /// Correction in default unit
|
||||||
|
double error = 0;
|
||||||
|
|
||||||
|
if (subItem == 1 && Utils.TryParseEDouble(strValue, out oriMeasurement) && (measurement = Units.ConvertFrom(currentUnit, oriMeasurement)) >= 0)
|
||||||
{
|
{
|
||||||
(item.Tag as MeasurementCorrection).Measurement = (float)dblValue;
|
(item.Tag as MeasurementCorrection).Measurement = measurement;
|
||||||
|
|
||||||
/// Update error (if possible)
|
/// Update error (if possible)
|
||||||
double correction1000;
|
if (Utils.TryParseEDouble(item.SubItems[2].Text, out difference) && (measurement != 0))
|
||||||
if (Utils.TryParseEDouble(item.SubItems[2].Text, out correction1000) && (dblValue != 0))
|
|
||||||
{
|
{
|
||||||
double correction = correction1000 / 1000;
|
correction = Units.IsDefaultUnit(currentUnit) ? difference
|
||||||
double error = Formulas.ErrorFromVolumes(dblValue, dblValue + correction);
|
: Units.ConvertFrom(currentUnit, oriMeasurement + difference) - Units.ConvertFrom(currentUnit, oriMeasurement);
|
||||||
item.SubItems[3].Text = error.ToString(Common.Utils.SignificantDigitsToFmt(error, 5));
|
error = Formulas.ErrorFromVolumes(measurement, measurement + correction);
|
||||||
|
item.SubItems[3].Text = Common.Utils.ToNiceString(error, SignifDigits);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -188,39 +213,48 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (subItem == 2 && Utils.TryParseEDouble(strValue, out dblValue))
|
else if (subItem == 2 && Utils.TryParseEDouble(strValue, out difference))
|
||||||
{
|
{
|
||||||
double correctionInDefaultUnits = dblValue / 1000;
|
if (Utils.TryParseEDouble(item.SubItems[1].Text, out oriMeasurement))
|
||||||
(item.Tag as MeasurementCorrection).Correction = (float)correctionInDefaultUnits;
|
{
|
||||||
|
measurement = Units.ConvertFrom(currentUnit, oriMeasurement);
|
||||||
|
correction = Units.IsDefaultUnit(currentUnit) ? difference
|
||||||
|
: Units.ConvertFrom(currentUnit, oriMeasurement + difference) - Units.ConvertFrom(currentUnit, oriMeasurement);
|
||||||
|
(item.Tag as MeasurementCorrection).Correction = correction;
|
||||||
|
|
||||||
/// Update error (if possible)
|
/// Update error (if possible)
|
||||||
double measurement;
|
if (measurement != 0)
|
||||||
if (Utils.TryParseEDouble(item.SubItems[1].Text, out measurement) && (measurement != 0))
|
{
|
||||||
{
|
error = Formulas.ErrorFromVolumes(measurement, measurement + correction);
|
||||||
double error = Formulas.ErrorFromVolumes(measurement, measurement + correctionInDefaultUnits);
|
item.SubItems[3].Text = Common.Utils.ToNiceString(error, SignifDigits);
|
||||||
item.SubItems[3].Text = error.ToString(Common.Utils.SignificantDigitsToFmt(error, 5));
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
item.SubItems[3].Text = Strings.NaN;
|
||||||
item.SubItems[3].Text = Strings.NaN;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (subItem == 3 && ((strValue == Strings.NaN) || Utils.TryParseEDouble(strValue, out dblValue)))
|
else if (subItem == 3 && ((strValue == Strings.NaN) || Utils.TryParseEDouble(strValue, out error)))
|
||||||
{
|
{
|
||||||
if (strValue == Strings.NaN)
|
if (strValue == Strings.NaN)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
double measurement;
|
if (Utils.TryParseEDouble(item.SubItems[1].Text, out oriMeasurement) && (measurement = Units.ConvertFrom(currentUnit, oriMeasurement)) != 0)
|
||||||
if (Utils.TryParseEDouble(item.SubItems[1].Text, out measurement) && measurement != 0)
|
|
||||||
{
|
{
|
||||||
double correction = Formulas.CorrectionFromError(measurement, dblValue);
|
correction = Formulas.CorrectionFromError(measurement, error);
|
||||||
double correction1000 = 1000 * correction;
|
(item.Tag as MeasurementCorrection).Correction = correction;
|
||||||
item.SubItems[2].Text = correction1000.ToString(Common.Utils.SignificantDigitsToFmt(correction1000, 5));
|
difference = Units.IsDefaultUnit(currentUnit)
|
||||||
(item.Tag as MeasurementCorrection).Correction = (float)correction;
|
? correction
|
||||||
|
: Units.ConvertTo(currentUnit, measurement + correction) - oriMeasurement;
|
||||||
|
item.SubItems[2].Text = Common.Utils.ToNiceString(difference, SignifDigits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,18 +384,21 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
|
|
||||||
private void measuredTextBox_TextChanged(object sender, EventArgs e)
|
private void measuredTextBox_TextChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
float measured;
|
double measured;
|
||||||
if (float.TryParse(measuredTextBox.Text,
|
if (double.TryParse(measuredTextBox.Text,
|
||||||
NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowExponent,
|
NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowExponent,
|
||||||
CultureInfo.CurrentCulture,
|
CultureInfo.CurrentCulture,
|
||||||
out measured) ||
|
out measured) ||
|
||||||
float.TryParse(measuredTextBox.Text,
|
double.TryParse(measuredTextBox.Text,
|
||||||
NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowExponent,
|
NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowExponent,
|
||||||
CultureInfo.InvariantCulture,
|
CultureInfo.InvariantCulture,
|
||||||
out measured))
|
out measured))
|
||||||
{
|
{
|
||||||
double corrected = MeasurementCorrection.CorrectedValue(measured, meterEntity.Corrections);
|
var corrections = new List<MeasurementCorrection>();
|
||||||
correctedTextBox.Text = corrected.ToString();
|
foreach (var c in meterEntity.Corrections) corrections.Add(c);
|
||||||
|
corrections.Sort();
|
||||||
|
double corrected = MeasurementCorrection.CorrectedValue(Units.ConvertFrom(currentUnit, measured), corrections);
|
||||||
|
correctedTextBox.Text = Units.ConvertTo(currentUnit, corrected).ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,5 +415,20 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
{
|
{
|
||||||
session.SaveOrUpdate(MeterEntity);
|
session.SaveOrUpdate(MeterEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void unitComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
for (Unit u = 0; u < Unit.Count; u++)
|
||||||
|
{
|
||||||
|
if (u.ToDescription() == unitComboBox.Text)
|
||||||
|
{
|
||||||
|
currentUnit = u;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
InitializeColumns(listViewEx, currentUnit);
|
||||||
|
RefreshAll();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,7 +32,11 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
||||||
|
this.unitLabel = new System.Windows.Forms.Label();
|
||||||
|
this.unitComboBox = new System.Windows.Forms.ComboBox();
|
||||||
this.calibrationGroupBox = new System.Windows.Forms.GroupBox();
|
this.calibrationGroupBox = new System.Windows.Forms.GroupBox();
|
||||||
|
this.calibExpirationDateTimePicker = new System.Windows.Forms.DateTimePicker();
|
||||||
|
this.calibDateTimePicker = new System.Windows.Forms.DateTimePicker();
|
||||||
this.calibValidDateLabel = new System.Windows.Forms.Label();
|
this.calibValidDateLabel = new System.Windows.Forms.Label();
|
||||||
this.calibDateLabel = new System.Windows.Forms.Label();
|
this.calibDateLabel = new System.Windows.Forms.Label();
|
||||||
this.calibCertificateNrTextBox = new System.Windows.Forms.TextBox();
|
this.calibCertificateNrTextBox = new System.Windows.Forms.TextBox();
|
||||||
@ -45,8 +49,6 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
this.componentLabel = new System.Windows.Forms.Label();
|
this.componentLabel = new System.Windows.Forms.Label();
|
||||||
this.cmpntNameLabel = new System.Windows.Forms.Label();
|
this.cmpntNameLabel = new System.Windows.Forms.Label();
|
||||||
this.listViewEx = new Common.Forms.ListViewEx();
|
this.listViewEx = new Common.Forms.ListViewEx();
|
||||||
this.calibExpirationDateTimePicker = new System.Windows.Forms.DateTimePicker();
|
|
||||||
this.calibDateTimePicker = new System.Windows.Forms.DateTimePicker();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
|
||||||
this.splitContainer1.Panel1.SuspendLayout();
|
this.splitContainer1.Panel1.SuspendLayout();
|
||||||
this.splitContainer1.Panel2.SuspendLayout();
|
this.splitContainer1.Panel2.SuspendLayout();
|
||||||
@ -65,6 +67,8 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
//
|
//
|
||||||
// splitContainer1.Panel1
|
// splitContainer1.Panel1
|
||||||
//
|
//
|
||||||
|
this.splitContainer1.Panel1.Controls.Add(this.unitLabel);
|
||||||
|
this.splitContainer1.Panel1.Controls.Add(this.unitComboBox);
|
||||||
this.splitContainer1.Panel1.Controls.Add(this.calibrationGroupBox);
|
this.splitContainer1.Panel1.Controls.Add(this.calibrationGroupBox);
|
||||||
this.splitContainer1.Panel1.Controls.Add(this.testGroupBox);
|
this.splitContainer1.Panel1.Controls.Add(this.testGroupBox);
|
||||||
this.splitContainer1.Panel1.Controls.Add(this.componentLabel);
|
this.splitContainer1.Panel1.Controls.Add(this.componentLabel);
|
||||||
@ -73,10 +77,27 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
// splitContainer1.Panel2
|
// splitContainer1.Panel2
|
||||||
//
|
//
|
||||||
this.splitContainer1.Panel2.Controls.Add(this.listViewEx);
|
this.splitContainer1.Panel2.Controls.Add(this.listViewEx);
|
||||||
this.splitContainer1.Size = new System.Drawing.Size(600, 300);
|
this.splitContainer1.Size = new System.Drawing.Size(650, 300);
|
||||||
this.splitContainer1.SplitterDistance = 110;
|
this.splitContainer1.SplitterDistance = 110;
|
||||||
this.splitContainer1.TabIndex = 2;
|
this.splitContainer1.TabIndex = 2;
|
||||||
//
|
//
|
||||||
|
// unitLabel
|
||||||
|
//
|
||||||
|
this.unitLabel.AutoSize = true;
|
||||||
|
this.unitLabel.Location = new System.Drawing.Point(14, 60);
|
||||||
|
this.unitLabel.Name = "unitLabel";
|
||||||
|
this.unitLabel.Size = new System.Drawing.Size(100, 13);
|
||||||
|
this.unitLabel.TabIndex = 8;
|
||||||
|
this.unitLabel.Text = "Unit of temperature:";
|
||||||
|
//
|
||||||
|
// unitComboBox
|
||||||
|
//
|
||||||
|
this.unitComboBox.FormattingEnabled = true;
|
||||||
|
this.unitComboBox.Location = new System.Drawing.Point(123, 57);
|
||||||
|
this.unitComboBox.Name = "unitComboBox";
|
||||||
|
this.unitComboBox.Size = new System.Drawing.Size(62, 21);
|
||||||
|
this.unitComboBox.TabIndex = 1;
|
||||||
|
//
|
||||||
// calibrationGroupBox
|
// calibrationGroupBox
|
||||||
//
|
//
|
||||||
this.calibrationGroupBox.Controls.Add(this.calibExpirationDateTimePicker);
|
this.calibrationGroupBox.Controls.Add(this.calibExpirationDateTimePicker);
|
||||||
@ -92,6 +113,26 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
this.calibrationGroupBox.TabStop = false;
|
this.calibrationGroupBox.TabStop = false;
|
||||||
this.calibrationGroupBox.Text = "Calibration";
|
this.calibrationGroupBox.Text = "Calibration";
|
||||||
//
|
//
|
||||||
|
// calibExpirationDateTimePicker
|
||||||
|
//
|
||||||
|
this.calibExpirationDateTimePicker.CustomFormat = "dd.MM.yyyy";
|
||||||
|
this.calibExpirationDateTimePicker.Enabled = false;
|
||||||
|
this.calibExpirationDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
|
||||||
|
this.calibExpirationDateTimePicker.Location = new System.Drawing.Point(117, 59);
|
||||||
|
this.calibExpirationDateTimePicker.Name = "calibExpirationDateTimePicker";
|
||||||
|
this.calibExpirationDateTimePicker.Size = new System.Drawing.Size(82, 20);
|
||||||
|
this.calibExpirationDateTimePicker.TabIndex = 19;
|
||||||
|
//
|
||||||
|
// calibDateTimePicker
|
||||||
|
//
|
||||||
|
this.calibDateTimePicker.CustomFormat = "dd.MM.yyyy";
|
||||||
|
this.calibDateTimePicker.Enabled = false;
|
||||||
|
this.calibDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
|
||||||
|
this.calibDateTimePicker.Location = new System.Drawing.Point(117, 37);
|
||||||
|
this.calibDateTimePicker.Name = "calibDateTimePicker";
|
||||||
|
this.calibDateTimePicker.Size = new System.Drawing.Size(82, 20);
|
||||||
|
this.calibDateTimePicker.TabIndex = 18;
|
||||||
|
//
|
||||||
// calibValidDateLabel
|
// calibValidDateLabel
|
||||||
//
|
//
|
||||||
this.calibValidDateLabel.AutoSize = true;
|
this.calibValidDateLabel.AutoSize = true;
|
||||||
@ -113,7 +154,7 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
// calibCertificateNrTextBox
|
// calibCertificateNrTextBox
|
||||||
//
|
//
|
||||||
this.calibCertificateNrTextBox.Enabled = false;
|
this.calibCertificateNrTextBox.Enabled = false;
|
||||||
this.calibCertificateNrTextBox.Location = new System.Drawing.Point(120, 15);
|
this.calibCertificateNrTextBox.Location = new System.Drawing.Point(117, 15);
|
||||||
this.calibCertificateNrTextBox.Name = "calibCertificateNrTextBox";
|
this.calibCertificateNrTextBox.Name = "calibCertificateNrTextBox";
|
||||||
this.calibCertificateNrTextBox.Size = new System.Drawing.Size(82, 20);
|
this.calibCertificateNrTextBox.Size = new System.Drawing.Size(82, 20);
|
||||||
this.calibCertificateNrTextBox.TabIndex = 11;
|
this.calibCertificateNrTextBox.TabIndex = 11;
|
||||||
@ -135,14 +176,14 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
this.testGroupBox.Controls.Add(this.measuredLabel);
|
this.testGroupBox.Controls.Add(this.measuredLabel);
|
||||||
this.testGroupBox.Location = new System.Drawing.Point(428, 12);
|
this.testGroupBox.Location = new System.Drawing.Point(428, 12);
|
||||||
this.testGroupBox.Name = "testGroupBox";
|
this.testGroupBox.Name = "testGroupBox";
|
||||||
this.testGroupBox.Size = new System.Drawing.Size(157, 86);
|
this.testGroupBox.Size = new System.Drawing.Size(200, 86);
|
||||||
this.testGroupBox.TabIndex = 4;
|
this.testGroupBox.TabIndex = 4;
|
||||||
this.testGroupBox.TabStop = false;
|
this.testGroupBox.TabStop = false;
|
||||||
this.testGroupBox.Text = "Test";
|
this.testGroupBox.Text = "Test";
|
||||||
//
|
//
|
||||||
// correctedTextBox
|
// correctedTextBox
|
||||||
//
|
//
|
||||||
this.correctedTextBox.Location = new System.Drawing.Point(74, 49);
|
this.correctedTextBox.Location = new System.Drawing.Point(115, 49);
|
||||||
this.correctedTextBox.Name = "correctedTextBox";
|
this.correctedTextBox.Name = "correctedTextBox";
|
||||||
this.correctedTextBox.ReadOnly = true;
|
this.correctedTextBox.ReadOnly = true;
|
||||||
this.correctedTextBox.Size = new System.Drawing.Size(73, 20);
|
this.correctedTextBox.Size = new System.Drawing.Size(73, 20);
|
||||||
@ -150,7 +191,7 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
//
|
//
|
||||||
// measuredTextBox
|
// measuredTextBox
|
||||||
//
|
//
|
||||||
this.measuredTextBox.Location = new System.Drawing.Point(74, 24);
|
this.measuredTextBox.Location = new System.Drawing.Point(115, 24);
|
||||||
this.measuredTextBox.Name = "measuredTextBox";
|
this.measuredTextBox.Name = "measuredTextBox";
|
||||||
this.measuredTextBox.Size = new System.Drawing.Size(73, 20);
|
this.measuredTextBox.Size = new System.Drawing.Size(73, 20);
|
||||||
this.measuredTextBox.TabIndex = 4;
|
this.measuredTextBox.TabIndex = 4;
|
||||||
@ -168,7 +209,7 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
// measuredLabel
|
// measuredLabel
|
||||||
//
|
//
|
||||||
this.measuredLabel.AutoSize = true;
|
this.measuredLabel.AutoSize = true;
|
||||||
this.measuredLabel.Location = new System.Drawing.Point(6, 31);
|
this.measuredLabel.Location = new System.Drawing.Point(7, 27);
|
||||||
this.measuredLabel.Name = "measuredLabel";
|
this.measuredLabel.Name = "measuredLabel";
|
||||||
this.measuredLabel.Size = new System.Drawing.Size(54, 13);
|
this.measuredLabel.Size = new System.Drawing.Size(54, 13);
|
||||||
this.measuredLabel.TabIndex = 2;
|
this.measuredLabel.TabIndex = 2;
|
||||||
@ -201,39 +242,19 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
this.listViewEx.GridLines = true;
|
this.listViewEx.GridLines = true;
|
||||||
this.listViewEx.Location = new System.Drawing.Point(0, 0);
|
this.listViewEx.Location = new System.Drawing.Point(0, 0);
|
||||||
this.listViewEx.Name = "listViewEx";
|
this.listViewEx.Name = "listViewEx";
|
||||||
this.listViewEx.Size = new System.Drawing.Size(600, 186);
|
this.listViewEx.Size = new System.Drawing.Size(650, 186);
|
||||||
this.listViewEx.TabIndex = 0;
|
this.listViewEx.TabIndex = 0;
|
||||||
this.listViewEx.UseCompatibleStateImageBehavior = false;
|
this.listViewEx.UseCompatibleStateImageBehavior = false;
|
||||||
this.listViewEx.View = System.Windows.Forms.View.Details;
|
this.listViewEx.View = System.Windows.Forms.View.Details;
|
||||||
this.listViewEx.SelectedIndexChanged += new System.EventHandler(this.listViewEx_SelectedIndexChanged);
|
this.listViewEx.SelectedIndexChanged += new System.EventHandler(this.listViewEx_SelectedIndexChanged);
|
||||||
//
|
//
|
||||||
// calibExpirationDateTimePicker
|
|
||||||
//
|
|
||||||
this.calibExpirationDateTimePicker.CustomFormat = "dd.MM.yyyy";
|
|
||||||
this.calibExpirationDateTimePicker.Enabled = false;
|
|
||||||
this.calibExpirationDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
|
|
||||||
this.calibExpirationDateTimePicker.Location = new System.Drawing.Point(120, 59);
|
|
||||||
this.calibExpirationDateTimePicker.Name = "calibExpirationDateTimePicker";
|
|
||||||
this.calibExpirationDateTimePicker.Size = new System.Drawing.Size(82, 20);
|
|
||||||
this.calibExpirationDateTimePicker.TabIndex = 19;
|
|
||||||
//
|
|
||||||
// calibDateTimePicker
|
|
||||||
//
|
|
||||||
this.calibDateTimePicker.CustomFormat = "dd.MM.yyyy";
|
|
||||||
this.calibDateTimePicker.Enabled = false;
|
|
||||||
this.calibDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
|
|
||||||
this.calibDateTimePicker.Location = new System.Drawing.Point(120, 37);
|
|
||||||
this.calibDateTimePicker.Name = "calibDateTimePicker";
|
|
||||||
this.calibDateTimePicker.Size = new System.Drawing.Size(82, 20);
|
|
||||||
this.calibDateTimePicker.TabIndex = 18;
|
|
||||||
//
|
|
||||||
// MetrologyDlgTempMeterTab
|
// MetrologyDlgTempMeterTab
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.Controls.Add(this.splitContainer1);
|
this.Controls.Add(this.splitContainer1);
|
||||||
this.Name = "MetrologyDlgTempMeterTab";
|
this.Name = "MetrologyDlgTempMeterTab";
|
||||||
this.Size = new System.Drawing.Size(600, 300);
|
this.Size = new System.Drawing.Size(650, 300);
|
||||||
this.Load += new System.EventHandler(this.MetrologyDlgTempMeterTab_Load);
|
this.Load += new System.EventHandler(this.MetrologyDlgTempMeterTab_Load);
|
||||||
this.splitContainer1.Panel1.ResumeLayout(false);
|
this.splitContainer1.Panel1.ResumeLayout(false);
|
||||||
this.splitContainer1.Panel1.PerformLayout();
|
this.splitContainer1.Panel1.PerformLayout();
|
||||||
@ -266,6 +287,8 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
private System.Windows.Forms.Label calibCertificateNrLabel;
|
private System.Windows.Forms.Label calibCertificateNrLabel;
|
||||||
private System.Windows.Forms.DateTimePicker calibExpirationDateTimePicker;
|
private System.Windows.Forms.DateTimePicker calibExpirationDateTimePicker;
|
||||||
private System.Windows.Forms.DateTimePicker calibDateTimePicker;
|
private System.Windows.Forms.DateTimePicker calibDateTimePicker;
|
||||||
|
private System.Windows.Forms.Label unitLabel;
|
||||||
|
private System.Windows.Forms.ComboBox unitComboBox;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
///
|
///
|
||||||
/// Copyright (c) 2017-2020 Sensus Slovensko a.s.
|
/// Copyright (c) 2017-2022 Sensus Slovensko a.s.
|
||||||
///
|
///
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -18,6 +18,8 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
{
|
{
|
||||||
static readonly ILog log = LogManager.GetLogger(typeof(MetrologyDlgTempMeterTab));
|
static readonly ILog log = LogManager.GetLogger(typeof(MetrologyDlgTempMeterTab));
|
||||||
|
|
||||||
|
public const int SignifDigits = 5;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Component entity that has a list of 'measurement-correction' pairs
|
/// Component entity that has a list of 'measurement-correction' pairs
|
||||||
/// to be updated in the database on OK.
|
/// to be updated in the database on OK.
|
||||||
@ -30,7 +32,7 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Balance configuration (with buoyancy parameters)
|
/// Calibration information configuration
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Rig.GenericDevices.ICalibInfoCfg CalibInfoCfg;
|
public Rig.GenericDevices.ICalibInfoCfg CalibInfoCfg;
|
||||||
|
|
||||||
@ -50,6 +52,8 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
Control correctionTextBox;
|
Control correctionTextBox;
|
||||||
Control errorTextBox;
|
Control errorTextBox;
|
||||||
|
|
||||||
|
Unit currentUnit;
|
||||||
|
|
||||||
public MetrologyDlgTempMeterTab()
|
public MetrologyDlgTempMeterTab()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -58,8 +62,8 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
calibExpirationDateTimePicker.CustomFormat = Constants.DateFormat;
|
calibExpirationDateTimePicker.CustomFormat = Constants.DateFormat;
|
||||||
calibExpirationDateTimePicker.MinDate = Constants.MinDate;
|
calibExpirationDateTimePicker.MinDate = Constants.MinDate;
|
||||||
toBeRemoved = new List<MeasurementCorrection>();
|
toBeRemoved = new List<MeasurementCorrection>();
|
||||||
unlocked = false;
|
unlocked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MetrologyDlgTempMeterTab_Load(object sender, System.EventArgs e)
|
private void MetrologyDlgTempMeterTab_Load(object sender, System.EventArgs e)
|
||||||
{
|
{
|
||||||
@ -72,31 +76,43 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
/// Panel1
|
/// Panel1
|
||||||
cmpntNameLabel.Text = meterEntity.Name;
|
cmpntNameLabel.Text = meterEntity.Name;
|
||||||
|
|
||||||
|
for (Unit u = 0; u < Unit.Count; u++)
|
||||||
|
if (Units.IsTemperature(u))
|
||||||
|
unitComboBox.Items.Add(u.ToDescription());
|
||||||
|
|
||||||
/// Panel2
|
/// Panel2
|
||||||
this.Controls.Add(measurementTextBox = new TextBox());
|
this.Controls.Add(measurementTextBox = new TextBox());
|
||||||
this.Controls.Add(correctionTextBox = new TextBox());
|
this.Controls.Add(correctionTextBox = new TextBox());
|
||||||
this.Controls.Add(errorTextBox = new TextBox());
|
this.Controls.Add(errorTextBox = new TextBox());
|
||||||
|
|
||||||
|
currentUnit = TBF.Rig.Sequences.ProcessData.TempUnit;
|
||||||
|
unitComboBox.Text = currentUnit.ToDescription();
|
||||||
|
InitializeColumns(listViewEx, currentUnit);
|
||||||
|
RefreshAll();
|
||||||
|
|
||||||
listViewEx.SubItemClicked += new SubItemEventHandler(listViewEx_SubItemClicked);
|
listViewEx.SubItemClicked += new SubItemEventHandler(listViewEx_SubItemClicked);
|
||||||
listViewEx.SubItemEndEditing += new SubItemEndEditingEventHandler(listViewEx_SubItemEndEditing);
|
listViewEx.SubItemEndEditing += new SubItemEndEditingEventHandler(listViewEx_SubItemEndEditing);
|
||||||
|
unitComboBox.SelectedIndexChanged += new System.EventHandler(unitComboBox_SelectedIndexChanged);
|
||||||
listViewEx.Columns.Add(new ColumnHeader() { Text = Strings.Nr, Width = 40 });
|
|
||||||
listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [°C]", Strings.Temperature), Width = 120 });
|
|
||||||
listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [1/1000 °C]", Strings.Correction), Width = 150 });
|
|
||||||
listViewEx.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [%]", Strings.Error), Width = 100 });
|
|
||||||
|
|
||||||
RefreshAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InitializeColumns(ListView lv, Unit unit)
|
||||||
|
{
|
||||||
|
lv.Columns.Clear();
|
||||||
|
lv.Columns.Add(new ColumnHeader() { Text = Strings.Nr, Width = 40 });
|
||||||
|
lv.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [{1}]", Strings.Temperature, unit.ToDescription()), Width = 120 });
|
||||||
|
lv.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [{1}]", Strings.Correction, unit.ToDescription()), Width = 150 });
|
||||||
|
lv.Columns.Add(new ColumnHeader() { Text = string.Format("{0} [%]", Strings.Error), Width = 100 });
|
||||||
|
|
||||||
|
measuredLabel.Text = string.Format("{0} [{1}]:", Strings.Measured, unit.ToDescription());
|
||||||
|
correctedLabel.Text = string.Format("{0} [{1}]:", Strings.Corrected, unit.ToDescription());
|
||||||
|
measuredTextBox.Text = string.Empty;
|
||||||
|
correctedTextBox.Text = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
void Localize()
|
void Localize()
|
||||||
{
|
{
|
||||||
componentLabel.Text = Strings.Component;
|
componentLabel.Text = Strings.Component;
|
||||||
testGroupBox.Text = Strings.Test_measured_corrected;
|
testGroupBox.Text = Strings.Test_measured_corrected;
|
||||||
measuredLabel.Text = Strings.Measured;
|
|
||||||
correctedLabel.Text = Strings.Corrected;
|
|
||||||
measuredTextBox.Text = string.Empty;
|
|
||||||
correctedTextBox.Text = string.Empty;
|
|
||||||
|
|
||||||
calibrationGroupBox.Text = Strings.Calibration;
|
calibrationGroupBox.Text = Strings.Calibration;
|
||||||
calibCertificateNrLabel.Text = Strings.Certificate;
|
calibCertificateNrLabel.Text = Strings.Certificate;
|
||||||
calibDateLabel.Text = Strings.Date;
|
calibDateLabel.Text = Strings.Date;
|
||||||
@ -112,7 +128,7 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
calibExpirationDateTimePicker.Value = (CalibInfoCfg.CalibValidDate < Constants.MinDate) ? Constants.MinDate : CalibInfoCfg.CalibValidDate;
|
calibExpirationDateTimePicker.Value = (CalibInfoCfg.CalibValidDate < Constants.MinDate) ? Constants.MinDate : CalibInfoCfg.CalibValidDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
listViewEx.Items.Clear();
|
listViewEx.Items.Clear();
|
||||||
foreach (var corr in MeterEntity.Corrections) AddOneLVI(corr);
|
foreach (var corr in MeterEntity.Corrections) AddOneLVI(corr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,8 +137,12 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
int nr = listViewEx.Items.Count + 1;
|
int nr = listViewEx.Items.Count + 1;
|
||||||
ListViewItem lvi = new ListViewItem(nr.ToString());
|
ListViewItem lvi = new ListViewItem(nr.ToString());
|
||||||
lvi.Tag = corr;
|
lvi.Tag = corr;
|
||||||
lvi.SubItems.Add(corr.Measurement.ToString());
|
lvi.SubItems.Add(Units.ConvertTo(currentUnit, corr.Measurement).ToString());
|
||||||
lvi.SubItems.Add((1000 * corr.Correction).ToString());
|
double trueValue = corr.Measurement + corr.Correction;
|
||||||
|
double difference = Units.IsDefaultUnit(currentUnit)
|
||||||
|
? corr.Correction
|
||||||
|
: Units.ConvertTo(currentUnit, trueValue) - Units.ConvertTo(currentUnit, corr.Measurement);
|
||||||
|
lvi.SubItems.Add(Common.Utils.ToNiceString(difference, SignifDigits));
|
||||||
|
|
||||||
if (corr.Measurement == 0)
|
if (corr.Measurement == 0)
|
||||||
{
|
{
|
||||||
@ -130,8 +150,8 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
double error = Formulas.ErrorFromVolumes(corr.Measurement, corr.Measurement + corr.Correction);
|
double error = Formulas.ErrorFromVolumes(corr.Measurement, trueValue);
|
||||||
lvi.SubItems.Add(error.ToString(Common.Utils.SignificantDigitsToFmt(error, 5)));
|
lvi.SubItems.Add(Common.Utils.ToNiceString(error, SignifDigits));
|
||||||
}
|
}
|
||||||
|
|
||||||
listViewEx.Items.Add(lvi);
|
listViewEx.Items.Add(lvi);
|
||||||
@ -168,18 +188,23 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
/// <returns>true = value parsed OK</returns>
|
/// <returns>true = value parsed OK</returns>
|
||||||
bool ParseItem(ListViewItem item, int subItem, string strValue)
|
bool ParseItem(ListViewItem item, int subItem, string strValue)
|
||||||
{
|
{
|
||||||
double dblValue = 0;
|
double oriMeasurement; /// Measurement in selected units
|
||||||
if (subItem == 1 && Utils.TryParseEDouble(strValue, out dblValue) && dblValue >= 0)
|
double measurement; /// Measurement in default units
|
||||||
|
double difference; /// Correction in selected unit
|
||||||
|
double correction; /// Correction in default unit
|
||||||
|
double error = 0;
|
||||||
|
|
||||||
|
if (subItem == 1 && Utils.TryParseEDouble(strValue, out oriMeasurement) && (measurement = Units.ConvertFrom(currentUnit, oriMeasurement)) >= 0)
|
||||||
{
|
{
|
||||||
(item.Tag as MeasurementCorrection).Measurement = (float)dblValue;
|
(item.Tag as MeasurementCorrection).Measurement = measurement;
|
||||||
|
|
||||||
/// Update error (if possible)
|
/// Update error (if possible)
|
||||||
double correction1000;
|
if (Utils.TryParseEDouble(item.SubItems[2].Text, out difference) && (measurement != 0))
|
||||||
if (Utils.TryParseEDouble(item.SubItems[2].Text, out correction1000) && (dblValue != 0))
|
|
||||||
{
|
{
|
||||||
double correction = correction1000 / 1000;
|
correction = Units.IsDefaultUnit(currentUnit) ? difference
|
||||||
double error = Formulas.ErrorFromVolumes(dblValue, dblValue + correction);
|
: Units.ConvertFrom(currentUnit, oriMeasurement + difference) - Units.ConvertFrom(currentUnit, oriMeasurement);
|
||||||
item.SubItems[3].Text = error.ToString(Common.Utils.SignificantDigitsToFmt(error, 5));
|
error = Formulas.ErrorFromVolumes(measurement, measurement + correction);
|
||||||
|
item.SubItems[3].Text = Common.Utils.ToNiceString(error, SignifDigits);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -188,39 +213,48 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (subItem == 2 && Utils.TryParseEDouble(strValue, out dblValue))
|
else if (subItem == 2 && Utils.TryParseEDouble(strValue, out difference))
|
||||||
{
|
{
|
||||||
double correctionInDefaultUnits = dblValue / 1000;
|
if (Utils.TryParseEDouble(item.SubItems[1].Text, out oriMeasurement))
|
||||||
(item.Tag as MeasurementCorrection).Correction = (float)correctionInDefaultUnits;
|
{
|
||||||
|
measurement = Units.ConvertFrom(currentUnit, oriMeasurement);
|
||||||
|
correction = Units.IsDefaultUnit(currentUnit) ? difference
|
||||||
|
: Units.ConvertFrom(currentUnit, oriMeasurement + difference) - Units.ConvertFrom(currentUnit, oriMeasurement);
|
||||||
|
(item.Tag as MeasurementCorrection).Correction = correction;
|
||||||
|
|
||||||
/// Update error (if possible)
|
/// Update error (if possible)
|
||||||
double measurement;
|
if (measurement != 0)
|
||||||
if (Utils.TryParseEDouble(item.SubItems[1].Text, out measurement) && (measurement != 0))
|
{
|
||||||
{
|
error = Formulas.ErrorFromVolumes(measurement, measurement + correction);
|
||||||
double error = Formulas.ErrorFromVolumes(measurement, measurement + correctionInDefaultUnits);
|
item.SubItems[3].Text = Common.Utils.ToNiceString(error, SignifDigits);
|
||||||
item.SubItems[3].Text = error.ToString(Common.Utils.SignificantDigitsToFmt(error, 5));
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
item.SubItems[3].Text = Strings.NaN;
|
||||||
item.SubItems[3].Text = Strings.NaN;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (subItem == 3 && ((strValue == Strings.NaN) || Utils.TryParseEDouble(strValue, out dblValue)))
|
else if (subItem == 3 && ((strValue == Strings.NaN) || Utils.TryParseEDouble(strValue, out error)))
|
||||||
{
|
{
|
||||||
if (strValue == Strings.NaN)
|
if (strValue == Strings.NaN)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
double measurement;
|
if (Utils.TryParseEDouble(item.SubItems[1].Text, out oriMeasurement) && (measurement = Units.ConvertFrom(currentUnit, oriMeasurement)) != 0)
|
||||||
if (Utils.TryParseEDouble(item.SubItems[1].Text, out measurement) && measurement != 0)
|
|
||||||
{
|
{
|
||||||
double correction = Formulas.CorrectionFromError(measurement, dblValue);
|
correction = Formulas.CorrectionFromError(measurement, error);
|
||||||
double correction1000 = 1000 * correction;
|
(item.Tag as MeasurementCorrection).Correction = correction;
|
||||||
item.SubItems[2].Text = correction1000.ToString(Common.Utils.SignificantDigitsToFmt(correction1000, 5));
|
difference = Units.IsDefaultUnit(currentUnit)
|
||||||
(item.Tag as MeasurementCorrection).Correction = (float)correction;
|
? correction
|
||||||
|
: Units.ConvertTo(currentUnit, measurement + correction) - oriMeasurement;
|
||||||
|
item.SubItems[2].Text = Common.Utils.ToNiceString(difference, SignifDigits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,18 +384,21 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
|
|
||||||
private void measuredTextBox_TextChanged(object sender, EventArgs e)
|
private void measuredTextBox_TextChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
float measured;
|
double measured;
|
||||||
if (float.TryParse(measuredTextBox.Text,
|
if (double.TryParse(measuredTextBox.Text,
|
||||||
NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowExponent,
|
NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowExponent,
|
||||||
CultureInfo.CurrentCulture,
|
CultureInfo.CurrentCulture,
|
||||||
out measured) ||
|
out measured) ||
|
||||||
float.TryParse(measuredTextBox.Text,
|
double.TryParse(measuredTextBox.Text,
|
||||||
NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowExponent,
|
NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign | NumberStyles.AllowExponent,
|
||||||
CultureInfo.InvariantCulture,
|
CultureInfo.InvariantCulture,
|
||||||
out measured))
|
out measured))
|
||||||
{
|
{
|
||||||
double corrected = MeasurementCorrection.CorrectedValue(measured, meterEntity.Corrections);
|
var corrections = new List<MeasurementCorrection>();
|
||||||
correctedTextBox.Text = corrected.ToString();
|
foreach (var c in meterEntity.Corrections) corrections.Add(c);
|
||||||
|
corrections.Sort();
|
||||||
|
double corrected = MeasurementCorrection.CorrectedValue(Units.ConvertFrom(currentUnit, measured), corrections);
|
||||||
|
correctedTextBox.Text = Units.ConvertTo(currentUnit, corrected).ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,5 +415,20 @@ namespace TBF.UI.Bench.Metrology
|
|||||||
{
|
{
|
||||||
session.SaveOrUpdate(MeterEntity);
|
session.SaveOrUpdate(MeterEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void unitComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
for (Unit u = 0; u < Unit.Count; u++)
|
||||||
|
{
|
||||||
|
if (u.ToDescription() == unitComboBox.Text)
|
||||||
|
{
|
||||||
|
currentUnit = u;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
InitializeColumns(listViewEx, currentUnit);
|
||||||
|
RefreshAll();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user