|
@@ -0,0 +1,67 @@
|
|
|
+using RTCommunicatorBase;
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using TLVProtocal;
|
|
|
+using UniversalNetFrame451.IO;
|
|
|
+
|
|
|
+namespace AlarmInfoServerSim.Services
|
|
|
+{
|
|
|
+ public class SendInfoSevice : ISendInfoSevice, ITlvProvider
|
|
|
+ {
|
|
|
+ private readonly ISharedConfig _sharedConfig;
|
|
|
+ private readonly ITlvCommunicatorServer _server;
|
|
|
+
|
|
|
+ private bool _isConnected = false;
|
|
|
+
|
|
|
+ public SendInfoSevice(ISharedConfig sharedConfig)
|
|
|
+ {
|
|
|
+ _sharedConfig= sharedConfig;
|
|
|
+
|
|
|
+ _server = TlvFactory.GetTlvServer();
|
|
|
+ _server.Initialize(this);
|
|
|
+ }
|
|
|
+
|
|
|
+ public bool HasConnection => _isConnected;
|
|
|
+
|
|
|
+ public bool Open()
|
|
|
+ {
|
|
|
+ if (_sharedConfig.BasicInfo is not null)
|
|
|
+ {
|
|
|
+ return _server.Open(_sharedConfig.BasicInfo.RTServerAddress, _sharedConfig.BasicInfo.RTServerPort);
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ public bool Send(byte tag, ST_ALARM alarm)
|
|
|
+ {
|
|
|
+ if (_isConnected)
|
|
|
+ {
|
|
|
+ return _server.Send(tag, alarm);
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void Connected(TcpConnection connection)
|
|
|
+ {
|
|
|
+ _isConnected = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void Disconnected(TcpConnection connection)
|
|
|
+ {
|
|
|
+ _isConnected = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void Received(TlvData data)
|
|
|
+ {
|
|
|
+ throw new NotImplementedException();
|
|
|
+ }
|
|
|
+
|
|
|
+ public TlvData RequestReply(TlvData tlvData)
|
|
|
+ {
|
|
|
+ throw new NotImplementedException();
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|