FM2014: - time measurement automatic stop

This commit is contained in:
Thomas Wiedebusch
2026-02-13 16:56:42 +01:00
parent 0272761db8
commit 49c7cc5cc6
2 changed files with 119 additions and 99 deletions
@@ -77,7 +77,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
/// <summary> /// <summary>
/// The mantissa for the scale value has to be in the range from 1000 to 9999. /// The mantissa for the scale value has to be in the range from 1000 to 9999.
/// </summary> /// </summary>
private const UInt16 MANTISSA_SCALE_MIN = 1000; private const UInt16 REF_TO_DUT_SCALE_MANTISSA_MIN = 1000;
/// <summary> /// <summary>
/// REF to DUT scale conversion factor to meaningful human interpretable value /// REF to DUT scale conversion factor to meaningful human interpretable value
@@ -87,29 +87,29 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
/// <summary> /// <summary>
/// Default tolerance if not properly setup. /// Default tolerance if not properly setup.
/// </summary> /// </summary>
public const Int32 STANDARD_NOMINAL_TOLERANCE_INPUT_percent = 3; public const Int32 CURRENT_OUTPUT_TOLERANCE_STANDARD_NOMINAL_INT_percent = 3;
/// <summary> /// <summary>
/// Default tolerance if not properly setup. /// Default tolerance if not properly setup.
/// </summary> /// </summary>
public const Int32 EXTENDED_NOMINAL_TOLERANCE_INPUT_percent = 5; public const Int32 CURRENT_OUTPUT_TOLERANCE_EXTENDED_VALUE_INT_percent = 5;
/// <summary> /// <summary>
/// Standard tolerance (nominal 3 %) multiplicator for calculation of value based on feedback from FM2014 /// Standard tolerance (nominal 3 %) multiplicator for calculation of value based on feedback from FM2014
/// (+/- 255 digits). /// (+/- 255 digits).
/// </summary> /// </summary>
private const Double STANDARD_TOLERANCE_VALUE_percent = 3.3; private const Double CURRENT_OUTPUT_TOLERANCE_STANDARD_VALUE_DOUBLE_percent = 3.3;
/// <summary> /// <summary>
/// Extended tolerance (nominal 5 %) multiplicator for calculation of value based on feedback from FM2014 /// Extended tolerance (nominal 5 %) multiplicator for calculation of value based on feedback from FM2014
/// (+/- 255 digits). /// (+/- 255 digits).
/// </summary> /// </summary>
private const Double EXTENDED_TOLERANCE_VALUE_percent = 5.5; private const Double CURRENT_OUTPUT_TOLERANCE_EXTENDED_VALUE_DOUBLE_percent = 5.5;
/// <summary> /// <summary>
/// Resolution of tolerance raw value feedback from FM2014 (+/- 255 digits). /// Resolution of tolerance raw value feedback from FM2014 (+/- 255 digits).
/// </summary> /// </summary>
private const Double RESOLUTION_TOLERANCE_RAW_VALUE = 255; private const Double CURRENT_OUTPUT_TOLERANCE_RESOLUTION_PLUS_MINUS_BYTE = 255;
/// <summary> /// <summary>
/// Minimal value for attenuation. /// Minimal value for attenuation.
@@ -159,12 +159,12 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
/// <summary> /// <summary>
/// FM2014 minimal pulses for REF and DUT time measurement. /// FM2014 minimal pulses for REF and DUT time measurement.
/// </summary> /// </summary>
public const UInt16 TIME_MEASUREMENT_INPUT_MIN_pulses = 1; public const UInt16 PULSES_TIME_MEASUREMENT_INPUT_MIN = 1;
/// <summary> /// <summary>
/// FM2014 maximal pulses for REF and DUT time measurement. /// FM2014 maximal pulses for REF and DUT time measurement.
/// </summary> /// </summary>
public const UInt16 TIME_MEASUREMENT_INPUT_MAX_pulses = 0xFFFF; public const UInt16 PULSES_TIME_MEASUREMENT_INPUT_MAX = 0xFFFF;
/// <summary> /// <summary>
/// Minimal baudrate for serial communication. /// Minimal baudrate for serial communication.
@@ -247,7 +247,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
/// <summary> /// <summary>
/// Progress of actual process converted to percent /// Progress of actual process converted to percent
/// </summary> /// </summary>
private static Double ActualProcessProgress_percent { get; set; } private static Double? ActualProcessProgress_percent { get; set; }
private static Int32 _actualProcessProgress; private static Int32 _actualProcessProgress;
/// <summary> /// <summary>
@@ -343,35 +343,35 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
/// <summary> /// <summary>
/// Private tolerance percentage /// Private tolerance percentage
/// </summary> /// </summary>
private Int32 _tolerance_percent = STANDARD_NOMINAL_TOLERANCE_INPUT_percent; private Int32 _currentOutputToleranceNominalInt_percent = CURRENT_OUTPUT_TOLERANCE_STANDARD_NOMINAL_INT_percent;
/// <summary> /// <summary>
/// Actual tolerance scale to convert raw value from FM2014 to percent /// Actual tolerance scale to convert raw value from FM2014 to percent
/// </summary> /// </summary>
private Double ToleranceRawToPercentScale { set; get; } = private Double CurrentOutputToleranceNominalToRealScale { set; get; } =
STANDARD_TOLERANCE_VALUE_percent / RESOLUTION_TOLERANCE_RAW_VALUE; CURRENT_OUTPUT_TOLERANCE_STANDARD_VALUE_DOUBLE_percent / CURRENT_OUTPUT_TOLERANCE_RESOLUTION_PLUS_MINUS_BYTE;
/// <summary> /// <summary>
/// Tolerance output of current loop in percent: /// Nominal tolerance output of current loop in percent:
/// - hardware dependent 3% or 5% /// - hardware dependent 3% or 5%
/// </summary> /// </summary>
public Int32 Tolerance_percent public Int32 CurrentOutputToleranceNominalInt_percent
{ {
get => _tolerance_percent; get => _currentOutputToleranceNominalInt_percent;
set set
{ {
// Limit input to discrete nominal setting of 3 or 5 %, // Limit input to discrete nominal setting of 3 or 5 %,
// Internally those values are going to be scaled for higher resolution to 3.3 or 5.5 // Internally those values are going to be scaled for higher resolution to 3.3 or 5.5
Double percentage; Double percentage;
if (value == STANDARD_NOMINAL_TOLERANCE_INPUT_percent) if (value == CURRENT_OUTPUT_TOLERANCE_STANDARD_NOMINAL_INT_percent)
percentage = STANDARD_TOLERANCE_VALUE_percent; percentage = CURRENT_OUTPUT_TOLERANCE_STANDARD_VALUE_DOUBLE_percent;
else if (value == EXTENDED_NOMINAL_TOLERANCE_INPUT_percent) else if (value == CURRENT_OUTPUT_TOLERANCE_EXTENDED_VALUE_INT_percent)
percentage = EXTENDED_TOLERANCE_VALUE_percent; percentage = CURRENT_OUTPUT_TOLERANCE_EXTENDED_VALUE_DOUBLE_percent;
else else
percentage = STANDARD_TOLERANCE_VALUE_percent; percentage = CURRENT_OUTPUT_TOLERANCE_STANDARD_VALUE_DOUBLE_percent;
_tolerance_percent = value; _currentOutputToleranceNominalInt_percent = value;
ToleranceRawToPercentScale = percentage / RESOLUTION_TOLERANCE_RAW_VALUE; CurrentOutputToleranceNominalToRealScale = percentage / CURRENT_OUTPUT_TOLERANCE_RESOLUTION_PLUS_MINUS_BYTE;
} }
} }
@@ -390,7 +390,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
private set private set
{ {
// Check limits and equality // Check limits and equality
if (value < TIME_MEASUREMENT_INPUT_MIN_pulses || if (value < PULSES_TIME_MEASUREMENT_INPUT_MIN ||
value == _refPulsesRequired) value == _refPulsesRequired)
return; return;
@@ -408,7 +408,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
private set private set
{ {
// Check limits and equality // Check limits and equality
if (value < TIME_MEASUREMENT_INPUT_MIN_pulses || if (value < PULSES_TIME_MEASUREMENT_INPUT_MIN ||
value == _dutPulsesRequired) value == _dutPulsesRequired)
return; return;
@@ -563,7 +563,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
number *= REF_TO_DUT_SCALE_CONVERSION; number *= REF_TO_DUT_SCALE_CONVERSION;
mantissa = (UInt16)(number + 0.5); mantissa = (UInt16)(number + 0.5);
exponent--; exponent--;
} while (mantissa < MANTISSA_SCALE_MIN); } while (mantissa < REF_TO_DUT_SCALE_MANTISSA_MIN);
// The pre-generated string will be used to send it to the FM2014 directly // The pre-generated string will be used to send it to the FM2014 directly
RefToDutScaleStr = $"{mantissa}{GetCmdStr(CmdName.CMD_REF_SET_SCALE)}{exponent}"; RefToDutScaleStr = $"{mantissa}{GetCmdStr(CmdName.CMD_REF_SET_SCALE)}{exponent}";
@@ -688,7 +688,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
/// <summary> /// <summary>
/// Measured tolerance during calibration /// Measured tolerance during calibration
/// </summary> /// </summary>
public Double DutToRefToleranceMeasured_percent { get; private set; } public Double? DutToRefToleranceMeasured_percent { get; private set; }
#endregion ---------------------------------------- object properties ----------------------------------------- #endregion ---------------------------------------- object properties -----------------------------------------
@@ -777,7 +777,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
/// Get the first FM2014 which is connected and logged in for common service routines /// Get the first FM2014 which is connected and logged in for common service routines
/// using a broadcast command /// using a broadcast command
/// </summary> /// </summary>
/// <returns></returns> /// <returns>null if no device is connected and logged in</returns>
/// <remarks date="2026-Feb-05" author="Thomas Wiedebusch"> /// <remarks date="2026-Feb-05" author="Thomas Wiedebusch">
/// - Initial. /// - Initial.
/// </remarks> /// </remarks>
@@ -1150,17 +1150,18 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
// The response contains a sign! // The response contains a sign!
var signMultiplier = responseStr.Contains("+") ? 1.0f : -1.0f; var signMultiplier = responseStr.Contains("+") ? 1.0f : -1.0f;
var cleanedStr = responseStr.Replace("+", "").Replace("-", ""); var cleanedStr = responseStr.Replace("+", "").Replace("-", "");
if (int.TryParse(cleanedStr, NumberStyles.HexNumber, new CultureInfo("en"), if (int.TryParse(cleanedStr, NumberStyles.HexNumber,
out var measTolerance)) new CultureInfo("en"), out var measTolerance))
{ {
fm2014.DutToRefToleranceMeasured_percent = fm2014.DutToRefToleranceMeasured_percent =
measTolerance * fm2014.ToleranceRawToPercentScale * signMultiplier; measTolerance * fm2014.CurrentOutputToleranceNominalToRealScale * signMultiplier;
var response = new CmdResponse(cmdName, info, var response = new CmdResponse(cmdName, info,
doubleValue: fm2014.DutToRefToleranceMeasured_percent, doubleValue: fm2014.DutToRefToleranceMeasured_percent,
unit: Units.GetInfo(Units.Name.PERCENT)); unit: Units.GetInfo(Units.Name.PERCENT));
// Check the threshold for OOR // Check the threshold for OOR
if (Math.Abs(fm2014.DutToRefToleranceMeasured_percent) > fm2014.Tolerance_percent) if (Math.Abs((Double)fm2014.DutToRefToleranceMeasured_percent) >
fm2014.CurrentOutputToleranceNominalInt_percent)
statusReturn = StatusReturn.MeasurementOutOfRange; statusReturn = StatusReturn.MeasurementOutOfRange;
else statusReturn = StatusReturn.Okay; else statusReturn = StatusReturn.Okay;
@@ -1338,7 +1339,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
/// <param name="doublePulseDeadtime_ms">0 if double impulse deadtime detection is off</param> /// <param name="doublePulseDeadtime_ms">0 if double impulse deadtime detection is off</param>
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
/// <remarks date="2026-Jan-14..Feb-11" author="Thomas Wiedebusch"> /// <remarks date="2026-Jan-14..Feb-13" author="Thomas Wiedebusch">
/// - Initial. /// - Initial.
/// </remarks> /// </remarks>
public static Boolean PulseTimeMeasurement(UInt16? refPulsesRequired = null, UInt16? dutPulsesRequired = null, public static Boolean PulseTimeMeasurement(UInt16? refPulsesRequired = null, UInt16? dutPulsesRequired = null,
@@ -1359,8 +1360,8 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
// Check if regulation can be done // Check if regulation can be done
if ((refPulsesRequired == null && dutPulsesRequired == null) || if ((refPulsesRequired == null && dutPulsesRequired == null) ||
refPulsesRequired < TIME_MEASUREMENT_INPUT_MIN_pulses || refPulsesRequired < PULSES_TIME_MEASUREMENT_INPUT_MIN ||
dutPulsesRequired < TIME_MEASUREMENT_INPUT_MIN_pulses || dutPulsesRequired < PULSES_TIME_MEASUREMENT_INPUT_MIN ||
doublePulseDeadtime_ms > DOUBLE_PULSE_DEADTIME_MAX_ms) doublePulseDeadtime_ms > DOUBLE_PULSE_DEADTIME_MAX_ms)
{ {
return false; return false;
@@ -1458,8 +1459,26 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
String info; String info;
String responseStr; String responseStr;
StatusReturn statusReturn; StatusReturn statusReturn;
// Read the device status to check for timeout between pulses
cmdName = CmdName.CMD_GET_STATUS;
info = GetCmdInfo(cmdName);
if (SharedCyclicMeasSequ != CyclicMeasSequ.IDLE && Write(cmdName, fm2014))
{
if (Read(cmdName, fm2014, out responseStr) &&
int.TryParse(responseStr, NumberStyles.HexNumber, new CultureInfo("en"),
out var status))
{
info += $": {responseStr}";
var response = new CmdResponse(cmdName, info);
PublishResponse(fm2014, new ProcessExecEventArgs("",
actualProcessPercent: ActualProcessProgress_percent,
actualProcessMessage: measurementInfo, specificInfoObj: response));
}
}
// Read the remaining REF pulses if required // Read the remaining REF pulses if required
if (firstActiveFm2014.RefPulsesRequired != 0) if (fm2014.RefPulsesRequired != 0)
{ {
// Feed the progress counter // Feed the progress counter
ActualProcessProgress = firstActiveFm2014.RefPulsesRequired - ActualProcessProgress = firstActiveFm2014.RefPulsesRequired -
@@ -1473,16 +1492,30 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
out var pulses)) out var pulses))
{ {
fm2014.RefPulsesRemaining = pulses; fm2014.RefPulsesRemaining = pulses;
// Check if remaining pulses are going to count down based on required pulses
if (RegisteredFm2014s.Any(fm => fm.RefPulsesRemaining * 1.1 < fm.RefPulsesRequired) &&
fm2014.RefPulsesRemaining == fm2014.RefPulsesRequired)
{
statusReturn = StatusReturn.MeasurementOutOfRange;
fm2014.ErrorIsDetected = true;
}
else
{
statusReturn = StatusReturn.Okay;
}
var response = new CmdResponse(cmdName, info, pulses); var response = new CmdResponse(cmdName, info, pulses);
PublishResponse(fm2014, new ProcessExecEventArgs("", PublishResponse(fm2014, new ProcessExecEventArgs("",
actualProcessPercent: ActualProcessProgress_percent, actualProcessPercent: ActualProcessProgress_percent,
statusReturn: statusReturn,
actualProcessMessage: measurementInfo, specificInfoObj: response)); actualProcessMessage: measurementInfo, specificInfoObj: response));
} }
} }
} }
// Read the remaining DUT pulses if required // Read the remaining DUT pulses if required
if (firstActiveFm2014.DutPulsesRequired != 0) if (fm2014.DutPulsesRequired != 0)
{ {
// Feed the progress counter but only if not done for REF pulses // Feed the progress counter but only if not done for REF pulses
if (firstActiveFm2014.RefPulsesRequired == 0) if (firstActiveFm2014.RefPulsesRequired == 0)
@@ -1497,9 +1530,23 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
out var pulses)) out var pulses))
{ {
fm2014.DutPulsesRemaining = pulses; fm2014.DutPulsesRemaining = pulses;
// Check if remaining pulses are going to count down based on required pulses
if (RegisteredFm2014s.Any(fm => fm.DutPulsesRemaining * 1.1 < fm.DutPulsesRequired) &&
fm2014.DutPulsesRemaining == fm2014.DutPulsesRequired)
{
statusReturn = StatusReturn.MeasurementOutOfRange;
fm2014.ErrorIsDetected = true;
}
else
{
statusReturn = StatusReturn.Okay;
}
var response = new CmdResponse(cmdName, info, pulses); var response = new CmdResponse(cmdName, info, pulses);
PublishResponse(fm2014, new ProcessExecEventArgs("", PublishResponse(fm2014, new ProcessExecEventArgs("",
actualProcessMessage: measurementInfo, actualProcessMessage: measurementInfo,
statusReturn: statusReturn,
specificInfoObj: response)); specificInfoObj: response));
} }
} }
@@ -1512,7 +1559,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
var retVal = true; var retVal = true;
// Read the REF timer ticks for the counted pulses // Read the REF timer ticks for the counted pulses
if (firstActiveFm2014.RefPulsesRequired != 0) if (fm2014.RefPulsesRequired != 0)
{ {
cmdName = CmdName.CMD_REF_GET_TMR; cmdName = CmdName.CMD_REF_GET_TMR;
info = GetCmdInfo(cmdName); info = GetCmdInfo(cmdName);
@@ -1542,7 +1589,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
} }
// Read the DUT timer ticks for the counted pulses // Read the DUT timer ticks for the counted pulses
if (firstActiveFm2014.DutPulsesRequired != 0) if (fm2014.DutPulsesRequired != 0)
{ {
cmdName = CmdName.CMD_DUT_GET_TMR; cmdName = CmdName.CMD_DUT_GET_TMR;
info = GetCmdInfo(cmdName); info = GetCmdInfo(cmdName);
@@ -1572,7 +1619,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
} }
// Calculate the DUT to REF tolerance if both timer had been active // Calculate the DUT to REF tolerance if both timer had been active
if (firstActiveFm2014.RefPulsesRequired != 0 && firstActiveFm2014.DutPulsesRequired != 0) if (fm2014.RefPulsesRequired != 0 && fm2014.DutPulsesRequired != 0)
{ {
cmdName = CmdName.CMD_CAL_DUT_TO_REF_TOL; cmdName = CmdName.CMD_CAL_DUT_TO_REF_TOL;
info = GetCmdInfo(cmdName); info = GetCmdInfo(cmdName);
@@ -1614,9 +1661,8 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
// Check all remaining DUT and REF pulses are counted on all connected devices and finalize process by // Check all remaining DUT and REF pulses are counted on all connected devices and finalize process by
// reading out all results // reading out all results
//TODO THW take timeout for unresponsive device into account and if REF and/or DUT if (RegisteredFm2014s.All(fm2014 => fm2014.MeasurementIsReady || fm2014.ErrorIsDetected ||
if (RegisteredFm2014s.All(fm2014 => fm2014.RefPulsesRemaining == 0 && !fm2014.IsLoggedOn))
fm2014.DutPulsesRemaining == 0))
{ {
ResetHardwareAllDevices(); ResetHardwareAllDevices();
// Exit this task // Exit this task
@@ -1696,12 +1742,9 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
/// <param name="dataObj"></param> /// <param name="dataObj"></param>
/// <param name="isHexFormat"></param> /// <param name="isHexFormat"></param>
/// <returns></returns> /// <returns></returns>
/// <remarks date="2026-Jan-12..23" author="Thomas Wiedebusch"> /// <remarks date="2026-Jan-12..Feb-01" author="Thomas Wiedebusch">
/// - Initial. /// - Initial.
/// </remarks> /// </remarks>
/// <remarks date="2026-Jan-28..Feb-01" author="Thomas Wiedebusch">
/// - Support for multiple FM2014s.
/// </remarks>
private static Boolean Write(CmdName cmdName, FM2014 fm2014, Object dataObj = null, Boolean isHexFormat = false) private static Boolean Write(CmdName cmdName, FM2014 fm2014, Object dataObj = null, Boolean isHexFormat = false)
{ {
if (fm2014 == null) if (fm2014 == null)
@@ -1795,12 +1838,9 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
/// </summary> /// </summary>
/// <param name="fm2014"></param> /// <param name="fm2014"></param>
/// <returns></returns> /// <returns></returns>
/// <remarks date="2026-Jan-08..19" author="Thomas Wiedebusch"> /// <remarks date="2026-Jan-08..28" author="Thomas Wiedebusch">
/// - Initial. /// - Initial.
/// </remarks> /// </remarks>
/// <remarks date="2026-Jan-28" author="Thomas Wiedebusch">
/// - Support for multiple FM2014s.
/// </remarks>
private static Boolean InitiateBroadcastComm(FM2014 fm2014) private static Boolean InitiateBroadcastComm(FM2014 fm2014)
{ {
if (fm2014 == null) if (fm2014 == null)
@@ -1858,12 +1898,9 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
/// </summary> /// </summary>
/// <param name="fm2014"></param> /// <param name="fm2014"></param>
/// <returns></returns> /// <returns></returns>
/// <remarks date="2026-Jan-08..21" author="Thomas Wiedebusch"> /// <remarks date="2026-Jan-08..28" author="Thomas Wiedebusch">
/// - Initial. /// - Initial.
/// </remarks> /// </remarks>
/// <remarks date="2026-Jan-28" author="Thomas Wiedebusch">
/// - Support for multiple FM2014s.
/// </remarks>
private static Boolean InitiateIndividualComm(FM2014 fm2014) private static Boolean InitiateIndividualComm(FM2014 fm2014)
{ {
if (fm2014 == null) if (fm2014 == null)
@@ -1951,15 +1988,9 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
/// Transfer all standalone settings to FM2014 RAM and safe those to nonvolatile EEPROM /// Transfer all standalone settings to FM2014 RAM and safe those to nonvolatile EEPROM
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
/// <remarks date="2023-Jan-04" author="Thomas Wiedebusch"> /// <remarks date="2023-Jan-29" author="Thomas Wiedebusch">
/// - Initial. /// - Initial.
/// </remarks> /// </remarks>
/// <remarks date="2023-Jan-21" author="Thomas Wiedebusch">
/// - REF pulse rate can be 0 as 'invalid marker'.
/// </remarks>
/// <remarks date="2026-Jan-28..29" author="Thomas Wiedebusch">
/// - Support for multiple FM2014s.
/// </remarks>
private Boolean SaveStandAloneMeasurement() private Boolean SaveStandAloneMeasurement()
{ {
// If the cyclic task has already been started everything is fine // If the cyclic task has already been started everything is fine
@@ -2014,19 +2045,14 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
/// Handle the standalone measurement which will be executed after BOOT of the FM2014: /// Handle the standalone measurement which will be executed after BOOT of the FM2014:
/// - Read the setup stored to nonvolatile memory (EEPROM), /// - Read the setup stored to nonvolatile memory (EEPROM),
/// - Read the actual setup kept in RAM. /// - Read the actual setup kept in RAM.
/// </summary>
/// <param name="cmdName"></param>
/// <returns></returns>
/// <remarks date="2026-Jan-18" author="Thomas Wiedebusch">
/// - Initial.
/// </remarks>
/// <remarks date="2023-Jan-25" author="Thomas Wiedebusch">
/// - 'Ref_pulse_per_cm' will be calculated by 'Ref_pulses_per_cm = Dut_pulses_per_cm * RefToDutScale_norm' /// - 'Ref_pulse_per_cm' will be calculated by 'Ref_pulses_per_cm = Dut_pulses_per_cm * RefToDutScale_norm'
/// to avoid an overflow as the REF pulses per volume can store max 9999 pulses. As the Dut_pulse_per_cm /// to avoid an overflow as the REF pulses per volume can store max 9999 pulses. As the Dut_pulse_per_cm
/// is for the smallest meter 1000 Impulses/m³ /// is for the smallest meter 1000 Impulses/m³
/// </remarks> /// </summary>
/// <remarks date="2026-Jan-28..29" author="Thomas Wiedebusch"> /// <param name="cmdName"></param>
/// - Support for multiple FM2014s. /// <returns></returns>
/// <remarks date="2026-Jan-29" author="Thomas Wiedebusch">
/// - Initial.
/// </remarks> /// </remarks>
private Boolean ReadStandAloneMeasurement(CmdName cmdName) private Boolean ReadStandAloneMeasurement(CmdName cmdName)
{ {
@@ -2140,16 +2166,9 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
/// Login to individual address. /// Login to individual address.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
/// <remarks date="2026-Jan-08" author="Thomas Wiedebusch"> /// <remarks date="2026-Jan-08..Feb-05" author="Thomas Wiedebusch">
/// - Initial. /// - Initial.
/// </remarks> /// </remarks>
/// <remarks date="2026-Jan-28..30" author="Thomas Wiedebusch">
/// - Support for multiple FM2014s.
/// </remarks>
/// <remarks date="2026-Feb-05" author="Thomas Wiedebusch">
/// - Login with <see cref="InitiateIndividualComm"/>,
/// - Other communications moved to <see cref="Connect"/>
/// </remarks>
public Boolean Login() public Boolean Login()
{ {
// If the cyclic task has already been started the login isn't allowed anymore // If the cyclic task has already been started the login isn't allowed anymore
@@ -2186,8 +2205,9 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
{ {
foreach (var fm2014 in RegisteredFm2014s.Where(fm2014 => fm2014.IsLoggedOn)) foreach (var fm2014 in RegisteredFm2014s.Where(fm2014 => fm2014.IsLoggedOn))
{ {
fm2014.RefTimerTicksMeasured = 0; fm2014.RefTimeMeasured_s = 0;
fm2014.DutTimerTicksMeasured = 0; fm2014.DutTimeMeasured_s = 0;
fm2014.DutToRefToleranceMeasured_percent = null;
fm2014.RefFlowRate_cm_per_h = 0; fm2014.RefFlowRate_cm_per_h = 0;
fm2014.DutFlowRate_cm_per_h = 0; fm2014.DutFlowRate_cm_per_h = 0;
} }
@@ -503,8 +503,8 @@ namespace Sensus.Ui.FM2014TestBench
if (_fm2014Config?.IndividualTolerancePercent?[ctr] != null && if (_fm2014Config?.IndividualTolerancePercent?[ctr] != null &&
_fm2014Config.IndividualTolerancePercent.Count == MaxFm2014s) _fm2014Config.IndividualTolerancePercent.Count == MaxFm2014s)
{ {
fm2014.Tolerance_percent = _fm2014Config?.IndividualTolerancePercent[ctr] ?? fm2014.CurrentOutputToleranceNominalInt_percent = _fm2014Config?.IndividualTolerancePercent[ctr] ??
FM2014.STANDARD_NOMINAL_TOLERANCE_INPUT_percent; FM2014.CURRENT_OUTPUT_TOLERANCE_STANDARD_NOMINAL_INT_percent;
} }
} }
if (_fm2014Config != null) if (_fm2014Config != null)
@@ -512,7 +512,7 @@ namespace Sensus.Ui.FM2014TestBench
// Restore baudrate // Restore baudrate
FM2014.Baudrate = _fm2014Config.Baudrate; FM2014.Baudrate = _fm2014Config.Baudrate;
// Restore Calibration settings for user convenience // Restore calibration settings for user convenience
tbxRefPulsesRequired.Text = $"{_fm2014Config.RefPulsesRequired:D}"; tbxRefPulsesRequired.Text = $"{_fm2014Config.RefPulsesRequired:D}";
tbxDutPulsesRequired.Text = $"{_fm2014Config.DutPulsesRequired:D}"; tbxDutPulsesRequired.Text = $"{_fm2014Config.DutPulsesRequired:D}";
tbxDoublePulseDeadtime.Text = $"{_fm2014Config.DoublePulseDeadtime:D}"; tbxDoublePulseDeadtime.Text = $"{_fm2014Config.DoublePulseDeadtime:D}";
@@ -646,7 +646,7 @@ namespace Sensus.Ui.FM2014TestBench
var fm2014 = Fm2014s[ctr]; var fm2014 = Fm2014s[ctr];
if (fm2014 == null) if (fm2014 == null)
return; return;
_fm2014Config.IndividualTolerancePercent.Add(fm2014.Tolerance_percent); _fm2014Config.IndividualTolerancePercent.Add(fm2014.CurrentOutputToleranceNominalInt_percent);
_fm2014Config.SlotIsSelected.Add(SlotSelections[ctr].IsChecked); _fm2014Config.SlotIsSelected.Add(SlotSelections[ctr].IsChecked);
} }
@@ -1291,14 +1291,14 @@ namespace Sensus.Ui.FM2014TestBench
Dispatcher.Invoke(() => Dispatcher.Invoke(() =>
{ {
if (int.TryParse(tbxRefPulsesRequired.Text, out var pulses) && if (int.TryParse(tbxRefPulsesRequired.Text, out var pulses) &&
FM2014.TIME_MEASUREMENT_INPUT_MIN_pulses <= pulses && FM2014.PULSES_TIME_MEASUREMENT_INPUT_MIN <= pulses &&
FM2014.TIME_MEASUREMENT_INPUT_MAX_pulses >= pulses) FM2014.PULSES_TIME_MEASUREMENT_INPUT_MAX >= pulses)
{ {
refPulsesRequired = (UInt16)pulses; refPulsesRequired = (UInt16)pulses;
} }
if (int.TryParse(tbxDutPulsesRequired.Text, out pulses) && if (int.TryParse(tbxDutPulsesRequired.Text, out pulses) &&
FM2014.TIME_MEASUREMENT_INPUT_MIN_pulses <= pulses && FM2014.PULSES_TIME_MEASUREMENT_INPUT_MIN <= pulses &&
FM2014.TIME_MEASUREMENT_INPUT_MAX_pulses >= pulses) FM2014.PULSES_TIME_MEASUREMENT_INPUT_MAX >= pulses)
{ {
dutPulsesRequired = (UInt16)pulses; dutPulsesRequired = (UInt16)pulses;
} }
@@ -1420,8 +1420,8 @@ namespace Sensus.Ui.FM2014TestBench
} }
if (int.TryParse(cbxToleranceCalc.SelectedItem.ToString(), out var tolerance) && if (int.TryParse(cbxToleranceCalc.SelectedItem.ToString(), out var tolerance) &&
(tolerance == FM2014.STANDARD_NOMINAL_TOLERANCE_INPUT_percent || (tolerance == FM2014.CURRENT_OUTPUT_TOLERANCE_STANDARD_NOMINAL_INT_percent ||
tolerance == FM2014.EXTENDED_NOMINAL_TOLERANCE_INPUT_percent)) tolerance == FM2014.CURRENT_OUTPUT_TOLERANCE_EXTENDED_VALUE_INT_percent))
{ {
toleranceSetup = tolerance; toleranceSetup = tolerance;
} }
@@ -1433,7 +1433,7 @@ 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(REG_MEASURE_COUNT); ucFM2014.EnableMeasurements(REG_MEASURE_COUNT);
fm2014.Tolerance_percent = toleranceSetup; fm2014.CurrentOutputToleranceNominalInt_percent = toleranceSetup;
} }
if (FM2014.RegulationMeasurement(refPulses_per_cm, dutPulses_per_cm, doublePulseDeadtime_ms, if (FM2014.RegulationMeasurement(refPulses_per_cm, dutPulses_per_cm, doublePulseDeadtime_ms,
@@ -1547,9 +1547,9 @@ namespace Sensus.Ui.FM2014TestBench
Dispatcher.Invoke(() => Dispatcher.Invoke(() =>
{ {
if (byte.TryParse(cbxToleranceCalc.SelectedItem.ToString(), out var tolerance) && if (byte.TryParse(cbxToleranceCalc.SelectedItem.ToString(), out var tolerance) &&
(tolerance == FM2014.STANDARD_NOMINAL_TOLERANCE_INPUT_percent || (tolerance == FM2014.CURRENT_OUTPUT_TOLERANCE_STANDARD_NOMINAL_INT_percent ||
tolerance == FM2014.EXTENDED_NOMINAL_TOLERANCE_INPUT_percent) && tolerance == FM2014.CURRENT_OUTPUT_TOLERANCE_EXTENDED_VALUE_INT_percent) &&
firstFm2014.Tolerance_percent != tolerance) firstFm2014.CurrentOutputToleranceNominalInt_percent != tolerance)
{ {
_regulationSetupHasChanged = true; _regulationSetupHasChanged = true;
btnSaveRegulationSetup.IsEnabled = true; btnSaveRegulationSetup.IsEnabled = true;
@@ -1789,8 +1789,8 @@ namespace Sensus.Ui.FM2014TestBench
// Convert the input and check limits // Convert the input and check limits
if (int.TryParse(tbxRefPulsesRequired.Text, out var pulses) && if (int.TryParse(tbxRefPulsesRequired.Text, out var pulses) &&
FM2014.TIME_MEASUREMENT_INPUT_MIN_pulses <= pulses && FM2014.PULSES_TIME_MEASUREMENT_INPUT_MIN <= pulses &&
FM2014.TIME_MEASUREMENT_INPUT_MAX_pulses >= pulses) FM2014.PULSES_TIME_MEASUREMENT_INPUT_MAX >= pulses)
{ {
if (backupPulsesRequired != pulses) if (backupPulsesRequired != pulses)
_calibrationSetupHasChanged = true; _calibrationSetupHasChanged = true;
@@ -1884,8 +1884,8 @@ namespace Sensus.Ui.FM2014TestBench
// Convert the input and check limits // Convert the input and check limits
if (int.TryParse(tbxDutPulsesRequired.Text, out var pulses) && if (int.TryParse(tbxDutPulsesRequired.Text, out var pulses) &&
FM2014.TIME_MEASUREMENT_INPUT_MIN_pulses <= pulses && FM2014.PULSES_TIME_MEASUREMENT_INPUT_MIN <= pulses &&
FM2014.TIME_MEASUREMENT_INPUT_MAX_pulses >= pulses) FM2014.PULSES_TIME_MEASUREMENT_INPUT_MAX >= pulses)
{ {
if (backupPulsesRequired != pulses) if (backupPulsesRequired != pulses)
_calibrationSetupHasChanged = true; _calibrationSetupHasChanged = true;