diff --git a/framework/Directory.Build.props b/framework/Directory.Build.props index abac9830f..04e30ef4c 100644 --- a/framework/Directory.Build.props +++ b/framework/Directory.Build.props @@ -1,7 +1,7 @@ net6.0;net7.0 - 2.1.0.2 + 2.1.0.3 Diego ThingsGateway © 2023-present Diego diff --git a/framework/ThingsGateway.Admin.Blazor.Core/ThingsGateway.Admin.Blazor.Core.csproj b/framework/ThingsGateway.Admin.Blazor.Core/ThingsGateway.Admin.Blazor.Core.csproj index 6460a2a8f..c320b19ad 100644 --- a/framework/ThingsGateway.Admin.Blazor.Core/ThingsGateway.Admin.Blazor.Core.csproj +++ b/framework/ThingsGateway.Admin.Blazor.Core/ThingsGateway.Admin.Blazor.Core.csproj @@ -14,7 +14,7 @@ - + diff --git a/framework/ThingsGateway.Blazor/DebugPage/TcpClientPage.razor.cs b/framework/ThingsGateway.Blazor/DebugPage/TcpClientPage.razor.cs index f27dc598b..20dc8d715 100644 --- a/framework/ThingsGateway.Blazor/DebugPage/TcpClientPage.razor.cs +++ b/framework/ThingsGateway.Blazor/DebugPage/TcpClientPage.razor.cs @@ -82,7 +82,7 @@ public partial class TcpClientPage var LogMessage = new TouchSocket.Core.LoggerGroup() { LogLevel = TouchSocket.Core.LogLevel.Trace }; LogMessage.AddLogger(new EasyLogger(LogOut) { LogLevel = TouchSocket.Core.LogLevel.Trace }); config.ConfigureContainer(a => a.RegisterSingleton(LogMessage)); - config.SetRemoteIPHost(new IPHost(IP + ":" + Port)).SetBufferLength(300); + config.SetRemoteIPHost(new IPHost(IP + ":" + Port)); //载入配置 TcpClientEx.Setup(config); return TcpClientEx; @@ -96,7 +96,7 @@ public partial class TcpClientPage var LogMessage = new TouchSocket.Core.LoggerGroup() { LogLevel = TouchSocket.Core.LogLevel.Trace }; LogMessage.AddLogger(new EasyLogger(LogOut) { LogLevel = TouchSocket.Core.LogLevel.Trace }); config.ConfigureContainer(a => a.RegisterSingleton(LogMessage)); - config.SetRemoteIPHost(new IPHost(IP + ":" + Port)).SetBufferLength(300); + config.SetRemoteIPHost(new IPHost(IP + ":" + Port)); TcpClientEx = new TcpClientEx(); TcpClientEx.Setup(config); base.OnInitialized(); diff --git a/framework/ThingsGateway.Blazor/DebugPage/TcpServerPage.razor.cs b/framework/ThingsGateway.Blazor/DebugPage/TcpServerPage.razor.cs index b3c5683f6..1a2554a19 100644 --- a/framework/ThingsGateway.Blazor/DebugPage/TcpServerPage.razor.cs +++ b/framework/ThingsGateway.Blazor/DebugPage/TcpServerPage.razor.cs @@ -72,7 +72,6 @@ public partial class TcpServerPage LogMessage.AddLogger(new EasyLogger(LogOut) { LogLevel = TouchSocket.Core.LogLevel.Trace }); config.ConfigureContainer(a => a.RegisterSingleton(LogMessage)); config.SetListenIPHosts(new IPHost[] { new IPHost(ip + ":" + port) }); - config.SetBufferLength(300); //载入配置 TcpServer.Setup(config); return TcpServer; @@ -88,7 +87,6 @@ public partial class TcpServerPage LogMessage.AddLogger(new EasyLogger(LogOut) { LogLevel = TouchSocket.Core.LogLevel.Trace }); config.ConfigureContainer(a => a.RegisterSingleton(LogMessage)); config.SetListenIPHosts(new IPHost[] { new IPHost(ip + ":" + port) }); - config.SetBufferLength(300); TcpServer = new TcpService(); TcpServer.Setup(config); base.OnInitialized(); diff --git a/framework/ThingsGateway.Blazor/DebugPage/UdpSessionPage.razor.cs b/framework/ThingsGateway.Blazor/DebugPage/UdpSessionPage.razor.cs index 8230af8e5..7099d2393 100644 --- a/framework/ThingsGateway.Blazor/DebugPage/UdpSessionPage.razor.cs +++ b/framework/ThingsGateway.Blazor/DebugPage/UdpSessionPage.razor.cs @@ -71,7 +71,7 @@ public partial class UdpSessionPage : IDisposable var LogMessage = new TouchSocket.Core.LoggerGroup() { LogLevel = TouchSocket.Core.LogLevel.Trace }; LogMessage.AddLogger(new EasyLogger(LogOut) { LogLevel = TouchSocket.Core.LogLevel.Trace }); config.ConfigureContainer(a => a.RegisterSingleton(LogMessage)); - config.SetRemoteIPHost(new IPHost(ip + ":" + port)).SetBufferLength(300); + config.SetRemoteIPHost(new IPHost(ip + ":" + port)); config.SetBindIPHost(new IPHost(0)); //载入配置 UdpSession.Setup(config); @@ -88,7 +88,7 @@ public partial class UdpSessionPage : IDisposable var LogMessage = new TouchSocket.Core.LoggerGroup() { LogLevel = TouchSocket.Core.LogLevel.Trace }; LogMessage.AddLogger(new EasyLogger(LogOut) { LogLevel = TouchSocket.Core.LogLevel.Trace }); config.ConfigureContainer(a => a.RegisterSingleton(LogMessage)); - config.SetRemoteIPHost(new IPHost(ip + ":" + port)).SetBufferLength(300); + config.SetRemoteIPHost(new IPHost(ip + ":" + port)); config.SetBindIPHost(new IPHost(0)); UdpSession = new UdpSession(); UdpSession.Setup(config); diff --git a/framework/ThingsGateway.Foundation/Common/TcpClientEx.cs b/framework/ThingsGateway.Foundation/Common/TcpClientEx.cs index 5184aecb5..0e8e5b16f 100644 --- a/framework/ThingsGateway.Foundation/Common/TcpClientEx.cs +++ b/framework/ThingsGateway.Foundation/Common/TcpClientEx.cs @@ -64,13 +64,25 @@ public class TcpClientBaseEx : BaseSocket, ITcpClient public TcpClientBaseEx() { this.Protocol = Protocol.Tcp; + this.m_receiveCounter = new ValueCounter + { + Period = TimeSpan.FromSeconds(1), + OnPeriod = this.OnReceivePeriod + }; + this.m_sendCounter = new ValueCounter + { + Period = TimeSpan.FromSeconds(1), + OnPeriod = this.OnSendPeriod + }; } #region 变量 private DelaySender m_delaySender; private Stream m_workStream; - private int m_bufferRate = 1; + private long m_bufferRate = 1; private volatile bool m_online; + ValueCounter m_receiveCounter; + ValueCounter m_sendCounter; #endregion 变量 #region 事件 @@ -115,8 +127,6 @@ public class TcpClientBaseEx : BaseSocket, ITcpClient private void PrivateOnConnecting(ConnectingEventArgs e) { - this.LastReceivedTime = DateTime.Now; - this.LastSendTime = DateTime.Now; if (this.CanSetDataHandlingAdapter) { this.SetDataHandlingAdapter(this.Config.GetValue(TouchSocketConfigExtension.TcpDataHandlingAdapterProperty).Invoke()); @@ -206,10 +216,10 @@ public class TcpClientBaseEx : BaseSocket, ITcpClient #region 属性 /// - public DateTime LastReceivedTime { get; private set; } + public DateTime LastReceivedTime => this.m_receiveCounter.LastIncrement; /// - public DateTime LastSendTime { get; private set; } + public DateTime LastSendTime => this.m_sendCounter.LastIncrement; /// public Func OnHandleRawBuffer { get; set; } @@ -520,6 +530,44 @@ public class TcpClientBaseEx : BaseSocket, ITcpClient return this.m_workStream; } + private void OnReceivePeriod(long value) + { + this.ReceiveBufferSize = TouchSocketUtility.HitBufferLength(value); + } + + private void OnSendPeriod(long value) + { + this.SendBufferSize = TouchSocketUtility.HitBufferLength(value); + } + + /// + public override int ReceiveBufferSize + { + get => base.ReceiveBufferSize; + set + { + base.ReceiveBufferSize = value; + if (this.MainSocket != null) + { + this.MainSocket.ReceiveBufferSize = base.ReceiveBufferSize; + } + } + } + + /// + public override int SendBufferSize + { + get => base.SendBufferSize; + set + { + base.SendBufferSize = value; + if (this.MainSocket != null) + { + this.MainSocket.SendBufferSize = base.SendBufferSize; + } + } + } + /// public virtual void SetDataHandlingAdapter(SingleStreamDataHandlingAdapter adapter) { @@ -655,10 +703,6 @@ public class TcpClientBaseEx : BaseSocket, ITcpClient protected virtual void LoadConfig(TouchSocketConfig config) { this.RemoteIPHost = config.GetValue(TouchSocketConfigExtension.RemoteIPHostProperty); - if (config.GetValue(TouchSocketConfigExtension.BufferLengthProperty) is int value) - { - this.SetBufferLength(value); - } this.Logger ??= this.Container.Resolve(); this.ReceiveType = config.GetValue(TouchSocketConfigExtension.ReceiveTypeProperty); } @@ -727,7 +771,7 @@ public class TcpClientBaseEx : BaseSocket, ITcpClient var eventArgs = new SocketAsyncEventArgs(); eventArgs.Completed += this.EventArgs_Completed; - var byteBlock = BytePool.Default.GetByteBlock(this.BufferLength); + var byteBlock = BytePool.Default.GetByteBlock(this.ReceiveBufferSize); eventArgs.UserToken = byteBlock; eventArgs.SetBuffer(byteBlock.Buffer, 0, byteBlock.Capacity); if (!this.MainSocket.ReceiveAsync(eventArgs)) @@ -750,7 +794,7 @@ public class TcpClientBaseEx : BaseSocket, ITcpClient { while (true) { - var byteBlock = new ByteBlock(this.BufferLength); + var byteBlock = new ByteBlock(this.ReceiveBufferSize); try { var r = this.MainSocket.Receive(byteBlock.Buffer); @@ -773,7 +817,7 @@ public class TcpClientBaseEx : BaseSocket, ITcpClient private void BeginSsl() { - var byteBlock = new ByteBlock(this.BufferLength); + var byteBlock = new ByteBlock(this.ReceiveBufferSize); try { this.m_workStream.BeginRead(byteBlock.Buffer, 0, byteBlock.Capacity, this.EndSsl, byteBlock); @@ -813,8 +857,6 @@ public class TcpClientBaseEx : BaseSocket, ITcpClient { socket = new Socket(SocketType.Stream, ProtocolType.Tcp) { - ReceiveBufferSize = this.BufferLength, - SendBufferSize = this.BufferLength, SendTimeout = this.Config.GetValue(TouchSocketConfigExtension.SendTimeoutProperty) }; } @@ -822,8 +864,6 @@ public class TcpClientBaseEx : BaseSocket, ITcpClient { socket = new Socket(iPHost.EndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp) { - ReceiveBufferSize = this.BufferLength, - SendBufferSize = this.BufferLength, SendTimeout = this.Config.GetValue(TouchSocketConfigExtension.SendTimeoutProperty) }; } @@ -831,8 +871,8 @@ public class TcpClientBaseEx : BaseSocket, ITcpClient { #if NET45_OR_GREATER - socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true); - socket.IOControl(IOControlCode.KeepAliveValues, keepAliveValue.KeepAliveTime, null); + socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true); + socket.IOControl(IOControlCode.KeepAliveValues, keepAliveValue.KeepAliveTime, null); #else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { @@ -880,7 +920,7 @@ public class TcpClientBaseEx : BaseSocket, ITcpClient { try { - this.LastReceivedTime = DateTime.Now; + this.m_receiveCounter.Increment(byteBlock.Length); if (this.OnHandleRawBuffer?.Invoke(byteBlock) == false) { return; @@ -1075,8 +1115,7 @@ public class TcpClientBaseEx : BaseSocket, ITcpClient this.MainSocket.AbsoluteSend(buffer, offset, length); } } - - this.LastSendTime = DateTime.Now; + this.m_sendCounter.Increment(length); } } @@ -1138,7 +1177,7 @@ public class TcpClientBaseEx : BaseSocket, ITcpClient this.HandleBuffer(byteBlock); try { - var newByteBlock = BytePool.Default.GetByteBlock(Math.Min(this.BufferLength * this.m_bufferRate, 1024 * 1024)); + var newByteBlock = BytePool.Default.GetByteBlock((int)Math.Min(this.ReceiveBufferSize * this.m_bufferRate, TouchSocketUtility.MaxBufferLength)); e.UserToken = newByteBlock; e.SetBuffer(newByteBlock.Buffer, 0, newByteBlock.Capacity); diff --git a/framework/ThingsGateway.Foundation/SerialPort/Interface/ISerial.cs b/framework/ThingsGateway.Foundation/SerialPort/Interface/ISerial.cs index bd407378c..49cc6bf5f 100644 --- a/framework/ThingsGateway.Foundation/SerialPort/Interface/ISerial.cs +++ b/framework/ThingsGateway.Foundation/SerialPort/Interface/ISerial.cs @@ -18,21 +18,18 @@ namespace ThingsGateway.Foundation.Serial; public interface ISerial : IDisposable { /// - /// 数据交互缓存池限制 + /// 发送缓存区大小。最小值=1024。 /// - int BufferLength { get; } + int SendBufferSize { get; set; } + + /// + /// 接收缓存区大小。最小值=1024。 + /// + int ReceiveBufferSize { get; set; } /// /// 日志记录器 /// - ILog Logger { get; } - - /// - /// 设置数据交互缓存池尺寸,min=1024 byte。 - /// 一般情况下该值用于三个方面,包括:发送、接收缓存,及内存池的默认申请。 - /// - /// - /// - int SetBufferLength(int value); + ILog Logger { get; set; } } \ No newline at end of file diff --git a/framework/ThingsGateway.Foundation/SerialPort/SerialPort/BaseSerial.cs b/framework/ThingsGateway.Foundation/SerialPort/SerialPort/BaseSerial.cs index dc73f07d1..31a563c72 100644 --- a/framework/ThingsGateway.Foundation/SerialPort/SerialPort/BaseSerial.cs +++ b/framework/ThingsGateway.Foundation/SerialPort/SerialPort/BaseSerial.cs @@ -20,39 +20,22 @@ public abstract class BaseSerial : DependencyObject, ISerial /// /// 同步根。 /// - protected readonly object SyncRoot; + protected readonly object SyncRoot = new object(); + private int m_receiveBufferSize = 1024 * 64; + private int m_sendBufferSize = 1024 * 64; - /// - /// 通讯基类 - /// - public BaseSerial() + /// + public virtual int SendBufferSize { - this.SyncRoot = new object(); + get => m_sendBufferSize; + set => m_sendBufferSize = value < 1024 ? 1024 : value; } - - /// - /// 数据交互缓存池限制,min=1024 byte - /// - public int BufferLength { get; private set; } = 64 * 1024; - - /// - /// 日志记录器 - /// + /// + public virtual int ReceiveBufferSize + { + get => m_receiveBufferSize; + set => m_receiveBufferSize = value < 1024 ? 1024 : value; + } + /// public ILog Logger { get; set; } - - /// - /// 设置数据交互缓存池尺寸,min=1024 byte。 - /// 一般情况下该值用于三个方面,包括:socket的发送、接收缓存,及内存池的默认申请。 - /// - /// - /// - public virtual int SetBufferLength(int value) - { - if (value < 1024) - { - value = 1024; - } - this.BufferLength = value; - return this.BufferLength; - } } \ No newline at end of file diff --git a/framework/ThingsGateway.Foundation/SerialPort/SerialPort/SerialSession.cs b/framework/ThingsGateway.Foundation/SerialPort/SerialPort/SerialSession.cs index faff43ce5..945f7d85a 100644 --- a/framework/ThingsGateway.Foundation/SerialPort/SerialPort/SerialSession.cs +++ b/framework/ThingsGateway.Foundation/SerialPort/SerialPort/SerialSession.cs @@ -60,12 +60,27 @@ public class SerialSessionBase : BaseSerial, ISerialSession public SerialSessionBase() { this.Protocol = SerialPort; + this.m_receiveCounter = new ValueCounter + { + Period = TimeSpan.FromSeconds(1), + OnPeriod = this.OnReceivePeriod + }; + this.m_sendCounter = new ValueCounter + { + Period = TimeSpan.FromSeconds(1), + OnPeriod = this.OnSendPeriod + }; } + #region 变量 + private SerialDelaySender m_delaySender; - private int m_bufferRate = 1; + private long m_bufferRate = 1; private volatile bool m_online; + ValueCounter m_receiveCounter; + ValueCounter m_sendCounter; + #endregion 变量 #region 事件 @@ -110,8 +125,6 @@ public class SerialSessionBase : BaseSerial, ISerialSession private void PrivateOnConnecting(SerialConnectingEventArgs e) { - this.LastReceivedTime = DateTime.Now; - this.LastSendTime = DateTime.Now; if (this.CanSetDataHandlingAdapter) { this.SetDataHandlingAdapter(this.Config.GetValue(TouchSocketConfigExtension.TcpDataHandlingAdapterProperty).Invoke()); @@ -201,10 +214,10 @@ public class SerialSessionBase : BaseSerial, ISerialSession #region 属性 /// - public DateTime LastReceivedTime { get; private set; } + public DateTime LastReceivedTime => this.m_receiveCounter.LastIncrement; /// - public DateTime LastSendTime { get; private set; } + public DateTime LastSendTime => this.m_sendCounter.LastIncrement; /// public Func OnHandleRawBuffer { get; set; } @@ -370,7 +383,43 @@ public class SerialSessionBase : BaseSerial, ISerialSession } #endregion + private void OnReceivePeriod(long value) + { + this.ReceiveBufferSize = TouchSocketUtility.HitBufferLength(value); + } + private void OnSendPeriod(long value) + { + this.SendBufferSize = TouchSocketUtility.HitBufferLength(value); + } + + /// + public override int ReceiveBufferSize + { + get => base.ReceiveBufferSize; + set + { + base.ReceiveBufferSize = value; + if (this.MainSerialPort != null && !MainSerialPort.IsOpen) + { + this.MainSerialPort.ReadBufferSize = base.ReceiveBufferSize; + } + } + } + + /// + public override int SendBufferSize + { + get => base.SendBufferSize; + set + { + base.SendBufferSize = value; + if (this.MainSerialPort != null && !MainSerialPort.IsOpen) + { + this.MainSerialPort.WriteBufferSize = base.SendBufferSize; + } + } + } /// public virtual void SetDataHandlingAdapter(SingleStreamDataHandlingAdapter adapter) @@ -499,10 +548,6 @@ public class SerialSessionBase : BaseSerial, ISerialSession protected virtual void LoadConfig(TouchSocketConfig config) { this.SerialProperty = config.GetValue(SerialConfigExtension.SerialProperty); - if (config.GetValue(TouchSocketConfigExtension.BufferLengthProperty) is int value) - { - this.SetBufferLength(value); - } this.Logger ??= this.Container.Resolve(); this.ReceiveType = config.GetValue(TouchSocketConfigExtension.ReceiveTypeProperty); } @@ -546,7 +591,7 @@ public class SerialSessionBase : BaseSerial, ISerialSession if (this.ReceiveType == ReceiveType.Iocp) { SerialReceivedEventArgs eventArgs = new(); - var byteBlock = BytePool.Default.GetByteBlock(this.BufferLength); + var byteBlock = BytePool.Default.GetByteBlock(this.ReceiveBufferSize); byteBlock.SetLength(0); eventArgs.UserToken = byteBlock; if (this.MainSerialPort.BytesToRead > 0) @@ -580,7 +625,7 @@ public class SerialSessionBase : BaseSerial, ISerialSession { this.m_bufferRate = 1; SerialReceivedEventArgs eventArgs = new(); - var newByteBlock = BytePool.Default.GetByteBlock(Math.Min(this.BufferLength * this.m_bufferRate, 1024 * 1024)); + var newByteBlock = BytePool.Default.GetByteBlock((int)Math.Min(this.ReceiveBufferSize * this.m_bufferRate, TouchSocketUtility.MaxBufferLength)); newByteBlock.SetLength(0); eventArgs.UserToken = newByteBlock; if (MainSerialPort.BytesToRead > 0) @@ -597,7 +642,7 @@ public class SerialSessionBase : BaseSerial, ISerialSession { while (true) { - var byteBlock = new ByteBlock(this.BufferLength); + var byteBlock = BytePool.Default.GetByteBlock(this.ReceiveBufferSize); try { int r = MainSerialPort.Read(byteBlock.Buffer, 0, MainSerialPort.BytesToRead); @@ -634,7 +679,7 @@ public class SerialSessionBase : BaseSerial, ISerialSession this.HandleBuffer(byteBlock); try { - var newByteBlock = BytePool.Default.GetByteBlock(Math.Min(this.BufferLength * this.m_bufferRate, 1024 * 1024)); + var newByteBlock = BytePool.Default.GetByteBlock((int)Math.Min(this.ReceiveBufferSize * this.m_bufferRate, TouchSocketUtility.MaxBufferLength)); newByteBlock.SetLength(num); e.UserToken = newByteBlock; @@ -678,7 +723,7 @@ public class SerialSessionBase : BaseSerial, ISerialSession { try { - this.LastReceivedTime = DateTime.Now; + this.m_receiveCounter.Increment(byteBlock.Length); if (this.OnHandleRawBuffer?.Invoke(byteBlock) == false) { return; @@ -867,7 +912,7 @@ public class SerialSessionBase : BaseSerial, ISerialSession this.MainSerialPort.AbsoluteSend(buffer, offset, length); } - this.LastSendTime = DateTime.Now; + this.m_sendCounter.Increment(length); } } diff --git a/framework/ThingsGateway.Foundation/ThingsGateway.Foundation.csproj b/framework/ThingsGateway.Foundation/ThingsGateway.Foundation.csproj index d2e18cfb0..2b0b2695a 100644 --- a/framework/ThingsGateway.Foundation/ThingsGateway.Foundation.csproj +++ b/framework/ThingsGateway.Foundation/ThingsGateway.Foundation.csproj @@ -13,7 +13,7 @@ - + diff --git a/framework/ThingsGateway.Foundation/ThingsGateway.Foundation.xml b/framework/ThingsGateway.Foundation/ThingsGateway.Foundation.xml index 636ecc9cf..d0e06b95e 100644 --- a/framework/ThingsGateway.Foundation/ThingsGateway.Foundation.xml +++ b/framework/ThingsGateway.Foundation/ThingsGateway.Foundation.xml @@ -837,6 +837,12 @@ + + + + + + @@ -1820,9 +1826,14 @@ 串口基接口 - + - 数据交互缓存池限制 + 发送缓存区大小。最小值=1024。 + + + + + 接收缓存区大小。最小值=1024。 @@ -1830,14 +1841,6 @@ 日志记录器 - - - 设置数据交互缓存池尺寸,min=1024 byte。 - 一般情况下该值用于三个方面,包括:发送、接收缓存,及内存池的默认申请。 - - - - @@ -1936,28 +1939,14 @@ 同步根。 - - - 通讯基类 - + + - - - 数据交互缓存池限制,min=1024 byte - + + - - 日志记录器 - - - - - 设置数据交互缓存池尺寸,min=1024 byte。 - 一般情况下该值用于三个方面,包括:socket的发送、接收缓存,及内存池的默认申请。 - - - + @@ -2157,6 +2146,12 @@ + + + + + + diff --git a/framework/ThingsGateway.Plugin/Foundataion.ConsoleTests/DLT645Test/Program.cs b/framework/ThingsGateway.Plugin/Foundataion.ConsoleTests/DLT645Test/Program.cs index 864480e3a..e8cff121f 100644 --- a/framework/ThingsGateway.Plugin/Foundataion.ConsoleTests/DLT645Test/Program.cs +++ b/framework/ThingsGateway.Plugin/Foundataion.ConsoleTests/DLT645Test/Program.cs @@ -27,7 +27,7 @@ namespace DLT645Test .SetSerialProperty(new SerialProperty() //串口链路才需要 { PortName = "COM1" - }).SetBufferLength(1024); + }); var serialSession = new SerialsSession();//链路对象 serialSession.Setup(config); diff --git a/framework/ThingsGateway.Plugin/Foundataion.ConsoleTests/ModbusTest/Program.cs b/framework/ThingsGateway.Plugin/Foundataion.ConsoleTests/ModbusTest/Program.cs index 53354e225..fb1760c7a 100644 --- a/framework/ThingsGateway.Plugin/Foundataion.ConsoleTests/ModbusTest/Program.cs +++ b/framework/ThingsGateway.Plugin/Foundataion.ConsoleTests/ModbusTest/Program.cs @@ -61,7 +61,7 @@ namespace ModbusDemo .SetSerialProperty(new SerialProperty() //串口链路才需要 { PortName = "COM1" - }).SetBufferLength(1024); + }); var tcpClient1 = new TcpClientEx();//链路对象 var tcpClient2 = new TcpClientEx();//链路对象 diff --git a/framework/ThingsGateway.Plugin/Foundataion/Directory.Build.props b/framework/ThingsGateway.Plugin/Foundataion/Directory.Build.props index b6f6be8bd..1b5a48fa0 100644 --- a/framework/ThingsGateway.Plugin/Foundataion/Directory.Build.props +++ b/framework/ThingsGateway.Plugin/Foundataion/Directory.Build.props @@ -1,7 +1,7 @@ net6.0;net7.0 - 2.1.0.2 + 2.1.0.3 Diego ThingsGateway © 2023-present Diego diff --git a/framework/ThingsGateway.Plugin/ThingsGateway.DLT645/DLT645_2007/DLT645_2007.cs b/framework/ThingsGateway.Plugin/ThingsGateway.DLT645/DLT645_2007/DLT645_2007.cs index 23e9bfd2d..759faf9f8 100644 --- a/framework/ThingsGateway.Plugin/ThingsGateway.DLT645/DLT645_2007/DLT645_2007.cs +++ b/framework/ThingsGateway.Plugin/ThingsGateway.DLT645/DLT645_2007/DLT645_2007.cs @@ -94,7 +94,7 @@ public class DLT645_2007 : CollectBase Parity = driverPropertys.Parity, StopBits = driverPropertys.StopBits, }) - .SetBufferLength(1024); + ; client = new SerialsSession(); ((SerialsSession)client).Setup(FoundataionConfig); } diff --git a/framework/ThingsGateway.Plugin/ThingsGateway.DLT645/DLT645_2007OverTcp/DLT645_2007OverTcp.cs b/framework/ThingsGateway.Plugin/ThingsGateway.DLT645/DLT645_2007OverTcp/DLT645_2007OverTcp.cs index 25d4c7a1c..0e679570d 100644 --- a/framework/ThingsGateway.Plugin/ThingsGateway.DLT645/DLT645_2007OverTcp/DLT645_2007OverTcp.cs +++ b/framework/ThingsGateway.Plugin/ThingsGateway.DLT645/DLT645_2007OverTcp/DLT645_2007OverTcp.cs @@ -81,7 +81,7 @@ public class DLT645_2007OverTcp : CollectBase if (client == null) { FoundataionConfig.SetRemoteIPHost(new IPHost($"{driverPropertys.IP}:{driverPropertys.Port}")) - .SetBufferLength(1024); + ; client = new TcpClientEx(); ((TcpClientEx)client).Setup(FoundataionConfig); } diff --git a/framework/ThingsGateway.Plugin/ThingsGateway.Modbus/ModbusRtu/ModbusRtu.cs b/framework/ThingsGateway.Plugin/ThingsGateway.Modbus/ModbusRtu/ModbusRtu.cs index d13a5e64b..54e66a2ec 100644 --- a/framework/ThingsGateway.Plugin/ThingsGateway.Modbus/ModbusRtu/ModbusRtu.cs +++ b/framework/ThingsGateway.Plugin/ThingsGateway.Modbus/ModbusRtu/ModbusRtu.cs @@ -87,7 +87,7 @@ public class ModbusRtu : CollectBase Parity = driverPropertys.Parity, StopBits = driverPropertys.StopBits, }) - .SetBufferLength(1024); + ; client = new SerialsSession(); ((SerialsSession)client).Setup(FoundataionConfig); } diff --git a/framework/ThingsGateway.Plugin/ThingsGateway.Modbus/ModbusRtuOverTcp/ModbusRtuOverTcp.cs b/framework/ThingsGateway.Plugin/ThingsGateway.Modbus/ModbusRtuOverTcp/ModbusRtuOverTcp.cs index f00f6ce4a..1d0aa99ba 100644 --- a/framework/ThingsGateway.Plugin/ThingsGateway.Modbus/ModbusRtuOverTcp/ModbusRtuOverTcp.cs +++ b/framework/ThingsGateway.Plugin/ThingsGateway.Modbus/ModbusRtuOverTcp/ModbusRtuOverTcp.cs @@ -75,7 +75,7 @@ public class ModbusRtuOverTcp : CollectBase if (client == null) { FoundataionConfig.SetRemoteIPHost(new IPHost($"{driverPropertys.IP}:{driverPropertys.Port}")) - .SetBufferLength(1024); + ; client = new TcpClientEx(); ((TcpClientEx)client).Setup(FoundataionConfig); } diff --git a/framework/ThingsGateway.Plugin/ThingsGateway.Modbus/ModbusRtuOverUdp/ModbusRtuOverUdp.cs b/framework/ThingsGateway.Plugin/ThingsGateway.Modbus/ModbusRtuOverUdp/ModbusRtuOverUdp.cs index 9e0d53222..f4e1f6017 100644 --- a/framework/ThingsGateway.Plugin/ThingsGateway.Modbus/ModbusRtuOverUdp/ModbusRtuOverUdp.cs +++ b/framework/ThingsGateway.Plugin/ThingsGateway.Modbus/ModbusRtuOverUdp/ModbusRtuOverUdp.cs @@ -80,7 +80,7 @@ public class ModbusRtuOverUdp : CollectBase { FoundataionConfig.SetRemoteIPHost(new IPHost($"{driverPropertys.IP}:{driverPropertys.Port}")) .SetBindIPHost(new IPHost(0)) - .SetBufferLength(1024); + ; client = new UdpSession(); ((UdpSession)client).Setup(FoundataionConfig); diff --git a/framework/ThingsGateway.Plugin/ThingsGateway.Modbus/ModbusServer/ModbusServer.cs b/framework/ThingsGateway.Plugin/ThingsGateway.Modbus/ModbusServer/ModbusServer.cs index e0202ba7c..a25c50216 100644 --- a/framework/ThingsGateway.Plugin/ThingsGateway.Modbus/ModbusServer/ModbusServer.cs +++ b/framework/ThingsGateway.Plugin/ThingsGateway.Modbus/ModbusServer/ModbusServer.cs @@ -122,7 +122,7 @@ public class ModbusServer : UpLoadBase { iPHost = new IPHost($"{driverPropertys.IP}:{driverPropertys.Port}"); } - FoundataionConfig.SetListenIPHosts(new IPHost[] { iPHost }).SetBufferLength(1024); + FoundataionConfig.SetListenIPHosts(new IPHost[] { iPHost }); var service = new TcpService(); service.Setup(FoundataionConfig); //载入配置 diff --git a/framework/ThingsGateway.Plugin/ThingsGateway.Modbus/ModbusTcp/ModbusTcp.cs b/framework/ThingsGateway.Plugin/ThingsGateway.Modbus/ModbusTcp/ModbusTcp.cs index ad855e59d..335085d29 100644 --- a/framework/ThingsGateway.Plugin/ThingsGateway.Modbus/ModbusTcp/ModbusTcp.cs +++ b/framework/ThingsGateway.Plugin/ThingsGateway.Modbus/ModbusTcp/ModbusTcp.cs @@ -81,7 +81,7 @@ public class ModbusTcp : CollectBase if (client == null) { FoundataionConfig.SetRemoteIPHost(new IPHost($"{driverPropertys.IP}:{driverPropertys.Port}")) - .SetBufferLength(1024); + ; client = new TcpClientEx(); ((TcpClientEx)client).Setup(FoundataionConfig); } diff --git a/framework/ThingsGateway.Plugin/ThingsGateway.Modbus/ModbusUdp/ModbusUdp.cs b/framework/ThingsGateway.Plugin/ThingsGateway.Modbus/ModbusUdp/ModbusUdp.cs index 3af0275dd..41b7eb4fd 100644 --- a/framework/ThingsGateway.Plugin/ThingsGateway.Modbus/ModbusUdp/ModbusUdp.cs +++ b/framework/ThingsGateway.Plugin/ThingsGateway.Modbus/ModbusUdp/ModbusUdp.cs @@ -81,7 +81,7 @@ public class ModbusUdp : CollectBase { FoundataionConfig.SetRemoteIPHost(new IPHost($"{driverPropertys.IP}:{driverPropertys.Port}")) .SetBindIPHost(new IPHost(0)) - .SetBufferLength(1024); + ; client = new UdpSession(); ((UdpSession)client).Setup(FoundataionConfig); } diff --git a/framework/ThingsGateway.Plugin/ThingsGateway.Siemens/S7_1200.cs b/framework/ThingsGateway.Plugin/ThingsGateway.Siemens/S7_1200.cs index 36c6ce041..e8874065f 100644 --- a/framework/ThingsGateway.Plugin/ThingsGateway.Siemens/S7_1200.cs +++ b/framework/ThingsGateway.Plugin/ThingsGateway.Siemens/S7_1200.cs @@ -33,7 +33,7 @@ namespace ThingsGateway.Siemens if (client == null) { FoundataionConfig.SetRemoteIPHost(new IPHost($"{driverPropertys.IP}:{driverPropertys.Port}")) - .SetBufferLength(1024); + ; client = new TcpClientEx(); ((TcpClientEx)client).Setup(FoundataionConfig); } diff --git a/framework/ThingsGateway.Plugin/ThingsGateway.Siemens/S7_1500.cs b/framework/ThingsGateway.Plugin/ThingsGateway.Siemens/S7_1500.cs index e182ed110..40a386915 100644 --- a/framework/ThingsGateway.Plugin/ThingsGateway.Siemens/S7_1500.cs +++ b/framework/ThingsGateway.Plugin/ThingsGateway.Siemens/S7_1500.cs @@ -32,7 +32,7 @@ namespace ThingsGateway.Siemens if (client == null) { FoundataionConfig.SetRemoteIPHost(new IPHost($"{driverPropertys.IP}:{driverPropertys.Port}")) - .SetBufferLength(1024); + ; client = new TcpClientEx(); ((TcpClientEx)client).Setup(FoundataionConfig); } diff --git a/framework/ThingsGateway.Plugin/ThingsGateway.Siemens/S7_200.cs b/framework/ThingsGateway.Plugin/ThingsGateway.Siemens/S7_200.cs index 5369b8e16..a1fda90ae 100644 --- a/framework/ThingsGateway.Plugin/ThingsGateway.Siemens/S7_200.cs +++ b/framework/ThingsGateway.Plugin/ThingsGateway.Siemens/S7_200.cs @@ -32,7 +32,7 @@ namespace ThingsGateway.Siemens if (client == null) { FoundataionConfig.SetRemoteIPHost(new IPHost($"{driverPropertys.IP}:{driverPropertys.Port}")) - .SetBufferLength(1024); + ; client = new TcpClientEx(); ((TcpClientEx)client).Setup(FoundataionConfig); } diff --git a/framework/ThingsGateway.Plugin/ThingsGateway.Siemens/S7_200SMART.cs b/framework/ThingsGateway.Plugin/ThingsGateway.Siemens/S7_200SMART.cs index 3e372a41b..4724a437b 100644 --- a/framework/ThingsGateway.Plugin/ThingsGateway.Siemens/S7_200SMART.cs +++ b/framework/ThingsGateway.Plugin/ThingsGateway.Siemens/S7_200SMART.cs @@ -32,7 +32,7 @@ namespace ThingsGateway.Siemens if (client == null) { FoundataionConfig.SetRemoteIPHost(new IPHost($"{driverPropertys.IP}:{driverPropertys.Port}")) - .SetBufferLength(1024); + ; client = new TcpClientEx(); ((TcpClientEx)client).Setup(FoundataionConfig); } diff --git a/framework/ThingsGateway.Plugin/ThingsGateway.Siemens/S7_300.cs b/framework/ThingsGateway.Plugin/ThingsGateway.Siemens/S7_300.cs index 5323573ac..91b7aba0e 100644 --- a/framework/ThingsGateway.Plugin/ThingsGateway.Siemens/S7_300.cs +++ b/framework/ThingsGateway.Plugin/ThingsGateway.Siemens/S7_300.cs @@ -32,7 +32,7 @@ namespace ThingsGateway.Siemens if (client == null) { FoundataionConfig.SetRemoteIPHost(new IPHost($"{driverPropertys.IP}:{driverPropertys.Port}")) - .SetBufferLength(1024); + ; client = new TcpClientEx(); ((TcpClientEx)client).Setup(FoundataionConfig); } diff --git a/framework/ThingsGateway.Plugin/ThingsGateway.Siemens/S7_400.cs b/framework/ThingsGateway.Plugin/ThingsGateway.Siemens/S7_400.cs index 02d9d75a8..3ab345728 100644 --- a/framework/ThingsGateway.Plugin/ThingsGateway.Siemens/S7_400.cs +++ b/framework/ThingsGateway.Plugin/ThingsGateway.Siemens/S7_400.cs @@ -32,7 +32,7 @@ namespace ThingsGateway.Siemens if (client == null) { FoundataionConfig.SetRemoteIPHost(new IPHost($"{driverPropertys.IP}:{driverPropertys.Port}")) - .SetBufferLength(1024); + ; client = new TcpClientEx(); ((TcpClientEx)client).Setup(FoundataionConfig); }