MeterSize moved from "Logic.PrdctionToProductMapper" to "ProductionOrderCore",

RegionRadio split to Region (string) and RadioFrequencyMhz (Int32?),
CoreRevision changed from string to Int32?,
Service\MeterProcessState\Controllers\GetCorondelFw changed to GetCordonelFw and corrected
This commit is contained in:
Thomas Wiedebusch
2022-12-06 13:15:53 +01:00
parent 51c5934b8b
commit ef0d333d66
67 changed files with 2314 additions and 2343 deletions
@@ -27,7 +27,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Applications
/// <summary>
/// Version string of application because of FLEXNETVERSION
/// does return a different layout, instead of decimals it
/// used hexadecimals. Therefore the version has to be safed as
/// used hexadecimals. Therefore the version has to be saved as
/// string at time of receiving for the FW-Update comparison
/// </summary>
public String StrVersion;
@@ -36,6 +36,7 @@ using Xylem.Common.Hardware.WaterMeter.WaterMeterCore;
using Xylem.Common.Hardware.WaterMeter.WaterMeterCore.Consts;
using Xylem.Common.Hardware.WaterMeter.WaterMeterRegisters;
using Xylem.Common.Logic.ProductionOrderCore.File;
using Xylem.Common.Logic.ProductionOrderCore.OrderData;
using Xylem.Common.Logic.RelatePcb;
using Xylem.Common.Logic.SoftwareAccessHelper;
using Xylem.Common.Metrology.Measurements;
@@ -1138,6 +1139,19 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
return msbPartString + $"{msb & 0x0F:X0}" + "." + $"{(lsb & 0xF0) >> 4:X1}" + $"{lsb & 0x0F:X1}";
}
/// <summary>
/// Building a version string with 2 decimals e.g. " 12.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)
{
return version == null ? "0.00" : $@"{version / 100}.{version % 100 :D2}";
}
/// <summary>
/// List of all present meter applications
/// </summary>
@@ -1146,7 +1160,8 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
/// <summary>
/// Core revision of boot code.
/// </summary>
public String CoreRevision;
//public String CoreRevision;
public Int32? CoreRevision;
/// <summary>
/// This is the FLEXNET version which describes the entire packet.
@@ -1164,9 +1179,14 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
public String MeterSize;
/// <summary>
/// Region (EMEA or NA) and Radio frequency (433 or 868 or null).
/// Region (EMEA or NA).
/// </summary>
public String RegionRadio;
public String Region;
/// <summary>
/// Radio frequency in MHz (433 or 868 or null).
/// </summary>
public Int32? RadioFrequencyMhz;
/// <summary>
/// Metrology upgrade permission.
@@ -1192,6 +1212,13 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
/// <remarks date="2022-Apr-27" author="Thomas Wiedebusch">
/// - Read lockup table CRC bugfix with try, catch for legacy versions, where this register does not exists.
/// </remarks>
/// <remarks date="2022-Dec-02" author="Thomas Wiedebusch">
/// - CoreRevision from String to Int32?,
/// - MeterSize from String to MeterSize,
/// - Region separated from RadioRegion as String,
/// - RadioFrequencyMhz introduced as Int32? (null if "NA" region or not installed),
/// - LutCrc from String to Int32?.
/// </remarks>
private void ReadMeterFirmwareAndAssignRegisters()
{
//avoid overwriting of list if this already exits
@@ -1284,18 +1311,32 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
//read core revision
var coreRegisterRead = RegisterConverter.ConvertTo<String>(ReadRegister(Register.System.CoreRevision, 16));
var coreRevision = coreRegisterRead?.Split('\0');
CoreRevision = coreRevision == null ? "0.00" : $"{coreRevision[0].ToLower().Replace("cordonel ", "")}";
CoreRevision = null;
if (!string.IsNullOrEmpty(coreRegisterRead))
{
var coreRevisionStrings = coreRegisterRead.Split('\0');
//remove Cordonel sub-string and the blanks
var coreRevisionSubString = $"{coreRevisionStrings[0].ToLower().Replace("cordonel ", "")}";
var coreRevisionSubStrings = coreRevisionSubString.Split('.');
if (Int32.TryParse(coreRevisionSubStrings[0], out var coreRevisionMsb))
{
if (Int32.TryParse(coreRevisionSubStrings[1], out var coreRevisionLsb))
{
CoreRevision = coreRevisionMsb * 100 + coreRevisionLsb;
}
}
}
//read radio frequency
RegionRadio = "NA";
Region = "NA";
RadioFrequencyMhz = null;
try
{
var radioFrequencyRaw = ReadRegister(Register.Sensusradio.FrequencyIndicator);
if (radioFrequencyRaw != null)
{
var radioFrequency = RegisterConverter.ConvertTo<UInt16>(radioFrequencyRaw);
RegionRadio = $"EMEA_{radioFrequency}";
Region = "EMEA";
RadioFrequencyMhz = RegisterConverter.ConvertTo<Int32>(radioFrequencyRaw);
}
}
catch (Exception)
@@ -1309,10 +1350,15 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
_logger.Info($"Date time (UTC): {DateTimeOffset.UtcNow}");
if (CoreRevision != null)
{
_logger.Info("System Core Revision: " + CoreRevision);
_logger.Info("System Core Revision: " + BuildFwVersionString(CoreRevision));
}
_logger.Info("Region and radio frequency[Mhz]: " + RegionRadio);
_logger.Info("Region: " + Region);
if (RadioFrequencyMhz != null)
{
_logger.Info($"Radio frequency [MHz]: {RadioFrequencyMhz}");
}
foreach (var fm in MeterAppListVersion.OrderBy(o => o.AppId))
{
@@ -2144,9 +2190,10 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
apps.Add(new CordonelAppVersion(item.AppId, item.StrVersion, item.AppId != 15));
}
apps.Add(new CordonelAppVersion(-1, CoreRevision, false));
apps.Add(new CordonelAppVersion(-1, BuildFwVersionString(CoreRevision), false));
var url = $"{ServiceUrls.MeterProcessStateUrl()}SetCordonelProgress?PcbId={PcbId}&ProgressName={progressName}&version={version}";
var url = $"{ServiceUrls.MeterProcessStateUrl()}SetCordonelProgress?PcbId={PcbId}" +
$"&ProgressName={progressName}&version={version}";
LocalWebRequest.PostRequestAsync(url, json: apps);
}
@@ -136,6 +136,10 @@
<Project>{D0C859D9-D55E-4E85-AC50-0FF31B1CE50D}</Project>
<Name>Logic.ProductionToProductMapper</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Logic\ProductionOrderCore\ProductionOrderCore.csproj">
<Project>{6D2777BB-7A88-466D-A49B-3266F9BF0160}</Project>
<Name>ProductionOrderCore</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Utils\Crc16Ccitt\Crc16Ccitt.csproj">
<Project>{91DEF0C0-AA4F-40AE-8F18-CB717FDE7E7F}</Project>
<Name>Crc16Ccitt</Name>
@@ -99,19 +99,13 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
public Int32 MaxPartialFileDataSize = 2 * 1024;
/// <summary>
/// Core revision minimum as double for comparison
/// Core revision minimum as int32? with major * 100 + minor for comparison
/// </summary>
public Double? CoreRevisionMinimum
{
get; set;
}
public Int32? CoreRevisionMinimum { get; private set; }
/// <summary>
/// Core revision maximum as double for comparison
/// Core revision maximum as int32? with major * 100 + minor for comparison
/// </summary>
public Double? CoreRevisionMaximum
{
get; private set;
}
public Int32? CoreRevisionMaximum { get; private set; }
//reminder for the core minimum requirement as string
private String _strCoreRevisionMinimum;
@@ -1950,9 +1944,9 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
/// </summary>
/// <param name="version"></param>
/// <returns></returns>
public static String ConvertVersionToString(UInt32 version)
public static String ConvertVersionToString(Int32? version)
{
return $"{version / 100}.{version % 100:D2}";
return version == null ? "0.00" : $"{version / 100}.{version % 100:D2}";
}
/// <summary>
@@ -2062,7 +2056,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
/// Checks if the core version is in range of required minimum to maximum version.
/// The package file has to be read in advance as this contains the min/max.
/// </summary>
/// <param name="coreVersionString">string containing the core version</param>
/// <param name="coreRevision">containing the core version</param>
/// <returns>true if version is in range</returns>
/// <remarks date="2020-Dec-08" author="Thomas Wiedebusch">
/// - Initial.
@@ -2070,16 +2064,18 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
/// <remarks date="2021-Mar-10" author="Thomas Wiedebusch">
/// - Removed "Cordonel " string check.
/// </remarks>
public Boolean CheckCoreRevision(String coreVersionString)
/// <remarks date="2022-Dec-05" author="Thomas Wiedebusch">
/// - Core revision data type changed from string ti int32?.
/// </remarks>
public Boolean CheckCoreRevision(Int32? coreRevision)
{
if (null == CoreRevisionMaximum || null == CoreRevisionMinimum || null == coreVersionString ||
if (null == CoreRevisionMaximum || null == CoreRevisionMinimum || null == coreRevision ||
null == _packageDescriptionFile)
{
return false;
}
var meterCoreRevision = ExtractVersionFromString(coreVersionString);
return meterCoreRevision >= CoreRevisionMinimum && meterCoreRevision <= CoreRevisionMaximum;
return coreRevision >= CoreRevisionMinimum && coreRevision <= CoreRevisionMaximum;
}
/// <summary>
@@ -2097,7 +2093,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
/// <remarks date="2021-Mar-09" author="Thomas Wiedebusch">
/// - Changed to Int32 with major * 100 + minor.
/// </remarks>
public static Int32 ExtractVersionFromString(String versionString)
private static Int32 ExtractVersionFromString(String versionString)
{
var majorVersion = 0;
@@ -57,15 +57,18 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
/// The package file has to be read in advance as this contains the min/max.
/// </summary>
/// <param name="meterFwUpdate"></param>
/// <param name="coreVersionString">string containing the core version</param>
/// <param name="coreRevision">containing the core version</param>
/// <returns>true if version is in range</returns>
/// <remarks date="2020-Dec-08" author="Thomas Wiedebusch">
/// - Initial.
/// </remarks>
public static Boolean CheckCoreRevision(MeterFwUpdate meterFwUpdate, String coreVersionString)
/// <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)
{
if (meterFwUpdate == null || coreVersionString == null) return false;
return meterFwUpdate.CheckCoreRevision(coreVersionString);
if (meterFwUpdate == null || coreRevision == null) return false;
return meterFwUpdate.CheckCoreRevision(coreRevision);
}
}
}
@@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
using Logic.ProductionToProductMapper.Cordonel;
using Xylem.Common.Logic.ProductionOrderCore.OrderData;
namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
{
@@ -4,12 +4,12 @@ using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using Logic.ProductionToProductMapper.Cordonel;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore.Consts;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile.Consts;
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
using Xylem.Common.Hardware.WaterMeter.WaterMeterCore.Consts;
using Xylem.Common.Logic.ProductionOrderCore.OrderData;
using Xylem.Common.Utils.Crc16Ccitt;
using Xylem.Common.Utils.ProcessExec;
using Xylem.Common.Utils.ProcessExec.EventArguments;
@@ -1 +1 @@
5ed75d99ee45ff67821090f1b3dbb001dd9e4fe3
1a3d4919c9c702245832d925951f2b7cb72fc333