MiniPrf: - first operational version, - missing default setup implementation
This commit is contained in:
parent
c7ea03febe
commit
785b5466f6
@ -160,7 +160,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = false;
|
||||
}
|
||||
|
||||
private UInt16 _ref_pulse_per_cm = 1000;
|
||||
/// <inheritdoc/>
|
||||
@ -511,10 +511,9 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
{
|
||||
cmdName = UseDampedTolerance ? CmdName.CMD_GET_DTLC : CmdName.CMD_GET_UDTLC;
|
||||
var info = GetCmdInfo(cmdName);
|
||||
var responseStr = "";
|
||||
if (Write(cmdName))
|
||||
{
|
||||
responseStr = SerialPort.ReadTo(END_OF_STR);
|
||||
var 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 measTolerance))
|
||||
@ -764,6 +763,8 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
return true;
|
||||
|
||||
CyclicReceiveTaskLoopIsActive = false;
|
||||
// Schedule to other tasks
|
||||
Thread.Sleep(100);
|
||||
// Reset measurement
|
||||
var infoStr = GetCmdInfo(CmdName.CMD_RST_MEAS);
|
||||
if (!Write(CmdName.CMD_RST_MEAS))
|
||||
|
||||
4
MiniPrf/Ui/FrmMainMiniPrf.Designer.cs
generated
4
MiniPrf/Ui/FrmMainMiniPrf.Designer.cs
generated
@ -467,9 +467,9 @@
|
||||
this.lblWeightScaleVolume.AutoSize = true;
|
||||
this.lblWeightScaleVolume.Location = new System.Drawing.Point(10, 53);
|
||||
this.lblWeightScaleVolume.Name = "lblWeightScaleVolume";
|
||||
this.lblWeightScaleVolume.Size = new System.Drawing.Size(107, 13);
|
||||
this.lblWeightScaleVolume.Size = new System.Drawing.Size(19, 13);
|
||||
this.lblWeightScaleVolume.TabIndex = 70;
|
||||
this.lblWeightScaleVolume.Text = "Weight Scale [liters]:";
|
||||
this.lblWeightScaleVolume.Text = "ba";
|
||||
//
|
||||
// tbxWeightScaleVolumeLiters
|
||||
//
|
||||
|
||||
@ -103,6 +103,15 @@ namespace Sensus.MiniPrf.Ui
|
||||
private Int32 _comPortIdx;
|
||||
private Int32 _addressIdx;
|
||||
private Int32 _toleranceIdx;
|
||||
|
||||
// Backups of results from 'Manual REF Calibration' being able to restore those if a manual change
|
||||
// of the REF pulses per cubic meter clears those fields. Bringing the last calibrated REF pulses
|
||||
// per cubic meters back will automatically restore these results being able to adjust the measured
|
||||
// volume in liters without a restart of the 'Manual REF Calibration'
|
||||
private String _backupWeightScaleVolumeLitersStr;
|
||||
private String _backupRefCalibrationResultPulsePerCmStr;
|
||||
private String _backupMeasuredRefPulsesStr;
|
||||
|
||||
private Boolean _regulationSetupHasChanged;
|
||||
#endregion Properties
|
||||
|
||||
@ -465,6 +474,9 @@ namespace Sensus.MiniPrf.Ui
|
||||
tbxFM2014FullId.Visible = true;
|
||||
tbxFM2014ApplicationFwVersion.Text = Fm2014.FwVersion;
|
||||
tbxFM2014SerialNumber.Text = Fm2014.SerialNumber;
|
||||
tbxRefPulsePerCm.Text = $@"{Fm2014.Ref_pulse_per_cm:D}";
|
||||
tbxDutPulsePerCm.Text = $@"{Fm2014.Dut_pulse_per_cm:D}";
|
||||
tbxScaleRefToDut.Text = $@"{Fm2014.RefToDutScale_norm:F3}";
|
||||
|
||||
// Logging to history window
|
||||
LogText("FM2014 ID:\t\t" + Fm2014.FullId);
|
||||
@ -695,6 +707,16 @@ namespace Sensus.MiniPrf.Ui
|
||||
if (!Fm2014.CyclicReceiveTaskLoopIsActive)
|
||||
{
|
||||
ActionControl(true);
|
||||
tbxMeasuredRefPulses.Text = "";
|
||||
tbxWeightScaleVolumeLiters.Text = "";
|
||||
tbxRefCalibrationResultPulsePerCm.Text = "";
|
||||
tbxActualFlowRateCmPerHour.Text = "";
|
||||
tbxActualMeasuredToleranceDutToRef.Text = "";
|
||||
|
||||
_backupMeasuredRefPulsesStr = "";
|
||||
_backupRefCalibrationResultPulsePerCmStr = "";
|
||||
_backupWeightScaleVolumeLitersStr = "";
|
||||
|
||||
_autoProgressBar = true;
|
||||
if (Fm2014.PulseCounterMeasurement())
|
||||
{
|
||||
@ -755,10 +777,6 @@ namespace Sensus.MiniPrf.Ui
|
||||
tbxRefPulsePerVolume_Leave(this, null);
|
||||
}
|
||||
}
|
||||
|
||||
private String _backupWeightScaleVolumeLitersStr;
|
||||
private String _backupRefCalibrationResultPulsePerCmStr;
|
||||
private String _backupMeasuredRefPulsesStr;
|
||||
/// <summary>
|
||||
/// After manual input of the REF pulses per cubic meter the scale REF to DUT has to be recalculated
|
||||
/// </summary>
|
||||
@ -766,30 +784,37 @@ namespace Sensus.MiniPrf.Ui
|
||||
/// <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}";
|
||||
// If the REF pulses per cubic meter have been changed manually, the 'Manual REF Calibration'
|
||||
// fields have to be cleared if those are different. A backup to restore it may be useful.
|
||||
if (!tbxRefPulsePerCm.Text.Equals(tbxRefCalibrationResultPulsePerCm.Text) &&
|
||||
!string.IsNullOrEmpty(tbxRefCalibrationResultPulsePerCm.Text))
|
||||
if (pulses_per_cm != Fm2014.Ref_pulse_per_cm)
|
||||
{
|
||||
_backupMeasuredRefPulsesStr = tbxMeasuredRefPulses.Text;
|
||||
tbxMeasuredRefPulses.Text = "";
|
||||
_backupRefCalibrationResultPulsePerCmStr = tbxRefCalibrationResultPulsePerCm.Text;
|
||||
tbxRefCalibrationResultPulsePerCm.Text = "";
|
||||
_backupWeightScaleVolumeLitersStr = tbxWeightScaleVolumeLiters.Text;
|
||||
tbxWeightScaleVolumeLiters.Text = "";
|
||||
}
|
||||
// Restore values if REF pulses per cubic meters is back to the calibrated one
|
||||
else if (tbxRefPulsePerCm.Text.Equals(_backupRefCalibrationResultPulsePerCmStr))
|
||||
{
|
||||
tbxMeasuredRefPulses.Text = _backupMeasuredRefPulsesStr;
|
||||
tbxRefCalibrationResultPulsePerCm.Text = _backupRefCalibrationResultPulsePerCmStr;
|
||||
tbxWeightScaleVolumeLiters.Text = _backupWeightScaleVolumeLitersStr;
|
||||
_regulationSetupHasChanged = true;
|
||||
btnSaveRegulationSetup.Enabled = true;
|
||||
tbxActualFlowRateCmPerHour.Text = "";
|
||||
tbxActualMeasuredToleranceDutToRef.Text = "";
|
||||
|
||||
Fm2014.Ref_pulse_per_cm = (UInt16)pulses_per_cm;
|
||||
tbxScaleRefToDut.Text = $@"{Fm2014.RefToDutScale_norm:F3}";
|
||||
// If the REF pulses per cubic meter have been changed manually, the 'Manual REF Calibration'
|
||||
// fields have to be cleared if those are different. A backup to restore it may be useful.
|
||||
if (!tbxRefPulsePerCm.Text.Equals(tbxRefCalibrationResultPulsePerCm.Text) &&
|
||||
!string.IsNullOrEmpty(tbxRefCalibrationResultPulsePerCm.Text))
|
||||
{
|
||||
_backupMeasuredRefPulsesStr = tbxMeasuredRefPulses.Text;
|
||||
tbxMeasuredRefPulses.Text = "";
|
||||
_backupRefCalibrationResultPulsePerCmStr = tbxRefCalibrationResultPulsePerCm.Text;
|
||||
tbxRefCalibrationResultPulsePerCm.Text = "";
|
||||
_backupWeightScaleVolumeLitersStr = tbxWeightScaleVolumeLiters.Text;
|
||||
tbxWeightScaleVolumeLiters.Text = "";
|
||||
}
|
||||
// Restore values if REF pulses per cubic meters is back to the calibrated one
|
||||
else if (tbxRefPulsePerCm.Text.Equals(_backupRefCalibrationResultPulsePerCmStr))
|
||||
{
|
||||
tbxMeasuredRefPulses.Text = _backupMeasuredRefPulsesStr;
|
||||
tbxRefCalibrationResultPulsePerCm.Text = _backupRefCalibrationResultPulsePerCmStr;
|
||||
tbxWeightScaleVolumeLiters.Text = _backupWeightScaleVolumeLitersStr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -812,14 +837,22 @@ namespace Sensus.MiniPrf.Ui
|
||||
/// <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}";
|
||||
if (pulses_per_cm != Fm2014.Dut_pulse_per_cm)
|
||||
{
|
||||
_regulationSetupHasChanged = true;
|
||||
btnSaveRegulationSetup.Enabled = true;
|
||||
tbxActualFlowRateCmPerHour.Text = "";
|
||||
tbxActualMeasuredToleranceDutToRef.Text = "";
|
||||
|
||||
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>
|
||||
@ -850,6 +883,10 @@ namespace Sensus.MiniPrf.Ui
|
||||
if (!tbxRefCalibrationResultPulsePerCm.Text.Equals(tbxRefPulsePerCm.Text))
|
||||
{
|
||||
_regulationSetupHasChanged = true;
|
||||
btnSaveRegulationSetup.Enabled = true;
|
||||
tbxActualFlowRateCmPerHour.Text = "";
|
||||
tbxActualMeasuredToleranceDutToRef.Text = "";
|
||||
|
||||
tbxRefPulsePerCm.Text = tbxRefCalibrationResultPulsePerCm.Text;
|
||||
// Setup FM2014
|
||||
if (Fm2014 != null && int.TryParse(tbxRefCalibrationResultPulsePerCm.Text, out var pulses_per_cm))
|
||||
@ -907,6 +944,8 @@ namespace Sensus.MiniPrf.Ui
|
||||
|
||||
}
|
||||
}
|
||||
// Catch the latest information
|
||||
Update();
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
2
MiniPrf/Ui/Properties/Resources.Designer.cs
generated
2
MiniPrf/Ui/Properties/Resources.Designer.cs
generated
@ -305,7 +305,7 @@ namespace Sensus.MiniPrf.Ui.Properties {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Weight Scale [l]:.
|
||||
/// Looks up a localized string similar to Volume [liters]:.
|
||||
/// </summary>
|
||||
internal static string StrLblMeasuredWeightScaleVolume {
|
||||
get {
|
||||
|
||||
@ -197,7 +197,7 @@
|
||||
<value>Gemessene REF [Pulse]:</value>
|
||||
</data>
|
||||
<data name="StrLblMeasuredWeightScaleVolume" xml:space="preserve">
|
||||
<value>Waageninhalt [l]:</value>
|
||||
<value>Volumen [Liter]:</value>
|
||||
</data>
|
||||
<data name="StrGbxDutToRefRegulation" xml:space="preserve">
|
||||
<value>DUT zu REF Regulierung</value>
|
||||
|
||||
@ -197,7 +197,7 @@
|
||||
<value>Measured REF [pulses]:</value>
|
||||
</data>
|
||||
<data name="StrLblMeasuredWeightScaleVolume" xml:space="preserve">
|
||||
<value>Weight Scale [l]:</value>
|
||||
<value>Volume [liters]:</value>
|
||||
</data>
|
||||
<data name="StrGbxDutToRefRegulation" xml:space="preserve">
|
||||
<value>DUT to REF Regulation</value>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user