From 905362c59c9b04022d532afdd210df4c4f5b5653 Mon Sep 17 00:00:00 2001
From: Diego <2248356998@qq.com>
Date: Thu, 13 Jun 2024 10:23:36 +0800
Subject: [PATCH] =?UTF-8?q?release=EF=BC=9A6.0.3.6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
 src/ThingsGateway.Foundation/Protocol/IProtocol.cs | 14 ++++++++++++++
 .../Protocol/ProtocolBase.cs                       | 12 ++++++++++++
 src/Version.props                                  |  2 +-
 .../ModbusMasterTest.cs                            |  4 ++--
 .../ThingsGateway.Foundation.Demo.csproj           |  2 +-
 5 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/src/ThingsGateway.Foundation/Protocol/IProtocol.cs b/src/ThingsGateway.Foundation/Protocol/IProtocol.cs
index 9c82045ee..c9a23943b 100644
--- a/src/ThingsGateway.Foundation/Protocol/IProtocol.cs
+++ b/src/ThingsGateway.Foundation/Protocol/IProtocol.cs
@@ -466,4 +466,18 @@ public interface IProtocol : IDisposable
     /// 变量地址
     /// 
     bool BitReverse(string address);
+
+    /// 
+    /// 断开连接
+    /// 
+    /// 
+    /// 
+    Task Close(string msg = null);
+
+    /// 
+    /// 连接
+    /// 
+    /// 
+    /// 
+    Task ConnectAsync(CancellationToken cancellationToken = default);
 }
diff --git a/src/ThingsGateway.Foundation/Protocol/ProtocolBase.cs b/src/ThingsGateway.Foundation/Protocol/ProtocolBase.cs
index d3ad47490..49f66b8b4 100644
--- a/src/ThingsGateway.Foundation/Protocol/ProtocolBase.cs
+++ b/src/ThingsGateway.Foundation/Protocol/ProtocolBase.cs
@@ -204,6 +204,18 @@ public abstract class ProtocolBase : DisposableObject, IProtocol
 
     #region 设备异步返回
 
+    /// 
+    public Task ConnectAsync(CancellationToken cancellationToken=default)
+    {
+      return  Channel.ConnectAsync(ConnectTimeout, cancellationToken);
+    }
+
+    /// 
+    public Task Close(string msg=default)
+    {
+        return Channel.CloseAsync(msg);
+    }
+
     /// 
     /// 接收,非主动发送的情况,重写实现非主从并发通讯协议
     /// 
diff --git a/src/Version.props b/src/Version.props
index 6c873ae58..7ce6616cc 100644
--- a/src/Version.props
+++ b/src/Version.props
@@ -1,6 +1,6 @@
 
   
-    6.0.3.5
+    6.0.3.6
   
 
   
diff --git a/src/adapter/ThingsGateway.Foundation.Demo/ModbusMasterTest.cs b/src/adapter/ThingsGateway.Foundation.Demo/ModbusMasterTest.cs
index b53278cfe..55c0d0429 100644
--- a/src/adapter/ThingsGateway.Foundation.Demo/ModbusMasterTest.cs
+++ b/src/adapter/ThingsGateway.Foundation.Demo/ModbusMasterTest.cs
@@ -17,8 +17,8 @@ internal class ModbusMasterTest
 {
     private static ModbusMaster GetMaster()
     {
-        var clientConfig = new TouchSocketConfig();
         ConsoleLogger.Default.LogLevel = LogLevel.Trace;
+        var clientConfig = new TouchSocketConfig();
         clientConfig.ConfigureContainer(a => a.AddConsoleLogger());
         //创建通道,也可以通过TouchSocketConfig.GetChannel扩展获取
         //var clientChannel = clientConfig.GetTcpServiceWithBindIPHost("tcp://127.0.0.1:502");
@@ -38,7 +38,7 @@ internal class ModbusMasterTest
     {
         using ModbusMaster modbusMaster = GetMaster();
         //modbusMaster.HeartbeatHexString = "ccccdddd";//心跳
-        await modbusMaster.Channel.ConnectAsync();
+        await modbusMaster.ConnectAsync();
         //Console.WriteLine("回车后读取注册包为abcd的客户端");
         Console.ReadLine();
         var data = await modbusMaster.ReadInt16Async("40001;id=abcd");//寄存器;{id=注册包}
diff --git a/src/adapter/ThingsGateway.Foundation.Demo/ThingsGateway.Foundation.Demo.csproj b/src/adapter/ThingsGateway.Foundation.Demo/ThingsGateway.Foundation.Demo.csproj
index 685bbead6..347e0c027 100644
--- a/src/adapter/ThingsGateway.Foundation.Demo/ThingsGateway.Foundation.Demo.csproj
+++ b/src/adapter/ThingsGateway.Foundation.Demo/ThingsGateway.Foundation.Demo.csproj
@@ -6,7 +6,7 @@
     Exe
   
   
-    
+