This commit is contained in:
Stoyan Zlatev
2024-05-07 15:11:36 +02:00
46 changed files with 1966 additions and 825 deletions
@@ -444,6 +444,7 @@ namespace Xylem.Common.Hardware.Interfaces.Ports.SerialPorts
if (!string.IsNullOrEmpty(rxStringRecord))
{
//decode optional at synchronized data SyncStart, SyncEnd or DecodeIntermediate
//todo remove after air problem
if (SyncMarkRecord.SkipDecoding != dataSyncMarkThisRun)
{
OnRawRecordReceived?.Invoke(this, new StringPortDataEventArgs(rxStringRecord,
@@ -3,6 +3,7 @@ using Newtonsoft.Json;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
@@ -10,6 +11,7 @@ using System.Reflection;
using System.Runtime.InteropServices;
using System.Security.Authentication;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Timers;
using NLog;
@@ -824,7 +826,10 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
//nobody is listening
}
}
/// <summary>
///
/// </summary>
public Dictionary<Int32,Tuple<Int32,DateTime>> ErrorCurrent = new Dictionary<Int32,Tuple<Int32, DateTime>>();
/// <summary>
/// Track all incoming led record packages (Calibration and Flow)
/// </summary>
@@ -854,6 +859,18 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
return;
}
//if (calRec.Validation != 0)
//{
// if (!ErrorCurrent.ContainsKey(calRec.Channel))
// {
// ErrorCurrent.Add(calRec.Channel, new Tuple<int, DateTime>(1, DateTime.Now));
// }
// else
// {
// ErrorCurrent[calRec.Channel] = new Tuple<int, DateTime>(ErrorCurrent[calRec.Channel].Item1 + 1, DateTime.Now);
// }
// _logger.Info($"MessuremntError on {calRec.Channel} Code: {calRec.Validation}");
//}
}
AddData(((IMeasurementRecord)result));
}
@@ -1167,32 +1184,109 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
/// <summary>
/// Building the FW Version string out of 2 bytes of data.
/// REASON: FLEXNETVERSION is one application which does not follow the same rule of
/// decimal numbers. Instead it uses hexadecimal digits. After the conversion of this
/// number to a pure Uint32, needed for comparison of file versions in configuration.json,
/// the hexadecimal outline will be lost and the comparison with the rowproduct.txt fails.
/// FW-update needs this information to validate a tested package!
/// decimal numbers. Instead it uses hexadecimal digits.
/// </summary>
/// <param name="msb">most significant byte</param>
/// <param name="lsb">last significant byte</param>
/// <returns>converted "msb.lsb" as string e.g. "12.34" or "2.0C" </returns>
public static String BuildFwVersionString(Byte msb, Byte lsb)
/// <param name="fwVersion">version as hexadecimal result of version e.g. 0x1107 or 0x130B</param>
/// <param name="strVersion">any string to evaluate like "11.07" or "R1.1.07" or "1.3.0B"</param>
/// <param name="msb">most significant byte representing the major and minor version</param>
/// <param name="lsb">last significant byte representing the built version</param>
/// <returns>FLEXNET version string e.g. "R1.2.47" or "B1.2.0C" </returns>
public static String BuildFlexnetFwVersion(out UInt32 fwVersion, String strVersion, Byte? msb = null,
Byte? lsb = null)
{
//skip leading 0
var msbPartString = (msb & 0xF0) > 0 ? $"{(msb & 0xF0) >> 4:X0}" : "";
return msbPartString + $"{msb & 0x0F:X0}" + "." + $"{(lsb & 0xF0) >> 4:X1}" + $"{lsb & 0x0F:X1}";
var major = 0;
var minor = 0;
var builtMajor = 0;
var builtMinor = 0;
// preset version with 0 as undetected
fwVersion = 0;
if (msb != null && lsb != null)
{
major = (Int32)((msb & 0xF0) >> 4);
minor = (Int32)(msb & 0x0F);
builtMajor = (Int32)((lsb & 0xF0) >> 4);
builtMinor = (Int32)(lsb & 0x0F);
fwVersion = (UInt32)((msb << 8) + lsb);
}
else if (!string.IsNullOrEmpty(strVersion))
{
// this is always a string like 1.0.2D or 9.0.2D,
// a msb higher as 8 is indicating "B" version
var strResult = Regex.Replace(strVersion, "[^0-9,A-F,a-f]", "");
var strMajor = strResult.Substring(0, 1);
var strMinor = strResult.Substring(1, 1);
var strBuiltMajor = strResult.Substring(2, 1);
var strBuiltMinor = strResult.Substring(3, 1);
if (!uint.TryParse(strResult, NumberStyles.HexNumber, new CultureInfo("en"), out fwVersion)
|| !int.TryParse(strMajor, NumberStyles.HexNumber, new CultureInfo("en"), out major)
|| !int.TryParse(strMinor, NumberStyles.HexNumber, new CultureInfo("en"), out minor)
|| !int.TryParse(strBuiltMajor, NumberStyles.HexNumber, new CultureInfo("en"), out builtMajor)
|| !int.TryParse(strBuiltMinor, NumberStyles.HexNumber, new CultureInfo("en"), out builtMinor))
{
return "R" + strVersion;
}
}
// release version marked with "R"
if (major <= 8)
return $"R{major:X0}.{minor:X0}.{builtMajor:X0}{builtMinor:X0}";
// debug version marked with "B"
major -= 8;
return $"B{major:X0}.{minor:X0}.{builtMajor:X0}{builtMinor:X0}";
}
/// <summary>
/// Building a version string with 2 decimals e.g. " 12.34"
/// Building the FW Version string out of 2 bytes of data and a decimal version.
/// Example:
/// Inputs msb = 0x02, msb = 0x34,
/// Outputs fwVersion = 234, string "2.34"
/// </summary>
/// <remarks date="2022-Dec-02" author="Thomas Wiedebusch">
/// - Initial.
/// </remarks>
/// <param name="version">the version</param>
/// <returns>converted version to string </returns>
public static String BuildFwVersionString(Int32? version)
/// <param name="fwVersion">firmware version as decimal e.g. 234 </param>
/// <param name="msb">most significant byte hex</param>
/// <param name="lsb">last significant byte hex</param>
/// <returns>converted as string e.g. "2.34" or "2.0C" </returns>
public static String BuildFwVersion(out UInt32 fwVersion, Byte msb, Byte lsb)
{
return version == null ? "0.00" : $@"{version / 100}.{version % 100:D2}";
fwVersion = (UInt32)(((msb & 0xF0) >> 4) * 10 + (msb & 0x0F)) * 100;
fwVersion += (UInt32)(((lsb & 0xF0) >> 4) * 10 + (lsb & 0x0F));
//skip leading 0
var msbPartString = (msb & 0xF0) > 0 ? $"{(msb & 0xF0) >> 4:X0}." : "";
msbPartString += $"{msb & 0x0F:X0}" + "." + $"{(lsb & 0xF0) >> 4:X1}" + $"{lsb & 0x0F:X1}";
return msbPartString;
}
/// <summary>
/// Building the FW Version string out of UInt32 as hexadecimal input like 0x1107 (meaning 1.1.07).
/// Example:
/// Input fwVersion = 0x1107,
/// Outputs string "1.1.07"
/// </summary>
/// <param name="fwVersion">firmware version as hex</param>
/// <returns>converted "to "2.34" or "2.0C" </returns>
public static String BuildFwVersionStringFromHex(UInt32 fwVersion)
{
//skip leading 0
var msbPartString = (fwVersion & 0xF000) > 0 ? $"{(fwVersion & 0xF000) >> 12:X0}." : "";
msbPartString += $"{(fwVersion & 0xF00) >> 8:X0}.{(fwVersion & 0x0F0) >> 4:X0}" +
$"{fwVersion & 0x00F:X0}";
return msbPartString;
}
/// <summary>
/// Building the FW Version string out of Int32 as decimal input.
/// Example:
/// Input fwVersion = 238,
/// Outputs string "2.38"
/// </summary>
/// <param name="fwVersion">firmware version as hex</param>
/// <returns>converted to "2.34" or "2.01" </returns>
public static String BuildFwVersionStringFromDec(Int32? fwVersion)
{
return fwVersion == null ? "0.00" : $"{fwVersion / 100}.{fwVersion % 100:D2}";
}
/// <summary>
@@ -1206,6 +1300,12 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
//public String CoreRevision;
public Int32? CoreRevision;
/// <summary>
/// Core revision of boot code as string.
/// </summary>
//public String CoreRevision;
public String StrCoreRevision;
/// <summary>
/// This is the FLEXNETVERSION version which describes the entire packet.
/// </summary>
@@ -1214,7 +1314,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
/// <summary>
/// This is the FLEXNETVERSION version which describes the entire packet.
/// </summary>
public UInt32 InstalledFwVersion;
public UInt32? InstalledFwVersion;
/// <summary>
/// This is the Metrology Lookup Table CRC.
@@ -1324,7 +1424,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
{
foreach (var registerToCheck in tempConfigRegisters)
{
if (registerToCheck.Key?.RegisterDetail?.Version == null ||
if (registerToCheck.Key?.RegisterDetail?.Version == null ||
MeterAppListVersion.All(f => f.AppId != registerToCheck.Key.AppAddress))
continue;
@@ -1411,6 +1511,10 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
/// was responsible to start a FW update process in the CUST as it assumes the installation was incomplete
/// but it couldn't detect those applications due to communication issues.
/// </remarks>
/// <remarks date="2024-May-06" author="Thomas Wiedebusch">
/// - BuildFlexnetFwVersion,
/// - Calculate core revision.
/// </remarks>
private void ReadMeterFirmwareAndAssignRegisters()
{
// Avoid overwriting of list if this already exits
@@ -1440,18 +1544,20 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
//the FW version as UInt32 will be used for comparison with the configuration.json
if (readFwVersionBytes != null && readFwVersionBytes.Length > 0)
{
readFwVersion = (UInt32)(((readFwVersionBytes[1] & 0xF0) >> 4) * 10 +
(readFwVersionBytes[1] & 0x0F)) * 100;
readFwVersion += (UInt32)(((readFwVersionBytes[0] & 0xF0) >> 4) * 10 +
(readFwVersionBytes[0] & 0x0F));
//build the version string, because e.g. FLEXNETVERSION is one application which does not
//follow the same rule. After the upper conversion, the hexadecimal outline will be lost
versionString = BuildFwVersionString(readFwVersionBytes[1], readFwVersionBytes[0]);
if (meterApp.AppName == "FLEXNETVERSION")
{
FwVersion = versionString;
// msb and lsb are swapped during communication
FwVersion = BuildFlexnetFwVersion(out readFwVersion, null, readFwVersionBytes[1], readFwVersionBytes[0]);
versionString = FwVersion;
InstalledFwVersion = readFwVersion;
}
else
{
// msb and lsb are swapped during communication
versionString = BuildFwVersion(out readFwVersion, readFwVersionBytes[1], readFwVersionBytes[0]);
}
if (readFwVersion != 0)
{
@@ -1498,27 +1604,27 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
//read core revision
var coreRegisterRead = RegisterConverter.ByteArrayToValue<String>(ReadRegister(Register.System.CoreRevision, 16));
CoreRevision = null;
StrCoreRevision = "";
if (!string.IsNullOrEmpty(coreRegisterRead))
{
var coreRevisionStrings = coreRegisterRead.Split('\0');
//remove Cordonel sub-string and the blanks
// remove Cordonel sub-string and the blanks
var coreRevisionSubString = $"{coreRevisionStrings[0].ToLower().Replace("cordonel ", "")}";
var coreRevisionSubStrings = coreRevisionSubString.Split('.');
if (int.TryParse(coreRevisionSubStrings[0], out var coreRevisionMsb))
var strResult = Regex.Replace(coreRevisionSubString, "[^0-9,A-F,a-f]", "");
if (int.TryParse(strResult, out var coreRevision))
{
if (int.TryParse(coreRevisionSubStrings[1], out var coreRevisionLsb))
{
CoreRevision = coreRevisionMsb * 100 + coreRevisionLsb;
}
CoreRevision = coreRevision;
StrCoreRevision = BuildFwVersionStringFromDec(CoreRevision);
}
}
//log application information to file
// log application information to file
_logger.Info($"Slot:{Slot} - PCB ID: {PcbId}");
_logger.Info($"Slot:{Slot} - Date time (UTC): {DateTimeOffset.UtcNow}");
if (CoreRevision != null)
if (CoreRevision != 0)
{
_logger.Info($"Slot:{Slot} - System Core Revision: {BuildFwVersionString(CoreRevision)}");
_logger.Info($"Slot:{Slot} - System Core Revision: {StrCoreRevision}");
}
_logger.Info($"Slot:{Slot} - Region: {Region}");
@@ -1534,7 +1640,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
? $"V: {fm.StrVersion} - CRC: 0x{fm.Crc:X4}" : "Not installed";
if (fm.Status == MeterAppState.Unknown)
versionString = "Communication error";
_logger.Info($"Slot:{Slot} - AppId: 0x{fm.AppId:X2} - {versionString} - AppName: {fm.AppName}");
}
@@ -1594,6 +1700,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
}
}
}
}
/// <summary>
@@ -2292,6 +2399,9 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
/// <remarks date="2023-Nov-27" author="Thomas Wiedebusch">
/// - Installed FW version taken to enable read back for radio and na2walarms.
/// </remarks>
/// <remarks date="2024-May-07" author="Thomas Wiedebusch">
/// - Changed threshold check from decimal 1200 to hexadecimal 0x1200.
/// </remarks>
public Boolean StoreAllConfigurations()
{
@@ -2337,8 +2447,8 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
if (!a.Key.IsAvailable)
continue;
// For R1.2.x the read back is corrected
if (InstalledFwVersion < 1200 && (a.Key.AppName == "SENSUSRADIO" || a.Key.AppName == "NA2WALARMS"))
// For R1.2.x the read back is corrected use as hexadecimal value outline
if (InstalledFwVersion < 0x1200 && (a.Key.AppName == "SENSUSRADIO" || a.Key.AppName == "NA2WALARMS"))
{
continue;
}
@@ -2380,7 +2490,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
apps.Add(new CordonelAppVersion(item.AppId, item.StrVersion, item.AppId != 15));
}
apps.Add(new CordonelAppVersion(-1, BuildFwVersionString(CoreRevision), false));
apps.Add(new CordonelAppVersion(-1, StrCoreRevision, false));
var url = $"{ServiceUrls.MeterProcessStateUrl()}SetCordonelProgress?PcbId={PcbId}" +
$"&ProgressName={progressName}&version={version}";
@@ -58,6 +58,19 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
#endregion
#region Constants
/// <summary>
/// Threshold for power correction EMEA version
/// </summary>
public const UInt32 EmeaFwThresholdForPowCorr= 0x1300;
/// <summary>
/// Threshold for power correction NA version
/// </summary>
public const UInt32 NaFNaFwThresholdForPowCorr = 0x2006;
#endregion
#region Maintenance readout
/// <summary>
@@ -121,6 +121,8 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
/// <inheritdoc />
public void SetCalibFactorsAllChannels(Boolean justLog = false)
{
WriteRegister<Byte>(Register.Genesisflow.SampleRate, 2, checkRegister: true);
WriteRegister<UInt16>(Register.Genesisflow.TriggerIdle, 0x1234, true);
for (var channel = 0; channel < MeterConfig.CalibChannels; channel++)
{
if (_calibFactor[channel].IsCalculated == false) continue;
@@ -132,16 +134,25 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
else
{
var registerRawCalibFactor = _calibFactor[channel].GetMeterRawCalibFactor();
WriteRegister(_calibFactor[channel].RegisterToStoreCalibFactor,
var resultWrite = WriteRegister(_calibFactor[channel].RegisterToStoreCalibFactor,
registerRawCalibFactor, checkRegister: true);
_logger.Info($"Slot:{Slot}, Channel:{channel} - Stored calibration factor({_registersToStoreCalibFactor})");
_logger.Info($"Slot:{Slot}, Channel:{channel} - Stored calibration factor({_registersToStoreCalibFactor[channel]})");
if (resultWrite)
{
_logger.Warn($"Set calibration went wrong {_calibFactor[channel].RegisterToStoreCalibFactor}, with {registerRawCalibFactor}");
}
}
}
WriteRegister<Byte>(Register.Genesisflow.SampleRate, 10, checkRegister: true);
WriteRegister(Register.Genesisflow.ResetAccumulators, true);
//WriteRegister<UInt16>(Register.Genesisflow.ForwardArrow, 0, checkRegister: true);
WriteRegister<UInt16>(Register.Genesisflow.StoreCalibration, 1);
WriteRegister<UInt16>(Register.Genesisflow.StoreCalibration, 1,true);
_logger.Info($"Slot:{Slot} - StoreCalibration { RegisterConverter.ByteArrayToValue<UInt16>(ReadRegister(Register.Genesisflow.StoreCalibration))}");
WriteRegister<UInt16>(Register.Genesisflow.TriggerActive, 1, true);
_logger.Info($"Slot:{Slot} - Set forward arrow of LCD, reset accumulators, set sample rate to 2Hz");
WriteRegister<Byte>(Register.Genesisflow.SampleRate, 10, checkRegister: true);
}
}
}
@@ -50,7 +50,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
//SkipPreparationForTestBench = true;
//TODO set display unit
//TODO calculated overflow volume for display
WriteRegister<Byte>(Register.Genesisflow.SampleRate, 16, checkRegister: true);
WriteRegister<Byte>(Register.Genesisflow.SampleRate, 0x0a, checkRegister: true);
WriteRegister(Register.Genesisflow.LedMode, (Byte)LedMode.FlowTestAndCalibData, checkRegister: true);
WriteRegister("GENESISFLOW_SealDisplay", 0, true, true);
@@ -1427,15 +1427,29 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
/// Extracts version from binary application file.
/// </summary>
/// <returns></returns>
/// <remarks date="2024-Apr-04" author="Thomas Wiedebusch">
/// <remarks date="2024-May-07" author="Thomas Wiedebusch">
/// - Initial extracted from <see cref="CheckFileApp"/>
/// </remarks>
public static UInt32 GetFileAppVersion(Byte[] binData)
public static UInt32 GetFileAppVersion(Byte[] binData, out String strVersion)
{
return (UInt32)((binData[FileAppVersionIndex] & 0x0F)
+ ((binData[FileAppVersionIndex] & 0xF0) >> 4) * 10
+ (binData[FileAppVersionIndex + 1] & 0x0F) * 100
+ ((binData[FileAppVersionIndex + 1] & 0xF0) >> 4) * 1000);
var appId = binData[FileAppAppIdIndex];
strVersion = "0.00";
UInt32 version;
if (appId == 0x18) //FLEXNETVERSION
{
strVersion = GenesisMeter.BuildFlexnetFwVersion(out version, null,
binData[FileAppVersionIndex + 1],
binData[FileAppVersionIndex]);
}
else
{
strVersion = GenesisMeter.BuildFwVersion(out version,
binData[FileAppVersionIndex + 1],
binData[FileAppVersionIndex]);
}
return version;
}
/// <summary>
@@ -1453,15 +1467,19 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
/// <remarks date="2019-Jun-26" author="Thomas Wiedebusch">
/// - New file version string builder.
/// </remarks>
/// <remarks date="2024-May-06" author="Thomas Wiedebusch">
/// - File version as hex number to handle .
/// </remarks>
/// <remarks date="2024-May-07" author="Thomas Wiedebusch">
/// - Uses <see cref="GetFileAppVersion"/>.
/// </remarks>
private static Boolean CheckFileApp(FileApplications fileApp)
{
fileApp.AppId = GetFileAppAppId(fileApp.BinData.ToArray());
fileApp.Crc = GetFileAppCrc(fileApp.BinData.ToArray());
fileApp.Version = GetFileAppVersion(fileApp.BinData.ToArray());
fileApp.StrVersion = GenesisMeter.BuildFwVersionString(fileApp.BinData[FileAppVersionIndex + 1],
fileApp.BinData[FileAppVersionIndex]);
var fileAppStartId = Encoding.UTF8.GetString(fileApp.BinData.ToArray(), 0, 4);
var binData = fileApp.BinData.ToArray();
fileApp.AppId = binData[FileAppAppIdIndex];
fileApp.Version = GetFileAppVersion(binData, out fileApp.StrVersion);
fileApp.Crc = (UInt16)(binData[FileAppCrcIndex] + (binData[FileAppCrcIndex + 1] << 8));
var fileAppStartId = Encoding.UTF8.GetString(binData, 0, 4);
//check update file start identifier
if (fileAppStartId != StrFileAppStartId)
{
@@ -1988,16 +2006,6 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
return $"0x{appId:X2}";
}
/// <summary>
/// Build a version string like 2.02
/// </summary>
/// <param name="version"></param>
/// <returns></returns>
public static String ConvertVersionToString(Int32? version)
{
return version == null ? "0.00" : $"{version / 100}.{version % 100:D2}";
}
/// <summary>
/// Build the hexadecimal CRC string
/// </summary>
@@ -2013,7 +2021,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
#region PackageFile
/// <summary>
/// Load package control file
/// Load package control file - ADF (application description file)
/// </summary>
/// <param name="filePathName">to binary files</param>
/// <returns></returns>
@@ -2032,7 +2040,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
}
/// <summary>
/// Load package control file
/// Load package control file - ADF (application description file)
/// </summary>
/// <param name="text">control file content</param>
/// <returns></returns>
@@ -2046,7 +2054,8 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
}
/// <summary>
/// Validate package file with update files
/// Validate package file (ADF - application description file)
/// with update files (ABC - application binary container)
/// </summary>
/// <returns></returns>
/// <remarks date="2019-Jun-24" author="Thomas Wiedebusch">
@@ -2067,6 +2076,9 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
/// new versions starting with 2022-11-04_NA_B122B contain a CRC16 and CRC32 identifier.
/// - File line check modified to be immune against multiple blanks behind the field identifier.
/// </remarks>
/// <remarks date="2024-May-06" author="Thomas Wiedebusch">
/// - Handle FLEXNETVERSION correctly.
/// </remarks>
public Boolean ValidateFileAppsWithPackageFile()
{
if (string.IsNullOrEmpty(_packageDescriptionFile) || FileApps.Count == 0 ||
@@ -2079,7 +2091,11 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
var validAppsCtr = 0;
foreach (var fileApp in FileApps)
{
//find a line which contains all required information
// convert version from 0x1107 to "11.07"
var strVersion = fileApp.AppId == 0x18 ?
$"{(fileApp.Version & 0xFF00) >> 8:X2}.{fileApp.Version & 0x00FF:X2}"
: fileApp.StrVersion;
// find a line which contains all required information
validAppsCtr += packageFileLines.Count(line =>
line.Contains($"{StrPackageFileAppId}") &&
line.Contains($"{ConvertAppIdToString(fileApp.AppId)}") &&
@@ -2087,7 +2103,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
line.Contains($"{StrPackageFileAppCrc16}")) &&
line.Contains($"{ConvertCrcToString(fileApp.Crc)}") &&
line.Contains($"{StrPackageFileAppVersion}") &&
line.Contains($"{fileApp.StrVersion}"));
line.Contains($"{strVersion}"));
}
//extract the core revision fields
@@ -2118,8 +2134,8 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
/// </remarks>
public Boolean CheckCoreRevision(Int32? coreRevision)
{
if (null == CoreRevisionMaximum || null == CoreRevisionMinimum || null == coreRevision ||
null == _packageDescriptionFile)
if (null == CoreRevisionMaximum || null == CoreRevisionMinimum ||
null == _packageDescriptionFile || coreRevision == null)
{
return false;
}
@@ -67,7 +67,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
/// </remarks>
public static Boolean CheckCoreRevision(MeterFwUpdate meterFwUpdate, Int32? coreRevision)
{
if (meterFwUpdate == null || coreRevision == null) return false;
if (coreRevision == null || meterFwUpdate == null ) return false;
return meterFwUpdate.CheckCoreRevision(coreRevision);
}
}
@@ -29,6 +29,15 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
//error mask for unsuccessfully written LUT CRC
private const UInt32 LutCrcErrorMask = 0x8000000;
/// <summary>
/// Threshold for power correction EMEA version
/// </summary>
public const UInt32 EmeaFwThresholdForLutFile= 0x1200;
/// <summary>
/// Threshold for power correction NA version
/// </summary>
public const UInt32 NaFwThresholdForLutFile = 0x2000;
//trigger update retries
private const Int32 RegisterWriteRetries = 0;