FM2014: - time measurement automatic stop
This commit is contained in:
parent
0272761db8
commit
49c7cc5cc6
@ -77,7 +77,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
/// <summary>
|
||||
/// The mantissa for the scale value has to be in the range from 1000 to 9999.
|
||||
/// </summary>
|
||||
private const UInt16 MANTISSA_SCALE_MIN = 1000;
|
||||
private const UInt16 REF_TO_DUT_SCALE_MANTISSA_MIN = 1000;
|
||||
|
||||
/// <summary>
|
||||
/// REF to DUT scale conversion factor to meaningful human interpretable value
|
||||
@ -87,29 +87,29 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
/// <summary>
|
||||
/// Default tolerance if not properly setup.
|
||||
/// </summary>
|
||||
public const Int32 STANDARD_NOMINAL_TOLERANCE_INPUT_percent = 3;
|
||||
public const Int32 CURRENT_OUTPUT_TOLERANCE_STANDARD_NOMINAL_INT_percent = 3;
|
||||
|
||||
/// <summary>
|
||||
/// Default tolerance if not properly setup.
|
||||
/// </summary>
|
||||
public const Int32 EXTENDED_NOMINAL_TOLERANCE_INPUT_percent = 5;
|
||||
public const Int32 CURRENT_OUTPUT_TOLERANCE_EXTENDED_VALUE_INT_percent = 5;
|
||||
|
||||
/// <summary>
|
||||
/// Standard tolerance (nominal 3 %) multiplicator for calculation of value based on feedback from FM2014
|
||||
/// (+/- 255 digits).
|
||||
/// </summary>
|
||||
private const Double STANDARD_TOLERANCE_VALUE_percent = 3.3;
|
||||
private const Double CURRENT_OUTPUT_TOLERANCE_STANDARD_VALUE_DOUBLE_percent = 3.3;
|
||||
|
||||
/// <summary>
|
||||
/// Extended tolerance (nominal 5 %) multiplicator for calculation of value based on feedback from FM2014
|
||||
/// (+/- 255 digits).
|
||||
/// </summary>
|
||||
private const Double EXTENDED_TOLERANCE_VALUE_percent = 5.5;
|
||||
private const Double CURRENT_OUTPUT_TOLERANCE_EXTENDED_VALUE_DOUBLE_percent = 5.5;
|
||||
|
||||
/// <summary>
|
||||
/// Resolution of tolerance raw value feedback from FM2014 (+/- 255 digits).
|
||||
/// </summary>
|
||||
private const Double RESOLUTION_TOLERANCE_RAW_VALUE = 255;
|
||||
private const Double CURRENT_OUTPUT_TOLERANCE_RESOLUTION_PLUS_MINUS_BYTE = 255;
|
||||
|
||||
/// <summary>
|
||||
/// Minimal value for attenuation.
|
||||
@ -159,12 +159,12 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
/// <summary>
|
||||
/// FM2014 minimal pulses for REF and DUT time measurement.
|
||||
/// </summary>
|
||||
public const UInt16 TIME_MEASUREMENT_INPUT_MIN_pulses = 1;
|
||||
public const UInt16 PULSES_TIME_MEASUREMENT_INPUT_MIN = 1;
|
||||
|
||||
/// <summary>
|
||||
/// FM2014 maximal pulses for REF and DUT time measurement.
|
||||
/// </summary>
|
||||
public const UInt16 TIME_MEASUREMENT_INPUT_MAX_pulses = 0xFFFF;
|
||||
public const UInt16 PULSES_TIME_MEASUREMENT_INPUT_MAX = 0xFFFF;
|
||||
|
||||
/// <summary>
|
||||
/// Minimal baudrate for serial communication.
|
||||
@ -247,7 +247,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
/// <summary>
|
||||
/// Progress of actual process converted to percent
|
||||
/// </summary>
|
||||
private static Double ActualProcessProgress_percent { get; set; }
|
||||
private static Double? ActualProcessProgress_percent { get; set; }
|
||||
|
||||
private static Int32 _actualProcessProgress;
|
||||
/// <summary>
|
||||
@ -343,35 +343,35 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
/// <summary>
|
||||
/// Private tolerance percentage
|
||||
/// </summary>
|
||||
private Int32 _tolerance_percent = STANDARD_NOMINAL_TOLERANCE_INPUT_percent;
|
||||
private Int32 _currentOutputToleranceNominalInt_percent = CURRENT_OUTPUT_TOLERANCE_STANDARD_NOMINAL_INT_percent;
|
||||
|
||||
/// <summary>
|
||||
/// Actual tolerance scale to convert raw value from FM2014 to percent
|
||||
/// </summary>
|
||||
private Double ToleranceRawToPercentScale { set; get; } =
|
||||
STANDARD_TOLERANCE_VALUE_percent / RESOLUTION_TOLERANCE_RAW_VALUE;
|
||||
private Double CurrentOutputToleranceNominalToRealScale { set; get; } =
|
||||
CURRENT_OUTPUT_TOLERANCE_STANDARD_VALUE_DOUBLE_percent / CURRENT_OUTPUT_TOLERANCE_RESOLUTION_PLUS_MINUS_BYTE;
|
||||
|
||||
/// <summary>
|
||||
/// Tolerance output of current loop in percent:
|
||||
/// Nominal tolerance output of current loop in percent:
|
||||
/// - hardware dependent 3% or 5%
|
||||
/// </summary>
|
||||
public Int32 Tolerance_percent
|
||||
public Int32 CurrentOutputToleranceNominalInt_percent
|
||||
{
|
||||
get => _tolerance_percent;
|
||||
get => _currentOutputToleranceNominalInt_percent;
|
||||
set
|
||||
{
|
||||
// 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
|
||||
Double percentage;
|
||||
if (value == STANDARD_NOMINAL_TOLERANCE_INPUT_percent)
|
||||
percentage = STANDARD_TOLERANCE_VALUE_percent;
|
||||
else if (value == EXTENDED_NOMINAL_TOLERANCE_INPUT_percent)
|
||||
percentage = EXTENDED_TOLERANCE_VALUE_percent;
|
||||
if (value == CURRENT_OUTPUT_TOLERANCE_STANDARD_NOMINAL_INT_percent)
|
||||
percentage = CURRENT_OUTPUT_TOLERANCE_STANDARD_VALUE_DOUBLE_percent;
|
||||
else if (value == CURRENT_OUTPUT_TOLERANCE_EXTENDED_VALUE_INT_percent)
|
||||
percentage = CURRENT_OUTPUT_TOLERANCE_EXTENDED_VALUE_DOUBLE_percent;
|
||||
else
|
||||
percentage = STANDARD_TOLERANCE_VALUE_percent;
|
||||
percentage = CURRENT_OUTPUT_TOLERANCE_STANDARD_VALUE_DOUBLE_percent;
|
||||
|
||||
_tolerance_percent = value;
|
||||
ToleranceRawToPercentScale = percentage / RESOLUTION_TOLERANCE_RAW_VALUE;
|
||||
_currentOutputToleranceNominalInt_percent = value;
|
||||
CurrentOutputToleranceNominalToRealScale = percentage / CURRENT_OUTPUT_TOLERANCE_RESOLUTION_PLUS_MINUS_BYTE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -390,7 +390,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
private set
|
||||
{
|
||||
// Check limits and equality
|
||||
if (value < TIME_MEASUREMENT_INPUT_MIN_pulses ||
|
||||
if (value < PULSES_TIME_MEASUREMENT_INPUT_MIN ||
|
||||
value == _refPulsesRequired)
|
||||
return;
|
||||
|
||||
@ -408,7 +408,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
private set
|
||||
{
|
||||
// Check limits and equality
|
||||
if (value < TIME_MEASUREMENT_INPUT_MIN_pulses ||
|
||||
if (value < PULSES_TIME_MEASUREMENT_INPUT_MIN ||
|
||||
value == _dutPulsesRequired)
|
||||
return;
|
||||
|
||||
@ -563,7 +563,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
number *= REF_TO_DUT_SCALE_CONVERSION;
|
||||
mantissa = (UInt16)(number + 0.5);
|
||||
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
|
||||
RefToDutScaleStr = $"{mantissa}{GetCmdStr(CmdName.CMD_REF_SET_SCALE)}{exponent}";
|
||||
@ -688,7 +688,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
/// <summary>
|
||||
/// Measured tolerance during calibration
|
||||
/// </summary>
|
||||
public Double DutToRefToleranceMeasured_percent { get; private set; }
|
||||
public Double? DutToRefToleranceMeasured_percent { get; private set; }
|
||||
|
||||
#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
|
||||
/// using a broadcast command
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <returns>null if no device is connected and logged in</returns>
|
||||
/// <remarks date="2026-Feb-05" author="Thomas Wiedebusch">
|
||||
/// - Initial.
|
||||
/// </remarks>
|
||||
@ -1150,17 +1150,18 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
// The response contains a sign!
|
||||
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))
|
||||
if (int.TryParse(cleanedStr, NumberStyles.HexNumber,
|
||||
new CultureInfo("en"), out var measTolerance))
|
||||
{
|
||||
fm2014.DutToRefToleranceMeasured_percent =
|
||||
measTolerance * fm2014.ToleranceRawToPercentScale * signMultiplier;
|
||||
measTolerance * fm2014.CurrentOutputToleranceNominalToRealScale * signMultiplier;
|
||||
var response = new CmdResponse(cmdName, info,
|
||||
doubleValue: fm2014.DutToRefToleranceMeasured_percent,
|
||||
unit: Units.GetInfo(Units.Name.PERCENT));
|
||||
|
||||
// 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;
|
||||
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>
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2026-Jan-14..Feb-11" author="Thomas Wiedebusch">
|
||||
/// <remarks date="2026-Jan-14..Feb-13" author="Thomas Wiedebusch">
|
||||
/// - Initial.
|
||||
/// </remarks>
|
||||
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
|
||||
if ((refPulsesRequired == null && dutPulsesRequired == null) ||
|
||||
refPulsesRequired < TIME_MEASUREMENT_INPUT_MIN_pulses ||
|
||||
dutPulsesRequired < TIME_MEASUREMENT_INPUT_MIN_pulses ||
|
||||
refPulsesRequired < PULSES_TIME_MEASUREMENT_INPUT_MIN ||
|
||||
dutPulsesRequired < PULSES_TIME_MEASUREMENT_INPUT_MIN ||
|
||||
doublePulseDeadtime_ms > DOUBLE_PULSE_DEADTIME_MAX_ms)
|
||||
{
|
||||
return false;
|
||||
@ -1458,8 +1459,26 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
String info;
|
||||
String responseStr;
|
||||
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
|
||||
if (firstActiveFm2014.RefPulsesRequired != 0)
|
||||
if (fm2014.RefPulsesRequired != 0)
|
||||
{
|
||||
// Feed the progress counter
|
||||
ActualProcessProgress = firstActiveFm2014.RefPulsesRequired -
|
||||
@ -1473,16 +1492,30 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
out var 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);
|
||||
PublishResponse(fm2014, new ProcessExecEventArgs("",
|
||||
actualProcessPercent: ActualProcessProgress_percent,
|
||||
statusReturn: statusReturn,
|
||||
actualProcessMessage: measurementInfo, specificInfoObj: response));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
if (firstActiveFm2014.RefPulsesRequired == 0)
|
||||
@ -1497,9 +1530,23 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
out var 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);
|
||||
PublishResponse(fm2014, new ProcessExecEventArgs("",
|
||||
actualProcessMessage: measurementInfo,
|
||||
statusReturn: statusReturn,
|
||||
specificInfoObj: response));
|
||||
}
|
||||
}
|
||||
@ -1512,7 +1559,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
var retVal = true;
|
||||
|
||||
// Read the REF timer ticks for the counted pulses
|
||||
if (firstActiveFm2014.RefPulsesRequired != 0)
|
||||
if (fm2014.RefPulsesRequired != 0)
|
||||
{
|
||||
cmdName = CmdName.CMD_REF_GET_TMR;
|
||||
info = GetCmdInfo(cmdName);
|
||||
@ -1542,7 +1589,7 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
}
|
||||
|
||||
// Read the DUT timer ticks for the counted pulses
|
||||
if (firstActiveFm2014.DutPulsesRequired != 0)
|
||||
if (fm2014.DutPulsesRequired != 0)
|
||||
{
|
||||
cmdName = CmdName.CMD_DUT_GET_TMR;
|
||||
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
|
||||
if (firstActiveFm2014.RefPulsesRequired != 0 && firstActiveFm2014.DutPulsesRequired != 0)
|
||||
if (fm2014.RefPulsesRequired != 0 && fm2014.DutPulsesRequired != 0)
|
||||
{
|
||||
cmdName = CmdName.CMD_CAL_DUT_TO_REF_TOL;
|
||||
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
|
||||
// reading out all results
|
||||
//TODO THW take timeout for unresponsive device into account and if REF and/or DUT
|
||||
if (RegisteredFm2014s.All(fm2014 => fm2014.RefPulsesRemaining == 0 &&
|
||||
fm2014.DutPulsesRemaining == 0))
|
||||
if (RegisteredFm2014s.All(fm2014 => fm2014.MeasurementIsReady || fm2014.ErrorIsDetected ||
|
||||
!fm2014.IsLoggedOn))
|
||||
{
|
||||
ResetHardwareAllDevices();
|
||||
// Exit this task
|
||||
@ -1696,12 +1742,9 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
/// <param name="dataObj"></param>
|
||||
/// <param name="isHexFormat"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2026-Jan-12..23" author="Thomas Wiedebusch">
|
||||
/// <remarks date="2026-Jan-12..Feb-01" author="Thomas Wiedebusch">
|
||||
/// - Initial.
|
||||
/// </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)
|
||||
{
|
||||
if (fm2014 == null)
|
||||
@ -1795,12 +1838,9 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
/// </summary>
|
||||
/// <param name="fm2014"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2026-Jan-08..19" author="Thomas Wiedebusch">
|
||||
/// <remarks date="2026-Jan-08..28" author="Thomas Wiedebusch">
|
||||
/// - Initial.
|
||||
/// </remarks>
|
||||
/// <remarks date="2026-Jan-28" author="Thomas Wiedebusch">
|
||||
/// - Support for multiple FM2014s.
|
||||
/// </remarks>
|
||||
private static Boolean InitiateBroadcastComm(FM2014 fm2014)
|
||||
{
|
||||
if (fm2014 == null)
|
||||
@ -1858,12 +1898,9 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
/// </summary>
|
||||
/// <param name="fm2014"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2026-Jan-08..21" author="Thomas Wiedebusch">
|
||||
/// <remarks date="2026-Jan-08..28" author="Thomas Wiedebusch">
|
||||
/// - Initial.
|
||||
/// </remarks>
|
||||
/// <remarks date="2026-Jan-28" author="Thomas Wiedebusch">
|
||||
/// - Support for multiple FM2014s.
|
||||
/// </remarks>
|
||||
private static Boolean InitiateIndividualComm(FM2014 fm2014)
|
||||
{
|
||||
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
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2023-Jan-04" author="Thomas Wiedebusch">
|
||||
/// <remarks date="2023-Jan-29" author="Thomas Wiedebusch">
|
||||
/// - Initial.
|
||||
/// </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()
|
||||
{
|
||||
// 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:
|
||||
/// - Read the setup stored to nonvolatile memory (EEPROM),
|
||||
/// - 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'
|
||||
/// 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³
|
||||
/// </remarks>
|
||||
/// <remarks date="2026-Jan-28..29" author="Thomas Wiedebusch">
|
||||
/// - Support for multiple FM2014s.
|
||||
/// </summary>
|
||||
/// <param name="cmdName"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2026-Jan-29" author="Thomas Wiedebusch">
|
||||
/// - Initial.
|
||||
/// </remarks>
|
||||
private Boolean ReadStandAloneMeasurement(CmdName cmdName)
|
||||
{
|
||||
@ -2140,16 +2166,9 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
|
||||
/// Login to individual address.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <remarks date="2026-Jan-08" author="Thomas Wiedebusch">
|
||||
/// <remarks date="2026-Jan-08..Feb-05" author="Thomas Wiedebusch">
|
||||
/// - Initial.
|
||||
/// </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()
|
||||
{
|
||||
// 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))
|
||||
{
|
||||
fm2014.RefTimerTicksMeasured = 0;
|
||||
fm2014.DutTimerTicksMeasured = 0;
|
||||
fm2014.RefTimeMeasured_s = 0;
|
||||
fm2014.DutTimeMeasured_s = 0;
|
||||
fm2014.DutToRefToleranceMeasured_percent = null;
|
||||
fm2014.RefFlowRate_cm_per_h = 0;
|
||||
fm2014.DutFlowRate_cm_per_h = 0;
|
||||
}
|
||||
|
||||
@ -503,8 +503,8 @@ namespace Sensus.Ui.FM2014TestBench
|
||||
if (_fm2014Config?.IndividualTolerancePercent?[ctr] != null &&
|
||||
_fm2014Config.IndividualTolerancePercent.Count == MaxFm2014s)
|
||||
{
|
||||
fm2014.Tolerance_percent = _fm2014Config?.IndividualTolerancePercent[ctr] ??
|
||||
FM2014.STANDARD_NOMINAL_TOLERANCE_INPUT_percent;
|
||||
fm2014.CurrentOutputToleranceNominalInt_percent = _fm2014Config?.IndividualTolerancePercent[ctr] ??
|
||||
FM2014.CURRENT_OUTPUT_TOLERANCE_STANDARD_NOMINAL_INT_percent;
|
||||
}
|
||||
}
|
||||
if (_fm2014Config != null)
|
||||
@ -512,7 +512,7 @@ namespace Sensus.Ui.FM2014TestBench
|
||||
// Restore baudrate
|
||||
FM2014.Baudrate = _fm2014Config.Baudrate;
|
||||
|
||||
// Restore Calibration settings for user convenience
|
||||
// Restore calibration settings for user convenience
|
||||
tbxRefPulsesRequired.Text = $"{_fm2014Config.RefPulsesRequired:D}";
|
||||
tbxDutPulsesRequired.Text = $"{_fm2014Config.DutPulsesRequired:D}";
|
||||
tbxDoublePulseDeadtime.Text = $"{_fm2014Config.DoublePulseDeadtime:D}";
|
||||
@ -646,7 +646,7 @@ namespace Sensus.Ui.FM2014TestBench
|
||||
var fm2014 = Fm2014s[ctr];
|
||||
if (fm2014 == null)
|
||||
return;
|
||||
_fm2014Config.IndividualTolerancePercent.Add(fm2014.Tolerance_percent);
|
||||
_fm2014Config.IndividualTolerancePercent.Add(fm2014.CurrentOutputToleranceNominalInt_percent);
|
||||
_fm2014Config.SlotIsSelected.Add(SlotSelections[ctr].IsChecked);
|
||||
}
|
||||
|
||||
@ -1291,14 +1291,14 @@ namespace Sensus.Ui.FM2014TestBench
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
if (int.TryParse(tbxRefPulsesRequired.Text, out var pulses) &&
|
||||
FM2014.TIME_MEASUREMENT_INPUT_MIN_pulses <= pulses &&
|
||||
FM2014.TIME_MEASUREMENT_INPUT_MAX_pulses >= pulses)
|
||||
FM2014.PULSES_TIME_MEASUREMENT_INPUT_MIN <= pulses &&
|
||||
FM2014.PULSES_TIME_MEASUREMENT_INPUT_MAX >= pulses)
|
||||
{
|
||||
refPulsesRequired = (UInt16)pulses;
|
||||
}
|
||||
if (int.TryParse(tbxDutPulsesRequired.Text, out pulses) &&
|
||||
FM2014.TIME_MEASUREMENT_INPUT_MIN_pulses <= pulses &&
|
||||
FM2014.TIME_MEASUREMENT_INPUT_MAX_pulses >= pulses)
|
||||
FM2014.PULSES_TIME_MEASUREMENT_INPUT_MIN <= pulses &&
|
||||
FM2014.PULSES_TIME_MEASUREMENT_INPUT_MAX >= pulses)
|
||||
{
|
||||
dutPulsesRequired = (UInt16)pulses;
|
||||
}
|
||||
@ -1420,8 +1420,8 @@ namespace Sensus.Ui.FM2014TestBench
|
||||
}
|
||||
|
||||
if (int.TryParse(cbxToleranceCalc.SelectedItem.ToString(), out var tolerance) &&
|
||||
(tolerance == FM2014.STANDARD_NOMINAL_TOLERANCE_INPUT_percent ||
|
||||
tolerance == FM2014.EXTENDED_NOMINAL_TOLERANCE_INPUT_percent))
|
||||
(tolerance == FM2014.CURRENT_OUTPUT_TOLERANCE_STANDARD_NOMINAL_INT_percent ||
|
||||
tolerance == FM2014.CURRENT_OUTPUT_TOLERANCE_EXTENDED_VALUE_INT_percent))
|
||||
{
|
||||
toleranceSetup = tolerance;
|
||||
}
|
||||
@ -1433,7 +1433,7 @@ namespace Sensus.Ui.FM2014TestBench
|
||||
var idx = fm2014.Address - 1;
|
||||
var ucFM2014 = (UcFM2014Device)UcFM2014s[idx];
|
||||
ucFM2014.EnableMeasurements(REG_MEASURE_COUNT);
|
||||
fm2014.Tolerance_percent = toleranceSetup;
|
||||
fm2014.CurrentOutputToleranceNominalInt_percent = toleranceSetup;
|
||||
}
|
||||
|
||||
if (FM2014.RegulationMeasurement(refPulses_per_cm, dutPulses_per_cm, doublePulseDeadtime_ms,
|
||||
@ -1547,9 +1547,9 @@ namespace Sensus.Ui.FM2014TestBench
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
if (byte.TryParse(cbxToleranceCalc.SelectedItem.ToString(), out var tolerance) &&
|
||||
(tolerance == FM2014.STANDARD_NOMINAL_TOLERANCE_INPUT_percent ||
|
||||
tolerance == FM2014.EXTENDED_NOMINAL_TOLERANCE_INPUT_percent) &&
|
||||
firstFm2014.Tolerance_percent != tolerance)
|
||||
(tolerance == FM2014.CURRENT_OUTPUT_TOLERANCE_STANDARD_NOMINAL_INT_percent ||
|
||||
tolerance == FM2014.CURRENT_OUTPUT_TOLERANCE_EXTENDED_VALUE_INT_percent) &&
|
||||
firstFm2014.CurrentOutputToleranceNominalInt_percent != tolerance)
|
||||
{
|
||||
_regulationSetupHasChanged = true;
|
||||
btnSaveRegulationSetup.IsEnabled = true;
|
||||
@ -1789,8 +1789,8 @@ namespace Sensus.Ui.FM2014TestBench
|
||||
|
||||
// Convert the input and check limits
|
||||
if (int.TryParse(tbxRefPulsesRequired.Text, out var pulses) &&
|
||||
FM2014.TIME_MEASUREMENT_INPUT_MIN_pulses <= pulses &&
|
||||
FM2014.TIME_MEASUREMENT_INPUT_MAX_pulses >= pulses)
|
||||
FM2014.PULSES_TIME_MEASUREMENT_INPUT_MIN <= pulses &&
|
||||
FM2014.PULSES_TIME_MEASUREMENT_INPUT_MAX >= pulses)
|
||||
{
|
||||
if (backupPulsesRequired != pulses)
|
||||
_calibrationSetupHasChanged = true;
|
||||
@ -1884,8 +1884,8 @@ namespace Sensus.Ui.FM2014TestBench
|
||||
|
||||
// Convert the input and check limits
|
||||
if (int.TryParse(tbxDutPulsesRequired.Text, out var pulses) &&
|
||||
FM2014.TIME_MEASUREMENT_INPUT_MIN_pulses <= pulses &&
|
||||
FM2014.TIME_MEASUREMENT_INPUT_MAX_pulses >= pulses)
|
||||
FM2014.PULSES_TIME_MEASUREMENT_INPUT_MIN <= pulses &&
|
||||
FM2014.PULSES_TIME_MEASUREMENT_INPUT_MAX >= pulses)
|
||||
{
|
||||
if (backupPulsesRequired != pulses)
|
||||
_calibrationSetupHasChanged = true;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user