FM2014TestBench: - initial setup to test multiple FM2014 - 15.Step

This commit is contained in:
Thomas Wiedebusch 2026-02-11 11:48:09 +01:00
parent d39c71c7e7
commit 26e1ea6378
7 changed files with 46 additions and 26 deletions

View File

@ -114,12 +114,12 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
/// <summary>
/// Minimal value for attenuation.
/// </summary>
public const Byte ATTENUATION_MIN = 1;
public const Byte CURRENT_OUTPUT_ATTENUATION_MIN = 1;
/// <summary>
/// Maximal value for attenuation.
/// </summary>
public const Byte ATTENUATION_MAX = 9;
public const Byte CURRENT_OUTPUT_ATTENUATION_MAX = 9;
/// <summary>
/// Minimal value for double pulse lock time in milliseconds, 0.0 means it is disabled.
@ -580,7 +580,8 @@ namespace Sensus.Common.Hardware.WaterMeter.MechanicalMeter.FM2014.FM2014Core
get => _currentOutputAttenuation;
private set
{
if (value < ATTENUATION_MIN || value > ATTENUATION_MAX)
if (value < CURRENT_OUTPUT_ATTENUATION_MIN ||
value > CURRENT_OUTPUT_ATTENUATION_MAX)
return;
_currentOutputAttenuation = value;

View File

@ -2,6 +2,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=Ackn/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=BAUDRATE/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Brodcast/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Calib/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Consts/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=DBPL/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=DPLS/@EntryIndexedValue">True</s:Boolean>

View File

@ -338,7 +338,7 @@
<ComboBox x:Name="cbxToleranceCalc" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="1,1,1,1" Grid.Row="5" Grid.Column="23" Grid.ColumnSpan="2" TabIndex="105" HorizontalContentAlignment="Right" KeyDown="cbxToleranceCalc_KeyDown" SelectionChanged="cbxToleranceCalc_SelectedIndexChanged"/>
<CheckBox x:Name="chkUseDampedTolerance" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="1,1,1,1" Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="6" Content="Damped Tolerance ON" TabIndex="101" Click="chkUseDampedTolerance_CheckedChanged" />
<Button x:Name="btnDutToRefRegulation" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="1,1,1,1" Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="4" Content="Start Regulation" TabIndex="100" Click="btnDutToRefRegulation_Click" />
<Button x:Name="btnSaveRegulationSetup" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="1,1,1,1" Grid.Row="6" Grid.Column="21" Grid.ColumnSpan="4" Content="Save" TabIndex="106" Click="btnSaveRegulationSetup_Click" />
<Button x:Name="btnSaveRegulationSetup" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="1,1,1,1" Grid.Row="6" Grid.Column="21" Grid.ColumnSpan="4" Content="Save to FM2014" TabIndex="106" Click="btnSaveRegulationSetup_Click" />
</Grid>
</TabItem>
@ -437,7 +437,7 @@
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label x:Name="lblRefPulsesMeasured" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,0,0,0" Grid.Row="1" Grid.Column="17" Grid.ColumnSpan="6" Content="Measured REF Pulses:" />
<CheckBox x:Name="chkDutPulsesMeasured" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="4,1,1,1" Grid.Row="2" Grid.Column="17" Grid.ColumnSpan="6" Content="Measured DUT Pulses:" TabIndex="121" Click="chkUseDampedTolerance_CheckedChanged" />
<CheckBox x:Name="chkDutPulsesMeasured" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="4,1,1,1" Grid.Row="2" Grid.Column="17" Grid.ColumnSpan="6" Content="Measured DUT Pulses:" TabIndex="121" Click="chkDutPulseMeasurement_CheckChanged" />
<Label x:Name="lblVolumeMeasuredLiters" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,0,0,0" Grid.Row="3" Grid.Column="17" Grid.ColumnSpan="6" Content="Measured Volume [liters]:" />
<Label x:Name="lblRefPulsesPerCmScale" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,0,0,0" Grid.Row="4" Grid.Column="17" Grid.ColumnSpan="6" Content="REF Pulse Ratio [pulses/m³]:" />
<TextBox x:Name="tbxRefPulsesMeasured" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="1,1,1,1" Grid.Row="1" Grid.Column="23" Grid.ColumnSpan="2" Text="500" MaxLines="1" HorizontalContentAlignment="Right" />

View File

@ -239,8 +239,8 @@ namespace Sensus.Ui.FM2014TestBench
MeasurementLabels.Add(lblMeasurement7Text);
// Preset attenuation
var attenuation = FM2014.ATTENUATION_MIN;
for (var idx = 0; idx < FM2014.ATTENUATION_MAX - FM2014.ATTENUATION_MIN; idx++)
var attenuation = FM2014.CURRENT_OUTPUT_ATTENUATION_MIN;
for (var idx = 0; idx < FM2014.CURRENT_OUTPUT_ATTENUATION_MAX - FM2014.CURRENT_OUTPUT_ATTENUATION_MIN; idx++)
{
cbxDisplayAttenuation.Items.Add(attenuation.ToString());
attenuation++;
@ -1000,15 +1000,15 @@ namespace Sensus.Ui.FM2014TestBench
UiElmEnable(tbxDutToRefTolMin, false);
UiElmEnable(tbxRefPulsesPerCm, false);
UiElmEnable(tbxDutPulsesPerCm, false);
UiElmEnable(tbxScaleRefToDut, false); // Additional scale is permanent read only
UiElmEnable(tbxScaleRefToDut, false); // Is permanent read only
UiElmEnable(cbxDisplayAttenuation, false);
UiElmEnable(cbxToleranceCalc, false);
UiElmEnable(cbxFM2014ComPort, false);
UiElmEnable(tbxRefPulsesMeasured, false); // Additional scale is permanent read only
UiElmEnable(tbxRefPulsesMeasured, false); // Is permanent read only
UiElmEnable(chkDutPulsesMeasured, false);
UiElmEnable(tbxDutPulsesMeasured, false); // Additional scale is permanent read only
UiElmEnable(tbxDutPulsesMeasured, false); // Is permanent read only
UiElmEnable(tbxVolumeMeasuredLiters, false);
UiElmEnable(tbxRefPulsesPerCmCalib, false); // Additional scale is permanent read only
UiElmEnable(tbxRefPulsesPerCmCalib, false); // Is permanent read only
foreach (var slotSelector in SlotSelections)
{
UiElmEnable(slotSelector, false);
@ -1022,7 +1022,7 @@ namespace Sensus.Ui.FM2014TestBench
{
// Enable buttons and display correct information
UiElmEnable(btnDutToRefCalibration, true);
UiElmEnable(btnSaveRegulationSetup, _regulationSetupHasChanged); // activate if setup has changed
UiElmEnable(btnSaveRegulationSetup, _regulationSetupHasChanged); // Activate if setup has changed
UiElmEnable(btnDutToRefRegulation, true);
UiElmEnable(btnFM2014Connect, true);
UiElmEnable(btnRefToVolumeCalibration, true);
@ -1032,9 +1032,12 @@ namespace Sensus.Ui.FM2014TestBench
UpdateContentControl(btnDutToRefCalibration, Properties.Resources.StrBtnStartCalibration);
UpdateContentControl(btnDutToRefRegulation, Properties.Resources.StrBtnStartRegulation);
var dutPulseMeasurementIsActive = false;
// Enable manual input
Dispatcher.Invoke(() =>
{
if (chkDutPulsesMeasured.IsChecked != null)
dutPulseMeasurementIsActive = (Boolean)chkDutPulsesMeasured.IsChecked;
tbxVolumeMeasuredLiters.IsReadOnly = false;
tbxRefPulsesPerCm.IsReadOnly = false;
tbxDutPulsesPerCm.IsReadOnly = false;
@ -1048,15 +1051,15 @@ namespace Sensus.Ui.FM2014TestBench
UiElmEnable(tbxDutToRefTolMin, true);
UiElmEnable(tbxRefPulsesPerCm, true);
UiElmEnable(tbxDutPulsesPerCm, true);
UiElmEnable(tbxScaleRefToDut, true); // Additional scale is permanent read only
UiElmEnable(tbxScaleRefToDut, true); // Is permanent read only
UiElmEnable(cbxDisplayAttenuation, true);
UiElmEnable(cbxToleranceCalc, true);
UiElmEnable(cbxFM2014ComPort, true);
UiElmEnable(tbxRefPulsesMeasured, true); // Additional scale is permanent read only
UiElmEnable(tbxRefPulsesMeasured, true); // Is permanent read only
UiElmEnable(chkDutPulsesMeasured, true);
UiElmEnable(tbxDutPulsesMeasured, true); // Additional scale is permanent read only
UiElmEnable(tbxDutPulsesMeasured, dutPulseMeasurementIsActive); // Is permanent read only
UiElmEnable(tbxVolumeMeasuredLiters, true);
UiElmEnable(tbxRefPulsesPerCmCalib, true); // Additional scale is permanent read only
UiElmEnable(tbxRefPulsesPerCmCalib, true); // Is permanent read only
foreach (var slotSelector in SlotSelections)
{
@ -1128,7 +1131,7 @@ namespace Sensus.Ui.FM2014TestBench
break;
case CmdName.CMD_REF_GET_PLS_CTR:
case CmdName.CMD_REF_GET_PLS_CTR_BU:
if (firstFm2014 != null && firstFm2014.Address == fm2014.Address )
if (firstFm2014 != null && firstFm2014.Address == fm2014.Address)
UpdateTextBox(tbxRefPulsesMeasured, $"{resp.IntValue:D}");
ucFm2014.SetValue(CTR_LBL_IDX_REF_PLS, $"{resp.IntValue:D}");
break;
@ -1408,8 +1411,8 @@ namespace Sensus.Ui.FM2014TestBench
}
if (byte.TryParse(cbxDisplayAttenuation.SelectedItem.ToString(), out var attenuation) &&
attenuation >= FM2014.ATTENUATION_MIN &&
attenuation <= FM2014.ATTENUATION_MAX)
attenuation >= FM2014.CURRENT_OUTPUT_ATTENUATION_MIN &&
attenuation <= FM2014.CURRENT_OUTPUT_ATTENUATION_MAX)
{
currentOutputAttenuation = attenuation;
}
@ -1423,7 +1426,7 @@ namespace Sensus.Ui.FM2014TestBench
ucFM2014.EnableMeasurements(REG_MEASURE_COUNT);
}
if (FM2014.RegulationMeasurement(refPulses_per_cm, dutPulses_per_cm, doublePulseDeadtime_ms,
if (FM2014.RegulationMeasurement(refPulses_per_cm, dutPulses_per_cm, doublePulseDeadtime_ms,
currentOutputAttenuation))
{
_autoProgressBar = true;
@ -1584,8 +1587,8 @@ namespace Sensus.Ui.FM2014TestBench
Dispatcher.Invoke(() =>
{
if (byte.TryParse(cbxDisplayAttenuation.SelectedItem.ToString(), out var attenuation) &&
attenuation >= FM2014.ATTENUATION_MIN &&
attenuation <= FM2014.ATTENUATION_MAX &&
attenuation >= FM2014.CURRENT_OUTPUT_ATTENUATION_MIN &&
attenuation <= FM2014.CURRENT_OUTPUT_ATTENUATION_MAX &&
firstFm2014.CurrentOutputAttenuation != attenuation)
{
_regulationSetupHasChanged = true;
@ -1656,6 +1659,21 @@ namespace Sensus.Ui.FM2014TestBench
}));
}
/// <summary>
/// Enable/Disable input
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void chkDutPulseMeasurement_CheckChanged(Object sender, EventArgs e)
{
Dispatcher.Invoke(() =>
{
var isChecked = false;
if (chkDutPulsesMeasured.IsChecked != null)
isChecked = (Boolean)chkDutPulsesMeasured.IsChecked;
UiElmEnable(tbxDutPulsesMeasured, isChecked);
});
}
/// <summary>
/// Common check for key input to edit an integer field:
/// - Allows Left, Right, Back, Delete and 0-9 keys . and ,
@ -2228,7 +2246,7 @@ namespace Sensus.Ui.FM2014TestBench
FM2014.PULSES_PER_CM_REGULATION_SETUP_MIN <= pulses_per_cm &&
FM2014.REF_PULSES_PER_CM_REGULATION_INPUT_MAX >= pulses_per_cm)
{
// During setup of the 'Ref_pulse_per_cm' the 'RefToDutScaleStr' will be generated
// During setup of the 'Ref_pulse_per_cm' the 'RefToDutScaleStr' will be generated
if (!UpdateRefToDutScale())
{
tbxRefPulsesPerCm.Background = ColorProcessFailed;

View File

@ -70,7 +70,7 @@ namespace Sensus.Ui.Fm2014TestBench.Properties {
}
/// <summary>
/// Looks up a localized string similar to Save.
/// Looks up a localized string similar to Save to FM2014.
/// </summary>
internal static string StrBtnSaveRegulationSetup {
get {

View File

@ -184,7 +184,7 @@
<value>Anzeigestabilisierung []:</value>
</data>
<data name="StrBtnSaveRegulationSetup" xml:space="preserve">
<value>Speichern</value>
<value>In FM2014 speichern</value>
</data>
<data name="StrGbxManualRefCalibration" xml:space="preserve">
<value>REF zu Volumen Kalibrierung</value>

View File

@ -184,7 +184,7 @@
<value>Display Attenuation []:</value>
</data>
<data name="StrBtnSaveRegulationSetup" xml:space="preserve">
<value>Save</value>
<value>Save to FM2014</value>
</data>
<data name="StrGbxManualRefCalibration" xml:space="preserve">
<value>REF to Volume Calibration</value>