|
|
@@ -20,6 +20,8 @@ public class RTCommunicator_TLV : IRTMini8Sender, ITlvProvider
|
|
|
private readonly ConcurrentDictionary<byte, Timer> _DisconnectNotifyTimer = [];
|
|
|
private Dictionary<byte, Dictionary<byte, HeaterType>> _HeaterTypes;
|
|
|
|
|
|
+ public ConcurrentDictionary<string, ST_CHANNEL_Notify> ChannelData { get; } = [];
|
|
|
+
|
|
|
public bool Initialize(IRTMini8Provider provider)
|
|
|
{
|
|
|
if (provider is null)
|
|
|
@@ -32,8 +34,10 @@ public class RTCommunicator_TLV : IRTMini8Sender, ITlvProvider
|
|
|
return false;
|
|
|
|
|
|
this._provider = provider;
|
|
|
+
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
public bool StartService(string ip, int port)
|
|
|
{
|
|
|
if (_provider is null)
|
|
|
@@ -49,8 +53,6 @@ public class RTCommunicator_TLV : IRTMini8Sender, ITlvProvider
|
|
|
if (!client.Initialize(this, false, 500))
|
|
|
return false;
|
|
|
|
|
|
-
|
|
|
-
|
|
|
Task.Factory.StartNew(() =>
|
|
|
{
|
|
|
while (!client.Open(ip, (ushort)port))
|
|
|
@@ -97,7 +99,13 @@ public class RTCommunicator_TLV : IRTMini8Sender, ITlvProvider
|
|
|
string fileName = Encoding.UTF8.GetString(data.RawData);
|
|
|
if (string.IsNullOrEmpty(fileName))
|
|
|
return;
|
|
|
- this._provider?.CurrentTempConfigFile(fileName);
|
|
|
+ try
|
|
|
+ {
|
|
|
+ this._provider?.CurrentTempConfigFile(fileName);
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+ }
|
|
|
break;
|
|
|
case Tags.ChannelAlarmNotify:
|
|
|
if (!StructConverter.TryGetStruct(data.RawData, out ST_ALARM? alarm) || alarm is null)
|
|
|
@@ -122,14 +130,26 @@ public class RTCommunicator_TLV : IRTMini8Sender, ITlvProvider
|
|
|
AlarmType = alarm.Value.AlarmType,
|
|
|
HeaterType = heaterType,
|
|
|
};
|
|
|
- this._provider?.ChannelAlarmNotify(alarmNotify);
|
|
|
+ try
|
|
|
+ {
|
|
|
+ this._provider?.ChannelAlarmNotify(alarmNotify);
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+ }
|
|
|
break;
|
|
|
case Tags.Mini8ConnectNotify:
|
|
|
{
|
|
|
byte index = data.RawData[0];
|
|
|
this._DisconnectNotifyTimer.TryRemove(index, out Timer timer);
|
|
|
timer?.Dispose();
|
|
|
- this._provider?.Mini8ConnectNotify(index);
|
|
|
+ try
|
|
|
+ {
|
|
|
+ this._provider?.Mini8ConnectNotify(index);
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
case Tags.Mini8DisconnectNotify:
|
|
|
@@ -139,6 +159,41 @@ public class RTCommunicator_TLV : IRTMini8Sender, ITlvProvider
|
|
|
this._DisconnectNotifyTimer[index] = new(DisconnectNotifyTimerCallBack, index, 0, 1000);
|
|
|
break;
|
|
|
}
|
|
|
+ case Tags.ChannelRealtimeDataNotify:
|
|
|
+ if (!StructConverter.TryGetStruct(data.RawData, out ST_CHANNEL? channel) || channel is null)
|
|
|
+ return;
|
|
|
+
|
|
|
+ string key = $"{channel.Value.Mini8Index}-{channel.Value.ChannelIndex}";
|
|
|
+
|
|
|
+ if (this.ChannelData.TryGetValue(key, out ST_CHANNEL_Notify notify) || notify is null)
|
|
|
+ {
|
|
|
+ notify = new()
|
|
|
+ {
|
|
|
+ Mini8Index = channel.Value.Mini8Index,
|
|
|
+ ChannelIndex = channel.Value.ChannelIndex,
|
|
|
+ PV = channel.Value.PV,
|
|
|
+ Caps = channel.Value.Caps,
|
|
|
+ Floor = channel.Value.Floor,
|
|
|
+ };
|
|
|
+ this.ChannelData[key] = notify;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ notify.Mini8Index = channel.Value.Mini8Index;
|
|
|
+ notify.ChannelIndex = channel.Value.ChannelIndex;
|
|
|
+ notify.PV = channel.Value.PV;
|
|
|
+ notify.Caps = channel.Value.Caps;
|
|
|
+ notify.Floor = channel.Value.Floor;
|
|
|
+ }
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ this._provider?.ChannelRealtimeNotify(notify);
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+ }
|
|
|
+ break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|