Cordonel FwVersion: - String from hex or deci, String and version from string, string from read as 2 byte array
This commit is contained in:
@@ -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;
|
||||
@@ -1167,32 +1169,98 @@ 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="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)
|
||||
{
|
||||
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 (!UInt32.TryParse(strResult, NumberStyles.HexNumber, new CultureInfo("en"), out fwVersion)
|
||||
|| !Int32.TryParse(strMajor, NumberStyles.HexNumber, new CultureInfo("en"), out major)
|
||||
|| !Int32.TryParse(strMinor, NumberStyles.HexNumber, new CultureInfo("en"), out minor)
|
||||
|| !Int32.TryParse(strBuiltMajor, NumberStyles.HexNumber, new CultureInfo("en"), out builtMajor)
|
||||
|| !Int32.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 the FW Version string out of 2 bytes of data.
|
||||
/// </summary>
|
||||
/// <param name="fwVersion">firmware version as hex</param>
|
||||
/// <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)
|
||||
/// <returns>converted "msb.lsb" as string e.g. "2.34" or "2.0C" </returns>
|
||||
public static String BuildFwVersion(out UInt32 fwVersion, Byte msb, Byte lsb)
|
||||
{
|
||||
fwVersion = (UInt32)((msb << 8) + lsb);
|
||||
//skip leading 0
|
||||
var msbPartString = (msb & 0xF0) > 0 ? $"{(msb & 0xF0) >> 4:X0}" : "";
|
||||
var msbPartString = (msb & 0xF0) > 0 ? $"{(msb & 0xF0) >> 4:X0}." : "";
|
||||
return msbPartString + $"{msb & 0x0F:X0}" + "." + $"{(lsb & 0xF0) >> 4:X1}" + $"{lsb & 0x0F:X1}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Building a version string with 2 decimals e.g. " 12.34"
|
||||
/// Building the FW Version string out of UInt32 as hexadecimal input.
|
||||
/// </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 hex</param>
|
||||
/// <returns>converted "to "2.34" or "2.0C" </returns>
|
||||
public static String BuildFwVersionStringFromHex(UInt32 fwVersion)
|
||||
{
|
||||
return version == null ? "0.00" : $@"{version / 100}.{version % 100:D2}";
|
||||
//skip leading 0
|
||||
var msbPartString = (fwVersion & 0xF000) > 0 ? $"{(fwVersion & 0xF000) >> 12:X0}." : "";
|
||||
return msbPartString + $"{(fwVersion & 0xF00) >> 8:X0}.{(fwVersion & 0x0F0) >> 4:X0}{fwVersion & 0x00F:X0}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Building the FW Version string out of Int32 as decimal input.
|
||||
/// </summary>
|
||||
/// <param name="fwVersion">firmware version as hex</param>
|
||||
/// <returns>converted to "2.34" or "2.01" </returns>
|
||||
public static String BuildFwVersionStringFromDec(Int32? fwVersion)
|
||||
{
|
||||
if (fwVersion == 0)
|
||||
return "0.00";
|
||||
return $"{fwVersion / 100}.{fwVersion % 100:D2}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1201,10 +1269,15 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
public List<MeterApplications> MeterAppListVersion = new List<MeterApplications>();
|
||||
|
||||
/// <summary>
|
||||
/// Core revision of boot code.
|
||||
/// Core revision of boot code as hex number.
|
||||
/// </summary>
|
||||
public UInt32 CoreRevision;
|
||||
|
||||
/// <summary>
|
||||
/// Core revision of boot code as string.
|
||||
/// </summary>
|
||||
//public String CoreRevision;
|
||||
public Int32? CoreRevision;
|
||||
public String StrCoreRevision;
|
||||
|
||||
/// <summary>
|
||||
/// This is the FLEXNETVERSION version which describes the entire packet.
|
||||
@@ -1214,7 +1287,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 +1397,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 +1484,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 +1517,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)
|
||||
{
|
||||
@@ -1497,28 +1576,27 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
|
||||
//read core revision
|
||||
var coreRegisterRead = RegisterConverter.ByteArrayToValue<String>(ReadRegister(Register.System.CoreRevision, 16));
|
||||
CoreRevision = null;
|
||||
CoreRevision = 0;
|
||||
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 (UInt32.TryParse(strResult, NumberStyles.HexNumber, new CultureInfo("en"), out CoreRevision))
|
||||
{
|
||||
if (int.TryParse(coreRevisionSubStrings[1], out var coreRevisionLsb))
|
||||
{
|
||||
CoreRevision = coreRevisionMsb * 100 + coreRevisionLsb;
|
||||
}
|
||||
StrCoreRevision = BuildFwVersionStringFromHex(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 +1612,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}");
|
||||
}
|
||||
|
||||
@@ -2380,7 +2458,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}";
|
||||
|
||||
@@ -1432,12 +1432,8 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
/// </remarks>
|
||||
public static UInt32 GetFileAppVersion(Byte[] binData)
|
||||
{
|
||||
return (UInt32)((binData[FileAppVersionIndex] & 0x0F)
|
||||
+ ((binData[FileAppVersionIndex] & 0xF0) >> 4) * 10
|
||||
+ (binData[FileAppVersionIndex + 1] & 0x0F) * 100
|
||||
+ ((binData[FileAppVersionIndex + 1] & 0xF0) >> 4) * 1000);
|
||||
return (UInt32)(binData[FileAppVersionIndex] + (binData[FileAppVersionIndex + 1] << 8));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check the content of the binaries:
|
||||
/// - begins with "APP>",
|
||||
@@ -1453,15 +1449,29 @@ 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>
|
||||
private static Boolean CheckFileApp(FileApplications fileApp)
|
||||
{
|
||||
fileApp.AppId = GetFileAppAppId(fileApp.BinData.ToArray());
|
||||
fileApp.Crc = GetFileAppCrc(fileApp.BinData.ToArray());
|
||||
fileApp.Version = GetFileAppVersion(fileApp.BinData.ToArray());
|
||||
var binData = fileApp.BinData.ToArray();
|
||||
fileApp.AppId = binData[FileAppAppIdIndex];
|
||||
fileApp.Crc = (UInt16)(binData[FileAppCrcIndex] + (binData[FileAppCrcIndex + 1] << 8));
|
||||
|
||||
fileApp.StrVersion = GenesisMeter.BuildFwVersionString(fileApp.BinData[FileAppVersionIndex + 1],
|
||||
fileApp.BinData[FileAppVersionIndex]);
|
||||
var fileAppStartId = Encoding.UTF8.GetString(fileApp.BinData.ToArray(), 0, 4);
|
||||
if (fileApp.AppId == 0x18) //FLEXNETVERSION
|
||||
{
|
||||
fileApp.StrVersion = GenesisMeter.BuildFlexnetFwVersion(out fileApp.Version, null,
|
||||
binData[FileAppVersionIndex + 1],
|
||||
binData[FileAppVersionIndex]);
|
||||
}
|
||||
else
|
||||
{
|
||||
fileApp.StrVersion = GenesisMeter.BuildFwVersion(out fileApp.Version,
|
||||
binData[FileAppVersionIndex + 1],
|
||||
binData[FileAppVersionIndex]);
|
||||
}
|
||||
|
||||
var fileAppStartId = Encoding.UTF8.GetString(binData, 0, 4);
|
||||
//check update file start identifier
|
||||
if (fileAppStartId != StrFileAppStartId)
|
||||
{
|
||||
@@ -1988,16 +1998,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>
|
||||
@@ -2067,6 +2067,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 +2082,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 +2094,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
|
||||
@@ -2116,9 +2123,9 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
/// <remarks date="2022-Dec-05" author="Thomas Wiedebusch">
|
||||
/// - Core revision data type changed from string ti int32?.
|
||||
/// </remarks>
|
||||
public Boolean CheckCoreRevision(Int32? coreRevision)
|
||||
public Boolean CheckCoreRevision(UInt32 coreRevision)
|
||||
{
|
||||
if (null == CoreRevisionMaximum || null == CoreRevisionMinimum || null == coreRevision ||
|
||||
if (null == CoreRevisionMaximum || null == CoreRevisionMinimum ||
|
||||
null == _packageDescriptionFile)
|
||||
{
|
||||
return false;
|
||||
|
||||
@@ -65,9 +65,9 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
|
||||
/// <remarks date="2022-Dec-05" author="Thomas Wiedebusch">
|
||||
/// - Core revision data type changed from string ti int32?.
|
||||
/// </remarks>
|
||||
public static Boolean CheckCoreRevision(MeterFwUpdate meterFwUpdate, Int32? coreRevision)
|
||||
public static Boolean CheckCoreRevision(MeterFwUpdate meterFwUpdate, UInt32 coreRevision)
|
||||
{
|
||||
if (meterFwUpdate == null || coreRevision == null) return false;
|
||||
if (meterFwUpdate == null ) return false;
|
||||
return meterFwUpdate.CheckCoreRevision(coreRevision);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
|
||||
apps.Add(new CordonelAppVersion(item.AppId, item.StrVersion, item.AppId != 15));
|
||||
}
|
||||
|
||||
apps.Add(new CordonelAppVersion(-1, GenesisMeter.BuildFwVersionString(Meter.CoreRevision), false));
|
||||
apps.Add(new CordonelAppVersion(-1, Meter.StrCoreRevision, false));
|
||||
|
||||
var url = $"{ServiceUrls.MeterProcessStateUrl()}SetCordonelProgress?PcbId={Meter.PcbId}&ProgressName=Shipping&version={Assembly.GetExecutingAssembly().GetName().Version}";
|
||||
LocalWebRequest.PostRequestAsync(url, json: apps);
|
||||
|
||||
@@ -668,8 +668,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
lblConnectPcb.Text = StrPartPcbConnected + _currentGenesis.PcbId;
|
||||
lblCoreRevision.Text = StrCoreRevision +
|
||||
GenesisMeter.BuildFwVersionString(_currentGenesis.CoreRevision);
|
||||
lblCoreRevision.Text = StrCoreRevision + _currentGenesis.StrCoreRevision;
|
||||
lblConnectPcb.ForeColor = Color.Green;
|
||||
_meterFwUpdate?.CompareAllMeterAndFileApps(true);
|
||||
FillDataGridWithAllInfos();
|
||||
|
||||
@@ -520,7 +520,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
|
||||
LogText(StrSeparator);
|
||||
LogText($"PCB ID: {_currentGenesis.PcbId}");
|
||||
LogText($"Core Version: {GenesisMeter.BuildFwVersionString(_currentGenesis.CoreRevision)}");
|
||||
LogText($"Core Version: {_currentGenesis.StrCoreRevision}");
|
||||
LogText("");
|
||||
LogText("Installed Applications:");
|
||||
|
||||
|
||||
@@ -391,7 +391,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
return;
|
||||
LogText(StrSeparator);
|
||||
LogText($"PCB ID: {_currentGenesis.PcbId}");
|
||||
LogText($"Core Version: {GenesisMeter.BuildFwVersionString(_currentGenesis.CoreRevision)}");
|
||||
LogText($"Core Version: {_currentGenesis.StrCoreRevision}");
|
||||
LogText("");
|
||||
LogText("Installed Applications:");
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ using System.Windows.Forms;
|
||||
using Xylem.Common.CommonCore.Configuration;
|
||||
using Xylem.Common.CommonCore.Consts;
|
||||
using Xylem.Common.Hardware.Interfaces.Ports.PortCore;
|
||||
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.GenesisStatus;
|
||||
@@ -1093,12 +1094,14 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine($"PCBID: {_currentGenesis.PcbId}");
|
||||
sb.AppendLine($"Date: {DateTimeOffset.UtcNow}");
|
||||
sb.AppendLine($"System Core Revision: {BuildFwVersionString(_currentGenesis.CoreRevision)}");
|
||||
sb.AppendLine($"System Core Revision: {_currentGenesis.StrCoreRevision}");
|
||||
foreach (var fm in _currentGenesis.MeterAppListVersion.OrderBy(o => o.AppId))
|
||||
{
|
||||
var versionString = fm.IsInstalled
|
||||
? $"V: {fm.Version / 100}.{fm.Version % 100:D2} - CRC: 0x{fm.Crc:X4}\t"
|
||||
: "Not installed\t\t";
|
||||
? $"V: {fm.StrVersion} - CRC: 0x{fm.Crc:X4}" : "Not installed";
|
||||
if (fm.Status == MeterAppState.Unknown)
|
||||
versionString = "Communication error";
|
||||
|
||||
sb.AppendLine($"AppId: 0x{fm.AppId:X2} - {versionString} - AppName: {fm.AppName}");
|
||||
}
|
||||
|
||||
@@ -1901,7 +1904,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
apps.Add(new CordonelAppVersion(item.AppId, item.StrVersion, item.AppId != 15));
|
||||
}
|
||||
|
||||
apps.Add(new CordonelAppVersion(-1, BuildFwVersionString(_currentGenesis.CoreRevision), false));
|
||||
apps.Add(new CordonelAppVersion(-1, _currentGenesis.StrCoreRevision, false));
|
||||
|
||||
var url = $"{ServiceUrls.MeterProcessStateUrl()}SetCordonelProgress?PcbId={_currentGenesis.PcbId}&ProgressName=toolbox&version={Assembly.GetExecutingAssembly().GetName().Version}";
|
||||
var a = LocalWebRequest.PostRequestAsync(url, json: apps);
|
||||
|
||||
@@ -3170,9 +3170,9 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
|
||||
|
||||
row[Resources.StrTableRegion] = fw.Region ?? Constants.StrWildcard;
|
||||
row[Resources.StrTableRadioFrequency] = fw.RadioFrequencyMhz == null ? Constants.StrWildcard : $@"{fw.RadioFrequencyMhz}";
|
||||
row[Resources.StrTableCordonelMetrology] = MeterFwUpdate.ConvertVersionToString(fw.MetrologyVersion);
|
||||
row[Resources.StrTableFwPackageCoreMin] = MeterFwUpdate.ConvertVersionToString(fw.CoreRevisionMin);
|
||||
row[Resources.StrTableFwPackageCoreMax] = MeterFwUpdate.ConvertVersionToString(fw.CoreRevisionMax);
|
||||
row[Resources.StrTableCordonelMetrology] = GenesisMeter.BuildFwVersionStringFromDec(fw.MetrologyVersion);
|
||||
row[Resources.StrTableFwPackageCoreMin] = GenesisMeter.BuildFwVersionStringFromDec(fw.CoreRevisionMin);
|
||||
row[Resources.StrTableFwPackageCoreMax] = GenesisMeter.BuildFwVersionStringFromDec(fw.CoreRevisionMax);
|
||||
|
||||
row[Resources.StrTableCordonelDiameter] = fw.MeterSize ?? Constants.StrWildcard;
|
||||
if (fw.ReleaseDate != null)
|
||||
@@ -4757,36 +4757,9 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
|
||||
|
||||
if (appVersion.Id == 0x18) //FLEXNETVERSION
|
||||
{
|
||||
// this is always a number like 1.0.2D or 9.0.2D, a msb higher as 8 is
|
||||
// indicating "B" version
|
||||
var strResult = Regex.Replace(appVersion.Version, "[^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 ( Int32.TryParse(strMajor, NumberStyles.HexNumber, new CultureInfo("en"), out var major)
|
||||
&& Int32.TryParse(strMinor, NumberStyles.HexNumber, new CultureInfo("en"), out var minor)
|
||||
&& Int32.TryParse(strBuiltMajor, NumberStyles.HexNumber, new CultureInfo("en"), out var builtMajor)
|
||||
&& Int32.TryParse(strBuiltMinor, NumberStyles.HexNumber, new CultureInfo("en"), out var builtMinor)
|
||||
&& Int32.TryParse(strResult, NumberStyles.HexNumber, new CultureInfo("en"), out var version))
|
||||
{
|
||||
cordonel.InstalledFwVersion = version;
|
||||
if (major > 8)
|
||||
{
|
||||
major -= 8;
|
||||
cordonel.InstalledReleaseNameVersion = $"B{major}.{minor:X0}.{builtMajor:X0}{builtMinor:X0}";
|
||||
}
|
||||
else
|
||||
{
|
||||
cordonel.InstalledReleaseNameVersion = $"R{major}.{minor:X0}.{builtMajor:X0}{builtMinor:X0}";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cordonel.InstalledReleaseNameVersion = "R" + appVersion.Version;
|
||||
cordonel.InstalledFwVersion = null;
|
||||
}
|
||||
cordonel.InstalledReleaseNameVersion =
|
||||
GenesisMeter.BuildFlexnetFwVersion(out var version, appVersion.Version);
|
||||
cordonel.InstalledFwVersion = (Int32?)version;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5747,7 +5720,7 @@ namespace Xylem.ServiceFwUpdate.Ui.FwUpdateBuilder
|
||||
|
||||
#endregion --------------------------------------- Load DB Contents -------------------------------------------
|
||||
|
||||
#region ------------------------------------------ Language ---------------------------------------------------
|
||||
#region ------------------------------------------ Language ---------------------------------------------------
|
||||
/// <summary>
|
||||
/// Select language at runtime: English
|
||||
/// </summary>
|
||||
|
||||
@@ -1456,7 +1456,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
||||
@"Minimum: " + _meterFwUpdate.CoreRevisionMinimum / 100 + "." +
|
||||
_meterFwUpdate.CoreRevisionMinimum % 100,
|
||||
@"Maximum: " + _meterFwUpdate.CoreRevisionMaximum / 100 + "." + _meterFwUpdate.CoreRevisionMaximum % 100,
|
||||
@"Cordonel: " + GenesisMeter.BuildFwVersionString(_currentGenesis.CoreRevision)
|
||||
@"Cordonel: " + _currentGenesis.StrCoreRevision
|
||||
};
|
||||
|
||||
LogStringList(Resources.StrCoreRevision, coreLineList,
|
||||
@@ -2306,7 +2306,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
||||
LogText($"PCB ID: {_currentGenesis.PcbId}");
|
||||
LogText($"{Resources.StrMessageCustomerSerialNumber} {_customerSerialNumber}");
|
||||
LogText($"FW Version: {_currentGenesis.FwVersion}");
|
||||
LogText($"{Resources.StrMessageSystemCoreRevision} {GenesisMeter.BuildFwVersionString(_currentGenesis.CoreRevision)}");
|
||||
LogText($"{Resources.StrMessageSystemCoreRevision} {_currentGenesis.StrCoreRevision}");
|
||||
LogText($"{Resources.StrMessageSystemRegion} {_currentGenesis.Region}");
|
||||
LogText($"{Resources.StrMessageSystemRadio} {_currentGenesis.RadioFrequencyMhz}");
|
||||
LogText($"{Resources.StrMessageMeterSize} {_currentGenesis.MeterSize}");
|
||||
@@ -2316,16 +2316,16 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
||||
var appList = new List<CordonelAppVersion>();
|
||||
|
||||
// the core has the -1 as identifier and is not updateable
|
||||
var coreVersion = new CordonelAppVersion(-1, GenesisMeter.BuildFwVersionString(_currentGenesis.CoreRevision), false);
|
||||
var coreVersion = new CordonelAppVersion(-1, _currentGenesis.StrCoreRevision, false);
|
||||
appList.Add(coreVersion);
|
||||
|
||||
foreach (var app in _currentGenesis.MeterAppListVersion)
|
||||
{
|
||||
var versionString = app.IsInstalled ? $"V: {app.StrVersion} - CRC: 0x{app.Crc:X4}" :
|
||||
Resources.StrMessageAppNotInstalled;
|
||||
|
||||
if (app.Status == MeterAppState.Unknown)
|
||||
versionString = Resources.StrCordonelCommunicationFailed;
|
||||
|
||||
|
||||
LogText($"{Resources.StrTableAppId}: 0x{app.AppId:X2} - {versionString} - " +
|
||||
$"{Resources.StrTableAppName}: {app.AppName}");
|
||||
@@ -3856,8 +3856,7 @@ namespace Xylem.ServiceFwUpdate.Ui.ServiceFwUpdateSw
|
||||
UiInvoker.ControlInvoker(lblConnectPcb, ColorSuccess,
|
||||
Resources.StrPartPcbConnected + @" " + _currentGenesis.PcbId);
|
||||
UiInvoker.ControlInvoker(lblCoreRevision, ColorDefault,
|
||||
Resources.StrCoreRevision + @" " +
|
||||
$"{GenesisMeter.BuildFwVersionString(_currentGenesis.CoreRevision)}");
|
||||
Resources.StrCoreRevision + @" " + $"{_currentGenesis.StrCoreRevision}");
|
||||
|
||||
LogInstalledMeterFw();
|
||||
_processState = successExitState;
|
||||
|
||||
Reference in New Issue
Block a user