FwUpdateBuilder: - changed single FwUpdate package detect and load

This commit is contained in:
Thomas Wiedebusch
2023-02-18 15:24:18 +01:00
parent 8aaeb27f17
commit 786f786343
9 changed files with 265 additions and 188 deletions
@@ -2191,7 +2191,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
} }
// Wait for storing // Wait for storing
Thread.Sleep(400); Thread.Sleep(500);
//TODO enable this for R1.2.x //TODO enable this for R1.2.x
if (a.Key.AppName == "SENSUSRADIO" || a.Key.AppName == "NA2WALARMS") if (a.Key.AppName == "SENSUSRADIO" || a.Key.AppName == "NA2WALARMS")
{ {
@@ -2220,7 +2220,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
catch (Exception) catch (Exception)
{ {
// ignored return false;
} }
return allConfigRegisters == 0; return allConfigRegisters == 0;
@@ -19,7 +19,7 @@ namespace Xylem.Common.Logic.ProductionOrderCore.FW
public Int32 Id; public Int32 Id;
/// <summary> /// <summary>
/// Frequency in MHz, null if not used or not assigned /// Frequency in MHz, null if not used or not assigned or for all frequencies
/// </summary> /// </summary>
public Int32? RadioFrequencyMhz; public Int32? RadioFrequencyMhz;
@@ -48,11 +48,6 @@ namespace Xylem.ServiceFwUpdate.Common.FwUpdateDb
/// </summary> /// </summary>
public List<FilePart> DbFwUpdateConfigFiles { get; private set; } public List<FilePart> DbFwUpdateConfigFiles { get; private set; }
/// <summary>
/// Cordonel FW packages.
/// </summary>
public List<ClusteredFile> DbCordonelFwPackages { get; private set; }
/// <summary> /// <summary>
/// Cordonel FW packages information. /// Cordonel FW packages information.
/// </summary> /// </summary>
@@ -363,39 +358,6 @@ namespace Xylem.ServiceFwUpdate.Common.FwUpdateDb
} }
} }
///// <summary>
///// Get all Cordonel FW packages info files from DB.
///// </summary>
///// <returns>true if successful</returns>
///// <remarks date="2021-Apr-08" author="Thomas Wiedebusch">
///// - Initial.
///// </remarks>
//public Boolean GetAllCordonelFwInfoFilesFromDb()
//{
// if (DbCordonelFwPackages == null) DbCordonelFwPackages = new List<ClusteredFile>();
// DbCordonelFwPackages.Clear();
// try
// {
// var url = ServiceUrls.ListAllFwPackages();
// var requestResponse = LocalWebRequest.GetRequest(url, 10000);
// if (string.IsNullOrEmpty(requestResponse))
// {
// DbIsConnected = false;
// return false;
// }
// DbIsConnected = true;
// DbCordonelFwPackages = JsonConvert.DeserializeObject<List<ClusteredFile>>(requestResponse);
// return DbCordonelFwPackages != null && DbCordonelFwPackages.Count != 0;
// }
// catch (Exception)
// {
// DbIsConnected = false;
// return false;
// }
//}
/// <summary> /// <summary>
/// Load the latest FW update SW package from DB. /// Load the latest FW update SW package from DB.
/// </summary> /// </summary>
@@ -809,7 +771,7 @@ namespace Xylem.ServiceFwUpdate.Common.FwUpdateDb
JsonConvert.DeserializeObject<List<CordonelFwPackageInfo>>(requestResponse); JsonConvert.DeserializeObject<List<CordonelFwPackageInfo>>(requestResponse);
return DbCordonelFwPackagesInfo != null && DbCordonelFwPackagesInfo.Count != 0; return DbCordonelFwPackagesInfo != null && DbCordonelFwPackagesInfo.Count != 0;
} }
catch (Exception e) catch (Exception)
{ {
DbIsConnected = false; DbIsConnected = false;
return false; return false;
@@ -78,9 +78,9 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder.Const
GetCordonelSerialNumbersFromDb, GetCordonelSerialNumbersFromDb,
/// <summary> /// <summary>
/// Load all available FW packages from DB /// Load all available FW packages information from DB
/// </summary> /// </summary>
GetFwPackagesFromDb, GetFwPackagesInfosFromDb,
/// <summary> /// <summary>
/// Load all registered update operators from DB /// Load all registered update operators from DB
@@ -98,7 +98,7 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder.Const
UserRegistration, UserRegistration,
/// <summary> /// <summary>
/// Updatedata tables /// Update data tables
/// </summary> /// </summary>
UpdateDataTables, UpdateDataTables,
@@ -151,13 +151,12 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
/// </summary> /// </summary>
private readonly List<CordonelDeviceInfo> _cordonelUpdateList = new List<CordonelDeviceInfo>(); private readonly List<CordonelDeviceInfo> _cordonelUpdateList = new List<CordonelDeviceInfo>();
//private String _fwPackageCordonelPcbId;
///<summary> ///<summary>
/// The FW-Update package is a collection of all needed applications and settings to install into the Cordonel! /// The FW-Update package is a collection of all needed applications and settings to install into the Cordonel!
/// This information will be passed to the FW-Update SW if any Cordonel requires this package. /// This information will be passed to the FW-Update SW if any Cordonel requires this package.
/// </summary> /// </summary>
private CordonelFirmware _fwUpdatePackage = new CordonelFirmware(); private CordonelFirmware _fwUpdatePackage = new CordonelFirmware();
///<summary> ///<summary>
/// All Cordonel FW package information needed to select the right package for installation! This is going to be /// All Cordonel FW package information needed to select the right package for installation! This is going to be
/// filled with information from the read packages from DB. /// filled with information from the read packages from DB.
@@ -170,6 +169,7 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
private readonly List<String> _regionSearchItems = new List<String>(); private readonly List<String> _regionSearchItems = new List<String>();
private readonly List<String> _radioSearchItems = new List<String>(); private readonly List<String> _radioSearchItems = new List<String>();
private readonly List<String> _sizeSearchItems = new List<String>(); private readonly List<String> _sizeSearchItems = new List<String>();
///<summary> ///<summary>
/// The FW-Update update capability is internally used to check core revision, metrology, region, frequency a.s.o. /// The FW-Update update capability is internally used to check core revision, metrology, region, frequency a.s.o.
/// This information will only be used by the FW Update Builder! /// This information will only be used by the FW Update Builder!
@@ -186,7 +186,6 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
private String _fwUpdateSafeName; private String _fwUpdateSafeName;
private FwUpdateSafeDb _fwUpdateSafeDb; private FwUpdateSafeDb _fwUpdateSafeDb;
private Int32 _updateOperatorId; private Int32 _updateOperatorId;
//private readonly List<MeterFwUpdateRuler> _meterFwUpdateRuler = new List<MeterFwUpdateRuler>();
/// <summary> /// <summary>
/// Reminder to avoid repeated reading of DB contents and reset of selection if item has already been assigned /// Reminder to avoid repeated reading of DB contents and reset of selection if item has already been assigned
@@ -224,7 +223,7 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
/// <summary> /// <summary>
/// Name for firmware update software including the namespace /// Name for firmware update software including the namespace
/// </summary> /// </summary>
public const String FwUpdateSwFullName = "Xylem.ServiceFwUpdate.Ui." + FwUpdateProjectName; private const String FwUpdateSwFullName = "Xylem.ServiceFwUpdate.Ui." + FwUpdateProjectName;
/// <summary> /// <summary>
/// Path for FW-Update safes /// Path for FW-Update safes
@@ -346,8 +345,8 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
LoadDbCordonelSerialNumbersTask(); LoadDbCordonelSerialNumbersTask();
break; break;
case ProcessState.GetFwPackagesFromDb: case ProcessState.GetFwPackagesInfosFromDb:
LoadDbCordonelFwPackagesTask(); LoadDbCordonelFwPackagesInfosTask();
break; break;
case ProcessState.DbAccessLocked: case ProcessState.DbAccessLocked:
@@ -438,7 +437,7 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
case ProcessState.GetFwUpdateOperatorsFromDb: case ProcessState.GetFwUpdateOperatorsFromDb:
case ProcessState.GetCordonelProductionOrdersFromDb: case ProcessState.GetCordonelProductionOrdersFromDb:
case ProcessState.GetCustomersFromDb: case ProcessState.GetCustomersFromDb:
case ProcessState.GetFwPackagesFromDb: case ProcessState.GetFwPackagesInfosFromDb:
case ProcessState.GetCordonelSerialNumbersFromDb: case ProcessState.GetCordonelSerialNumbersFromDb:
case ProcessState.GetFwUpdateSafesInfosFromDb: case ProcessState.GetFwUpdateSafesInfosFromDb:
case ProcessState.GetReportsFromDb: case ProcessState.GetReportsFromDb:
@@ -687,7 +686,7 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
UiInvoker.ToolStripLabelInvoker(lblStatusDbConnect, ColorSuccess, Resources.StrReadingFwPackages); UiInvoker.ToolStripLabelInvoker(lblStatusDbConnect, ColorSuccess, Resources.StrReadingFwPackages);
SetStatusProgressBar(); SetStatusProgressBar();
_dbAccessDelayCtrMs = 0; _dbAccessDelayCtrMs = 0;
_processState = ProcessState.GetFwPackagesFromDb; _processState = ProcessState.GetFwPackagesInfosFromDb;
} }
/// <summary> /// <summary>
@@ -779,7 +778,7 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
{ {
// Load fw packages only if not selected indicated in count // Load fw packages only if not selected indicated in count
if (_fwUpdatePackage?.FwPackageInfo != null || if (_fwUpdatePackage?.FwPackageInfo != null ||
(_fwUpdateDbAccess?.DbCordonelFwPackagesInfo != null && (_fwUpdateDbAccess?.DbCordonelFwPackagesInfo != null &&
_fwUpdateDbAccess.DbCordonelFwPackagesInfo.Count > 0)) _fwUpdateDbAccess.DbCordonelFwPackagesInfo.Count > 0))
return; return;
@@ -788,7 +787,7 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
UiInvoker.ToolStripLabelInvoker(lblStatusDbConnect, ColorSuccess, Resources.StrReadingFwPackages); UiInvoker.ToolStripLabelInvoker(lblStatusDbConnect, ColorSuccess, Resources.StrReadingFwPackages);
SetStatusProgressBar(); SetStatusProgressBar();
_dbAccessDelayCtrMs = 0; _dbAccessDelayCtrMs = 0;
_processState = ProcessState.GetFwPackagesFromDb; _processState = ProcessState.GetFwPackagesInfosFromDb;
} }
if (e.TabPage == tabPageUpdateOperator) if (e.TabPage == tabPageUpdateOperator)
@@ -1199,7 +1198,7 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
/// - Register recovery implemented, /// - Register recovery implemented,
/// - FW information taken from fields instead of the name. /// - FW information taken from fields instead of the name.
/// </remarks> /// </remarks>
public Boolean BuildFwUpdateSafe() private Boolean BuildFwUpdateSafe()
{ {
if (string.IsNullOrEmpty(lblUpdateOperator.Text)) if (string.IsNullOrEmpty(lblUpdateOperator.Text))
return false; return false;
@@ -1391,7 +1390,7 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
/// <remarks date="2021-Apr-01" author="Thomas Wiedebusch"> /// <remarks date="2021-Apr-01" author="Thomas Wiedebusch">
/// - Password container directly assigned. /// - Password container directly assigned.
/// </remarks> /// </remarks>
public void CompleteCordonelDeviceInfos() private void CompleteCordonelDeviceInfos()
{ {
// establish DB connection with dummy request // establish DB connection with dummy request
_fwUpdateDbAccess?.DownloadCordonelPwdFromDb("0", out _); _fwUpdateDbAccess?.DownloadCordonelPwdFromDb("0", out _);
@@ -1512,7 +1511,7 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
string.IsNullOrEmpty(fw.RadioFrequencyMhz.ToString())) && string.IsNullOrEmpty(fw.RadioFrequencyMhz.ToString())) &&
requiredCoreVersion <= fw.CoreRevisionMax && requiredCoreVersion <= fw.CoreRevisionMax &&
requiredCoreVersion >= fw.CoreRevisionMin && requiredCoreVersion >= fw.CoreRevisionMin &&
cordonel.Diameter == fw.MeterSize) cordonel.Diameter == fw.MeterSize)
{ {
cordonel.IsRemoved = false; cordonel.IsRemoved = false;
cordonel.IsApproved = true; cordonel.IsApproved = true;
@@ -1793,7 +1792,7 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
// Selected FW-Packages ----------------------------------------------------------------------------------- // Selected FW-Packages -----------------------------------------------------------------------------------
// Add fw packages to fw package selection combo box for Cordonel FW to install selection // Add fw packages to fw package selection combo box for Cordonel FW to install selection
if (_fwUpdateDbAccess?.DbCordonelFwPackages != null && _fwUpdatePackage?.FwPackageInfo != null && if (_fwUpdateDbAccess?.DbCordonelFwPackage != null && _fwUpdatePackage?.FwPackageInfo != null &&
_cbxFwReleaseSelection != null) _cbxFwReleaseSelection != null)
{ {
if (_cbxFwReleaseSelection.Items.Count < 1) if (_cbxFwReleaseSelection.Items.Count < 1)
@@ -2579,21 +2578,12 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
} }
/// <summary> /// <summary>
/// Acquire all FW packages from DB. /// Acquire all FW packages infos from DB.
/// </summary> /// </summary>
/// <remarks date="2021-Apr-08" author="Thomas Wiedebusch">
/// - Initial
/// </remarks>
/// <remarks date="2021-Oct-26" author="Thomas Wiedebusch">
/// - Load configuration files from DB as the latest MeterFwUpdateRuler.json is needed for the
/// FwUpdateBuilder FW package check and validation routine! This step has to be done in advance
/// to the FW package load, as the Builder uses the information of the MeterFwUpdateRuler to
/// create the package information!
/// </remarks>
/// <remarks date="2022-Nov-30" author="Thomas Wiedebusch"> /// <remarks date="2022-Nov-30" author="Thomas Wiedebusch">
/// - Load only the information about the FW packages and not the FW package content. /// - Initial.
/// </remarks> /// </remarks>
private void LoadDbCordonelFwPackagesTask() private void LoadDbCordonelFwPackagesInfosTask()
{ {
_invokerProcessState = _processState; _invokerProcessState = _processState;
Task.Factory.StartNew(() => Task.Factory.StartNew(() =>
@@ -2604,10 +2594,8 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
{ {
// check DB connection in advance to overcome the timing issues for DB service startup // check DB connection in advance to overcome the timing issues for DB service startup
_fwUpdateDbAccess.CheckDbConnection(); _fwUpdateDbAccess.CheckDbConnection();
// has to be done first to extract the MeterFwUpdateRuler // load the packages information
//GetFwUpdateConfigFilesFromDb(); GetCordonelFwPackagesInfosFromDb();
// load the packages and use the MeterFwUpdateRuler to assign the DN, EMEA, NA, 868, 433..
GetCordonelFwPackagesFromDb();
} }
catch (Exception) catch (Exception)
{ {
@@ -2846,7 +2834,7 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
try try
{ {
if (e.ColumnIndex < 0 || e.RowIndex < 0 ) if (e.ColumnIndex < 0 || e.RowIndex < 0)
{ {
return; return;
} }
@@ -2861,7 +2849,7 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
for (var columnIndex = 0; columnIndex < gridViewFwPackageSelection.ColumnCount; columnIndex++) for (var columnIndex = 0; columnIndex < gridViewFwPackageSelection.ColumnCount; columnIndex++)
{ {
if (gridViewFwPackageSelection.Columns[columnIndex].Name == Resources.StrTableFileId) if (gridViewFwPackageSelection.Columns[columnIndex].Name == Resources.StrTableFileId)
fwPackage.FwPackageInfo.Id = fwPackage.FwPackageInfo.Id =
(Int32)gridViewFwPackageSelection.Rows[e.RowIndex].Cells[columnIndex].Value; (Int32)gridViewFwPackageSelection.Rows[e.RowIndex].Cells[columnIndex].Value;
} }
@@ -2884,9 +2872,10 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
{ {
cordonel.RequiredRelease = null; cordonel.RequiredRelease = null;
} }
// Search the FW package Id in data table, select if found // Search the FW package Id in data table, select if found
//foreach (var fw in _cordonelFwPackageInfoSearch) if (_fwUpdateDbAccess?.DbCordonelFwPackagesInfo == null)
if (_fwUpdateDbAccess?.DbCordonelFwPackagesInfo == null) return; return;
foreach (var fw in _fwUpdateDbAccess.DbCordonelFwPackagesInfo) foreach (var fw in _fwUpdateDbAccess.DbCordonelFwPackagesInfo)
{ {
if (fw.Id == fwPackage.FwPackageInfo.Id) if (fw.Id == fwPackage.FwPackageInfo.Id)
@@ -2977,7 +2966,8 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
try try
{ {
if (_fwUpdateDbAccess?.DbCordonelFwPackagesInfo == null) return; if (_fwUpdateDbAccess?.DbCordonelFwPackagesInfo == null)
return;
foreach (var fw in _fwUpdateDbAccess.DbCordonelFwPackagesInfo) foreach (var fw in _fwUpdateDbAccess.DbCordonelFwPackagesInfo)
{ {
// pre-selection of displayed FW packages // pre-selection of displayed FW packages
@@ -2992,7 +2982,7 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
if ((fw.Region != cbxFwPackageRegionMask.Text && cbxFwPackageRegionMask.Text != Constants.StrWildcard) || if ((fw.Region != cbxFwPackageRegionMask.Text && cbxFwPackageRegionMask.Text != Constants.StrWildcard) ||
(fw.RadioFrequencyMhz.ToString() != cbxFwPackageRadioMask.Text && cbxFwPackageRadioMask.Text != Constants.StrWildcard) || (fw.RadioFrequencyMhz.ToString() != cbxFwPackageRadioMask.Text && cbxFwPackageRadioMask.Text != Constants.StrWildcard) ||
(fw.MeterSize != cbxFwPackageSizeMask.Text && cbxFwPackageSizeMask.Text != Constants.StrWildcard) || (fw.MeterSize != cbxFwPackageSizeMask.Text && cbxFwPackageSizeMask.Text != Constants.StrWildcard) ||
(((fw.CoreRevisionMin != null && fw.CoreRevisionMin > requiredCoreVersion) || (((fw.CoreRevisionMin != null && fw.CoreRevisionMin > requiredCoreVersion) ||
(fw.CoreRevisionMax != null && requiredCoreVersion > fw.CoreRevisionMax)) && (fw.CoreRevisionMax != null && requiredCoreVersion > fw.CoreRevisionMax)) &&
cbxFwPackageSearchCore.Text != Constants.StrWildcard) || cbxFwPackageSearchCore.Text != Constants.StrWildcard) ||
(fw.MetrologyVersion.ToString() != cbxFwPackageSearchMetrology.Text && (fw.MetrologyVersion.ToString() != cbxFwPackageSearchMetrology.Text &&
@@ -3009,7 +2999,7 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
row[Resources.StrTableRadioFrequency] = fw.RadioFrequencyMhz == null ? Constants.StrWildcard : $@"{fw.RadioFrequencyMhz}"; row[Resources.StrTableRadioFrequency] = fw.RadioFrequencyMhz == null ? Constants.StrWildcard : $@"{fw.RadioFrequencyMhz}";
row[Resources.StrTableCordonelMetrology] = MeterFwUpdate.ConvertVersionToString(fw.MetrologyVersion); row[Resources.StrTableCordonelMetrology] = MeterFwUpdate.ConvertVersionToString(fw.MetrologyVersion);
row[Resources.StrTableFwPackageCoreMin] = MeterFwUpdate.ConvertVersionToString(fw.CoreRevisionMin); row[Resources.StrTableFwPackageCoreMin] = MeterFwUpdate.ConvertVersionToString(fw.CoreRevisionMin);
row[Resources.StrTableFwPackageCoreMax] = MeterFwUpdate.ConvertVersionToString(fw.CoreRevisionMax); row[Resources.StrTableFwPackageCoreMax] = MeterFwUpdate.ConvertVersionToString(fw.CoreRevisionMax);
row[Resources.StrTableCordonelDiameter] = fw.MeterSize ?? Constants.StrWildcard; row[Resources.StrTableCordonelDiameter] = fw.MeterSize ?? Constants.StrWildcard;
if (fw.ReleaseDate != null) if (fw.ReleaseDate != null)
@@ -3887,7 +3877,7 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
var row = _dataTableCordonels.NewRow(); var row = _dataTableCordonels.NewRow();
row[Resources.StrTableSelect] = cordSearch.IsSelected; row[Resources.StrTableSelect] = cordSearch.IsSelected;
row[Resources.StrTableCordonelCustomerSerialNumber] = cordSearch.CustomerSerialNumber ?? row[Resources.StrTableCordonelCustomerSerialNumber] = cordSearch.CustomerSerialNumber ??
Constants.StrUnknown; Constants.StrUnknown;
row[Resources.StrTableCordonelPcbId] = cordSearch.PcbId ?? Constants.StrUnknown; row[Resources.StrTableCordonelPcbId] = cordSearch.PcbId ?? Constants.StrUnknown;
@@ -4508,10 +4498,11 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
/// - Removed FUpdateRuler, all data are going to be taken from DB, /// - Removed FUpdateRuler, all data are going to be taken from DB,
/// - file name no longer used to identify capability of release, all information from DB. /// - file name no longer used to identify capability of release, all information from DB.
/// </remarks> /// </remarks>
private void GetCordonelFwPackagesFromDb() private void GetCordonelFwPackagesInfosFromDb()
{ {
if (_fwUpdateDbAccess == null) return; if (_fwUpdateDbAccess == null)
_fwUpdateDbAccess.GetAllCordonelFwPackagesInfoFromDb(); return;
_fwUpdateDbAccess.GetAllCordonelFwPackagesInfoFromDb();
} }
/// <summary> /// <summary>
@@ -5155,61 +5146,69 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
} }
String msg; String msg;
// search file id in ClusteredFiles but as the name in unambiguous and files are stored several times var fileId = 0;
// with this file name, the last and therefore latest item has to be taken // extract the clustered file Id from selected fw package
if (_fwUpdateDbAccess?.DbCordonelFwPackages != null) foreach (var packInfo in _fwUpdateDbAccess.DbCordonelFwPackagesInfo)
{ {
var fileId = (from cu in _fwUpdateDbAccess.DbCordonelFwPackages // fill up fw package info
where cu.FileName == releaseName if (!packInfo.IsSelected)
select cu.FileId).LastOrDefault(); continue;
if (_fwUpdateDbAccess.GetCordonelFwPackageFromDb(fileId, out var fwPackage)) fileId = packInfo.FileClusterStoreId;
_fwUpdatePackage.FwPackageInfo.Name = packInfo.Name;
_fwUpdatePackage.FwPackageInfo.RadioFrequencyMhz = packInfo.RadioFrequencyMhz;
_fwUpdatePackage.FwPackageInfo.MeterSize = packInfo.MeterSize;
_fwUpdatePackage.FwPackageInfo.Region = packInfo.Region;
_fwUpdatePackage.FwPackageInfo.CoreRevisionMax = packInfo.CoreRevisionMax;
_fwUpdatePackage.FwPackageInfo.CoreRevisionMin = packInfo.CoreRevisionMin;
_fwUpdatePackage.FwPackageInfo.MetrologyVersion = packInfo.MetrologyVersion;
_fwUpdatePackage.FwPackageInfo.Version = packInfo.Version;
_fwUpdatePackage.FwPackageInfo.FileName = packInfo.FileName;
break;
}
if (_fwUpdateDbAccess.GetCordonelFwPackageFromDb(fileId, out var fwPackage))
{
try
{ {
try // search the cordonel firmware
_fwUpdatePackage.PackageDescriptionFile = new FilePart();
_fwUpdatePackage.BinaryApplicationFiles = new List<FilePart>();
foreach (var f in fwPackage)
{ {
// search the cordonel firmware // load the ADF
if (_fwUpdatePackage.FwPackageInfo.Name == releaseName) if (f.FileName.Contains("product") && f.FileName.EndsWith(".txt"))
{ {
_fwUpdatePackage.PackageDescriptionFile = new FilePart(); _fwUpdatePackage.PackageDescriptionFile.FileName = f.FileName;
_fwUpdatePackage.BinaryApplicationFiles = new List<FilePart>(); _fwUpdatePackage.PackageDescriptionFile.FileContent = new Byte[f.FileContent.Length];
_fwUpdatePackage.PackageDescriptionFile.FileContent = f.FileContent.ToArray();
}
foreach (var f in fwPackage) // load the binaries
if (f.FileName.Contains("binfile") && f.FileName.EndsWith(".bin"))
{
var filePart = new FilePart
{ {
// load the ADF FileName = f.FileName,
if (f.FileName.Contains("product") && f.FileName.EndsWith(".txt")) FileContent = new Byte[f.FileContent.Length]
{ };
_fwUpdatePackage.PackageDescriptionFile.FileName = f.FileName; filePart.FileContent = f.FileContent.ToArray();
_fwUpdatePackage.PackageDescriptionFile.FileContent = new Byte[f.FileContent.Length]; _fwUpdatePackage.BinaryApplicationFiles.Add(filePart);
_fwUpdatePackage.PackageDescriptionFile.FileContent = f.FileContent.ToArray();
}
// load the binaries
if (f.FileName.Contains("binfile") && f.FileName.EndsWith(".bin"))
{
var filePart = new FilePart
{
FileName = f.FileName,
FileContent = new Byte[f.FileContent.Length]
};
filePart.FileContent = f.FileContent.ToArray();
_fwUpdatePackage.BinaryApplicationFiles.Add(filePart);
}
}
LogSuccessText(Resources.StrFwPackageLoadSuccess + " " + releaseName);
return true;
} }
} }
catch (Exception e)
{ LogSuccessText(Resources.StrFwPackageLoadSuccess + " " + releaseName);
msg = Resources.StrFwPackageLoadFailed + @" " + releaseName; return true;
LogErrorText(msg); }
MessageBoxShow(msg, Resources.StrError, MessageBoxButtons.OK, MessageBoxIcon.Error); catch (Exception e)
MessageBoxShow(e.ToString(), Resources.StrError, MessageBoxButtons.OK, {
MessageBoxIcon.Error); msg = Resources.StrFwPackageLoadFailed + @" " + releaseName;
_processState = ProcessState.Error; LogErrorText(msg);
return false; MessageBoxShow(msg, Resources.StrError, MessageBoxButtons.OK, MessageBoxIcon.Error);
} MessageBoxShow(e.ToString(), Resources.StrError, MessageBoxButtons.OK,
MessageBoxIcon.Error);
_processState = ProcessState.Error;
return false;
} }
} }
msg = Resources.StrFwPackageLoadFailed + @" " + releaseName; msg = Resources.StrFwPackageLoadFailed + @" " + releaseName;
@@ -962,8 +962,9 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
/// <remarks date="2020-Dec-21" author="Thomas Wiedebusch"> /// <remarks date="2020-Dec-21" author="Thomas Wiedebusch">
/// - Error messages exported. /// - Error messages exported.
/// </remarks> /// </remarks>
/// <remarks date="2023-Feb-17" author="Thomas Wiedebusch"> /// <remarks date="2023-Feb-18" author="Thomas Wiedebusch">
/// - Removed information like region and size of fw update package from name of package. /// - Removed information like region and size of fw update package from name of package,
/// - Added check for null of FwPackage info, binary content and description file.
/// </remarks> /// </remarks>
private void LoadUpdateFiles(ProcessState successExitState, ProcessState errorExitState = ProcessState.Error) private void LoadUpdateFiles(ProcessState successExitState, ProcessState errorExitState = ProcessState.Error)
{ {
@@ -979,7 +980,11 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
try try
{ {
if (_cordonelDeviceInfos == null || _cordonelFirmwarePackage == null) if (_cordonelDeviceInfos == null
|| _cordonelFirmwarePackage?.FwPackageInfo == null
|| _cordonelFirmwarePackage.BinaryApplicationFiles == null
|| _cordonelFirmwarePackage.BinaryApplicationFiles.Count == 0
|| _cordonelFirmwarePackage.PackageDescriptionFile == null)
{ {
InfoProcessFailed(lblUpdateInformationStatus, Resources.StrPackageFileInvalid); InfoProcessFailed(lblUpdateInformationStatus, Resources.StrPackageFileInvalid);
_processState = errorExitState; _processState = errorExitState;
@@ -1240,6 +1245,8 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
/// - MeterSize (DN40, DN50,..., DN300, US1_5, US2, US3,..., US12. /// - MeterSize (DN40, DN50,..., DN300, US1_5, US2, US3,..., US12.
/// If any information cannot be read from the meter, it will be assumed, that the FwUpdateBuilder operator /// If any information cannot be read from the meter, it will be assumed, that the FwUpdateBuilder operator
/// assembled a correct FwUpdateSafe. Otherwise old devices may be unable to update. /// assembled a correct FwUpdateSafe. Otherwise old devices may be unable to update.
/// The FwPackage has to be checked in advance before calling this routine, as all these information is needed
/// for this update capability check.
/// </summary> /// </summary>
/// <returns>true if core revision is valid</returns> /// <returns>true if core revision is valid</returns>
/// <remarks date="2021-Apr-26" author="Thomas Wiedebusch"> /// <remarks date="2021-Apr-26" author="Thomas Wiedebusch">
@@ -1257,27 +1264,76 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
Thread.CurrentThread.CurrentUICulture = _cultureInfo; Thread.CurrentThread.CurrentUICulture = _cultureInfo;
Thread.CurrentThread.CurrentCulture = _cultureInfo; Thread.CurrentThread.CurrentCulture = _cultureInfo;
Boolean retVal = true; var retVal = true;
// check the update capability for region
var region = Constants.StrUnknown;
if (!string.IsNullOrEmpty(_cordonelFirmwarePackage.FwPackageInfo.Region))
{
region = _cordonelFirmwarePackage.FwPackageInfo.Region;
if (_currentGenesis.Region.Contains(region) ) // extract the package information
var region = _cordonelFirmwarePackage.FwPackageInfo.Region;
var meterSize = _cordonelFirmwarePackage.FwPackageInfo.MeterSize;
var radioFrequencyMhz = _cordonelFirmwarePackage.FwPackageInfo.RadioFrequencyMhz;
// region
if (!string.IsNullOrEmpty(region))
{
// check the update capability for region, on undefined region accept update
if (_currentGenesis.Region == region
|| Constants.StrUnknown == region
|| Constants.StrUnknown == _currentGenesis.Region)
{ {
InfoProcessSuccess(null, Resources.StrCordonelUpdateCapabilityRegionSucceeded); InfoProcessSuccess(null, Resources.StrCordonelUpdateCapabilityRegionSucceeded);
retVal = true; }
else
{
retVal = false;
// set information of required and detected regions radio, check failed!
LogText(StrSeparator);
LogErrorText(Resources.StrFwPackageInfo + " " + region);
LogErrorText(@"Cordonel: " + _currentGenesis.Region);
InfoProcessFailed(lblCordonelUpdateCapability, Resources.StrCordonelUpdateCapabilityRegionFailed);
} }
} }
// set information of required and detected regions radio, check failed!
LogText(StrSeparator); // meter size
LogErrorText(Resources.StrRegionRadio); if (!string.IsNullOrEmpty(meterSize))
LogErrorText(Resources.StrFwPackageRegionRadio + " " + region); {
LogErrorText(@"Cordonel: " + _currentGenesis.Region); // check the update capability for meter size, on undefined meter size accept update
InfoProcessFailed(lblCordonelUpdateCapability, Resources.StrCordonelUpdateCapabilityRegionFailed); if (_currentGenesis.MeterSize == meterSize
_processState = ProcessState.Error; || Constants.StrUnknown == meterSize
return false; || Constants.StrUnknown == _currentGenesis.MeterSize)
{
InfoProcessSuccess(null, Resources.StrCordonelUpdateCapabilityMeterSizeSucceeded);
}
else
{
retVal = false;
// set information of required and detected regions check failed!
LogText(StrSeparator);
LogErrorText(Resources.StrFwPackageInfo + " " + meterSize);
LogErrorText(@"Cordonel: " + _currentGenesis.MeterSize);
InfoProcessFailed(lblCordonelUpdateCapability, Resources.StrCordonelUpdateCapabilityMeterSizeFailed);
}
}
// radio frequency
// if radio frequency is null the region is "NA" or the fw package serves all frequencies
if (radioFrequencyMhz == null) return retVal;
// if the radio frequency is required, it has to be verified against the preset value in the Cordonel
if (radioFrequencyMhz == _currentGenesis.RadioFrequencyMhz)
{
InfoProcessSuccess(null, Resources.StrCordonelUpdateCapabilityRadioSucceeded);
}
else
{
retVal = false;
// set information of required and detected radio frequency check failed!
LogText(StrSeparator);
LogErrorText(Resources.StrFwPackageInfo + " " + radioFrequencyMhz + " MHz");
LogErrorText(@"Cordonel: " + _currentGenesis.RadioFrequencyMhz + " MHz");
InfoProcessFailed(lblCordonelUpdateCapability, Resources.StrCordonelUpdateCapabilityRadioFailed);
}
if (!retVal) _processState = ProcessState.Error;
return retVal;
} }
/// <summary> /// <summary>
@@ -1448,7 +1504,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
// read initially if radio is already active in customer mode 2 // read initially if radio is already active in customer mode 2
if ( 2 == RegisterConverter.ConvertTo<Int32>(_currentGenesis.ReadRegister(Register.Sensusradio.SystemState))) if ( 2 == RegisterConverter.ConvertTo<Int32>(_currentGenesis.ReadRegister(Register.Sensusradio.SystemState)))
{ {
LogSuccessText(Resources.StrRadioActivationSuccess); LogSuccessText(Resources.StrRadioAlreadyActive);
retVal = true; retVal = true;
} }
else // switch radio active else // switch radio active
@@ -170,7 +170,25 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw.Properties {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Update denied due to deviating GENESISFLOW version!. /// Looks up a localized string similar to Update denied: Deviating meter size!.
/// </summary>
internal static string StrCordonelUpdateCapabilityMeterSizeFailed {
get {
return ResourceManager.GetString("StrCordonelUpdateCapabilityMeterSizeFailed", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Meter size is approved!.
/// </summary>
internal static string StrCordonelUpdateCapabilityMeterSizeSucceeded {
get {
return ResourceManager.GetString("StrCordonelUpdateCapabilityMeterSizeSucceeded", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Update denied: Deviating metrology version!.
/// </summary> /// </summary>
internal static string StrCordonelUpdateCapabilityMetrologyFailed { internal static string StrCordonelUpdateCapabilityMetrologyFailed {
get { get {
@@ -188,7 +206,25 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw.Properties {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Update denied due to region or radio frequency!. /// Looks up a localized string similar to Update denied: Deviating radio frequency!.
/// </summary>
internal static string StrCordonelUpdateCapabilityRadioFailed {
get {
return ResourceManager.GetString("StrCordonelUpdateCapabilityRadioFailed", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Radio frequency is approved!.
/// </summary>
internal static string StrCordonelUpdateCapabilityRadioSucceeded {
get {
return ResourceManager.GetString("StrCordonelUpdateCapabilityRadioSucceeded", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Update denied: Deviating region!.
/// </summary> /// </summary>
internal static string StrCordonelUpdateCapabilityRegionFailed { internal static string StrCordonelUpdateCapabilityRegionFailed {
get { get {
@@ -197,7 +233,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw.Properties {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Region and radio frequency is approved!. /// Looks up a localized string similar to Region is approved!.
/// </summary> /// </summary>
internal static string StrCordonelUpdateCapabilityRegionSucceeded { internal static string StrCordonelUpdateCapabilityRegionSucceeded {
get { get {
@@ -242,7 +278,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw.Properties {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Display released to normal operation.. /// Looks up a localized string similar to Display released to accumulator- and flow-display..
/// </summary> /// </summary>
internal static string StrDisplayReleased { internal static string StrDisplayReleased {
get { get {
@@ -460,9 +496,9 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw.Properties {
/// <summary> /// <summary>
/// Looks up a localized string similar to FW-Package:. /// Looks up a localized string similar to FW-Package:.
/// </summary> /// </summary>
internal static string StrFwPackageRegionRadio { internal static string StrFwPackageInfo {
get { get {
return ResourceManager.GetString("StrFwPackageRegionRadio", resourceCulture); return ResourceManager.GetString("StrFwPackageInfo", resourceCulture);
} }
} }
@@ -818,7 +854,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw.Properties {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Failed to activate the radio!. /// Looks up a localized string similar to Failed to activate the radio in customer mode!.
/// </summary> /// </summary>
internal static string StrRadioActivationFailed { internal static string StrRadioActivationFailed {
get { get {
@@ -827,7 +863,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw.Properties {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Successfully activated the radio.. /// Looks up a localized string similar to Successfully activated the radio in customer mode..
/// </summary> /// </summary>
internal static string StrRadioActivationSuccess { internal static string StrRadioActivationSuccess {
get { get {
@@ -835,6 +871,15 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw.Properties {
} }
} }
/// <summary>
/// Looks up a localized string similar to Radio is in customer mode..
/// </summary>
internal static string StrRadioAlreadyActive {
get {
return ResourceManager.GetString("StrRadioAlreadyActive", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Device reboot timeout! Press [Connect]!. /// Looks up a localized string similar to Device reboot timeout! Press [Connect]!.
/// </summary> /// </summary>
@@ -844,15 +889,6 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw.Properties {
} }
} }
/// <summary>
/// Looks up a localized string similar to Region and radio frequency [MHz]:.
/// </summary>
internal static string StrRegionRadio {
get {
return ResourceManager.GetString("StrRegionRadio", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Configuration access active..... /// Looks up a localized string similar to Configuration access active.....
/// </summary> /// </summary>
@@ -154,10 +154,7 @@
<data name="StrCoreRevision" xml:space="preserve"> <data name="StrCoreRevision" xml:space="preserve">
<value>Systemkern-Version:</value> <value>Systemkern-Version:</value>
</data> </data>
<data name="StrRegionRadio" xml:space="preserve"> <data name="StrFwPackageInfo" xml:space="preserve">
<value>Region und Funkfrequenz [MHz]:</value>
</data>
<data name="StrFwPackageRegionRadio" xml:space="preserve">
<value>FW-Paket:</value> <value>FW-Paket:</value>
</data> </data>
<data name="StrNotConnected" xml:space="preserve"> <data name="StrNotConnected" xml:space="preserve">
@@ -206,10 +203,22 @@
<value>Metrologieversion ist genehmigt.</value> <value>Metrologieversion ist genehmigt.</value>
</data> </data>
<data name="StrCordonelUpdateCapabilityRegionFailed" xml:space="preserve"> <data name="StrCordonelUpdateCapabilityRegionFailed" xml:space="preserve">
<value>Update verweigert: Region oder Funkfrequenz inkompatibel!</value> <value>Update verweigert: Unterschiedliche Region!</value>
</data> </data>
<data name="StrCordonelUpdateCapabilityRegionSucceeded" xml:space="preserve"> <data name="StrCordonelUpdateCapabilityRegionSucceeded" xml:space="preserve">
<value>Region und Funkfrequenz genehmigt!</value> <value>Region bestätigt!</value>
</data>
<data name="StrCordonelUpdateCapabilityMeterSizeFailed" xml:space="preserve">
<value>Update verweigert: Unterschiedliche Baugröße!</value>
</data>
<data name="StrCordonelUpdateCapabilityMeterSizeSucceeded" xml:space="preserve">
<value>Baugröße bestätigt!</value>
</data>
<data name="StrCordonelUpdateCapabilityRadioFailed" xml:space="preserve">
<value>Update verweigert: Unterschiedliche Funkfrequenz!</value>
</data>
<data name="StrCordonelUpdateCapabilityRadioSucceeded" xml:space="preserve">
<value>Funkfrequenz bestätigt!</value>
</data> </data>
<data name="StrCordonelUpdateCapabilitySucceeded" xml:space="preserve"> <data name="StrCordonelUpdateCapabilitySucceeded" xml:space="preserve">
<value>Update freigegeben.</value> <value>Update freigegeben.</value>
@@ -509,12 +518,15 @@
<value>Einstellungen erfolgreich gesichert.</value> <value>Einstellungen erfolgreich gesichert.</value>
</data> </data>
<data name="StrRadioActivationFailed" xml:space="preserve"> <data name="StrRadioActivationFailed" xml:space="preserve">
<value>Funk konnte nicht eingeschaltet werden!</value> <value>Funk konnte nicht in Kundenmodus geschaltet werden!</value>
</data>
<data name="StrRadioAlreadyActive" xml:space="preserve">
<value>Funk ist bereits im Kundenmodus.</value>
</data> </data>
<data name="StrRadioActivationSuccess" xml:space="preserve"> <data name="StrRadioActivationSuccess" xml:space="preserve">
<value>Funk erfolgreich eingeschaltet.</value> <value>Funk erfolgreich auf Kundenmodus geschaltet.</value>
</data> </data>
<data name="StrDisplayReleased" xml:space="preserve"> <data name="StrDisplayReleased" xml:space="preserve">
<value>Display freigegeben für Standardoperation.</value> <value>Display freigegeben für Volumen- und Durchflußanzeige.</value>
</data> </data>
</root> </root>
@@ -154,10 +154,7 @@
<data name="StrCoreRevision" xml:space="preserve"> <data name="StrCoreRevision" xml:space="preserve">
<value>System core revision:</value> <value>System core revision:</value>
</data> </data>
<data name="StrRegionRadio" xml:space="preserve"> <data name="StrFwPackageInfo" xml:space="preserve">
<value>Region and radio frequency [MHz]:</value>
</data>
<data name="StrFwPackageRegionRadio" xml:space="preserve">
<value>FW-Package:</value> <value>FW-Package:</value>
</data> </data>
<data name="StrNotConnected" xml:space="preserve"> <data name="StrNotConnected" xml:space="preserve">
@@ -200,16 +197,28 @@
<value>Core version is compatible.</value> <value>Core version is compatible.</value>
</data> </data>
<data name="StrCordonelUpdateCapabilityMetrologyFailed" xml:space="preserve"> <data name="StrCordonelUpdateCapabilityMetrologyFailed" xml:space="preserve">
<value>Update denied due to deviating GENESISFLOW version!</value> <value>Update denied: Deviating metrology version!</value>
</data> </data>
<data name="StrCordonelUpdateCapabilityMetrologySucceeded" xml:space="preserve"> <data name="StrCordonelUpdateCapabilityMetrologySucceeded" xml:space="preserve">
<value>Metrology version is approved</value> <value>Metrology version is approved</value>
</data> </data>
<data name="StrCordonelUpdateCapabilityRegionFailed" xml:space="preserve"> <data name="StrCordonelUpdateCapabilityRegionFailed" xml:space="preserve">
<value>Update denied due to region or radio frequency!</value> <value>Update denied: Deviating region!</value>
</data> </data>
<data name="StrCordonelUpdateCapabilityRegionSucceeded" xml:space="preserve"> <data name="StrCordonelUpdateCapabilityRegionSucceeded" xml:space="preserve">
<value>Region and radio frequency is approved!</value> <value>Region is approved!</value>
</data>
<data name="StrCordonelUpdateCapabilityMeterSizeFailed" xml:space="preserve">
<value>Update denied: Deviating meter size!</value>
</data>
<data name="StrCordonelUpdateCapabilityMeterSizeSucceeded" xml:space="preserve">
<value>Meter size is approved!</value>
</data>
<data name="StrCordonelUpdateCapabilityRadioFailed" xml:space="preserve">
<value>Update denied: Deviating radio frequency!</value>
</data>
<data name="StrCordonelUpdateCapabilityRadioSucceeded" xml:space="preserve">
<value>Radio frequency is approved!</value>
</data> </data>
<data name="StrCordonelUpdateCapabilitySucceeded" xml:space="preserve"> <data name="StrCordonelUpdateCapabilitySucceeded" xml:space="preserve">
<value>Update capability validated.</value> <value>Update capability validated.</value>
@@ -509,12 +518,15 @@
<value>Successfully stored configurations.</value> <value>Successfully stored configurations.</value>
</data> </data>
<data name="StrRadioActivationFailed" xml:space="preserve"> <data name="StrRadioActivationFailed" xml:space="preserve">
<value>Failed to activate the radio!</value> <value>Failed to activate the radio in customer mode!</value>
</data>
<data name="StrRadioAlreadyActive" xml:space="preserve">
<value>Radio is in customer mode.</value>
</data> </data>
<data name="StrRadioActivationSuccess" xml:space="preserve"> <data name="StrRadioActivationSuccess" xml:space="preserve">
<value>Successfully activated the radio.</value> <value>Successfully activated the radio in customer mode.</value>
</data> </data>
<data name="StrDisplayReleased" xml:space="preserve"> <data name="StrDisplayReleased" xml:space="preserve">
<value>Display released to normal operation.</value> <value>Display released to accumulator- and flow-display.</value>
</data> </data>
</root> </root>