merged from Dev_Shipping
RegisterRestorer: - check for ranges,
This commit is contained in:
@@ -109,12 +109,14 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
||||
|
||||
// status information
|
||||
private static readonly Color ColorDefault = Color.Black;
|
||||
private static readonly Color ColorWarning = Color.DarkOrange;
|
||||
private static readonly Color ColorSuccess = Color.Green;
|
||||
private static readonly Color ColorProcessFailed = Color.Red;
|
||||
private static readonly Color ColorOngoingProcess = Color.Blue;
|
||||
private static readonly Color ColorUnknownStatus = Color.Gray;
|
||||
private const String SuccessSign = @"✔";
|
||||
private const String FailedSign = @"✘";
|
||||
private const String WarningSign = @"?";
|
||||
|
||||
private const String StrSeparator = "-----------------------------------------------------" +
|
||||
"-----------------------------------------------------" +
|
||||
@@ -2371,6 +2373,17 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
||||
LogText(StrSeparator);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Output exclusively to user update remarks text window.
|
||||
/// </summary>
|
||||
private void LogWarningText(String txtHistory)
|
||||
{
|
||||
InfoWindowColoredText(txtHistory, ColorWarning);
|
||||
_logger.Info(txtHistory);
|
||||
ReportText(txtHistory);
|
||||
LogText(StrSeparator);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Output exclusively to user update remarks text window.
|
||||
/// </summary>
|
||||
@@ -2472,6 +2485,19 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
||||
UiInvoker.ControlInvoker(label, ColorSuccess, $@"{SuccessSign} {msg}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Success information to label, user text box and logger.
|
||||
/// </summary>
|
||||
private void InfoProcessWarning(Control label, String msg, Boolean log = true)
|
||||
{
|
||||
if (log)
|
||||
{
|
||||
LogWarningText(msg);
|
||||
}
|
||||
|
||||
UiInvoker.ControlInvoker(label, ColorWarning, $@"{WarningSign} {msg}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Failed information to label, user text box and logger.
|
||||
/// </summary>
|
||||
@@ -3112,7 +3138,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
||||
/// <remarks date="2020-Dec-17" author="Thomas Wiedebusch">
|
||||
/// - Timer interval expired introduced.
|
||||
/// </remarks>
|
||||
private Boolean ExecReboot()
|
||||
private StatusReturn ExecReboot()
|
||||
{
|
||||
String text = null;
|
||||
// var timerInterval = _tmrProgressUpdate.Interval;
|
||||
@@ -3137,7 +3163,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
||||
_bootDelayCtr_ms += timerInterval;
|
||||
}
|
||||
|
||||
return !string.IsNullOrEmpty(text);
|
||||
return string.IsNullOrEmpty(text) ? StatusReturn.Failed : StatusReturn.Okay;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -3164,7 +3190,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
||||
/// <remarks date="2024-Feb-12" author="Thomas Wiedebusch">
|
||||
/// - Request new pcbId as the auto-detected may be corrupt.
|
||||
/// </remarks>
|
||||
private void FinalizeReboot(Boolean success, IReadOnlyList<Object> exitProcessStateObjects)
|
||||
private void FinalizeReboot(StatusReturn success, IReadOnlyList<Object> exitProcessStateObjects)
|
||||
{
|
||||
ObjectsToProcessStates(exitProcessStateObjects, out var successExitState, out var errorExitState,
|
||||
out _);
|
||||
@@ -3246,10 +3272,10 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
||||
/// <remarks date="2020-Dec-09" author="Thomas Wiedebusch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
private Boolean ExecPortScanner()
|
||||
private StatusReturn ExecPortScanner()
|
||||
{
|
||||
_serialPortScanner.ScanAllSerialPorts(Slot, _basePath?.PortConfigFilePathName);
|
||||
return _serialPortScanner.AutoDetectedPortName != null;
|
||||
return _serialPortScanner.AutoDetectedPortName == null ? StatusReturn.Failed : StatusReturn.Okay;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -3283,7 +3309,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
||||
/// <remarks date="2021-Mai-11" author="Thomas Wiedebusch">
|
||||
/// - Delay after port scan to free serial port for new assignment.
|
||||
/// </remarks>
|
||||
private void FinalizePortScanner(Boolean success, IReadOnlyList<Object> exitProcessStateObjects)
|
||||
private void FinalizePortScanner(StatusReturn success, IReadOnlyList<Object> exitProcessStateObjects)
|
||||
{
|
||||
if (_serialPortScanner != null)
|
||||
_serialPortScanner.OnProcessUpdate -= ProcessUpdate_Event;
|
||||
@@ -3298,7 +3324,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
||||
return;
|
||||
}
|
||||
|
||||
if (!success)
|
||||
if (success != StatusReturn.Okay)
|
||||
{
|
||||
// If the IrDA port scan failed, it makes no sense to signal Cordonel Detection failed!
|
||||
InfoProcessFailed(null, Resources.StrRequestPortFailed);
|
||||
@@ -3483,7 +3509,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
||||
/// <remarks date="2023-Nov-22" author="Thomas Wiedebusch">
|
||||
/// - Added password valid information main screen and log file.
|
||||
/// </remarks>
|
||||
private Boolean ExecConnect()
|
||||
private StatusReturn ExecConnect()
|
||||
{
|
||||
// If the PCB ID is not set (read from meter) this is the first initial login.
|
||||
if (string.IsNullOrEmpty(_currentGenesis.PcbId))
|
||||
@@ -3524,7 +3550,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
||||
if (_passwordLvl8 == null || _skeletonKey == null)
|
||||
{
|
||||
_processState = ProcessState.Error;
|
||||
return false;
|
||||
return StatusReturn.Failed;
|
||||
}
|
||||
|
||||
// This login may be time consuming on readout of application information
|
||||
@@ -3536,7 +3562,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
||||
LogText(Resources.StrLoginPwdLevel8);
|
||||
InfoProcessSuccess(lblPasswordFileCheck, Resources.StrPasswordFileValid);
|
||||
_passwordFileIsCorrupted = false;
|
||||
return true;
|
||||
return StatusReturn.Okay;
|
||||
}
|
||||
|
||||
// Delay needed if repeated login trial given by Cordonel, the next communication has to
|
||||
@@ -3550,11 +3576,11 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
||||
// Reset login delay as on successfully login the meter resets the retry-lock-in-delay
|
||||
_loginDelay_ms = DefaultLoginDelay_ms;
|
||||
LogText(Resources.StrLoginSkeletonKey);
|
||||
return true;
|
||||
return StatusReturn.Okay;
|
||||
}
|
||||
|
||||
_processState = ProcessState.Error;
|
||||
return false;
|
||||
return StatusReturn.Failed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -3720,7 +3746,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
||||
/// <remarks date="2023-Nov-22" author="Thomas Wiedebusch">
|
||||
/// - Final login is not a grant for valid password file anymore.
|
||||
/// </remarks>
|
||||
private void FinalizeConnect(Boolean success, IReadOnlyList<Object> exitProcessStateObjects)
|
||||
private void FinalizeConnect(StatusReturn success, IReadOnlyList<Object> exitProcessStateObjects)
|
||||
{
|
||||
ObjectsToProcessStates(exitProcessStateObjects, out var successExitState, out var errorExitState,
|
||||
out var breakExitState);
|
||||
@@ -3732,7 +3758,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
||||
return;
|
||||
}
|
||||
|
||||
if (!success)
|
||||
if (success != StatusReturn.Okay)
|
||||
{
|
||||
InfoProcessFailed(lblCordonelAuthentication, !_genesisInUpdateList
|
||||
? $"{_currentGenesis.PcbId} {Resources.StrCordonelNotInUpdateList}"
|
||||
@@ -3836,7 +3862,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
||||
/// <remarks date="2023-Nov-21" author="Thomas Wiedebusch">
|
||||
/// - Skip final read and compare if not updated or no recovery request.
|
||||
/// </remarks>
|
||||
private Boolean ExecReadRegister()
|
||||
private StatusReturn ExecReadRegister()
|
||||
{
|
||||
Boolean retVal;
|
||||
switch (_invokerProcessState)
|
||||
@@ -3871,7 +3897,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
||||
retVal = _registerRestorer.ReadRegisters();
|
||||
break;
|
||||
}
|
||||
return retVal;
|
||||
return retVal ? StatusReturn.Okay : StatusReturn.Failed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -3898,7 +3924,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
||||
/// <remarks date="2023-Nov-21" author="Thomas Wiedebusch">
|
||||
/// - Context depending message.
|
||||
/// </remarks>
|
||||
private void FinalReadRegisters(Boolean success, IReadOnlyList<Object> exitProcessStateObjects)
|
||||
private void FinalReadRegisters(StatusReturn success, IReadOnlyList<Object> exitProcessStateObjects)
|
||||
{
|
||||
if (_registerRestorer != null)
|
||||
_registerRestorer.OnProcessUpdate -= ProcessUpdate_Event;
|
||||
@@ -3915,7 +3941,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
||||
}
|
||||
|
||||
String msg;
|
||||
if (success)
|
||||
if (success == StatusReturn.Okay)
|
||||
{
|
||||
switch (_invokerProcessState)
|
||||
{
|
||||
@@ -4525,9 +4551,9 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
||||
/// <remarks date="2023-Oct-26" author="Thomas Wiedebusch">
|
||||
/// - Removed redundant marker for recovery required.
|
||||
/// </remarks>
|
||||
private Boolean ExecRegisterRecovery()
|
||||
private StatusReturn ExecRegisterRecovery()
|
||||
{
|
||||
var success = true;
|
||||
var retVal = StatusReturn.Okay;
|
||||
_recoveryRegistersRequired = false;
|
||||
if (_cordonelDeviceInfos != null)
|
||||
{
|
||||
@@ -4535,17 +4561,17 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
||||
{
|
||||
// If recovery registers not defined, skip this step with success
|
||||
if (device.RecoveryRegisters == null || device.RecoveryRegisters.Count == 0)
|
||||
return true;
|
||||
return StatusReturn.Okay;
|
||||
|
||||
success &= _registerRestorer.WriteRegisters(device.RecoveryRegisters);
|
||||
retVal = _registerRestorer.WriteRegisters(device.RecoveryRegisters);
|
||||
break;
|
||||
}
|
||||
|
||||
_recoveryRegistersRequired = true;
|
||||
Thread.Sleep(1000);
|
||||
StoreConfigurations();
|
||||
if (!StoreConfigurations()) retVal =StatusReturn.Failed;
|
||||
}
|
||||
return success;
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -4569,7 +4595,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
||||
/// <remarks date="2021-Apr-07" author="Thomas Wiedebusch">
|
||||
/// - Change the process state before setting the SetOverallProgressDisplayOff as timer may reactivate it.
|
||||
/// </remarks>
|
||||
private void FinalizeRegisterRecovery(Boolean success, IReadOnlyList<Object> exitProcessStateObjects)
|
||||
private void FinalizeRegisterRecovery(StatusReturn success, IReadOnlyList<Object> exitProcessStateObjects)
|
||||
{
|
||||
if (_registerRestorer != null)
|
||||
_registerRestorer.OnProcessUpdate -= ProcessUpdate_Event;
|
||||
@@ -4586,7 +4612,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
||||
return;
|
||||
}
|
||||
|
||||
if (success)
|
||||
if (success == StatusReturn.Okay)
|
||||
{
|
||||
InfoProcessSuccess(lblRegisterRestore, Resources.StrRegisterRecoverySucceeded, false);
|
||||
_processState = successExitState;
|
||||
@@ -4595,6 +4621,16 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
||||
return;
|
||||
}
|
||||
|
||||
if (success == StatusReturn.Warning)
|
||||
{
|
||||
InfoProcessWarning(lblRegisterRestore, Resources.StrRegisterRecoveryWarning, false);
|
||||
// but go ahead to continue writing of registers
|
||||
_processState = successExitState;
|
||||
// change first the process state, otherwise the timer may switch the bar on again
|
||||
SetOverallProgressDisplayOff();
|
||||
return;
|
||||
}
|
||||
|
||||
InfoProcessFailed(lblRegisterRestore, Resources.StrRegisterRecoveryFailed, false);
|
||||
_processState = errorExitState;
|
||||
// change first the process state, otherwise the timer may switch the bar on again
|
||||
@@ -4662,9 +4698,9 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
||||
/// <remarks date="2020-Dec-09" author="Thomas Wiedebusch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
private Boolean ExecFwUpdate()
|
||||
private StatusReturn ExecFwUpdate()
|
||||
{
|
||||
return _meterFwUpdate.UpdateMeterFw();
|
||||
return _meterFwUpdate.UpdateMeterFw() ? StatusReturn.Okay : StatusReturn.Failed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -4685,7 +4721,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
||||
/// <remarks date="2020-Dec-19" author="Thomas Wiedebusch">
|
||||
/// - Reworked exit state.
|
||||
/// </remarks>
|
||||
private void FinalizeFwUpdate(Boolean success, IReadOnlyList<Object> exitProcessStateObjects)
|
||||
private void FinalizeFwUpdate(StatusReturn success, IReadOnlyList<Object> exitProcessStateObjects)
|
||||
{
|
||||
if (_meterFwUpdate != null)
|
||||
_meterFwUpdate.OnProcessUpdate -= ProcessUpdate_Event;
|
||||
@@ -4702,7 +4738,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
||||
return;
|
||||
}
|
||||
|
||||
if (success)
|
||||
if (success == StatusReturn.Okay)
|
||||
{
|
||||
InfoProcessActive(lblFirmwareUpdate, Resources.StrFirmwareUpdateCheck);
|
||||
_processState = successExitState;
|
||||
|
||||
@@ -685,4 +685,7 @@
|
||||
<data name="StrRegisterCompareSucceeded" xml:space="preserve">
|
||||
<value>Konfigurationsvergleich erfolgreich.</value>
|
||||
</data>
|
||||
<data name="StrRegisterRecoveryWarning" xml:space="preserve">
|
||||
<value>WARNUNG: Konfigurationswiederherstellung unvollständig</value>
|
||||
</data>
|
||||
</root>
|
||||
Reference in New Issue
Block a user