Merged from main common version 2.6.4
This commit is contained in:
parent
d6ae9cdb8c
commit
8dd4cc58ce
@ -183,8 +183,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SIRTBroadcaster.Host", "SIR
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LaaProduction", "LaaProduction\LaaProduction.csproj", "{FD30EB7A-7809-4E62-9374-791D31877D6D}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommonMessurementUnits", "CommonMessurementUnits\CommonMessurementUnits.csproj", "{17C15B79-9A9E-4079-8FE2-0E563F18CA01}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommonConsole", "CommonConsole\CommonConsole.csproj", "{AFC428F5-0141-4A3F-BEF2-470A89D972F6}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "modbus_master_csharp", "modbus_master_csharp\modbus_master_csharp.csproj", "{F14940F8-3C86-4BB7-A915-B021E4B3052D}"
|
||||
@ -4255,70 +4253,6 @@ Global
|
||||
{FD30EB7A-7809-4E62-9374-791D31877D6D}.XP32bit|x64.Build.0 = Release|Any CPU
|
||||
{FD30EB7A-7809-4E62-9374-791D31877D6D}.XP32bit|x86.ActiveCfg = Release|Any CPU
|
||||
{FD30EB7A-7809-4E62-9374-791D31877D6D}.XP32bit|x86.Build.0 = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}._MANUAL_CONTROL|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}._MANUAL_CONTROL|Any CPU.Build.0 = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}._MANUAL_CONTROL|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}._MANUAL_CONTROL|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}._MANUAL_CONTROL|x64.ActiveCfg = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}._MANUAL_CONTROL|x64.Build.0 = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}._MANUAL_CONTROL|x86.ActiveCfg = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}._MANUAL_CONTROL|x86.Build.0 = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.COM|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.COM|Any CPU.Build.0 = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.COM|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.COM|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.COM|x64.ActiveCfg = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.COM|x64.Build.0 = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.COM|x86.ActiveCfg = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.COM|x86.Build.0 = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.GenesisDisplayTool_V01|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.GenesisDisplayTool_V01|Any CPU.Build.0 = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.GenesisDisplayTool_V01|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.GenesisDisplayTool_V01|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.GenesisDisplayTool_V01|x64.ActiveCfg = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.GenesisDisplayTool_V01|x64.Build.0 = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.GenesisDisplayTool_V01|x86.ActiveCfg = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.GenesisDisplayTool_V01|x86.Build.0 = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.PerformTest|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.PerformTest|Any CPU.Build.0 = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.PerformTest|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.PerformTest|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.PerformTest|x64.ActiveCfg = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.PerformTest|x64.Build.0 = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.PerformTest|x86.ActiveCfg = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.PerformTest|x86.Build.0 = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.Release|x64.Build.0 = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.Release|x86.Build.0 = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.ReleaseTest|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.ReleaseTest|Any CPU.Build.0 = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.ReleaseTest|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.ReleaseTest|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.ReleaseTest|x64.ActiveCfg = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.ReleaseTest|x64.Build.0 = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.ReleaseTest|x86.ActiveCfg = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.ReleaseTest|x86.Build.0 = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.XP32bit|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.XP32bit|Any CPU.Build.0 = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.XP32bit|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.XP32bit|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.XP32bit|x64.ActiveCfg = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.XP32bit|x64.Build.0 = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.XP32bit|x86.ActiveCfg = Release|Any CPU
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01}.XP32bit|x86.Build.0 = Release|Any CPU
|
||||
{AFC428F5-0141-4A3F-BEF2-470A89D972F6}._MANUAL_CONTROL|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AFC428F5-0141-4A3F-BEF2-470A89D972F6}._MANUAL_CONTROL|Any CPU.Build.0 = Release|Any CPU
|
||||
{AFC428F5-0141-4A3F-BEF2-470A89D972F6}._MANUAL_CONTROL|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
@ -4530,7 +4464,6 @@ Global
|
||||
{AF973E0E-2B44-4F1A-B1E7-77C8B4F30579} = {99B23EE9-CE50-4924-A055-C39EFA038721}
|
||||
{A9D1A99D-6E55-4394-86AD-B5C53E9225EB} = {AF973E0E-2B44-4F1A-B1E7-77C8B4F30579}
|
||||
{FD30EB7A-7809-4E62-9374-791D31877D6D} = {696A94BE-7237-4AE2-9E36-6059DE519971}
|
||||
{17C15B79-9A9E-4079-8FE2-0E563F18CA01} = {C17363DF-A043-4F25-8EBA-2B3B078227DC}
|
||||
{AFC428F5-0141-4A3F-BEF2-470A89D972F6} = {C17363DF-A043-4F25-8EBA-2B3B078227DC}
|
||||
{F14940F8-3C86-4BB7-A915-B021E4B3052D} = {B4F8545B-F379-42A5-BDE9-763FD7B79598}
|
||||
EndGlobalSection
|
||||
|
||||
@ -54,12 +54,6 @@
|
||||
<None Include="configuration.json" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CommonMessurementUnits\CommonMessurementUnits.csproj">
|
||||
<Project>{17C15B79-9A9E-4079-8FE2-0E563F18CA01}</Project>
|
||||
<Name>CommonMessurementUnits</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@ -1,75 +1,75 @@
|
||||
namespace CommonMessurementUnits
|
||||
{
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Xylem.Common.CommonCore.CommonMeasurementUnits
|
||||
{
|
||||
public static class BitExtensions
|
||||
{
|
||||
public static byte[] GetBits(this byte[] bytes)
|
||||
public static Byte[] GetBits(this Byte[] bytes)
|
||||
{
|
||||
if (bytes is null)
|
||||
{
|
||||
return Array.Empty<byte>();
|
||||
return Array.Empty<Byte>();
|
||||
}
|
||||
|
||||
var bytesCount = bytes.Length;
|
||||
var bitsCount = bytesCount * 8;
|
||||
var bits = new byte[bitsCount];
|
||||
var bits = new Byte[bitsCount];
|
||||
var bit = 0;
|
||||
|
||||
foreach (var @byte in bytes)
|
||||
{
|
||||
for (int b = 7; b >= 0; b--)
|
||||
for (Int32 b = 7; b >= 0; b--)
|
||||
{
|
||||
bits[bit++] = (byte)((@byte >> b) % 2);
|
||||
bits[bit++] = (Byte)((@byte >> b) % 2);
|
||||
}
|
||||
}
|
||||
|
||||
return bits;
|
||||
}
|
||||
|
||||
public static byte[] GetBytes(this byte value, int take = 1)
|
||||
=> BitConverter.GetBytes(value).Take(take);
|
||||
public static Byte[] GetBytes(this Byte value, Int32 take = 1)
|
||||
=> Enumerable.Take(BitConverter.GetBytes(value), take);
|
||||
|
||||
public static byte[] GetBytes(this sbyte value, int take = 2)
|
||||
=> BitConverter.GetBytes(value).Take(take);
|
||||
public static Byte[] GetBytes(this SByte value, Int32 take = 2)
|
||||
=> Enumerable.Take(BitConverter.GetBytes(value), take);
|
||||
|
||||
public static byte[] GetBytes(this short value, int take = 2)
|
||||
=> BitConverter.GetBytes(value).Take(2);
|
||||
public static Byte[] GetBytes(this Int16 value, Int32 take = 2)
|
||||
=> Enumerable.Take(BitConverter.GetBytes(value), 2);
|
||||
|
||||
public static byte[] GetBytes(this ushort value, int take = 2)
|
||||
=> BitConverter.GetBytes(value).Take(2);
|
||||
public static Byte[] GetBytes(this UInt16 value, Int32 take = 2)
|
||||
=> Enumerable.Take(BitConverter.GetBytes(value), 2);
|
||||
|
||||
public static byte[] GetBytes(this int value, int take = 4)
|
||||
=> BitConverter.GetBytes(value).Take(take);
|
||||
public static Byte[] GetBytes(this Int32 value, Int32 take = 4)
|
||||
=> Enumerable.Take(BitConverter.GetBytes(value), take);
|
||||
|
||||
public static byte[] GetBytes(this uint value, int take = 4)
|
||||
=> BitConverter.GetBytes(value).Take(take);
|
||||
public static Byte[] GetBytes(this UInt32 value, Int32 take = 4)
|
||||
=> Enumerable.Take(BitConverter.GetBytes(value), take);
|
||||
|
||||
public static byte[] GetBytes(this long value, int take = 8)
|
||||
=> BitConverter.GetBytes(value).Take(take);
|
||||
public static Byte[] GetBytes(this Int64 value, Int32 take = 8)
|
||||
=> Enumerable.Take(BitConverter.GetBytes(value), take);
|
||||
|
||||
public static byte[] GetBytes(this ulong value, int take = 8)
|
||||
=> BitConverter.GetBytes(value).Take(take);
|
||||
public static Byte[] GetBytes(this UInt64 value, Int32 take = 8)
|
||||
=> Enumerable.Take(BitConverter.GetBytes(value), take);
|
||||
|
||||
public static byte[] GetBytes(this double value)
|
||||
public static Byte[] GetBytes(this Double value)
|
||||
=> BitConverter.GetBytes(value);
|
||||
|
||||
public static byte[] GetBytes(this string value)
|
||||
public static Byte[] GetBytes(this String value)
|
||||
=> Encoding.ASCII.GetBytes(value);
|
||||
|
||||
public static byte[] Swap(this byte[] bytes)
|
||||
public static Byte[] Swap(this Byte[] bytes)
|
||||
{
|
||||
if (bytes is null)
|
||||
{
|
||||
return Array.Empty<byte>();
|
||||
return Array.Empty<Byte>();
|
||||
}
|
||||
|
||||
var length = bytes.Length;
|
||||
var swapped = new byte[length];
|
||||
var swapped = new Byte[length];
|
||||
|
||||
for (int x = 0; x < length; x++)
|
||||
for (Int32 x = 0; x < length; x++)
|
||||
{
|
||||
swapped[x] = bytes[length - x - 1];
|
||||
}
|
||||
@ -77,21 +77,21 @@
|
||||
return swapped;
|
||||
}
|
||||
|
||||
public static byte[] Take(this byte[] bytesSRC, int count)
|
||||
public static Byte[] Take(this Byte[] bytesSRC, Int32 count)
|
||||
{
|
||||
if (bytesSRC is null || count < 0)
|
||||
{
|
||||
return Array.Empty<byte>();
|
||||
return Array.Empty<Byte>();
|
||||
}
|
||||
|
||||
var bytesDST = new byte[count];
|
||||
var bytesDST = new Byte[count];
|
||||
|
||||
Array.Copy(bytesSRC, 0, bytesDST, 0, count);
|
||||
|
||||
return bytesDST;
|
||||
}
|
||||
|
||||
public static string ToHex(this byte[] value, string separator = " ")
|
||||
public static String ToHex(this Byte[] value, String separator = " ")
|
||||
{
|
||||
if (value is null)
|
||||
{
|
||||
@ -101,16 +101,16 @@
|
||||
return BitConverter.ToString(value).Replace("-", separator);
|
||||
}
|
||||
|
||||
public static byte[] FromHex(this string value, string separator = " ")
|
||||
public static Byte[] FromHex(this String value, String separator = " ")
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
return Array.Empty<byte>();
|
||||
return Array.Empty<Byte>();
|
||||
}
|
||||
|
||||
return value
|
||||
.Split(new[] { separator }, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(x => byte.TryParse(x, out byte b) ? b : default(byte))
|
||||
.Select(x => byte.TryParse(x, out Byte b) ? b : default(Byte))
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,8 +7,8 @@
|
||||
<ProjectGuid>{17C15B79-9A9E-4079-8FE2-0E563F18CA01}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>CommonMessurementUnits</RootNamespace>
|
||||
<AssemblyName>CommonMessurementUnits</AssemblyName>
|
||||
<RootNamespace>Xylem.Common.CommonCore.CommonMeasurementUnits</RootNamespace>
|
||||
<AssemblyName>Xylem.Common.CommonCore.CommonMeasurementUnits</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
|
||||
<Authors>Stoyan Zlatev</Authors>
|
||||
<Company>Sensus - a Xylem brand</Company>
|
||||
@ -1,28 +1,28 @@
|
||||
namespace CommonMessurementUnits
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using Xylem.Common.CommonCore.CommonMeasurementUnits.JsonConverters;
|
||||
|
||||
namespace Xylem.Common.CommonCore.CommonMeasurementUnits
|
||||
{
|
||||
using CommonMessurementUnits.JsonConverters;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
[JsonConverter(typeof(CurrentConverter))]
|
||||
public class Current : Unit
|
||||
{
|
||||
public double MiliampereHours
|
||||
public Double MilliampereHours
|
||||
{
|
||||
get => this.AmpereHours * MAInH;
|
||||
set => this.AmpereHours = value / MAInH;
|
||||
get => AmpereHours * MAInH;
|
||||
set => AmpereHours = value / MAInH;
|
||||
}
|
||||
|
||||
public double AmpereHours
|
||||
public Double AmpereHours
|
||||
{
|
||||
get => this.value;
|
||||
get => value;
|
||||
set => this.value = value;
|
||||
}
|
||||
|
||||
public static implicit operator Current(double x)
|
||||
public static implicit operator Current(Double x)
|
||||
=> new Current { value = x };
|
||||
|
||||
public static implicit operator Current(double? x)
|
||||
public static implicit operator Current(Double? x)
|
||||
=> new Current { value = x ?? 0 };
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,28 +1,28 @@
|
||||
namespace CommonMessurementUnits
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using Xylem.Common.CommonCore.CommonMeasurementUnits.JsonConverters;
|
||||
|
||||
namespace Xylem.Common.CommonCore.CommonMeasurementUnits
|
||||
{
|
||||
using CommonMessurementUnits.JsonConverters;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
[JsonConverter(typeof(FlowConverter))]
|
||||
public class Flow : Unit
|
||||
{
|
||||
public double CubicMeterInHour
|
||||
public Double CubicMeterInHour
|
||||
{
|
||||
get => this.value;
|
||||
get => value;
|
||||
set => this.value = value;
|
||||
}
|
||||
|
||||
public double LiterInMinute
|
||||
public Double LiterInMinute
|
||||
{
|
||||
get => this.CubicMeterInHour / MinInH * LInm3;
|
||||
set => this.CubicMeterInHour = value * MinInH / LInm3;
|
||||
get => CubicMeterInHour / MinInH * LInm3;
|
||||
set => CubicMeterInHour = value * MinInH / LInm3;
|
||||
}
|
||||
|
||||
public static implicit operator Flow(double x)
|
||||
public static implicit operator Flow(Double x)
|
||||
=> new Flow { value = x };
|
||||
|
||||
public static implicit operator Flow(double? x)
|
||||
public static implicit operator Flow(Double? x)
|
||||
=> new Flow { value = x ?? 0 };
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,19 +1,18 @@
|
||||
namespace CommonMessurementUnits.JsonConverters
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Xylem.Common.CommonCore.CommonMeasurementUnits.JsonConverters
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using System;
|
||||
|
||||
public class CurrentConverter : JsonConverter<Current>
|
||||
{
|
||||
public override Current ReadJson(JsonReader reader, Type objectType, Current existingValue, bool hasExistingValue, JsonSerializer serializer)
|
||||
public override Current ReadJson(JsonReader reader, Type objectType, Current existingValue, Boolean hasExistingValue, JsonSerializer serializer)
|
||||
{
|
||||
while (reader.ValueType != typeof(double))
|
||||
while (reader.ValueType != typeof(Double))
|
||||
{
|
||||
reader.Read();
|
||||
}
|
||||
|
||||
if (reader.Value is double value)
|
||||
if (reader.Value is Double value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
@ -22,6 +21,6 @@
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, Current value, JsonSerializer serializer)
|
||||
=> writer.WriteValue((double)value);
|
||||
=> writer.WriteValue((Double)value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,19 +1,18 @@
|
||||
namespace CommonMessurementUnits.JsonConverters
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Xylem.Common.CommonCore.CommonMeasurementUnits.JsonConverters
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using System;
|
||||
|
||||
public class FlowConverter : JsonConverter<Flow>
|
||||
{
|
||||
public override Flow ReadJson(JsonReader reader, Type objectType, Flow existingValue, bool hasExistingValue, JsonSerializer serializer)
|
||||
public override Flow ReadJson(JsonReader reader, Type objectType, Flow existingValue, Boolean hasExistingValue, JsonSerializer serializer)
|
||||
{
|
||||
while (reader.ValueType != typeof(double))
|
||||
while (reader.ValueType != typeof(Double))
|
||||
{
|
||||
reader.Read();
|
||||
}
|
||||
|
||||
if (reader.Value is double value)
|
||||
if (reader.Value is Double value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
@ -22,6 +21,6 @@
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, Flow value, JsonSerializer serializer)
|
||||
=> writer.WriteValue((double)value);
|
||||
=> writer.WriteValue((Double)value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,19 +1,18 @@
|
||||
namespace CommonMessurementUnits.JsonConverters
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Xylem.Common.CommonCore.CommonMeasurementUnits.JsonConverters
|
||||
{
|
||||
using System;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
public class PressureConverter : JsonConverter<Pressure>
|
||||
{
|
||||
public override Pressure ReadJson(JsonReader reader, Type objectType, Pressure existingValue, bool hasExistingValue, JsonSerializer serializer)
|
||||
public override Pressure ReadJson(JsonReader reader, Type objectType, Pressure existingValue, Boolean hasExistingValue, JsonSerializer serializer)
|
||||
{
|
||||
while (reader.ValueType != typeof(double))
|
||||
while (reader.ValueType != typeof(Double))
|
||||
{
|
||||
reader.Read();
|
||||
}
|
||||
|
||||
if (reader.Value is double value)
|
||||
if (reader.Value is Double value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
@ -22,6 +21,6 @@
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, Pressure value, JsonSerializer serializer)
|
||||
=> writer.WriteValue((double)value);
|
||||
=> writer.WriteValue((Double)value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,19 +1,18 @@
|
||||
namespace CommonMessurementUnits.JsonConverters
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Xylem.Common.CommonCore.CommonMeasurementUnits.JsonConverters
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using System;
|
||||
|
||||
public class TemperatureConverter : JsonConverter<Temperature>
|
||||
{
|
||||
public override Temperature ReadJson(JsonReader reader, Type objectType, Temperature existingValue, bool hasExistingValue, JsonSerializer serializer)
|
||||
public override Temperature ReadJson(JsonReader reader, Type objectType, Temperature existingValue, Boolean hasExistingValue, JsonSerializer serializer)
|
||||
{
|
||||
while (reader.ValueType != typeof(double))
|
||||
while (reader.ValueType != typeof(Double))
|
||||
{
|
||||
reader.Read();
|
||||
}
|
||||
|
||||
if (reader.Value is double value)
|
||||
if (reader.Value is Double value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
@ -22,6 +21,6 @@
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, Temperature value, JsonSerializer serializer)
|
||||
=> writer.WriteValue((double)value);
|
||||
=> writer.WriteValue((Double)value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,19 +1,18 @@
|
||||
namespace CommonMessurementUnits.JsonConverters
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Xylem.Common.CommonCore.CommonMeasurementUnits.JsonConverters
|
||||
{
|
||||
using System;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
public class TimeConverter : JsonConverter<Time>
|
||||
{
|
||||
public override Time ReadJson(JsonReader reader, Type objectType, Time existingValue, bool hasExistingValue, JsonSerializer serializer)
|
||||
public override Time ReadJson(JsonReader reader, Type objectType, Time existingValue, Boolean hasExistingValue, JsonSerializer serializer)
|
||||
{
|
||||
while (reader.ValueType != typeof(double))
|
||||
while (reader.ValueType != typeof(Double))
|
||||
{
|
||||
reader.Read();
|
||||
}
|
||||
|
||||
if (reader.Value is double value)
|
||||
if (reader.Value is Double value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
@ -22,6 +21,6 @@
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, Time value, JsonSerializer serializer)
|
||||
=> writer.WriteValue((double)value);
|
||||
=> writer.WriteValue((Double)value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,19 +1,18 @@
|
||||
namespace CommonMessurementUnits.JsonConverters
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Xylem.Common.CommonCore.CommonMeasurementUnits.JsonConverters
|
||||
{
|
||||
using System;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
public class VolumeConverter : JsonConverter<Volume>
|
||||
{
|
||||
public override Volume ReadJson(JsonReader reader, Type objectType, Volume existingValue, bool hasExistingValue, JsonSerializer serializer)
|
||||
public override Volume ReadJson(JsonReader reader, Type objectType, Volume existingValue, Boolean hasExistingValue, JsonSerializer serializer)
|
||||
{
|
||||
while (reader.ValueType != typeof(double))
|
||||
while (reader.ValueType != typeof(Double))
|
||||
{
|
||||
reader.Read();
|
||||
}
|
||||
|
||||
if (reader.Value is double value)
|
||||
if (reader.Value is Double value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
@ -22,6 +21,6 @@
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, Volume value, JsonSerializer serializer)
|
||||
=> writer.WriteValue((double)value);
|
||||
=> writer.WriteValue((Double)value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,28 +1,28 @@
|
||||
namespace CommonMessurementUnits
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using Xylem.Common.CommonCore.CommonMeasurementUnits.JsonConverters;
|
||||
|
||||
namespace Xylem.Common.CommonCore.CommonMeasurementUnits
|
||||
{
|
||||
using CommonMessurementUnits.JsonConverters;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
[JsonConverter(typeof(PressureConverter))]
|
||||
public class Pressure : Unit
|
||||
{
|
||||
public double Pascal
|
||||
public Double Pascal
|
||||
{
|
||||
get => this.value;
|
||||
get => value;
|
||||
set => this.value = value;
|
||||
}
|
||||
|
||||
public double Bar
|
||||
public Double Bar
|
||||
{
|
||||
get => this.Pascal / PInBar;
|
||||
set => this.Pascal = value * PInBar;
|
||||
get => Pascal / PInBar;
|
||||
set => Pascal = value * PInBar;
|
||||
}
|
||||
|
||||
public static implicit operator Pressure(double x)
|
||||
public static implicit operator Pressure(Double x)
|
||||
=> new Pressure { value = x };
|
||||
|
||||
public static implicit operator Pressure(double? x)
|
||||
public static implicit operator Pressure(Double? x)
|
||||
=> new Pressure { value = x ?? 0 };
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,11 +5,11 @@ using System.Runtime.InteropServices;
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("CommonMessurementUnits")]
|
||||
[assembly: AssemblyTitle("Xylem.Common.CommonCore.CommonMeasurementUnits")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("CommonMessurementUnits")]
|
||||
[assembly: AssemblyProduct("CommonMeasurementUnits")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2023")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
@ -1,22 +1,22 @@
|
||||
namespace CommonMessurementUnits
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using Xylem.Common.CommonCore.CommonMeasurementUnits.JsonConverters;
|
||||
|
||||
namespace Xylem.Common.CommonCore.CommonMeasurementUnits
|
||||
{
|
||||
using CommonMessurementUnits.JsonConverters;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
[JsonConverter(typeof(TemperatureConverter))]
|
||||
public class Temperature : Unit
|
||||
{
|
||||
public double Celsius
|
||||
public Double Celsius
|
||||
{
|
||||
get => this.value;
|
||||
get => value;
|
||||
set => this.value = value;
|
||||
}
|
||||
|
||||
public static implicit operator Temperature(double x)
|
||||
public static implicit operator Temperature(Double x)
|
||||
=> new Temperature { value = x };
|
||||
|
||||
public static implicit operator Temperature(double? x)
|
||||
public static implicit operator Temperature(Double? x)
|
||||
=> new Temperature { value = x ?? 0 };
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,46 +1,46 @@
|
||||
namespace CommonMessurementUnits
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using Xylem.Common.CommonCore.CommonMeasurementUnits.JsonConverters;
|
||||
|
||||
namespace Xylem.Common.CommonCore.CommonMeasurementUnits
|
||||
{
|
||||
using CommonMessurementUnits.JsonConverters;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
[JsonConverter(typeof(TimeConverter))]
|
||||
public class Time : Unit
|
||||
{
|
||||
public double Miliseconds
|
||||
public Double Miliseconds
|
||||
{
|
||||
get => this.Seconds * MsInSec;
|
||||
set => this.Seconds = value / MsInSec;
|
||||
get => Seconds * MsInSec;
|
||||
set => Seconds = value / MsInSec;
|
||||
}
|
||||
|
||||
public double Seconds
|
||||
public Double Seconds
|
||||
{
|
||||
get => this.value;
|
||||
get => value;
|
||||
set => this.value = value;
|
||||
}
|
||||
|
||||
public double Minutes
|
||||
public Double Minutes
|
||||
{
|
||||
get => this.Seconds / SecInMin;
|
||||
set => this.Seconds = value * SecInMin;
|
||||
get => Seconds / SecInMin;
|
||||
set => Seconds = value * SecInMin;
|
||||
}
|
||||
|
||||
public double Hours
|
||||
public Double Hours
|
||||
{
|
||||
get => this.Minutes / MinInH;
|
||||
set => this.Minutes = value * MinInH;
|
||||
get => Minutes / MinInH;
|
||||
set => Minutes = value * MinInH;
|
||||
}
|
||||
|
||||
public double Days
|
||||
public Double Days
|
||||
{
|
||||
get => this.Hours / HInDay;
|
||||
set => this.Hours = value * HInDay;
|
||||
get => Hours / HInDay;
|
||||
set => Hours = value * HInDay;
|
||||
}
|
||||
|
||||
public static implicit operator Time(double x)
|
||||
public static implicit operator Time(Double x)
|
||||
=> new Time { value = x };
|
||||
|
||||
public static implicit operator Time(double? x)
|
||||
public static implicit operator Time(Double? x)
|
||||
=> new Time { value = x ?? 0 };
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,31 +1,33 @@
|
||||
namespace CommonMessurementUnits
|
||||
using System;
|
||||
|
||||
namespace Xylem.Common.CommonCore.CommonMeasurementUnits
|
||||
{
|
||||
public abstract class Unit
|
||||
{
|
||||
public const int MsInSec = 1000;
|
||||
public const int SecInMin = 60;
|
||||
public const int MinInH = 60;
|
||||
public const int HInDay = 24;
|
||||
public const int MlInL = 1000;
|
||||
public const int LInm3 = 1000;
|
||||
public const int PInBar = 100000;
|
||||
public const int MAInH = 1000;
|
||||
public const Int32 MsInSec = 1000;
|
||||
public const Int32 SecInMin = 60;
|
||||
public const Int32 MinInH = 60;
|
||||
public const Int32 HInDay = 24;
|
||||
public const Int32 MlInL = 1000;
|
||||
public const Int32 LInm3 = 1000;
|
||||
public const Int32 PInBar = 100000;
|
||||
public const Int32 MAInH = 1000;
|
||||
|
||||
protected double value;
|
||||
protected Double value;
|
||||
|
||||
public override string ToString()
|
||||
=> this.value.ToString();
|
||||
public override String ToString()
|
||||
=> value.ToString();
|
||||
|
||||
public override bool Equals(object obj)
|
||||
=> this.value.Equals(obj);
|
||||
public override Boolean Equals(Object obj)
|
||||
=> value.Equals(obj);
|
||||
|
||||
public override int GetHashCode()
|
||||
=> this.value.GetHashCode();
|
||||
public override Int32 GetHashCode()
|
||||
=> value.GetHashCode();
|
||||
|
||||
public static explicit operator double (Unit @base)
|
||||
=> @base?.value ?? default(double);
|
||||
public static explicit operator Double (Unit @base)
|
||||
=> @base?.value ?? default(Double);
|
||||
|
||||
public static explicit operator double? (Unit @base)
|
||||
public static explicit operator Double? (Unit @base)
|
||||
=> @base?.value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,36 +1,36 @@
|
||||
namespace CommonMessurementUnits
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using Xylem.Common.CommonCore.CommonMeasurementUnits.JsonConverters;
|
||||
|
||||
namespace Xylem.Common.CommonCore.CommonMeasurementUnits
|
||||
{
|
||||
using CommonMessurementUnits.JsonConverters;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
[JsonConverter(typeof(VolumeConverter))]
|
||||
public class Volume : Unit
|
||||
{
|
||||
public double Mililiter
|
||||
public Double Mililiter
|
||||
{
|
||||
get => this.Liter * MlInL;
|
||||
set => this.Liter = value / MlInL;
|
||||
get => Liter * MlInL;
|
||||
set => Liter = value / MlInL;
|
||||
}
|
||||
|
||||
public double Liter
|
||||
public Double Liter
|
||||
{
|
||||
get => this.value * LInm3;
|
||||
get => value * LInm3;
|
||||
set => this.value = value / LInm3;
|
||||
}
|
||||
|
||||
public double CubicMeter
|
||||
public Double CubicMeter
|
||||
{
|
||||
get => this.value * this.Factor;
|
||||
set => this.value = value / this.Factor;
|
||||
get => value * Factor;
|
||||
set => this.value = value / Factor;
|
||||
}
|
||||
|
||||
public int Factor { get; set; } = 1000;
|
||||
public Int32 Factor { get; set; } = 1000;
|
||||
|
||||
public static implicit operator Volume(double x)
|
||||
public static implicit operator Volume(Double x)
|
||||
=> new Volume { value = x };
|
||||
|
||||
public static implicit operator Volume(double? x)
|
||||
public static implicit operator Volume(Double? x)
|
||||
=> new Volume { value = x ?? 0 };
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,11 +8,11 @@
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.Applications;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers.DataTypes;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers.Json;
|
||||
using Xylem.Common.Hardware.WaterMeter.WaterMeterRegisters;
|
||||
using Applications;
|
||||
using Registers;
|
||||
using Registers.DataTypes;
|
||||
using Registers.Json;
|
||||
using WaterMeterRegisters;
|
||||
|
||||
/// <summary>
|
||||
/// JSON filer reader for generation of register lists
|
||||
@ -22,20 +22,15 @@
|
||||
/// <summary>
|
||||
/// Registers defined in configuration.json file
|
||||
/// </summary>
|
||||
public List<IRegister> ConfigRegistersDefinitions { get; set; }
|
||||
public List<IRegister> ConfigRegistersDefinitions { get; }
|
||||
= new List<IRegister>();
|
||||
|
||||
/// <summary>
|
||||
/// Applications defined in configuration.json file
|
||||
/// </summary>
|
||||
public List<ApplicationDefinition> ConfigApplicationDefinitions { get; set; }
|
||||
public List<ApplicationDefinition> ConfigApplicationDefinitions { get; }
|
||||
= new List<ApplicationDefinition>();
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public IDictionary<string, AppSection> Value { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Ctor
|
||||
/// </summary>
|
||||
@ -60,29 +55,27 @@
|
||||
/// <param name="configurationJson"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="Exception"></exception>
|
||||
private void Convert(string configurationJson)
|
||||
private void Convert(String configurationJson)
|
||||
{
|
||||
var sections = default(IDictionary<string, AppSection>);
|
||||
IDictionary<String, AppSection> sections;
|
||||
|
||||
try
|
||||
{
|
||||
sections = JsonConvert
|
||||
.DeserializeObject<IDictionary<string, AppSection>>(configurationJson, SerializerSettings)
|
||||
?? new Dictionary<string, AppSection>();
|
||||
.DeserializeObject<IDictionary<String, AppSection>>(configurationJson, SerializerSettings)
|
||||
?? new Dictionary<String, AppSection>();
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (Exception )
|
||||
{
|
||||
sections = new Dictionary<string, AppSection>();
|
||||
sections = new Dictionary<String, AppSection>();
|
||||
}
|
||||
|
||||
this.Value = sections;
|
||||
|
||||
foreach (var sectionKVP in sections)
|
||||
{
|
||||
var appId = sectionKVP.Value.Id;
|
||||
var appName = sectionKVP.Key;
|
||||
|
||||
this.ConfigApplicationDefinitions.Add(new ApplicationDefinition
|
||||
ConfigApplicationDefinitions.Add(new ApplicationDefinition
|
||||
{
|
||||
AppId = appId,
|
||||
AppName = appName
|
||||
@ -90,11 +83,6 @@
|
||||
|
||||
var section = sectionKVP.Value;
|
||||
|
||||
if (section is null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var registers = section.Registers;
|
||||
|
||||
if (registers is null)
|
||||
@ -124,15 +112,15 @@
|
||||
{
|
||||
var values = detail.Values;
|
||||
|
||||
this.ConfigRegistersDefinitions.Add(new RegisterDefinition
|
||||
ConfigRegistersDefinitions.Add(new RegisterDefinition
|
||||
{
|
||||
AppAddress = appId,
|
||||
AppName = appName,
|
||||
DataType = this.GetType(detail.Type),
|
||||
Default = values?.Default is long d ? d : default(long?),
|
||||
IsAvailable = default(bool),
|
||||
Maximum = values?.Maximum is long max ? max : default(long?),
|
||||
Minimum = values?.Minimum is long min ? min : default(long?),
|
||||
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,
|
||||
@ -147,7 +135,7 @@
|
||||
/// <summary>
|
||||
/// Settings
|
||||
/// </summary>
|
||||
public static readonly JsonSerializerSettings SerializerSettings = new JsonSerializerSettings
|
||||
private static readonly JsonSerializerSettings SerializerSettings = new JsonSerializerSettings
|
||||
{
|
||||
MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
|
||||
DateParseHandling = DateParseHandling.None,
|
||||
@ -158,7 +146,7 @@
|
||||
},
|
||||
};
|
||||
|
||||
private Type GetType(string value)
|
||||
private static Type GetType(String value)
|
||||
{
|
||||
switch (value.ToLower())
|
||||
{
|
||||
@ -169,12 +157,12 @@
|
||||
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 "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 "int8_t": return typeof(SByte);
|
||||
case "int32_t": return typeof(Int32);
|
||||
case "int64_t": return typeof(Int64);
|
||||
case "int16_t": return typeof(Int16);
|
||||
@ -193,7 +181,7 @@
|
||||
/// </summary>
|
||||
/// <param name="t"></param>
|
||||
/// <returns></returns>
|
||||
public override bool CanConvert(Type t) => t == typeof(Access) || t == typeof(Access?);
|
||||
public override Boolean CanConvert(Type t) => t == typeof(Access) || t == typeof(Access?);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@ -210,14 +198,9 @@
|
||||
return null;
|
||||
}
|
||||
|
||||
var value = serializer.Deserialize<string>(reader);
|
||||
var value = serializer.Deserialize<String>(reader);
|
||||
|
||||
if (Enum.TryParse(value, true, out Access access))
|
||||
{
|
||||
return access;
|
||||
}
|
||||
|
||||
return default(Access);
|
||||
return Enum.TryParse(value, true, out Access access) ? access : default(Access);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -1383,9 +1383,9 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
||||
//remove Cordonel sub-string and the blanks
|
||||
var coreRevisionSubString = $"{coreRevisionStrings[0].ToLower().Replace("cordonel ", "")}";
|
||||
var coreRevisionSubStrings = coreRevisionSubString.Split('.');
|
||||
if (Int32.TryParse(coreRevisionSubStrings[0], out var coreRevisionMsb))
|
||||
if (int.TryParse(coreRevisionSubStrings[0], out var coreRevisionMsb))
|
||||
{
|
||||
if (Int32.TryParse(coreRevisionSubStrings[1], out var coreRevisionLsb))
|
||||
if (int.TryParse(coreRevisionSubStrings[1], out var coreRevisionLsb))
|
||||
{
|
||||
CoreRevision = coreRevisionMsb * 100 + coreRevisionLsb;
|
||||
}
|
||||
|
||||
@ -1,15 +1,17 @@
|
||||
namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers.Json
|
||||
using System;
|
||||
|
||||
namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers.Json
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class AppSection
|
||||
{
|
||||
public byte Id { get; set; }
|
||||
public Byte Id { get; set; }
|
||||
|
||||
public FwVersion Version { get; set; }
|
||||
|
||||
public IDictionary<string, Register> Registers { get; set; }
|
||||
public IDictionary<String, Register> Registers { get; set; }
|
||||
|
||||
public IDictionary<string, Status> Status { get; set; }
|
||||
public IDictionary<String, Status> Status { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,16 +1,18 @@
|
||||
namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers.Json
|
||||
using System;
|
||||
|
||||
namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers.Json
|
||||
{
|
||||
public class Details
|
||||
{
|
||||
public string Type { get; set; }
|
||||
public String Type { get; set; }
|
||||
|
||||
public Privilege Privilege { get; set; }
|
||||
|
||||
public string Description { get; set; }
|
||||
public String Description { get; set; }
|
||||
|
||||
public FwVersion Version { get; set; }
|
||||
|
||||
public string StaticType { get; set; }
|
||||
public String StaticType { get; set; }
|
||||
|
||||
public Value Values { get; set; }
|
||||
}
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers.Json
|
||||
using System;
|
||||
|
||||
namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers.Json
|
||||
{
|
||||
public class FwVersion
|
||||
{
|
||||
public int? First { get; set; }
|
||||
public Int32? First { get; set; }
|
||||
|
||||
public int? Last { get; set; }
|
||||
public Int32? Last { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers.Json
|
||||
using System;
|
||||
|
||||
namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers.Json
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class Register
|
||||
{
|
||||
public byte Id { get; set; }
|
||||
public Byte Id { get; set; }
|
||||
|
||||
public IEnumerable<Details> Details { get; set; }
|
||||
}
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers.Json
|
||||
using System;
|
||||
|
||||
namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers.Json
|
||||
{
|
||||
public class Status
|
||||
{
|
||||
public byte Id { get; set; }
|
||||
public Byte Id { get; set; }
|
||||
|
||||
public string Action { get; set; }
|
||||
public String Action { get; set; }
|
||||
|
||||
public string Description { get; set; }
|
||||
public String Description { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers.Json
|
||||
using System;
|
||||
|
||||
namespace Xylem.Common.Hardware.WaterMeter.Genesis.Registers.Json
|
||||
{
|
||||
public class Value
|
||||
{
|
||||
public object Minimum { get; set; }
|
||||
public Object Minimum { get; set; }
|
||||
|
||||
public object Maximum { get; set; }
|
||||
public Object Maximum { get; set; }
|
||||
|
||||
public object Default { get; set; }
|
||||
public Object Default { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user