eregister prüfung abschlus ~
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace Common.Hardware.SIRT.Parameters
|
||||
{
|
||||
using Common.Hardware.Ports;
|
||||
using System;
|
||||
|
||||
using System.Text;
|
||||
|
||||
public class PAMStatus
|
||||
@@ -60,6 +60,8 @@
|
||||
|
||||
public static byte OK = 0;
|
||||
|
||||
public static byte EXPIREDAUTH = 4;
|
||||
|
||||
public static implicit operator byte(PAMStatus status)
|
||||
=> status?.bits?.GetByteLE() ?? 0xFF;
|
||||
|
||||
|
||||
@@ -28,5 +28,9 @@
|
||||
public double Dbm { get; }
|
||||
|
||||
public double Percent { get; }
|
||||
|
||||
public override string ToString() => $"{this.Dbm}dBm ({this.Percent:0.0}%)";
|
||||
|
||||
public static implicit operator string(RSSI rssi) => rssi?.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,12 +33,12 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Logging?.Invoke($"SIRT on {this.COMPort} not identified.");
|
||||
// this.Logging?.Invoke($"SIRT on {this.COMPort} not identified.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Logging?.Invoke($"SIRT on {this.COMPort} not activated.");
|
||||
// this.Logging?.Invoke($"SIRT on {this.COMPort} not activated.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,26 +72,37 @@
|
||||
|
||||
private void OnStateChanged(SIRTTask task)
|
||||
{
|
||||
if (task.State != SIRTTaskState.Cancelled)
|
||||
if (task.State == SIRTTaskState.Completed)
|
||||
{
|
||||
this.TaskRemoveEventHandlers(task);
|
||||
|
||||
if (this.tasks.TryGetValue(task.RequestAddress, out var requestTasks))
|
||||
{
|
||||
requestTasks.TryDequeue(out var _);
|
||||
if (requestTasks.TryDequeue(out var _))
|
||||
{
|
||||
this.TaskRemoveEventHandlers(task);
|
||||
}
|
||||
}
|
||||
else if (this.tasks.TryGetValue(task.ResponseAddress, out var responseTasks))
|
||||
{
|
||||
responseTasks.TryDequeue(out var _);
|
||||
if (responseTasks.TryDequeue(out var _))
|
||||
{
|
||||
this.TaskRemoveEventHandlers(task);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (task.State == SIRTTaskState.Cancelled)
|
||||
{
|
||||
this.TaskRemoveEventHandlers(task);
|
||||
this.OnTaskTimeout(task);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTaskTimeout(SIRTTask task)
|
||||
{
|
||||
var deleteRequestAddress = SIRTTask.DeleteFromPamPool(task.RequestAddress);
|
||||
|
||||
this.TryRun(deleteRequestAddress);
|
||||
|
||||
var deleteResponseAddress = SIRTTask.DeleteFromPamPool(task.ResponseAddress);
|
||||
this.TryRun(deleteResponseAddress);
|
||||
}
|
||||
|
||||
private void OnTaskUpdated(SIRTTask task)
|
||||
@@ -100,13 +111,7 @@
|
||||
{
|
||||
foreach (var _task in tasksQueue.AsEnumerable())
|
||||
{
|
||||
if (_task.State != SIRTTaskState.Pending)
|
||||
{
|
||||
_task.P1 = task.P1;
|
||||
_task.P2 = task.P2;
|
||||
_task.RequestAddress = task.RequestAddress;
|
||||
_task.ResponseAddress = task.ResponseAddress;
|
||||
}
|
||||
_task.UpdateFrom(task);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -116,8 +121,8 @@
|
||||
this.cancellationTokenSource = new CancellationTokenSource();
|
||||
this.cancellationToken = this.cancellationTokenSource.Token;
|
||||
|
||||
Task.Factory.StartNew((Action)this.StartReadingMessages, this.cancellationToken);
|
||||
Task.Factory.StartNew((Action)this.ActivateSIRT, this.cancellationToken);
|
||||
Task.Factory.StartNew(this.StartReadingMessages, this.cancellationToken);
|
||||
Task.Factory.StartNew(this.ActivateSIRT, this.cancellationToken);
|
||||
|
||||
this.Connected?.Invoke();
|
||||
}
|
||||
@@ -136,8 +141,10 @@
|
||||
this.Disconnected?.Invoke();
|
||||
}
|
||||
|
||||
private void SerialPort_Logging(string e)
|
||||
=> this.Logging?.Invoke(e);
|
||||
private void SerialPort_Logging(string e)
|
||||
{
|
||||
//this.Logging?.Invoke(e);
|
||||
}
|
||||
|
||||
private void SIRTConnection_MessageReceived(SIRTMessage message)
|
||||
{
|
||||
@@ -146,10 +153,9 @@
|
||||
if (tasksQueue.TryPeek(out var task))
|
||||
{
|
||||
task.PushResponse(message);
|
||||
this.Logging?.Invoke(message.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
this.Logging?.Invoke(message.ToString());
|
||||
}
|
||||
|
||||
private void StartProcessingTasksAsync()
|
||||
@@ -165,18 +171,15 @@
|
||||
|
||||
foreach (var tasksQueue in connection.tasks.Values.ToArray())
|
||||
{
|
||||
if (tasksQueue.TryPeek(out var task))
|
||||
{
|
||||
if (task.State == SIRTTaskState.Pending)
|
||||
{
|
||||
connection.serialPort.Write(task.Start());
|
||||
this.Logging?.Invoke(task.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
totalTasksCount += tasksQueue.Count;
|
||||
|
||||
await Task.Delay(10);
|
||||
if (tasksQueue.TryPeek(out var task) && task.State == SIRTTaskState.Pending)
|
||||
{
|
||||
connection.serialPort.Write(task.Start());
|
||||
this.Logging?.Invoke(task.ToString());
|
||||
}
|
||||
|
||||
await Task.Delay(50);
|
||||
}
|
||||
|
||||
if (totalTasksCount <= 0)
|
||||
@@ -298,7 +301,7 @@
|
||||
task.Completed += taskStateChanged;
|
||||
|
||||
this.serialPort.Write(task.Start());
|
||||
this.Logging?.Invoke(task.ToString());
|
||||
// this.Logging?.Invoke(task.ToString());
|
||||
manualResetEventSlim.Wait(task.Timeout);
|
||||
manualResetEventSlim.Reset();
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
|
||||
if (task.RequestAddress != task.ResponseAddress)
|
||||
{
|
||||
this.tasks.AddOrUpdate(task.ResponseAddress, requestTasks, (k, v) => requestTasks);
|
||||
this.tasks.AddOrUpdate(task.ResponseAddress, requestTasks, (_, _requestTasks) => _requestTasks);
|
||||
}
|
||||
|
||||
if (!this.processingWaitHandle.IsSet)
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
private readonly ConcurrentDictionary<string, SIRTBroadcaster> connections
|
||||
= new ConcurrentDictionary<string, SIRTBroadcaster>();
|
||||
|
||||
public event Action<string> Log;
|
||||
public event Action<string> Logging;
|
||||
|
||||
public void CloseConnection(string portName)
|
||||
{
|
||||
@@ -52,12 +52,13 @@
|
||||
|
||||
if (this.connections.TryAdd(comPort, connection))
|
||||
{
|
||||
connection.Logging += message => this.Log?.Invoke(message);
|
||||
connection.Logging += message => this.Logging?.Invoke(message);
|
||||
connection.Open();
|
||||
}
|
||||
else
|
||||
{
|
||||
connection = null;
|
||||
this.Logging?.Invoke($"Cann't connect SIRT to {comPort}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
namespace Common.Hardware.SIRT
|
||||
{
|
||||
using Common.Hardware.Ports;
|
||||
using Common.Hardware.SIRT.Parameters;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
|
||||
public class SIRTMessage
|
||||
@@ -62,6 +61,7 @@
|
||||
|
||||
public byte Length => this.bytes[8];
|
||||
|
||||
[JsonIgnore]
|
||||
public byte[] Data
|
||||
{
|
||||
get
|
||||
@@ -89,6 +89,8 @@
|
||||
|
||||
public ushort CRC => this.bytes.ToUInt16BE(this.bytes.Length - 3);
|
||||
|
||||
public string Content => this.ToString();
|
||||
|
||||
public byte[] ToByteArray()
|
||||
{
|
||||
var length = this.bytes.Length;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
internal class AnswerTask : SIRTTask
|
||||
{
|
||||
public AnswerTask() : base(0, 3000)
|
||||
public AnswerTask() : base(0, 1000)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
public partial class SIRTTask
|
||||
{
|
||||
protected readonly ConcurrentStack<SIRTMessage> responses;
|
||||
protected readonly SIRTMessage request;
|
||||
public readonly ConcurrentStack<SIRTMessage> responses;
|
||||
public readonly SIRTMessage request;
|
||||
protected readonly Timer timeoutTimer;
|
||||
|
||||
public SIRTTask(int frequency, int timeout = 5_000)
|
||||
@@ -33,7 +33,7 @@
|
||||
public byte Cmd
|
||||
{
|
||||
get => this.request.Cmd;
|
||||
protected set => this.request.Cmd = value;
|
||||
set => this.request.Cmd = value;
|
||||
}
|
||||
|
||||
public byte P1
|
||||
@@ -74,27 +74,42 @@
|
||||
|
||||
public void PushResponse(SIRTMessage response)
|
||||
{
|
||||
var address = response.Address;
|
||||
|
||||
if (address == this.RequestAddress || address == this.ResponseAddress)
|
||||
if (this.State == SIRTTaskState.Cancelled)
|
||||
{
|
||||
this.responses.Push(response);
|
||||
return;
|
||||
}
|
||||
|
||||
if (address == this.ResponseAddress)
|
||||
this.responses.Push(response);
|
||||
|
||||
if (response.Length >= 13)
|
||||
{
|
||||
var responseAddress = response.Address;
|
||||
|
||||
if (responseAddress != this.RequestAddress)
|
||||
{
|
||||
var requestAddress = this.RequestAddress;
|
||||
this.RequestAddress = this.ResponseAddress;
|
||||
this.ResponseAddress = requestAddress;
|
||||
|
||||
this.NotifyUpdated();
|
||||
}
|
||||
|
||||
this.ProcessResponse(response);
|
||||
}
|
||||
|
||||
this.ProcessResponse(response);
|
||||
}
|
||||
|
||||
public virtual byte[] ToByteArray() => this.request.ToByteArray();
|
||||
|
||||
public override string ToString() => BitConverter.ToString(this.ToByteArray());
|
||||
|
||||
public virtual void UpdateFrom(SIRTTask task)
|
||||
{
|
||||
this.P1 = task.P1;
|
||||
this.P2 = task.P2;
|
||||
this.RequestAddress = task.RequestAddress;
|
||||
this.ResponseAddress = task.ResponseAddress;
|
||||
}
|
||||
|
||||
protected void NotifyCancelled() => this.Cancelled?.Invoke(this);
|
||||
|
||||
protected void NotifyCompleted() => this.Completed?.Invoke(this);
|
||||
|
||||
@@ -5,9 +5,6 @@
|
||||
Pending = 0,
|
||||
Running = 1,
|
||||
Completed = 2,
|
||||
Timeouted = 3,
|
||||
Cancelled = 4,
|
||||
ErrorSEMI = 5,
|
||||
ErrorP11 = 6,
|
||||
Cancelled = 4
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
namespace Common.Hardware.WaterMeter.eRegister.Attributes
|
||||
{
|
||||
using System;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
|
||||
public class ComparePropertyAttribute : Attribute
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
namespace Common.Hardware.WaterMeter.eRegister.Attributes
|
||||
{
|
||||
using System;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
|
||||
public class EregisterFeatureAttribute : Attribute
|
||||
{
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -56,11 +56,13 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Attributes\EregisterFeatureAttribute.cs" />
|
||||
<Compile Include="Eregister.cs" />
|
||||
<Compile Include="EregisterBatch.cs" />
|
||||
<Compile Include="EregisterCheckFinalizationTask.cs" />
|
||||
<Compile Include="EregisterCheckInitializationTask.cs" />
|
||||
<Compile Include="EregisterExtensions.cs" />
|
||||
<Compile Include="EregisterCheckStateTask.cs" />
|
||||
<Compile Include="EregisterTask.cs" />
|
||||
<Compile Include="Features\ActivateMetrologyTestMode.cs" />
|
||||
<Compile Include="Features\AlarmPersistence.cs" />
|
||||
@@ -139,9 +141,10 @@
|
||||
<Compile Include="Features\SingleBytePam.cs" />
|
||||
<Compile Include="Features\WakeUpMode.cs" />
|
||||
<Compile Include="Features\WirelessMBusMode.cs" />
|
||||
<Compile Include="Models\ComparePropertyAttribute.cs" />
|
||||
<Compile Include="Attributes\ComparePropertyAttribute.cs" />
|
||||
<Compile Include="Models\EregisterDebugFeatures.cs" />
|
||||
<Compile Include="Models\EregisterFeatures.cs" />
|
||||
<Compile Include="Models\EregisterAvailableParametersParser.cs" />
|
||||
<Compile Include="Models\EregisterProgrammingParameters.cs" />
|
||||
<Compile Include="Models\EregisterProgrammingParametersList.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
||||
+16
-6
@@ -134,10 +134,23 @@
|
||||
this.runningTasks.Clear();
|
||||
|
||||
var frequency = this.features.Frequency;
|
||||
var pams = this.features.BuildPams();
|
||||
var wakeUP = true;
|
||||
|
||||
foreach (var pam in pams)
|
||||
this.runningTasks.Enqueue(new EregisterCheckStateTask(frequency)
|
||||
{
|
||||
SlotNr = this.features.SlotNr,
|
||||
PoNr = this.features.PoNr,
|
||||
SerialNr = this.features.SerialNr,
|
||||
P1 = new P811
|
||||
{
|
||||
DelPamSemi = true,
|
||||
WakeUpCmd = true,
|
||||
},
|
||||
RequestAddress = this.features.RequestAddress,
|
||||
ResponseAddress = this.features.ResponseAddress,
|
||||
EncryptionKey = this.features.EncryptionKey
|
||||
});
|
||||
|
||||
foreach (var pam in this.features.BuildPamsFull())
|
||||
{
|
||||
this.runningTasks.Enqueue(new EregisterTask(frequency)
|
||||
{
|
||||
@@ -148,15 +161,12 @@
|
||||
P1 = new P811
|
||||
{
|
||||
DelPamSemi = true,
|
||||
WakeUpCmd = wakeUP,
|
||||
},
|
||||
RequestAddress = this.features.RequestAddress,
|
||||
ResponseAddress = this.features.ResponseAddress,
|
||||
Data = pam.Value,
|
||||
EncryptionKey = this.features.EncryptionKey
|
||||
});
|
||||
|
||||
wakeUP = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-12
@@ -10,12 +10,12 @@
|
||||
|
||||
public class EregisterBatch
|
||||
{
|
||||
private readonly SIRTFactory broadcaster;
|
||||
private readonly SIRTFactory sirtFactory;
|
||||
private readonly ICollection<Eregister> eregisters;
|
||||
|
||||
public EregisterBatch(SIRTFactory broadcaster)
|
||||
{
|
||||
this.broadcaster = broadcaster;
|
||||
this.sirtFactory = broadcaster;
|
||||
this.eregisters = new List<Eregister>();
|
||||
}
|
||||
|
||||
@@ -26,10 +26,10 @@
|
||||
foreach (var parameters in parametersList)
|
||||
{
|
||||
var features = parameters.LoadCustomFeatures();
|
||||
var eregister = new Eregister(features, this.broadcaster.EnqueueTask);
|
||||
var eregister = new Eregister(features, this.sirtFactory.EnqueueTask);
|
||||
|
||||
this.broadcaster.DequeueTasks(features.RequestAddress);
|
||||
this.broadcaster.DequeueTasks(features.ResponseAddress);
|
||||
this.sirtFactory.DequeueTasks(features.RequestAddress);
|
||||
this.sirtFactory.DequeueTasks(features.ResponseAddress);
|
||||
this.eregisters.Add(eregister);
|
||||
|
||||
yield return eregister.LoadCustomTasks(parameters);
|
||||
@@ -43,10 +43,10 @@
|
||||
foreach (var parameters in parametersList)
|
||||
{
|
||||
var features = parameters.LoadInspectionFinalizationFeatures();
|
||||
var eregister = new Eregister(features, this.broadcaster.EnqueueTask);
|
||||
var eregister = new Eregister(features, this.sirtFactory.EnqueueTask);
|
||||
|
||||
this.broadcaster.DequeueTasks(features.RequestAddress);
|
||||
this.broadcaster.DequeueTasks(features.ResponseAddress);
|
||||
this.sirtFactory.DequeueTasks(features.RequestAddress);
|
||||
this.sirtFactory.DequeueTasks(features.ResponseAddress);
|
||||
this.eregisters.Add(eregister);
|
||||
|
||||
yield return eregister.LoadInspectionFinalizationTasks(parameters);
|
||||
@@ -60,10 +60,10 @@
|
||||
foreach (var parameters in parametersList)
|
||||
{
|
||||
var features = parameters.LoadInspectionInitializationFeatures();
|
||||
var eregister = new Eregister(features, this.broadcaster.EnqueueTask);
|
||||
var eregister = new Eregister(features, this.sirtFactory.EnqueueTask);
|
||||
|
||||
this.broadcaster.DequeueTasks(features.RequestAddress);
|
||||
this.broadcaster.DequeueTasks(features.ResponseAddress);
|
||||
this.sirtFactory.DequeueTasks(features.RequestAddress);
|
||||
this.sirtFactory.DequeueTasks(features.ResponseAddress);
|
||||
this.eregisters.Add(eregister);
|
||||
|
||||
yield return eregister.LoadInspectionInitializationTasks(parameters);
|
||||
@@ -86,7 +86,7 @@
|
||||
{
|
||||
foreach (var eregister in this.eregisters)
|
||||
{
|
||||
this.broadcaster.DequeueTasks(eregister.Address);
|
||||
this.sirtFactory.DequeueTasks(eregister.Address);
|
||||
|
||||
eregister.Clear();
|
||||
}
|
||||
|
||||
+21
-5
@@ -2,8 +2,10 @@
|
||||
{
|
||||
using Common.Hardware.Ports;
|
||||
using Common.Hardware.SIRT;
|
||||
using Common.Hardware.WaterMeter.eRegister.Attributes;
|
||||
using Common.Hardware.WaterMeter.eRegister.Features;
|
||||
using Common.Hardware.WaterMeter.eRegister.Models;
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
@@ -20,7 +22,8 @@
|
||||
this.requestParameters = requestParameters;
|
||||
this.pendingState = SIRTTaskState.Completed;
|
||||
this.Name = "Final Check";
|
||||
this.Data = new RequestDebugTelegram();
|
||||
this.Data = new OpticalTelegram { Minutes = 0 }
|
||||
.Append(new ProvidePin { AuthLevel = AuthLevel.III });
|
||||
}
|
||||
|
||||
protected override void EndProcessResponse(SIRTMessage response)
|
||||
@@ -43,14 +46,27 @@
|
||||
|
||||
foreach (var property in comparebleProperties)
|
||||
{
|
||||
var requestValue = property.GetValue(this.requestParameters);
|
||||
var responseValue = property.GetValue(responseParameters);
|
||||
var requestValue = $"{property.GetValue(this.requestParameters)}"
|
||||
.ToString()
|
||||
.Trim('\0')
|
||||
.Trim();
|
||||
var responseValue = $"{property.GetValue(responseParameters)}"
|
||||
.ToString()
|
||||
.Trim('\0')
|
||||
.Trim();
|
||||
|
||||
if ($"{requestValue}".Trim('\0').Trim() != $"{responseValue}".Trim('\0').Trim())
|
||||
if (requestValue != responseValue)
|
||||
{
|
||||
errors += $"- {property.Name}: request value {requestValue} != response value {responseValue}{Environment.NewLine}";
|
||||
}
|
||||
}
|
||||
|
||||
var volumeDifference = Math.Abs((int)this.requestParameters.DisplayVolume - (int)responseParameters.DisplayVolume);
|
||||
|
||||
if (volumeDifference > 10)
|
||||
{
|
||||
errors += $"- {nameof(this.requestParameters.DisplayVolume)}: request value {this.requestParameters.DisplayVolume} != response value {responseParameters.DisplayVolume}{Environment.NewLine}";
|
||||
}
|
||||
}
|
||||
|
||||
if (errors.Length > 0)
|
||||
@@ -97,7 +113,7 @@
|
||||
OffsetFactor = (byte)this.DEBUG.OffsetFactor, // TODO: normalize debug or parameter value
|
||||
OffsetTime = this.DEBUG.OffsetTime,
|
||||
FactoryCalibration = (byte)(this.DEBUG.FactoryCalibration * 10), // TODO: normalize debug or parameter value
|
||||
UnitsOfMessure = (byte)this.SEMI.Units, // TODO: normalize debug or parameter value
|
||||
UnitsOfMessureSEMI = (byte)this.SEMI.Units, // TODO: normalize debug or parameter value
|
||||
MeterSize = this.SEMI.MeterSize,
|
||||
Alarm_Backflow = alarms.Backflow,
|
||||
Alarm_Broken_Pipe = alarms.BrokenPipe,
|
||||
|
||||
+5
-5
@@ -18,11 +18,9 @@
|
||||
{
|
||||
this.parameters = parameters;
|
||||
this.pendingState = SIRTTaskState.Completed;
|
||||
this.Name = "Programming Check";
|
||||
this.Data = new OpticalTelegram
|
||||
{
|
||||
Minutes = 1
|
||||
};
|
||||
this.Name = "Initial Check";
|
||||
this.Data = new OpticalTelegram { Minutes = 0, } // parameters.LED_On_Minutes }
|
||||
.Append(new ProvidePin { AuthLevel = AuthLevel.III });
|
||||
}
|
||||
|
||||
protected override void EndProcessResponse(SIRTMessage response)
|
||||
@@ -32,6 +30,7 @@
|
||||
if (this.State == this.pendingState)
|
||||
{
|
||||
this.State = SIRTTaskState.Running;
|
||||
this.Name = "Initial Check - ✓";
|
||||
|
||||
var message = new StringBuilder();
|
||||
message.AppendLine();
|
||||
@@ -113,6 +112,7 @@
|
||||
{
|
||||
Minutes = 0
|
||||
};
|
||||
this.Name = "Initial Check ✘";
|
||||
|
||||
this.NotifyTimeouted();
|
||||
}
|
||||
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
namespace Common.Hardware.WaterMeter.eRegister
|
||||
{
|
||||
using Common.Hardware.SIRT;
|
||||
using Common.Hardware.SIRT.Parameters;
|
||||
using Common.Hardware.WaterMeter.eRegister.Telegrams;
|
||||
|
||||
public class EregisterCheckStateTask : EregisterTask
|
||||
{
|
||||
public EregisterCheckStateTask(int frequency)
|
||||
: base(frequency)
|
||||
=> this.Name = "Check State";
|
||||
|
||||
protected override void ProcessResponse(SIRTMessage response)
|
||||
{
|
||||
base.ProcessResponse(response);
|
||||
|
||||
if (this.SEMI != null)
|
||||
{
|
||||
var isEncrypted = this.IsEncrypted;
|
||||
this.IsEncrypted = this.SEMI.PAMStatus == PAMStatus.OK && this.SEMI.Crc != 0;
|
||||
|
||||
if (this.IsEncrypted != isEncrypted)
|
||||
{
|
||||
var data = response.Data.DecryptResponse(this.EncryptionKey);
|
||||
this.SEMI = new SEMI(data, this.Frequency, response.P1);
|
||||
this.Label = this.SEMI.PAMStatus.ToString();
|
||||
|
||||
this.NotifyTelegram(this.SEMI);
|
||||
this.NotifyUpdated();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+87
@@ -114,6 +114,93 @@
|
||||
});
|
||||
}
|
||||
|
||||
public static IEnumerable<KeyValuePair<string, byte[]>> BuildPamsFull(this EregisterFeatures eregister)
|
||||
{
|
||||
var pamList = new List<KeyValuePair<string, byte[]>>();
|
||||
var debugList = new List<KeyValuePair<string, byte[]>>();
|
||||
var pamNames = new Dictionary<byte, string>();
|
||||
var pamAttribute = default(PamAttribute);
|
||||
var cmd = default(byte);
|
||||
var bytes = default(byte[]);
|
||||
var value = default(object);
|
||||
|
||||
foreach (var field in typeof(Pam).GetFields(BindingFlags.Public | BindingFlags.Static))
|
||||
{
|
||||
value = field.GetValue(null);
|
||||
|
||||
if (value is byte cmdByte)
|
||||
{
|
||||
pamNames[cmdByte] = field.Name;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var eregisterProperty in typeof(EregisterFeatures).GetProperties())
|
||||
{
|
||||
pamAttribute = eregisterProperty.GetCustomAttribute<PamAttribute>();
|
||||
|
||||
if (pamAttribute is null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
value = eregisterProperty.GetValue(eregister);
|
||||
|
||||
if (value is null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (eregisterProperty.Name == nameof(eregister.Debug))
|
||||
{
|
||||
var debugValue = default(object);
|
||||
|
||||
foreach (var debugProperty in typeof(EregisterDebugFeatures).GetProperties())
|
||||
{
|
||||
debugValue = debugProperty.GetValue(value);
|
||||
|
||||
if (debugValue is null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (debugValue is Pam pam)
|
||||
{
|
||||
pam.Append(new ProvidePin { AuthLevel = pamAttribute.AuthLevel });
|
||||
bytes = pam.ToByteArray();
|
||||
cmd = bytes[0];
|
||||
|
||||
if (pamNames.TryGetValue(cmd, out var name))
|
||||
{
|
||||
debugList.Add(new KeyValuePair<string, byte[]>($"{cmd} - {debugProperty.Name}", bytes));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (value is Pam pam)
|
||||
{
|
||||
pam.Append(new ProvidePin { AuthLevel = pamAttribute.AuthLevel });
|
||||
bytes = pam.ToByteArray();
|
||||
cmd = bytes[0];
|
||||
|
||||
if (pamNames.TryGetValue(cmd, out var name))
|
||||
{
|
||||
pamList.Add(new KeyValuePair<string, byte[]>($"{cmd} - {eregisterProperty.Name}", bytes));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var sortedPams = pamList
|
||||
.OrderBy(x => x.Value[0])
|
||||
.ToList();
|
||||
var sortedDebugs = debugList
|
||||
.OrderByDescending(x => x.Value[2])
|
||||
.ToList();
|
||||
|
||||
sortedPams.AddRange(sortedDebugs);
|
||||
|
||||
return sortedPams;
|
||||
}
|
||||
|
||||
public static byte[] AuthBytes(this AuthLevel authLevel)
|
||||
{
|
||||
var bytes = new byte[] { };
|
||||
|
||||
+90
-23
@@ -1,8 +1,9 @@
|
||||
namespace Common.Hardware.WaterMeter.eRegister
|
||||
{
|
||||
using Common.Hardware.Ports;
|
||||
using Common.Hardware.SIRT;
|
||||
using Common.Hardware.SIRT.Parameters;
|
||||
using Common.Hardware.WaterMeter.eRegister.Features;
|
||||
using Common.Hardware.WaterMeter.eRegister.Models;
|
||||
using Common.Hardware.WaterMeter.eRegister.Telegrams;
|
||||
|
||||
using System;
|
||||
@@ -10,11 +11,16 @@
|
||||
|
||||
public class EregisterTask : SIRTTask
|
||||
{
|
||||
public EregisterTask(int frequency, int timeout = 5_000)
|
||||
: base(frequency, timeout)
|
||||
=> this.Cmd = SIRTMessage.W_PAM;
|
||||
public EregisterTask(int frequency, int timeout = 6_000)
|
||||
: base(frequency, timeout)
|
||||
{
|
||||
this.Cmd = SIRTMessage.W_PAM;
|
||||
this.RSSI = new RSSI(0, frequency);
|
||||
this.Label = nameof(SIRTTaskState.Pending);
|
||||
}
|
||||
|
||||
public event Action<EregisterTask> Changed;
|
||||
public event Action<object> Telegram;
|
||||
|
||||
public int SlotNr { get; internal set; }
|
||||
|
||||
@@ -40,17 +46,40 @@
|
||||
|
||||
public DEBUG DEBUG { get; private set; }
|
||||
|
||||
public SEMI SEMI { get; private set; }
|
||||
public SEMI SEMI { get; protected set; }
|
||||
|
||||
public bool IsEncrypted { get; set; }
|
||||
|
||||
public byte[] EncryptionKey { get; set; }
|
||||
|
||||
public StateModes Mode { get; set; }
|
||||
|
||||
public override void UpdateFrom(SIRTTask task)
|
||||
{
|
||||
base.UpdateFrom(task);
|
||||
|
||||
if (task is EregisterTask etask)
|
||||
{
|
||||
this.Mode = etask.Mode;
|
||||
this.IsEncrypted = etask.IsEncrypted;
|
||||
|
||||
if (this.Mode == StateModes.Shipment)
|
||||
{
|
||||
this.Data = new EregisterAvailableParametersParser(this.Data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
var data = this.request.Data;
|
||||
|
||||
if (this.IsEncrypted)
|
||||
// if (this.SEMI?.PAMStatus?.WRONG_AUTH == true || this.Mode == StateModes.Shipment)
|
||||
{
|
||||
data = new EregisterAvailableParametersParser(data);
|
||||
}
|
||||
|
||||
if (this.IsEncrypted || this.Mode == StateModes.Shipment)
|
||||
{
|
||||
data = data.EncryptRequest(this.EncryptionKey, this.RequestAddress);
|
||||
}
|
||||
@@ -88,21 +117,11 @@
|
||||
var dataLength = data?.Length ?? 0;
|
||||
|
||||
this.P11 = new P11(response.P1);
|
||||
this.RSSI = SEMI.CalculateRSSI(response.P2, (ushort)this.Frequency);
|
||||
this.RSSI = new RSSI(response.P2, (ushort)this.Frequency);
|
||||
|
||||
if (dataLength > 0)
|
||||
{
|
||||
var type = data[0];
|
||||
var crc = data.ToInt16BE(dataLength - 2);
|
||||
|
||||
if (!this.IsEncrypted)
|
||||
{
|
||||
this.IsEncrypted = (type <= SIRTMessage.LAT && crc != 0)
|
||||
|| (type == SIRTMessage.DEBUG && dataLength >= 53)
|
||||
|| (type == SIRTMessage.SEMI && dataLength >= 93);
|
||||
|
||||
this.NotifyUpdated();
|
||||
}
|
||||
|
||||
if (this.IsEncrypted)
|
||||
{
|
||||
@@ -113,26 +132,30 @@
|
||||
{
|
||||
this.Label = nameof(SIRTMessage.BUP);
|
||||
this.BUP = new BUP(data, this.P11);
|
||||
this.NotifyTelegram(this.BUP);
|
||||
}
|
||||
else if (type == SIRTMessage.LAT)
|
||||
{
|
||||
this.Label = nameof(SIRTMessage.LAT);
|
||||
this.LAT = new LAT(data, this.P11);
|
||||
this.NotifyTelegram(this.LAT);
|
||||
}
|
||||
else if (type == SIRTMessage.DEBUG)
|
||||
{
|
||||
this.Label = nameof(SIRTMessage.DEBUG);
|
||||
this.DEBUG = new DEBUG(data, this.P11);
|
||||
this.NotifyTelegram(this.DEBUG);
|
||||
|
||||
this.Mode = (StateModes)(this.DEBUG.FactoryState - 1);
|
||||
this.IsEncrypted = this.Mode == StateModes.Shipment;
|
||||
this.NotifyUpdated();
|
||||
}
|
||||
else if (type == SIRTMessage.SEMI)
|
||||
{
|
||||
this.SEMI = new SEMI(data, this.Frequency, this.P11);
|
||||
this.Label = this.SEMI.PAMStatus.ToString();
|
||||
this.ProcessSEMI(data);
|
||||
|
||||
if (this.SEMI.PAMStatus == PAMStatus.OK)
|
||||
if (this.State == SIRTTaskState.Completed || this.State == SIRTTaskState.Cancelled)
|
||||
{
|
||||
this.State = SIRTTaskState.Completed;
|
||||
|
||||
this.EndProcessResponse(response);
|
||||
}
|
||||
}
|
||||
@@ -152,10 +175,54 @@
|
||||
this.Label = "NA";
|
||||
}
|
||||
|
||||
this.Changed?.Invoke(this);
|
||||
this.NotifyChanged();
|
||||
}
|
||||
|
||||
protected virtual void EndProcessResponse(SIRTMessage response)
|
||||
=> base.ProcessResponse(response);
|
||||
|
||||
protected void NotifyChanged() => this.Changed?.Invoke(this);
|
||||
|
||||
protected void NotifyTelegram(object value) => this.Telegram?.Invoke(value);
|
||||
|
||||
private void ProcessSEMI(byte[] data)
|
||||
{
|
||||
this.SEMI = new SEMI(data, this.Frequency, this.P11);
|
||||
|
||||
if (this.SEMI.PAMStatus == PAMStatus.OK)
|
||||
{
|
||||
this.State = SIRTTaskState.Completed;
|
||||
this.Label = this.SEMI.PAMStatus.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
var isEncrypted = this.IsEncrypted;
|
||||
this.IsEncrypted = this.SEMI.Crc != 0;
|
||||
|
||||
if (this.IsEncrypted != isEncrypted)
|
||||
{
|
||||
data = data.DecryptResponse(this.EncryptionKey);
|
||||
}
|
||||
|
||||
this.SEMI = new SEMI(data, this.Frequency, this.P11);
|
||||
|
||||
if (this.SEMI.PAMStatus == PAMStatus.OK)
|
||||
{
|
||||
this.State = SIRTTaskState.Completed;
|
||||
this.Label = this.SEMI.PAMStatus.ToString();
|
||||
}
|
||||
else if (this.SEMI.PAMStatus == PAMStatus.EXPIREDAUTH)
|
||||
{
|
||||
this.State = SIRTTaskState.Cancelled;
|
||||
this.Label = this.SEMI.PAMStatus.ToString();
|
||||
this.timeoutTimer.Stop();
|
||||
}
|
||||
|
||||
this.Label = this.SEMI.PAMStatus.ToString();
|
||||
}
|
||||
|
||||
this.NotifyTelegram(this.SEMI);
|
||||
this.NotifyUpdated();
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-1
@@ -3,10 +3,15 @@
|
||||
public enum MessurementUnits : byte
|
||||
{
|
||||
CubicMeters = 0,
|
||||
m3 = 19,
|
||||
CubicFeet = 1,
|
||||
CF = 35,
|
||||
USGallons = 4,
|
||||
GAL = 24,
|
||||
ImperialGallons = 5,
|
||||
IGAL = 144,
|
||||
AcreFeet = 6,
|
||||
Kiloliters = 7
|
||||
Kiloliters = 7,
|
||||
kl = 19,
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -5,14 +5,17 @@
|
||||
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
|
||||
public class PamAttribute : Attribute
|
||||
{
|
||||
public PamAttribute(AuthLevel authLevel, bool isSingleCmd = false)
|
||||
public PamAttribute(AuthLevel authLevel, bool isSingleCmd = false, bool onlyProductionMode = false)
|
||||
{
|
||||
this.AuthLevel = authLevel;
|
||||
this.IsSingleCmd = isSingleCmd;
|
||||
this.OnlyProductionMode = onlyProductionMode;
|
||||
}
|
||||
|
||||
public AuthLevel AuthLevel { get; }
|
||||
|
||||
public bool IsSingleCmd { get; }
|
||||
|
||||
public bool OnlyProductionMode { get; }
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@
|
||||
{
|
||||
var bytes = BitConverter.GetBytes((UInt64)value);
|
||||
|
||||
Array.Copy(bytes, 0, this.bytes, 1, 5);
|
||||
Array.Copy(bytes, 1, this.bytes, 1, 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
namespace Common.Hardware.WaterMeter.eRegister.Models
|
||||
{
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
public class ComparePropertyAttribute : ValidationAttribute
|
||||
{
|
||||
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
|
||||
{
|
||||
return base.IsValid(value, validationContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
+125
@@ -0,0 +1,125 @@
|
||||
namespace Common.Hardware.WaterMeter.eRegister.Models
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class EregisterAvailableParametersParser : List<byte>
|
||||
{
|
||||
public EregisterAvailableParametersParser(byte[] bytes)
|
||||
{
|
||||
var bytesLength = bytes.Length;
|
||||
var available = default(bool);
|
||||
var cmdLength = default(int);
|
||||
var index = default(int);
|
||||
|
||||
while (bytesLength > index)
|
||||
{
|
||||
var cmd = bytes[index++];
|
||||
_ = EregisterAvailableParametersParser.cmdLengths.TryGetValue(cmd, out cmdLength);
|
||||
_ = cmdAvailableAfterSeal.TryGetValue(cmd, out available);
|
||||
|
||||
if (available)
|
||||
{
|
||||
this.Add(cmd);
|
||||
}
|
||||
|
||||
for (var i = 0; i < cmdLength; i++)
|
||||
{
|
||||
if (available)
|
||||
{
|
||||
this.Add(bytes[index]);
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static implicit operator byte[] (EregisterAvailableParametersParser parser) => parser.ToArray();
|
||||
|
||||
private static readonly IDictionary<byte, bool> cmdAvailableAfterSeal = new Dictionary<byte, bool>
|
||||
{
|
||||
{ 0, true },
|
||||
{ 1, false },
|
||||
{ 2, true },
|
||||
{ 3, false },
|
||||
{ 4, true },
|
||||
{ 5, true },
|
||||
{ 6, true },
|
||||
{ 7, true },
|
||||
{ 10, true },
|
||||
{ 11, true },
|
||||
{ 12, false },
|
||||
{ 14, true },
|
||||
{ 16, true },
|
||||
{ 17, true },
|
||||
{ 19, true },
|
||||
{ 20, true },
|
||||
{ 21, true },
|
||||
{ 22, false },
|
||||
{ 31, true },
|
||||
{ 32, true },
|
||||
{ 33, true },
|
||||
{ 48, false },
|
||||
{ 49, false },
|
||||
{ 50, true },
|
||||
{ 51, true },
|
||||
{ 52, true },
|
||||
{ 53, true },
|
||||
{ 54, false },
|
||||
{ 64, true },
|
||||
{ 65, true },
|
||||
{ 66, true },
|
||||
{ 67, true },
|
||||
{ 68, true },
|
||||
{ 69, true },
|
||||
{ 72, true },
|
||||
{ 73, true },
|
||||
{ 80, true },
|
||||
{ 108, true },
|
||||
{ 146, false },
|
||||
};
|
||||
|
||||
private static readonly IDictionary<byte, int> cmdLengths = new Dictionary<byte, int>
|
||||
{
|
||||
{ 0, 1 },
|
||||
{ 1, 1 },
|
||||
{ 2, 1 },
|
||||
{ 3, 1 },
|
||||
{ 4, 1 },
|
||||
{ 5, 1 },
|
||||
{ 6, 1 },
|
||||
{ 7, 1 },
|
||||
{ 10, 1 },
|
||||
{ 11, 1 },
|
||||
{ 12, 1 },
|
||||
{ 14, 1 },
|
||||
{ 16, 2 },
|
||||
{ 17, 2 },
|
||||
{ 19, 2 },
|
||||
{ 20, 2 },
|
||||
{ 21, 2 },
|
||||
{ 22, 2 },
|
||||
{ 31, 2 },
|
||||
{ 32, 3 },
|
||||
{ 33, 2 },
|
||||
{ 48, 4 },
|
||||
{ 49, 4 },
|
||||
{ 50, 4 },
|
||||
{ 51, 4 },
|
||||
{ 52, 4 },
|
||||
{ 53, 4 },
|
||||
{ 54, 4 },
|
||||
{ 64, 5 },
|
||||
{ 65, 5 },
|
||||
{ 66, 5 },
|
||||
{ 67, 5 },
|
||||
{ 68, 6 },
|
||||
{ 69, 6 },
|
||||
{ 72, 7 },
|
||||
{ 73, 7 },
|
||||
{ 80, 9 },
|
||||
{ 108, 16 },
|
||||
{ 146, 16 },
|
||||
};
|
||||
}
|
||||
}
|
||||
+16
-16
@@ -4,52 +4,52 @@
|
||||
|
||||
public class EregisterDebugFeatures
|
||||
{
|
||||
[Pam(AuthLevel.III, true)]
|
||||
[Pam(AuthLevel.III, isSingleCmd: true)]
|
||||
public RequestDebugTelegram RequestDebugTelegram { get; set; }
|
||||
|
||||
[Pam(AuthLevel.III, true)]
|
||||
[Pam(AuthLevel.III, isSingleCmd: true)]
|
||||
public ChangeState ChangeState { get; set; }
|
||||
|
||||
[Pam(AuthLevel.III, true)]
|
||||
[Pam(AuthLevel.III, isSingleCmd: true)]
|
||||
public ResetCredits ResetCredits { get; set; }
|
||||
|
||||
[Pam(AuthLevel.III, true)]
|
||||
[Pam(AuthLevel.III, isSingleCmd: true)]
|
||||
public DisableCredits DisableCredits { get; set; }
|
||||
|
||||
[Pam(AuthLevel.III, true)]
|
||||
[Pam(AuthLevel.III, isSingleCmd: true)]
|
||||
public SerialOutput SerialOutput { get; set; }
|
||||
|
||||
[Pam(AuthLevel.III, true)]
|
||||
[Pam(AuthLevel.III, isSingleCmd: true)]
|
||||
public SetAlarms SetAlarm { get; set; }
|
||||
|
||||
[Pam(AuthLevel.III, true)]
|
||||
[Pam(AuthLevel.III, isSingleCmd: true)]
|
||||
public SetSpecificError SetSpecificError { get; set; }
|
||||
|
||||
[Pam(AuthLevel.III, true)]
|
||||
[Pam(AuthLevel.III, isSingleCmd: true)]
|
||||
public OpticalTelegram OpticalTelegram { get; set; }
|
||||
|
||||
[Pam(AuthLevel.III, true)]
|
||||
[Pam(AuthLevel.III, isSingleCmd: true)]
|
||||
public FactoryComplete FactoryComplete { get; set; }
|
||||
|
||||
[Pam(AuthLevel.III, true)]
|
||||
[Pam(AuthLevel.III, isSingleCmd: true)]
|
||||
public EnableCredits EnableCredits { get; set; }
|
||||
|
||||
[Pam(AuthLevel.III, true)]
|
||||
[Pam(AuthLevel.III, isSingleCmd: true)]
|
||||
public SetBatteryUsageTestOffset SetBatteryUsageTestOffset { get; set; }
|
||||
|
||||
[Pam(AuthLevel.III, true)]
|
||||
[Pam(AuthLevel.III, isSingleCmd: true)]
|
||||
public SetTestFastActivityBupTiming SetTestFastActivityBupTiming { get; set; }
|
||||
|
||||
[Pam(AuthLevel.III, true)]
|
||||
[Pam(AuthLevel.III, isSingleCmd: true)]
|
||||
public SetActivityCreditLimits SetActivityCreditLimits { get; set; }
|
||||
|
||||
[Pam(AuthLevel.III, true)]
|
||||
[Pam(AuthLevel.III, isSingleCmd: true)]
|
||||
public SetActivationByThreshold SetActivationByThreshold { get; set; }
|
||||
|
||||
[Pam(AuthLevel.III, true)]
|
||||
[Pam(AuthLevel.III, isSingleCmd: true)]
|
||||
public DisableOTAFirmwareUpdate DisableOTAFirmwareUpdate { get; set; }
|
||||
|
||||
[Pam(AuthLevel.III, true)]
|
||||
[Pam(AuthLevel.III, isSingleCmd: true)]
|
||||
public SetMeterType SetMeterType { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
+24
-27
@@ -23,14 +23,11 @@
|
||||
[Pam(AuthLevel.II)]
|
||||
public ChangeWakeUp ChangeWakeUp { get; set; }
|
||||
|
||||
[Pam(AuthLevel.O)]
|
||||
public SetPowerLevel SetPowerLevelSensusRF0 { get; set; }
|
||||
|
||||
[Pam(AuthLevel.O)]
|
||||
public SetPowerLevel SetPowerLevelFlexNet0 { get; set; }
|
||||
[Pam(AuthLevel.O, onlyProductionMode: true)]
|
||||
public SetPowerLevel SetPowerLevelSensusRF { get; set; }
|
||||
|
||||
[Pam(AuthLevel.III)]
|
||||
public SetPowerLevel SetPowerLevelFlexNetIII { get; internal set; }
|
||||
public SetPowerLevel SetPowerLevelFlexNet { get; internal set; }
|
||||
|
||||
[Pam(AuthLevel.II)]
|
||||
public ChangeNumberOfLatWindows ChangeNumberOfLatWindows { get; set; }
|
||||
@@ -38,7 +35,7 @@
|
||||
[Pam(AuthLevel.I)]
|
||||
public ResetAlarms ResetAlarms { get; set; }
|
||||
|
||||
[Pam(AuthLevel.II, true)]
|
||||
[Pam(AuthLevel.II, isSingleCmd: true)]
|
||||
public DeactivateTransmitter DeactivateTransmiter { get; set; }
|
||||
|
||||
[Pam(AuthLevel.II)]
|
||||
@@ -59,7 +56,7 @@
|
||||
[Pam(AuthLevel.I)]
|
||||
public SetHistoricalErrorLimit SetHistoricalErrorLimit { get; set; }
|
||||
|
||||
[Pam(AuthLevel.III, true)]
|
||||
[Pam(AuthLevel.III, isSingleCmd: true)]
|
||||
public Reset Reset { get; set; }
|
||||
|
||||
[Pam(AuthLevel.II)]
|
||||
@@ -68,31 +65,31 @@
|
||||
[Pam(AuthLevel.II)]
|
||||
public OpenMeteringTransmitionIntervalWMBus OpenMeteringTransmitionIntervalWMBus { get; set; }
|
||||
|
||||
[Pam(AuthLevel.III, true)]
|
||||
[Pam(AuthLevel.III, isSingleCmd: true)]
|
||||
public SendBubbleUpBurst SendBubbleUpBurst { get; set; }
|
||||
|
||||
[Pam(AuthLevel.III, true)]
|
||||
[Pam(AuthLevel.III, isSingleCmd: true)]
|
||||
public SetFrequencyOffset SetFrequencyOffset { get; set; }
|
||||
|
||||
[Pam(AuthLevel.I)]
|
||||
public ActivateMetrologyTestMode ActivateMetrologyTestMode { get; set; }
|
||||
|
||||
[Pam(AuthLevel.III)]
|
||||
[Pam(AuthLevel.III, onlyProductionMode: true)]
|
||||
public SetRebootCount SetRebootCount { get; set; }
|
||||
|
||||
[Pam(AuthLevel.III, true)]
|
||||
[Pam(AuthLevel.III, isSingleCmd: true)]
|
||||
public EregisterDebugFeatures Debug { get; set; }
|
||||
|
||||
[Pam(AuthLevel.O)]
|
||||
public ChangeFixedDateReadingSettings ChangeFixedDateReadingSettings { get; set; }
|
||||
|
||||
[Pam(AuthLevel.II, true)]
|
||||
[Pam(AuthLevel.II, isSingleCmd: true)]
|
||||
public GetCustomerDebug GetCustomerDebug { get; set; }
|
||||
|
||||
[Pam(AuthLevel.III)]
|
||||
[Pam(AuthLevel.III, onlyProductionMode: true)]
|
||||
public ChangeMeterReading ChangeMeterReading { get; set; }
|
||||
|
||||
[Pam(AuthLevel.III)]
|
||||
[Pam(AuthLevel.III, onlyProductionMode: true)]
|
||||
public ChangeMeterId ChangeMeterId { get; set; }
|
||||
|
||||
[Pam(AuthLevel.I)]
|
||||
@@ -107,37 +104,37 @@
|
||||
[Pam(AuthLevel.III)]
|
||||
public ChangeRadioId ChangeRadioId { get; set; }
|
||||
|
||||
[Pam(AuthLevel.III)]
|
||||
[Pam(AuthLevel.III, onlyProductionMode: true)]
|
||||
public SetPcbId SetPcbId { get; set; }
|
||||
|
||||
[Pam(AuthLevel.O, true)]
|
||||
[Pam(AuthLevel.O, isSingleCmd: true)]
|
||||
public RequestFixedDateReading RequestFixedDateReading { get; set; }
|
||||
|
||||
[Pam(AuthLevel.O, true)]
|
||||
[Pam(AuthLevel.O, isSingleCmd: true)]
|
||||
public RequestLoggingData RequestLoggingData { get; set; }
|
||||
|
||||
[Pam(AuthLevel.I, true)]
|
||||
[Pam(AuthLevel.I, isSingleCmd: true)]
|
||||
public ChangePin ChangePinI { get; set; }
|
||||
|
||||
[Pam(AuthLevel.II, true)]
|
||||
[Pam(AuthLevel.II, isSingleCmd: true)]
|
||||
public ChangePin ChangePinII { get; set; }
|
||||
|
||||
[Pam(AuthLevel.III, true)]
|
||||
[Pam(AuthLevel.III, isSingleCmd: true)]
|
||||
public ChangePin ChangePinIII { get; set; }
|
||||
|
||||
[Pam(AuthLevel.O)]
|
||||
public ProvidePin ProvidePin { get; set; }
|
||||
|
||||
[Pam(AuthLevel.III, true)]
|
||||
[Pam(AuthLevel.III, isSingleCmd: true)]
|
||||
public SendTestPattern SendTestPattern { get; set; }
|
||||
|
||||
[Pam(AuthLevel.III, true)]
|
||||
[Pam(AuthLevel.III, isSingleCmd: true)]
|
||||
public RequestMemoryDump RequestMemoryDump { get; set; }
|
||||
|
||||
[Pam(AuthLevel.III, true)]
|
||||
[Pam(AuthLevel.III, isSingleCmd: true)]
|
||||
public SendSequenceOfTestTelegrams SendSequenceOfTestTelegrams { get; set; }
|
||||
|
||||
[Pam(AuthLevel.III, true)]
|
||||
[Pam(AuthLevel.III, isSingleCmd: true)]
|
||||
public ReceiveSequenceOfTestTelegrams ReceiveSequenceOfTestTelegrams { get; set; }
|
||||
|
||||
[Pam(AuthLevel.II)]
|
||||
@@ -152,10 +149,10 @@
|
||||
[Pam(AuthLevel.O)]
|
||||
public SetTFXParameters SetTFXParameters { get; set; }
|
||||
|
||||
[Pam(AuthLevel.III, true)]
|
||||
[Pam(AuthLevel.III, isSingleCmd: true, onlyProductionMode: true)]
|
||||
public SetMetrologyParameters SetMetrologyParameters { get; set; }
|
||||
|
||||
[Pam(AuthLevel.O, true)]
|
||||
[Pam(AuthLevel.O, isSingleCmd: true)]
|
||||
public Ping Ping { get; set; }
|
||||
|
||||
[Pam(AuthLevel.III)]
|
||||
|
||||
+81
-80
@@ -1,6 +1,7 @@
|
||||
namespace Common.Hardware.WaterMeter.eRegister.Models
|
||||
{
|
||||
using Common.Hardware.Ports;
|
||||
using Common.Hardware.WaterMeter.eRegister.Attributes;
|
||||
using Common.Hardware.WaterMeter.eRegister.Features;
|
||||
using Common.Hardware.WaterMeter.eRegister.Telegrams;
|
||||
|
||||
@@ -69,9 +70,11 @@
|
||||
|
||||
[CompareProperty]
|
||||
public byte LATWindowsFinalization { get; set; }
|
||||
|
||||
public byte UnitsOfMessure { get; set; }
|
||||
|
||||
[CompareProperty]
|
||||
public byte UnitsOfMessure { get; set; }
|
||||
public byte UnitsOfMessureSEMI { get; set; }
|
||||
|
||||
public byte DecimalPoint { get; set; }
|
||||
|
||||
@@ -209,8 +212,7 @@
|
||||
public float UTC_Offset { get; set; }
|
||||
|
||||
public byte Wake_Up_Interval { get; set; }
|
||||
|
||||
[CompareProperty]
|
||||
|
||||
public uint DisplayVolume { get; set; }
|
||||
|
||||
public bool Encrypted { get; set; }
|
||||
@@ -232,42 +234,43 @@
|
||||
[CompareProperty]
|
||||
public string CustomerSpecificText { get; set; }
|
||||
|
||||
internal EregisterFeatures LoadCustomFeatures()
|
||||
=> new EregisterFeatures
|
||||
public bool Sealed { get; set; }
|
||||
|
||||
public uint RequestAddress => (uint)(this.TempAdresse % 10_000_000_000);
|
||||
|
||||
public uint ResponseAddress => (uint)(this.Adresse % 10_000_000_000);
|
||||
|
||||
internal EregisterFeatures LoadCustomFeatures()
|
||||
{
|
||||
var features = new EregisterFeatures
|
||||
{
|
||||
SlotNr = this.Slotno,
|
||||
SerialNr = this.SerienNr,
|
||||
PoNr = this.FertigungsauftragNr,
|
||||
RequestAddress = (uint)(this.TempAdresse % 10_000_000_000),
|
||||
ResponseAddress = (uint)(this.Adresse % 10_000_000_000),
|
||||
RequestAddress = this.RequestAddress,
|
||||
ResponseAddress = this.ResponseAddress,
|
||||
Frequency = this.Frequency,
|
||||
Sealed = this.Encrypted,
|
||||
EncryptionKey = this.EncryptionKey.GetEncryptionKey(),
|
||||
ActivateMetrologyTestMode = new ActivateMetrologyTestMode
|
||||
//ChangeWakeUp = new ChangeWakeUp
|
||||
//{
|
||||
// WakeUpMode = WakeUpMode.StayAwake
|
||||
//},
|
||||
//ChangeNumberOfLatWindows = new ChangeNumberOfLatWindows
|
||||
//{
|
||||
// N = 1
|
||||
//},
|
||||
//ChangeTransmissionInterval = new ChangeTransmissionInterval
|
||||
//{
|
||||
// Seconds = 1
|
||||
//}
|
||||
ChangeRadioId = new ChangeRadioId
|
||||
{
|
||||
Mode = 0
|
||||
},
|
||||
Reset = new Reset
|
||||
{
|
||||
Mode = 0
|
||||
},
|
||||
Debug = new EregisterDebugFeatures
|
||||
{
|
||||
RequestDebugTelegram = new RequestDebugTelegram
|
||||
{
|
||||
|
||||
},
|
||||
ChangeState = new ChangeState
|
||||
{
|
||||
Mode = StateModes.Production
|
||||
},
|
||||
OpticalTelegram = new OpticalTelegram
|
||||
{
|
||||
Minutes = 1
|
||||
}
|
||||
Address = this.ResponseAddress
|
||||
}
|
||||
};
|
||||
|
||||
return features;
|
||||
}
|
||||
|
||||
internal EregisterFeatures LoadInspectionFinalizationFeatures()
|
||||
{
|
||||
@@ -276,10 +279,9 @@
|
||||
SlotNr = this.Slotno,
|
||||
SerialNr = this.SerienNr,
|
||||
PoNr = this.FertigungsauftragNr,
|
||||
RequestAddress = (uint)(this.TempAdresse % 10_000_000_000),
|
||||
ResponseAddress = (uint)(this.Adresse % 10_000_000_000),
|
||||
RequestAddress = this.RequestAddress,
|
||||
ResponseAddress = this.ResponseAddress,
|
||||
Frequency = this.Frequency,
|
||||
Sealed = this.Encrypted,
|
||||
EncryptionKey = this.EncryptionKey.GetEncryptionKey(),
|
||||
};
|
||||
|
||||
@@ -288,21 +290,33 @@
|
||||
return features;
|
||||
}
|
||||
|
||||
features.ChangeRadioId = new ChangeRadioId(this.ResponseAddress);
|
||||
features.ChangeMeterId = new ChangeMeterId(this.MeterId);
|
||||
features.ChangeMeterReading = new ChangeMeterReading((uint)this.DisplayVolume);
|
||||
features.SetPowerLevelSensusRF0 = new SetPowerLevel
|
||||
features.ChangeMeterReading = new ChangeMeterReading(this.DisplayVolume);
|
||||
features.SetPowerLevelSensusRF = new SetPowerLevel
|
||||
{
|
||||
Value = (byte)(this.PowerLevelHex & 127)
|
||||
};
|
||||
features.SetPowerLevelFlexNet0 = new SetPowerLevel
|
||||
features.SetPowerLevelFlexNet = new SetPowerLevel
|
||||
{
|
||||
Value = (byte)(this.PowerLevelHex | 128)
|
||||
};
|
||||
features.SetPowerLevelFlexNetIII = new SetPowerLevel
|
||||
features.Debug = new EregisterDebugFeatures
|
||||
{
|
||||
Value = (byte)(this.PowerLevelHex | 128)
|
||||
DisableOTAFirmwareUpdate = new DisableOTAFirmwareUpdate
|
||||
{
|
||||
Mode = (OTAMode)this.DisableOTA
|
||||
},
|
||||
SetActivationByThreshold = new SetActivationByThreshold
|
||||
{
|
||||
Rotations = this.ActivationByThreshold
|
||||
},
|
||||
ChangeState = new ChangeState
|
||||
{
|
||||
Mode = StateModes.Shipment
|
||||
}
|
||||
};
|
||||
features.ChangeRadioId = new ChangeRadioId((uint)(this.Adresse % 10_000_000_000));
|
||||
|
||||
features.DeactivateAlarms = new DeactivateAlarms
|
||||
{
|
||||
Backflow = this.Alarm_Backflow,
|
||||
@@ -315,7 +329,10 @@
|
||||
SpecificError = this.Alarm_Specific_Error,
|
||||
};
|
||||
features.ResetAlarms = new ResetAlarms(0xFF);
|
||||
features.ChangeCustomerText = new ChangeCustomerText();
|
||||
features.ChangeCustomerText = new ChangeCustomerText
|
||||
{
|
||||
Text = this.CustomerSpecificText
|
||||
};
|
||||
features.ParameterizeLeakageDetection = new ParameterizeLeakageDetection
|
||||
{
|
||||
Value = (byte)(this.LeakagePeriod | (this.LeakageThreshold * (byte)Math.Pow(2, 3)))
|
||||
@@ -370,21 +387,6 @@
|
||||
}
|
||||
};
|
||||
features.WirelessMBusMode = new WirelessMBusMode(this.MBusStatus);
|
||||
features.Debug = new EregisterDebugFeatures
|
||||
{
|
||||
DisableOTAFirmwareUpdate = new DisableOTAFirmwareUpdate
|
||||
{
|
||||
Mode = (OTAMode)this.DisableOTA
|
||||
},
|
||||
//SetActivationByThreshold = new SetActivationByThreshold
|
||||
//{
|
||||
// Rotations = this.ActivationByThreshold
|
||||
//},
|
||||
//ChangeState = new ChangeState
|
||||
//{
|
||||
// Mode = StateModes.Shipment
|
||||
//}
|
||||
};
|
||||
features.OpenMeteringTransmitionIntervalWMBus = new OpenMeteringTransmitionIntervalWMBus
|
||||
{
|
||||
Seconds = this.OpenMeteringTransmissionIntervalSeconds
|
||||
@@ -407,41 +409,40 @@
|
||||
|
||||
internal EregisterFeatures LoadInspectionInitializationFeatures()
|
||||
{
|
||||
var address = (uint)(this.Adresse % 10_000_000_000);
|
||||
var tempAddress = (uint)(this.TempAdresse % 10_000_000_000);
|
||||
var features = new EregisterFeatures
|
||||
{
|
||||
SlotNr = this.Slotno,
|
||||
SerialNr = this.SerienNr,
|
||||
PoNr = this.FertigungsauftragNr,
|
||||
RequestAddress = tempAddress,
|
||||
ResponseAddress = address,
|
||||
RequestAddress = this.RequestAddress,
|
||||
ResponseAddress = this.ResponseAddress,
|
||||
Frequency = this.Frequency,
|
||||
EncryptionKey = this.EncryptionKey.GetEncryptionKey(),
|
||||
ChangeWakeUp = new ChangeWakeUp(WakeUpMode.StayAwake),
|
||||
ChangeTransmissionInterval = new ChangeTransmissionInterval(this.TransmissionIntervalInitialization),
|
||||
ChangeNumberOfLatWindows = new ChangeNumberOfLatWindows(this.LatWindowsInitialization),
|
||||
WirelessMBusMode = new WirelessMBusMode(this.MBusStatus),
|
||||
ChangeMeterReading = new ChangeMeterReading(111111111),
|
||||
SetMetrologyParameters = new SetMetrologyParameters
|
||||
};
|
||||
|
||||
features.ChangeWakeUp = new ChangeWakeUp(WakeUpMode.StayAwake);
|
||||
features.ChangeTransmissionInterval = new ChangeTransmissionInterval(this.TransmissionIntervalInitialization);
|
||||
features.ChangeNumberOfLatWindows = new ChangeNumberOfLatWindows(this.LatWindowsInitialization);
|
||||
features.WirelessMBusMode = new WirelessMBusMode(this.MBusStatus);
|
||||
features.ChangeMeterReading = new ChangeMeterReading(111111111);
|
||||
features.SetMetrologyParameters = new SetMetrologyParameters
|
||||
{
|
||||
UseCandIRules = this.Use_CandI_Rules == 1,
|
||||
DecimalPoint = (DecimalPointLocations)this.DecimalPoint,
|
||||
FactoryCalibration = this.FactoryCalibration,
|
||||
MeterSize = this.MeterSize,
|
||||
OffsetFactor = this.OffsetFactor,
|
||||
OffsetTime = this.OffsetTime,
|
||||
Units = (MessurementUnits)this.UnitsOfMessure,
|
||||
Vpp = this.VolumePerPulse,
|
||||
VppLED = (uint)this.VolumePerLedPulse
|
||||
};
|
||||
features.Debug = new EregisterDebugFeatures
|
||||
{
|
||||
SetMeterType = new SetMeterType
|
||||
{
|
||||
UseCandIRules = this.Use_CandI_Rules == 1,
|
||||
DecimalPoint = (DecimalPointLocations)this.DecimalPoint,
|
||||
FactoryCalibration = this.FactoryCalibration,
|
||||
MeterSize = this.MeterSize,
|
||||
OffsetFactor = this.OffsetFactor,
|
||||
OffsetTime = this.OffsetTime,
|
||||
Units = (MessurementUnits)this.UnitsOfMessure,
|
||||
Vpp = this.VolumePerPulse,
|
||||
VppLED = (uint)this.VolumePerLedPulse
|
||||
Type = (MeterTypes)this.Use_CandI_Rules
|
||||
},
|
||||
Debug = new EregisterDebugFeatures
|
||||
{
|
||||
SetMeterType = new SetMeterType
|
||||
{
|
||||
Type = (MeterTypes)this.Use_CandI_Rules
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return features;
|
||||
|
||||
+1
-1
@@ -6,6 +6,6 @@
|
||||
m3 = 19,
|
||||
CF = 35,
|
||||
GAL = 24,
|
||||
IGAL = 144
|
||||
IGAL = 144,
|
||||
}
|
||||
}
|
||||
|
||||
+2
-9
@@ -12,7 +12,7 @@
|
||||
public SEMI(byte[] payload, int mhz, P11 p11) : base(payload, p11)
|
||||
{
|
||||
this.PAMStatus = new PAMStatus(payload[11]);
|
||||
this.RSSI = CalculateRSSI(payload[12], mhz);
|
||||
this.RSSI = new RSSI(payload[12], mhz);
|
||||
this.MeterType = payload[13];
|
||||
this.TransmissionInterval = payload.ToUInt16BE(14);
|
||||
this.LATInterval = payload[16];
|
||||
@@ -65,7 +65,7 @@
|
||||
|
||||
public PAMStatus PAMStatus { get; }
|
||||
|
||||
public string RSSI { get; }
|
||||
public RSSI RSSI { get; }
|
||||
|
||||
public byte MeterType { get; }
|
||||
|
||||
@@ -142,12 +142,5 @@
|
||||
public ushort TimeOfLogReset { get; }
|
||||
|
||||
public byte MeterSize { get; }
|
||||
|
||||
public static string CalculateRSSI(byte value, int mhz)
|
||||
{
|
||||
var rssi = new RSSI(value, mhz);
|
||||
|
||||
return $"{rssi.Dbm:0}dBm ({rssi.Percent:0.0}%)";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user