From d7bcdc22a510ca5333094dad63a5167fd6cf329e Mon Sep 17 00:00:00 2001 From: Thomas Wiedebusch Date: Tue, 24 Oct 2023 22:24:00 +0200 Subject: [PATCH] CUST: - State machine restructured --- .../Properties/AssemblyInfo.cs | 2 +- .../Properties/AssemblyInfo.cs | 2 +- .../ServiceFwUpdateSw/FrmServiceFwUpdateSw.cs | 57 +++++++++++-------- .../Properties/AssemblyInfo.cs | 2 +- .../ServiceFwUpdateSw.csproj | 4 ++ 5 files changed, 40 insertions(+), 27 deletions(-) diff --git a/ServiceFwUpdate/Ui/ServiceFwUpdateBuilder/Properties/AssemblyInfo.cs b/ServiceFwUpdate/Ui/ServiceFwUpdateBuilder/Properties/AssemblyInfo.cs index 1d419321..94346a4d 100644 --- a/ServiceFwUpdate/Ui/ServiceFwUpdateBuilder/Properties/AssemblyInfo.cs +++ b/ServiceFwUpdate/Ui/ServiceFwUpdateBuilder/Properties/AssemblyInfo.cs @@ -9,7 +9,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Sensus")] [assembly: AssemblyProduct("Cordonel Service FW Update Builder")] -[assembly: AssemblyCopyright("Copyright © Xylem 2020..2022")] +[assembly: AssemblyCopyright("Copyright © Xylem 2020..2023")] [assembly: AssemblyTrademark("Cordonel")] [assembly: AssemblyCulture("")] diff --git a/ServiceFwUpdate/Ui/ServiceFwUpdateLoader/Properties/AssemblyInfo.cs b/ServiceFwUpdate/Ui/ServiceFwUpdateLoader/Properties/AssemblyInfo.cs index 270975f5..9b50cb5e 100644 --- a/ServiceFwUpdate/Ui/ServiceFwUpdateLoader/Properties/AssemblyInfo.cs +++ b/ServiceFwUpdate/Ui/ServiceFwUpdateLoader/Properties/AssemblyInfo.cs @@ -9,7 +9,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Sensus")] [assembly: AssemblyProduct("Cordonel Service FW Update Loader")] -[assembly: AssemblyCopyright("Copyright © Xylem 2020..2022")] +[assembly: AssemblyCopyright("Copyright © Xylem 2020..2023")] [assembly: AssemblyTrademark("Cordonel")] [assembly: AssemblyCulture("")] diff --git a/ServiceFwUpdate/Ui/ServiceFwUpdateSw/FrmServiceFwUpdateSw.cs b/ServiceFwUpdate/Ui/ServiceFwUpdateSw/FrmServiceFwUpdateSw.cs index c9feb21d..f9706548 100644 --- a/ServiceFwUpdate/Ui/ServiceFwUpdateSw/FrmServiceFwUpdateSw.cs +++ b/ServiceFwUpdate/Ui/ServiceFwUpdateSw/FrmServiceFwUpdateSw.cs @@ -249,7 +249,6 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw /// /// /// - Reorganized to support maintenance before the FW update capability check, - /// - /// private void FwUpdateSwStateMachine() { @@ -326,9 +325,18 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw break; case ProcessState.CheckUpdateCapability: - CheckUpdateCapability(ProcessState.CheckUpdateRequest); + CheckUpdateCapability(ProcessState.Idle); break; + case ProcessState.ReadInfoEraseRestoreFiles: + PrepareInfoMeterFilesEraseRestore(ProcessState.EraseMeterFiles); + break; + + case ProcessState.EraseMeterFiles: + // even if the erasure failed it should be continued + MeterFilesErase(ProcessState.FirmwareUpdate, ProcessState.FirmwareUpdate); + break; + case ProcessState.FirmwareUpdate: FwUpdate(ProcessState.Reboot); break; @@ -339,21 +347,10 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw case ProcessState.FinalConnect: DisposeGenesis(); - Connect(ProcessState.LoadUpdateFiles); - break; - - case ProcessState.ReadInfoEraseRestoreFiles: - PrepareInfoMeterFilesEraseRestore(ProcessState.LoadUpdateFiles, ProcessState.LoadUpdateFiles); - break; - - case ProcessState.EraseMeterFiles: - // even if the erasure failed it should be continued - MeterFilesErase(ProcessState.PreUpdateReadMeterFiles, ProcessState.PreUpdateReadMeterFiles); - break; - - case ProcessState.PreUpdateReadMeterFiles: - // even if the pre update read failed it should be continued - ReadMeterFiles(ProcessState.FirmwareUpdate, ProcessState.FirmwareUpdate); + // remind, that the final login with the Level 8 password has to be forced to validate + // the password file + _finalLoginAfterUpdate = true; + Connect(ProcessState.PostUpdateReadMeterFiles); break; case ProcessState.PostUpdateReadMeterFiles: @@ -1518,6 +1515,9 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw /// /// - Initial /// + /// + /// - Start of update procedure changed to read files to erase and restore. + /// private void BtnUpdateFw_Click(Object sender, EventArgs e) { if (_currentGenesis == null || _meterFwUpdate?.FileApps == null || @@ -1526,7 +1526,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw _startTime = DateTimeOffset.UtcNow; _resetTimeMeasurement = false; - _processState = ProcessState.InitialReadRegisters; + _processState = ProcessState.ReadInfoEraseRestoreFiles; } /// @@ -1870,6 +1870,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw ? Resources.StrReleaseDisplaySucceeded : Resources.StrReleaseDisplayFailed); + // safe all settings for GENESISFLOW application _currentGenesis.WriteRegister(Register.Genesisflow.StoreConfiguration, 1); _currentGenesis.Logout(); } @@ -1884,6 +1885,9 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw /// /// - Output message changed to get colored error or success messages. /// + /// + /// - LogErrorText. + /// private void LogStringList(String strHeader, IEnumerable strings, String successMessage = null, String errorMessage = null) { @@ -1896,7 +1900,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw if (!string.IsNullOrEmpty(successMessage)) LogSuccessText(successMessage); if (!string.IsNullOrEmpty(errorMessage)) - LogSuccessText(errorMessage); + LogErrorText(errorMessage); LogText(StrSeparator); } @@ -2990,6 +2994,9 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw /// /// - Restructured. /// + /// + /// - Avoid report file generation on finalLoginAfterUpdate. + /// private Boolean ExecConnect() { // If the PCB ID is not set (read from meter) this is the first initial login. @@ -2998,7 +3005,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw // Read out the PCB ID from water-meter needed to open the password container of this device _currentGenesis.GetPcbId(); // Create report file - BuildReportFiles(); + if (!_finalLoginAfterUpdate) + BuildReportFiles(); } // Search the PCB ID and extract password for login @@ -3716,14 +3724,14 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw /// /// - Hashed password file read on connect from FW update safe. /// + /// + /// - Read and log password file after restoring. + /// private void RestorePasswordFile(ProcessState successExitState, ProcessState errorExitState = ProcessState.Error) { // remind the invoker being able to generate error messages based on the last state _invokerProcessState = _processState; - // remind, that the final login with the Level 8 password has to be forced to validate the password file - _finalLoginAfterUpdate = true; - // if the password file is valid exit if (!_passwordFileIsCorrupted) { @@ -3744,7 +3752,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw _currentGenesis?.ReLogin(); if (pwdFileObject.UnlockEraseWriteMeterPwdFile()) { - if (pwdFileObject.WriteAndVerifyMeterPwdFile(_hashedPwdFile)) + if (pwdFileObject.WriteAndVerifyMeterPwdFile(_hashedPwdFile) && + ReadLogAndCompareMeterPwdFile()) { // a reconnect will check for proper installed password file and check the Level 8 pwd. _processState = ProcessState.FinalConnect; diff --git a/ServiceFwUpdate/Ui/ServiceFwUpdateSw/Properties/AssemblyInfo.cs b/ServiceFwUpdate/Ui/ServiceFwUpdateSw/Properties/AssemblyInfo.cs index 73947602..970c3938 100644 --- a/ServiceFwUpdate/Ui/ServiceFwUpdateSw/Properties/AssemblyInfo.cs +++ b/ServiceFwUpdate/Ui/ServiceFwUpdateSw/Properties/AssemblyInfo.cs @@ -9,7 +9,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Sensus")] [assembly: AssemblyProduct("Cordonel Service FW Update SW")] -[assembly: AssemblyCopyright("Copyright © Xylem 2020..2022")] +[assembly: AssemblyCopyright("Copyright © Xylem 2020..2023")] [assembly: AssemblyTrademark("Cordonel")] [assembly: AssemblyCulture("")] diff --git a/ServiceFwUpdate/Ui/ServiceFwUpdateSw/ServiceFwUpdateSw.csproj b/ServiceFwUpdate/Ui/ServiceFwUpdateSw/ServiceFwUpdateSw.csproj index 6645f715..3ab2e716 100644 --- a/ServiceFwUpdate/Ui/ServiceFwUpdateSw/ServiceFwUpdateSw.csproj +++ b/ServiceFwUpdate/Ui/ServiceFwUpdateSw/ServiceFwUpdateSw.csproj @@ -309,4 +309,8 @@ + + if $(ConfigurationName) == Release erase "$(TargetDir)*.pdb" + + \ No newline at end of file