1952 lines
70 KiB
C#
1952 lines
70 KiB
C#
|
|
using Logic.ProductionToProductMapper.Files.Fw;
|
|||
|
|
using Newtonsoft.Json;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Data;
|
|||
|
|
using System.Drawing;
|
|||
|
|
using System.Globalization;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Reflection;
|
|||
|
|
using System.Threading;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
using System.Windows.Forms;
|
|||
|
|
using Xylem.Common.CommonCore.Configuration;
|
|||
|
|
using Xylem.Common.Hardware.WaterMeter.Genesis.Applications;
|
|||
|
|
using Xylem.Common.Hardware.WaterMeter.Genesis.Applications.Const;
|
|||
|
|
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
|
|||
|
|
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile;
|
|||
|
|
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
|
|||
|
|
using Xylem.Common.Hardware.WaterMeter.WaterMeterCore;
|
|||
|
|
using Xylem.Common.Logic.ProductionOrderCore.FW;
|
|||
|
|
using Xylem.Common.Logic.ProductionOrderCore.OrderData;
|
|||
|
|
using Xylem.Common.Logic.SoftwareAccessHelper;
|
|||
|
|
using Xylem.Common.Ui.GenesisToolBox.Properties;
|
|||
|
|
|
|||
|
|
|
|||
|
|
namespace Xylem.Common.Ui.GenesisToolBox
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// FW update form
|
|||
|
|
/// </summary>
|
|||
|
|
public partial class FrmFwUpdate : Form
|
|||
|
|
{
|
|||
|
|
#region Variables
|
|||
|
|
private readonly MeterBatch _meterBatch = new MeterBatch();
|
|||
|
|
private GenesisMeter _currentGenesis;
|
|||
|
|
private const String StrConnecting = "Connecting to PCB";
|
|||
|
|
private const String StrNotConnected = "NOT CONNECTED";
|
|||
|
|
private const String StrCoreRevision = "System Core Revision: ";
|
|||
|
|
private const String StrPartPcbConnected = "Connected to PCB ID: ";
|
|||
|
|
private const String StrFileAppsLoaded = "ABC loaded";
|
|||
|
|
private const String StrUpdatePathEmpty = "No update files in path";
|
|||
|
|
private const String StrPackageFileLoaded = "ADF loaded";
|
|||
|
|
private const String StrPackageFileInvalid = "ADF invalid";
|
|||
|
|
private const String StrPackageFileToFileAppsMismatch = "ADF to ABC mismatch";
|
|||
|
|
private const String StrBurnUpgrade = "Waiting for meter response";
|
|||
|
|
private const String StrOverallProcess = "Overall Process";
|
|||
|
|
private readonly DataTable _dataTable = new DataTable();
|
|||
|
|
|
|||
|
|
//data grid table header
|
|||
|
|
private const String StrAppName = "AppName";
|
|||
|
|
private const String StrAppId = "AppId";
|
|||
|
|
private const String StrMeterVersion = "MeterVersion";
|
|||
|
|
private const String StrMeterCrc = "MeterCrc";
|
|||
|
|
private const String StrFileVersion = "FileVersion";
|
|||
|
|
private const String StrFileCrc = "FileCrc";
|
|||
|
|
private const String StrFileSize = "FileSize [kB]";
|
|||
|
|
private const String StrUpdate = "Download";
|
|||
|
|
private const String StrErase = "Erase";
|
|||
|
|
private const String StrStatus = "Status";
|
|||
|
|
|
|||
|
|
private readonly DataGridViewCellStyle _styleInstalled = new DataGridViewCellStyle();
|
|||
|
|
private readonly DataGridViewCellStyle _styleNotInstalled = new DataGridViewCellStyle();
|
|||
|
|
private readonly DataGridViewCellStyle _styleInvalidMeterCrc = new DataGridViewCellStyle();
|
|||
|
|
private readonly DataGridViewCellStyle _styleUpdateRequired = new DataGridViewCellStyle();
|
|||
|
|
private readonly DataGridViewCellStyle _styleDownloadSucceeded = new DataGridViewCellStyle();
|
|||
|
|
private readonly DataGridViewCellStyle _styleDownloadFailed = new DataGridViewCellStyle();
|
|||
|
|
private readonly DataGridViewCellStyle _styleDownloadOngoing = new DataGridViewCellStyle();
|
|||
|
|
private readonly DataGridViewCellStyle _styleValidated = new DataGridViewCellStyle();
|
|||
|
|
private readonly DataGridViewCellStyle _styleVerificationRequired = new DataGridViewCellStyle();
|
|||
|
|
private readonly DataGridViewCellStyle _styleEraseRequired = new DataGridViewCellStyle();
|
|||
|
|
private readonly DataGridViewCellStyle _styleCommunicationError = new DataGridViewCellStyle();
|
|||
|
|
|
|||
|
|
private Boolean _updateGui = true;
|
|||
|
|
private MeterFwUpdate _meterFwUpdate;
|
|||
|
|
private MeterResetPsu _meterResetPsu;
|
|||
|
|
private Boolean _meterResetProcessActive;
|
|||
|
|
|
|||
|
|
private String _lastFwUpdateState;
|
|||
|
|
private Int32 _lastSingleProgress;
|
|||
|
|
private DateTimeOffset _startTime;
|
|||
|
|
private Boolean _resetTimeMeasurement;
|
|||
|
|
private UInt32 _rebootCtr;
|
|||
|
|
|
|||
|
|
private static String DefaultBinaryPath
|
|||
|
|
{
|
|||
|
|
get => Settings.Default.InitialBinaryPath;
|
|||
|
|
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
Settings.Default.InitialBinaryPath = value;
|
|||
|
|
Settings.Default.Save();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private static String DefaultPackageFile
|
|||
|
|
{
|
|||
|
|
get => Settings.Default.InitialPackageFile;
|
|||
|
|
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
Settings.Default.InitialPackageFile = value;
|
|||
|
|
Settings.Default.Save();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private Boolean _fileAppsSuccessfulWritten;
|
|||
|
|
private Boolean _rebootSucceeded;
|
|||
|
|
|
|||
|
|
private Boolean _tryConnectPcb;
|
|||
|
|
private Boolean _packageFileToFileAppsValidated;
|
|||
|
|
|
|||
|
|
private const String StrUpdateErrorMessageManualControl =
|
|||
|
|
"FW UPDATE FAILED!\n\n" +
|
|||
|
|
"TIP1: Press [Update FW] button for next trial,\n " +
|
|||
|
|
"this keeps all downloaded files without new download\n" +
|
|||
|
|
"\nor\n" +
|
|||
|
|
"TIP2: Demarcate largest or failed file and press [Update FW],\n" +
|
|||
|
|
"this keeps all other downloaded files without new download.\n" +
|
|||
|
|
"Download of demarcated file separately!\n" +
|
|||
|
|
"\nor\n" +
|
|||
|
|
"TIP3: Press [Connect] and select large files separately!\n" +
|
|||
|
|
"This is a stepwise update, proceed until update is completed!\n";
|
|||
|
|
private const String StrUpdateErrorMessage =
|
|||
|
|
"FW UPDATE FAILED!\n\n";
|
|||
|
|
|
|||
|
|
private enum FwSource
|
|||
|
|
{
|
|||
|
|
File,
|
|||
|
|
// Production,
|
|||
|
|
Db
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
private FwSource _fwSource = FwSource.File;
|
|||
|
|
#endregion
|
|||
|
|
#region FormControls
|
|||
|
|
/// <summary>
|
|||
|
|
/// Ctor FW update
|
|||
|
|
/// </summary>
|
|||
|
|
public FrmFwUpdate()
|
|||
|
|
{
|
|||
|
|
InitializeComponent();
|
|||
|
|
var cultureInfo = new CultureInfo("en-GB");
|
|||
|
|
Thread.CurrentThread.CurrentUICulture = cultureInfo;
|
|||
|
|
Thread.CurrentThread.CurrentCulture = cultureInfo;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Clear data table and set genesis to not connected
|
|||
|
|
/// </summary>
|
|||
|
|
/// <remarks date="2023-Jan-18" author="Thomas Wiedebusch">
|
|||
|
|
/// - Enable update of Genesis Flow in Genesis Tool Box.
|
|||
|
|
/// </remarks>
|
|||
|
|
private void Init()
|
|||
|
|
{
|
|||
|
|
ProcessViewControl(false);
|
|||
|
|
lblConnectPcb.Text = StrNotConnected;
|
|||
|
|
lblCoreRevision.Text = "";
|
|||
|
|
lblConnectPcb.ForeColor = Color.Red;
|
|||
|
|
lblWaitingForMeterResponse.Visible = false;
|
|||
|
|
btnConnect.Enabled = true;
|
|||
|
|
btnUpdateFw.ForeColor = Color.DarkGreen;
|
|||
|
|
btnStopFwUpdate.ForeColor = Color.Red;
|
|||
|
|
SetControlDownloadsLocked();
|
|||
|
|
btnStopFwUpdate.Enabled = false;
|
|||
|
|
btnOpenUpdateDirectory.Enabled = false;
|
|||
|
|
btnOpenPackageControlFile.Enabled = false;
|
|||
|
|
btnRebootMeter.Enabled = false;
|
|||
|
|
btnClearDisplay.Enabled = false;
|
|||
|
|
cbFilePartSize.Enabled = true;
|
|||
|
|
_meterResetProcessActive = false;
|
|||
|
|
CheckManualControl();
|
|||
|
|
if (_meterFwUpdate != null)
|
|||
|
|
{
|
|||
|
|
_meterFwUpdate.SingleFilePartsRetryEnable = cbxSingleFilePartsRetryEnable.Checked;
|
|||
|
|
_meterFwUpdate.ConsecutiveFilePartsRetryEnable = cbxConsecutiveFilePartsRetryEnable.Checked;
|
|||
|
|
_meterFwUpdate.StoreConfigEnable = cbxStoreConfigEnable.Checked;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
_dataTable.Rows.Clear();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void FrmFwUpdate_Load(Object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
_styleInstalled.BackColor = Color.White;
|
|||
|
|
_styleInstalled.ForeColor = Color.Black;
|
|||
|
|
|
|||
|
|
_styleNotInstalled.BackColor = Color.LightGray;
|
|||
|
|
_styleNotInstalled.ForeColor = Color.Black;
|
|||
|
|
|
|||
|
|
_styleCommunicationError.BackColor = Color.LightPink;
|
|||
|
|
_styleCommunicationError.ForeColor = Color.Red;
|
|||
|
|
|
|||
|
|
_styleUpdateRequired.BackColor = Color.White;
|
|||
|
|
_styleUpdateRequired.ForeColor = Color.Red;
|
|||
|
|
|
|||
|
|
_styleEraseRequired.BackColor = Color.LightGray;
|
|||
|
|
_styleEraseRequired.ForeColor = Color.Black;
|
|||
|
|
|
|||
|
|
_styleDownloadOngoing.BackColor = Color.GreenYellow;
|
|||
|
|
_styleDownloadOngoing.ForeColor = Color.Black;
|
|||
|
|
|
|||
|
|
_styleValidated.BackColor = Color.White;
|
|||
|
|
_styleValidated.ForeColor = Color.Green;
|
|||
|
|
|
|||
|
|
_styleDownloadSucceeded.BackColor = Color.LightGreen;
|
|||
|
|
_styleDownloadSucceeded.ForeColor = Color.Green;
|
|||
|
|
|
|||
|
|
_styleDownloadFailed.BackColor = Color.LightPink;
|
|||
|
|
_styleDownloadFailed.ForeColor = Color.Red;
|
|||
|
|
|
|||
|
|
_styleVerificationRequired.BackColor = Color.LightGoldenrodYellow;
|
|||
|
|
_styleVerificationRequired.ForeColor = Color.Green;
|
|||
|
|
|
|||
|
|
_dataTable.Columns.Add(StrAppName, typeof(String));
|
|||
|
|
_dataTable.Columns.Add(StrAppId, typeof(String));
|
|||
|
|
_dataTable.Columns.Add(StrMeterVersion, typeof(String));
|
|||
|
|
_dataTable.Columns.Add(StrMeterCrc, typeof(String));
|
|||
|
|
_dataTable.Columns.Add(StrFileVersion, typeof(String));
|
|||
|
|
_dataTable.Columns.Add(StrFileCrc, typeof(String));
|
|||
|
|
_dataTable.Columns.Add(StrFileSize, typeof(String));
|
|||
|
|
_dataTable.Columns.Add(StrUpdate, typeof(Boolean));
|
|||
|
|
_dataTable.Columns.Add(StrErase, typeof(Boolean));
|
|||
|
|
_dataTable.Columns.Add(StrStatus, typeof(String));
|
|||
|
|
|
|||
|
|
var version = Assembly.GetExecutingAssembly().GetName().Version;
|
|||
|
|
lblFwUpdateInfo.Text = $@"GTB Version: {version.Major}.{version.Minor}.{version.Build}";
|
|||
|
|
_resetTimeMeasurement = true;
|
|||
|
|
Init();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void FrmFwUpdate_FormClosing(Object sender, FormClosingEventArgs e)
|
|||
|
|
{
|
|||
|
|
_currentGenesis?.Logout();
|
|||
|
|
_meterBatch?.RemoveAllMeters();
|
|||
|
|
_meterBatch?.Dispose();
|
|||
|
|
_meterFwUpdate?.Dispose();
|
|||
|
|
_meterFwUpdate = null;
|
|||
|
|
Dispose();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void cbComSlot_SelectedIndexChanged(Object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
_resetTimeMeasurement = true;
|
|||
|
|
Init();
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
#region DataGridControls
|
|||
|
|
/// <summary>
|
|||
|
|
/// Build data grid and fill it with meter and file information,
|
|||
|
|
/// compare version and CRC of meter and file
|
|||
|
|
/// </summary>
|
|||
|
|
private void FillDataGridWithAllInfos()
|
|||
|
|
{
|
|||
|
|
_dataTable.Rows.Clear();
|
|||
|
|
if (_currentGenesis == null)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
foreach (var meterApp in _currentGenesis.MeterAppListVersion)
|
|||
|
|
{
|
|||
|
|
var row = _dataTable.NewRow();
|
|||
|
|
//application information read from configuration
|
|||
|
|
row[StrAppName] = meterApp.AppName;
|
|||
|
|
row[StrAppId] = MeterFwUpdate.ConvertAppIdToString(meterApp.AppId);
|
|||
|
|
|
|||
|
|
_dataTable.Rows.Add(row);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//output data to data grid view
|
|||
|
|
gridViewApplic.DataSource = _dataTable.DefaultView;
|
|||
|
|
|
|||
|
|
foreach (DataRow dataRow in _dataTable.Rows)
|
|||
|
|
{
|
|||
|
|
DisplayFileAppInfo(dataRow);
|
|||
|
|
DisplayMeterAppInfo(dataRow);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
foreach (DataGridViewColumn column in gridViewApplic.Columns)
|
|||
|
|
{
|
|||
|
|
column.SortMode = DataGridViewColumnSortMode.NotSortable;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//color the results of the compare
|
|||
|
|
UpdateInformationStyleSet();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Set meter application information to data grid view
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="dataRow"></param>
|
|||
|
|
private void DisplayMeterAppInfo(DataRow dataRow)
|
|||
|
|
{
|
|||
|
|
if (_currentGenesis == null)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var meterStateAppInfo = new MeterAppStateInfo();
|
|||
|
|
foreach (var meterApp in _currentGenesis.MeterAppListVersion)
|
|||
|
|
{
|
|||
|
|
var appId = dataRow[StrAppId].ToString();
|
|||
|
|
if (appId != MeterFwUpdate.ConvertAppIdToString(meterApp.AppId))
|
|||
|
|
{
|
|||
|
|
continue;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
dataRow[StrUpdate] = meterApp.Update;
|
|||
|
|
dataRow[StrErase] = meterApp.Erase;
|
|||
|
|
dataRow[StrStatus] = meterStateAppInfo.GetTextFromState(meterApp.Status);
|
|||
|
|
|
|||
|
|
dataRow[StrMeterVersion] = meterApp.StrVersion;
|
|||
|
|
dataRow[StrMeterCrc] = meterApp.IsInstalled ?
|
|||
|
|
MeterFwUpdate.ConvertCrcToString(meterApp.Crc) : "";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Set file application information to data grid view.
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="dataRow"></param>
|
|||
|
|
private void DisplayFileAppInfo(DataRow dataRow)
|
|||
|
|
{
|
|||
|
|
if (_currentGenesis == null || _meterFwUpdate?.FileApps == null)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
foreach (var meterApp in _currentGenesis.MeterAppListVersion)
|
|||
|
|
{
|
|||
|
|
var appId = dataRow[StrAppId].ToString();
|
|||
|
|
if (appId != MeterFwUpdate.ConvertAppIdToString(meterApp.AppId))
|
|||
|
|
{
|
|||
|
|
continue;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
foreach (var fileApp in _meterFwUpdate.FileApps)
|
|||
|
|
{
|
|||
|
|
if (meterApp.AppId != fileApp.AppId)
|
|||
|
|
{
|
|||
|
|
continue;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
dataRow[StrFileVersion] = fileApp.StrVersion;
|
|||
|
|
dataRow[StrFileCrc] = MeterFwUpdate.ConvertCrcToString(fileApp.Crc);
|
|||
|
|
dataRow[StrFileSize] = $"{(Double)fileApp.BinData.Count / 1024:0.000}";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Display the update information
|
|||
|
|
/// </summary>
|
|||
|
|
private void UpdateInformationStyleSet()
|
|||
|
|
{
|
|||
|
|
foreach (DataGridViewRow dataGridRow in gridViewApplic.Rows)
|
|||
|
|
{
|
|||
|
|
var testString = dataGridRow.Cells[StrStatus].Value.ToString();
|
|||
|
|
var meterAppStateInfo = new MeterAppStateInfo();
|
|||
|
|
var meterAppState = meterAppStateInfo.GetStateFromText(testString);
|
|||
|
|
|
|||
|
|
switch (meterAppState)
|
|||
|
|
{
|
|||
|
|
case MeterAppState.MeterAppInstalledUnchecked:
|
|||
|
|
dataGridRow.DefaultCellStyle = _styleInstalled;
|
|||
|
|
break;
|
|||
|
|
case MeterAppState.MeterAppUpToDate:
|
|||
|
|
dataGridRow.DefaultCellStyle = _styleValidated;
|
|||
|
|
break;
|
|||
|
|
case MeterAppState.MeterAppInstallationRequired:
|
|||
|
|
dataGridRow.DefaultCellStyle = _styleUpdateRequired;
|
|||
|
|
break;
|
|||
|
|
case MeterAppState.FileAppInvalid:
|
|||
|
|
dataGridRow.DefaultCellStyle = _styleNotInstalled;
|
|||
|
|
break;
|
|||
|
|
case MeterAppState.MeterAppVersionOutdated:
|
|||
|
|
dataGridRow.DefaultCellStyle = _styleUpdateRequired;
|
|||
|
|
break;
|
|||
|
|
case MeterAppState.Unknown:
|
|||
|
|
dataGridRow.DefaultCellStyle = _styleCommunicationError;
|
|||
|
|
break;
|
|||
|
|
case MeterAppState.MeterAppNotInstalled:
|
|||
|
|
dataGridRow.DefaultCellStyle = _styleNotInstalled;
|
|||
|
|
break;
|
|||
|
|
case MeterAppState.MeterAppNotRequired:
|
|||
|
|
dataGridRow.DefaultCellStyle = _styleNotInstalled;
|
|||
|
|
break;
|
|||
|
|
case MeterAppState.InvalidCrc:
|
|||
|
|
dataGridRow.DefaultCellStyle = _styleInvalidMeterCrc;
|
|||
|
|
break;
|
|||
|
|
case MeterAppState.MeterAppErasureRequired:
|
|||
|
|
dataGridRow.DefaultCellStyle = _styleEraseRequired;
|
|||
|
|
break;
|
|||
|
|
case MeterAppState.MeterAppDownloadSucceeded:
|
|||
|
|
dataGridRow.DefaultCellStyle = _styleDownloadSucceeded;
|
|||
|
|
break;
|
|||
|
|
case MeterAppState.MeterAppDownloadSuspicious:
|
|||
|
|
dataGridRow.DefaultCellStyle = _styleVerificationRequired;
|
|||
|
|
break;
|
|||
|
|
case MeterAppState.MeterAppSuccessfulErased:
|
|||
|
|
dataGridRow.DefaultCellStyle = _styleDownloadSucceeded;
|
|||
|
|
break;
|
|||
|
|
case MeterAppState.MeterAppSuccessfulUpdated:
|
|||
|
|
dataGridRow.DefaultCellStyle = _styleDownloadSucceeded;
|
|||
|
|
break;
|
|||
|
|
case MeterAppState.MeterAppDownloadFailed:
|
|||
|
|
dataGridRow.DefaultCellStyle = _styleDownloadFailed;
|
|||
|
|
break;
|
|||
|
|
case MeterAppState.MeterAppDownloadActive:
|
|||
|
|
dataGridRow.DefaultCellStyle = _styleDownloadOngoing;
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
dataGridRow.DefaultCellStyle = _styleNotInstalled;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// After changing the grid view cell and data row cell contents, the meter application lists
|
|||
|
|
/// have to be updated with the required action (erase or update or none of them)
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="dataRow"></param>
|
|||
|
|
private void SetMeterAppEraseUpdateInfo(DataRow dataRow)
|
|||
|
|
{
|
|||
|
|
foreach (var meterApp in _currentGenesis.MeterAppListVersion)
|
|||
|
|
{
|
|||
|
|
var appId = dataRow[StrAppId].ToString();
|
|||
|
|
if (appId != MeterFwUpdate.ConvertAppIdToString(meterApp.AppId))
|
|||
|
|
{
|
|||
|
|
continue;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
meterApp.Update = (Boolean)dataRow[StrUpdate];
|
|||
|
|
meterApp.Erase = (Boolean)dataRow[StrErase];
|
|||
|
|
}
|
|||
|
|
//force upgrade file generation on update cell click
|
|||
|
|
_meterFwUpdate?.AssignGenesis(_currentGenesis);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Overwrite cell click, because edit of cells is denied. This is needed for update and/or erase selection
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void gridViewApplic_CellClick(Object sender, DataGridViewCellEventArgs e)
|
|||
|
|
{
|
|||
|
|
if (e.ColumnIndex <= 0 || !btnOpenUpdateDirectory.Enabled ||
|
|||
|
|
!cbxManualControl.Checked)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var dataRow = _dataTable.Rows[e.RowIndex];
|
|||
|
|
if (gridViewApplic.Columns[e.ColumnIndex].Name == StrUpdate)
|
|||
|
|
{
|
|||
|
|
//deny update if update file invalid
|
|||
|
|
if (dataRow[StrFileVersion].ToString() == "")
|
|||
|
|
{
|
|||
|
|
dataRow[StrUpdate] = false;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
//toggle selection
|
|||
|
|
dataRow[StrUpdate] = (Boolean)dataRow[StrUpdate] != true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//remove erase selection
|
|||
|
|
if ((Boolean)dataRow[StrUpdate])
|
|||
|
|
{
|
|||
|
|
dataRow[StrErase] = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
if (gridViewApplic.Columns[e.ColumnIndex].Name == StrErase)
|
|||
|
|
{
|
|||
|
|
//deny erase if meter file not installed or the essential applications
|
|||
|
|
//needed to keep the operation for the update procedure alive
|
|||
|
|
if (dataRow[StrMeterVersion].ToString() == ""
|
|||
|
|
|| dataRow[StrAppName].ToString() == "SYSTEM"
|
|||
|
|
|| dataRow[StrAppName].ToString() == "CONFIGEXCHANGE"
|
|||
|
|
|| dataRow[StrAppName].ToString() == "IRDA")
|
|||
|
|
{
|
|||
|
|
dataRow[StrErase] = false;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
//toggle selection
|
|||
|
|
dataRow[StrErase] = (Boolean)dataRow[StrErase] != true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//remove update selection
|
|||
|
|
if ((Boolean)dataRow[StrErase])
|
|||
|
|
{
|
|||
|
|
dataRow[StrUpdate] = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
//update information in meter application list
|
|||
|
|
SetMeterAppEraseUpdateInfo(dataRow);
|
|||
|
|
CheckUpdateEnabled();
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
#region ActivationControls
|
|||
|
|
private void SetControlDownloadsUnlocked()
|
|||
|
|
{
|
|||
|
|
btnUpdateFw.Enabled = true;
|
|||
|
|
btnStopFwUpdate.Enabled = false;
|
|||
|
|
|
|||
|
|
btnDownloadFiles.Enabled = true;
|
|||
|
|
if (cbxSingleFilePartsRetryEnable.Checked)
|
|||
|
|
{
|
|||
|
|
btnRetryFileParts.Enabled = CheckRetryPossible();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
btnVerifyFiles.Enabled = true;
|
|||
|
|
|
|||
|
|
btnPrepareTrigger.Enabled = true;
|
|||
|
|
btnTriggerUpdate.Enabled = true;
|
|||
|
|
btnClearDisplay.Enabled = true;
|
|||
|
|
btnRebootMeter.Enabled = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void SetControlDownloadsLocked()
|
|||
|
|
{
|
|||
|
|
btnUpdateFw.Enabled = false;
|
|||
|
|
btnStopFwUpdate.Enabled = false;
|
|||
|
|
|
|||
|
|
btnDownloadFiles.Enabled = false;
|
|||
|
|
btnRetryFileParts.Enabled = false;
|
|||
|
|
btnVerifyFiles.Enabled = false;
|
|||
|
|
|
|||
|
|
btnPrepareTrigger.Enabled = false;
|
|||
|
|
btnTriggerUpdate.Enabled = false;
|
|||
|
|
btnConnect.Enabled = true;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void SetControlsDownloadIsOngoing()
|
|||
|
|
{
|
|||
|
|
cbFilePartSize.Enabled = false;
|
|||
|
|
cbAddRetryTimeout.Enabled = false;
|
|||
|
|
btnConnect.Enabled = false;
|
|||
|
|
btnOpenUpdateDirectory.Enabled = false;
|
|||
|
|
btnOpenPackageControlFile.Enabled = false;
|
|||
|
|
|
|||
|
|
btnUpdateFw.Enabled = false;
|
|||
|
|
btnStopFwUpdate.Enabled = true;
|
|||
|
|
|
|||
|
|
btnDownloadFiles.Enabled = false;
|
|||
|
|
btnRetryFileParts.Enabled = false;
|
|||
|
|
btnVerifyFiles.Enabled = false;
|
|||
|
|
|
|||
|
|
btnPrepareTrigger.Enabled = false;
|
|||
|
|
btnTriggerUpdate.Enabled = false;
|
|||
|
|
btnClearDisplay.Enabled = false;
|
|||
|
|
btnRebootMeter.Enabled = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void SetControlsDownloadIsFinished()
|
|||
|
|
{
|
|||
|
|
_currentGenesis.RequestProtocol.AdditionalRetryTimeoutMs = 0;
|
|||
|
|
cbFilePartSize.Enabled = true;
|
|||
|
|
cbAddRetryTimeout.Enabled = true;
|
|||
|
|
btnConnect.Enabled = true;
|
|||
|
|
btnOpenUpdateDirectory.Enabled = true;
|
|||
|
|
btnOpenPackageControlFile.Enabled = true;
|
|||
|
|
|
|||
|
|
btnUpdateFw.Enabled = true;
|
|||
|
|
btnStopFwUpdate.Enabled = false;
|
|||
|
|
|
|||
|
|
btnDownloadFiles.Enabled = true;
|
|||
|
|
if (cbxSingleFilePartsRetryEnable.Checked)
|
|||
|
|
{
|
|||
|
|
btnRetryFileParts.Enabled = CheckRetryPossible();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
btnVerifyFiles.Enabled = true;
|
|||
|
|
|
|||
|
|
btnPrepareTrigger.Enabled = true;
|
|||
|
|
btnTriggerUpdate.Enabled = true;
|
|||
|
|
btnClearDisplay.Enabled = true;
|
|||
|
|
btnRebootMeter.Enabled = true;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
#region BoardControls
|
|||
|
|
private void WaitForReboot()
|
|||
|
|
{
|
|||
|
|
if (_currentGenesis == null)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
lblActualProcess.Text = StrBurnUpgrade;
|
|||
|
|
lblOverall.Text = @"Update Applications and Restart Meter";
|
|||
|
|
ProcessViewControl(true);
|
|||
|
|
|
|||
|
|
//wait until meter update is completed and meter is re-booted
|
|||
|
|
const Double maxBootDelayMs = 50000.0;
|
|||
|
|
const Double loopDelayMs = 200.0;
|
|||
|
|
var bootDelayMs = 0.0;
|
|||
|
|
var text = "";
|
|||
|
|
while (bootDelayMs < maxBootDelayMs && string.IsNullOrEmpty(text))
|
|||
|
|
{
|
|||
|
|
SetTimeDisplay();
|
|||
|
|
|
|||
|
|
text = RegisterConverter.ByteArrayToValue<String>(
|
|||
|
|
_currentGenesis.ReadRegister(Register.Configexchange.PcbSerialNumber, 12));
|
|||
|
|
barOverallProgressUpdate.Value = barOverallProgressUpdate.Value + 4 > 100 ? 0 :
|
|||
|
|
barOverallProgressUpdate.Value + 4;
|
|||
|
|
var bootProcess = (Int32)(bootDelayMs * 100.0 / maxBootDelayMs);
|
|||
|
|
barSingleProgressUpdate.Value = barSingleProgressUpdate.Value + bootProcess > 100 ? 0 :
|
|||
|
|
barSingleProgressUpdate.Value + bootProcess;
|
|||
|
|
Update();
|
|||
|
|
bootDelayMs += loopDelayMs;
|
|||
|
|
Thread.Sleep((Int32)loopDelayMs);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
ProcessViewControl(false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Establish connection
|
|||
|
|
/// </summary>
|
|||
|
|
/// <remarks date="2025-Aug-07" author="Thomas Wiedebusch">
|
|||
|
|
/// - Compare the max supported FW versions of the configuration.json.
|
|||
|
|
/// </remarks>
|
|||
|
|
/// <remarks date="2025-Oct-02" author="Thomas Wiedebusch">
|
|||
|
|
/// - Catch error message on unknown data type and kill meter.
|
|||
|
|
/// </remarks>
|
|||
|
|
/// <remarks date="2025-Oct-14" author="Thomas Wiedebusch">
|
|||
|
|
/// - Use optional offline passwords.
|
|||
|
|
/// </remarks>
|
|||
|
|
/// <remarks date="2025-Dec-02" author="Thomas Wiedebusch">
|
|||
|
|
/// - Restore reboot counter.
|
|||
|
|
/// </remarks>
|
|||
|
|
private void Connect()
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
Init();
|
|||
|
|
|
|||
|
|
if (string.IsNullOrEmpty(cbComSlot.SelectedItem.ToString()) ||
|
|||
|
|
!int.TryParse(cbComSlot.SelectedItem.ToString(), out var slotNr))
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
lblOverall.Text = @"Login to Cordonel...";
|
|||
|
|
|
|||
|
|
ViewProgressPcb(true);
|
|||
|
|
|
|||
|
|
var oldPcbId = "";
|
|||
|
|
// If the current meter is not assigned this is the initial connection or new meter
|
|||
|
|
if (_currentGenesis != null)
|
|||
|
|
{
|
|||
|
|
oldPcbId = _currentGenesis.PcbId;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
_currentGenesis?.DisposeMeter();
|
|||
|
|
//dispose old meter
|
|||
|
|
_meterBatch.RemoveAllMeters();
|
|||
|
|
_currentGenesis = null;
|
|||
|
|
|
|||
|
|
//assign new meter and assign meter to FW update file if this exists
|
|||
|
|
_currentGenesis = new GenesisMeter();
|
|||
|
|
_currentGenesis.UseOfflinePasswords = cbxUseOfflinePwds.Checked;
|
|||
|
|
_currentGenesis.SetupFromConfigFile(slotNr);
|
|||
|
|
_meterBatch.AddMeter(_currentGenesis);
|
|||
|
|
|
|||
|
|
_currentGenesis.Configuration.UseRegisterWatchService = false;
|
|||
|
|
_currentGenesis.Configuration.UseMinMaxCheck = false;
|
|||
|
|
|
|||
|
|
lblActualProcess.Text = @"Connecting to PCB...";
|
|||
|
|
|
|||
|
|
Task.Factory.StartNew(() =>
|
|||
|
|
{
|
|||
|
|
_meterBatch.MetersLogin();
|
|||
|
|
|
|||
|
|
if (!_currentGenesis.IsLoggedOn)
|
|||
|
|
{
|
|||
|
|
Thread.Sleep(2000);
|
|||
|
|
_meterBatch.MetersLogin();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!_currentGenesis.IsLoggedOn)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Take the actual reboot counter
|
|||
|
|
var rebootCtr =
|
|||
|
|
RegisterConverter.ByteArrayToValue<UInt32>(_currentGenesis.ReadRegister("CUSTOMER_RebootCount"));
|
|||
|
|
|
|||
|
|
// Check for old meter to restore the reboot counter
|
|||
|
|
if (_currentGenesis.PcbId.Equals(oldPcbId))
|
|||
|
|
{
|
|||
|
|
// Restore reboot counter
|
|||
|
|
if (_rebootCtr != rebootCtr)
|
|||
|
|
{
|
|||
|
|
_currentGenesis.WriteRegister("CUSTOMER_RebootCount", _rebootCtr);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
// Preset the reboot counter for the new meter
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
_rebootCtr = rebootCtr;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
_meterFwUpdate?.AssignGenesis(_currentGenesis);
|
|||
|
|
|
|||
|
|
Invoke(new Action(() =>
|
|||
|
|
{
|
|||
|
|
lblConnectPcb.Text = StrPartPcbConnected + _currentGenesis.PcbId;
|
|||
|
|
lblCoreRevision.Text = StrCoreRevision + _currentGenesis.StrCoreRevision;
|
|||
|
|
lblConfigVersion.Text = @"Configuration Version: " + _currentGenesis.InterfaceInfo.InterfaceVersion;
|
|||
|
|
lblConfigVersion.ForeColor = _currentGenesis.InterfaceSupportsFwVersion ?
|
|||
|
|
Color.Green :
|
|||
|
|
Color.Red;
|
|||
|
|
lblConnectPcb.ForeColor = Color.Green;
|
|||
|
|
_meterFwUpdate?.CompareAllMeterAndFileApps(true);
|
|||
|
|
FillDataGridWithAllInfos();
|
|||
|
|
CheckUpdateEnabled();
|
|||
|
|
_currentGenesis.Logout();
|
|||
|
|
if (!_currentGenesis.InterfaceSupportsFwVersion)
|
|||
|
|
{
|
|||
|
|
var text = "CONFIGURATION OUTDATED!\n\n" +
|
|||
|
|
"The loaded \"configuration.json\" " +
|
|||
|
|
$"version: {_currentGenesis.InterfaceInfo.InterfaceVersion}\n" +
|
|||
|
|
$"does NOT support the Cordonel FW version: {_currentGenesis.FwVersion}!";
|
|||
|
|
MessageBoxShow(text, @"FAILED", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|||
|
|
}
|
|||
|
|
}));
|
|||
|
|
}).ContinueWith(delegate
|
|||
|
|
{
|
|||
|
|
ViewProgressPcb(false);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
ViewProgressPcb(false);
|
|||
|
|
MessageBox.Show(ex.Message, @"FAILED", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|||
|
|
// Dispose meter
|
|||
|
|
_meterBatch.RemoveAllMeters();
|
|||
|
|
// If meter is not already assigned to batch as the config reader may fail
|
|||
|
|
_currentGenesis?.DisposeMeter();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
#region ProcessControls
|
|||
|
|
private void ViewProgressPcb(Boolean isActive)
|
|||
|
|
{
|
|||
|
|
if (_updateGui)
|
|||
|
|
{
|
|||
|
|
if (isActive)
|
|||
|
|
{
|
|||
|
|
Invoke(new Action(() =>
|
|||
|
|
{
|
|||
|
|
_tryConnectPcb = true;
|
|||
|
|
ProcessViewControl(true);
|
|||
|
|
lblActualProcess.Text = StrConnecting;
|
|||
|
|
lblOverall.Text = StrOverallProcess;
|
|||
|
|
}));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Invoke(new Action(() =>
|
|||
|
|
{
|
|||
|
|
_tryConnectPcb = false;
|
|||
|
|
ProcessViewControl(false);
|
|||
|
|
}));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// View all process bars and labels
|
|||
|
|
/// </summary>
|
|||
|
|
private void ProcessViewControl(Boolean view)
|
|||
|
|
{
|
|||
|
|
if (view)
|
|||
|
|
{
|
|||
|
|
lblActualProcess.Visible = true;
|
|||
|
|
lblOverall.Visible = true;
|
|||
|
|
barOverallProgressUpdate.Visible = true;
|
|||
|
|
barSingleProgressUpdate.Visible = true;
|
|||
|
|
_lastFwUpdateState = "";
|
|||
|
|
tmrProgressUpdate.Enabled = true;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
lblActualProcess.Visible = false;
|
|||
|
|
lblOverall.Visible = false;
|
|||
|
|
barOverallProgressUpdate.Visible = false;
|
|||
|
|
barSingleProgressUpdate.Visible = false;
|
|||
|
|
tmrProgressUpdate.Enabled = false;
|
|||
|
|
_lastFwUpdateState = "";
|
|||
|
|
lblWaitingForMeterResponse.Visible = false;
|
|||
|
|
lblActualProcess.Text = "";
|
|||
|
|
lblOverall.Text = "";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//common actions and settings
|
|||
|
|
lblActualProcess.Update();
|
|||
|
|
lblOverall.Update();
|
|||
|
|
barOverallProgressUpdate.Value = 0;
|
|||
|
|
barOverallProgressUpdate.Update();
|
|||
|
|
barSingleProgressUpdate.Value = 0;
|
|||
|
|
barSingleProgressUpdate.Update();
|
|||
|
|
Update();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void AutomaticUpdateControl(Boolean isActive)
|
|||
|
|
{
|
|||
|
|
if (isActive)
|
|||
|
|
{
|
|||
|
|
Invoke(new Action(() =>
|
|||
|
|
{
|
|||
|
|
ProcessViewControl(true);
|
|||
|
|
tmrProgressUpdate.Enabled = true;
|
|||
|
|
}));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Invoke(new Action(() =>
|
|||
|
|
{
|
|||
|
|
ProcessViewControl(false);
|
|||
|
|
_meterFwUpdate?.CompareAllMeterAndFileApps();
|
|||
|
|
FillDataGridWithAllInfos();
|
|||
|
|
SetControlsDownloadIsFinished();
|
|||
|
|
|
|||
|
|
if (_fileAppsSuccessfulWritten)
|
|||
|
|
{
|
|||
|
|
WaitForReboot();
|
|||
|
|
btnConnect_Click(this, null);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
var requiredUpdates = _meterFwUpdate?.GetFailedFileApps();
|
|||
|
|
var text = cbxManualControl.Checked ?
|
|||
|
|
StrUpdateErrorMessageManualControl : StrUpdateErrorMessage;
|
|||
|
|
if (requiredUpdates != null && requiredUpdates.Count > 0)
|
|||
|
|
{
|
|||
|
|
text += "\nFailed to update application:\n";
|
|||
|
|
FileApplications lastFile = null;
|
|||
|
|
foreach (var file in requiredUpdates)
|
|||
|
|
{
|
|||
|
|
if (lastFile == null || lastFile.AppId != file.AppId)
|
|||
|
|
{
|
|||
|
|
text += $"{file.AppName}\n";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
lastFile = file;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
MessageBoxShow(text, @"FAILED", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|||
|
|
}
|
|||
|
|
}));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
private void UploadFileControl(Boolean isActive)
|
|||
|
|
{
|
|||
|
|
if (isActive)
|
|||
|
|
{
|
|||
|
|
Invoke(new Action(() =>
|
|||
|
|
{
|
|||
|
|
ProcessViewControl(true);
|
|||
|
|
tmrProgressUpdate.Enabled = true;
|
|||
|
|
}));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Invoke(new Action(() =>
|
|||
|
|
{
|
|||
|
|
ProcessViewControl(false);
|
|||
|
|
SetControlsDownloadIsFinished();
|
|||
|
|
}));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void RebootControl(Boolean isActive)
|
|||
|
|
{
|
|||
|
|
if (isActive)
|
|||
|
|
{
|
|||
|
|
Invoke(new Action(() =>
|
|||
|
|
{
|
|||
|
|
_lastFwUpdateState = "";
|
|||
|
|
ProcessViewControl(true);
|
|||
|
|
tmrProgressUpdate.Enabled = true;
|
|||
|
|
}));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Invoke(new Action(() =>
|
|||
|
|
{
|
|||
|
|
ProcessViewControl(false);
|
|||
|
|
SetControlsDownloadIsFinished();
|
|||
|
|
|
|||
|
|
if (_rebootSucceeded)
|
|||
|
|
{
|
|||
|
|
WaitForReboot();
|
|||
|
|
btnConnect_Click(this, null);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
MessageBoxShow("Reboot failed!", @"FAILED", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|||
|
|
}
|
|||
|
|
}));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void DownloadFilesControl(Boolean isActive)
|
|||
|
|
{
|
|||
|
|
if (isActive)
|
|||
|
|
{
|
|||
|
|
Invoke(new Action(() =>
|
|||
|
|
{
|
|||
|
|
_lastFwUpdateState = "";
|
|||
|
|
ProcessViewControl(true);
|
|||
|
|
tmrProgressUpdate.Enabled = true;
|
|||
|
|
}));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Invoke(new Action(() =>
|
|||
|
|
{
|
|||
|
|
ProcessViewControl(false);
|
|||
|
|
_meterFwUpdate?.CompareAllMeterAndFileApps();
|
|||
|
|
FillDataGridWithAllInfos();
|
|||
|
|
SetControlsDownloadIsFinished();
|
|||
|
|
|
|||
|
|
if (!_fileAppsSuccessfulWritten)
|
|||
|
|
{
|
|||
|
|
var text = "DOWNLOAD FAILED!\n\n" +
|
|||
|
|
"If some files marked red:\n" +
|
|||
|
|
"Download these files by select \"Download\" and\n" +
|
|||
|
|
"then press \"Manual Download\" [Entire File Parts]!\n\n";
|
|||
|
|
var requiredUpdates = _meterFwUpdate?.GetFailedFileApps();
|
|||
|
|
if (requiredUpdates != null && requiredUpdates.Count > 0)
|
|||
|
|
{
|
|||
|
|
text += "\nFailed to update application:\n";
|
|||
|
|
FileApplications lastFile = null;
|
|||
|
|
foreach (var file in requiredUpdates)
|
|||
|
|
{
|
|||
|
|
if (lastFile == null || lastFile.AppId != file.AppId)
|
|||
|
|
{
|
|||
|
|
text += $"{file.AppName}\n";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
lastFile = file;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
MessageBoxShow(text, @"FAILED", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
const String text = "Download of selected files succeeded!\n\n" +
|
|||
|
|
"If some files marked red:\n" +
|
|||
|
|
"Download these files by select \"Download\" and\n" +
|
|||
|
|
"then press \"Manual Download\" [Entire File Parts]!\n\n" +
|
|||
|
|
"If all files are downloaded:\n" +
|
|||
|
|
"Select all green marked files \"Download\"," +
|
|||
|
|
"all red written \"Erasure required\" with \"Erase\" and\n" +
|
|||
|
|
"press [Trigger Upgrade] to finalize the update!";
|
|||
|
|
MessageBoxShow(text, @"SUCCESS",
|
|||
|
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|||
|
|
}
|
|||
|
|
}));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void TriggerUpdateControl(Boolean isActive)
|
|||
|
|
{
|
|||
|
|
if (isActive)
|
|||
|
|
{
|
|||
|
|
Invoke(new Action(() =>
|
|||
|
|
{
|
|||
|
|
_lastFwUpdateState = "";
|
|||
|
|
ProcessViewControl(true);
|
|||
|
|
tmrProgressUpdate.Enabled = true;
|
|||
|
|
}));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Invoke(new Action(() =>
|
|||
|
|
{
|
|||
|
|
ProcessViewControl(false);
|
|||
|
|
_meterFwUpdate?.CompareAllMeterAndFileApps();
|
|||
|
|
FillDataGridWithAllInfos();
|
|||
|
|
SetControlsDownloadIsFinished();
|
|||
|
|
|
|||
|
|
if (_fileAppsSuccessfulWritten)
|
|||
|
|
{
|
|||
|
|
const String text = "Trigger upgrade succeeded!\n\n" +
|
|||
|
|
"Press [Connect] for verification!";
|
|||
|
|
MessageBoxShow(text, @"SUCCESS",
|
|||
|
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
const String text = "TRIGGER UPGRADE FAILED\n\n" +
|
|||
|
|
"FW installation may be successfully executed!\n\n" +
|
|||
|
|
"Press [Connect] for verification!";
|
|||
|
|
|
|||
|
|
MessageBoxShow(text, @"Verification Needed",
|
|||
|
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|||
|
|
}
|
|||
|
|
}));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
private void VerifyFilesControl(Boolean isActive)
|
|||
|
|
{
|
|||
|
|
if (isActive)
|
|||
|
|
{
|
|||
|
|
Invoke(new Action(() =>
|
|||
|
|
{
|
|||
|
|
_lastFwUpdateState = "";
|
|||
|
|
ProcessViewControl(true);
|
|||
|
|
tmrProgressUpdate.Enabled = true;
|
|||
|
|
}));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Invoke(new Action(() =>
|
|||
|
|
{
|
|||
|
|
ProcessViewControl(false);
|
|||
|
|
_meterFwUpdate?.CompareAllMeterAndFileApps();
|
|||
|
|
FillDataGridWithAllInfos();
|
|||
|
|
SetControlsDownloadIsFinished();
|
|||
|
|
|
|||
|
|
if (!_fileAppsSuccessfulWritten)
|
|||
|
|
{
|
|||
|
|
const String text = "VERIFICATION FAILED!\n\n" +
|
|||
|
|
"If some files marked red:\n" +
|
|||
|
|
"Download these files by select \"Download\" and\n" +
|
|||
|
|
"then press \"Manual Download\" [Entire File Parts]!";
|
|||
|
|
MessageBoxShow(text, @"FAILED", MessageBoxButtons.OK,
|
|||
|
|
MessageBoxIcon.Error);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
const String text = "Verification of selected files succeeded!\n\n" +
|
|||
|
|
"If some files marked red:\n" +
|
|||
|
|
"Download these files by select \"Download\" and\n" +
|
|||
|
|
"then press \"Manual Download\" [Entire File Parts]!\n\n" +
|
|||
|
|
"If all files are verified green:\n" +
|
|||
|
|
"Select all green marked files \"Download\"," +
|
|||
|
|
"all red written \"Erasure required\" with \"Erase\" and\n" +
|
|||
|
|
"press [Trigger Upgrade] to finalize the update!";
|
|||
|
|
MessageBoxShow(text, @"SUCCESS",
|
|||
|
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|||
|
|
}
|
|||
|
|
}));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
#region Checks
|
|||
|
|
private void CheckManualControl()
|
|||
|
|
{
|
|||
|
|
if (cbxManualControl.Checked)
|
|||
|
|
{
|
|||
|
|
gbxManualDownload.Visible = true;
|
|||
|
|
gbxManualTriggerControl.Visible = true;
|
|||
|
|
gbxManualUploadAndVerification.Visible = true;
|
|||
|
|
gbxManualTimingControl.Visible = true;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
gbxManualDownload.Visible = false;
|
|||
|
|
gbxManualTriggerControl.Visible = false;
|
|||
|
|
gbxManualUploadAndVerification.Visible = false;
|
|||
|
|
gbxManualTimingControl.Visible = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
private Boolean CheckUpdateEnabled()
|
|||
|
|
{
|
|||
|
|
// enable file load and fix battery only if device is connected
|
|||
|
|
if (_currentGenesis != null)
|
|||
|
|
{
|
|||
|
|
btnOpenUpdateDirectory.Enabled = true;
|
|||
|
|
btnOpenPackageControlFile.Enabled = true;
|
|||
|
|
btnClearDisplay.Enabled = true;
|
|||
|
|
btnRebootMeter.Enabled = true;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
btnOpenUpdateDirectory.Enabled = false;
|
|||
|
|
btnOpenPackageControlFile.Enabled = false;
|
|||
|
|
btnClearDisplay.Enabled = false;
|
|||
|
|
btnRebootMeter.Enabled = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//this check has been placed here to force display update
|
|||
|
|
if (_meterFwUpdate != null && _currentGenesis != null &&
|
|||
|
|
// avoid activation on invalidated update files
|
|||
|
|
_packageFileToFileAppsValidated &&
|
|||
|
|
// avoid activation on unknown app installation status due to communication error
|
|||
|
|
_currentGenesis.MeterAppListVersion.All(f => f.Status != MeterAppState.Unknown) &&
|
|||
|
|
// check if anything has to be updated or erased
|
|||
|
|
(_currentGenesis.MeterAppListVersion.Any(f => f.Update) ||
|
|||
|
|
_currentGenesis.MeterAppListVersion.Any(f => f.Erase)))
|
|||
|
|
{
|
|||
|
|
SetControlDownloadsUnlocked();
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SetControlDownloadsLocked();
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private Boolean CheckRetryPossible()
|
|||
|
|
{
|
|||
|
|
return _meterFwUpdate != null && _meterFwUpdate.GetFailedFileApps().Count > 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void CheckPackageFileAndFileApps()
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
_packageFileToFileAppsValidated = _meterFwUpdate.ValidateFileAppsWithPackageFile();
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
if (_meterFwUpdate.CoreRevisionMaximum == null)
|
|||
|
|
MessageBoxShow(@"Core Revision missing in ADF!", @"FAILED",
|
|||
|
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (_packageFileToFileAppsValidated)
|
|||
|
|
{
|
|||
|
|
lblPackageFileLoadedInfo.ForeColor = Color.Green;
|
|||
|
|
lblPackageFileLoadedInfo.Text = StrPackageFileLoaded;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
lblPackageFileLoadedInfo.ForeColor = Color.Red;
|
|||
|
|
lblPackageFileLoadedInfo.Text = StrPackageFileToFileAppsMismatch;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
#region TimerControls
|
|||
|
|
private void tmrProgressUpdate_Tick(Object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
//cbxManualControl.Visible = true;
|
|||
|
|
if (_tryConnectPcb)
|
|||
|
|
{
|
|||
|
|
barOverallProgressUpdate.Value = barOverallProgressUpdate.Value + 1 > 100 ? 0 :
|
|||
|
|
barOverallProgressUpdate.Value + 1;
|
|||
|
|
barSingleProgressUpdate.Value = barSingleProgressUpdate.Value + 4 > 100 ? 0 :
|
|||
|
|
barSingleProgressUpdate.Value + 4;
|
|||
|
|
lblOverall.Text = StrOverallProcess;
|
|||
|
|
}
|
|||
|
|
else if (_meterResetProcessActive)
|
|||
|
|
{
|
|||
|
|
lblOverall.Text = @"Reboot Meter with pseudo FW update";
|
|||
|
|
lblActualProcess.Text = _meterResetPsu?.GetActualOperation();
|
|||
|
|
|
|||
|
|
barOverallProgressUpdate.Value = barOverallProgressUpdate.Value + 1 > 100 ? 0 :
|
|||
|
|
barOverallProgressUpdate.Value + 1;
|
|||
|
|
barOverallProgressUpdate.Update();
|
|||
|
|
|
|||
|
|
var singleProgress = (Int32)(_meterResetPsu?.SingleFileProcessCtrPercent ?? 0);
|
|||
|
|
barSingleProgressUpdate.Value = singleProgress > 100 ? 100 : singleProgress;
|
|||
|
|
_lastSingleProgress = singleProgress;
|
|||
|
|
barSingleProgressUpdate.Update();
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
lblOverall.Text = _meterFwUpdate?.GetFwUpdateStateOperation();
|
|||
|
|
lblActualProcess.Text = _meterFwUpdate?.GetActualOperation();
|
|||
|
|
|
|||
|
|
var overallProgress = (Int32)(_meterFwUpdate?.OverallProcessCtrPercent ?? 0);
|
|||
|
|
barOverallProgressUpdate.Value = overallProgress > 100 ? 100 : overallProgress;
|
|||
|
|
barOverallProgressUpdate.Update();
|
|||
|
|
|
|||
|
|
var singleProgress = (Int32)(_meterFwUpdate?.SingleFileProcessCtrPercent ?? 0);
|
|||
|
|
if (_meterFwUpdate?.GetFwUpdateStateOperation() != _lastFwUpdateState)
|
|||
|
|
{
|
|||
|
|
_lastFwUpdateState = _meterFwUpdate?.GetFwUpdateStateOperation();
|
|||
|
|
FillDataGridWithAllInfos();
|
|||
|
|
lblWaitingForMeterResponse.Visible = false;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
//if the communication gets frozen
|
|||
|
|
lblWaitingForMeterResponse.Visible = _lastSingleProgress == singleProgress;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
barSingleProgressUpdate.Value = singleProgress > 100 ? 100 : singleProgress;
|
|||
|
|
_lastSingleProgress = singleProgress;
|
|||
|
|
barSingleProgressUpdate.Update();
|
|||
|
|
}
|
|||
|
|
SetTimeDisplay();
|
|||
|
|
if (_currentGenesis != null)
|
|||
|
|
cbxMetUpdPerm.Checked = (_currentGenesis.MetrologyUpgradePermission & 0xFF) == 0xFF;
|
|||
|
|
Update();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void SetTimeDisplay()
|
|||
|
|
{
|
|||
|
|
var time = DateTimeOffset.UtcNow;
|
|||
|
|
var timeSpan = time - _startTime;
|
|||
|
|
lblUpdateTime.Text = $@"{(UInt32)timeSpan.TotalMinutes}:{timeSpan.Seconds:00}";
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
#region Buttons
|
|||
|
|
private void btnConnect_Click(Object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (_resetTimeMeasurement)
|
|||
|
|
{
|
|||
|
|
_startTime = DateTimeOffset.UtcNow;
|
|||
|
|
_resetTimeMeasurement = false;
|
|||
|
|
}
|
|||
|
|
Connect();
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <remarks date="2023-Jan-18" author="Thomas Wiedebusch">
|
|||
|
|
/// - Enable update of Genesis Flow in Genesis Tool Box.
|
|||
|
|
/// </remarks>
|
|||
|
|
private void btnOpenPackageControlFile_Click(Object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
//reload last path
|
|||
|
|
dlgOpenPackageFile.InitialDirectory = DefaultPackageFile;
|
|||
|
|
|
|||
|
|
dlgOpenPackageFile.DefaultExt = ".txt";
|
|||
|
|
if (dlgOpenPackageFile.ShowDialog() != DialogResult.OK)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var packageFilePathName = dlgOpenPackageFile.FileName;
|
|||
|
|
|
|||
|
|
DefaultPackageFile = packageFilePathName;
|
|||
|
|
|
|||
|
|
//copy path to binary file load
|
|||
|
|
//if (String.IsNullOrEmpty(DefaultBinaryPath))
|
|||
|
|
// dlgBinaryPath.SelectedPath = Path.GetFullPath(packageFilePathName);
|
|||
|
|
|
|||
|
|
tbxPackageFilePathName.Text = packageFilePathName;
|
|||
|
|
if (_meterFwUpdate == null)
|
|||
|
|
{
|
|||
|
|
_meterFwUpdate = new MeterFwUpdate(_currentGenesis, true);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (_meterFwUpdate == null)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (_meterFwUpdate.LoadPackageFile(packageFilePathName))
|
|||
|
|
{
|
|||
|
|
CheckPackageFileAndFileApps();
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
lblPackageFileLoadedInfo.ForeColor = Color.Red;
|
|||
|
|
lblPackageFileLoadedInfo.Text = StrPackageFileInvalid;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
CheckUpdateEnabled();
|
|||
|
|
_resetTimeMeasurement = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void btnOpenUpdateDirectory_Click(Object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
//reload last file path
|
|||
|
|
dlgBinaryPath.SelectedPath = DefaultBinaryPath;
|
|||
|
|
|
|||
|
|
if (dlgBinaryPath.ShowDialog() != DialogResult.OK)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var binaryFilePath = dlgBinaryPath.SelectedPath;
|
|||
|
|
DefaultBinaryPath = binaryFilePath;
|
|||
|
|
|
|||
|
|
//copy path to package file load
|
|||
|
|
//if (String.IsNullOrEmpty(DefaultPackageFile))
|
|||
|
|
// dlgOpenPackageFile.InitialDirectory = binaryFilePath;
|
|||
|
|
|
|||
|
|
tbxBinaryPath.Text = binaryFilePath;
|
|||
|
|
|
|||
|
|
var meterFwUpdate = new MeterFwUpdate(_currentGenesis, true);
|
|||
|
|
if (meterFwUpdate.LoadFileApps(binaryFilePath))
|
|||
|
|
{
|
|||
|
|
lblFileAppsLoadedInfo.ForeColor = Color.Green;
|
|||
|
|
lblFileAppsLoadedInfo.Text = StrFileAppsLoaded;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
lblFileAppsLoadedInfo.ForeColor = Color.Red;
|
|||
|
|
lblFileAppsLoadedInfo.Text = StrUpdatePathEmpty;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
PushFwFile(meterFwUpdate);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Upload selected update files and compare them with update files
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void btnVerifyFiles_Click(Object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (_currentGenesis == null || _meterFwUpdate?.FileApps == null)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SetControlsDownloadIsOngoing();
|
|||
|
|
VerifyFilesControl(true);
|
|||
|
|
|
|||
|
|
Task.Factory.StartNew(() =>
|
|||
|
|
{
|
|||
|
|
_fileAppsSuccessfulWritten = _meterFwUpdate.ManualVerifyFiles();
|
|||
|
|
Thread.Sleep(1000);
|
|||
|
|
}).ContinueWith(delegate
|
|||
|
|
{
|
|||
|
|
VerifyFilesControl(false);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Download selected update files entirely
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void btnDownloadFiles_Click(Object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (_currentGenesis == null || _meterFwUpdate?.FileApps == null)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Int32 fileSizePartKb;
|
|||
|
|
Int32 addRetryTimeoutMs;
|
|||
|
|
if (string.IsNullOrEmpty(cbFilePartSize.SelectedItem.ToString()) ||
|
|||
|
|
!int.TryParse(cbFilePartSize.SelectedItem.ToString(), out fileSizePartKb))
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
_meterFwUpdate.MaxPartialFileDataSize = fileSizePartKb * 1024;
|
|||
|
|
|
|||
|
|
if (string.IsNullOrEmpty(cbAddRetryTimeout.SelectedItem.ToString()) ||
|
|||
|
|
!int.TryParse(cbAddRetryTimeout.SelectedItem.ToString(), out addRetryTimeoutMs))
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
_currentGenesis.RequestProtocol.AdditionalRetryTimeoutMs = addRetryTimeoutMs;
|
|||
|
|
|
|||
|
|
SetControlsDownloadIsOngoing();
|
|||
|
|
DownloadFilesControl(true);
|
|||
|
|
|
|||
|
|
Task.Factory.StartNew(() =>
|
|||
|
|
{
|
|||
|
|
_fileAppsSuccessfulWritten = _meterFwUpdate.ManualDownloadAllFileApps();
|
|||
|
|
Thread.Sleep(1000);
|
|||
|
|
}).ContinueWith(delegate
|
|||
|
|
{
|
|||
|
|
DownloadFilesControl(false);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Reboot the meter
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
/// <remarks date="2022-Aug-11" author="Thomas Wiedebusch">
|
|||
|
|
/// - Initial
|
|||
|
|
/// </remarks>
|
|||
|
|
private void btnRebootMeter_Click(Object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (_currentGenesis == null)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// reset the time
|
|||
|
|
_startTime = DateTimeOffset.UtcNow;
|
|||
|
|
|
|||
|
|
// clear display before store configuration
|
|||
|
|
btnClearDisplay_Click(this, null);
|
|||
|
|
|
|||
|
|
_meterResetPsu = new MeterResetPsu(_currentGenesis)
|
|||
|
|
{
|
|||
|
|
StoreConfigEnable = cbxStoreConfigEnable.Checked
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
_meterResetProcessActive = true;
|
|||
|
|
|
|||
|
|
SetControlsDownloadIsOngoing();
|
|||
|
|
RebootControl(true);
|
|||
|
|
|
|||
|
|
Task.Factory.StartNew(() =>
|
|||
|
|
{
|
|||
|
|
_rebootSucceeded = _meterResetPsu.MeterResetPsuExecute();
|
|||
|
|
Thread.Sleep(1000);
|
|||
|
|
_meterResetProcessActive = false;
|
|||
|
|
|
|||
|
|
}).ContinueWith(delegate
|
|||
|
|
{
|
|||
|
|
RebootControl(false);
|
|||
|
|
_meterResetPsu.Dispose();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Download remaining files parts from previous download
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void btnRetryFileParts_Click(Object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (_currentGenesis == null || _meterFwUpdate?.FileApps == null)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SetControlsDownloadIsOngoing();
|
|||
|
|
DownloadFilesControl(true);
|
|||
|
|
|
|||
|
|
Task.Factory.StartNew(() =>
|
|||
|
|
{
|
|||
|
|
_fileAppsSuccessfulWritten = _meterFwUpdate.ManualDownloadRemainingFileAppsParts();
|
|||
|
|
Thread.Sleep(1000);
|
|||
|
|
}).ContinueWith(delegate
|
|||
|
|
{
|
|||
|
|
DownloadFilesControl(false);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Preselect "Download" trigger marks on successfully downloaded files
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void btnPrepareTrigger_Click(Object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (_meterFwUpdate == null)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
_meterFwUpdate.PrepareTrigger();
|
|||
|
|
FillDataGridWithAllInfos();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Build update control file and trigger update of selected files
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void btnTriggerUpdate_Click(Object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (_currentGenesis == null || _meterFwUpdate?.FileApps == null)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SetControlsDownloadIsOngoing();
|
|||
|
|
TriggerUpdateControl(true);
|
|||
|
|
|
|||
|
|
Task.Factory.StartNew(() =>
|
|||
|
|
{
|
|||
|
|
_fileAppsSuccessfulWritten = _meterFwUpdate.ManualTriggerUpgrade();
|
|||
|
|
Thread.Sleep(1000);
|
|||
|
|
}).ContinueWith(delegate
|
|||
|
|
{
|
|||
|
|
TriggerUpdateControl(false);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Automatic update of entire FW
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void btnUpdateFw_Click(Object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (_currentGenesis == null || _meterFwUpdate?.FileApps == null)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (_meterFwUpdate != null)
|
|||
|
|
_meterFwUpdate.StoreConfigEnable = cbxStoreConfigEnable.Checked;
|
|||
|
|
|
|||
|
|
SetControlsDownloadIsOngoing();
|
|||
|
|
AutomaticUpdateControl(true);
|
|||
|
|
|
|||
|
|
_startTime = DateTimeOffset.UtcNow;
|
|||
|
|
_resetTimeMeasurement = false;
|
|||
|
|
|
|||
|
|
if (string.IsNullOrEmpty(cbFilePartSize.SelectedItem.ToString()) ||
|
|||
|
|
!int.TryParse(cbFilePartSize.SelectedItem.ToString(), out var fileSizePartKb))
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
_meterFwUpdate.MaxPartialFileDataSize = fileSizePartKb * 1024;
|
|||
|
|
|
|||
|
|
if (string.IsNullOrEmpty(cbAddRetryTimeout.SelectedItem.ToString()) ||
|
|||
|
|
!int.TryParse(cbAddRetryTimeout.SelectedItem.ToString(), out var addRetryTimeoutMs))
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
_currentGenesis.RequestProtocol.AdditionalRetryTimeoutMs = addRetryTimeoutMs;
|
|||
|
|
|
|||
|
|
Task.Factory.StartNew(() =>
|
|||
|
|
{
|
|||
|
|
_fileAppsSuccessfulWritten = _meterFwUpdate.UpdateMeterFw();
|
|||
|
|
Thread.Sleep(1000);
|
|||
|
|
}).ContinueWith(delegate
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
AutomaticUpdateControl(false);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void btnStopFwUpdate_Click(Object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (_meterFwUpdate != null)
|
|||
|
|
{
|
|||
|
|
_meterFwUpdate.StopUpdateProcess = true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void btnResetAll_Click(Object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
btnStopFwUpdate_Click(this, null);
|
|||
|
|
_meterFwUpdate?.ResetAll();
|
|||
|
|
Init();
|
|||
|
|
FillDataGridWithAllInfos();
|
|||
|
|
CheckUpdateEnabled();
|
|||
|
|
_currentGenesis.Logout();
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
#region CheckBoxes
|
|||
|
|
private void cbxUseOfflinePwds_CheckedChanged(Object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
cbxUseOfflinePwds.ForeColor = cbxUseOfflinePwds.Checked ? Color.Red : Color.Black;
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// File parts are consecutive, stop process at first failed part and retry from
|
|||
|
|
/// this part on all others behind
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void cbxConsecutiveFilePartsRetryEnable_CheckedChanged(Object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (_meterFwUpdate == null)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
_meterFwUpdate.ConsecutiveFilePartsRetryEnable =
|
|||
|
|
cbxConsecutiveFilePartsRetryEnable.Checked;
|
|||
|
|
cbxSingleFilePartsRetryEnable.Checked = false;
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// Failed file parts are somewhere in between succeeded parts and will be retried separately
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void cbxSingleFilePartsRetryEnable_CheckedChanged(Object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (_meterFwUpdate == null)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
_meterFwUpdate.SingleFilePartsRetryEnable =
|
|||
|
|
cbxSingleFilePartsRetryEnable.Checked;
|
|||
|
|
cbxConsecutiveFilePartsRetryEnable.Checked = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void cbxStoreConfigEnable_CheckedChanged(Object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (_meterFwUpdate != null)
|
|||
|
|
_meterFwUpdate.StoreConfigEnable = cbxStoreConfigEnable.Checked;
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// Activation of manual control buttons for individual update procedure
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void cbxManualControl_CheckedChanged_1(Object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
CheckManualControl();
|
|||
|
|
_meterFwUpdate?.CompareAllMeterAndFileApps();
|
|||
|
|
FillDataGridWithAllInfos();
|
|||
|
|
CheckUpdateEnabled();
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
#region ExternalCalls
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="slot"></param>
|
|||
|
|
/// <param name="binaryPath"></param>
|
|||
|
|
/// <param name="packageInfoPath"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
/// <remarks date="2023-Jan-18" author="Thomas Wiedebusch">
|
|||
|
|
/// - Enable update of Genesis Flow in Genesis Tool Box.
|
|||
|
|
/// </remarks>
|
|||
|
|
public Boolean Prepare(Int32 slot, String binaryPath, String packageInfoPath)
|
|||
|
|
{
|
|||
|
|
_updateGui = false;
|
|||
|
|
cbComSlot.SelectedItem = slot;
|
|||
|
|
|
|||
|
|
Connect();
|
|||
|
|
var retries = 40;
|
|||
|
|
while (_currentGenesis == null || !_currentGenesis.IsLoggedOn)
|
|||
|
|
{
|
|||
|
|
Thread.Sleep(1000);
|
|||
|
|
retries -= 1;
|
|||
|
|
if (retries <= 0)
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Thread.Sleep(10000);
|
|||
|
|
tbxBinaryPath.Text = binaryPath;
|
|||
|
|
if (_meterFwUpdate == null)
|
|||
|
|
{
|
|||
|
|
_meterFwUpdate = new MeterFwUpdate(_currentGenesis, true);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (_meterFwUpdate == null)
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (_meterFwUpdate.LoadFileApps(binaryPath))
|
|||
|
|
{
|
|||
|
|
lblFileAppsLoadedInfo.ForeColor = Color.Green;
|
|||
|
|
lblFileAppsLoadedInfo.Text = StrFileAppsLoaded;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
lblFileAppsLoadedInfo.ForeColor = Color.Red;
|
|||
|
|
lblFileAppsLoadedInfo.Text = StrUpdatePathEmpty;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
CheckPackageFileAndFileApps();
|
|||
|
|
|
|||
|
|
if (_currentGenesis == null)
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
_meterFwUpdate?.AssignGenesis(_currentGenesis);
|
|||
|
|
_meterFwUpdate?.CompareAllMeterAndFileApps();
|
|||
|
|
FillDataGridWithAllInfos();
|
|||
|
|
|
|||
|
|
|
|||
|
|
tbxPackageFilePathName.Text = packageInfoPath;
|
|||
|
|
if (_meterFwUpdate == null)
|
|||
|
|
{
|
|||
|
|
_meterFwUpdate = new MeterFwUpdate(_currentGenesis, true);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (_meterFwUpdate == null)
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (_meterFwUpdate.LoadPackageFile(packageInfoPath))
|
|||
|
|
{
|
|||
|
|
CheckPackageFileAndFileApps();
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
lblPackageFileLoadedInfo.ForeColor = Color.Red;
|
|||
|
|
lblPackageFileLoadedInfo.Text = StrPackageFileInvalid;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (CheckUpdateEnabled())
|
|||
|
|
{
|
|||
|
|
btnUpdateFw_Click(null, EventArgs.Empty);
|
|||
|
|
//wait for response return e
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
public MsgEventargs LastMsgEvent;
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
public class MsgEventargs : EventArgs
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// Message text
|
|||
|
|
/// </summary>
|
|||
|
|
public String Text;
|
|||
|
|
/// <summary>
|
|||
|
|
/// Title
|
|||
|
|
/// </summary>
|
|||
|
|
public String Caption;
|
|||
|
|
/// <summary>
|
|||
|
|
/// Buttons
|
|||
|
|
/// </summary>
|
|||
|
|
public MessageBoxButtons Buttons;
|
|||
|
|
/// <summary>
|
|||
|
|
/// The Icon
|
|||
|
|
/// </summary>
|
|||
|
|
public MessageBoxIcon Icon;
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
public event EventHandler<MsgEventargs> OnMsgPopUp;
|
|||
|
|
private void MessageBoxShow(String text, String caption, MessageBoxButtons buttons, MessageBoxIcon icon)
|
|||
|
|
{
|
|||
|
|
if (_updateGui)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show(text, caption, buttons, icon);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
LastMsgEvent = new MsgEventargs() { Text = text, Caption = caption, Buttons = buttons, Icon = icon };
|
|||
|
|
OnMsgPopUp?.Invoke(this, LastMsgEvent);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
#region User Controls
|
|||
|
|
private void tabDb_Click(Object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void tabFwSources_SelectedIndexChanged(Object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (tabFwSources.SelectedTab == tabLocalFile)
|
|||
|
|
{
|
|||
|
|
CheckSelectionChanged(FwSource.File);
|
|||
|
|
}
|
|||
|
|
else if (tabFwSources.SelectedTab == tabProduction)
|
|||
|
|
{
|
|||
|
|
CheckSelectionChanged(FwSource.File);
|
|||
|
|
}
|
|||
|
|
else if (tabFwSources.SelectedTab == tabDb)
|
|||
|
|
{
|
|||
|
|
CheckSelectionChanged(FwSource.Db);
|
|||
|
|
|
|||
|
|
|
|||
|
|
cbxFilterFwDn.Items.Add("ALL");
|
|||
|
|
|
|||
|
|
cbxFilterFWType.Items.Add("ALL");
|
|||
|
|
|
|||
|
|
foreach (MeterSize suit in (MeterSize[])Enum.GetValues(typeof(MeterSize)))
|
|||
|
|
{
|
|||
|
|
cbxFilterFwDn.Items.Add(suit);
|
|||
|
|
}
|
|||
|
|
cbxFilterFwDn.SelectedIndex = 0;
|
|||
|
|
|
|||
|
|
cbxFilterFWType.Items.Add(CordonelFWTypeEnum.EMEA_433);
|
|||
|
|
cbxFilterFWType.Items.Add(CordonelFWTypeEnum.EMEA_868);
|
|||
|
|
cbxFilterFWType.Items.Add(CordonelFWTypeEnum.NA);
|
|||
|
|
cbxFilterFWType.SelectedIndex = 0;
|
|||
|
|
|
|||
|
|
|
|||
|
|
btnGetFWFiles_Click(sender, e);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
MessageBox.Show(@"No Tab selected!");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//tabFwSources.SelectedTab = tabLocalFile;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
private void CheckSelectionChanged(FwSource newSource)
|
|||
|
|
{
|
|||
|
|
// ReSharper disable once RedundantCheckBeforeAssignment
|
|||
|
|
if (newSource == _fwSource)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
_fwSource = newSource;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void PushFwFile(MeterFwUpdate meterFwUpdate)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
|
|||
|
|
_meterFwUpdate = meterFwUpdate;
|
|||
|
|
|
|||
|
|
CheckPackageFileAndFileApps();
|
|||
|
|
|
|||
|
|
if (_currentGenesis == null)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
_meterFwUpdate?.AssignGenesis(_currentGenesis);
|
|||
|
|
_meterFwUpdate?.CompareAllMeterAndFileApps();
|
|||
|
|
FillDataGridWithAllInfos();
|
|||
|
|
CheckUpdateEnabled();
|
|||
|
|
_resetTimeMeasurement = true;
|
|||
|
|
}
|
|||
|
|
private void btnGetFWFiles_Click(Object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
var isDeveloper = chbFilterIsDeveloper.Checked;
|
|||
|
|
|
|||
|
|
|
|||
|
|
var url = $"{ServiceUrls.FileContentControllerUrl()}GetFwFiles?FileIsForDeveloperOnly={isDeveloper}";
|
|||
|
|
if (cbxFilterFwDn.SelectedItem.ToString() != "ALL")
|
|||
|
|
{
|
|||
|
|
var myMeterSize = ((MeterSize)cbxFilterFwDn.SelectedItem).GetHashCode();
|
|||
|
|
url += $"&CordonelFwFile_Dn={myMeterSize}";
|
|||
|
|
}
|
|||
|
|
if (cbxFilterFWType.SelectedItem.ToString() != "ALL")
|
|||
|
|
{
|
|||
|
|
var fwTypeEnum = ((CordonelFWTypeEnum)cbxFilterFWType.SelectedItem).GetHashCode();
|
|||
|
|
url += $"&CordonelFwFile_Type={fwTypeEnum}";
|
|||
|
|
}
|
|||
|
|
url += "&FileCategoryID=1";
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
var result = LocalWebRequest.GetRequest(url, 30000);
|
|||
|
|
var a = JsonConvert.DeserializeObject<List<ClusteredFile>>(result);
|
|||
|
|
|
|||
|
|
dgvFiles.DataSource = a?.OrderByDescending(o => o.FileDate).ToList();
|
|||
|
|
|
|||
|
|
for (var i = 0; i < dgvFiles.ColumnCount; i++)
|
|||
|
|
{
|
|||
|
|
dgvFiles.Columns[i].Visible = i < 5;
|
|||
|
|
}
|
|||
|
|
dgvFiles.AutoResizeColumns();
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
_currentGenesis?.WriteLog("Cannot access database: " + ex.Message);
|
|||
|
|
throw;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <remarks date="2023-Jan-18" author="Thomas Wiedebusch">
|
|||
|
|
/// - Enable update of Genesis Flow in Genesis Tool Box.
|
|||
|
|
/// </remarks>
|
|||
|
|
private void dgvFiles_CellContentClick(Object sender, DataGridViewCellEventArgs e)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
var parentFilId = (Int32)dgvFiles.Rows[e.RowIndex].Cells[1].Value;
|
|||
|
|
|
|||
|
|
var url = $"{ServiceUrls.FileContentControllerUrl()}GetFileParts?ParentFileId={parentFilId}&readContent=true";
|
|||
|
|
|
|||
|
|
var result = LocalWebRequest.GetRequest(url, 20000);
|
|||
|
|
var a = JsonConvert.DeserializeObject<List<FilePart>>(result);
|
|||
|
|
|
|||
|
|
lblFwNameSelected.Text = dgvFiles.Rows[e.RowIndex].Cells[1].Value.ToString();
|
|||
|
|
lblSelectedID.Text = parentFilId.ToString();
|
|||
|
|
|
|||
|
|
_meterFwUpdate = new MeterFwUpdate(_currentGenesis, true);
|
|||
|
|
|
|||
|
|
var fileApps = new List<FileApplications>();
|
|||
|
|
|
|||
|
|
if (a != null)
|
|||
|
|
foreach (var item in a)
|
|||
|
|
{
|
|||
|
|
if (item.FileName.ToLower().EndsWith(".bin"))
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
|
|||
|
|
var fileApplication = new FileApplications(item.FileName)
|
|||
|
|
{
|
|||
|
|
BinData = new List<Byte>(item.FileContent.ToList())
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
fileApps.Add(fileApplication);
|
|||
|
|
}
|
|||
|
|
else if (item.FileName.ToLower().EndsWith(".txt"))
|
|||
|
|
{
|
|||
|
|
//encode content
|
|||
|
|
|
|||
|
|
var enc = new System.Text.ASCIIEncoding();
|
|||
|
|
var controlFileContent = enc.GetString(item.FileContent.ToArray());
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
_meterFwUpdate.LoadPackageFileFromText(controlFileContent);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
_meterFwUpdate.LoadFileApps(fileApps);
|
|||
|
|
|
|||
|
|
_meterFwUpdate?.CompareAllMeterAndFileApps();
|
|||
|
|
_meterFwUpdate?.AssignGenesis(_currentGenesis);
|
|||
|
|
FillDataGridWithAllInfos();
|
|||
|
|
|
|||
|
|
CheckPackageFileAndFileApps();
|
|||
|
|
CheckUpdateEnabled();
|
|||
|
|
_resetTimeMeasurement = true;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
private void btnClearDisplay_Click(Object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (_currentGenesis == null)
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
lblOverall.Text = @"Set display to normal operation";
|
|||
|
|
lblOverall.Visible = true;
|
|||
|
|
Update();
|
|||
|
|
|
|||
|
|
if (!_currentGenesis.IsLoggedOn)
|
|||
|
|
{
|
|||
|
|
_currentGenesis.ReLogin();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
_currentGenesis.SetLcdText(true, new Byte[] { 0x00, 0x00, 0x00, 0x00 });
|
|||
|
|
_currentGenesis.WriteRegister(Register.Genesisflow.StoreConfiguration, 1);
|
|||
|
|
_currentGenesis.Logout();
|
|||
|
|
lblOverall.Visible = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|