added - Hardware - eRegister
This commit is contained in:
+1
-1
@@ -51,7 +51,7 @@
|
||||
/// </summary>
|
||||
public Boolean WildCardAddr => this.parameterP12.WildCardAddr;
|
||||
|
||||
public Byte LastCmd => this.message.P2;
|
||||
public String LastCmd => this.message.P2.ToString("X2");
|
||||
|
||||
public override Boolean IsValid => base.IsValid && (this.parameterP12 == 0 || this.parameterP12 == 128);
|
||||
}
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
namespace Common.Hardware.WaterMeter.OmniPlus.Features.Base
|
||||
{
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
public class ASCIIRequest : FeatureRequest
|
||||
{
|
||||
private String value;
|
||||
|
||||
public ASCIIRequest(Int32 length) : base(length)
|
||||
{
|
||||
}
|
||||
|
||||
public String Value
|
||||
{
|
||||
get => this.value;
|
||||
set
|
||||
{
|
||||
this.value = value;
|
||||
|
||||
var bytesLength = this.bytes.Length;
|
||||
|
||||
for (var i = 0; i < bytesLength; i++)
|
||||
{
|
||||
this.bytes[i] = 0;
|
||||
}
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(this.value))
|
||||
{
|
||||
var bytes = Encoding.ASCII.GetBytes(this.value);
|
||||
var length = Math.Min(bytesLength, bytes.Length);
|
||||
|
||||
for (var i = 0; i < length; i++)
|
||||
{
|
||||
this.bytes[i] = bytes[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override Byte[] ToByteArray()
|
||||
=> this.bytes;
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
namespace Common.Hardware.WaterMeter.OmniPlus.Features.Base
|
||||
{
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
public class ASCIIResponse : FeatureResponse
|
||||
{
|
||||
public ASCIIResponse(Byte[] bytes = null) : base(bytes ?? new Byte[2])
|
||||
=> this.Value = Encoding.ASCII.GetString(this.bytes, 1, this.DataLength);
|
||||
|
||||
public string Value { get; }
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
namespace Common.Hardware.WaterMeter.OmniPlus.Features.Base
|
||||
{
|
||||
using System;
|
||||
|
||||
public abstract class Feature
|
||||
{
|
||||
protected readonly Byte[] bytes;
|
||||
|
||||
protected Feature(Int32 length) => this.bytes = new Byte[length];
|
||||
|
||||
protected Feature(Byte[] bytes) => this.bytes = bytes;
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
namespace Common.Hardware.WaterMeter.OmniPlus.Features.Requests
|
||||
{
|
||||
using Common.Hardware.WaterMeter.OmniPlus.Features.Base;
|
||||
|
||||
using System;
|
||||
|
||||
public class FactoryIdRequest : ASCIIRequest
|
||||
{
|
||||
public FactoryIdRequest(String value = null) : base(FeaturesConstants.FactoryIdLength)
|
||||
=> this.Value = value;
|
||||
|
||||
protected override Byte[] ToByteArray()
|
||||
{
|
||||
var length = this.bytes.Length;
|
||||
var bytes = new Byte[length + 1];
|
||||
bytes[0] = FeaturesConstants.SetFactoryId;
|
||||
|
||||
Array.Copy(this.bytes, 0, bytes, 1, length);
|
||||
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
namespace Common.Hardware.WaterMeter.OmniPlus.Features.Requests
|
||||
{
|
||||
using Common.Hardware.WaterMeter.OmniPlus.Features.Base;
|
||||
|
||||
using System;
|
||||
|
||||
public class ProgrammableIdRequest : ASCIIRequest
|
||||
{
|
||||
public ProgrammableIdRequest(String value = null) : base(FeaturesConstants.FactoryIdLength)
|
||||
=> this.Value = value;
|
||||
|
||||
protected override Byte[] ToByteArray()
|
||||
{
|
||||
var length = this.bytes.Length;
|
||||
var bytes = new Byte[length + 1];
|
||||
bytes[0] = FeaturesConstants.ViewProgrammableId;
|
||||
|
||||
Array.Copy(this.bytes, 0, bytes, 1, length);
|
||||
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
-3
@@ -1,14 +1,19 @@
|
||||
namespace Common.Hardware.WaterMeter.eRegister.Features
|
||||
{
|
||||
using Common.Utils.Extensions;
|
||||
|
||||
using System;
|
||||
|
||||
public abstract class AlarmMask : Pam
|
||||
public class AlarmMask : Pam
|
||||
{
|
||||
private readonly Byte[] bits;
|
||||
|
||||
public AlarmMask(Int32 length, Byte cmd) : base(length, cmd)
|
||||
protected AlarmMask(Int32 length, Byte cmd) : base(length, cmd)
|
||||
=> this.bits = new Byte[8];
|
||||
|
||||
public AlarmMask(Byte value) : base(2, 0)
|
||||
=> this.bits = value.GetBits();
|
||||
|
||||
public Boolean SpecificError
|
||||
{
|
||||
get => this.bits[0] == 1;
|
||||
@@ -59,7 +64,7 @@
|
||||
|
||||
protected override Byte[] ToByteArray()
|
||||
{
|
||||
this.bytes[1] = this.bits.GetByteFromBits();
|
||||
this.bytes[1] = this.bits.ToByte();
|
||||
|
||||
return base.ToByteArray();
|
||||
}
|
||||
|
||||
+6
-1
@@ -64,7 +64,6 @@
|
||||
<Compile Include="DeactivateAlarms.cs" />
|
||||
<Compile Include="GetDebug.cs" />
|
||||
<Compile Include="Pam.cs" />
|
||||
<Compile Include="PamExtensions.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ChangeWakeUp.cs" />
|
||||
<Compile Include="RebootsCounter.cs" />
|
||||
@@ -79,5 +78,11 @@
|
||||
<Compile Include="WirelessMBusMode.cs" />
|
||||
<Compile Include="WMBusTransmition.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\..\Utils\Common.Utils.Extensions\Common.Utils.Extensions.csproj">
|
||||
<Project>{05f0ccaf-9f2b-45f9-a7f8-12f29ad182f3}</Project>
|
||||
<Name>Common.Utils.Extensions</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
-133
@@ -1,133 +0,0 @@
|
||||
namespace Common.Hardware.WaterMeter.eRegister.Features
|
||||
{
|
||||
using System;
|
||||
|
||||
public static class PamExtensions
|
||||
{
|
||||
public static Byte[] GetBits(this Byte @byte)
|
||||
{
|
||||
var bits = new Byte[8];
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
bits[i] = (Byte)((@byte >> i) & 1);
|
||||
}
|
||||
|
||||
return bits;
|
||||
}
|
||||
|
||||
public static Byte GetByteFromBits(this Byte[] bits)
|
||||
{
|
||||
var @byte = default(int);
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
@byte |= bits[i] << i;
|
||||
}
|
||||
|
||||
return (Byte)@byte;
|
||||
}
|
||||
|
||||
public static Int32 Int32FromBigEndian(this Byte[] bytes, Int32 start = 0)
|
||||
{
|
||||
var _bytes = new Byte[4];
|
||||
|
||||
Array.Copy(bytes, start, _bytes, 0, 4);
|
||||
Array.Reverse(_bytes);
|
||||
|
||||
return BitConverter.ToInt32(_bytes, 0);
|
||||
}
|
||||
|
||||
public static UInt32 UInt32FromBigEndian(this Byte[] bytes, Int32 start = 0)
|
||||
{
|
||||
var _bytes = new Byte[4];
|
||||
|
||||
Array.Copy(bytes, start, _bytes, 0, 4);
|
||||
Array.Reverse(_bytes);
|
||||
|
||||
return BitConverter.ToUInt32(_bytes, 0);
|
||||
}
|
||||
|
||||
public static void Int32ToBigEndian(this Int32 value, Byte[] bytes, Int32 start = 0)
|
||||
{
|
||||
var _bytes = BitConverter.GetBytes(value);
|
||||
|
||||
Array.Reverse(_bytes);
|
||||
Array.Copy(_bytes, 0, bytes, start, 4);
|
||||
}
|
||||
|
||||
public static void UInt32ToBigEndian(this UInt32 value, Byte[] bytes, Int32 start = 0)
|
||||
{
|
||||
var _bytes = BitConverter.GetBytes(value);
|
||||
|
||||
Array.Reverse(_bytes);
|
||||
Array.Copy(_bytes, 0, bytes, start, 4);
|
||||
}
|
||||
|
||||
public static Byte GetByteFromBits(this Byte[] bytes, Int32 start, Int32 count)
|
||||
{
|
||||
var sum = 0;
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
sum |= bytes[start + i] << i;
|
||||
}
|
||||
|
||||
return (Byte)sum;
|
||||
}
|
||||
|
||||
public static void SetBitsFromByte(this Byte value, Byte[] bits, Int32 start, Int32 count)
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
bits[start + i] = (Byte)((value >> i) & 1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Encrypt(byte pu8_PositionInput, char[] key, int length)
|
||||
{
|
||||
//byte pu8_PositionEnd;
|
||||
//long u32_UnencryptedReference = 0;
|
||||
|
||||
//byte pu8_PositionInput2 = pu8_PositionInput;
|
||||
//short u16_Check;
|
||||
//byte u8_KeyDefinition = 0xFF; // Instructions for application of key, start always with 0xFF
|
||||
//length += 2;
|
||||
//pu8_PositionEnd = (byte)(pu8_PositionInput + length - 1);
|
||||
|
||||
//// Add the CRC-bytes. This starts at the 3rd byte of the radio-telegram which is the 2nd byte of the address (what is the starter, here)
|
||||
//u16_Check = calcCRC_SensusRF(pu8_PositionInput2 + 1, length - 3);
|
||||
|
||||
//// printf("Start with %c, length %d\n", *(pu8_PositionInput2 + 1), length - 3);
|
||||
|
||||
//*(pu8_PositionEnd - 1) = u16_Check >> 8;
|
||||
//*(pu8_PositionEnd) = u16_Check;
|
||||
|
||||
//// Compose the unencrypted reference which is a basis for Key Definition
|
||||
//for (int i = 0; i < 4; i++)
|
||||
//{
|
||||
// u32_UnencryptedReference <<= 8;
|
||||
// u32_UnencryptedReference += *(pu8_PositionInput++);
|
||||
//}
|
||||
|
||||
//// Perform the encryption
|
||||
//while (pu8_PositionInput <= pu8_PositionEnd)
|
||||
//{
|
||||
// // Update u8_KeyDefinition for this byte
|
||||
// u8_KeyDefinition += (((u32_UnencryptedReference >> ((u8_KeyDefinition & 0x3) << 3))
|
||||
// & 0xFF) >> ((u8_KeyDefinition >> 6) & 1));
|
||||
// // Update the unencrypted reference before the byte gets encrypted
|
||||
// u32_UnencryptedReference = (u32_UnencryptedReference << 8);
|
||||
// u32_UnencryptedReference += *pu8_PositionInput;
|
||||
// // Encrypt the data by applying the resepective key
|
||||
// *pu8_PositionInput ^= key[((u8_KeyDefinition >> 2) & 0x0F)];
|
||||
// // Check if data has to be inverted
|
||||
// if (u8_KeyDefinition & 0x80)
|
||||
// *pu8_PositionInput = ~(*pu8_PositionInput);
|
||||
// pu8_PositionInput++;
|
||||
//}
|
||||
|
||||
//return;
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -1,5 +1,7 @@
|
||||
namespace Common.Hardware.WaterMeter.eRegister.Features
|
||||
{
|
||||
using Common.Utils.Extensions;
|
||||
|
||||
using System;
|
||||
|
||||
public class SetBytterySeconds : Pam
|
||||
@@ -10,8 +12,8 @@
|
||||
|
||||
public UInt32 Seconds
|
||||
{
|
||||
get => this.bytes.UInt32FromBigEndian(1);
|
||||
set => value.UInt32ToBigEndian(this.bytes, 1);
|
||||
get => this.bytes.ToUInt32BigEndian(1);
|
||||
set => value.ToBigEndianBytes().CopyTo(this.bytes, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+14
-11
@@ -1,5 +1,7 @@
|
||||
namespace Common.Hardware.WaterMeter.eRegister.Features
|
||||
{
|
||||
using Common.Utils.Extensions;
|
||||
|
||||
using System;
|
||||
|
||||
public class SetMetrologyParameters : Pam
|
||||
@@ -13,14 +15,14 @@
|
||||
|
||||
public Int32 VPP
|
||||
{
|
||||
get => this.bytes.Int32FromBigEndian(2);
|
||||
set => value.Int32ToBigEndian(this.bytes, 2);
|
||||
get => this.bytes.ToInt32BigEndian(2);
|
||||
set => value.ToBigEndianBytes().CopyTo(this.bytes, 2);
|
||||
}
|
||||
|
||||
public Int32 OffsetFactor
|
||||
{
|
||||
get => this.bytes.Int32FromBigEndian(6);
|
||||
set => value.Int32ToBigEndian(this.bytes, 6);
|
||||
get => this.bytes.ToInt32BigEndian(6);
|
||||
set => value.ToBigEndianBytes().CopyTo(this.bytes, 6);
|
||||
}
|
||||
|
||||
public Byte OffsetTime
|
||||
@@ -40,14 +42,14 @@
|
||||
/// </summary>
|
||||
public Byte Units
|
||||
{
|
||||
get => this.bitsFromByte11.GetByteFromBits(0, 5);
|
||||
set => value.SetBitsFromByte(this.bytes, 0, 5);
|
||||
get => this.bitsFromByte11.ToByte(0, 5);
|
||||
set => value.SetBits(this.bytes, 0, 5);
|
||||
}
|
||||
|
||||
public Byte DecimalPoint
|
||||
{
|
||||
get => this.bitsFromByte11.GetByteFromBits(6, 2);
|
||||
set => value.SetBitsFromByte(this.bytes, 6, 2);
|
||||
get => this.bitsFromByte11.ToByte(6, 2);
|
||||
set => value.SetBits(this.bytes, 6, 2);
|
||||
}
|
||||
|
||||
public Boolean UseCandIRules
|
||||
@@ -64,17 +66,18 @@
|
||||
|
||||
public UInt32 VPLP
|
||||
{
|
||||
get => this.bytes.UInt32FromBigEndian(14);
|
||||
set => value.UInt32ToBigEndian(this.bytes, 14);
|
||||
get => this.bytes.ToUInt32BigEndian(14);
|
||||
set => value.ToBigEndianBytes().CopyTo(this.bytes, 14);
|
||||
}
|
||||
|
||||
protected override Byte[] ToByteArray()
|
||||
{
|
||||
var bytes11 = new Byte[8];
|
||||
|
||||
Array.Copy(this.bitsFromByte11, 0, bytes11, 0, 8);
|
||||
Array.Reverse(bytes11);
|
||||
|
||||
this.bytes[12] = bytes11.GetByteFromBits();
|
||||
this.bytes[12] = bytes11.ToByte();
|
||||
|
||||
return base.ToByteArray();
|
||||
}
|
||||
|
||||
+4
-2
@@ -1,5 +1,7 @@
|
||||
namespace Common.Hardware.WaterMeter.eRegister.Features
|
||||
{
|
||||
using Common.Utils.Extensions;
|
||||
|
||||
using System;
|
||||
|
||||
public class SetPCB : Pam
|
||||
@@ -10,8 +12,8 @@
|
||||
|
||||
public UInt32 ID
|
||||
{
|
||||
get => this.bytes.UInt32FromBigEndian(1);
|
||||
set => value.UInt32ToBigEndian(this.bytes, 1);
|
||||
get => this.bytes.ToUInt32BigEndian(1);
|
||||
set => value.ToBigEndianBytes().CopyTo(this.bytes, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+20
-18
@@ -1,5 +1,7 @@
|
||||
namespace Common.Hardware.WaterMeter.eRegister.Features
|
||||
{
|
||||
using Common.Utils.Extensions;
|
||||
|
||||
using System;
|
||||
|
||||
public class SetTFXParameters : Pam
|
||||
@@ -71,32 +73,32 @@
|
||||
|
||||
public Byte MeterSampleRate
|
||||
{
|
||||
get => this.bitsFromByte3.GetByteFromBits(0, 3);
|
||||
set => value.SetBitsFromByte(this.bitsFromByte3, 0, 3);
|
||||
get => this.bitsFromByte3.ToByte(0, 3);
|
||||
set => value.SetBits(this.bitsFromByte3, 0, 3);
|
||||
}
|
||||
|
||||
public Byte Units
|
||||
{
|
||||
get => this.bitsFromByte3.GetByteFromBits(3, 3);
|
||||
set => value.SetBitsFromByte(this.bitsFromByte3, 3, 3);
|
||||
get => this.bitsFromByte3.ToByte(3, 3);
|
||||
set => value.SetBits(this.bitsFromByte3, 3, 3);
|
||||
}
|
||||
|
||||
public Byte HistoryScale
|
||||
{
|
||||
get => this.bitsFromByte3.GetByteFromBits(6, 2);
|
||||
set => value.SetBitsFromByte(this.bitsFromByte3, 6, 2);
|
||||
get => this.bitsFromByte3.ToByte(6, 2);
|
||||
set => value.SetBits(this.bitsFromByte3, 6, 2);
|
||||
}
|
||||
|
||||
public Byte ReadingResolution
|
||||
{
|
||||
get => this.bitsFromByte4.GetByteFromBits(0, 4);
|
||||
set => value.SetBitsFromByte(this.bitsFromByte4, 0, 4);
|
||||
get => this.bitsFromByte4.ToByte(0, 4);
|
||||
set => value.SetBits(this.bitsFromByte4, 0, 4);
|
||||
}
|
||||
|
||||
public Byte NumberOfDigits
|
||||
{
|
||||
get => this.bitsFromByte4.GetByteFromBits(4, 3);
|
||||
set => value.SetBitsFromByte(this.bitsFromByte4, 4, 3);
|
||||
get => this.bitsFromByte4.ToByte(4, 3);
|
||||
set => value.SetBits(this.bitsFromByte4, 4, 3);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -124,14 +126,14 @@
|
||||
/// </summary>
|
||||
public Byte RegisterMode
|
||||
{
|
||||
get => this.bitsFromByte5.GetByteFromBits(0, 2);
|
||||
set => value.SetBitsFromByte(this.bitsFromByte5, 0, 2);
|
||||
get => this.bitsFromByte5.ToByte(0, 2);
|
||||
set => value.SetBits(this.bitsFromByte5, 0, 2);
|
||||
}
|
||||
|
||||
public Byte MeterTransmitRate
|
||||
{
|
||||
get => this.bitsFromByte5.GetByteFromBits(2, 3);
|
||||
set => value.SetBitsFromByte(this.bitsFromByte5, 2, 3);
|
||||
get => this.bitsFromByte5.ToByte(2, 3);
|
||||
set => value.SetBits(this.bitsFromByte5, 2, 3);
|
||||
}
|
||||
|
||||
public Boolean MTRChanged
|
||||
@@ -175,10 +177,10 @@
|
||||
|
||||
protected override Byte[] ToByteArray()
|
||||
{
|
||||
this.bytes[3] = this.bitsFromByte2.GetByteFromBits();
|
||||
this.bytes[4] = this.bitsFromByte3.GetByteFromBits();
|
||||
this.bytes[5] = this.bitsFromByte4.GetByteFromBits();
|
||||
this.bytes[6] = this.bitsFromByte5.GetByteFromBits();
|
||||
this.bytes[3] = this.bitsFromByte2.ToByte();
|
||||
this.bytes[4] = this.bitsFromByte3.ToByte();
|
||||
this.bytes[5] = this.bitsFromByte4.ToByte();
|
||||
this.bytes[6] = this.bitsFromByte5.ToByte();
|
||||
|
||||
return base.ToByteArray();
|
||||
}
|
||||
|
||||
+3
-1
@@ -1,5 +1,7 @@
|
||||
namespace Common.Hardware.WaterMeter.eRegister.Features
|
||||
{
|
||||
using Common.Utils.Extensions;
|
||||
|
||||
using System;
|
||||
|
||||
public class WirelessMBusMode : Pam
|
||||
@@ -80,7 +82,7 @@
|
||||
|
||||
protected override Byte[] ToByteArray()
|
||||
{
|
||||
this.bytes[1] = this.bits.GetByteFromBits();
|
||||
this.bytes[1] = this.bits.ToByte();
|
||||
|
||||
return base.ToByteArray();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
namespace Common.UI.SIRTBroadcaster.Models.Payloads
|
||||
{
|
||||
using Common.Hardware.WaterMeter.eRegister.Features;
|
||||
using Common.Utils.Extensions;
|
||||
|
||||
using System;
|
||||
|
||||
public class BUP : Payload
|
||||
{
|
||||
public BUP(Byte[] payload) : base(payload)
|
||||
{
|
||||
var index = 6;
|
||||
|
||||
this.Reading = payload.ToUInt32BigEndian((index += 4) - 4);
|
||||
this.Alarm = new AlarmMask(payload[index++]);
|
||||
this.Crc = payload.ToUInt16BigEndian((index += 2) - 2);
|
||||
}
|
||||
|
||||
public UInt32 Reading { get; }
|
||||
|
||||
public AlarmMask Alarm { get; }
|
||||
|
||||
public UInt16 Crc { get; protected set; }
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{4E8BB839-D40A-488C-88CE-F21811F1F476}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>Common.Hardware.WaterMeter.eRegister</RootNamespace>
|
||||
<AssemblyName>Common.Hardware.WaterMeter.eRegister</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject />
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="BUP.cs" />
|
||||
<Compile Include="DEBUG.cs" />
|
||||
<Compile Include="LAT.cs" />
|
||||
<Compile Include="Payload.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SEMI.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\..\Utils\Common.Utils.Extensions\Common.Utils.Extensions.csproj">
|
||||
<Project>{05F0CCAF-9F2B-45F9-A7F8-12F29AD182F3}</Project>
|
||||
<Name>Common.Utils.Extensions</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Common.Hardware.WaterMeter.eRegister.Features\Common.Hardware.WaterMeter.eRegister.Features.csproj">
|
||||
<Project>{E19C1694-132E-477C-86CB-8E146D5F59B0}</Project>
|
||||
<Name>Common.Hardware.WaterMeter.eRegister.Features</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,129 @@
|
||||
namespace Common.UI.SIRTBroadcaster.Models.Payloads
|
||||
{
|
||||
using Common.Utils.Extensions;
|
||||
|
||||
using System;
|
||||
|
||||
public class DEBUG : BUP
|
||||
{
|
||||
public DEBUG(Byte[] payload) : base(payload)
|
||||
{
|
||||
var index = 6;
|
||||
|
||||
this.DebugType = payload[index++];
|
||||
this.MeterType = payload[index++];
|
||||
this.RadioFirmwareVersion = payload[index++].ToString();
|
||||
this.FirmwareVersion = payload[index++].ToString();
|
||||
this.MetrologyFirmwareVersion = this.VersionString(payload[index++], payload[index++]);
|
||||
this.HardwareVersion = payload[index++].ToString();
|
||||
this.FactoryState = payload[index++];
|
||||
this.PCBID = payload.ToUInt32BigEndian((index += 4) - 4);
|
||||
this.BoardTemperature = payload[index++];
|
||||
this.BatteryVoltage = payload.ToUInt16BigEndian((index += 2) - 2);
|
||||
this.WakeupInterval = payload[index++];
|
||||
this.PowerLevelSensusRF = payload[index++];
|
||||
this.PowerLevelFlexNet = payload[index++];
|
||||
this.FrequencyOffset = payload.ToUInt16BigEndian((index += 2) - 2);
|
||||
this.RebootCount = payload[index++];
|
||||
this.WatchdogCount = payload[index++];
|
||||
this.BatterySeconds = payload.ToUInt32BigEndian((index += 4) - 4);
|
||||
this.MeterSampleRate = payload[index++];
|
||||
this.HistoryScale = payload[index++];
|
||||
this.RegisterMode = payload[index++];
|
||||
this.HistorySize = payload[index++];
|
||||
this.FactoryCalibration = payload[index++] / 10F;
|
||||
this.MeterSize = payload[index++];
|
||||
this.VolumePerLedPulse = payload.ToUInt32BigEndian((index += 4) - 4);
|
||||
this.VolumePerPulse = payload.ToUInt32BigEndian((index += 4) - 4);
|
||||
this.OffsetFactor = payload.ToUInt32BigEndian((index += 4) - 4);
|
||||
this.OffsetTime = payload[index++];
|
||||
|
||||
if (payload.Length > index + 2)
|
||||
{
|
||||
this.Crc = payload.ToUInt16BigEndian((index += 2) - 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Crc = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public Byte DebugType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 0x0A for Residential and 0x0C for C & I
|
||||
/// </summary>
|
||||
public Byte MeterType { get; }
|
||||
|
||||
public String RadioFirmwareVersion { get; }
|
||||
|
||||
public String FirmwareVersion { get; }
|
||||
|
||||
public String HardwareVersion { get; }
|
||||
|
||||
public String MetrologyFirmwareVersion { get; }
|
||||
|
||||
public Byte FactoryState { get; }
|
||||
|
||||
public UInt32 PCBID { get; }
|
||||
|
||||
public Byte BoardTemperature { get; }
|
||||
|
||||
public UInt16 BatteryVoltage { get; }
|
||||
|
||||
public Byte WakeupInterval { get; }
|
||||
|
||||
public Byte PowerLevelSensusRF { get; }
|
||||
|
||||
public Byte PowerLevelFlexNet { get; }
|
||||
|
||||
public UInt32 FrequencyOffset { get; }
|
||||
|
||||
public Byte RebootCount { get; }
|
||||
|
||||
public Byte WatchdogCount { get; }
|
||||
|
||||
public UInt32 BatterySeconds { get; }
|
||||
|
||||
public Byte MeterSampleRate { get; }
|
||||
|
||||
public Byte HistoryScale { get; }
|
||||
|
||||
public Byte RegisterMode { get; }
|
||||
|
||||
public Byte HistorySize { get; }
|
||||
|
||||
public Single FactoryCalibration { get; }
|
||||
|
||||
public Byte MeterSize { get; }
|
||||
|
||||
public UInt32 VolumePerLedPulse { get; }
|
||||
|
||||
public UInt32 VolumePerPulse { get; }
|
||||
|
||||
public UInt32 OffsetFactor { get; }
|
||||
|
||||
public Byte OffsetTime { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Bit 15 – Beta or Release
|
||||
/// Bits 12-14 – Major Version
|
||||
/// Bits 8-11 – Minor Version
|
||||
/// Bits 0-7 – Patch Version
|
||||
/// </summary>
|
||||
private String VersionString(Byte param, Byte patch)
|
||||
{
|
||||
var bits = param.GetBits();
|
||||
var _major = new Byte[8];
|
||||
var _minor = new Byte[8];
|
||||
|
||||
Array.Copy(bits, 0, _major, 0, 4);
|
||||
Array.Copy(bits, 4, _minor, 0, 3);
|
||||
|
||||
var major = _major.ToByte();
|
||||
var minor = _minor.ToByte();
|
||||
|
||||
return $"{bits[7]}.{major}.{minor}.{patch}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace Common.UI.SIRTBroadcaster.Models.Payloads
|
||||
{
|
||||
using System;
|
||||
|
||||
public class LAT : BUP
|
||||
{
|
||||
public LAT(Byte[] payload) : base(payload)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace Common.UI.SIRTBroadcaster.Models.Payloads
|
||||
{
|
||||
using Common.Utils.Extensions;
|
||||
|
||||
using System;
|
||||
|
||||
public abstract class Payload
|
||||
{
|
||||
protected Payload(Byte[] payload)
|
||||
{
|
||||
var index = 0;
|
||||
|
||||
this.AppCode = payload[index++];
|
||||
this.Counter = payload[index++];
|
||||
this.Address = payload.ToUInt32BigEndian((index += 4) - 4);
|
||||
}
|
||||
|
||||
public Byte AppCode { get; }
|
||||
|
||||
public Byte Counter { get; }
|
||||
|
||||
public UInt32 Address { get; }
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
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("Common.Hardware.WaterMeter.eRegister")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Common.Hardware.WaterMeter.eRegister")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2024")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("4e8bb839-d40a-488c-88ce-f21811f1f476")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,151 @@
|
||||
namespace Common.UI.SIRTBroadcaster.Models.Payloads
|
||||
{
|
||||
using Common.Utils.Extensions;
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
public class SEMI : BUP
|
||||
{
|
||||
public SEMI(Byte[] payload) : base(payload)
|
||||
{
|
||||
var index = 11;
|
||||
|
||||
this.PamStatus = payload[index++];
|
||||
this.RSSI = payload[index++];
|
||||
this.MeterType = payload[index++];
|
||||
this.TransmissionInterval = payload.ToUInt16BigEndian((index += 2) - 2);
|
||||
this.LATInterval = payload[index++];
|
||||
this.CurrentFlow = payload.ToUInt16BigEndian((index += 2) - 2);
|
||||
this.BackwardVolume = payload.ToUInt32BigEndian((index += 4) - 4);
|
||||
this.NumberOfDials = payload[index++];
|
||||
this.Units = payload[index++];
|
||||
this.MeterID = payload.ToUInt32BigEndian((index += 4) - 4);
|
||||
this.MBusStatus = payload[index++];
|
||||
this.MBusTransmissionInterval = payload.ToUInt16BigEndian((index += 2) - 2);
|
||||
this.AlarmActiveInformation = payload[index++];
|
||||
this.LeakageDetectionParameters = payload[index++];
|
||||
this.BrokenPipeDetectionParameters = payload[index++];
|
||||
this.BatteryRemaining = payload.ToUInt16BigEndian((index += 2) - 2);
|
||||
this.BatteryEndDetected = payload.ToUInt16BigEndian((index += 2) - 2);
|
||||
this.MaximumFlow = payload.ToUInt16BigEndian((index += 2) - 2);
|
||||
this.TimeOfMaximumFlow = payload.ToUInt16BigEndian((index += 2) - 2);
|
||||
this.LowBatteryDetected = payload.ToUInt16BigEndian((index += 2) - 2);
|
||||
this.LeakStart = payload.ToUInt16BigEndian((index += 2) - 2);
|
||||
this.LeakEnd = payload.ToUInt16BigEndian((index += 2) - 2);
|
||||
this.MagneticTamperStart = payload.ToUInt16BigEndian((index += 2) - 2);
|
||||
this.MagneticTamperEnd = payload.ToUInt16BigEndian((index += 2) - 2);
|
||||
this.ModuleRemoveStart = payload.ToUInt16BigEndian((index += 2) - 2);
|
||||
this.ModuleRemoveEnd = payload.ToUInt16BigEndian((index += 2) - 2);
|
||||
this.BackflowStart = payload.ToUInt16BigEndian((index += 2) - 2);
|
||||
this.BackflowEnd = payload.ToUInt16BigEndian((index += 2) - 2);
|
||||
this.BrokenPipeStart = payload.ToUInt16BigEndian((index += 2) - 2);
|
||||
this.BrokenPipeEnd = payload.ToUInt16BigEndian((index += 2) - 2);
|
||||
this.LogContent = payload.ToUInt16BigEndian((index += 2) - 2);
|
||||
this.LoggingInterval = payload.ToUInt16BigEndian((index += 2) - 2);
|
||||
this.FixedDateReadingContent = payload.ToUInt16BigEndian((index += 2) - 2);
|
||||
this.DayOfMonth = payload[index++];
|
||||
this.ActualDateTime = payload.ToUInt32BigEndian((index += 4) - 4);
|
||||
this.HistoricalErrorLimit = payload[index++];
|
||||
this.CustomerSpecificText = Encoding.ASCII.GetString(payload, (index += 9) - 9, 9);
|
||||
this.TimeOfFDRReset = payload.ToUInt16BigEndian((index += 2) - 2);
|
||||
this.TimeOfLogReset = payload.ToUInt16BigEndian((index += 2) - 2);
|
||||
this.MeterSize = payload[index++];
|
||||
|
||||
if (payload.Length > index + 2)
|
||||
{
|
||||
this.Crc = payload.ToUInt16BigEndian((index += 2) - 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Crc = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public UInt32 ModuleAddress { get; }
|
||||
|
||||
public UInt32 DisplayVolume { get; }
|
||||
|
||||
public Byte Alarms { get; }
|
||||
|
||||
public Byte PamStatus { get; }
|
||||
|
||||
public Byte RSSI { get; }
|
||||
|
||||
public Byte MeterType { get; }
|
||||
|
||||
public UInt16 TransmissionInterval { get; }
|
||||
|
||||
public Byte LATInterval { get; }
|
||||
|
||||
public UInt16 CurrentFlow { get; }
|
||||
|
||||
public UInt32 BackwardVolume { get; }
|
||||
|
||||
public Byte NumberOfDials { get; }
|
||||
|
||||
public Byte Units { get; }
|
||||
|
||||
public UInt32 MeterID { get; }
|
||||
|
||||
public Byte MBusStatus { get; }
|
||||
|
||||
public UInt16 MBusTransmissionInterval { get; }
|
||||
|
||||
public Byte AlarmActiveInformation { get; }
|
||||
|
||||
public Byte LeakageDetectionParameters { get; }
|
||||
|
||||
public Byte BrokenPipeDetectionParameters { get; }
|
||||
|
||||
public UInt16 BatteryRemaining { get; }
|
||||
|
||||
public UInt16 BatteryEndDetected { get; }
|
||||
|
||||
public UInt16 MaximumFlow { get; }
|
||||
|
||||
public UInt16 TimeOfMaximumFlow { get; }
|
||||
|
||||
public UInt16 LowBatteryDetected { get; }
|
||||
|
||||
public UInt16 LeakStart { get; }
|
||||
|
||||
public UInt16 LeakEnd { get; }
|
||||
|
||||
public UInt16 MagneticTamperStart { get; }
|
||||
|
||||
public UInt16 MagneticTamperEnd { get; }
|
||||
|
||||
public UInt16 ModuleRemoveStart { get; }
|
||||
|
||||
public UInt16 ModuleRemoveEnd { get; }
|
||||
|
||||
public UInt16 BackflowStart { get; }
|
||||
|
||||
public UInt16 BackflowEnd { get; }
|
||||
|
||||
public UInt16 BrokenPipeStart { get; }
|
||||
|
||||
public UInt16 BrokenPipeEnd { get; }
|
||||
|
||||
public UInt16 LogContent { get; }
|
||||
|
||||
public UInt16 LoggingInterval { get; }
|
||||
|
||||
public UInt16 FixedDateReadingContent { get; }
|
||||
|
||||
public Byte DayOfMonth { get; }
|
||||
|
||||
public UInt32 ActualDateTime { get; }
|
||||
|
||||
public Byte HistoricalErrorLimit { get; }
|
||||
|
||||
public String CustomerSpecificText { get; }
|
||||
|
||||
public UInt16 TimeOfFDRReset { get; }
|
||||
|
||||
public UInt16 TimeOfLogReset { get; }
|
||||
|
||||
public Byte MeterSize { get; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user