198 lines
6.6 KiB
C#
198 lines
6.6 KiB
C#
///
|
|
/// Copyright (c) 2016-2023 Senus Slovensko a.s.
|
|
///
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Windows.Forms;
|
|
using log4net;
|
|
using Config;
|
|
using Config.Entities;
|
|
using TBF.Resources;
|
|
|
|
namespace TBF.UI.Bench.Metrology
|
|
{
|
|
public partial class MetrologyDlgPlatinumResistanceTMeterTab : UserControl, IMetrologyDlgTab
|
|
{
|
|
static readonly ILog log = LogManager.GetLogger(typeof(MetrologyDlgPlatinumResistanceTMeterTab));
|
|
|
|
/// <summary>
|
|
/// Component entity that has a list of 'measurement-correction' pairs
|
|
/// to be updated in the database on OK.
|
|
/// </summary>
|
|
public Component MeterEntity { get; set; }
|
|
|
|
/// <summary>
|
|
/// Balance configuration (with buoyancy parameters)
|
|
/// </summary>
|
|
public Rig.Keithley.TempMeter.TempMeterCfg TempMeterCfg;
|
|
|
|
/// <summary>
|
|
/// A list of 'measurement-correction' pairs to be deleted from the database on OK.
|
|
/// </summary>
|
|
public IList<MeasurementCorrection> ToBeRemoved { get; set; }
|
|
|
|
MetrologyDlg parent;
|
|
|
|
public MetrologyDlgPlatinumResistanceTMeterTab()
|
|
{
|
|
InitializeComponent();
|
|
ToBeRemoved = new List<MeasurementCorrection>();
|
|
}
|
|
|
|
private void MetrologyDlgBalanceTab_Load(object sender, System.EventArgs e)
|
|
{
|
|
if (MeterEntity == null) return;
|
|
|
|
parent = ParentForm as MetrologyDlg;
|
|
|
|
Localize();
|
|
|
|
/// Panel1
|
|
cmpntNameLabel.Text = TempMeterCfg.Name;
|
|
resistanceTextBox.Text = string.Empty;
|
|
temperatureTextBox.Text = string.Empty;
|
|
|
|
RefreshAll();
|
|
}
|
|
|
|
void Localize()
|
|
{
|
|
nameGroupBox.Text = Strings.Component;
|
|
|
|
testGroupBox.Text = Strings.Test;
|
|
resistanceLabel.Text = string.Format("{0} [Ω]", Strings.Resistance);
|
|
temperatureLabel.Text = string.Format("{0} [°C]", Strings.Temperature);
|
|
|
|
radioButton1.Text = string.Format(Strings.Use_0, Strings.ITS90_calibration_coefficients);
|
|
radioButton2.Text = string.Format(Strings.Use_0, Strings.ITS27_calibration_coefficients);
|
|
|
|
its90CalibrationCoefficientsGroupBox.Text = Strings.ITS90_calibration_coefficients;
|
|
its27CalibrationCoefficientsGroupBox.Text = Strings.ITS27_calibration_coefficients;
|
|
}
|
|
|
|
void RefreshAll()
|
|
{
|
|
if (TempMeterCfg != null)
|
|
{
|
|
calibCertificateCtrl.Refresh(TempMeterCfg);
|
|
|
|
radioButton1.Checked = TempMeterCfg.UseITS90;
|
|
radioButton2.Checked = !TempMeterCfg.UseITS90;
|
|
|
|
r001cTextBox.Text = TempMeterCfg.R001C.ToString();
|
|
a7TextBox.Text = TempMeterCfg.a7.ToString();
|
|
b7TextBox.Text = TempMeterCfg.b7.ToString();
|
|
c7TextBox.Text = TempMeterCfg.c7.ToString();
|
|
|
|
r0TextBox.Text = TempMeterCfg.R0.ToString();
|
|
aTextBox.Text = TempMeterCfg.A.ToString();
|
|
bTextBox.Text = TempMeterCfg.B.ToString();
|
|
}
|
|
}
|
|
|
|
public void Unlock()
|
|
{
|
|
calibCertificateCtrl.Unlock();
|
|
|
|
radioButton1.Enabled = true;
|
|
radioButton2.Enabled = true;
|
|
|
|
r001cTextBox.Enabled = true;
|
|
a7TextBox.Enabled = true;
|
|
b7TextBox.Enabled = true;
|
|
c7TextBox.Enabled = true;
|
|
|
|
r0TextBox.Enabled = true;
|
|
aTextBox.Enabled = true;
|
|
bTextBox.Enabled = true;
|
|
}
|
|
|
|
public void OkBtnClicked()
|
|
{
|
|
if (TempMeterCfg != null)
|
|
{
|
|
try
|
|
{
|
|
calibCertificateCtrl.Update(TempMeterCfg);
|
|
|
|
TempMeterCfg.UseITS90 = radioButton1.Checked;
|
|
|
|
TempMeterCfg.R001C = Utils.ParseUDouble(r001cTextBox.Text);
|
|
TempMeterCfg.a7 = Utils.ParseEDouble(a7TextBox.Text);
|
|
TempMeterCfg.b7 = Utils.ParseEDouble(b7TextBox.Text);
|
|
TempMeterCfg.c7 = Utils.ParseEDouble(c7TextBox.Text);
|
|
|
|
TempMeterCfg.R0 = Utils.ParseUDouble(r0TextBox.Text);
|
|
TempMeterCfg.A = Utils.ParseEDouble(aTextBox.Text);
|
|
TempMeterCfg.B = Utils.ParseEDouble(bTextBox.Text);
|
|
|
|
Component modified = TempMeterCfg.CreateDbEntity();
|
|
MeterEntity.Parameters = modified.Parameters;
|
|
}
|
|
catch
|
|
{
|
|
MessageBox.Show(string.Format(Strings.Invalid_0, Strings.Calibration_coefficients),
|
|
Strings.Error,
|
|
MessageBoxButtons.OK,
|
|
MessageBoxIcon.Exclamation);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void measuredTextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
double resistance;
|
|
if (Utils.TryParseUDouble(resistanceTextBox.Text, out resistance))
|
|
{
|
|
try
|
|
{
|
|
double temperature;
|
|
if (radioButton1.Checked)
|
|
{
|
|
double R001C = Utils.ParseUDouble(r001cTextBox.Text);
|
|
double a7 = Utils.ParseEDouble(a7TextBox.Text);
|
|
double b7 = Utils.ParseEDouble(b7TextBox.Text);
|
|
double c7 = Utils.ParseEDouble(c7TextBox.Text);
|
|
temperature = Formulas.PlatinumResistanceTM_ITS90_R2T(resistance, R001C, a7, b7, c7);
|
|
}
|
|
else
|
|
{
|
|
double R0 = Utils.ParseUDouble(r0TextBox.Text);
|
|
double a = Utils.ParseEDouble(aTextBox.Text);
|
|
double b = Utils.ParseEDouble(bTextBox.Text);
|
|
temperature = Formulas.PlatinumResistanceTM_ITS27_R2T(resistance, R0, a, b);
|
|
}
|
|
temperatureTextBox.Text = temperature.ToString();
|
|
}
|
|
catch
|
|
{
|
|
MessageBox.Show(string.Format(Strings.Invalid_0, Strings.Calibration_coefficients),
|
|
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)
|
|
{
|
|
}
|
|
|
|
public void SaveEntityToDB(NHibernate.ISession session)
|
|
{
|
|
session.SaveOrUpdate(MeterEntity);
|
|
}
|
|
}
|
|
}
|