CUST: - State machine restructured

This commit is contained in:
Thomas Wiedebusch 2023-10-24 22:24:00 +02:00
parent 6417adc86d
commit d7bcdc22a5
5 changed files with 40 additions and 27 deletions

View File

@ -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("")]

View File

@ -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("")]

View File

@ -249,7 +249,6 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
/// </remarks>
/// <remarks date="2023-Oct-18" author="Thomas Wiedebusch">
/// - Reorganized to support maintenance before the FW update capability check,
/// -
/// </remarks>
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
/// <remarks date="2020-Nov-27" author="Thomas Wiedebusch">
/// - Initial
/// </remarks>
/// <remarks date="2023-Oct-24" author="Thomas Wiedebusch">
/// - Start of update procedure changed to read files to erase and restore.
/// </remarks>
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;
}
/// <summary>
@ -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
/// <remarks date="2023-Oct-19" author="Thomas Wiedebusch">
/// - Output message changed to get colored error or success messages.
/// </remarks>
/// <remarks date="2023-Oct-24" author="Thomas Wiedebusch">
/// - LogErrorText.
/// </remarks>
private void LogStringList(String strHeader, IEnumerable<String> 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
/// <remarks date="2023-Oct-18" author="Thomas Wiedebusch">
/// - Restructured.
/// </remarks>
/// <remarks date="2023-Oct-18" author="Thomas Wiedebusch">
/// - Avoid report file generation on finalLoginAfterUpdate.
/// </remarks>
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
/// <remarks date="2023-Oct-11" author="Thomas Wiedebusch">
/// - Hashed password file read on connect from FW update safe.
/// </remarks>
/// <remarks date="2023-Oct-24" author="Thomas Wiedebusch">
/// - Read and log password file after restoring.
/// </remarks>
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;

View File

@ -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("")]

View File

@ -309,4 +309,8 @@
<Import Project="..\..\..\Common\Utils\UiInvokerShared\UiInvokerShared.projitems" Label="Shared" />
<Import Project="..\..\..\Common\Utils\UiLanguageControlShared\UiLanguageControlShared.projitems" Label="Shared" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>if $(ConfigurationName) == Release erase "$(TargetDir)*.pdb"
</PostBuildEvent>
</PropertyGroup>
</Project>