FM2014: - improvements

This commit is contained in:
Thomas Wiedebusch 2026-02-14 11:17:10 +01:00
parent 8998f9058f
commit 312195ef86
2 changed files with 24 additions and 19 deletions

View File

@ -814,6 +814,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
DisableWriteReadActualProcessIncreasing = disableWriteReadIncrease; DisableWriteReadActualProcessIncreasing = disableWriteReadIncrease;
MaxActualProcessProgress = 1; MaxActualProcessProgress = 1;
ActualProcessProgress = 0; ActualProcessProgress = 0;
ActualProcessProgress_percent = null;
if (maxInitProcesses != null) if (maxInitProcesses != null)
{ {
@ -1363,6 +1364,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
fm2014.ErrorIsDetected = false; fm2014.ErrorIsDetected = false;
} }
var cmdName = CmdName.CMD_NA; var cmdName = CmdName.CMD_NA;
MeasurementInfo = Resources.StrMeasMsgCalibration; MeasurementInfo = Resources.StrMeasMsgCalibration;
@ -1372,7 +1374,6 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
// Check if double pulse deadtime has been set or si switched off // Check if double pulse deadtime has been set or si switched off
if (DOUBLE_PULSE_DEADTIME_MIN_ms == firstActiveFm2014.DoublePulseDeadtime_ms) if (DOUBLE_PULSE_DEADTIME_MIN_ms == firstActiveFm2014.DoublePulseDeadtime_ms)
{ {
InitActualProcessProgress(3, broadcast: true);
// This is a command without parameter // This is a command without parameter
cmdName = CmdName.CMD_SET_DBPL_UNLOCK; cmdName = CmdName.CMD_SET_DBPL_UNLOCK;
if (!Write(cmdName, firstActiveFm2014)) if (!Write(cmdName, firstActiveFm2014))
@ -1382,7 +1383,6 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
} }
else else
{ {
InitActualProcessProgress(4, broadcast: true);
cmdName = CmdName.CMD_SET_DPLS_LOCK_TMR; cmdName = CmdName.CMD_SET_DPLS_LOCK_TMR;
if (!Write(cmdName, firstActiveFm2014, firstActiveFm2014.DoublePulseBaseDeadTime_ms)) if (!Write(cmdName, firstActiveFm2014, firstActiveFm2014.DoublePulseBaseDeadTime_ms))
{ {
@ -1458,9 +1458,6 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
// Read the remaining REF pulses if required // Read the remaining REF pulses if required
if (fm2014.RefPulsesRequired != 0) if (fm2014.RefPulsesRequired != 0)
{ {
// Feed the progress counter
ActualProcessProgress = (Int32)firstActiveFm2014.RefPulsesRequired -
firstActiveFm2014.RefPulsesRemaining;
cmdName = CmdName.CMD_REF_GET_PLS_RMN; cmdName = CmdName.CMD_REF_GET_PLS_RMN;
info = GetCmdInfo(cmdName); info = GetCmdInfo(cmdName);
if (SharedCyclicMeasSequ != CyclicMeasSequ.IDLE && Write(cmdName, fm2014)) if (SharedCyclicMeasSequ != CyclicMeasSequ.IDLE && Write(cmdName, fm2014))
@ -1483,6 +1480,12 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
var response = new CmdResponse(cmdName, info, pulses); var response = new CmdResponse(cmdName, info, pulses);
ResponseEvent(fm2014, response, statusReturn); ResponseEvent(fm2014, response, statusReturn);
// Feed the progress counter but only if not done for DUT pulses as with the first
// DUT pulse the RefPulsesRemaining will be reset to the initial value
if (firstActiveFm2014.DutPulsesRequired == 0)
ActualProcessProgress = (Int32)firstActiveFm2014.RefPulsesRequired -
firstActiveFm2014.RefPulsesRemaining;
} }
} }
} }
@ -1490,10 +1493,6 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
// Read the remaining DUT pulses if required // Read the remaining DUT pulses if required
if (fm2014.DutPulsesRequired != 0) if (fm2014.DutPulsesRequired != 0)
{ {
// Feed the progress counter but only if not done for REF pulses
if (firstActiveFm2014.RefPulsesRequired == 0)
ActualProcessProgress = (Int32)firstActiveFm2014.DutPulsesRequired -
firstActiveFm2014.DutPulsesRemaining;
cmdName = CmdName.CMD_DUT_GET_PLS_RMN; cmdName = CmdName.CMD_DUT_GET_PLS_RMN;
info = GetCmdInfo(cmdName); info = GetCmdInfo(cmdName);
if (SharedCyclicMeasSequ != CyclicMeasSequ.IDLE && Write(cmdName, fm2014)) if (SharedCyclicMeasSequ != CyclicMeasSequ.IDLE && Write(cmdName, fm2014))
@ -1516,6 +1515,10 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
var response = new CmdResponse(cmdName, info, pulses); var response = new CmdResponse(cmdName, info, pulses);
ResponseEvent(fm2014, response, statusReturn); ResponseEvent(fm2014, response, statusReturn);
// Feed the progress counter
ActualProcessProgress = (Int32)firstActiveFm2014.DutPulsesRequired -
firstActiveFm2014.DutPulsesRemaining;
} }
} }
} }
@ -1830,7 +1833,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
var statusReturn = retVal ? StatusReturn.Okay : StatusReturn.Failed; var statusReturn = retVal ? StatusReturn.Okay : StatusReturn.Failed;
ResponseEvent(fm2014, response, statusReturn); ResponseEvent(fm2014, response, statusReturn);
return retVal; return retVal;
} }
@ -2103,7 +2106,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
{ {
var strCleaned = Regex.Replace(str, "[^0-9]", string.Empty); var strCleaned = Regex.Replace(str, "[^0-9]", string.Empty);
if (byte.TryParse(strCleaned, out var attenuation) && if (byte.TryParse(strCleaned, out var attenuation) &&
attenuation >= CURRENT_OUTPUT_ATTENUATION_MIN && attenuation >= CURRENT_OUTPUT_ATTENUATION_MIN &&
attenuation <= CURRENT_OUTPUT_ATTENUATION_MAX) attenuation <= CURRENT_OUTPUT_ATTENUATION_MAX)
{ {
cmdName = CmdName.CMD_MEAS_SET_ATTN; cmdName = CmdName.CMD_MEAS_SET_ATTN;

View File

@ -759,7 +759,7 @@ namespace Sensus.Ui.FM2014TestBench
/// <summary> /// <summary>
/// Common method to (de-)activate controls and timer. /// Common method to (de-)activate controls and timer.
/// </summary> /// </summary>
/// <remarks date="2026-Jan-14..20" author="Thomas Wiedebusch"> /// <remarks date="2026-Jan-14..Feb-14" author="Thomas Wiedebusch">
/// - Initial. /// - Initial.
/// </remarks> /// </remarks>
private void ActionControl(Boolean isActive) private void ActionControl(Boolean isActive)
@ -771,7 +771,7 @@ namespace Sensus.Ui.FM2014TestBench
//UiElmEnable(lblTotalProcessText, true); //UiElmEnable(lblTotalProcessText, true);
//UiElmEnable(lblActualProcessLabel, true); //UiElmEnable(lblActualProcessLabel, true);
//UiElmEnable(lblTotalProcessLabel, true); //UiElmEnable(lblTotalProcessLabel, true);
UiElmEnable(lblActualProgressPercent, true); UiElmEnable(lblActualProgressPercent, !_autoProgressBar, !_autoProgressBar);
//UiElmEnable(lblTotalProgressPercent, true); //UiElmEnable(lblTotalProgressPercent, true);
UiElmEnable(pbActualProgress, true); UiElmEnable(pbActualProgress, true);
//UiElmEnable(pbTotalProgress, true); //UiElmEnable(pbTotalProgress, true);
@ -1076,7 +1076,7 @@ namespace Sensus.Ui.FM2014TestBench
/// <summary> /// <summary>
/// Feedback from FM2014being parsed to GUI /// Feedback from FM2014being parsed to GUI
/// </summary> /// </summary>
/// <remarks date="2026-Feb-02..13" author="Thomas Wiedebusch"> /// <remarks date="2026-Feb-02..14" author="Thomas Wiedebusch">
/// - Initial. /// - Initial.
/// </remarks> /// </remarks>
private void DataReceived_Handler(Object sender, ProcessExecEventArgs e) private void DataReceived_Handler(Object sender, ProcessExecEventArgs e)
@ -1105,7 +1105,10 @@ namespace Sensus.Ui.FM2014TestBench
UpdateProgressBar(pbActualProgress, (Double)e.ActualProcessPercent); UpdateProgressBar(pbActualProgress, (Double)e.ActualProcessPercent);
} }
Dispatcher.Invoke(() => lblActualProgressPercent.Content = $@"{pbActualProgress.Value:##0.0} %"); // A circulating process bar will be used to observe an activity, but as it restarts at the beginning
// after reaching the end, a value isn't of importance
if (!_autoProgressBar)
Dispatcher.Invoke(() => lblActualProgressPercent.Content = $@"{pbActualProgress.Value:##0.0} %");
SetTimeDisplay(); SetTimeDisplay();
@ -1165,6 +1168,7 @@ namespace Sensus.Ui.FM2014TestBench
case CmdName.CMD_RST_MEAS: case CmdName.CMD_RST_MEAS:
// Immediately lock all buttons and input fields until reset is finished // Immediately lock all buttons and input fields until reset is finished
SetFM2014AccessLocked(); SetFM2014AccessLocked();
UiElmEnable(lblActualProgressPercent, true);
// Check countdown of reset method // Check countdown of reset method
if (resp.IntValue == 0) if (resp.IntValue == 0)
ActionControl(false); ActionControl(false);
@ -1342,7 +1346,7 @@ namespace Sensus.Ui.FM2014TestBench
// Backup if meanwhile anything has changed // Backup if meanwhile anything has changed
if (_configSetupHasChanged || _calibrationSetupHasChanged) if (_configSetupHasChanged || _calibrationSetupHasChanged)
StoreFM2014SettingsToConfigFile(); StoreFM2014SettingsToConfigFile();
_autoProgressBar = false; _autoProgressBar = false;
ActionControl(true); ActionControl(true);
UpdateContentControl(btnDutToRefCalibration, Properties.Resources.StrBtnStopCalibration); UpdateContentControl(btnDutToRefCalibration, Properties.Resources.StrBtnStopCalibration);
@ -1492,8 +1496,6 @@ namespace Sensus.Ui.FM2014TestBench
var idx = fm2014.Address - 1; var idx = fm2014.Address - 1;
var ucFM2014 = (UcFM2014Device)UcFM2014s[idx]; var ucFM2014 = (UcFM2014Device)UcFM2014s[idx];
ucFM2014.EnableMeasurements(CTR_MEASURE_COUNT); ucFM2014.EnableMeasurements(CTR_MEASURE_COUNT);
//fm2014.RefPulseCtrOn = true;
//fm2014.DutPulseCtrOn = measureDutPulses;
} }
if (FM2014.PulseCounterMeasurement(true, measureDutPulses)) if (FM2014.PulseCounterMeasurement(true, measureDutPulses))
@ -2353,7 +2355,7 @@ namespace Sensus.Ui.FM2014TestBench
{ {
fm2014.DutPulses_per_cm = (UInt16)pulses_per_cm; fm2014.DutPulses_per_cm = (UInt16)pulses_per_cm;
} }
if (!UpdateRefToDutScale()) if (!UpdateRefToDutScale())
{ {
tbxDutPulsesPerCm.Background = ColorProcessFailed; tbxDutPulsesPerCm.Background = ColorProcessFailed;