This commit is contained in:
Roland Drabesch
2023-12-11 13:26:42 +01:00
33 changed files with 17820 additions and 530 deletions
@@ -885,6 +885,9 @@ namespace Xylem.ServiceFwUpdate.Common.FwUpdateDb
/// <remarks date="2021-Mar-31" author="Thomas Wiedebusch">
/// - Initial.
/// </remarks>
/// <remarks date="2023-Nov-28" author="Thomas Wiedebusch">
/// - Sort list by customer order numbers.
/// </remarks>
public Boolean GetAllCordonelCustomerOrdersFromDb(Int64 customerNumber)
{
if (DbCordonelCustomerOrders == null)
@@ -905,6 +908,7 @@ namespace Xylem.ServiceFwUpdate.Common.FwUpdateDb
DbIsConnected = true;
DbCordonelCustomerOrders =
JsonConvert.DeserializeObject<List<CordonelCustomerOrderDb>>(requestResponse);
DbCordonelCustomerOrders?.Sort( (a, b) => a.CustomerOrderNumber.CompareTo(b.CustomerOrderNumber));
return DbCordonelCustomerOrders != null && DbCordonelCustomerOrders.Count != 0;
}
catch (Exception)
@@ -656,7 +656,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw.Properties {
}
/// <summary>
/// Looks up a localized string similar to Installed LUT is equal to required LUT..
/// Looks up a localized string similar to Installed LUT is equal to required..
/// </summary>
internal static string StrLutFileCompareSucceeded {
get {
@@ -701,7 +701,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw.Properties {
}
/// <summary>
/// Looks up a localized string similar to ERROR: LUT is not in FW updae safe!.
/// Looks up a localized string similar to ERROR: LUT is not in FW update safe!.
/// </summary>
internal static string StrLutFileNotDelivered {
get {
@@ -620,13 +620,13 @@
<value>ERROR: Installed LUT is unequal to required!</value>
</data>
<data name="StrLutFileCompareSucceeded" xml:space="preserve">
<value>Installed LUT is equal to required LUT.</value>
<value>Installed LUT is equal to required.</value>
</data>
<data name="StrLutFileFromSafeInvalid" xml:space="preserve">
<value>ERROR: LUT from FW update safe invalid!</value>
</data>
<data name="StrLutFileNotDelivered" xml:space="preserve">
<value>ERROR: LUT is not in FW updae safe!</value>
<value>ERROR: LUT is not in FW update safe!</value>
</data>
<data name="StrLutFileReadoutFailed" xml:space="preserve">
<value>ERROR: LUT readout failed!</value>
@@ -231,6 +231,7 @@ if $(ConfigurationName) == Release move "$(TargetDir)FwUpdateLoader.exe.manifest
if $(ConfigurationName) == Release move "$(TargetDir)NLogConfig.xml" "$(TargetDir)..\Config\"
if $(ConfigurationName) == Release erase "$(TargetDir)*.xml"
if $(ConfigurationName) == Release erase "$(TargetDir)*.pdb"
if $(ConfigurationName) == Release erase "$(TargetDir)*.json"
if $(ConfigurationName) == Release move "$(TargetDir)FwUpdateLoader.*" "$(TargetDir)..\"
if $(ConfigurationName) == Release erase "$(TargetDir)*.config"
@@ -323,6 +323,10 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
/// <remarks date="2023-Nov-22" author="Thomas Wiedebusch">
/// - Restore meter files and compare registers removed for this release.
/// </remarks>
/// <remarks date="2023-Nov-27" author="Thomas Wiedebusch">
/// - Compare registers reactivated based on new interface (configuration.json) with new
/// "StaticType": “approximate”.
/// </remarks>
private void FwUpdateSwStateMachine()
{
while (!_processToken.IsCancellationRequested)
@@ -457,8 +461,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
break;
case ProcessState.CompareRegisters:
//TODO THW ReadRegisters(GetNextProcessState(_processState, _stateSequencePrepareMeterRelease));
_processState = GetNextProcessState(_processState, _stateSequencePrepareMeterRelease);
ReadRegisters(GetNextProcessState(_processState, _stateSequencePrepareMeterRelease));
break;
case ProcessState.RestorePasswordFile:
@@ -2717,6 +2720,9 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
/// <remarks date="2023-Nov-15..16" author="Thomas Wiedebusch">
/// - Error state decides what to do next.
/// </remarks>
/// <remarks date="2023-Nov-29" author="Thomas Wiedebusch">
/// - If LUT restore generates an error all processes have to be stopped as the meter is NOT functional.
/// </remarks>
private void ErrorProcesses()
{
SetOverallProgressDisplayOff();
@@ -2770,9 +2776,11 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
_processState = GetNextProcessState(_invokerProcessState, _stateSequencePrepareMeterRelease);
break;
case ProcessState.RestoreLutFile:
msg = Resources.StrLutFileRestoreFailed;
//msg = Resources.StrLutFileRestoreFailed;
msg = Resources.StrLutFileCompareFailed;
ErrorProcessCommon(msg);
_processState = GetNextProcessState(_invokerProcessState, _stateSequencePrepareMeterRelease);
// If LUT file is invalid all processes have to be stopped as the meter is NOT functional.
_processState = ProcessState.Idle;
break;
case ProcessState.RecoverRegisters:
msg = Resources.StrRegisterRecoveryFailed;
@@ -4360,28 +4368,43 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
/// <remarks date="2023-Nov-22" author="Thomas Wiedebusch">
/// - Taking meter response of invalid LUT file indicated by 0x8000xxxx.
/// </remarks>
/// <remarks date="2023-Nov-27" author="Thomas Wiedebusch">
/// - Added check for string LutCrc is not null or empty.
/// </remarks>
/// <remarks date="2023-Nov-28" author="Thomas Wiedebusch">
/// - Use installed FW version to decide if LUT is required.
/// </remarks>
private void RestoreLutFile(ProcessState successExitState, ProcessState errorExitState = ProcessState.Error)
{
// Remind the invoker being able to generate error messages based on the last state
_invokerProcessState = _processState;
InfoProcessActive(lblLutFileCheck, Resources.StrLutFileRestoreActive, false);
// 1. LUT file is invalid indicated by CRC
if (_currentGenesis.LutCrc.Contains(MeterLutFile.StrLutFileInvalidCrc))
//1. If InstalledFwVersion is below 1.2.xxx a LUT file is NOT required
if (_currentGenesis.InstalledFwVersion < 1200)
{
InfoProcessSuccess(lblLutFileCheck, Resources.StrLutFileNotNeeded);
_processState = successExitState;
LogText(Resources.StrLutFileNotNeeded);
return;
}
// 2. LUT file is needed but invalid indicated by CRC or cannot be observed in file list
if ((!string.IsNullOrEmpty(_currentGenesis.LutCrc) && _currentGenesis.LutCrc.Contains(MeterLutFile.StrLutFileInvalidCrc))
|| (_readMeterFiles != null && !_readMeterFiles.Any(f => f.Contains(MeterLutFile.StrLutMeterFileName))))
{
InfoProcessFailed(lblLutFileCheck, Resources.StrLutFileNotInstalled);
_processState = errorExitState;
return;
}
// 2. LUT file NOT installed:
// 3. LUT file NOT installed:
// If meter LUT CRC is not set and the meter files do not report the LUT, the meter does not have an
// installed LUT
if ((string.IsNullOrEmpty(_currentGenesis.LutCrc) ||
_currentGenesis.LutCrc.Equals(Constants.StrUnknown)) &&
_readMeterFiles != null && !_readMeterFiles.Any(f => f.Contains(MeterLutFile.StrLutMeterFileName)))
{
// 2. a) LUT file not installed but required by the FW update safe:
// 3. a) LUT file not installed but required by the FW update safe:
// If the safe contains a LUT file, the installation of it has failed or it got lost during
// update
if (_fwUpdateSafeLutFile != null)
@@ -4391,7 +4414,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
return;
}
// 2. b) LUT file not installed and not delivered by the FW update safe
// 3. b) LUT file not installed and not delivered by the FW update safe
// This FW version does not require a LUT file
InfoProcessSuccess(lblLutFileCheck, Resources.StrLutFileNotNeeded);
_processState = successExitState;
@@ -4399,11 +4422,11 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
return;
}
// 3. LUT file is installed:
// 3.a) Lut file is installed but NOT in the safe:
// 4. LUT file is installed:
// 4.a) Lut file is installed but NOT in the safe:
// If the LUT is not in the safe it cannot be restored or compared to the required content but can
// be analyzed and logged
// 3.b) LUT file is installed and delivered by the FW update safe:
// 4.b) LUT file is installed and delivered by the FW update safe:
// On validated installed LUT file in meter this can be compared with the required LUT file
if (!ReadLogAndCompareMeterLutFile())
{
@@ -656,7 +656,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw.Properties {
}
/// <summary>
/// Looks up a localized string similar to Installed LUT is equal to required LUT..
/// Looks up a localized string similar to Installed LUT is equal to required..
/// </summary>
internal static string StrLutFileCompareSucceeded {
get {
@@ -701,7 +701,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw.Properties {
}
/// <summary>
/// Looks up a localized string similar to ERROR: LUT is not in FW updae safe!.
/// Looks up a localized string similar to ERROR: LUT is not in FW update safe!.
/// </summary>
internal static string StrLutFileNotDelivered {
get {
@@ -620,13 +620,13 @@
<value>ERROR: Installed LUT is unequal to required!</value>
</data>
<data name="StrLutFileCompareSucceeded" xml:space="preserve">
<value>Installed LUT is equal to required LUT.</value>
<value>Installed LUT is equal to required.</value>
</data>
<data name="StrLutFileFromSafeInvalid" xml:space="preserve">
<value>ERROR: LUT from FW update safe invalid!</value>
</data>
<data name="StrLutFileNotDelivered" xml:space="preserve">
<value>ERROR: LUT is not in FW updae safe!</value>
<value>ERROR: LUT is not in FW update safe!</value>
</data>
<data name="StrLutFileReadoutFailed" xml:space="preserve">
<value>ERROR: LUT readout failed!</value>