|
@@ -1,10 +1,13 @@
|
|
|
using RTCommunicatorBase;
|
|
|
+using System;
|
|
|
using System.Collections.Concurrent;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.IO;
|
|
|
using System.Text;
|
|
|
using System.Threading;
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
-using TLVProtocal;
|
|
|
+using TLVProtocal;
|
|
|
using UniversalNetFrame451;
|
|
|
using UniversalNetFrame451.IO;
|
|
|
|
|
@@ -15,6 +18,7 @@ public class RTCommunicator_TLV : IRTMini8Sender, ITlvProvider
|
|
|
private IRTMini8Provider _provider;
|
|
|
private ITlvCommunicatorClient _client;
|
|
|
private readonly ConcurrentDictionary<byte, Timer> _DisconnectNotifyTimer = [];
|
|
|
+ private Dictionary<byte, Dictionary<byte, HeaterType>> _HeaterTypes;
|
|
|
|
|
|
public bool Initialize(IRTMini8Provider provider)
|
|
|
{
|
|
@@ -23,6 +27,9 @@ public class RTCommunicator_TLV : IRTMini8Sender, ITlvProvider
|
|
|
|
|
|
if (this._provider is not null)
|
|
|
return false;
|
|
|
+ string path = Path.Combine(Environment.CurrentDirectory, "HeaterType.csv");
|
|
|
+ if (!HeaterTypeAnalizer.Analize(path, out _HeaterTypes) || _HeaterTypes is null)
|
|
|
+ return false;
|
|
|
|
|
|
this._provider = provider;
|
|
|
return true;
|
|
@@ -95,7 +102,27 @@ public class RTCommunicator_TLV : IRTMini8Sender, ITlvProvider
|
|
|
case Tags.ChannelAlarmNotify:
|
|
|
if (!StructConverter.TryGetStruct(data.RawData, out ST_ALARM? alarm) || alarm is null)
|
|
|
return;
|
|
|
- this._provider?.ChannelAlarmNotify(alarm.Value);
|
|
|
+
|
|
|
+ if (this._HeaterTypes is null)
|
|
|
+ return;
|
|
|
+
|
|
|
+ if (!this._HeaterTypes.TryGetValue(alarm.Value.Mini8Index, out var channels) || channels is null)
|
|
|
+ return;
|
|
|
+
|
|
|
+ if (!channels.TryGetValue(alarm.Value.ChannelIndex, out HeaterType heaterType))
|
|
|
+ return;
|
|
|
+
|
|
|
+ ST_ALARM_Notify alarmNotify = new()
|
|
|
+ {
|
|
|
+ Mini8Index = alarm.Value.Mini8Index,
|
|
|
+ ChannelIndex = alarm.Value.ChannelIndex,
|
|
|
+ PV = alarm.Value.PV,
|
|
|
+ Caps = alarm.Value.Caps,
|
|
|
+ Floor = alarm.Value.Floor,
|
|
|
+ AlarmType = alarm.Value.AlarmType,
|
|
|
+ HeaterType = heaterType,
|
|
|
+ };
|
|
|
+ this._provider?.ChannelAlarmNotify(alarmNotify);
|
|
|
break;
|
|
|
case Tags.Mini8ConnectNotify:
|
|
|
{
|