ProductionUiCordonel: - mover reset counters and setup clock to RebootCordonel

This commit is contained in:
Thomas Wiedebusch
2025-04-03 18:30:25 +02:00
parent bb83139a95
commit 4296920966
16 changed files with 115 additions and 83 deletions
@@ -52,6 +52,7 @@
<ItemGroup>
<SpecFlowFeatureFiles Update="Features\FinalParamSequence_Write_Store_Reboot_Verify.feature">
<Generator>SpecFlowSingleFileGenerator</Generator>
<LastGenOutput>FinalParamSequence_Write_Store_Reboot_Verify.feature.cs</LastGenOutput>
</SpecFlowFeatureFiles>
<SpecFlowFeatureFiles Update="Features\ProductionProcessCheckProductionState.feature">
<Generator>SpecFlowSingleFileGenerator</Generator>
@@ -646,9 +646,6 @@ namespace Xylem.Common.Production.ProductionUiCordonel.UnitTests.Steps
break;
case "ExecRebootCordonel":
registerName = "CUSTOMER_RebootCount";
var rebootCountBeforeReboot = RegisterConverter.ByteArrayToValue<UInt32>(
testCase.Meter.ReadRegister(registerName));
// Avoid reboot if failing is required
if (testCase.RequiredEOLProgress.RebootDoneChecked != EOLStatus.FAIL)
{
@@ -663,17 +660,6 @@ namespace Xylem.Common.Production.ProductionUiCordonel.UnitTests.Steps
testResult.StatusReturn = StatusReturn.Failed;
}
var rebootCountAfterReboot = RegisterConverter.ByteArrayToValue<UInt32>(
testCase.Meter.ReadRegister(registerName));
// The reboot counter will only be increased if reboot executed
if (rebootCountAfterReboot == rebootCountBeforeReboot)
{
testResult.StatusReturn = StatusReturn.Failed;
// Without reboot the RAM parameters are identical
paramsCheckWillSucceed = true;
}
if (string.IsNullOrEmpty(testResult.EOLProgress.ProductionStatusFwVersion))
testResult.EOLProgress.ProductionStatusFwVersion = testCase.Meter.FwVersion;
break;
@@ -417,33 +417,18 @@ namespace Xylem.Common.Production.ProductionUiCordonel
// Ready for shipping
if (e.State == ProcessState.ReadyForShipping)
{
// Update progress bars
ProcessProgress_Handler(this, new ProcessProgressArgs(0,
ProcessProgressArgs.ProcessProgressType.OverallProcessesSteps));
ProcessProgress_Handler(this, new ProcessProgressArgs(0,
ProcessProgressArgs.ProcessProgressType.ActualProcessSteps));
StoreSuccessNote(out _);
BtnStop_Click(this, null);
}
// Print return report
if (e.State == ProcessState.PrintReturnReport)
{
// Update progress bars
ProcessProgress_Handler(this, new ProcessProgressArgs(0,
ProcessProgressArgs.ProcessProgressType.OverallProcessesSteps));
ProcessProgress_Handler(this, new ProcessProgressArgs(0,
ProcessProgressArgs.ProcessProgressType.ActualProcessSteps));
PrintErrorNote();
BtnStop_Click(this, null);
}
// Print success report
if (e.State == ProcessState.PrintSuccessReport)
{
// Update progress bars
ProcessProgress_Handler(this, new ProcessProgressArgs(0,
ProcessProgressArgs.ProcessProgressType.OverallProcessesSteps));
ProcessProgress_Handler(this, new ProcessProgressArgs(0,
ProcessProgressArgs.ProcessProgressType.ActualProcessSteps));
PrintSuccessNote();
BtnStop_Click(this, null);
}
@@ -185,6 +185,15 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses
#endregion --------------------------------------- Init -------------------------------------------------------
#region ------------------------------------------ Tools ------------------------------------------------------
/// <summary>
/// Set overall process to 100 %
/// </summary>
protected void SetOverallProcessTo100Percent()
{
OnProcessProgressChanged?.Invoke(this, new ProcessProgressArgs(Int32.MaxValue,
ProcessProgressArgs.ProcessProgressType.OverallProcessesSteps));
}
/// <inheritdoc/>
public UserControl GetUserControl()
{
@@ -3,8 +3,8 @@ using System.Collections.Generic;
using LaaPackages.Features.Cordonel.Models;
using Xylem.Common.CommonCore.Consts;
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers.DataTypes;
using Xylem.Common.Logic.ProductionOrderCore;
//using Xylem.Common.Hardware.WaterMeter.Genesis.Registers.DataTypes;
//using Xylem.Common.Logic.ProductionOrderCore;
using Xylem.Common.Production.ProductionUiCordonel.Properties;
namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.EolProcesses
@@ -43,6 +43,9 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.EolPr
/// <remarks date="2025-Mar-31" author="Thomas Wiedebusch">
/// - Reset sensus radio and periodic log reset counters.
/// </remarks>
/// <remarks date="2025-Apr-03" author="Thomas Wiedebusch">
/// - Moved setting of time and reset counters from here to <see cref="ExecRebootCordonel"/>.
/// </remarks>
public override StatusReturn ExecuteProcess()
{
// Uncheck executed process to leave the result open needed for retries
@@ -73,37 +76,37 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.EolPr
}
}
// Get the time in UTC to program the time for the Cordonel in seconds since 01. Jan 2000
// to set the new UTC after reboot
var teaTime = new TimeT();
// Build byte array
var rawSeconds = RegisterConverter.ValueToByteArray(teaTime.UtcNowToSecondsSince2000);
var timerSetup = new ProgrammingParameters("SYSTEM_CalendarSeconds", rawSeconds,
ProgrammingSource.ProgramInternal);
// This is the manufacturing date of the Cordonel
var irdaMfgDate = new ProgrammingParameters("IRDA_MfgDate", rawSeconds,
ProgrammingSource.ProgramInternal);
// Reset reboot counter
var nullRebootCtr = new ProgrammingParameters("CUSTOMER_RebootCount", new Byte[] { 0x00 },
ProgrammingSource.ProgramInternal);
var retValBol = WriteRegisterLogAndProcessCtr(timerSetup);
retValBol &= WriteRegisterLogAndProcessCtr(irdaMfgDate);
retValBol &= WriteRegisterLogAndProcessCtr(nullRebootCtr);
if (Meter.RadioFrequencyMhz != null)
{
// Reset periodic log reset counter
var periodicLogResetCtr = new ProgrammingParameters("PERIODICLOG_ResetCounter", new Byte[] { 0x00 },
ProgrammingSource.ProgramInternal);
retValBol &= WriteRegisterLogAndProcessCtr(periodicLogResetCtr);
// Reset sensus radio reset counter
var sensusRadioResetCtr = new ProgrammingParameters("SENSUSRADIO_ResetCounter", new Byte[] { 0x00 },
ProgrammingSource.ProgramInternal);
retValBol &= WriteRegisterLogAndProcessCtr(sensusRadioResetCtr);
}
//// Get the time in UTC to program the time for the Cordonel in seconds since 01. Jan 2000
//// to set the new UTC after reboot
//var teaTime = new TimeT();
//// Build byte array
//var rawSeconds = RegisterConverter.ValueToByteArray(teaTime.UtcNowToSecondsSince2000);
//var timerSetup = new ProgrammingParameters("SYSTEM_CalendarSeconds", rawSeconds,
// ProgrammingSource.ProgramInternal);
//// This is the manufacturing date of the Cordonel
//var irdaMfgDate = new ProgrammingParameters("IRDA_MfgDate", rawSeconds,
// ProgrammingSource.ProgramInternal);
//// Reset reboot counter
//var nullRebootCtr = new ProgrammingParameters("CUSTOMER_RebootCount", new Byte[] { 0x00 },
// ProgrammingSource.ProgramInternal);
//var retValBol = WriteRegisterLogAndProcessCtr(timerSetup);
//retValBol &= WriteRegisterLogAndProcessCtr(irdaMfgDate);
//retValBol &= WriteRegisterLogAndProcessCtr(nullRebootCtr);
//if (Meter.RadioFrequencyMhz != null)
//{
// // Reset periodic log reset counter
// var periodicLogResetCtr = new ProgrammingParameters("PERIODICLOG_ResetCounter", new Byte[] { 0x00 },
// ProgrammingSource.ProgramInternal);
// retValBol &= WriteRegisterLogAndProcessCtr(periodicLogResetCtr);
// // Reset sensus radio reset counter
// var sensusRadioResetCtr = new ProgrammingParameters("SENSUSRADIO_ResetCounter", new Byte[] { 0x00 },
// ProgrammingSource.ProgramInternal);
// retValBol &= WriteRegisterLogAndProcessCtr(sensusRadioResetCtr);
//}
// Execute final read after reboot
RegisterRestorer.OnProcessUpdate += ProcessUpdate_Handler;
retValBol &= RegisterRestorer.FinalReadRegisters();
var retValBol = RegisterRestorer.FinalReadRegisters();
retValBol &= RegisterRestorer.CompareRegisters();
RegisterRestorer.OnProcessUpdate -= ProcessUpdate_Handler;
@@ -125,10 +125,10 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.EolPr
{
Retry();
};
_checkRadioUserControl.OnDoneRequested += delegate
{
SaveRssiLevelsToDb();
};
//_checkRadioUserControl.OnDoneRequested += delegate
//{
// SaveRssiLevelsToDb();
//};
}
/// <summary>
@@ -436,7 +436,7 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.EolPr
/// </remarks>
private void DisableAllButtons()
{
EnableBtn(_checkRadioUserControl.btnSkip, false);
//EnableBtn(_checkRadioUserControl.btnSkip, false);
EnableBtn(_checkRadioUserControl.btnRetry, false);
}
@@ -726,7 +726,7 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.EolPr
{
_dataContainer.Result = 0;
// done can finish the test which is equal to abort on error
EnableBtn(_checkRadioUserControl.btnSkip, true);
//EnableBtn(_checkRadioUserControl.btnSkip, true);
// reset can repeat the test as often as wanted
EnableBtn(_checkRadioUserControl.btnRetry, true);
_successSignalLevel = false;
@@ -2,6 +2,9 @@
using LaaPackages.Features.Cordonel.Models;
using Xylem.Common.CommonCore.Consts;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile;
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers.DataTypes;
using Xylem.Common.Logic.ProductionOrderCore;
using Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.Enum;
using Xylem.Common.Production.ProductionUiCordonel.Properties;
@@ -36,6 +39,9 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.EolPr
/// <remarks date="2024-Sep-05" author="Thomas Wiedebusch">
/// - EOL progress signaled.
/// </remarks>
/// <remarks date="2025-Apr-03" author="Thomas Wiedebusch">
/// - Moved setting of time and reset counters from <see cref="CheckFinalParametrization"/> to here.
/// </remarks>
public override StatusReturn ExecuteProcess()
{
// Uncheck executed process to leave the result open needed for retries
@@ -73,15 +79,60 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.EolPr
var rebootSucceeded = _meterResetPsu.MeterResetPsuExecute();
_meterResetPsu.OnProcessUpdate -= ProcessUpdate_Handler;
if (rebootSucceeded)
if (!rebootSucceeded)
{
EolProgress.RebootDoneChecked = EOLStatus.OK;
return StatusReturn.Okay;
EolProgress.RebootDoneChecked = EOLStatus.FAIL;
return StatusReturn.Failed;
}
EolProgress.RebootDoneChecked = EOLStatus.FAIL;
return StatusReturn.Failed;
// access to meter requires login
if (!Meter.IsLoggedOn)
{
Meter.Login();
if (!Meter.IsLoggedOn)
{
ErrorMsgDispatcher(Resources.StrErrorMsgCordonelLogin);
EolProgress.RebootDoneChecked = EOLStatus.FAIL;
return StatusReturn.Failed;
}
}
// Get the time in UTC to program the time for the Cordonel in seconds since 01. Jan 2000
// to set the new UTC after reboot
var teaTime = new TimeT();
// Build byte array
var rawSeconds = RegisterConverter.ValueToByteArray(teaTime.UtcNowToSecondsSince2000);
var timerSetup = new ProgrammingParameters("SYSTEM_CalendarSeconds", rawSeconds,
ProgrammingSource.ProgramInternal);
// This is the manufacturing date of the Cordonel
var irdaMfgDate = new ProgrammingParameters("IRDA_MfgDate", rawSeconds,
ProgrammingSource.ProgramInternal);
// Reset reboot counter
var nullRebootCtr = new ProgrammingParameters("CUSTOMER_RebootCount", new Byte[] { 0x00 },
ProgrammingSource.ProgramInternal);
var retValBol = WriteRegisterLogAndProcessCtr(timerSetup);
retValBol &= WriteRegisterLogAndProcessCtr(irdaMfgDate);
retValBol &= WriteRegisterLogAndProcessCtr(nullRebootCtr);
if (Meter.RadioFrequencyMhz != null)
{
// Reset periodic log reset counter
var periodicLogResetCtr = new ProgrammingParameters("PERIODICLOG_ResetCounter", new Byte[] { 0x00 },
ProgrammingSource.ProgramInternal);
retValBol &= WriteRegisterLogAndProcessCtr(periodicLogResetCtr);
// Reset sensus radio reset counter
var sensusRadioResetCtr = new ProgrammingParameters("SENSUSRADIO_ResetCounter", new Byte[] { 0x00 },
ProgrammingSource.ProgramInternal);
retValBol &= WriteRegisterLogAndProcessCtr(sensusRadioResetCtr);
}
if (!retValBol)
{
EolProgress.RebootDoneChecked = EOLStatus.FAIL;
return StatusReturn.Failed;
}
EolProgress.RebootDoneChecked = EOLStatus.OK;
return StatusReturn.Okay;
}
catch (Exception ex)
{
@@ -144,11 +144,13 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.EolPr
ucDialog.SetDialogOptions(OptionList);
ActualProcessProgress = MaxActualProgressSteps;
SetOverallProcessTo100Percent();
while (_waitOnUserFeedback && SingleProcessState != SingleProcessState.Idle)
{
}
ActualProcessProgress = MaxActualProgressSteps;
// Always use okay to kick off ForcedSuccessExitState
return StatusReturn.Okay;
}
@@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Height="400" Width="250" Closing="Window_Closing" ResizeMode="NoResize" WindowStyle="SingleBorderWindow"
WindowStartupLocation="CenterScreen">
WindowStartupLocation="CenterScreen" Topmost="True">
<Grid Name="dgWinFormsHost" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
</Grid>
</Window>
@@ -35,7 +35,7 @@
<Label Name="lblRssiPamSirtDbMax" Content="-" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="2" Grid.Column="3"/>
<Label Name="lblRssiSemiCordonelDbMax" Content="-" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="3" Grid.Column="3"/>
<Button Name="btnSkip" Content="Skip" Height="52" Width="96" Grid.Row="4" Grid.Column="0" Click="BtnSkip_Click" IsEnabled="False" />
<Button Name="btnRetry" Content="Retry" Height="52" Width="96" Grid.Row="4" Grid.Column="2" Grid.ColumnSpan="2" Click="btnReset_Click" IsEnabled="False" />
<!--Button Name="btnSkip" Content="Skip" Height="52" Width="96" Grid.Row="4" Grid.Column="0" Click="BtnSkip_Click" IsEnabled="False" /-->
<Button Name="btnRetry" Content="Retry" Height="52" Width="96" Grid.Row="4" Grid.Column="0" Click="btnReset_Click" IsEnabled="False" />
</Grid>
</UserControl>
@@ -123,7 +123,7 @@ namespace Xylem.Common.Production.ProductionUiCordonel.UserControls.FinalTest
{
InitializeComponent();
lblHeadLine.Content = Properties.Resources.StrLblRadioCheck;
btnSkip.Content = Properties.Resources.StrBtnSkip;
//btnSkip.Content = Properties.Resources.StrBtnSkip;
btnRetry.Content = Properties.Resources.StrBtnRetry;
}