Genesis: - data types UInt48/72/88 supported,
manual merge from Dev_Shipping - part 1
This commit is contained in:
@@ -6,17 +6,25 @@
|
|||||||
public enum StatusReturn
|
public enum StatusReturn
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// undefined status
|
/// undefined status does not fit in any other status defined below
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Unknown,
|
Unknown,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// skipped test and therefore the return identifies this
|
||||||
|
/// </summary>
|
||||||
|
Skipped,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// successfully executed without any restrictions
|
/// successfully executed without any restrictions
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Okay,
|
Okay,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// execution failed
|
/// execution failed
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Failed,
|
Failed,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// inspection needed as warning returns
|
/// inspection needed as warning returns
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<ProjectConfiguration>
|
||||||
|
<Settings>
|
||||||
|
<CopyReferencedAssembliesToWorkspace>False</CopyReferencedAssembliesToWorkspace>
|
||||||
|
<HiddenComponentWarnings />
|
||||||
|
<IgnoredTests>
|
||||||
|
<AllTestsSelector />
|
||||||
|
</IgnoredTests>
|
||||||
|
<IncludeStaticReferencesInWorkspace>False</IncludeStaticReferencesInWorkspace>
|
||||||
|
<PreventSigningOfAssembly>True</PreventSigningOfAssembly>
|
||||||
|
</Settings>
|
||||||
|
</ProjectConfiguration>
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Xylem.Common.Hardware.WaterMeter.Genesis.DataPackages.EventArguments
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
/// <summary>
|
||||||
|
/// abstract for set structure for BaseDataEventArgs
|
||||||
|
/// </summary>
|
||||||
|
public abstract class BaseDataEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 'Base' get event record form real child.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Object GetData()
|
||||||
|
{
|
||||||
|
return GetEventData();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// get real Event record
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public abstract Object GetEventData();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Holds the record before decoding, for logging
|
||||||
|
/// </summary>
|
||||||
|
public String RawData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore.Consts
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Alarm messages
|
||||||
|
/// </summary>
|
||||||
|
[Flags]
|
||||||
|
public enum Alarm
|
||||||
|
{
|
||||||
|
// ReSharper disable InconsistentNaming
|
||||||
|
#pragma warning disable CS1591
|
||||||
|
REBOOT = 1 << 0,
|
||||||
|
LOW_BATTERY = 1 << 1,
|
||||||
|
EMPTY_PIPE = 1 << 4,
|
||||||
|
REVERSE_FLOW = 1 << 6,
|
||||||
|
SUSPECT_LEAK = 1 << 7,
|
||||||
|
BROKEN_PIPE = 1 << 8,
|
||||||
|
LOW_PRESSURE = 1 << 9,
|
||||||
|
HIGH_PRESSURE = 1 << 10,
|
||||||
|
LOW_TEMPERATURE = 1 << 11,
|
||||||
|
HIGH_TEMPERATURE = 1 << 12,
|
||||||
|
RADIO_ERROR = 1 << 13,
|
||||||
|
METROLOGY_PARAMS = 1 << 14,
|
||||||
|
METROLOGY_MEASURE = 1 << 15,
|
||||||
|
|
||||||
|
ALL = 0xFFFFFF,
|
||||||
|
#pragma warning restore CS1591
|
||||||
|
// ReSharper restore InconsistentNaming
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,15 +1,17 @@
|
|||||||
namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||||
{
|
{
|
||||||
using Applications;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Converters;
|
using Newtonsoft.Json.Converters;
|
||||||
using Registers;
|
|
||||||
using Registers.DataTypes;
|
|
||||||
using Registers.Json;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
|
using Applications;
|
||||||
|
using Registers;
|
||||||
|
using Registers.DataTypes;
|
||||||
|
using Registers.Json;
|
||||||
using WaterMeterRegisters;
|
using WaterMeterRegisters;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -150,8 +152,6 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
private static Type GetType(String value)
|
private static Type GetType(String value)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
switch (value.ToLower())
|
switch (value.ToLower())
|
||||||
{
|
{
|
||||||
@@ -171,16 +171,12 @@
|
|||||||
case "int32_t": return typeof(Int32);
|
case "int32_t": return typeof(Int32);
|
||||||
case "int64_t": return typeof(Int64);
|
case "int64_t": return typeof(Int64);
|
||||||
case "int16_t": return typeof(Int16);
|
case "int16_t": return typeof(Int16);
|
||||||
|
case "uint72_t": return typeof(UInt72);
|
||||||
|
case "uint48_t": return typeof(UInt48);
|
||||||
|
case "uint88_t": return typeof(UInt88);
|
||||||
default: throw new Exception($"Type {value} not recognized!");
|
default: throw new Exception($"Type {value} not recognized!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
//throw ex;
|
|
||||||
return typeof(Boolean);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -0,0 +1,241 @@
|
|||||||
|
namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||||
|
{
|
||||||
|
using Applications;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Converters;
|
||||||
|
using Registers;
|
||||||
|
using Registers.DataTypes;
|
||||||
|
using Registers.Json;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.IO;
|
||||||
|
using WaterMeterRegisters;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// JSON filer reader for generation of register lists
|
||||||
|
/// </summary>
|
||||||
|
public class GenesisConfigurationReader
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Registers defined in configuration.json file
|
||||||
|
/// </summary>
|
||||||
|
public List<IRegister> ConfigRegistersDefinitions { get; }
|
||||||
|
= new List<IRegister>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Applications defined in configuration.json file
|
||||||
|
/// </summary>
|
||||||
|
public List<ApplicationDefinition> ConfigApplicationDefinitions { get; }
|
||||||
|
= new List<ApplicationDefinition>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ctor
|
||||||
|
/// </summary>
|
||||||
|
public GenesisConfigurationReader() { }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ctor
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="configFilePath">the file path for configuration.json as interface description to the meter</param>
|
||||||
|
public GenesisConfigurationReader(String configFilePath)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(configFilePath))
|
||||||
|
{
|
||||||
|
throw new ApplicationException("JsonFileRegisterReader needs at least one file path");
|
||||||
|
}
|
||||||
|
if (!File.Exists(configFilePath))
|
||||||
|
{
|
||||||
|
throw new ApplicationException($" {configFilePath} doesn't exists");
|
||||||
|
}
|
||||||
|
|
||||||
|
BuildRegisterList(File.ReadAllText(configFilePath));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Convert file content to register list
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="configurationJson"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="Exception"></exception>
|
||||||
|
public void BuildRegisterList(String configurationJson)
|
||||||
|
{
|
||||||
|
IDictionary<String, AppSection> sections;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
sections = JsonConvert
|
||||||
|
.DeserializeObject<IDictionary<String, AppSection>>(configurationJson, SerializerSettings)
|
||||||
|
?? new Dictionary<String, AppSection>();
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
sections = new Dictionary<String, AppSection>();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var sectionKVP in sections)
|
||||||
|
{
|
||||||
|
var appId = sectionKVP.Value.Id;
|
||||||
|
var appName = sectionKVP.Key;
|
||||||
|
|
||||||
|
ConfigApplicationDefinitions.Add(new ApplicationDefinition
|
||||||
|
{
|
||||||
|
AppId = appId,
|
||||||
|
AppName = appName
|
||||||
|
});
|
||||||
|
|
||||||
|
var section = sectionKVP.Value;
|
||||||
|
|
||||||
|
var registers = section.Registers;
|
||||||
|
|
||||||
|
if (registers is null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var registerKVP in registers)
|
||||||
|
{
|
||||||
|
var register = registerKVP.Value;
|
||||||
|
|
||||||
|
if (register is null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var details = register.Details;
|
||||||
|
|
||||||
|
if (details is null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var regId = register.Id;
|
||||||
|
|
||||||
|
foreach (var detail in details)
|
||||||
|
{
|
||||||
|
var values = detail.Values;
|
||||||
|
|
||||||
|
ConfigRegistersDefinitions.Add(new RegisterDefinition
|
||||||
|
{
|
||||||
|
AppAddress = appId,
|
||||||
|
AppName = appName,
|
||||||
|
DataType = GetType(detail.Type),
|
||||||
|
Default = values?.Default is Int64 d ? d : default(Int64?),
|
||||||
|
IsAvailable = default(Boolean),
|
||||||
|
Maximum = values?.Maximum is Int64 max ? max : default(Int64?),
|
||||||
|
Minimum = values?.Minimum is Int64 min ? min : default(Int64?),
|
||||||
|
RegAddressInApp = regId,
|
||||||
|
// RegisterAddress = new byte[] { appId, regId },
|
||||||
|
RegisterDetail = detail,
|
||||||
|
RegisterName = registerKVP.Key,
|
||||||
|
RestoreCapability = new StaticType(detail.StaticType)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Settings
|
||||||
|
/// </summary>
|
||||||
|
private static readonly JsonSerializerSettings SerializerSettings = new JsonSerializerSettings
|
||||||
|
{
|
||||||
|
MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
|
||||||
|
DateParseHandling = DateParseHandling.None,
|
||||||
|
Converters =
|
||||||
|
{
|
||||||
|
AccessConverter.Singleton,
|
||||||
|
new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
private static Type GetType(String value)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch (value.ToLower())
|
||||||
|
{
|
||||||
|
case "bool_t": return typeof(Boolean);
|
||||||
|
case "rpc": return typeof(Rpc);
|
||||||
|
case "string": return typeof(String);
|
||||||
|
case "uint32_t": return typeof(UInt32);
|
||||||
|
case "time_t": return typeof(TimeT);
|
||||||
|
case "status_t": return typeof(StatusT);
|
||||||
|
case "uint16_t": return typeof(UInt16);
|
||||||
|
case "uint8_t": return typeof(Byte);
|
||||||
|
case "enum8": return typeof(Enum8);
|
||||||
|
case "uint64_t": return typeof(UInt64);
|
||||||
|
case "uint96_t": return typeof(UInt96);
|
||||||
|
case "uint128_t": return typeof(UInt128);
|
||||||
|
case "int8_t": return typeof(SByte);
|
||||||
|
case "int32_t": return typeof(Int32);
|
||||||
|
case "int64_t": return typeof(Int64);
|
||||||
|
case "int16_t": return typeof(Int16);
|
||||||
|
default: throw new Exception($"Type {value} not recognized!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
//throw ex;
|
||||||
|
return typeof(Boolean);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public class AccessConverter : JsonConverter
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="t"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override Boolean CanConvert(Type t) => t == typeof(Access) || t == typeof(Access?);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="reader"></param>
|
||||||
|
/// <param name="t"></param>
|
||||||
|
/// <param name="existingValue"></param>
|
||||||
|
/// <param name="serializer"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override Object ReadJson(JsonReader reader, Type t, Object existingValue, JsonSerializer serializer)
|
||||||
|
{
|
||||||
|
if (reader.TokenType == JsonToken.Null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var value = serializer.Deserialize<String>(reader);
|
||||||
|
|
||||||
|
return Enum.TryParse(value, true, out Access access) ? access : default(Access);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="writer"></param>
|
||||||
|
/// <param name="untypedValue"></param>
|
||||||
|
/// <param name="serializer"></param>
|
||||||
|
public override void WriteJson(JsonWriter writer, Object untypedValue, JsonSerializer serializer)
|
||||||
|
{
|
||||||
|
if (untypedValue is Access access)
|
||||||
|
{
|
||||||
|
writer.WriteValue(access.ToString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception("Cannot marshal type Lvl");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public static readonly AccessConverter Singleton = new AccessConverter();
|
||||||
|
}
|
||||||
|
}
|
||||||
+32
-5
@@ -60,6 +60,33 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore.Properties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to ERROR: Could not find a CSD parameter in register list!.
|
||||||
|
/// </summary>
|
||||||
|
internal static string StrErrorMsgCsdMissing {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("StrErrorMsgCsdMissing", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to ERROR: Could not find register in register list! Check configuration.json for latest version!.
|
||||||
|
/// </summary>
|
||||||
|
internal static string StrErrorMsgRegisterNotFound {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("StrErrorMsgRegisterNotFound", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to ERROR: Could not write register!.
|
||||||
|
/// </summary>
|
||||||
|
internal static string StrErrorMsgRegisterWrite {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("StrErrorMsgRegisterWrite", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Read back.
|
/// Looks up a localized string similar to Read back.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -169,7 +196,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore.Properties {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Recovery configuration.....
|
/// Looks up a localized string similar to Execute configuration sequence.....
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string StrRegisterRecoveryExec {
|
internal static string StrRegisterRecoveryExec {
|
||||||
get {
|
get {
|
||||||
@@ -178,7 +205,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore.Properties {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Finalize configuration recovery sequence.....
|
/// Looks up a localized string similar to Finalize configuration sequence.....
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string StrRegisterRecoveryFinalization {
|
internal static string StrRegisterRecoveryFinalization {
|
||||||
get {
|
get {
|
||||||
@@ -187,7 +214,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore.Properties {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Prepare configuration recovery sequence.....
|
/// Looks up a localized string similar to Prepare configuration sequence.....
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string StrRegisterRecoveryPreparation {
|
internal static string StrRegisterRecoveryPreparation {
|
||||||
get {
|
get {
|
||||||
@@ -196,7 +223,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore.Properties {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to ERROR: Register value is out of range.
|
/// Looks up a localized string similar to ERROR: Register value is out of range!.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string StrRegisterValueOutOfRange {
|
internal static string StrRegisterValueOutOfRange {
|
||||||
get {
|
get {
|
||||||
@@ -223,7 +250,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore.Properties {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Set register value to default.
|
/// Looks up a localized string similar to WARNING: Register value set to default.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string StrSetRegisterToDefault {
|
internal static string StrSetRegisterToDefault {
|
||||||
get {
|
get {
|
||||||
|
|||||||
@@ -154,13 +154,13 @@
|
|||||||
<value>Lese Register nach der Wartung</value>
|
<value>Lese Register nach der Wartung</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="StrRegisterRecoveryExec" xml:space="preserve">
|
<data name="StrRegisterRecoveryExec" xml:space="preserve">
|
||||||
<value>Ausführung Konfigurationswiederherstellungssequenz....</value>
|
<value>Ausführung der Konfigurationsequenz....</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="StrRegisterRecoveryFinalization" xml:space="preserve">
|
<data name="StrRegisterRecoveryFinalization" xml:space="preserve">
|
||||||
<value>Abschließen Konfigurationswiederherstellungssequenz....</value>
|
<value>Abschließen der Konfigurationsequenz....</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="StrRegisterRecoveryPreparation" xml:space="preserve">
|
<data name="StrRegisterRecoveryPreparation" xml:space="preserve">
|
||||||
<value>Vorbereitung Konfigurationswiederherstellungssequenz....</value>
|
<value>Vorbereitung der Konfigurationsequenz....</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="StrRegisterCompareFailed" xml:space="preserve">
|
<data name="StrRegisterCompareFailed" xml:space="preserve">
|
||||||
<value>FEHLER: Vergleich fehlgeschlagen!</value>
|
<value>FEHLER: Vergleich fehlgeschlagen!</value>
|
||||||
@@ -172,9 +172,18 @@
|
|||||||
<value>Zurückgelesen</value>
|
<value>Zurückgelesen</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="StrSetRegisterToDefault" xml:space="preserve">
|
<data name="StrSetRegisterToDefault" xml:space="preserve">
|
||||||
<value>Registerwert auf Standardwert gesetzt</value>
|
<value>WARNUNG: Registerwert auf Standardwert gesetzt</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="StrRegisterValueOutOfRange" xml:space="preserve">
|
<data name="StrRegisterValueOutOfRange" xml:space="preserve">
|
||||||
<value>FEHLER: Registerwert ungültig</value>
|
<value>FEHLER: Registerwert außerhalb des zulässigen Bereiches!</value>
|
||||||
|
</data>
|
||||||
|
<data name="StrErrorMsgCsdMissing" xml:space="preserve">
|
||||||
|
<value>FEHLER: Kein CSD Parameter in Parameterliste gefunden!</value>
|
||||||
|
</data>
|
||||||
|
<data name="StrErrorMsgRegisterNotFound" xml:space="preserve">
|
||||||
|
<value>FEHLER: Register nicht in Registerliste gefunden! Version der Configuration.json prüfen!</value>
|
||||||
|
</data>
|
||||||
|
<data name="StrErrorMsgRegisterWrite" xml:space="preserve">
|
||||||
|
<value>FEHLER: Register konnte nicht geschrieben werden!</value>
|
||||||
</data>
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@@ -154,13 +154,13 @@
|
|||||||
<value>Write register</value>
|
<value>Write register</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="StrRegisterRecoveryExec" xml:space="preserve">
|
<data name="StrRegisterRecoveryExec" xml:space="preserve">
|
||||||
<value>Recovery configuration....</value>
|
<value>Execute configuration sequence....</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="StrRegisterRecoveryFinalization" xml:space="preserve">
|
<data name="StrRegisterRecoveryFinalization" xml:space="preserve">
|
||||||
<value>Finalize configuration recovery sequence....</value>
|
<value>Finalize configuration sequence....</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="StrRegisterRecoveryPreparation" xml:space="preserve">
|
<data name="StrRegisterRecoveryPreparation" xml:space="preserve">
|
||||||
<value>Prepare configuration recovery sequence....</value>
|
<value>Prepare configuration sequence....</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="StrRegisterCompareFailed" xml:space="preserve">
|
<data name="StrRegisterCompareFailed" xml:space="preserve">
|
||||||
<value>ERROR: Comparison failed!</value>
|
<value>ERROR: Comparison failed!</value>
|
||||||
@@ -172,9 +172,18 @@
|
|||||||
<value>Read back</value>
|
<value>Read back</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="StrSetRegisterToDefault" xml:space="preserve">
|
<data name="StrSetRegisterToDefault" xml:space="preserve">
|
||||||
<value>Set register value to default</value>
|
<value>WARNING: Register value set to default</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="StrRegisterValueOutOfRange" xml:space="preserve">
|
<data name="StrRegisterValueOutOfRange" xml:space="preserve">
|
||||||
<value>ERROR: Register value is out of range</value>
|
<value>ERROR: Register value is out of range!</value>
|
||||||
|
</data>
|
||||||
|
<data name="StrErrorMsgCsdMissing" xml:space="preserve">
|
||||||
|
<value>ERROR: Could not find a CSD parameter in register list!</value>
|
||||||
|
</data>
|
||||||
|
<data name="StrErrorMsgRegisterNotFound" xml:space="preserve">
|
||||||
|
<value>ERROR: Could not find register in register list! Check configuration.json for latest version!</value>
|
||||||
|
</data>
|
||||||
|
<data name="StrErrorMsgRegisterWrite" xml:space="preserve">
|
||||||
|
<value>ERROR: Could not write register!</value>
|
||||||
</data>
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
@@ -34,7 +35,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// PCB ID for pre update write for comparison
|
/// PCB ID for pre update write for comparison
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private String _pcbIdWriteRegisters = Constants.StrUnknown;
|
private String _pcbIdWriteRegisters;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// PCB ID for post update for comparison
|
/// PCB ID for post update for comparison
|
||||||
@@ -71,7 +72,12 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private static readonly List<String> _unReversedParameters = new List<String>
|
private static readonly List<String> _unReversedParameters = new List<String>
|
||||||
{
|
{
|
||||||
|
"SENSUSRADIO_Authentification", //UInt96
|
||||||
"SENSUSRADIO_EncryptionKey", //UInt128
|
"SENSUSRADIO_EncryptionKey", //UInt128
|
||||||
|
"SENSUSRADIO_TfxSecondaryChannelInfo_1", //UInt48
|
||||||
|
"SENSUSRADIO_TfxSecondaryChannelInfo_2", //UInt48
|
||||||
|
"SENSUSRADIO_CustomerText", //UInt72
|
||||||
|
"SENSUSRADIO_Tfx_Structure", //UInt88
|
||||||
"GENESISFLOW_DisplayPow10", //SInt8
|
"GENESISFLOW_DisplayPow10", //SInt8
|
||||||
"METROLOGYASST_FlowPoint", //Enum8
|
"METROLOGYASST_FlowPoint", //Enum8
|
||||||
"CUSTOMER_SerialNumber", //String
|
"CUSTOMER_SerialNumber", //String
|
||||||
@@ -88,11 +94,9 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private static readonly List<String> _excludedFromCompareParameters = new List<String>
|
private static readonly List<String> _excludedFromCompareParameters = new List<String>
|
||||||
{
|
{
|
||||||
//THW 15-Aug-2024 reactivated "SYSTEM_UpgradePermissions",
|
"CUSTOMER_AlarmVisualMask", // Fully hard coded, cannot be overwritten
|
||||||
//// Once set to deviating from 0xFF it will maintain this after reboot,
|
"CUSTOMER_AlarmEnableMask", // Will be overwritten by SENSUSRADIO if set System state to 0xFF
|
||||||
//// it only can be overwritten temporary in RAM!
|
"CUSTOMER_AppArrangement", // Is read only, makes no sense to compare anything
|
||||||
|
|
||||||
"CUSTOMER_AlarmVisualMask", // Will be cyclically overwritten by SENSUSRADIO
|
|
||||||
"SENSUSRADIO_UpgFWVersion" // After a FW-Update the FW version has changed
|
"SENSUSRADIO_UpgFWVersion" // After a FW-Update the FW version has changed
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -102,22 +106,22 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private static readonly List<String> _excludedFromReadParameters = new List<String>
|
private static readonly List<String> _excludedFromReadParameters = new List<String>
|
||||||
{
|
{
|
||||||
|
"CUSTOMER_InternalLoginTest", // Does NOT respond
|
||||||
"CUSTOMER_AlarmVisualAutoClearMask", // Does NOT respond
|
"CUSTOMER_AlarmVisualAutoClearMask", // Does NOT respond
|
||||||
"SYSTEM_CustomerSerialNumber0", // Does NOT respond
|
|
||||||
"SYSTEM_CustomerSerialNumber1", // Does NOT respond
|
|
||||||
"SYSTEM_CustomerSerialNumber2", // Does NOT respond
|
|
||||||
"SYSTEM_CustomerSerialNumber3", // Does NOT respond
|
|
||||||
"SYSTEM_CRC", // Needs application number written to it
|
"SYSTEM_CRC", // Needs application number written to it
|
||||||
|
"SYSTEM_CRC32", // Needs application number written to it
|
||||||
"SYSTEM_ExitReason", // Needs application number written to it
|
"SYSTEM_ExitReason", // Needs application number written to it
|
||||||
"SYSTEM_DriveCapacity", // Needs drive number written to it
|
"SYSTEM_DriveCapacity", // Needs drive number written to it
|
||||||
"GENESISFLOW_TriggerActive", // Does NOT respond
|
"GENESISFLOW_TriggerActive", // Does NOT respond
|
||||||
"SENSUSRADIO_CurrentLoopMax", // Does NOT respond
|
"SENSUSRADIO_CurrentLoopMax", // Does NOT respond
|
||||||
"SENSUSRADIO_CurrentLoopSource", // Does NOT respond
|
"SENSUSRADIO_CurrentLoopSource", // Does NOT respond
|
||||||
"SENSUSRADIO_CustomerText" // Does NOT respond
|
"SENSUSRADIO_CustomerText", // Does NOT respond
|
||||||
|
"SENSUSRADIO_TfxSecondaryChannelInfo_1",// Does NOT respond
|
||||||
|
"SENSUSRADIO_TfxSecondaryChannelInfo_2" // Does NOT respond
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Pre programming parameters for all devices defined here, will be filled with radio parameters
|
/// Pre-programming parameters for all devices defined here, will be filled with radio parameters
|
||||||
/// if meter has radio
|
/// if meter has radio
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static readonly List<RecoveryRegisterItem> _prepareProgramming = new List<RecoveryRegisterItem>
|
private static readonly List<RecoveryRegisterItem> _prepareProgramming = new List<RecoveryRegisterItem>
|
||||||
@@ -128,9 +132,13 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
|
|
||||||
// ReSharper disable once CollectionNeverQueried.Local IS FOR DEBUG
|
// ReSharper disable once CollectionNeverQueried.Local IS FOR DEBUG
|
||||||
private readonly List<RecoveryRegisterItem> _failedComparisonRegisters = new List<RecoveryRegisterItem>();
|
private readonly List<RecoveryRegisterItem> _failedComparisonRegisters = new List<RecoveryRegisterItem>();
|
||||||
|
// ReSharper disable once CollectionNeverQueried.Local IS FOR DEBUG
|
||||||
private List<String> _dbParameterRegisterList = new List<String>();
|
private List<String> _dbParameterRegisterList = new List<String>();
|
||||||
|
// ReSharper disable once CollectionNeverQueried.Local IS FOR DEBUG
|
||||||
private List<String> _initialRegisterList = new List<String>();
|
private List<String> _initialRegisterList = new List<String>();
|
||||||
|
// ReSharper disable once CollectionNeverQueried.Local IS FOR DEBUG
|
||||||
private List<String> _finalRegisterList = new List<String>();
|
private List<String> _finalRegisterList = new List<String>();
|
||||||
|
// ReSharper disable once CollectionNeverQueried.Local IS FOR DEBUG
|
||||||
private readonly List<String> _readableRegisterList = new List<String>();
|
private readonly List<String> _readableRegisterList = new List<String>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -146,7 +154,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Post programming parameters for EMEA region (as NA region doesn't have radio and seal display shouldn't
|
/// Post programming parameters for EMEA region as NA region doesn't have radio and seal display shouldn't
|
||||||
/// be executed.
|
/// be executed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static readonly List<RecoveryRegisterItem> _finalizeProgrammingEmea = new List<RecoveryRegisterItem>
|
private static readonly List<RecoveryRegisterItem> _finalizeProgrammingEmea = new List<RecoveryRegisterItem>
|
||||||
@@ -184,6 +192,18 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private GenesisMeter _currentGenesis;
|
private GenesisMeter _currentGenesis;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Struct to observe replacements
|
||||||
|
/// </summary>
|
||||||
|
private struct ReplaceVakoByCsd
|
||||||
|
{
|
||||||
|
public String RegisterName;
|
||||||
|
// ReSharper disable once CollectionNeverQueried.Local IS FOR DEBUG
|
||||||
|
public List<Byte> VakoValue;
|
||||||
|
// ReSharper disable once CollectionNeverQueried.Local IS FOR DEBUG
|
||||||
|
public List<Byte> CsdValue;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ctor
|
/// Ctor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -208,53 +228,140 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Collect programming parameters from DB.
|
/// Enable comparison from external set registers for read back with written value
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="pcbId"></param>
|
/// <remarks date="2024-Nov-25" author="Thomas Wiedebusch">
|
||||||
/// <param name="recoveryRegistersDb">registers key value pair from data base</param>
|
/// - Initial
|
||||||
/// <returns>recovery registers</returns>
|
/// </remarks>
|
||||||
/// <remarks date="2021-Feb-01" author="Thomas Wiedebusch">
|
public void EnableCompareExternalSetRegisters()
|
||||||
|
{
|
||||||
|
_pcbIdFinalRegisterRead = _currentGenesis.PcbId;
|
||||||
|
_pcbIdWriteRegisters = _currentGenesis.PcbId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Export list of programming parameters to file being able to use it for test purposes.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <param name="fileName"></param>
|
||||||
|
/// <param name="programmingParameters"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <remarks date="2024-Dec-11" author="Thomas Wiedebusch">
|
||||||
/// - Initial.
|
/// - Initial.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <remarks date="2023-10-19" author="Thomas Wiedebusch">
|
public static Boolean ExportRawProgrammingParametersToFile(String path, String fileName,
|
||||||
/// - Sort the registers from DB but keep the PrepareProgramming and FinalizeProgramming in the required sequence.
|
List<ProgrammingParameters> programmingParameters)
|
||||||
/// </remarks>
|
|
||||||
/// <remarks date="2023-10-25" author="Thomas Wiedebusch">
|
|
||||||
/// - Removed preparation and finalization of register recovery to remove sequencing as this will be done in the
|
|
||||||
/// RegisterRestorer by the FwUpdateSw worker giving the ability to log this in the report.
|
|
||||||
/// </remarks>
|
|
||||||
/// <remarks date="2024-01-17" author="Thomas Wiedebusch">
|
|
||||||
/// - Data base access imported to have a common interface for programming parameters for EOL (shipping) and CUST.
|
|
||||||
/// </remarks>
|
|
||||||
/// <remarks date="2024-01-29" author="Thomas Wiedebusch">
|
|
||||||
/// - Removed prohibited parameters.
|
|
||||||
/// </remarks>
|
|
||||||
/// <remarks date="2024-02-12" author="Thomas Wiedebusch">
|
|
||||||
/// - Added un-reversed parameters based on data type (string, uint128).
|
|
||||||
/// </remarks>
|
|
||||||
/// <remarks date="2024-Apr-04..05" author="Thomas Wiedebusch">
|
|
||||||
/// - Check and validate register values with installed or intended to be installed FW and given configuration.json.
|
|
||||||
/// </remarks>
|
|
||||||
/// <remarks date="2024-Apr-08" author="Thomas Wiedebusch">
|
|
||||||
/// - Exported register range check to <see cref="ValidateRegisterRange"/>.
|
|
||||||
/// </remarks>
|
|
||||||
/// <remarks date="2024-Jul-05" author="Thomas Wiedebusch">
|
|
||||||
/// - Debug lists for CSD and VAKO parameters.
|
|
||||||
/// </remarks>
|
|
||||||
public static StatusReturn DownloadProgrammingParametersFromDb(String pcbId, List<RecoveryRegisterItem> recoveryRegistersDb)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var url = $"{ServiceUrls.GenesisFinalCheckServiceUrl()}GetProgrammingParameters?PcbID={pcbId}";
|
var fileNamePath = Path.Combine(path, fileName);
|
||||||
var ppJson = LocalWebRequest.GetRequest(url, 30000);
|
var text = JsonConvert.SerializeObject(programmingParameters);
|
||||||
|
File.WriteAllText(fileNamePath, text);
|
||||||
if (string.IsNullOrEmpty(ppJson))
|
}
|
||||||
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
return StatusReturn.Failed;
|
Console.WriteLine(e);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var programmingParameters = JsonConvert.DeserializeObject<List<ProgrammingParameters>>(ppJson);
|
return true;
|
||||||
if (programmingParameters == null || programmingParameters.Count == 0)
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Import list of programming parameters from file being able to use it for test purposes.
|
||||||
|
/// The input request the absolut path to the XX_YY_RawParameterExample.json and the filters for:
|
||||||
|
/// - Region,
|
||||||
|
/// - MeterSize,
|
||||||
|
/// - "RawParams" and
|
||||||
|
/// - ".json"
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="paramsRootPath">path where all raw parameter examples are stored</param>
|
||||||
|
/// <param name="region">Region for configuration</param>
|
||||||
|
/// <param name="meterSize">Meter size for programming parameters</param>
|
||||||
|
/// <param name="programmingParameters"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <remarks date="2024-Dec-11..13" author="Thomas Wiedebusch">
|
||||||
|
/// - Initial.
|
||||||
|
/// </remarks>
|
||||||
|
public static Boolean ImportRawProgrammingParametersFromFile(String paramsRootPath, String region,
|
||||||
|
String meterSize, List<ProgrammingParameters> programmingParameters)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(paramsRootPath) ||
|
||||||
|
string.IsNullOrEmpty(region) ||
|
||||||
|
string.IsNullOrEmpty(meterSize))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
programmingParameters.Clear();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var filePathNames = Directory.GetFiles(paramsRootPath);
|
||||||
|
if (filePathNames.Length == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
foreach (var filePathName in filePathNames)
|
||||||
|
{
|
||||||
|
var fileName = Path.GetFileName(filePathName);
|
||||||
|
if (fileName.Contains(region) &&
|
||||||
|
fileName.Contains(meterSize) &&
|
||||||
|
fileName.Contains("RawParams") &&
|
||||||
|
fileName.Contains(".json"))
|
||||||
|
{
|
||||||
|
var rawParamsFilePathMane = Path.Combine(paramsRootPath, fileName);
|
||||||
|
if (!File.Exists(rawParamsFilePathMane))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var text = File.ReadAllText(filePathName);
|
||||||
|
var progParams = JsonConvert.DeserializeObject<List<ProgrammingParameters>>(text);
|
||||||
|
programmingParameters.AddRange(progParams);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine(ex.Message);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Process the raw programming parameters got from the database or meanwhile in raw-format stored to file
|
||||||
|
/// being able to fill the register restorer from external with values and test the byte-wise reverting
|
||||||
|
/// of the parameter (optional un-reverted if defined in the list <see cref="_unReversedParameters"/>).
|
||||||
|
/// The priority of the parameters forced by its source is:
|
||||||
|
/// - CSD (highest),
|
||||||
|
/// - VAKO,
|
||||||
|
/// - Order based or standard config (lowest).
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="rawProgParams">unprocessed data, not filtered by the priority and un-reversed</param>
|
||||||
|
/// <param name="recoveryRegisters">output as recovery registers reduced to the real needed ones and
|
||||||
|
/// processed as reverted or non-reverted values which directly can be written to the meter using the
|
||||||
|
/// meter specific "IGenesisMeter.WriteRegister"</param>
|
||||||
|
/// <param name="errorMsg">error message for caller</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <remarks date="2024-Dec-11" author="Thomas Wiedebusch">
|
||||||
|
/// - Initial imported from <see cref="DownloadProgrammingParametersFromDb"/>.
|
||||||
|
/// </remarks>
|
||||||
|
/// <remarks date="2025-Jan-21" author="Thomas Wiedebusch">
|
||||||
|
/// - Return error message,
|
||||||
|
/// - Requirement to fulfill the at least one parameter has to be a CSD parameter as initially all programming
|
||||||
|
/// parameters are going to be preset with the default values (coming from the Web-API). After this they are
|
||||||
|
/// going to be overwritten with the VAKO (variant configuration) and finally again with the CSD of the
|
||||||
|
/// customer if required.
|
||||||
|
/// </remarks>
|
||||||
|
/// <remarks date="2025-Jan-28" author="Thomas Wiedebusch">
|
||||||
|
/// - Debug for overwriting VAKO with CSD including real values.
|
||||||
|
/// </remarks>
|
||||||
|
public static StatusReturn RawProgrammingParametersFilterAndSort(List<ProgrammingParameters> rawProgParams,
|
||||||
|
List<RecoveryRegisterItem> recoveryRegisters, out String errorMsg)
|
||||||
|
{
|
||||||
|
errorMsg = "";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (rawProgParams == null || rawProgParams.Count == 0)
|
||||||
{
|
{
|
||||||
return StatusReturn.Failed;
|
return StatusReturn.Failed;
|
||||||
}
|
}
|
||||||
@@ -262,7 +369,6 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
// Create DEBUG lists
|
// Create DEBUG lists
|
||||||
// ReSharper disable once CollectionNeverQueried.Local IS FOR DEBUG
|
// ReSharper disable once CollectionNeverQueried.Local IS FOR DEBUG
|
||||||
var vakoRegisterList = new List<String>();
|
var vakoRegisterList = new List<String>();
|
||||||
// ReSharper disable once CollectionNeverQueried.Local IS FOR DEBUG
|
|
||||||
var csdRegisterList = new List<String>();
|
var csdRegisterList = new List<String>();
|
||||||
// ReSharper disable once CollectionNeverQueried.Local IS FOR DEBUG
|
// ReSharper disable once CollectionNeverQueried.Local IS FOR DEBUG
|
||||||
var orderRegisterList = new List<String>();
|
var orderRegisterList = new List<String>();
|
||||||
@@ -270,20 +376,25 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
var sortableRegisterList = new List<String>();
|
var sortableRegisterList = new List<String>();
|
||||||
// ReSharper disable once CollectionNeverQueried.Local IS FOR DEBUG
|
// ReSharper disable once CollectionNeverQueried.Local IS FOR DEBUG
|
||||||
var multipleAssignedRegisterList = new List<String>();
|
var multipleAssignedRegisterList = new List<String>();
|
||||||
|
// ReSharper disable once CollectionNeverQueried.Local IS FOR DEBUG
|
||||||
|
var replacedVakoFromCsdList = new List<ReplaceVakoByCsd>();
|
||||||
|
|
||||||
// Temporary storage for sorting before assembling those registers with the preparation and
|
// Temporary storage for sorting before assembling those registers with the preparation and
|
||||||
// finalization of programming and therefore building a sequence
|
// finalization of programming and therefore building a sequence
|
||||||
var sortableProgrammingParameters = new List<ProgrammingParameters>();
|
var sortableProgrammingParameters = new List<ProgrammingParameters>();
|
||||||
|
|
||||||
foreach (var proPar in programmingParameters)
|
foreach (var proPar in rawProgParams)
|
||||||
{
|
{
|
||||||
// reverse byte order for all parameters except those listed below
|
// reverse byte order for all parameters except those listed below
|
||||||
if (!string.IsNullOrEmpty(proPar.RegisterName))
|
if (!string.IsNullOrEmpty(proPar.RegisterName))
|
||||||
{
|
{
|
||||||
// Fill DEBUG lists START
|
// Catch multiple assignments
|
||||||
if (sortableRegisterList.Any(a => proPar.RegisterName.Equals(a)))
|
if (sortableRegisterList.Any(a => proPar.RegisterName.Equals(a)))
|
||||||
multipleAssignedRegisterList.Add(proPar.RegisterName);
|
multipleAssignedRegisterList.Add(proPar.RegisterName);
|
||||||
|
|
||||||
|
// Fill DEBUG lists START with all registers even if they are multiple assigned
|
||||||
sortableRegisterList.Add(proPar.RegisterName);
|
sortableRegisterList.Add(proPar.RegisterName);
|
||||||
|
|
||||||
switch (proPar.Source)
|
switch (proPar.Source)
|
||||||
{
|
{
|
||||||
case ProgrammingSource.Vako:
|
case ProgrammingSource.Vako:
|
||||||
@@ -310,21 +421,37 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
proPar.RegisterName.Equals(a.RegisterName) && a.Source == ProgrammingSource.Vako))
|
proPar.RegisterName.Equals(a.RegisterName) && a.Source == ProgrammingSource.Vako))
|
||||||
{
|
{
|
||||||
var removeProPar =
|
var removeProPar =
|
||||||
sortableProgrammingParameters.Where(a => proPar.RegisterName.Equals(a.RegisterName));
|
sortableProgrammingParameters.LastOrDefault(a => proPar.RegisterName.Equals(a.RegisterName));
|
||||||
sortableProgrammingParameters.Remove(removeProPar.LastOrDefault());
|
|
||||||
|
var replace = new ReplaceVakoByCsd
|
||||||
|
{
|
||||||
|
RegisterName = proPar.RegisterName,
|
||||||
|
VakoValue = new List<Byte>(),
|
||||||
|
CsdValue = new List<Byte>()
|
||||||
|
};
|
||||||
|
|
||||||
|
if (removeProPar != null)
|
||||||
|
{
|
||||||
|
replace.VakoValue.AddRange(removeProPar.RegisterValue);
|
||||||
|
replace.CsdValue.AddRange(proPar.RegisterValue);
|
||||||
|
replacedVakoFromCsdList.Add(replace);
|
||||||
|
|
||||||
|
sortableProgrammingParameters.Remove(removeProPar);
|
||||||
sortableProgrammingParameters.Add(proPar);
|
sortableProgrammingParameters.Add(proPar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// ATTENTION: These parameters are coming out of the DB in wrong byte order and needed to be reversed
|
// ATTENTION: These parameters are coming out of the DB in wrong byte order and needed
|
||||||
// for the entire sequence
|
// to be reversed for the entire sequence
|
||||||
|
var reversedValue = proPar.RegisterValue.Reverse().ToArray();
|
||||||
|
|
||||||
// Add parameter if it is not in the list
|
// Add parameter if it is not in the list
|
||||||
if (sortableProgrammingParameters.All(a => !proPar.RegisterName.Equals(a.RegisterName)))
|
if (sortableProgrammingParameters.All(a => !proPar.RegisterName.Equals(a.RegisterName)))
|
||||||
{
|
{
|
||||||
sortableProgrammingParameters.Add(new ProgrammingParameters(proPar.RegisterName,
|
sortableProgrammingParameters.Add(new ProgrammingParameters(proPar.RegisterName,
|
||||||
proPar.RegisterValue.Reverse().ToArray(), proPar.Source));
|
reversedValue, proPar.Source));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// if parameter from VAKO is in the list and the new is from CSD, replace this with CSD
|
// if parameter from VAKO is in the list and the new is from CSD, replace this with CSD
|
||||||
@@ -332,10 +459,25 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
proPar.RegisterName.Equals(a.RegisterName) && a.Source == ProgrammingSource.Vako))
|
proPar.RegisterName.Equals(a.RegisterName) && a.Source == ProgrammingSource.Vako))
|
||||||
{
|
{
|
||||||
var removeProPar =
|
var removeProPar =
|
||||||
sortableProgrammingParameters.Where(a => proPar.RegisterName.Equals(a.RegisterName));
|
sortableProgrammingParameters.LastOrDefault(a => proPar.RegisterName.Equals(a.RegisterName));
|
||||||
sortableProgrammingParameters.Remove(removeProPar.LastOrDefault());
|
|
||||||
|
var replace = new ReplaceVakoByCsd
|
||||||
|
{
|
||||||
|
RegisterName = proPar.RegisterName,
|
||||||
|
VakoValue = new List<Byte>(),
|
||||||
|
CsdValue = new List<Byte>()
|
||||||
|
};
|
||||||
|
|
||||||
|
if (removeProPar != null)
|
||||||
|
{
|
||||||
|
replace.VakoValue.AddRange(removeProPar.RegisterValue);
|
||||||
|
replace.CsdValue.AddRange(reversedValue);
|
||||||
|
replacedVakoFromCsdList.Add(replace);
|
||||||
|
|
||||||
|
sortableProgrammingParameters.Remove(removeProPar);
|
||||||
sortableProgrammingParameters.Add(new ProgrammingParameters(proPar.RegisterName,
|
sortableProgrammingParameters.Add(new ProgrammingParameters(proPar.RegisterName,
|
||||||
proPar.RegisterValue.Reverse().ToArray(), proPar.Source));
|
reversedValue, proPar.Source));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // register for this FW is defined
|
} // register for this FW is defined
|
||||||
@@ -355,6 +497,8 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
orderRegisterList.Sort();
|
orderRegisterList.Sort();
|
||||||
sortableRegisterList.Sort();
|
sortableRegisterList.Sort();
|
||||||
multipleAssignedRegisterList.Sort();
|
multipleAssignedRegisterList.Sort();
|
||||||
|
replacedVakoFromCsdList.Sort((x, y) => string.Compare(x.RegisterName, y.RegisterName,
|
||||||
|
StringComparison.Ordinal));
|
||||||
|
|
||||||
// convert to RecoveryRegisterItem
|
// convert to RecoveryRegisterItem
|
||||||
if (sortableProgrammingParameters.Count > 0)
|
if (sortableProgrammingParameters.Count > 0)
|
||||||
@@ -362,10 +506,17 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
foreach (var proPar in sortableProgrammingParameters)
|
foreach (var proPar in sortableProgrammingParameters)
|
||||||
{
|
{
|
||||||
var recReg = new RecoveryRegisterItem(proPar.RegisterName, proPar.RegisterValue);
|
var recReg = new RecoveryRegisterItem(proPar.RegisterName, proPar.RegisterValue);
|
||||||
recoveryRegistersDb.Add(recReg);
|
recoveryRegisters.Add(recReg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Requirement to fulfill that at least one parameter has to be a CSD parameter
|
||||||
|
if (csdRegisterList.Count == 0)
|
||||||
|
{
|
||||||
|
errorMsg = Resources.StrErrorMsgCsdMissing;
|
||||||
|
return StatusReturn.Failed;
|
||||||
|
}
|
||||||
|
|
||||||
return StatusReturn.Okay;
|
return StatusReturn.Okay;
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
@@ -374,6 +525,79 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Collect programming parameters from DB.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pcbId"></param>
|
||||||
|
/// <param name="recoveryRegistersDb">registers key value pair from database</param>
|
||||||
|
/// <param name="errorMsg">error message from parameter analysis</param>
|
||||||
|
/// <returns>recovery registers</returns>
|
||||||
|
/// <remarks date="2021-Feb-01" author="Thomas Wiedebusch">
|
||||||
|
/// - Initial.
|
||||||
|
/// </remarks>
|
||||||
|
/// <remarks date="2023-10-19" author="Thomas Wiedebusch">
|
||||||
|
/// - Sort the registers from DB but keep the PrepareProgramming and FinalizeProgramming in the required sequence.
|
||||||
|
/// </remarks>
|
||||||
|
/// <remarks date="2023-10-25" author="Thomas Wiedebusch">
|
||||||
|
/// - Removed preparation and finalization of register recovery to remove sequencing as this will be done in the
|
||||||
|
/// RegisterRestorer by the FwUpdateSw worker giving the ability to log this in the report.
|
||||||
|
/// </remarks>
|
||||||
|
/// <remarks date="2024-01-17" author="Thomas Wiedebusch">
|
||||||
|
/// - Data base access imported to have a common interface for programming parameters for EOL (shipping) and CUST.
|
||||||
|
/// </remarks>
|
||||||
|
/// <remarks date="2024-01-29" author="Thomas Wiedebusch">
|
||||||
|
/// - Removed prohibited parameters.
|
||||||
|
/// </remarks>
|
||||||
|
/// <remarks date="2024-02-12" author="Thomas Wiedebusch">
|
||||||
|
/// - Added un-reversed parameters based on data type (string, uint128).
|
||||||
|
/// </remarks>
|
||||||
|
/// <remarks date="2024-Apr-04..05" author="Thomas Wiedebusch">
|
||||||
|
/// - Check and validate register values with installed or intended to be installed FW and given
|
||||||
|
/// configuration.json.
|
||||||
|
/// </remarks>
|
||||||
|
/// <remarks date="2024-Apr-08" author="Thomas Wiedebusch">
|
||||||
|
/// - Exported register range check to <see cref="ValidateRegisterRange"/>.
|
||||||
|
/// </remarks>
|
||||||
|
/// <remarks date="2024-Jul-05" author="Thomas Wiedebusch">
|
||||||
|
/// - Debug lists for CSD and VAKO parameters.
|
||||||
|
/// </remarks>
|
||||||
|
/// <remarks date="2024-Dec-11" author="Thomas Wiedebusch">
|
||||||
|
/// - Sorting, filtering for VAKO, CSD and order, reverting or un-reverting parameter value order exported
|
||||||
|
/// for the ability to load the raw programming parameters from any source and check the correct processing.
|
||||||
|
/// This will be especially used for unit-tests <see cref="RawProgrammingParametersFilterAndSort"/>
|
||||||
|
/// </remarks>
|
||||||
|
/// <remarks date="2025-Jan-21" author="Thomas Wiedebusch">
|
||||||
|
/// - Error message.
|
||||||
|
/// </remarks>
|
||||||
|
public static StatusReturn DownloadProgrammingParametersFromDb(String pcbId,
|
||||||
|
List<RecoveryRegisterItem> recoveryRegistersDb, out String errorMsg)
|
||||||
|
{
|
||||||
|
errorMsg = "";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var url = $"{ServiceUrls.GenesisFinalCheckServiceUrl()}GetProgrammingParameters?PcbID={pcbId}";
|
||||||
|
var ppJson = LocalWebRequest.GetRequest(url, 30000);
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(ppJson))
|
||||||
|
{
|
||||||
|
return StatusReturn.Failed;
|
||||||
|
}
|
||||||
|
|
||||||
|
var programmingParameters = JsonConvert.DeserializeObject<List<ProgrammingParameters>>(ppJson);
|
||||||
|
|
||||||
|
if (programmingParameters == null || programmingParameters.Count == 0)
|
||||||
|
{
|
||||||
|
return StatusReturn.Failed;
|
||||||
|
}
|
||||||
|
|
||||||
|
return RawProgrammingParametersFilterAndSort(programmingParameters, recoveryRegistersDb, out errorMsg);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return StatusReturn.Failed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Avoid doubling of register restore on subsequent FW-Update trials.
|
/// Avoid doubling of register restore on subsequent FW-Update trials.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -412,34 +636,28 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
/// <param name="recReg">register key value pair</param>
|
/// <param name="recReg">register key value pair</param>
|
||||||
/// <param name="regDef">register definition by configuration.json</param>
|
/// <param name="regDef">register definition by configuration.json</param>
|
||||||
/// <param name="errorMessage">error message if range check failed</param>
|
/// <param name="errorMessage">error message if range check failed</param>
|
||||||
|
/// <param name="checkDefault">check default value and supply warning</param>
|
||||||
/// <returns>status</returns>
|
/// <returns>status</returns>
|
||||||
/// <remarks date="2024-Apr-08" author="Thomas Wiedebusch">
|
/// <remarks date="2024-Apr-08" author="Thomas Wiedebusch">
|
||||||
/// - Initial, imported from <see cref="DownloadProgrammingParametersFromDb"/>
|
/// - Initial, imported from <see cref="DownloadProgrammingParametersFromDb"/>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
/// <remarks date="2024-Sep-25" author="Thomas Wiedebusch">
|
||||||
|
/// - Leave the message generation to the <see cref="RegisterCheck.CheckRange"/>
|
||||||
|
/// </remarks>
|
||||||
public static StatusReturn ValidateRegisterRange(RecoveryRegisterItem recReg,
|
public static StatusReturn ValidateRegisterRange(RecoveryRegisterItem recReg,
|
||||||
RegisterDefinition regDef, out String errorMessage)
|
RegisterDefinition regDef, out String errorMessage, Boolean checkDefault = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
// error message will return on failed check any information
|
// Error message will be returned on failed check or on default value
|
||||||
errorMessage = null;
|
errorMessage = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// check the limits and avoid writing if not in range
|
// check the limits and avoid writing if not in range
|
||||||
var check = RegisterCheck.CheckRange(regDef, recReg.WriteValue);
|
return RegisterCheck.CheckRange(regDef, recReg.WriteValue, out errorMessage, checkDefault);
|
||||||
if (!string.IsNullOrEmpty(check))
|
|
||||||
{
|
|
||||||
errorMessage = $"{Resources.StrRegisterValueOutOfRange}: " +
|
|
||||||
RegisterConverter.GetRegisterContentText(regDef, recReg.WriteValue) +
|
|
||||||
$" - Minimum ({regDef.Minimum})" +
|
|
||||||
$" - Maximum ({regDef.Maximum})";
|
|
||||||
|
|
||||||
return StatusReturn.Warning;
|
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
return StatusReturn.Okay;
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
{
|
||||||
|
errorMessage = ex.Message;
|
||||||
return StatusReturn.Failed;
|
return StatusReturn.Failed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -501,7 +719,10 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
/// <remarks date="2024-Jul-16" author="Thomas Wiedebusch">
|
/// <remarks date="2024-Jul-16" author="Thomas Wiedebusch">
|
||||||
/// - Seal display and Sensus radio to EMEA finalization.
|
/// - Seal display and Sensus radio to EMEA finalization.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public StatusReturn WriteRegisters(List<RecoveryRegisterItem> recoveryRegistersDb, Boolean eolProgramming = false)
|
/// <remarks date="2025-Feb-14" author="Thomas Wiedebusch">
|
||||||
|
/// - Exported write routines to <see cref="WriteRegisterParameterSet"/>.
|
||||||
|
/// </remarks>
|
||||||
|
private StatusReturn WriteRegisters(List<RecoveryRegisterItem> recoveryRegistersDb, Boolean eolProgramming = false)
|
||||||
{
|
{
|
||||||
if (_currentGenesis == null ||
|
if (_currentGenesis == null ||
|
||||||
string.IsNullOrEmpty(_currentGenesis.PcbId) ||
|
string.IsNullOrEmpty(_currentGenesis.PcbId) ||
|
||||||
@@ -509,8 +730,6 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
recoveryRegistersDb.Count == 0)
|
recoveryRegistersDb.Count == 0)
|
||||||
return StatusReturn.Failed;
|
return StatusReturn.Failed;
|
||||||
|
|
||||||
var retVal = StatusReturn.Okay;
|
|
||||||
|
|
||||||
// preset recovery registers if not already set
|
// preset recovery registers if not already set
|
||||||
if (RecoveryRegisters == null)
|
if (RecoveryRegisters == null)
|
||||||
{
|
{
|
||||||
@@ -568,59 +787,87 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
OnProcessUpdate?.Invoke(this, new ProcessExecEventArgs(Resources.StrRegisterRecoveryPreparation,
|
OnProcessUpdate?.Invoke(this, new ProcessExecEventArgs(Resources.StrRegisterRecoveryPreparation,
|
||||||
actualProcessMessage: Resources.StrRegisterRecoveryPreparation));
|
actualProcessMessage: Resources.StrRegisterRecoveryPreparation));
|
||||||
|
|
||||||
foreach (var prepRecReg in _prepareProgramming)
|
if (StatusReturn.Failed == WriteRegisterParameterSet(_prepareProgramming, recRegistersCount, meterRegisters))
|
||||||
{
|
{
|
||||||
_actualRegisterCtr++;
|
// the logout will force the radio app to activate the settings
|
||||||
var overallProcessCtrPercent = 100.0 * _actualRegisterCtr / recRegistersCount;
|
_currentGenesis?.Logout();
|
||||||
|
return StatusReturn.Failed;
|
||||||
try
|
|
||||||
{
|
|
||||||
// if this call does not throw an exception, the register is present
|
|
||||||
var regDef = meterRegisters.GetRegisterDefinitionByName(prepRecReg.RegisterIdent);
|
|
||||||
|
|
||||||
_currentGenesis.WriteRegister(prepRecReg.RegisterIdent, prepRecReg.WriteValue);
|
|
||||||
|
|
||||||
var strRawAndConvertedValue = "";
|
|
||||||
try
|
|
||||||
{
|
|
||||||
strRawAndConvertedValue = RegisterConverter.GetRegisterContentText(regDef, prepRecReg.WriteValue);
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_currentGenesis.WriteLog("Could not convert register value of " + prepRecReg.RegisterIdent +
|
|
||||||
"; " + ex.Message);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
var actualProcessMsg = $"{Resources.StrWriteRegister}: {strRawAndConvertedValue} ";
|
|
||||||
|
|
||||||
OnProcessUpdate?.Invoke(this, new ProcessExecEventArgs($@"{Resources.StrWriteRegister}" +
|
|
||||||
$@" {_actualRegisterCtr} / {recRegistersCount}",
|
|
||||||
overallProcessCtrPercent, actualProcessMsg));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StopRegisterAccess)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_currentGenesis.WriteLog("Could not write register value of " + prepRecReg.RegisterIdent +
|
|
||||||
"; " + ex.Message);
|
|
||||||
}
|
|
||||||
}// prepare recovery
|
|
||||||
|
|
||||||
// register recovery
|
// register recovery
|
||||||
OnProcessUpdate?.Invoke(this, new ProcessExecEventArgs(Resources.StrRegisterRecoveryExec,
|
OnProcessUpdate?.Invoke(this, new ProcessExecEventArgs(Resources.StrRegisterRecoveryExec,
|
||||||
actualProcessMessage: Resources.StrRegisterRecoveryExec));
|
actualProcessMessage: Resources.StrRegisterRecoveryExec));
|
||||||
|
|
||||||
|
if (StatusReturn.Failed == WriteRegisterParameterSet(recoveryRegistersDb, recRegistersCount, meterRegisters))
|
||||||
|
{
|
||||||
|
// the logout will force the radio app to activate the settings
|
||||||
|
_currentGenesis?.Logout();
|
||||||
|
return StatusReturn.Failed;
|
||||||
|
}
|
||||||
|
|
||||||
|
// finalize recovery
|
||||||
|
OnProcessUpdate?.Invoke(this, new ProcessExecEventArgs(Resources.StrRegisterRecoveryFinalization,
|
||||||
|
actualProcessMessage: Resources.StrRegisterRecoveryFinalization));
|
||||||
|
|
||||||
|
if (StatusReturn.Failed == WriteRegisterParameterSet(finalizeProgrammingAll, recRegistersCount, meterRegisters))
|
||||||
|
{
|
||||||
|
// the logout will force the radio app to activate the settings
|
||||||
|
_currentGenesis?.Logout();
|
||||||
|
return StatusReturn.Failed;
|
||||||
|
}
|
||||||
|
|
||||||
|
// remind pcbId of this run to avoid endless repetition
|
||||||
|
_pcbIdWriteRegisters = _currentGenesis.PcbId;
|
||||||
|
|
||||||
|
// the logout will force the radio app to activate the settings
|
||||||
|
_currentGenesis?.Logout();
|
||||||
|
|
||||||
|
// Wait for completion as storing may need a certain time
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
|
return StatusReturn.Okay;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Write a parameter set:
|
||||||
|
/// -
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="recoveryRegistersDb"></param>
|
||||||
|
/// <param name="recRegistersCount"></param>
|
||||||
|
/// <param name="meterRegisters"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <remarks date="2025-Feb-14" author="Thomas Wiedebusch">
|
||||||
|
/// - Initial imported from <see cref="WriteRegisters"/>.
|
||||||
|
/// </remarks>
|
||||||
|
private StatusReturn WriteRegisterParameterSet(List<RecoveryRegisterItem> recoveryRegistersDb, Int32 recRegistersCount,
|
||||||
|
MeterRegisters meterRegisters)
|
||||||
|
{
|
||||||
foreach (var recReg in recoveryRegistersDb)
|
foreach (var recReg in recoveryRegistersDb)
|
||||||
{
|
{
|
||||||
_actualRegisterCtr++;
|
_actualRegisterCtr++;
|
||||||
var overallProcessCtrPercent = 100.0 * _actualRegisterCtr / recRegistersCount;
|
var overallProcessCtrPercent = 100.0 * _actualRegisterCtr / recRegistersCount;
|
||||||
|
|
||||||
|
RegisterDefinition regDef;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// if this call does not throw an exception, the register is present
|
// If this call does not throw an exception, the register is present
|
||||||
var regDef = meterRegisters.GetRegisterDefinitionByName(recReg.RegisterIdent);
|
regDef = meterRegisters.GetRegisterDefinitionByName(recReg.RegisterIdent);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_currentGenesis.WriteLog(ex.Message);
|
||||||
|
regDef = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null == regDef)
|
||||||
|
{
|
||||||
|
OnProcessUpdate?.Invoke(this, new ProcessExecEventArgs(
|
||||||
|
$@"{Resources.StrWriteRegister} {_actualRegisterCtr} / {recRegistersCount}",
|
||||||
|
overallProcessCtrPercent, Resources.StrErrorMsgRegisterNotFound + " Register: " +
|
||||||
|
recReg.RegisterIdent));
|
||||||
|
return StatusReturn.Failed;
|
||||||
|
}
|
||||||
|
|
||||||
// avoid writing of NOT writable registers
|
// avoid writing of NOT writable registers
|
||||||
if (regDef.RegisterDetail.Privilege.Lvl8 != Access.WO
|
if (regDef.RegisterDetail.Privilege.Lvl8 != Access.WO
|
||||||
@@ -628,19 +875,25 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// check the limits and avoid writing if not in range
|
// check the limits and avoid writing if not in range
|
||||||
retVal = ValidateRegisterRange(recReg, regDef, out var errorMessage);
|
var retVal = ValidateRegisterRange(recReg, regDef, out var errorMessage);
|
||||||
if (StatusReturn.Okay != retVal)
|
if (StatusReturn.Failed == retVal)
|
||||||
{
|
{
|
||||||
_currentGenesis.WriteLog(errorMessage);
|
_currentGenesis.WriteLog(errorMessage);
|
||||||
|
OnProcessUpdate?.Invoke(this, new ProcessExecEventArgs(
|
||||||
OnProcessUpdate?.Invoke(this, new ProcessExecEventArgs($@"{Resources.StrWriteRegister}" +
|
$@"{Resources.StrWriteRegister} {_actualRegisterCtr} / {recRegistersCount}",
|
||||||
$@" {_actualRegisterCtr} / {recRegistersCount}",
|
overallProcessCtrPercent, Resources.StrRegisterValueOutOfRange + " " + errorMessage));
|
||||||
overallProcessCtrPercent, errorMessage));
|
return StatusReturn.Failed;
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_currentGenesis.WriteRegister(recReg.RegisterIdent, recReg.WriteValue);
|
if (!_currentGenesis.WriteRegister(recReg.RegisterIdent, recReg.WriteValue))
|
||||||
|
{
|
||||||
|
OnProcessUpdate?.Invoke(this, new ProcessExecEventArgs(
|
||||||
|
$@"{Resources.StrWriteRegister} {_actualRegisterCtr} / {recRegistersCount}",
|
||||||
|
overallProcessCtrPercent, Resources.StrErrorMsgRegisterWrite + " Register: " +
|
||||||
|
recReg.RegisterIdent));
|
||||||
|
return StatusReturn.Failed;
|
||||||
|
|
||||||
|
}
|
||||||
var strRawAndConvertedValue = "";
|
var strRawAndConvertedValue = "";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -655,75 +908,16 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
{
|
{
|
||||||
var actualProcessMsg = $"{Resources.StrWriteRegister}: {strRawAndConvertedValue} ";
|
var actualProcessMsg = $"{Resources.StrWriteRegister}: {strRawAndConvertedValue} ";
|
||||||
|
|
||||||
OnProcessUpdate?.Invoke(this, new ProcessExecEventArgs($@"{Resources.StrWriteRegister}" +
|
OnProcessUpdate?.Invoke(this, new ProcessExecEventArgs(
|
||||||
$@" {_actualRegisterCtr} / {recRegistersCount}",
|
$@"{Resources.StrWriteRegister} {_actualRegisterCtr} / {recRegistersCount}",
|
||||||
overallProcessCtrPercent, actualProcessMsg));
|
overallProcessCtrPercent, actualProcessMsg));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StopRegisterAccess)
|
if (StopRegisterAccess)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_currentGenesis.WriteLog("Could not write register value of " + recReg.RegisterIdent +
|
|
||||||
"; " + ex.Message);
|
|
||||||
}
|
|
||||||
}// recovery registers
|
|
||||||
|
|
||||||
// finalize recovery
|
return StatusReturn.Okay;
|
||||||
OnProcessUpdate?.Invoke(this, new ProcessExecEventArgs(Resources.StrRegisterRecoveryFinalization,
|
|
||||||
actualProcessMessage: Resources.StrRegisterRecoveryFinalization));
|
|
||||||
foreach (var finalRecReg in finalizeProgrammingAll)
|
|
||||||
{
|
|
||||||
_actualRegisterCtr++;
|
|
||||||
var overallProcessCtrPercent = 100.0 * _actualRegisterCtr / recRegistersCount;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_currentGenesis.WriteRegister(finalRecReg.RegisterIdent, finalRecReg.WriteValue);
|
|
||||||
|
|
||||||
// if this call does not throw an exception, the register is present
|
|
||||||
var regDef = meterRegisters.GetRegisterDefinitionByName(finalRecReg.RegisterIdent);
|
|
||||||
|
|
||||||
var strRawAndConvertedValue = "";
|
|
||||||
try
|
|
||||||
{
|
|
||||||
strRawAndConvertedValue = RegisterConverter.GetRegisterContentText(regDef, finalRecReg.WriteValue);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_currentGenesis.WriteLog("Could not convert register value of " + finalRecReg.RegisterIdent + "; "
|
|
||||||
+ ex.Message);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
var actualProcessMsg = $"{Resources.StrWriteRegister}: {strRawAndConvertedValue} ";
|
|
||||||
|
|
||||||
OnProcessUpdate?.Invoke(this, new ProcessExecEventArgs($@"{Resources.StrWriteRegister}" +
|
|
||||||
$@" {_actualRegisterCtr} / {recRegistersCount}",
|
|
||||||
overallProcessCtrPercent, actualProcessMsg));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StopRegisterAccess)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_currentGenesis.WriteLog("Could not write register value of " + finalRecReg.RegisterIdent +
|
|
||||||
"; " + ex.Message);
|
|
||||||
}
|
|
||||||
}// finalize recovery
|
|
||||||
|
|
||||||
// remind pcbId of this run to avoid endless repetition
|
|
||||||
_pcbIdWriteRegisters = _currentGenesis.PcbId;
|
|
||||||
|
|
||||||
// the logout will force the radio app to activate the settings
|
|
||||||
_currentGenesis?.Logout();
|
|
||||||
|
|
||||||
// Wait for completion as storing may need a certain time
|
|
||||||
Thread.Sleep(1000);
|
|
||||||
|
|
||||||
return retVal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -912,7 +1106,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
var strReadBackRegisterValue = RegisterConverter.GetRegisterRawText(regDef, readBackValue,
|
var strReadBackRegisterValue = RegisterConverter.GetRegisterRawText(regDef, readBackValue,
|
||||||
encryptRawData);
|
encryptRawData);
|
||||||
|
|
||||||
strRequiredRegisterValue += $" - {Resources.StrMeterValue}: ({strReadBackRegisterValue})" +
|
strRequiredRegisterValue += $" - {Resources.StrMeterValue} ({strReadBackRegisterValue})h" +
|
||||||
$" - {Resources.StrRegisterCompareFailed}";
|
$" - {Resources.StrRegisterCompareFailed}";
|
||||||
_failedComparisonRegisters?.Add(new RecoveryRegisterItem(regName, writtenValue,
|
_failedComparisonRegisters?.Add(new RecoveryRegisterItem(regName, writtenValue,
|
||||||
readBackValue));
|
readBackValue));
|
||||||
@@ -925,7 +1119,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
var actualProcessMsg = $"{Resources.StrRegisterCompare}: {strRequiredRegisterValue} ";
|
var actualProcessMsg = $"{Resources.StrRegisterCompare} {strRequiredRegisterValue} ";
|
||||||
|
|
||||||
// Avoid message if nothing to tell
|
// Avoid message if nothing to tell
|
||||||
if (!string.IsNullOrEmpty(strRequiredRegisterValue))
|
if (!string.IsNullOrEmpty(strRequiredRegisterValue))
|
||||||
@@ -960,7 +1154,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <remarks date="2020-Dec-21" author="Thomas Wiedebusch">
|
/// <remarks date="2020-Dec-21" author="Thomas Wiedebusch">
|
||||||
/// - Clear pre update registers if post indicates a different PCB ID to avoid wrong overwriting of
|
/// - Clear pre update registers if post indicates a different PCB ID to avoid wrong overwriting of
|
||||||
/// registers to non matching new meter.
|
/// registers to non-matching new meter.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <remarks date="2023-Oct-24" author="Thomas Wiedebusch">
|
/// <remarks date="2023-Oct-24" author="Thomas Wiedebusch">
|
||||||
/// - Return true if already executed in previous run.
|
/// - Return true if already executed in previous run.
|
||||||
@@ -977,11 +1171,18 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
/// <remarks date="2024-Mar-06" author="Thomas Wiedebusch">
|
/// <remarks date="2024-Mar-06" author="Thomas Wiedebusch">
|
||||||
/// - Backup _finalRegisters to RecoveryRegisters.
|
/// - Backup _finalRegisters to RecoveryRegisters.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
/// <remarks date="2024-Dec-12" author="Thomas Wiedebusch">
|
||||||
|
/// - Check readBack value for null.
|
||||||
|
/// </remarks>
|
||||||
public Boolean FinalReadRegisters()
|
public Boolean FinalReadRegisters()
|
||||||
{
|
{
|
||||||
if (_currentGenesis == null)
|
if (_currentGenesis == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
Boolean retVal;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
// create a dictionary for final read being able to compare those with the initial read and restored
|
// create a dictionary for final read being able to compare those with the initial read and restored
|
||||||
if (!BuildReadableRegisterDictionary(ref _finalRegisters))
|
if (!BuildReadableRegisterDictionary(ref _finalRegisters))
|
||||||
return false;
|
return false;
|
||||||
@@ -996,7 +1197,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
_finalRegisterList.Sort();
|
_finalRegisterList.Sort();
|
||||||
|
|
||||||
// executes login read logout
|
// executes login read logout
|
||||||
var retVal = ReadRegistersSet(ref _finalRegisters);
|
retVal = ReadRegistersSet(ref _finalRegisters);
|
||||||
|
|
||||||
// backup read data to RecoveryRegisters
|
// backup read data to RecoveryRegisters
|
||||||
if (RecoveryRegisters != null && _finalRegisters != null)
|
if (RecoveryRegisters != null && _finalRegisters != null)
|
||||||
@@ -1006,6 +1207,12 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
foreach (var finalReg in _finalRegisters.Where(finalReg =>
|
foreach (var finalReg in _finalRegisters.Where(finalReg =>
|
||||||
recReg.RegisterIdent.Equals(finalReg.RegisterIdent)))
|
recReg.RegisterIdent.Equals(finalReg.RegisterIdent)))
|
||||||
{
|
{
|
||||||
|
if (finalReg.ReadBackValue == null)
|
||||||
|
{
|
||||||
|
recReg.ReadBackValue = null;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
recReg.ReadBackValue = new Byte[finalReg.ReadBackValue.Length];
|
recReg.ReadBackValue = new Byte[finalReg.ReadBackValue.Length];
|
||||||
for (var c = 0; c < finalReg.ReadBackValue.Length; c++)
|
for (var c = 0; c < finalReg.ReadBackValue.Length; c++)
|
||||||
recReg.ReadBackValue[c] = finalReg.ReadBackValue[c];
|
recReg.ReadBackValue[c] = finalReg.ReadBackValue[c];
|
||||||
@@ -1016,6 +1223,12 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
// remind the PCB ID before update for comparison
|
// remind the PCB ID before update for comparison
|
||||||
_pcbIdFinalRegisterRead = _currentGenesis.PcbId;
|
_pcbIdFinalRegisterRead = _currentGenesis.PcbId;
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_currentGenesis.WriteLog("Copying read back data failed " + ex.Message);
|
||||||
|
retVal = false;
|
||||||
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1156,6 +1369,27 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
return ReadRegistersSet(ref registers);
|
return ReadRegistersSet(ref registers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Read predefined registers from RecoveryRegisters.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>true if registers could be read</returns>
|
||||||
|
/// <remarks date="2024-Sep-25" author="Thomas Wiedebusch">
|
||||||
|
/// - Initial.
|
||||||
|
/// </remarks>
|
||||||
|
public Boolean ReadPresetRegisters()
|
||||||
|
{
|
||||||
|
if (_currentGenesis == null || RecoveryRegisters == null || RecoveryRegisters.Count == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Assume that this meter shall be used for comparison even if nothing has been written.
|
||||||
|
// The RecoveryRegisters can be preset with a writeValue being able to use FinalReadRegisters
|
||||||
|
// and compare the readBackValue from those with the preset writeValue.
|
||||||
|
_pcbIdWriteRegisters = _currentGenesis.PcbId;
|
||||||
|
_pcbIdFinalRegisterRead = _currentGenesis.PcbId;
|
||||||
|
|
||||||
|
return ReadRegistersSet(ref RecoveryRegisters);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Register read loop.
|
/// Register read loop.
|
||||||
/// All registers needed to be read from the Genesis meter as they are only prepared as template and NOT filled
|
/// All registers needed to be read from the Genesis meter as they are only prepared as template and NOT filled
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,8 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers.DataTypes
|
||||||
|
{
|
||||||
|
public struct UInt48
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers.DataTypes
|
||||||
|
{
|
||||||
|
public struct UInt72
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers.DataTypes
|
||||||
|
{
|
||||||
|
public struct UInt88
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -122,6 +122,11 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Unimplemented
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="NotImplementedException"></exception>
|
||||||
public IEnumerator GetEnumerator()
|
public IEnumerator GetEnumerator()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
|||||||
+90
@@ -0,0 +1,90 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Runtime Version:4.0.30319.42000
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers.Properties {
|
||||||
|
using System;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||||
|
/// </summary>
|
||||||
|
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||||
|
// class via a tool like ResGen or Visual Studio.
|
||||||
|
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||||
|
// with the /str option, or rebuild your VS project.
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
internal class Resources {
|
||||||
|
|
||||||
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
|
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||||
|
|
||||||
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||||
|
internal Resources() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the cached ResourceManager instance used by this class.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||||
|
get {
|
||||||
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Xylem.Common.Hardware.WaterMeter.Genesis.Registers.Properties.Resources", typeof(Resources).Assembly);
|
||||||
|
resourceMan = temp;
|
||||||
|
}
|
||||||
|
return resourceMan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Overrides the current thread's CurrentUICulture property for all
|
||||||
|
/// resource lookups using this strongly typed resource class.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Globalization.CultureInfo Culture {
|
||||||
|
get {
|
||||||
|
return resourceCulture;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
resourceCulture = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to ERROR: Register data type unknown.
|
||||||
|
/// </summary>
|
||||||
|
internal static string StrRegisterDataTypeUnknown {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("StrRegisterDataTypeUnknown", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to ERROR: Register value is out of range.
|
||||||
|
/// </summary>
|
||||||
|
internal static string StrRegisterValueOutOfRange {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("StrRegisterValueOutOfRange", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to WARNING: Register value is set to default.
|
||||||
|
/// </summary>
|
||||||
|
internal static string StrSetRegisterToDefault {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("StrSetRegisterToDefault", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 1.3
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">1.3</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1">this is my long string</data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
[base64 mime encoded serialized .NET Framework object]
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
[base64 mime encoded string representing a byte array form of the .NET Framework object]
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>1.3</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<data name="StrSetRegisterToDefault" xml:space="preserve">
|
||||||
|
<value>WARNUNG: Registerwert auf Standardwert gesetzt</value>
|
||||||
|
</data>
|
||||||
|
<data name="StrRegisterValueOutOfRange" xml:space="preserve">
|
||||||
|
<value>FEHLER: Registerwert außerhalb des zulässigen Bereiches</value>
|
||||||
|
</data>
|
||||||
|
<data name="StrRegisterDataTypeUnknown" xml:space="preserve">
|
||||||
|
<value>FEHLER: Registerdatentyp ist unbekannt!</value>
|
||||||
|
</data>
|
||||||
|
</root>
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<data name="StrSetRegisterToDefault" xml:space="preserve">
|
||||||
|
<value>WARNING: Register value is set to default</value>
|
||||||
|
</data>
|
||||||
|
<data name="StrRegisterValueOutOfRange" xml:space="preserve">
|
||||||
|
<value>ERROR: Register value is out of range</value>
|
||||||
|
</data>
|
||||||
|
<data name="StrRegisterDataTypeUnknown" xml:space="preserve">
|
||||||
|
<value>ERROR: Register data type unknown</value>
|
||||||
|
</data>
|
||||||
|
</root>
|
||||||
@@ -1,142 +1,264 @@
|
|||||||
using System;
|
using System;
|
||||||
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers.DataTypes;
|
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers.DataTypes;
|
||||||
|
using Xylem.Common.CommonCore.Consts;
|
||||||
|
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers.Properties;
|
||||||
|
|
||||||
namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers
|
namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Check the register value for Out Of Boundaries (min, max) and optional if set to Default .
|
||||||
|
/// </summary>
|
||||||
public static class RegisterCheck
|
public static class RegisterCheck
|
||||||
{
|
{
|
||||||
private static String OutOfRangeMsg(Boolean isMin, String value, String range, String name)
|
private enum RangeCheck
|
||||||
{
|
{
|
||||||
return isMin ? $" Register {name} value ({value}) is to small - minimum is ({range})" :
|
MinimumExceeded,
|
||||||
$" Register {name} value ({value}) is to large - maximum is ({range})";
|
MaximumExceeded,
|
||||||
|
DefaultValue,
|
||||||
|
NotConvertible
|
||||||
|
};
|
||||||
|
private static String OutOfRangeMsg(RangeCheck rangeCheck, String value, String range, String name)
|
||||||
|
{
|
||||||
|
var msg = "";
|
||||||
|
switch (rangeCheck)
|
||||||
|
{
|
||||||
|
case RangeCheck.DefaultValue:
|
||||||
|
msg = $"{Resources.StrSetRegisterToDefault} {name}: ({value})";
|
||||||
|
break;
|
||||||
|
case RangeCheck.MaximumExceeded:
|
||||||
|
msg = $"{Resources.StrRegisterValueOutOfRange} {name}: ({value}) - Maximum ({range})";
|
||||||
|
break;
|
||||||
|
case RangeCheck.MinimumExceeded:
|
||||||
|
msg = $"{Resources.StrRegisterValueOutOfRange} {name}: ({value}) - Minimum ({range})";
|
||||||
|
break;
|
||||||
|
case RangeCheck.NotConvertible:
|
||||||
|
msg = $"{Resources.StrRegisterDataTypeUnknown} {name}";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return msg;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check the registers for ot of range (below minimum or above maximum) and return empty string
|
/// Check the registers for ot of range (below minimum or above maximum) and return empty string
|
||||||
/// if impossible to check (unset limits) or in range.
|
/// if impossible to check (unset limits) or in range.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="reg"></param>
|
/// <param name="regDef"></param>
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
/// <returns>empty string for in range or unset limits or out of range message</returns>
|
/// <param name="msg">feedback message</param>
|
||||||
|
/// <param name="checkIfValueIsDefault">forces a warning if value is set to default</param>
|
||||||
|
/// <returns>
|
||||||
|
/// <see cref="StatusReturn.Warning"/> if default and check for this is required
|
||||||
|
/// <see cref="StatusReturn.Okay"/>if the value is in range or has no range defined
|
||||||
|
/// <see cref="StatusReturn.Failed"/>if value exceeds the limits
|
||||||
|
/// </returns>
|
||||||
/// <remarks date="????" author="Roland Drabesch">
|
/// <remarks date="????" author="Roland Drabesch">
|
||||||
/// - Init.
|
/// - Init.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <remarks date="2024-Mar-21" author="Thomas Wiedebusch">
|
/// <remarks date="2024-Mar-21" author="Thomas Wiedebusch">
|
||||||
/// - Modified with try catch block.
|
/// - Modified with try catch block.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static String CheckRange(RegisterDefinition reg, Byte[] value)
|
/// <remarks date="2024-Sep-25" author="Thomas Wiedebusch">
|
||||||
|
/// - Returns warning on default, else error or okay.
|
||||||
|
/// </remarks>
|
||||||
|
/// <remarks date="2025-Feb-13" author="Thomas Wiedebusch">
|
||||||
|
/// - Ignore TimeT.
|
||||||
|
/// </remarks>
|
||||||
|
public static StatusReturn CheckRange(RegisterDefinition regDef, Byte[] value, out String msg,
|
||||||
|
Boolean checkIfValueIsDefault = false)
|
||||||
{
|
{
|
||||||
// for all registers without min and max a
|
msg = "";
|
||||||
if (!reg.Minimum.HasValue && !reg.Maximum.HasValue)
|
// for all registers without min and max or if type is of TimeT
|
||||||
|
if ((!regDef.Minimum.HasValue && !regDef.Maximum.HasValue) || regDef.DataType == typeof(TimeT))
|
||||||
{
|
{
|
||||||
return string.Empty;
|
return StatusReturn.Okay;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var type = reg.DataType;
|
var type = regDef.DataType;
|
||||||
if (type == typeof(UInt16))
|
if (type == typeof(UInt16))
|
||||||
{
|
{
|
||||||
var checkValue = RegisterConverter.ByteArrayToValue<UInt16>(value);
|
var checkValue = RegisterConverter.ByteArrayToValue<UInt16>(value);
|
||||||
if (reg.Minimum.HasValue && checkValue < reg.Minimum.Value)
|
if (regDef.Minimum.HasValue && checkValue < regDef.Minimum.Value)
|
||||||
{
|
{
|
||||||
return OutOfRangeMsg(true, checkValue.ToString(), reg.Minimum.Value.ToString(), reg.GetIdent());
|
msg = OutOfRangeMsg(RangeCheck.MinimumExceeded, checkValue.ToString(),
|
||||||
|
regDef.Minimum.Value.ToString(), regDef.GetIdent());
|
||||||
|
return StatusReturn.Failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reg.Maximum.HasValue && checkValue > reg.Maximum.Value)
|
if (regDef.Maximum.HasValue && checkValue > regDef.Maximum.Value)
|
||||||
{
|
{
|
||||||
return OutOfRangeMsg(false, checkValue.ToString(), reg.Maximum.Value.ToString(), reg.GetIdent());
|
msg = OutOfRangeMsg(RangeCheck.MaximumExceeded, checkValue.ToString(),
|
||||||
|
regDef.Maximum.Value.ToString(), regDef.GetIdent());
|
||||||
|
return StatusReturn.Failed;
|
||||||
|
}
|
||||||
|
if (checkIfValueIsDefault && regDef.Default.HasValue && checkValue == regDef.Default.Value)
|
||||||
|
{
|
||||||
|
msg = OutOfRangeMsg(RangeCheck.DefaultValue, checkValue.ToString(),
|
||||||
|
regDef.Default.Value.ToString(), regDef.GetIdent());
|
||||||
|
return StatusReturn.Warning;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (type == typeof(UInt32))
|
else if (type == typeof(UInt32))
|
||||||
{
|
{
|
||||||
var checkValue = RegisterConverter.ByteArrayToValue<UInt32>(value);
|
var checkValue = RegisterConverter.ByteArrayToValue<UInt32>(value);
|
||||||
if (reg.Minimum.HasValue && checkValue < reg.Minimum.Value)
|
if (regDef.Minimum.HasValue && checkValue < regDef.Minimum.Value)
|
||||||
{
|
{
|
||||||
return OutOfRangeMsg(true, checkValue.ToString(), reg.Minimum.Value.ToString(), reg.GetIdent());
|
msg = OutOfRangeMsg(RangeCheck.MinimumExceeded, checkValue.ToString(),
|
||||||
|
regDef.Minimum.Value.ToString(), regDef.GetIdent());
|
||||||
|
return StatusReturn.Failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reg.Maximum.HasValue && checkValue > reg.Maximum.Value)
|
if (regDef.Maximum.HasValue && checkValue > regDef.Maximum.Value)
|
||||||
{
|
{
|
||||||
return OutOfRangeMsg(false, checkValue.ToString(), reg.Maximum.Value.ToString(), reg.GetIdent());
|
msg = OutOfRangeMsg(RangeCheck.MaximumExceeded, checkValue.ToString(),
|
||||||
|
regDef.Maximum.Value.ToString(), regDef.GetIdent());
|
||||||
|
return StatusReturn.Failed;
|
||||||
|
}
|
||||||
|
if (checkIfValueIsDefault && regDef.Default.HasValue && checkValue == regDef.Default.Value)
|
||||||
|
{
|
||||||
|
msg = OutOfRangeMsg(RangeCheck.DefaultValue, checkValue.ToString(),
|
||||||
|
regDef.Default.Value.ToString(), regDef.GetIdent());
|
||||||
|
return StatusReturn.Warning;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (type == typeof(UInt64))
|
else if (type == typeof(UInt64))
|
||||||
{
|
{
|
||||||
var checkValue = RegisterConverter.ByteArrayToValue<UInt64>(value);
|
var checkValue = RegisterConverter.ByteArrayToValue<UInt64>(value);
|
||||||
if (reg.Minimum.HasValue && checkValue < (UInt64)reg.Minimum.Value)
|
if (regDef.Minimum.HasValue && checkValue < (UInt64)regDef.Minimum.Value)
|
||||||
{
|
{
|
||||||
return OutOfRangeMsg(true, checkValue.ToString(), reg.Minimum.Value.ToString(), reg.GetIdent());
|
msg = OutOfRangeMsg(RangeCheck.MinimumExceeded, checkValue.ToString(),
|
||||||
|
regDef.Minimum.Value.ToString(), regDef.GetIdent());
|
||||||
|
return StatusReturn.Failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reg.Maximum.HasValue && checkValue > (UInt64)reg.Maximum.Value)
|
if (regDef.Maximum.HasValue && checkValue > (UInt64)regDef.Maximum.Value)
|
||||||
{
|
{
|
||||||
return OutOfRangeMsg(false, checkValue.ToString(), reg.Maximum.Value.ToString(), reg.GetIdent());
|
msg = OutOfRangeMsg(RangeCheck.MaximumExceeded, checkValue.ToString(),
|
||||||
|
regDef.Maximum.Value.ToString(), regDef.GetIdent());
|
||||||
|
return StatusReturn.Failed;
|
||||||
|
}
|
||||||
|
if (checkIfValueIsDefault && regDef.Default.HasValue && 0 == checkValue.CompareTo(regDef.Default.Value))
|
||||||
|
{
|
||||||
|
msg = OutOfRangeMsg(RangeCheck.DefaultValue, checkValue.ToString(),
|
||||||
|
regDef.Default.Value.ToString(), regDef.GetIdent());
|
||||||
|
return StatusReturn.Warning;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (type == typeof(Int16))
|
else if (type == typeof(Int16))
|
||||||
{
|
{
|
||||||
var checkValue = RegisterConverter.ByteArrayToValue<Int16>(value);
|
var checkValue = RegisterConverter.ByteArrayToValue<Int16>(value);
|
||||||
if (reg.Minimum.HasValue && checkValue < reg.Minimum.Value)
|
if (regDef.Minimum.HasValue && checkValue < regDef.Minimum.Value)
|
||||||
{
|
{
|
||||||
return OutOfRangeMsg(true, checkValue.ToString(), reg.Minimum.Value.ToString(), reg.GetIdent());
|
msg = OutOfRangeMsg(RangeCheck.MinimumExceeded, checkValue.ToString(),
|
||||||
|
regDef.Minimum.Value.ToString(), regDef.GetIdent());
|
||||||
|
return StatusReturn.Failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reg.Maximum.HasValue && checkValue > reg.Maximum.Value)
|
if (regDef.Maximum.HasValue && checkValue > regDef.Maximum.Value)
|
||||||
{
|
{
|
||||||
return OutOfRangeMsg(false, checkValue.ToString(), reg.Maximum.Value.ToString(), reg.GetIdent());
|
msg = OutOfRangeMsg(RangeCheck.MaximumExceeded, checkValue.ToString(),
|
||||||
|
regDef.Maximum.Value.ToString(), regDef.GetIdent());
|
||||||
|
return StatusReturn.Failed;
|
||||||
|
}
|
||||||
|
if (checkIfValueIsDefault && regDef.Default.HasValue && checkValue == regDef.Default.Value)
|
||||||
|
{
|
||||||
|
msg = OutOfRangeMsg(RangeCheck.DefaultValue, checkValue.ToString(),
|
||||||
|
regDef.Default.Value.ToString(), regDef.GetIdent());
|
||||||
|
return StatusReturn.Warning;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (type == typeof(Int32))
|
else if (type == typeof(Int32))
|
||||||
{
|
{
|
||||||
var checkValue = RegisterConverter.ByteArrayToValue<Int32>(value);
|
var checkValue = RegisterConverter.ByteArrayToValue<Int32>(value);
|
||||||
if (reg.Minimum.HasValue && checkValue < reg.Minimum.Value)
|
if (regDef.Minimum.HasValue && checkValue < regDef.Minimum.Value)
|
||||||
{
|
{
|
||||||
return OutOfRangeMsg(true, checkValue.ToString(), reg.Minimum.Value.ToString(), reg.GetIdent());
|
msg = OutOfRangeMsg(RangeCheck.MinimumExceeded, checkValue.ToString(),
|
||||||
|
regDef.Minimum.Value.ToString(), regDef.GetIdent());
|
||||||
|
return StatusReturn.Failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reg.Maximum.HasValue && checkValue > reg.Maximum.Value)
|
if (regDef.Maximum.HasValue && checkValue > regDef.Maximum.Value)
|
||||||
{
|
{
|
||||||
return OutOfRangeMsg(false, checkValue.ToString(), reg.Maximum.Value.ToString(), reg.GetIdent());
|
msg = OutOfRangeMsg(RangeCheck.MaximumExceeded, checkValue.ToString(),
|
||||||
|
regDef.Maximum.Value.ToString(), regDef.GetIdent());
|
||||||
|
return StatusReturn.Failed;
|
||||||
|
}
|
||||||
|
if (checkIfValueIsDefault && regDef.Default.HasValue && checkValue == regDef.Default.Value)
|
||||||
|
{
|
||||||
|
msg = OutOfRangeMsg(RangeCheck.DefaultValue, checkValue.ToString(),
|
||||||
|
regDef.Default.Value.ToString(), regDef.GetIdent());
|
||||||
|
return StatusReturn.Warning;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (type == typeof(Int64))
|
else if (type == typeof(Int64))
|
||||||
{
|
{
|
||||||
var checkValue = RegisterConverter.ByteArrayToValue<Int64>(value);
|
var checkValue = RegisterConverter.ByteArrayToValue<Int64>(value);
|
||||||
if (reg.Minimum.HasValue && checkValue < reg.Minimum.Value)
|
if (regDef.Minimum.HasValue && checkValue < regDef.Minimum.Value)
|
||||||
{
|
{
|
||||||
return OutOfRangeMsg(true, checkValue.ToString(), reg.Minimum.Value.ToString(), reg.GetIdent());
|
msg = OutOfRangeMsg(RangeCheck.MinimumExceeded, checkValue.ToString(),
|
||||||
|
regDef.Minimum.Value.ToString(), regDef.GetIdent());
|
||||||
|
return StatusReturn.Failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reg.Maximum.HasValue && checkValue > reg.Maximum.Value)
|
if (regDef.Maximum.HasValue && checkValue > regDef.Maximum.Value)
|
||||||
{
|
{
|
||||||
return OutOfRangeMsg(false, checkValue.ToString(), reg.Maximum.Value.ToString(), reg.GetIdent());
|
msg = OutOfRangeMsg(RangeCheck.MaximumExceeded, checkValue.ToString(),
|
||||||
|
regDef.Maximum.Value.ToString(), regDef.GetIdent());
|
||||||
|
return StatusReturn.Failed;
|
||||||
|
}
|
||||||
|
if (checkIfValueIsDefault && regDef.Default.HasValue && checkValue == regDef.Default.Value)
|
||||||
|
{
|
||||||
|
msg = OutOfRangeMsg(RangeCheck.DefaultValue, checkValue.ToString(),
|
||||||
|
regDef.Default.Value.ToString(), regDef.GetIdent());
|
||||||
|
return StatusReturn.Warning;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (type == typeof(Byte) || type == typeof(Enum8))
|
else if (type == typeof(Byte) || type == typeof(Enum8))
|
||||||
{
|
{
|
||||||
var checkValue = RegisterConverter.ByteArrayToValue<Byte>(value);
|
var checkValue = RegisterConverter.ByteArrayToValue<Byte>(value);
|
||||||
if (reg.Minimum.HasValue && checkValue < reg.Minimum.Value)
|
if (regDef.Minimum.HasValue && checkValue < regDef.Minimum.Value)
|
||||||
{
|
{
|
||||||
return OutOfRangeMsg(true, checkValue.ToString(), reg.Minimum.Value.ToString(), reg.GetIdent());
|
msg = OutOfRangeMsg(RangeCheck.MinimumExceeded, checkValue.ToString(),
|
||||||
|
regDef.Minimum.Value.ToString(), regDef.GetIdent());
|
||||||
|
return StatusReturn.Failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reg.Maximum.HasValue && checkValue > reg.Maximum.Value)
|
if (regDef.Maximum.HasValue && checkValue > regDef.Maximum.Value)
|
||||||
{
|
{
|
||||||
return OutOfRangeMsg(false, checkValue.ToString(), reg.Maximum.Value.ToString(), reg.GetIdent());
|
msg = OutOfRangeMsg(RangeCheck.MaximumExceeded, checkValue.ToString(),
|
||||||
|
regDef.Maximum.Value.ToString(), regDef.GetIdent());
|
||||||
|
return StatusReturn.Failed;
|
||||||
|
}
|
||||||
|
if (checkIfValueIsDefault && regDef.Default.HasValue && checkValue == regDef.Default.Value)
|
||||||
|
{
|
||||||
|
msg = OutOfRangeMsg(RangeCheck.DefaultValue, checkValue.ToString(),
|
||||||
|
regDef.Default.Value.ToString(), regDef.GetIdent());
|
||||||
|
return StatusReturn.Warning;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (type == typeof(SByte))
|
else if (type == typeof(SByte))
|
||||||
{
|
{
|
||||||
var checkValue = RegisterConverter.ByteArrayToValue<SByte>(value);
|
var checkValue = RegisterConverter.ByteArrayToValue<SByte>(value);
|
||||||
if (reg.Minimum.HasValue && checkValue < reg.Minimum.Value)
|
if (regDef.Minimum.HasValue && checkValue < regDef.Minimum.Value)
|
||||||
{
|
{
|
||||||
return OutOfRangeMsg(true, checkValue.ToString(), reg.Minimum.Value.ToString(), reg.GetIdent());
|
msg = OutOfRangeMsg(RangeCheck.MinimumExceeded, checkValue.ToString(),
|
||||||
|
regDef.Minimum.Value.ToString(), regDef.GetIdent());
|
||||||
|
return StatusReturn.Failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reg.Maximum.HasValue && checkValue > reg.Maximum.Value)
|
if (regDef.Maximum.HasValue && checkValue > regDef.Maximum.Value)
|
||||||
{
|
{
|
||||||
return OutOfRangeMsg(false, checkValue.ToString(), reg.Maximum.Value.ToString(), reg.GetIdent());
|
msg = OutOfRangeMsg(RangeCheck.MaximumExceeded, checkValue.ToString(),
|
||||||
|
regDef.Maximum.Value.ToString(), regDef.GetIdent());
|
||||||
|
return StatusReturn.Failed;
|
||||||
|
}
|
||||||
|
if (checkIfValueIsDefault && regDef.Default.HasValue && checkValue == regDef.Default.Value)
|
||||||
|
{
|
||||||
|
msg = OutOfRangeMsg(RangeCheck.DefaultValue, checkValue.ToString(),
|
||||||
|
regDef.Default.Value.ToString(), regDef.GetIdent());
|
||||||
|
return StatusReturn.Warning;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (type == typeof(Boolean))
|
else if (type == typeof(Boolean))
|
||||||
@@ -146,17 +268,18 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return ($"Register {reg.RegisterName} has min or max value but the data type {reg.DataType} " +
|
msg = OutOfRangeMsg(RangeCheck.NotConvertible, "", "", regDef.GetIdent());
|
||||||
"doesn't support auto conversion");
|
return StatusReturn.Failed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
return e.Message;
|
msg = e.Message;
|
||||||
|
return StatusReturn.Failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the value is in range
|
// the value is in range and not on default
|
||||||
return string.Empty;
|
return StatusReturn.Okay;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers
|
|||||||
/// Convert single register from Genesis and return a message of the result. The value input is a byte array
|
/// Convert single register from Genesis and return a message of the result. The value input is a byte array
|
||||||
/// with the LSB at the index 0 and the MSB at the highest index. A string is sorted with the first character
|
/// with the LSB at the index 0 and the MSB at the highest index. A string is sorted with the first character
|
||||||
/// at index 0, this does not need to be reversed as it is readable by default.
|
/// at index 0, this does not need to be reversed as it is readable by default.
|
||||||
/// The raw value is swapped byte-wise to get a human readable value with MSB at leftmost and LSB at rightmost.
|
/// The raw value is swapped byte-wise to get a human-readable value with MSB at leftmost and LSB at rightmost.
|
||||||
/// The message contains the register name, the swapped raw value and on the converted value.
|
/// The message contains the register name, the swapped raw value and on the converted value.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="registerDefinition"></param>
|
/// <param name="registerDefinition"></param>
|
||||||
@@ -38,32 +38,31 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers
|
|||||||
public static String GetRegisterContentText(RegisterDefinition registerDefinition, Byte[] regRawByteArray)
|
public static String GetRegisterContentText(RegisterDefinition registerDefinition, Byte[] regRawByteArray)
|
||||||
{
|
{
|
||||||
String msg;
|
String msg;
|
||||||
var strValueResult = "?";
|
String registerName = "?";
|
||||||
var strRawResult = "?";
|
|
||||||
var registerName = "?";
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
registerName = registerDefinition.GetIdent();
|
registerName = registerDefinition.GetIdent();
|
||||||
// getting a result value as text of the data type e.g. UInt32
|
// getting a result value as text of the data type e.g. UInt32
|
||||||
var strValue = ConvertToText(regRawByteArray, registerDefinition.DataType);
|
var strValue = ConvertToText(regRawByteArray, registerDefinition.DataType);
|
||||||
// remove non printable char of the converted result
|
// remove non-printable char of the converted result
|
||||||
strValueResult = Regex.Replace(strValue, @"\p{C}+", string.Empty);
|
var strValueResult = Regex.Replace(strValue, @"\p{C}+", string.Empty);
|
||||||
|
|
||||||
// use hashed output being able to compare written and read back values
|
// use hashed output being able to compare written and read back values
|
||||||
|
String strRawResult;
|
||||||
if (registerName.Contains("EncryptionKey") || registerName.Contains("Password"))
|
if (registerName.Contains("EncryptionKey") || registerName.Contains("Password"))
|
||||||
{
|
{
|
||||||
strRawResult = GetRegisterRawText(registerDefinition, regRawByteArray, true);
|
strRawResult = GetRegisterRawText(registerDefinition, regRawByteArray, encryptData:true);
|
||||||
msg = $"{registerName} ({strRawResult})";
|
msg = $"{registerName}: ({strRawResult})h";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strRawResult = GetRegisterRawText(registerDefinition, regRawByteArray);
|
strRawResult = GetRegisterRawText(registerDefinition, regRawByteArray);
|
||||||
msg = $"{registerName} ({strRawResult}) ({strValueResult})";
|
msg = $"{registerName}: ({strRawResult})h ({strValueResult})";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
msg = $"{registerName} ({strRawResult}) ({strValueResult})";
|
throw new ApplicationException($"Cannot convert register {registerName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
return msg;
|
return msg;
|
||||||
@@ -73,7 +72,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers
|
|||||||
/// Convert single register from Genesis and return a message of the result. The value input is a byte array
|
/// Convert single register from Genesis and return a message of the result. The value input is a byte array
|
||||||
/// with the LSB at the index 0 and the MSB at the highest index. A string is sorted with the first character
|
/// with the LSB at the index 0 and the MSB at the highest index. A string is sorted with the first character
|
||||||
/// at index 0, this does not need to be reversed as it is readable by default.
|
/// at index 0, this does not need to be reversed as it is readable by default.
|
||||||
/// The raw value is swapped byte-wise to get a human readable value with MSB at leftmost and LSB at rightmost.
|
/// The raw value is swapped byte-wise to get a human-readable value with MSB at leftmost and LSB at rightmost.
|
||||||
/// The message contains the swapped raw value.
|
/// The message contains the swapped raw value.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="registerDefinition"></param>
|
/// <param name="registerDefinition"></param>
|
||||||
@@ -97,9 +96,12 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers
|
|||||||
// inverse the raw value to get a readable byte order MSB left and LSB last right position
|
// inverse the raw value to get a readable byte order MSB left and LSB last right position
|
||||||
var tmpList = regRawByteArray.ToList();
|
var tmpList = regRawByteArray.ToList();
|
||||||
|
|
||||||
// reverse the list if it is not a string or the UInt96 or UInt128 which will be used as
|
// reverse the list if it is not a string or the UInt48, UInt72, UInt88,UInt96 or UInt128 which
|
||||||
// placeholder for a string
|
// will be used as placeholder for a string
|
||||||
if (registerDefinition.DataType != typeof(String) &&
|
if (registerDefinition.DataType != typeof(String) &&
|
||||||
|
registerDefinition.DataType != typeof(UInt48) &&
|
||||||
|
registerDefinition.DataType != typeof(UInt72) &&
|
||||||
|
registerDefinition.DataType != typeof(UInt88) &&
|
||||||
registerDefinition.DataType != typeof(UInt96) &&
|
registerDefinition.DataType != typeof(UInt96) &&
|
||||||
registerDefinition.DataType != typeof(UInt128))
|
registerDefinition.DataType != typeof(UInt128))
|
||||||
{
|
{
|
||||||
@@ -288,18 +290,39 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers
|
|||||||
size = sizeof(Int64);
|
size = sizeof(Int64);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (registerDefinition.DataType == typeof(UInt48))
|
||||||
|
{
|
||||||
|
// 48 Bits / 8 Bits/Byte
|
||||||
|
size = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (registerDefinition.DataType == typeof(UInt72))
|
||||||
|
{
|
||||||
|
// 72 Bits / 8 Bits/Byte
|
||||||
|
size = 9;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (registerDefinition.DataType == typeof(UInt88))
|
||||||
|
{
|
||||||
|
// 88 Bits / 8 Bits/Byte
|
||||||
|
size = 11;
|
||||||
|
}
|
||||||
|
|
||||||
else if (registerDefinition.DataType == typeof(UInt96))
|
else if (registerDefinition.DataType == typeof(UInt96))
|
||||||
{
|
{
|
||||||
|
// 96 Bits / 8 Bits/Byte
|
||||||
size = 3 * 4;
|
size = 3 * 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (registerDefinition.DataType == typeof(UInt128))
|
else if (registerDefinition.DataType == typeof(UInt128))
|
||||||
{
|
{
|
||||||
|
// 128 Bits / 8 Bits/Byte
|
||||||
size = 4 * 4;
|
size = 4 * 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (registerDefinition.DataType == typeof(String))
|
else if (registerDefinition.DataType == typeof(String))
|
||||||
{
|
{
|
||||||
|
// just some value
|
||||||
size = 6 * 4;
|
size = 6 * 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -361,6 +384,18 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers
|
|||||||
{
|
{
|
||||||
return ByteArrayToValue<Byte>(rawByteArray).ToString();
|
return ByteArrayToValue<Byte>(rawByteArray).ToString();
|
||||||
}
|
}
|
||||||
|
if (type == typeof(UInt48))
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
if (type == typeof(UInt72))
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
if (type == typeof(UInt88))
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
if (type == typeof(UInt96))
|
if (type == typeof(UInt96))
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
@@ -421,6 +456,18 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers
|
|||||||
{
|
{
|
||||||
convertedObj = BitConverter.ToUInt64(rawByteArray, 0);
|
convertedObj = BitConverter.ToUInt64(rawByteArray, 0);
|
||||||
}
|
}
|
||||||
|
else if (type == typeof(UInt48))
|
||||||
|
{
|
||||||
|
return default(T);
|
||||||
|
}
|
||||||
|
else if (type == typeof(UInt72))
|
||||||
|
{
|
||||||
|
return default(T);
|
||||||
|
}
|
||||||
|
else if (type == typeof(UInt88))
|
||||||
|
{
|
||||||
|
return default(T);
|
||||||
|
}
|
||||||
else if (type == typeof(UInt96))
|
else if (type == typeof(UInt96))
|
||||||
{
|
{
|
||||||
return default(T);
|
return default(T);
|
||||||
|
|||||||
@@ -113,7 +113,10 @@
|
|||||||
<Compile Include="DataTypes\st_radio_dewa.cs" />
|
<Compile Include="DataTypes\st_radio_dewa.cs" />
|
||||||
<Compile Include="DataTypes\st_radio_tfx.cs" />
|
<Compile Include="DataTypes\st_radio_tfx.cs" />
|
||||||
<Compile Include="DataTypes\TimeT.cs" />
|
<Compile Include="DataTypes\TimeT.cs" />
|
||||||
|
<Compile Include="DataTypes\UInt48.cs" />
|
||||||
|
<Compile Include="DataTypes\UInt72.cs" />
|
||||||
<Compile Include="DataTypes\UInt128.cs" />
|
<Compile Include="DataTypes\UInt128.cs" />
|
||||||
|
<Compile Include="DataTypes\UInt88.cs" />
|
||||||
<Compile Include="DataTypes\UInt96.cs" />
|
<Compile Include="DataTypes\UInt96.cs" />
|
||||||
<Compile Include="Json\AppSection.cs" />
|
<Compile Include="Json\AppSection.cs" />
|
||||||
<Compile Include="Json\FwVersion.cs" />
|
<Compile Include="Json\FwVersion.cs" />
|
||||||
@@ -121,6 +124,16 @@
|
|||||||
<Compile Include="Json\Register.cs" />
|
<Compile Include="Json\Register.cs" />
|
||||||
<Compile Include="Json\Status.cs" />
|
<Compile Include="Json\Status.cs" />
|
||||||
<Compile Include="Json\Value.cs" />
|
<Compile Include="Json\Value.cs" />
|
||||||
|
<Compile Include="Properties\Resources.de.Designer.cs">
|
||||||
|
<DependentUpon>Resources.de.resx</DependentUpon>
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Properties\Resources.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="RecoveryRegisterItem.cs" />
|
<Compile Include="RecoveryRegisterItem.cs" />
|
||||||
<Compile Include="RecoverySettings.cs" />
|
<Compile Include="RecoverySettings.cs" />
|
||||||
<Compile Include="RegisterCheck.cs" />
|
<Compile Include="RegisterCheck.cs" />
|
||||||
@@ -136,6 +149,10 @@
|
|||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\..\..\CommonCore\CommonCore.csproj">
|
||||||
|
<Project>{1B02C79E-0B19-43E2-8F6B-71EF0C786C97}</Project>
|
||||||
|
<Name>CommonCore</Name>
|
||||||
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\..\..\..\Utils\ProcessExec\ProcessExec.csproj">
|
<ProjectReference Include="..\..\..\..\Utils\ProcessExec\ProcessExec.csproj">
|
||||||
<Project>{2FD60CF1-45CD-4060-B8E5-4F39FBA7F1CB}</Project>
|
<Project>{2FD60CF1-45CD-4060-B8E5-4F39FBA7F1CB}</Project>
|
||||||
<Name>ProcessExec</Name>
|
<Name>ProcessExec</Name>
|
||||||
@@ -156,6 +173,18 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<WCFMetadata Include="Connected Services\" />
|
<WCFMetadata Include="Connected Services\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="Properties\Resources.de.resx">
|
||||||
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>Resources.de.Designer.cs</LastGenOutput>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</EmbeddedResource>
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
|||||||
@@ -1827,7 +1827,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
|||||||
url += "&FileCategoryID=1";
|
url += "&FileCategoryID=1";
|
||||||
|
|
||||||
|
|
||||||
var result = LocalWebRequest.GetRequest(url, 1000);
|
var result = LocalWebRequest.GetRequest(url, 30000);
|
||||||
var a = JsonConvert.DeserializeObject<List<ClusteredFile>>(result);
|
var a = JsonConvert.DeserializeObject<List<ClusteredFile>>(result);
|
||||||
|
|
||||||
dgvFiles.DataSource = a?.OrderByDescending(o => o.FileDate).ToList();
|
dgvFiles.DataSource = a?.OrderByDescending(o => o.FileDate).ToList();
|
||||||
@@ -1849,7 +1849,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
|||||||
|
|
||||||
var url = $"{ServiceUrls.FileContentControllerUrl()}/GetFileParts?ParentFileId={parentFilId}&readContent=true";
|
var url = $"{ServiceUrls.FileContentControllerUrl()}/GetFileParts?ParentFileId={parentFilId}&readContent=true";
|
||||||
|
|
||||||
var result = LocalWebRequest.GetRequest(url, 1000);
|
var result = LocalWebRequest.GetRequest(url, 30000);
|
||||||
var a = JsonConvert.DeserializeObject<List<FilePart>>(result);
|
var a = JsonConvert.DeserializeObject<List<FilePart>>(result);
|
||||||
|
|
||||||
lblFwNameSelected.Text = dgvFiles.Rows[e.RowIndex].Cells[1].Value.ToString();
|
lblFwNameSelected.Text = dgvFiles.Rows[e.RowIndex].Cells[1].Value.ToString();
|
||||||
|
|||||||
@@ -1123,12 +1123,12 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
|||||||
fa.AddRange((new Byte[] { 0xAC, 0x21, 0x65, 0x35 }).ToArray());
|
fa.AddRange((new Byte[] { 0xAC, 0x21, 0x65, 0x35 }).ToArray());
|
||||||
_currentGenesis.WriteRegister("SENSUSRADIO_EncryptionKey", fa.ToArray());
|
_currentGenesis.WriteRegister("SENSUSRADIO_EncryptionKey", fa.ToArray());
|
||||||
return;
|
return;
|
||||||
var before = _currentGenesis.ReadRegister("SYSTEM_CalendarSeconds");
|
//var before = _currentGenesis.ReadRegister("SYSTEM_CalendarSeconds");
|
||||||
|
|
||||||
var tsa = DateTimeOffset.UtcNow - new DateTimeOffset(2000, 1, 1, 0, 0, 0, new TimeSpan(0));
|
//var tsa = DateTimeOffset.UtcNow - new DateTimeOffset(2000, 1, 1, 0, 0, 0, new TimeSpan(0));
|
||||||
_currentGenesis.WriteRegister("SYSTEM_CalendarSeconds", Convert.ToInt32(tsa.TotalSeconds));
|
//_currentGenesis.WriteRegister("SYSTEM_CalendarSeconds", Convert.ToInt32(tsa.TotalSeconds));
|
||||||
|
|
||||||
var after = _currentGenesis.ReadRegister("SYSTEM_CalendarSeconds");
|
//var after = _currentGenesis.ReadRegister("SYSTEM_CalendarSeconds");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1464,8 +1464,8 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
var a = _currentGenesis.ReadRegister(VARIABLE.GetIdent());
|
var a = _currentGenesis.ReadRegister(VARIABLE.GetIdent());
|
||||||
String result = RegisterCheck.CheckRange(VARIABLE, a);
|
//String result = RegisterCheck.CheckRange(VARIABLE, a);
|
||||||
if (!string.IsNullOrEmpty(result))
|
if (StatusReturn.Failed == RegisterCheck.CheckRange(VARIABLE, a, out var result))
|
||||||
{
|
{
|
||||||
MessageBox.Show(result);
|
MessageBox.Show(result);
|
||||||
allSucceed = false;
|
allSucceed = false;
|
||||||
|
|||||||
@@ -274,7 +274,7 @@ namespace Xylem.ServiceFwUpdate.Common.FwUpdateDb
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
public Boolean DownloadCordonelRecoveryRegistersFromDb(String pcbId, List<RecoveryRegisterItem> recoveryRegisters)
|
public Boolean DownloadCordonelRecoveryRegistersFromDb(String pcbId, List<RecoveryRegisterItem> recoveryRegisters)
|
||||||
{
|
{
|
||||||
if (StatusReturn.Okay == RegisterRestorer.DownloadProgrammingParametersFromDb(pcbId, recoveryRegisters))
|
if (StatusReturn.Okay == RegisterRestorer.DownloadProgrammingParametersFromDb(pcbId, recoveryRegisters, out _))
|
||||||
{
|
{
|
||||||
DbIsConnected = true;
|
DbIsConnected = true;
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user