GenesisMeter: - app versions as decimal version, - FLEXNETSERIAL as hexadecimal

This commit is contained in:
Thomas Wiedebusch
2024-05-06 18:12:15 +02:00
parent f049aebc6c
commit 6d94010108
2 changed files with 15 additions and 12 deletions
+1 -1
View File
@@ -155,7 +155,7 @@
</site> </site>
<site name="MeterProcessState" id="2"> <site name="MeterProcessState" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool"> <application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Users\SZLATEV\source\repos\laa_production\Common\Service\MeterProcessState" /> <virtualDirectory path="/" physicalPath="D:\Projekte\SENSUS_GitLab\LAA_PRODUCTION\Common\Service\MeterProcessState" />
</application> </application>
<bindings> <bindings>
<binding protocol="http" bindingInformation="*:56011:localhost" /> <binding protocol="http" bindingInformation="*:56011:localhost" />
@@ -1225,7 +1225,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
} }
/// <summary> /// <summary>
/// Building the FW Version string out of 2 bytes of data. /// Building the FW Version string out of 2 bytes of data and a decimal version.
/// </summary> /// </summary>
/// <param name="fwVersion">firmware version as hex</param> /// <param name="fwVersion">firmware version as hex</param>
/// <param name="msb">most significant byte</param> /// <param name="msb">most significant byte</param>
@@ -1233,14 +1233,16 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
/// <returns>converted "msb.lsb" as string e.g. "2.34" or "2.0C" </returns> /// <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) public static String BuildFwVersion(out UInt32 fwVersion, Byte msb, Byte lsb)
{ {
fwVersion = (UInt32)((msb << 8) + lsb); fwVersion = (UInt32)(((msb & 0xF0) >> 4) * 10 +
(msb & 0x0F)) * 100;
fwVersion += (UInt32)(((lsb & 0xF0) >> 4) * 10 + (lsb & 0x0F));
//skip leading 0 //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}"; return msbPartString + $"{msb & 0x0F:X0}" + "." + $"{(lsb & 0xF0) >> 4:X1}" + $"{lsb & 0x0F:X1}";
} }
/// <summary> /// <summary>
/// Building the FW Version string out of UInt32 as hexadecimal input. /// Building the FW Version string out of UInt32 as hexadecimal input like 0x1107 (meaning 1.1.07).
/// </summary> /// </summary>
/// <param name="fwVersion">firmware version as hex</param> /// <param name="fwVersion">firmware version as hex</param>
/// <returns>converted "to "2.34" or "2.0C" </returns> /// <returns>converted "to "2.34" or "2.0C" </returns>
@@ -1258,9 +1260,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
/// <returns>converted to "2.34" or "2.01" </returns> /// <returns>converted to "2.34" or "2.01" </returns>
public static String BuildFwVersionStringFromDec(Int32? fwVersion) public static String BuildFwVersionStringFromDec(Int32? fwVersion)
{ {
if (fwVersion == 0) return fwVersion == null ? "0.00" : $"{fwVersion / 100}.{fwVersion % 100:D2}";
return "0.00";
return $"{fwVersion / 100}.{fwVersion % 100:D2}";
} }
/// <summary> /// <summary>
@@ -1269,9 +1269,10 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
public List<MeterApplications> MeterAppListVersion = new List<MeterApplications>(); public List<MeterApplications> MeterAppListVersion = new List<MeterApplications>();
/// <summary> /// <summary>
/// Core revision of boot code as hex number. /// Core revision of boot code.
/// </summary> /// </summary>
public UInt32 CoreRevision; //public String CoreRevision;
public Int32? CoreRevision;
/// <summary> /// <summary>
/// Core revision of boot code as string. /// Core revision of boot code as string.
@@ -1576,7 +1577,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
//read core revision //read core revision
var coreRegisterRead = RegisterConverter.ByteArrayToValue<String>(ReadRegister(Register.System.CoreRevision, 16)); var coreRegisterRead = RegisterConverter.ByteArrayToValue<String>(ReadRegister(Register.System.CoreRevision, 16));
CoreRevision = 0; CoreRevision = null;
StrCoreRevision = ""; StrCoreRevision = "";
if (!string.IsNullOrEmpty(coreRegisterRead)) if (!string.IsNullOrEmpty(coreRegisterRead))
@@ -1585,9 +1586,10 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
// remove Cordonel sub-string and the blanks // remove Cordonel sub-string and the blanks
var coreRevisionSubString = $"{coreRevisionStrings[0].ToLower().Replace("cordonel ", "")}"; var coreRevisionSubString = $"{coreRevisionStrings[0].ToLower().Replace("cordonel ", "")}";
var strResult = Regex.Replace(coreRevisionSubString, "[^0-9,A-F,a-f]", ""); var strResult = Regex.Replace(coreRevisionSubString, "[^0-9,A-F,a-f]", "");
if (UInt32.TryParse(strResult, NumberStyles.HexNumber, new CultureInfo("en"), out CoreRevision)) if (Int32.TryParse(strResult, out var coreRevision))
{ {
StrCoreRevision = BuildFwVersionStringFromHex(CoreRevision); CoreRevision = coreRevision;
StrCoreRevision = BuildFwVersionStringFromDec(CoreRevision);
} }
} }
@@ -1672,6 +1674,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
} }
} }
} }
} }
/// <summary> /// <summary>