MiniPrf: - extended

This commit is contained in:
Thomas Wiedebusch
2026-01-15 14:38:14 +01:00
parent d69a79c034
commit 7b9c0b467f
3 changed files with 237 additions and 63 deletions
@@ -172,7 +172,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
{
_ref_pulse_per_cm = value;
if (_dut_pulse_per_cm != 0)
_refToDutScale_norm = (Single)_ref_pulse_per_cm / _dut_pulse_per_cm;
RefToDutScale_norm = (Single)_ref_pulse_per_cm / _dut_pulse_per_cm;
}
}
}
@@ -517,10 +517,10 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
responseStr = SerialPort.ReadTo(END_OF_STR);
var signMultiplier = responseStr.Contains("+") ? 1.0f : -1.0f;
var cleanedStr = responseStr.Replace("+", "").Replace("-","");
if (int.TryParse(cleanedStr, NumberStyles.HexNumber, new CultureInfo("en"), out var tolerance))
if (int.TryParse(cleanedStr, NumberStyles.HexNumber, new CultureInfo("en"), out var measTolerance))
{
var response = new CmdResponse(cmdName, info,
doubleValue: tolerance * _toleranceRawToPercentScale * signMultiplier,
doubleValue: measTolerance * _toleranceRawToPercentScale * signMultiplier,
siUnit: SiUnits.GetInfo(SiUnits.SiUnitName.PERCENTAGE_NON_SI) );
OnRawRecordReceived?.Invoke(this,
new ProcessExecEventArgs("", actualProcessMessage: measurementInfo,
+47 -43
View File
@@ -51,8 +51,8 @@
this.lblDutPulsePerVolume = new System.Windows.Forms.Label();
this.lblAttenuation = new System.Windows.Forms.Label();
this.lblScaleRefToDut = new System.Windows.Forms.Label();
this.tbxRefPulsePerVolume = new System.Windows.Forms.TextBox();
this.tbxDutPulsePerVolume = new System.Windows.Forms.TextBox();
this.tbxRefPulsePerCm = new System.Windows.Forms.TextBox();
this.tbxDutPulsePerCm = new System.Windows.Forms.TextBox();
this.tbxScaleRefToDut = new System.Windows.Forms.TextBox();
this.lblUpdateTimeValue = new System.Windows.Forms.Label();
this.tmrProgressUpdate = new System.Windows.Forms.Timer(this.components);
@@ -65,9 +65,9 @@
this.btnDutToRefRegulation = new System.Windows.Forms.Button();
this.gbxManualRefCalibration = new System.Windows.Forms.GroupBox();
this.lblPulseVolumeCmRelation = new System.Windows.Forms.Label();
this.tbxPulseVolumeCmRelation = new System.Windows.Forms.TextBox();
this.tbxRefCalibrationResultPulsePerCm = new System.Windows.Forms.TextBox();
this.lblWeightScaleVolume = new System.Windows.Forms.Label();
this.tbxWeightScaleMass = new System.Windows.Forms.TextBox();
this.tbxWeightScaleMass_liters = new System.Windows.Forms.TextBox();
this.lblMeasuredRefPulses = new System.Windows.Forms.Label();
this.tbxMeasuredRefPulses = new System.Windows.Forms.TextBox();
this.btnManualRefCalibration = new System.Windows.Forms.Button();
@@ -126,7 +126,7 @@
this.cbxFM2014TolerancePercent.Size = new System.Drawing.Size(60, 21);
this.cbxFM2014TolerancePercent.TabIndex = 35;
this.cbxFM2014TolerancePercent.Text = "3";
this.cbxFM2014TolerancePercent.SelectedValueChanged += new System.EventHandler(this.cbxFM2014ComPort_SelectedValueChanged);
this.cbxFM2014TolerancePercent.SelectedValueChanged += new System.EventHandler(this.cbxFM2014BaseSettings_SelectedValueChanged);
//
// tbxFM2014SerialNumber
//
@@ -172,7 +172,7 @@
this.cbxFM2014Address.Size = new System.Drawing.Size(60, 21);
this.cbxFM2014Address.TabIndex = 33;
this.cbxFM2014Address.Text = "1";
this.cbxFM2014Address.SelectedValueChanged += new System.EventHandler(this.cbxFM2014ComPort_SelectedValueChanged);
this.cbxFM2014Address.SelectedValueChanged += new System.EventHandler(this.cbxFM2014BaseSettings_SelectedValueChanged);
//
// lblFM2014Address
//
@@ -210,7 +210,7 @@
this.cbxFM2014ComPort.Size = new System.Drawing.Size(60, 21);
this.cbxFM2014ComPort.TabIndex = 5;
this.cbxFM2014ComPort.Text = "NA";
this.cbxFM2014ComPort.SelectedValueChanged += new System.EventHandler(this.cbxFM2014ComPort_SelectedValueChanged);
this.cbxFM2014ComPort.SelectedValueChanged += new System.EventHandler(this.cbxFM2014BaseSettings_SelectedValueChanged);
//
// lblFM2014SerialPort
//
@@ -256,8 +256,8 @@
this.gbxRegulationSetup.Controls.Add(this.lblDutPulsePerVolume);
this.gbxRegulationSetup.Controls.Add(this.lblAttenuation);
this.gbxRegulationSetup.Controls.Add(this.lblScaleRefToDut);
this.gbxRegulationSetup.Controls.Add(this.tbxRefPulsePerVolume);
this.gbxRegulationSetup.Controls.Add(this.tbxDutPulsePerVolume);
this.gbxRegulationSetup.Controls.Add(this.tbxRefPulsePerCm);
this.gbxRegulationSetup.Controls.Add(this.tbxDutPulsePerCm);
this.gbxRegulationSetup.Controls.Add(this.tbxScaleRefToDut);
this.gbxRegulationSetup.Location = new System.Drawing.Point(8, 222);
this.gbxRegulationSetup.Name = "gbxRegulationSetup";
@@ -330,23 +330,25 @@
this.lblScaleRefToDut.TabIndex = 64;
this.lblScaleRefToDut.Text = "Scale REF/DUT [norm]";
//
// tbxRefPulsePerVolume
// tbxRefPulsePerCm
//
this.tbxRefPulsePerVolume.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.tbxRefPulsePerVolume.Location = new System.Drawing.Point(140, 25);
this.tbxRefPulsePerVolume.Name = "tbxRefPulsePerVolume";
this.tbxRefPulsePerVolume.ReadOnly = true;
this.tbxRefPulsePerVolume.Size = new System.Drawing.Size(120, 20);
this.tbxRefPulsePerVolume.TabIndex = 67;
this.tbxRefPulsePerCm.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.tbxRefPulsePerCm.Location = new System.Drawing.Point(140, 25);
this.tbxRefPulsePerCm.Name = "tbxRefPulsePerCm";
this.tbxRefPulsePerCm.Size = new System.Drawing.Size(120, 20);
this.tbxRefPulsePerCm.TabIndex = 67;
this.tbxRefPulsePerCm.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tbxRefPulsePerVolume_KeyDown);
this.tbxRefPulsePerCm.Leave += new System.EventHandler(this.tbxRefPulsePerVolume_Leave);
//
// tbxDutPulsePerVolume
// tbxDutPulsePerCm
//
this.tbxDutPulsePerVolume.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.tbxDutPulsePerVolume.Location = new System.Drawing.Point(140, 50);
this.tbxDutPulsePerVolume.Name = "tbxDutPulsePerVolume";
this.tbxDutPulsePerVolume.ReadOnly = true;
this.tbxDutPulsePerVolume.Size = new System.Drawing.Size(120, 20);
this.tbxDutPulsePerVolume.TabIndex = 65;
this.tbxDutPulsePerCm.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.tbxDutPulsePerCm.Location = new System.Drawing.Point(140, 50);
this.tbxDutPulsePerCm.Name = "tbxDutPulsePerCm";
this.tbxDutPulsePerCm.Size = new System.Drawing.Size(120, 20);
this.tbxDutPulsePerCm.TabIndex = 65;
this.tbxDutPulsePerCm.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tbxDutPulsePerVolume_KeyDown);
this.tbxDutPulsePerCm.Leave += new System.EventHandler(this.tbxDutPulsePerVolume_Leave);
//
// tbxScaleRefToDut
//
@@ -440,9 +442,9 @@
// gbxManualRefCalibration
//
this.gbxManualRefCalibration.Controls.Add(this.lblPulseVolumeCmRelation);
this.gbxManualRefCalibration.Controls.Add(this.tbxPulseVolumeCmRelation);
this.gbxManualRefCalibration.Controls.Add(this.tbxRefCalibrationResultPulsePerCm);
this.gbxManualRefCalibration.Controls.Add(this.lblWeightScaleVolume);
this.gbxManualRefCalibration.Controls.Add(this.tbxWeightScaleMass);
this.gbxManualRefCalibration.Controls.Add(this.tbxWeightScaleMass_liters);
this.gbxManualRefCalibration.Controls.Add(this.lblMeasuredRefPulses);
this.gbxManualRefCalibration.Controls.Add(this.tbxMeasuredRefPulses);
this.gbxManualRefCalibration.Controls.Add(this.btnManualRefCalibration);
@@ -462,14 +464,14 @@
this.lblPulseVolumeCmRelation.TabIndex = 72;
this.lblPulseVolumeCmRelation.Text = "REF [pulses/m³]:";
//
// tbxPulseVolumeCmRelation
// tbxRefCalibrationResultPulsePerCm
//
this.tbxPulseVolumeCmRelation.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.tbxPulseVolumeCmRelation.Location = new System.Drawing.Point(140, 75);
this.tbxPulseVolumeCmRelation.Name = "tbxPulseVolumeCmRelation";
this.tbxPulseVolumeCmRelation.ReadOnly = true;
this.tbxPulseVolumeCmRelation.Size = new System.Drawing.Size(120, 20);
this.tbxPulseVolumeCmRelation.TabIndex = 73;
this.tbxRefCalibrationResultPulsePerCm.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.tbxRefCalibrationResultPulsePerCm.Location = new System.Drawing.Point(140, 75);
this.tbxRefCalibrationResultPulsePerCm.Name = "tbxRefCalibrationResultPulsePerCm";
this.tbxRefCalibrationResultPulsePerCm.ReadOnly = true;
this.tbxRefCalibrationResultPulsePerCm.Size = new System.Drawing.Size(120, 20);
this.tbxRefCalibrationResultPulsePerCm.TabIndex = 73;
//
// lblWeightScaleVolume
//
@@ -480,14 +482,15 @@
this.lblWeightScaleVolume.TabIndex = 70;
this.lblWeightScaleVolume.Text = "Weight Scale [liters]:";
//
// tbxWeightScaleMass
// tbxWeightScaleMass_liters
//
this.tbxWeightScaleMass.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.tbxWeightScaleMass.Location = new System.Drawing.Point(140, 50);
this.tbxWeightScaleMass.Name = "tbxWeightScaleMass";
this.tbxWeightScaleMass.ReadOnly = true;
this.tbxWeightScaleMass.Size = new System.Drawing.Size(120, 20);
this.tbxWeightScaleMass.TabIndex = 71;
this.tbxWeightScaleMass_liters.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.tbxWeightScaleMass_liters.Location = new System.Drawing.Point(140, 50);
this.tbxWeightScaleMass_liters.Name = "tbxWeightScaleMass_liters";
this.tbxWeightScaleMass_liters.Size = new System.Drawing.Size(120, 20);
this.tbxWeightScaleMass_liters.TabIndex = 71;
this.tbxWeightScaleMass_liters.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tbxWeightScaleMass_KeyStoke);
this.tbxWeightScaleMass_liters.Leave += new System.EventHandler(this.tbxWeightScaleMass_Leave);
//
// lblMeasuredRefPulses
//
@@ -542,6 +545,7 @@
this.chkUseDampedTolerance.TabIndex = 78;
this.chkUseDampedTolerance.Text = "Damped Tolerance On";
this.chkUseDampedTolerance.UseVisualStyleBackColor = true;
this.chkUseDampedTolerance.CheckedChanged += new System.EventHandler(this.chkUseDampedTolerance_CheckedChanged);
//
// lblActualMeasuredTolerance
//
@@ -627,8 +631,8 @@
private System.Windows.Forms.Label lblDutPulsePerVolume;
private System.Windows.Forms.Label lblAttenuation;
private System.Windows.Forms.Label lblScaleRefToDut;
private System.Windows.Forms.TextBox tbxRefPulsePerVolume;
private System.Windows.Forms.TextBox tbxDutPulsePerVolume;
private System.Windows.Forms.TextBox tbxRefPulsePerCm;
private System.Windows.Forms.TextBox tbxDutPulsePerCm;
private System.Windows.Forms.TextBox tbxScaleRefToDut;
private System.Windows.Forms.Label lblUpdateTimeValue;
private System.Windows.Forms.Timer tmrProgressUpdate;
@@ -654,9 +658,9 @@
private System.Windows.Forms.Label lblMeasuredRefPulses;
private System.Windows.Forms.TextBox tbxMeasuredRefPulses;
private System.Windows.Forms.Label lblPulseVolumeCmRelation;
private System.Windows.Forms.TextBox tbxPulseVolumeCmRelation;
private System.Windows.Forms.TextBox tbxRefCalibrationResultPulsePerCm;
private System.Windows.Forms.Label lblWeightScaleVolume;
private System.Windows.Forms.TextBox tbxWeightScaleMass;
private System.Windows.Forms.TextBox tbxWeightScaleMass_liters;
private System.Windows.Forms.Label lblActualMeasuredTolerance;
private System.Windows.Forms.TextBox tbxActualMeasuredToleranceDutToRef;
private System.Windows.Forms.Label lblActualFlowRateCmPerHour;
+187 -17
View File
@@ -59,7 +59,7 @@ namespace Sensus.MiniPrf.Ui
/// <summary>
/// The single FM2014 for this program
/// </summary>
private FM2014 Fm2014
private FM2014 Fm2014
{
get;
set;
@@ -70,7 +70,7 @@ namespace Sensus.MiniPrf.Ui
/// the actual time if the measurement should be (re)started.
/// </summary>
private DateTimeOffset _startTime;
/// <summary>
/// The auto progress bar enabled is for infinite processes or if the process doesn't feed
/// the progress bar with information (e.g. Connect()).
@@ -103,6 +103,7 @@ namespace Sensus.MiniPrf.Ui
private Int32 _comPortIdx;
private Int32 _addressIdx;
private Int32 _toleranceIdx;
private Boolean _regulationSetupHasChanged;
#endregion Properties
#region FormControls
@@ -131,6 +132,7 @@ namespace Sensus.MiniPrf.Ui
{
ViewProcessControl(false);
_autoProgressBar = false;
_regulationSetupHasChanged = false;
// Load the configuration from the local file stored in AppData\FM2014
_fm2014Config.ReadFM2014Config();
@@ -188,9 +190,9 @@ namespace Sensus.MiniPrf.Ui
// Regulation Setup group box
gbxRegulationSetup.Text = Resources.StrGbxRegulationSetup;
lblRefPulsePerVolume.Text = Resources.StrLblRefPulsesPerCm;
tbxRefPulsePerVolume.Text = "";
tbxRefPulsePerCm.Text = "";
lblDutPulsePerVolume.Text = Resources.StrLblDutPulsesPerCm;
tbxDutPulsePerVolume.Text = "";
tbxDutPulsePerCm.Text = "";
lblScaleRefToDut.Text = Resources.StrLblScaleRefToDut;
tbxScaleRefToDut.Text = "";
lblAttenuation.Text = Resources.StrLblAttenuation;
@@ -201,9 +203,9 @@ namespace Sensus.MiniPrf.Ui
lblMeasuredRefPulses.Text = Resources.StrLblMeasuredRefPulses;
tbxMeasuredRefPulses.Text = "";
lblWeightScaleVolume.Text = Resources.StrLblMeasuredWeightScaleVolume;
tbxWeightScaleMass.Text = "";
tbxWeightScaleMass_liters.Text = "";
lblPulseVolumeCmRelation.Text = Resources.StrLblRefPulsesPerCm;
tbxPulseVolumeCmRelation.Text = "";
tbxRefCalibrationResultPulsePerCm.Text = "";
btnManualRefCalibration.Text = Resources.StrBtnStartCalibration;
// DUT to REF Regulation group box
@@ -223,7 +225,10 @@ namespace Sensus.MiniPrf.Ui
SetFM2014AccessLocked();
btnFM2014Connect.Enabled = true;
cbxFM2014Address.Enabled = true;
cbxFM2014ComPort.Enabled = true;
btnFM2014Connect.Focus();
}
@@ -234,14 +239,28 @@ namespace Sensus.MiniPrf.Ui
/// <remarks date="2025-Nov-13" author="Thomas Wiedebusch">
/// - Initial.
/// </remarks>
/// <remarks date="2026-Jan-15" author="Thomas Wiedebusch">
/// - Update FM2014 properties.
/// </remarks>
private void StoreFM2014Settings()
{
_fm2014Config.SerialPort = cbxFM2014ComPort.Text;
if (int.TryParse(cbxFM2014Address.SelectedItem.ToString(), out var address))
{
_fm2014Config.Address = address;
if (Fm2014 != null)
Fm2014.Address = address;
}
if (int.TryParse(cbxFM2014TolerancePercent.SelectedItem.ToString(), out var tolerancePercent)
&& (tolerancePercent == 3 || tolerancePercent == 5))
{
_fm2014Config.TolerancePercent = tolerancePercent;
if (Fm2014 != null)
Fm2014.Tolerance_percent = tolerancePercent;
}
_fm2014Config.Update();
}
@@ -300,10 +319,22 @@ namespace Sensus.MiniPrf.Ui
/// </summary>
private void SetFM2014AccessLocked()
{
// Disable all buttons
btnSaveRegulationSetup.Enabled = false;
btnManualRefCalibration.Enabled = false;
btnDutToRefRegulation.Enabled = false;
btnFM2014Connect.Enabled = false;
// Disable manual input
tbxWeightScaleMass_liters.ReadOnly = true;
tbxRefPulsePerCm.ReadOnly = true;
tbxDutPulsePerCm.ReadOnly = true;
// Disable setting selections
cbxAttenuation.Enabled = false;
cbxFM2014Address.Enabled = false;
cbxFM2014ComPort.Enabled = false;
cbxFM2014TolerancePercent.Enabled = false;
}
/// <summary>
@@ -311,12 +342,27 @@ namespace Sensus.MiniPrf.Ui
/// </summary>
private void SetFM2014AccessEnabled()
{
btnSaveRegulationSetup.Enabled = true;
// Enable save setup depending on changed properties
btnSaveRegulationSetup.Enabled = _regulationSetupHasChanged;
// Enable buttons and display correct information
btnManualRefCalibration.Enabled = true;
btnDutToRefRegulation.Enabled = true;
btnFM2014Connect.Enabled = true;
btnManualRefCalibration.Text = Resources.StrBtnStartCalibration;
btnDutToRefRegulation.Text = Resources.StrBtnStartRegulation;
// Enable manual input
tbxWeightScaleMass_liters.ReadOnly = false;
tbxRefPulsePerCm.ReadOnly = false;
tbxDutPulsePerCm.ReadOnly = false;
// Enable setting selections
cbxAttenuation.Enabled = true;
cbxFM2014Address.Enabled = true;
cbxFM2014ComPort.Enabled = true;
cbxFM2014TolerancePercent.Enabled = true;
}
/// <summary>
@@ -674,7 +720,7 @@ namespace Sensus.MiniPrf.Ui
/// <remarks date="2023-Jan-04" author="Thomas Wiedebusch">
/// - Initial.
/// </remarks>
private void cbxFM2014ComPort_SelectedValueChanged(Object sender, EventArgs e)
private void cbxFM2014BaseSettings_SelectedValueChanged(Object sender, EventArgs e)
{
if (_toleranceIdx != cbxFM2014TolerancePercent.SelectedIndex ||
_addressIdx != cbxFM2014Address.SelectedIndex ||
@@ -686,6 +732,112 @@ namespace Sensus.MiniPrf.Ui
StoreFM2014Settings();
}
}
/// <summary>
/// Switch between damped or undamped tolerance display. This can be changed during the 'Regulation Measurement'
/// as it will just collect a different dataset and not change anything on the measurement setup.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void chkUseDampedTolerance_CheckedChanged(Object sender, EventArgs e)
{
if (Fm2014 != null)
Fm2014.UseDampedTolerance = chkUseDampedTolerance.Checked;
}
/// <summary>
/// Redirect keystroke 'Enter' to leaving the cell event
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tbxRefPulsePerVolume_KeyDown(Object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
tbxRefPulsePerVolume_Leave(this, null);
}
}
/// <summary>
/// After manual input of the REF pulses per cubic meter the scale REF to DUT has to be recalculated
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tbxRefPulsePerVolume_Leave(Object sender, EventArgs e)
{
_regulationSetupHasChanged = true;
// Setup FM2014
if (Fm2014 != null && int.TryParse(tbxRefPulsePerCm.Text, out var pulses_per_cm))
{
Fm2014.Ref_pulse_per_cm = (UInt16)pulses_per_cm;
tbxScaleRefToDut.Text = $@"{Fm2014.RefToDutScale_norm:F3}";
}
}
/// <summary>
/// Redirect keystroke 'Enter' to leaving the cell event
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tbxDutPulsePerVolume_KeyDown(Object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
tbxDutPulsePerVolume_Leave(this, null);
}
}
/// <summary>
/// After manual input of the DUT pulses per cubic meter the scale REF to DUT has to be recalculated
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tbxDutPulsePerVolume_Leave(Object sender, EventArgs e)
{
_regulationSetupHasChanged = true;
// Setup FM2014
if (Fm2014 != null && int.TryParse(tbxDutPulsePerCm.Text, out var pulses_per_cm))
{
Fm2014.Dut_pulse_per_cm = (UInt16)pulses_per_cm;
tbxScaleRefToDut.Text = $@"{Fm2014.RefToDutScale_norm:F3}";
}
}
/// <summary>
/// Redirect keystroke 'Enter' to leaving the cell event
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tbxWeightScaleMass_KeyStoke(Object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
tbxWeightScaleMass_Leave(this, null);
}
}
/// <summary>
/// After manual input of measured weight scale or reservoir in liters this will calculate the
/// REF pulses per cubic meter and copy from REF pulses per cubic meter in 'Manual REF Calibration'
/// to 'Regulation Setup'.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tbxWeightScaleMass_Leave(Object sender, EventArgs e)
{
// Calculate REF pulses per cubic meter
if (int.TryParse(tbxMeasuredRefPulses.Text, out var pulses) && pulses > 0 &&
int.TryParse(tbxWeightScaleMass_liters.Text, out var liters) && liters > 0)
{
tbxRefCalibrationResultPulsePerCm.Text = $@"{(UInt16)((Single)pulses / (liters / 1000.0f))}";
// Copy from REF pulses per cubic meter in 'Manual REF Calibration' to 'Regulation Setup'
if (!tbxRefCalibrationResultPulsePerCm.Text.Equals(tbxRefPulsePerCm.Text))
{
_regulationSetupHasChanged = true;
tbxRefPulsePerCm.Text = tbxRefCalibrationResultPulsePerCm.Text;
// Setup FM2014
if (Fm2014 != null && int.TryParse(tbxRefCalibrationResultPulsePerCm.Text, out var pulses_per_cm))
{
Fm2014.Ref_pulse_per_cm = (UInt16)pulses_per_cm;
tbxScaleRefToDut.Text = $@"{Fm2014.RefToDutScale_norm:F3}";
}
}
}
}
#endregion Buttons and Controls
#region Event handler
@@ -700,23 +852,41 @@ namespace Sensus.MiniPrf.Ui
{
Invoke(new Action(() =>
{
// Process info
lblActualProcess.Text = e.ActualProcessMessage;
lblActualProcess.Update();
SetTimeDisplay();
lblUpdateTimeValue.Update();
if (e.ActualProcessPercent != null && !_autoProgressBar && barSingleProgressUpdate.Visible)
barSingleProgressUpdate.Value = (Int32)e.ActualProcessPercent;
// Data dispatcher
var resp = (FM2014CmdDef.CmdResponse)e.SpecificInfoObj;
if (resp.IntValue != null)
{
LogText($"{resp.AnswerStr}: {resp.IntValue:D} {resp.SiUnit}");
switch (resp.CmdName)
{
case FM2014CmdDef.CmdName.CMD_REF_GET_PLS_CTR:
tbxMeasuredRefPulses.Text = $@"{resp.IntValue:D}";
break;
}
}
if (resp.DoubleValue != null)
{
LogText($"{resp.AnswerStr}: {resp.DoubleValue:F2} {resp.SiUnit}");
switch (resp.CmdName)
{
case FM2014CmdDef.CmdName.CMD_GET_UDTLC:
case FM2014CmdDef.CmdName.CMD_GET_DTLC:
tbxActualMeasuredToleranceDutToRef.Text = $@"{resp.DoubleValue:F2}";
break;
}
}
}));
var resp = (FM2014CmdDef.CmdResponse)e.SpecificInfoObj;
if (resp.IntValue != null)
{
LogText($"{resp.AnswerStr}: {resp.IntValue:D} {resp.SiUnit}");
}
if (resp.DoubleValue != null)
{
LogText($"{resp.AnswerStr}: {resp.DoubleValue:F2} {resp.SiUnit}");
}
}
#endregion
}