163 lines
4.2 KiB
C#
163 lines
4.2 KiB
C#
///
|
|
/// Copyright (c) 2019 Senus Slovensko a.s.
|
|
///
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Windows.Forms;
|
|
using log4net;
|
|
using Config.Entities;
|
|
using TBF.Resources;
|
|
|
|
namespace TBF.UI.Bench.Uncertainties
|
|
{
|
|
public partial class UncertntDlgDensityTab : UserControl, IUncetaintiesDlgTab
|
|
{
|
|
static readonly ILog log = LogManager.GetLogger(typeof(UncertntDlgDensityTab));
|
|
|
|
/// <summary>
|
|
/// Component entity that has a list of 'measurement-correction' pairs
|
|
/// to be updated in the database on OK.
|
|
/// </summary>
|
|
public Component MeterEntity
|
|
{
|
|
get { return meterEntity; }
|
|
set { meterEntity = value; }
|
|
}
|
|
Component meterEntity;
|
|
|
|
/// <summary>
|
|
/// Density configuration
|
|
/// </summary>
|
|
public BenchControl.DataContainers.Density.ComponentCfg DensityCfg;
|
|
|
|
/// <summary>
|
|
/// A list of 'measurement-correction' pairs to be deleted from the database on OK.
|
|
/// </summary>
|
|
public IList<Uncertainty> ToBeRemoved
|
|
{
|
|
get { return toBeRemoved; }
|
|
set { toBeRemoved = value; }
|
|
}
|
|
IList<Uncertainty> toBeRemoved;
|
|
|
|
UncertaintiesDlg parent;
|
|
bool unlocked;
|
|
|
|
public UncertntDlgDensityTab()
|
|
{
|
|
InitializeComponent();
|
|
toBeRemoved = new List<Uncertainty>();
|
|
unlocked = false;
|
|
}
|
|
|
|
private void MetrologyDlgDensityTab_Load(object sender, System.EventArgs e)
|
|
{
|
|
if (meterEntity == null) return;
|
|
|
|
parent = ParentForm as UncertaintiesDlg;
|
|
|
|
/// Panel1
|
|
densityLabel.Text = string.Format("{0} [{1}]", Strings.Density, Config.Unit.kgpm3.ToDescription());
|
|
temperatureLabel.Text = string.Format("{0} [{1}]", Strings.At_temperature, Config.Unit.C.ToDescription());
|
|
densityCorrLabel.Text = string.Format("{0} [{1}]", Strings.Density_correction, Config.Unit.kgpm3.ToDescription());
|
|
|
|
/// Panel2
|
|
|
|
RefreshAll();
|
|
}
|
|
|
|
void RefreshAll()
|
|
{
|
|
densityTextBox.Text = Config.Data.RealDensity.ToString("F4");
|
|
temperatureTextBox.Text = Config.Data.AtTemperature.ToString("F2");
|
|
densityCorrTextBox.Text = Config.Formulas.DensityCorrection(Config.Data.RealDensity, Config.Data.AtTemperature).ToString("F5");
|
|
}
|
|
|
|
public void Unlock()
|
|
{
|
|
unlocked = true;
|
|
|
|
densityTextBox.Enabled = true;
|
|
temperatureTextBox.Enabled = true;
|
|
}
|
|
|
|
public void OkBtnClicked()
|
|
{
|
|
if (DensityCfg != null)
|
|
{
|
|
try
|
|
{
|
|
double realDensity = Utils.ParseUDouble(densityTextBox.Text);
|
|
double atTemperature = Utils.ParseUDouble(temperatureTextBox.Text);
|
|
|
|
global::Results.WMeterRsltItemSpec.RealDensity =
|
|
Config.Data.RealDensity = DensityCfg.RealDensity = realDensity;
|
|
|
|
global::Results.WMeterRsltItemSpec.AtTemperature =
|
|
Config.Data.AtTemperature = DensityCfg.AtTemperature = atTemperature;
|
|
|
|
Component modified = DensityCfg.CreateDbEntity();
|
|
MeterEntity.Parameters = modified.Parameters;
|
|
}
|
|
catch
|
|
{
|
|
MessageBox.Show(Strings.Invalid_density_parameter_Correct_pls,
|
|
Strings.Error,
|
|
MessageBoxButtons.OK,
|
|
MessageBoxIcon.Exclamation);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void CancelBtnClicked()
|
|
{
|
|
}
|
|
|
|
public void AddOne()
|
|
{
|
|
}
|
|
|
|
public void RemoveSelected()
|
|
{
|
|
}
|
|
|
|
public void MoveUpSelected()
|
|
{
|
|
}
|
|
|
|
public void MoveDownSelected()
|
|
{
|
|
}
|
|
|
|
public string GetWarningsBeforeSaving(ref Dictionary<string, string> renmInfo)
|
|
{
|
|
return string.Empty;
|
|
}
|
|
|
|
public void UpdateRelatedItems(Dictionary<string, string> renameInfo)
|
|
{
|
|
}
|
|
|
|
private void densityTextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
UpdateDensityCorrectionDisplay();
|
|
}
|
|
|
|
private void temperatureTextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
UpdateDensityCorrectionDisplay();
|
|
}
|
|
|
|
void UpdateDensityCorrectionDisplay()
|
|
{
|
|
double density;
|
|
double temp;
|
|
if (Utils.TryParseUDouble(densityTextBox.Text, out density) &&
|
|
Utils.TryParseUDouble(temperatureTextBox.Text, out temp))
|
|
{
|
|
densityCorrTextBox.Text = Config.Formulas.DensityCorrection(density, temp).ToString();
|
|
}
|
|
}
|
|
}
|
|
}
|