|
|
|
@@ -302,7 +302,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
// this step can be skipped.
|
|
|
|
|
if (_registerRestorer != null && _registerRestorer.RegisterRestoreExecuted())
|
|
|
|
|
_processState = ProcessState.ReadPostUpdateMeterFiles;
|
|
|
|
|
else RegisterRestore(ProcessState.ReadPostUpdateMeterFiles);
|
|
|
|
|
else
|
|
|
|
|
RegisterRestore(ProcessState.ReadPostUpdateMeterFiles);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ProcessState.PortScan:
|
|
|
|
@@ -316,7 +317,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
// skipped to avoid erasure of successfully downloaded upgXX - Files!
|
|
|
|
|
if (_registerRestorer != null && _registerRestorer.RegisterBackupExecuted())
|
|
|
|
|
_processState = ProcessState.ReadPreUpdateMeterFiles;
|
|
|
|
|
else RegisterBackup(ProcessState.ReadInitialMeterFiles);
|
|
|
|
|
else
|
|
|
|
|
RegisterBackup(ProcessState.ReadInitialMeterFiles);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ProcessState.ReadMeterFilesConfig:
|
|
|
|
@@ -451,7 +453,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
case ProcessState.PwdFileRestore:
|
|
|
|
|
case ProcessState.Connect:
|
|
|
|
|
// these routines do not have an event callback handler
|
|
|
|
|
if (_progressBarValueCounter++ > 100) _progressBarValueCounter = 0;
|
|
|
|
|
if (_progressBarValueCounter++ > 100)
|
|
|
|
|
_progressBarValueCounter = 0;
|
|
|
|
|
UiInvoker.ProgressBarInvoker(barOverallProgressUpdate, _progressBarValueCounter);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
@@ -479,7 +482,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_timerDisplayOn) UpdateTimeDisplay();
|
|
|
|
|
if (_timerDisplayOn)
|
|
|
|
|
UpdateTimeDisplay();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@@ -614,9 +618,13 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
/// <remarks date="2020-Nov-30" author="Thomas Wiedebusch">
|
|
|
|
|
/// - Initial
|
|
|
|
|
/// </remarks>
|
|
|
|
|
/// <remarks date="2022-Apr-28" author="Thomas Wiedebusch">
|
|
|
|
|
/// - Release display to normal operation,
|
|
|
|
|
/// - switch measurement LED off.
|
|
|
|
|
/// </remarks>
|
|
|
|
|
private void DisposeGenesis()
|
|
|
|
|
{
|
|
|
|
|
_currentGenesis?.Logout();
|
|
|
|
|
ReleaseDisplay();
|
|
|
|
|
// Batch removal disposes the meter!
|
|
|
|
|
_meterBatch?.RemoveAllMeters();
|
|
|
|
|
_currentGenesis = null;
|
|
|
|
@@ -678,7 +686,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
{
|
|
|
|
|
_frmHistory.rtbHistory.Invoke(new Action(() => { _frmHistory.rtbHistory.Clear(); }));
|
|
|
|
|
}
|
|
|
|
|
else _frmHistory?.rtbHistory.Clear();
|
|
|
|
|
else
|
|
|
|
|
_frmHistory?.rtbHistory.Clear();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -718,24 +727,20 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Finalize update and clean up.
|
|
|
|
|
/// Finalize update and clean up. Bring the display back to normal operation and switch the LED off.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <remarks date="2020-Dec-17" author="Thomas Wiedebusch">
|
|
|
|
|
/// - Added LED off.
|
|
|
|
|
/// </remarks>
|
|
|
|
|
/// <remarks date="2022-Apr-28" author="Thomas Wiedebusch">
|
|
|
|
|
/// - Login before display back to normal operation.
|
|
|
|
|
/// </remarks>
|
|
|
|
|
private void FrmFwUpdate_FormClosing(Object sender, FormClosingEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// Set LCD DISPLAY from IdLE and 8888 back to operation, this may be necessary if the update has been
|
|
|
|
|
// interrupted by a program stop due to a power loss or any unpredictable event.
|
|
|
|
|
_currentGenesis?.SetLcdText(true, new Byte[] { 0, 0, 0, 0 });
|
|
|
|
|
// deactivate LED, not needed to get measurements during the update or on repeated start after system
|
|
|
|
|
// failure. This overwrites the settings in _meterFwUpdate.
|
|
|
|
|
_currentGenesis?.WriteRegister(Register.Genesisflow.LedMode, new[] { (Byte)LedMode.Off });
|
|
|
|
|
|
|
|
|
|
ReleaseDisplay();
|
|
|
|
|
_frmHistory?.Close();
|
|
|
|
|
_processToken?.Cancel();
|
|
|
|
|
_currentGenesis?.Logout();
|
|
|
|
|
// this additionally disposes all meters
|
|
|
|
|
_meterBatch?.RemoveAllMeters();
|
|
|
|
|
_meterBatch?.Dispose();
|
|
|
|
@@ -874,7 +879,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
Thread.CurrentThread.CurrentUICulture = _cultureInfo;
|
|
|
|
|
Thread.CurrentThread.CurrentCulture = _cultureInfo;
|
|
|
|
|
|
|
|
|
|
if (_meterFwUpdate == null) return;
|
|
|
|
|
if (_meterFwUpdate == null)
|
|
|
|
|
return;
|
|
|
|
|
foreach (DataGridViewRow dataGridRow in gridViewApplic.Rows)
|
|
|
|
|
{
|
|
|
|
|
var testString = dataGridRow.Cells[Resources.StrTableStatus].Value.ToString();
|
|
|
|
@@ -950,7 +956,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
Thread.CurrentThread.CurrentUICulture = _cultureInfo;
|
|
|
|
|
Thread.CurrentThread.CurrentCulture = _cultureInfo;
|
|
|
|
|
|
|
|
|
|
if (_meterFwUpdate == null) _meterFwUpdate = new MeterFwUpdate(_currentGenesis);
|
|
|
|
|
if (_meterFwUpdate == null)
|
|
|
|
|
_meterFwUpdate = new MeterFwUpdate(_currentGenesis);
|
|
|
|
|
_binaryPackageLoaded = false;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
@@ -1302,7 +1309,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
// if the Genesis/Cordonel has been already detected, the port scan can be bypassed
|
|
|
|
|
if (_currentGenesis != null && !string.IsNullOrEmpty(_currentGenesis.PcbId))
|
|
|
|
|
_processState = ProcessState.Connect;
|
|
|
|
|
else _processState = ProcessState.PortScan;
|
|
|
|
|
else
|
|
|
|
|
_processState = ProcessState.PortScan;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@@ -1347,7 +1355,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
private void BtnUpdateFw_Click(Object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (_currentGenesis == null || _meterFwUpdate?.FileApps == null ||
|
|
|
|
|
_registerRestorer == null) return;
|
|
|
|
|
_registerRestorer == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
_startTime = DateTimeOffset.UtcNow;
|
|
|
|
|
_resetTimeMeasurement = false;
|
|
|
|
@@ -1364,7 +1373,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
{
|
|
|
|
|
var xPosition = Location.X + Size.Width;
|
|
|
|
|
var yPosition = Location.Y;
|
|
|
|
|
if (_frmHistory == null) return;
|
|
|
|
|
if (_frmHistory == null)
|
|
|
|
|
return;
|
|
|
|
|
if (_frmHistory.Visible)
|
|
|
|
|
{
|
|
|
|
|
_frmHistory.Hide();
|
|
|
|
@@ -1382,6 +1392,24 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
#endregion --------------------------------------- User Interaction -------------------------------------------
|
|
|
|
|
|
|
|
|
|
#region ------------------------------------------ Tools ------------------------------------------------------
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Release display and switch measurement LED off..
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <remarks date="2022-Apr-27" author="Thomas Wiedebusch">
|
|
|
|
|
/// - Initial.
|
|
|
|
|
/// </remarks>
|
|
|
|
|
private void ReleaseDisplay()
|
|
|
|
|
{
|
|
|
|
|
_currentGenesis?.ReLogin();
|
|
|
|
|
// Set LCD DISPLAY from IdLE and 9999 back to operation, this may be necessary if the update has been
|
|
|
|
|
// interrupted by a program stop due to a power loss or any unpredictable event.
|
|
|
|
|
_currentGenesis?.SetLcdText(true, new Byte[] { 0, 0, 0, 0 });
|
|
|
|
|
// deactivate LED, not needed to get measurements during the update or on repeated start after system
|
|
|
|
|
// failure. This overwrites the settings in _meterFwUpdate.
|
|
|
|
|
_currentGenesis?.WriteRegister(Register.Genesisflow.LedMode, new[] { (Byte)LedMode.Off });
|
|
|
|
|
_currentGenesis?.Logout();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Logging of string lists.
|
|
|
|
|
/// </summary>
|
|
|
|
@@ -1407,7 +1435,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
/// </remarks>
|
|
|
|
|
private void LogInstalledMeterFw()
|
|
|
|
|
{
|
|
|
|
|
if (_currentGenesis == null) return;
|
|
|
|
|
if (_currentGenesis == null)
|
|
|
|
|
return;
|
|
|
|
|
LogText(StrSeparator);
|
|
|
|
|
LogText($"PCB ID: {_currentGenesis.PcbId}");
|
|
|
|
|
LogText($"{Resources.StrMessageSystemCoreRevision} {_currentGenesis.CoreRevision}");
|
|
|
|
@@ -1441,7 +1470,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
}
|
|
|
|
|
LogText(StrSeparator);
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(_pathNameCordonelAppVersionFile)) return;
|
|
|
|
|
if (string.IsNullOrEmpty(_pathNameCordonelAppVersionFile))
|
|
|
|
|
return;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Create new file as for report only one version is allowed
|
|
|
|
@@ -1517,7 +1547,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void InfoWindowColoredText(String txtHistory, Color color)
|
|
|
|
|
{
|
|
|
|
|
if (_frmHistory?.rtbHistory == null) return;
|
|
|
|
|
if (_frmHistory?.rtbHistory == null)
|
|
|
|
|
return;
|
|
|
|
|
Invoke(new Action(() =>
|
|
|
|
|
{
|
|
|
|
|
_frmHistory.rtbHistory.SuspendLayout();
|
|
|
|
@@ -1539,7 +1570,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
/// </remarks>
|
|
|
|
|
private void ReportText(String txtHistory)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(_pathNameReportFile)) return;
|
|
|
|
|
if (string.IsNullOrEmpty(_pathNameReportFile))
|
|
|
|
|
return;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Create new file or add to existing file
|
|
|
|
@@ -1566,7 +1598,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
/// </remarks>
|
|
|
|
|
private void InfoStatusUnknown(Control label, String msg, Boolean userTextOutput = false)
|
|
|
|
|
{
|
|
|
|
|
if (userTextOutput) LogText(msg);
|
|
|
|
|
if (userTextOutput)
|
|
|
|
|
LogText(msg);
|
|
|
|
|
UiInvoker.ControlInvoker(label, ColorUnknownStatus, msg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -1578,7 +1611,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
/// </remarks>
|
|
|
|
|
private void InfoProcessActive(Control label, String msg, Boolean log = true)
|
|
|
|
|
{
|
|
|
|
|
if (log) LogText(msg);
|
|
|
|
|
if (log)
|
|
|
|
|
LogText(msg);
|
|
|
|
|
UiInvoker.ControlInvoker(label, ColorOngoingProcess, msg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -1587,7 +1621,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void InfoProcessSuccess(Control label, String msg, Boolean log = true)
|
|
|
|
|
{
|
|
|
|
|
if (log) LogSuccessText(msg);
|
|
|
|
|
if (log)
|
|
|
|
|
LogSuccessText(msg);
|
|
|
|
|
UiInvoker.ControlInvoker(label, ColorSuccess, $@"{SuccessSign} {msg}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -1772,11 +1807,15 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
errorState = ProcessState.Error;
|
|
|
|
|
breakState = ProcessState.Stop;
|
|
|
|
|
|
|
|
|
|
if (objects == null) return;
|
|
|
|
|
if (objects == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (objects.Count > 0 && objects[0] != null) successState = (ProcessState)objects[0];
|
|
|
|
|
if (objects.Count > 1 && objects[1] != null) errorState = (ProcessState)objects[1];
|
|
|
|
|
if (objects.Count > 2 && objects[2] != null) breakState = (ProcessState)objects[2];
|
|
|
|
|
if (objects.Count > 0 && objects[0] != null)
|
|
|
|
|
successState = (ProcessState)objects[0];
|
|
|
|
|
if (objects.Count > 1 && objects[1] != null)
|
|
|
|
|
errorState = (ProcessState)objects[1];
|
|
|
|
|
if (objects.Count > 2 && objects[2] != null)
|
|
|
|
|
breakState = (ProcessState)objects[2];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@@ -1916,9 +1955,12 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
SetActualProgressDisplayOff();
|
|
|
|
|
SetDisableDownloadAndEnableConnect();
|
|
|
|
|
_resetTimeMeasurement = true;
|
|
|
|
|
if (_serialPortScanner != null) _serialPortScanner.StopPortScan = true;
|
|
|
|
|
if (_meterFwUpdate != null) _meterFwUpdate.StopUpdateProcess = true;
|
|
|
|
|
if (_registerRestorer != null) _registerRestorer.StopRegisterAccess = true;
|
|
|
|
|
if (_serialPortScanner != null)
|
|
|
|
|
_serialPortScanner.StopPortScan = true;
|
|
|
|
|
if (_meterFwUpdate != null)
|
|
|
|
|
_meterFwUpdate.StopUpdateProcess = true;
|
|
|
|
|
if (_registerRestorer != null)
|
|
|
|
|
_registerRestorer.StopRegisterAccess = true;
|
|
|
|
|
MessageBoxShow(Resources.StrUserStop, "Info", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
|
|
|
|
|
|
|
|
|
// take the invoker of the error state to generate the message and / or popup window
|
|
|
|
@@ -1975,7 +2017,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OverallProcessUpdate(e);
|
|
|
|
|
if (e.ActualProcessPercent != null) ActualProcessUpdate(e);
|
|
|
|
|
if (e.ActualProcessPercent != null)
|
|
|
|
|
ActualProcessUpdate(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@@ -1994,7 +2037,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
private void OverallProcessUpdate(ProcessExecEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
UiInvoker.ControlInvoker(lblOverallProcess, ColorDefault, e.OverallProcessMessage);
|
|
|
|
|
if (e.OverallProcessPercent == null) return;
|
|
|
|
|
if (e.OverallProcessPercent == null)
|
|
|
|
|
return;
|
|
|
|
|
var progress = (Int32)e.OverallProcessPercent;
|
|
|
|
|
UiInvoker.ProgressBarInvoker(barOverallProgressUpdate, progress > 100 ? 100 : progress);
|
|
|
|
|
}
|
|
|
|
@@ -2015,7 +2059,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
private void ActualProcessUpdate(ProcessExecEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
UiInvoker.ControlInvoker(lblActualProcess, ColorDefault, e.ActualProcessMessage);
|
|
|
|
|
if (e.ActualProcessPercent == null) return;
|
|
|
|
|
if (e.ActualProcessPercent == null)
|
|
|
|
|
return;
|
|
|
|
|
var progress = (Int32)e.ActualProcessPercent;
|
|
|
|
|
UiInvoker.ProgressBarInvoker(barActualProgressUpdate, progress > 100 ? 100 : progress);
|
|
|
|
|
}
|
|
|
|
@@ -2087,7 +2132,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
|
|
|
|
|
while (_bootDelayCtrMs < RebootTimeoutMs && string.IsNullOrEmpty(text))
|
|
|
|
|
{
|
|
|
|
|
if (!_timerIntervalExpired) continue;
|
|
|
|
|
if (!_timerIntervalExpired)
|
|
|
|
|
continue;
|
|
|
|
|
_timerIntervalExpired = false;
|
|
|
|
|
// internal communication delay to avoid overload of Cordonel
|
|
|
|
|
if (_bootDelayCtrMs % internalCommunicationDelayMs == 0)
|
|
|
|
@@ -2177,7 +2223,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
{
|
|
|
|
|
//initialize the port type if not read from file
|
|
|
|
|
_portType = "Xylem.Common.Hardware.Interfaces.Ports.SerialPorts.IrdaSerialPort";
|
|
|
|
|
if (_serialPortScanner == null) _serialPortScanner = new MeterPortScanner(_portType);
|
|
|
|
|
if (_serialPortScanner == null)
|
|
|
|
|
_serialPortScanner = new MeterPortScanner(_portType);
|
|
|
|
|
//set the process bars
|
|
|
|
|
SetOverallProgressDisplayOn();
|
|
|
|
|
SetControlsCommunicationActive();
|
|
|
|
@@ -2231,7 +2278,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
/// </remarks>
|
|
|
|
|
private void FinalizePortScanner(Boolean success, IReadOnlyList<Object> exitProcessStateObjects)
|
|
|
|
|
{
|
|
|
|
|
if (_serialPortScanner != null) _serialPortScanner.OnProcessUpdate -= ProcessUpdate_Event;
|
|
|
|
|
if (_serialPortScanner != null)
|
|
|
|
|
_serialPortScanner.OnProcessUpdate -= ProcessUpdate_Event;
|
|
|
|
|
|
|
|
|
|
ObjectsToProcessStates(exitProcessStateObjects, out var successExitState, out var errorExitState,
|
|
|
|
|
out var breakExitState);
|
|
|
|
@@ -2338,7 +2386,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
//assign register restorer or set new created Genesis to access the post update register restorer
|
|
|
|
|
if (_registerRestorer == null)
|
|
|
|
|
_registerRestorer = new RegisterRestorer(_currentGenesis);
|
|
|
|
|
else _registerRestorer.AssignGenesis(_currentGenesis);
|
|
|
|
|
else
|
|
|
|
|
_registerRestorer.AssignGenesis(_currentGenesis);
|
|
|
|
|
|
|
|
|
|
SetOverallProgressDisplayOn(Resources.StrConnecting);
|
|
|
|
|
}
|
|
|
|
@@ -2374,10 +2423,12 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
private Boolean ExecConnect()
|
|
|
|
|
{
|
|
|
|
|
// nothing to do if already logged in into meter
|
|
|
|
|
if (_currentGenesis.IsLoggedOn) return true;
|
|
|
|
|
if (_currentGenesis.IsLoggedOn)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
//read out the PCB ID from water-meter to open the password container of this device
|
|
|
|
|
if (string.IsNullOrEmpty(_currentGenesis.PcbId)) _currentGenesis.GetPcbId();
|
|
|
|
|
if (string.IsNullOrEmpty(_currentGenesis.PcbId))
|
|
|
|
|
_currentGenesis.GetPcbId();
|
|
|
|
|
|
|
|
|
|
// search the PCB ID and extract password for login
|
|
|
|
|
String password = null;
|
|
|
|
@@ -2426,14 +2477,15 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
// wait that long, otherwise the Cordonel locks for 2s, 4s, 8s, 16s and so on on every retry!
|
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
|
|
|
|
|
|
if (_currentGenesis.Login(skeletonKey)) return true;
|
|
|
|
|
if (_currentGenesis.Login(skeletonKey))
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
_processState = ProcessState.Error;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Initialization of connect to water-meter.
|
|
|
|
|
/// Finalize of connection process to water-meter.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="success">successful execution</param>
|
|
|
|
|
/// <param name="exitProcessStateObjects">objects containing process states sorted success-, error-,
|
|
|
|
@@ -2510,14 +2562,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
InfoProcessFailed(null, Resources.StrPasswordFileNotInstalled);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Set LCD DISPLAY from IdLE and 8888 back to operation, this may be necessary if the update has been
|
|
|
|
|
// interrupted by a program stop due to a power loss or any unpredictable event.
|
|
|
|
|
_currentGenesis.SetLcdText(true, new Byte[] { 0, 0, 0, 0 });
|
|
|
|
|
// deactivate LED, not needed to get measurements during the update or on repeated start after system
|
|
|
|
|
// failure. This overwrites the settings in _meterFwUpdate.
|
|
|
|
|
_currentGenesis.WriteRegister(Register.Genesisflow.LedMode, new[] { (Byte)LedMode.Off });
|
|
|
|
|
|
|
|
|
|
_currentGenesis.Logout();
|
|
|
|
|
ReleaseDisplay();
|
|
|
|
|
_meterFwUpdate?.AssignGenesis(_currentGenesis);
|
|
|
|
|
|
|
|
|
|
// if authentication succeeded, the cordonel port detection must have succeeded in advance,
|
|
|
|
@@ -2532,7 +2577,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
UiInvoker.ControlInvoker(lblCoreRevision, ColorDefault,
|
|
|
|
|
Resources.StrCoreRevision + @" " + _currentGenesis.CoreRevision);
|
|
|
|
|
// avoid report again on final login after update
|
|
|
|
|
if (!_finalLoginAfterUpdate && BuildReportFiles()) LogInstalledMeterFw();
|
|
|
|
|
if (!_finalLoginAfterUpdate && BuildReportFiles())
|
|
|
|
|
LogInstalledMeterFw();
|
|
|
|
|
_processState = successExitState;
|
|
|
|
|
// change first the process state, otherwise the timer may switch the bar on again
|
|
|
|
|
SetOverallProgressDisplayOff();
|
|
|
|
@@ -2624,7 +2670,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
/// </remarks>
|
|
|
|
|
private void FinalizeRegisterBackup(Boolean success, IReadOnlyList<Object> exitProcessStateObjects)
|
|
|
|
|
{
|
|
|
|
|
if (_registerRestorer != null) _registerRestorer.OnProcessUpdate -= ProcessUpdate_Event;
|
|
|
|
|
if (_registerRestorer != null)
|
|
|
|
|
_registerRestorer.OnProcessUpdate -= ProcessUpdate_Event;
|
|
|
|
|
|
|
|
|
|
ObjectsToProcessStates(exitProcessStateObjects, out var successExitState, out var errorExitState,
|
|
|
|
|
out var breakExitState);
|
|
|
|
@@ -2746,7 +2793,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
// read all meter files
|
|
|
|
|
var meterFile = new MeterFile(_currentGenesis);
|
|
|
|
|
|
|
|
|
|
if (_readMeterFiles == null) _readMeterFiles = new List<String>();
|
|
|
|
|
if (_readMeterFiles == null)
|
|
|
|
|
_readMeterFiles = new List<String>();
|
|
|
|
|
_readMeterFiles.Clear();
|
|
|
|
|
|
|
|
|
|
if (meterFile.ReadMeterFileCatalog(out var meterFilesDrive0, MeterFile.StrMeterDrive0,
|
|
|
|
@@ -2851,7 +2899,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
SetOverallProgressDisplayOn(Resources.StrFileErasing + eraseFile);
|
|
|
|
|
|
|
|
|
|
// here the real erase will be executed
|
|
|
|
|
if (!meterFile.UnlockEraseWriteMeterFile(eraseFile)) continue;
|
|
|
|
|
if (!meterFile.UnlockEraseWriteMeterFile(eraseFile))
|
|
|
|
|
continue;
|
|
|
|
|
if (meterFile.EraseMeterFile(eraseFile))
|
|
|
|
|
{
|
|
|
|
|
erasedMeterFiles.Add(eraseFile);
|
|
|
|
@@ -2926,7 +2975,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
|
|
|
|
|
SetOverallProgressDisplayOn(Resources.StrFileRestoring + restoreFile.Name);
|
|
|
|
|
// this is the restore execution
|
|
|
|
|
if (!meterFile.UnlockEraseWriteMeterFile(restoreFile.Name)) continue;
|
|
|
|
|
if (!meterFile.UnlockEraseWriteMeterFile(restoreFile.Name))
|
|
|
|
|
continue;
|
|
|
|
|
if (meterFile.CreateEmptyMeterFile(restoreFile.Name, restoreFile.ByteSize))
|
|
|
|
|
{
|
|
|
|
|
restoredMeterFiles.Add(restoreFile.Name);
|
|
|
|
@@ -2988,6 +3038,10 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
/// <remarks date="2021-Apr-26" author="Thomas Wiedebusch">
|
|
|
|
|
/// - Checked for password file not in update container.
|
|
|
|
|
/// </remarks>
|
|
|
|
|
/// <remarks date="2022-Apr-28" author="Thomas Wiedebusch">
|
|
|
|
|
/// - Release display to normal operation,
|
|
|
|
|
/// - switch measurement LED off.
|
|
|
|
|
/// </remarks>
|
|
|
|
|
private void PwdFileRestore(ProcessState successExitState, ProcessState errorExitState = ProcessState.Error)
|
|
|
|
|
{
|
|
|
|
|
// remind the invoker being able to generate error messages based on the last state
|
|
|
|
@@ -3028,31 +3082,32 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
_processState = ProcessState.Connect;
|
|
|
|
|
_passwordFileIsCorrupted = false;
|
|
|
|
|
InfoProcessSuccess(lblPasswordFileCheck, Resources.StrPasswordFileRestoreSucceeded);
|
|
|
|
|
_currentGenesis.Logout();
|
|
|
|
|
// change first the process state, otherwise the timer may switch the bar on again
|
|
|
|
|
SetOverallProgressDisplayOff();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_currentGenesis?.Logout();
|
|
|
|
|
|
|
|
|
|
_currentGenesis.Logout();
|
|
|
|
|
}
|
|
|
|
|
// the password file is NOT in the password container
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
InfoProcessFailed(lblPasswordFileCheck, Resources.StrPasswordNotDelivered);
|
|
|
|
|
_processState = errorExitState;
|
|
|
|
|
// change first the process state, otherwise the timer may switch the bar on again
|
|
|
|
|
SetOverallProgressDisplayOff();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ReleaseDisplay();
|
|
|
|
|
// change first the process state, otherwise the timer may switch the bar on again
|
|
|
|
|
SetOverallProgressDisplayOff();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ReleaseDisplay();
|
|
|
|
|
InfoProcessFailed(lblPasswordFileCheck, Resources.StrPasswordFileRestoreFailed);
|
|
|
|
|
_processState = errorExitState;
|
|
|
|
|
// change first the process state, otherwise the timer may switch the bar on again
|
|
|
|
|
SetOverallProgressDisplayOff();
|
|
|
|
|
}
|
|
|
|
|
#endregion --------------------------------------- File Access ------------------------------------------------
|
|
|
|
|
|
|
|
|
|
#endregion --------------------------------------- File Access ------------------------------------------------
|
|
|
|
|
|
|
|
|
|
#region ------------------------------------------ Register Restorer ------------------------------------------
|
|
|
|
|
/// <summary>
|
|
|
|
@@ -3111,7 +3166,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
private Boolean ExecRegisterRestore()
|
|
|
|
|
{
|
|
|
|
|
var success = _registerRestorer.PostUpdateReadRegisters();
|
|
|
|
|
if (success) success = _registerRestorer.CompareRegisters();
|
|
|
|
|
if (success)
|
|
|
|
|
success = _registerRestorer.CompareRegisters();
|
|
|
|
|
return success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -3138,7 +3194,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
/// </remarks>
|
|
|
|
|
private void FinalizeRegisterRestore(Boolean success, IReadOnlyList<Object> exitProcessStateObjects)
|
|
|
|
|
{
|
|
|
|
|
if (_registerRestorer != null) _registerRestorer.OnProcessUpdate -= ProcessUpdate_Event;
|
|
|
|
|
if (_registerRestorer != null)
|
|
|
|
|
_registerRestorer.OnProcessUpdate -= ProcessUpdate_Event;
|
|
|
|
|
|
|
|
|
|
ObjectsToProcessStates(exitProcessStateObjects, out var successExitState, out var errorExitState,
|
|
|
|
|
out var breakExitState);
|
|
|
|
@@ -3256,7 +3313,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
/// </remarks>
|
|
|
|
|
private void FinalizeFwUpdate(Boolean success, IReadOnlyList<Object> exitProcessStateObjects)
|
|
|
|
|
{
|
|
|
|
|
if (_meterFwUpdate != null) _meterFwUpdate.OnProcessUpdate -= ProcessUpdate_Event;
|
|
|
|
|
if (_meterFwUpdate != null)
|
|
|
|
|
_meterFwUpdate.OnProcessUpdate -= ProcessUpdate_Event;
|
|
|
|
|
|
|
|
|
|
ObjectsToProcessStates(exitProcessStateObjects, out var successExitState, out var errorExitState,
|
|
|
|
|
out var breakExitState);
|
|
|
|
@@ -3364,7 +3422,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
/// </remarks>
|
|
|
|
|
private void RadioBtnEnglishLanguage_Click(Object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Thread.CurrentThread.CurrentCulture.Name == "en-GB") return;
|
|
|
|
|
if (Thread.CurrentThread.CurrentCulture.Name == "en-GB")
|
|
|
|
|
return;
|
|
|
|
|
_cultureInfo = new CultureInfo("en-GB");
|
|
|
|
|
ChangeLanguageControls();
|
|
|
|
|
}
|
|
|
|
@@ -3383,7 +3442,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
|
|
|
|
/// </remarks>
|
|
|
|
|
private void RadioBtnGermanLanguage_Click(Object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Thread.CurrentThread.CurrentCulture.Name == "de-DE") return;
|
|
|
|
|
if (Thread.CurrentThread.CurrentCulture.Name == "de-DE")
|
|
|
|
|
return;
|
|
|
|
|
_cultureInfo = new CultureInfo("de-DE");
|
|
|
|
|
ChangeLanguageControls();
|
|
|
|
|
}
|
|
|
|
|