223 lines
7.3 KiB
C#
223 lines
7.3 KiB
C#
///
|
|
/// Copyright (c) 2016 Sensus Metering Systems
|
|
///
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.Windows.Forms;
|
|
using log4net;
|
|
using Config.Entities;
|
|
using TBF.Resources;
|
|
|
|
namespace TBF.UiControls
|
|
{
|
|
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 { return meterEntity; }
|
|
set { meterEntity = value; }
|
|
}
|
|
Component meterEntity;
|
|
|
|
/// <summary>
|
|
/// Balance configuration (with buoyancy parameters)
|
|
/// </summary>
|
|
public BenchControl.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 { return toBeRemoved; }
|
|
set { toBeRemoved = value; }
|
|
}
|
|
IList<MeasurementCorrection> toBeRemoved;
|
|
|
|
MetrologyDlg parent;
|
|
bool unlocked;
|
|
|
|
public MetrologyDlgPlatinumResistanceTMeterTab()
|
|
{
|
|
InitializeComponent();
|
|
toBeRemoved = new List<MeasurementCorrection>();
|
|
unlocked = false;
|
|
}
|
|
|
|
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;
|
|
|
|
calibrationGroupBox.Text = Strings.Calibration;
|
|
calibCertificateNrLabel.Text = Strings.Certificate;
|
|
calibDateLabel.Text = Strings.Date;
|
|
calibValidDateLabel.Text = Strings.Valid_until;
|
|
|
|
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)
|
|
{
|
|
calibCertificateNrTextBox.Text = TempMeterCfg.CalibCertificateNr;
|
|
calibDateTextBox.Text = TempMeterCfg.CalibDate.ToShortDateString();
|
|
calibValidDateTextBox.Text = TempMeterCfg.CalibValidDate.ToShortDateString();
|
|
|
|
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()
|
|
{
|
|
unlocked = true;
|
|
|
|
calibCertificateNrTextBox.Enabled = true;
|
|
calibDateTextBox.Enabled = true;
|
|
calibValidDateTextBox.Enabled = true;
|
|
|
|
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
|
|
{
|
|
TempMeterCfg.CalibCertificateNr = calibCertificateNrTextBox.Text;
|
|
TempMeterCfg.CalibDate = DateTime.Parse(calibDateTextBox.Text);
|
|
TempMeterCfg.CalibValidDate = DateTime.Parse(calibValidDateTextBox.Text);
|
|
|
|
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 = BenchControl.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 = BenchControl.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()
|
|
{
|
|
}
|
|
}
|
|
}
|