CUST: - FwUpdateSw: - state machine adapted to communication error - unfinished

This commit is contained in:
Thomas Wiedebusch
2024-04-23 19:12:15 +02:00
parent b2c1dfb96e
commit 73f342f3cf
7 changed files with 65 additions and 45 deletions
@@ -1414,7 +1414,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
private void ReadMeterFirmwareAndAssignRegisters() private void ReadMeterFirmwareAndAssignRegisters()
{ {
// Avoid overwriting of list if this already exits // Avoid overwriting of list if this already exits
if (MeterAppListVersion.Any()) if (MeterAppListVersion.Any() && MeterAppListVersion.All(f => f.Status != MeterAppState.Unknown))
{ {
_logger.Warn($"Slot:{Slot} - Trying to override meter dictionary. Skip read out FW"); _logger.Warn($"Slot:{Slot} - Trying to override meter dictionary. Skip read out FW");
return; return;
@@ -1422,6 +1422,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
// On new readout reset the installed version // On new readout reset the installed version
InstalledFwVersion = 0; InstalledFwVersion = 0;
MeterAppListVersion.Clear();
//Get all existing applications from meter register dictionary //Get all existing applications from meter register dictionary
foreach (var meterApp in _configApplications.OrderBy(o => o.AppId)) foreach (var meterApp in _configApplications.OrderBy(o => o.AppId))
@@ -1 +1 @@
89102b0142e574de38a9f47d370f3334e5e6c268 8fbe991b217e7692af4817ad205b768685aa5a72
@@ -133,6 +133,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
private readonly DataGridViewCellStyle _styleValidated = new DataGridViewCellStyle(); private readonly DataGridViewCellStyle _styleValidated = new DataGridViewCellStyle();
private readonly DataGridViewCellStyle _styleVerificationRequired = new DataGridViewCellStyle(); private readonly DataGridViewCellStyle _styleVerificationRequired = new DataGridViewCellStyle();
private readonly DataGridViewCellStyle _styleEraseRequired = new DataGridViewCellStyle(); private readonly DataGridViewCellStyle _styleEraseRequired = new DataGridViewCellStyle();
private readonly DataGridViewCellStyle _styleCommunicationError = new DataGridViewCellStyle();
// update information // update information
private Boolean _binaryPackageLoaded; private Boolean _binaryPackageLoaded;
@@ -491,7 +492,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
case ProcessState.CheckFwUpdateSuccess: case ProcessState.CheckFwUpdateSuccess:
// If the update request returns false, the FW is up to date, // If the update request returns false, the FW is up to date,
// if true it needs an update (update did not succeed) release meter to normal operation // if true it needs an update (update did not succeed) release meter to normal operation to
// leave this to the user
CheckUpdateRequest(ProcessState.ReleaseMeterToNormalOperation, ProcessState.FwUpdateSuccess); CheckUpdateRequest(ProcessState.ReleaseMeterToNormalOperation, ProcessState.FwUpdateSuccess);
break; break;
@@ -880,6 +882,9 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
_styleDownloadFailed.BackColor = Color.LightPink; _styleDownloadFailed.BackColor = Color.LightPink;
_styleDownloadFailed.ForeColor = Color.Red; _styleDownloadFailed.ForeColor = Color.Red;
_styleCommunicationError.BackColor = Color.LightPink;
_styleCommunicationError.ForeColor = Color.Red;
_styleVerificationRequired.BackColor = Color.LightGoldenrodYellow; _styleVerificationRequired.BackColor = Color.LightGoldenrodYellow;
_styleVerificationRequired.ForeColor = Color.Green; _styleVerificationRequired.ForeColor = Color.Green;
@@ -1064,7 +1069,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
dataGridRow.DefaultCellStyle = _styleUpdateRequired; dataGridRow.DefaultCellStyle = _styleUpdateRequired;
break; break;
case MeterAppState.Unknown: case MeterAppState.Unknown:
dataGridRow.DefaultCellStyle = _styleDownloadFailed; dataGridRow.DefaultCellStyle = _styleCommunicationError;
break; break;
case MeterAppState.MeterAppNotInstalled: case MeterAppState.MeterAppNotInstalled:
dataGridRow.DefaultCellStyle = _styleNotInstalled; dataGridRow.DefaultCellStyle = _styleNotInstalled;
@@ -1252,9 +1257,6 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
/// - Exported CheckPackageFileAndFileApps to CheckUpdateRequest to separate capability check from /// - Exported CheckPackageFileAndFileApps to CheckUpdateRequest to separate capability check from
/// applications are up-to-date. /// applications are up-to-date.
/// </remarks> /// </remarks>
/// <remarks date="2024-Apr-23" author="Thomas Wiedebusch">
/// - Check for communication issues to avoid wrong information on installed apps.
/// </remarks>
private void CheckUpdateCapability(ProcessState successExitState, private void CheckUpdateCapability(ProcessState successExitState,
ProcessState errorExitState = ProcessState.Error) ProcessState errorExitState = ProcessState.Error)
{ {
@@ -1265,13 +1267,6 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
{ {
Thread.CurrentThread.CurrentUICulture = _cultureInfo; Thread.CurrentThread.CurrentUICulture = _cultureInfo;
Thread.CurrentThread.CurrentCulture = _cultureInfo; Thread.CurrentThread.CurrentCulture = _cultureInfo;
if (!AllAppsDetected())
{
_processState = errorExitState;
// overwrite the invoker state to create a message
_invokerProcessState = ProcessState.CheckCommunication;
return;
}
if (!CoreRevisionValid()) if (!CoreRevisionValid())
{ {
_processState = errorExitState; _processState = errorExitState;
@@ -1319,6 +1314,9 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
/// <remarks date="2020-Dec-21" author="Thomas Wiedebusch"> /// <remarks date="2020-Dec-21" author="Thomas Wiedebusch">
/// - Initial based on previous implementation of CheckUpdateEnabled(). /// - Initial based on previous implementation of CheckUpdateEnabled().
/// </remarks> /// </remarks>
/// <remarks date="2024-Apr-23" author="Thomas Wiedebusch">
/// - Check for communication issues to avoid wrong information on installed apps.
/// </remarks>
private void CheckUpdateRequest(ProcessState successExitState, ProcessState breakExitState, private void CheckUpdateRequest(ProcessState successExitState, ProcessState breakExitState,
ProcessState errorExitState = ProcessState.Error) ProcessState errorExitState = ProcessState.Error)
{ {
@@ -1331,26 +1329,46 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
{ {
Thread.CurrentThread.CurrentUICulture = _cultureInfo; Thread.CurrentThread.CurrentUICulture = _cultureInfo;
Thread.CurrentThread.CurrentCulture = _cultureInfo; Thread.CurrentThread.CurrentCulture = _cultureInfo;
if (!CheckPackageFileAndFileApps()) if (_invokerProcessState == ProcessState.CheckUpdateRequest)
{ {
_processState = errorExitState; if (!CheckPackageFileAndFileApps())
// overwrite the invoker state to create a message {
_invokerProcessState = ProcessState.CheckUpdateFiles; _processState = errorExitState;
return; // overwrite the invoker state to create a message
_invokerProcessState = ProcessState.CheckUpdateFiles;
return;
}
if (!AllAppsDetected())
{
_processState = errorExitState;
// overwrite the invoker state to create a message
_invokerProcessState = ProcessState.CheckCommunication;
return;
}
} }
FillDataGridWithAllInfos(); FillDataGridWithAllInfos();
// this check has been placed here to force display update
if (_currentGenesis.MeterAppListVersion.Any(f => f.Update) || var allAppsDetected = AllAppsDetected();
_currentGenesis.MeterAppListVersion.Any(f => f.Erase)) if (allAppsDetected &&
!_currentGenesis.MeterAppListVersion.Any(f => f.Update) &&
!_currentGenesis.MeterAppListVersion.Any(f => f.Erase))
{
// Nothing has to be updated, the latest FW is installed from program handler
// it stops operation with break for FW-Update
_processState = breakExitState;
}
else if (_currentGenesis.MeterAppListVersion.Any(f => f.Update) ||
_currentGenesis.MeterAppListVersion.Any(f => f.Erase))
{ {
// an update needs to be executed // an update needs to be executed
_processState = successExitState; _processState = successExitState;
} }
else else
{ {
// Nothing has to be updated, the latest FW is installed from program handler // Communication error and therefore unknown installation state
// it stops operation with break for FW-Update _processState = errorExitState;
_processState = breakExitState;
} }
})); }));
} }
@@ -1479,7 +1497,6 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
return true; return true;
InfoProcessFailed(lblCordonelUpdateCapability, Resources.StrCordonelCommunicationFailed); InfoProcessFailed(lblCordonelUpdateCapability, Resources.StrCordonelCommunicationFailed);
_processState = ProcessState.Error;
return false; return false;
} }
@@ -2885,14 +2902,9 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
break; break;
// This is the check sequence for update capability // This is the check sequence for update capability
case ProcessState.CheckUpdateCapability: case ProcessState.CheckUpdateRequest:
// This state will never return with error as the following "Check.." states will be forced msg = Resources.StrFirmwareUpdateFailed;
// by the individual update capability checks
break;
case ProcessState.CheckCommunication:
msg = Resources.StrCordonelCommunicationFailed;
ErrorProcessCommon(msg); ErrorProcessCommon(msg);
_processState = ProcessState.PrepareMeterRelease;
break; break;
case ProcessState.CheckCoreRevision: case ProcessState.CheckCoreRevision:
msg = Resources.StrCordonelUpdateCapabilityCoreFailed; msg = Resources.StrCordonelUpdateCapabilityCoreFailed;
@@ -2919,6 +2931,11 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
ErrorProcessCommon(msg); ErrorProcessCommon(msg);
_processState = ProcessState.PrepareMeterRelease; _processState = ProcessState.PrepareMeterRelease;
break; break;
case ProcessState.CheckCommunication:
msg = Resources.StrCordonelCommunicationFailed;
ErrorProcessCommon(msg);
_processState = ProcessState.PrepareMeterRelease;
break;
// This is the FW-Update process // This is the FW-Update process
case ProcessState.FirmwareUpdate: case ProcessState.FirmwareUpdate:
@@ -115,6 +115,15 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw.Properties {
} }
} }
/// <summary>
/// Looks up a localized string similar to ERROR: Communication problems!.
/// </summary>
internal static string StrCordonelCommunicationFailed {
get {
return ResourceManager.GetString("StrCordonelCommunicationFailed", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to ERROR: Cordonel detection failed. /// Looks up a localized string similar to ERROR: Cordonel detection failed.
/// </summary> /// </summary>
@@ -269,7 +278,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw.Properties {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to ERROR: Unknown data container received. /// Looks up a localized string similar to ERROR: Unknown data container received!.
/// </summary> /// </summary>
internal static string StrDataContainerUnknown { internal static string StrDataContainerUnknown {
get { get {
@@ -227,7 +227,7 @@
<value>Update capability.</value> <value>Update capability.</value>
</data> </data>
<data name="StrDataContainerUnknown" xml:space="preserve"> <data name="StrDataContainerUnknown" xml:space="preserve">
<value>ERROR: Unknown data container received</value> <value>ERROR: Unknown data container received!</value>
</data> </data>
<data name="StrFailedToUpdateApp" xml:space="preserve"> <data name="StrFailedToUpdateApp" xml:space="preserve">
<value>ERROR: Failed to update application:</value> <value>ERROR: Failed to update application:</value>
@@ -688,4 +688,7 @@
<data name="StrRegisterRecoveryWarning" xml:space="preserve"> <data name="StrRegisterRecoveryWarning" xml:space="preserve">
<value>WARNING: Configuration partially skipped!</value> <value>WARNING: Configuration partially skipped!</value>
</data> </data>
<data name="StrCordonelCommunicationFailed" xml:space="preserve">
<value>ERROR: Communication problems!</value>
</data>
</root> </root>
@@ -154,16 +154,6 @@
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput> <LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None> </None>
<Compile Include="Properties\Resources.de.Designer.cs">
<DependentUpon>Resources.de.resx</DependentUpon>
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
</Compile>
<Compile Include="Properties\Resources.de1.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.de.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Resources.Designer.cs"> <Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>