mirror of
https://gitee.com/ThingsGateway/ThingsGateway.git
synced 2025-10-20 10:50:48 +08:00
10.11.54
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
<Project>
|
||||
|
||||
<PropertyGroup>
|
||||
<PluginVersion>10.11.52</PluginVersion>
|
||||
<ProPluginVersion>10.11.52</ProPluginVersion>
|
||||
<DefaultVersion>10.11.52</DefaultVersion>
|
||||
<PluginVersion>10.11.54</PluginVersion>
|
||||
<ProPluginVersion>10.11.54</ProPluginVersion>
|
||||
<DefaultVersion>10.11.54</DefaultVersion>
|
||||
<AuthenticationVersion>10.11.5</AuthenticationVersion>
|
||||
<SourceGeneratorVersion>10.11.4</SourceGeneratorVersion>
|
||||
<NET8Version>8.0.20</NET8Version>
|
||||
|
@@ -57,7 +57,7 @@ public interface IChannel : ISetupConfigObject, IDisposable, IClosableClient, IC
|
||||
/// </summary>
|
||||
public ChannelEventHandler Stoping { get; }
|
||||
|
||||
void ResetSign(int minSign = 0, int maxSign = ushort.MaxValue);
|
||||
void ResetSign(int minSign = 1, int maxSign = ushort.MaxValue - 1);
|
||||
|
||||
|
||||
}
|
||||
|
@@ -30,6 +30,7 @@ public interface IClientChannel : IChannel, ISender, IClient, IClientSender, IOn
|
||||
WaitHandlePool<MessageBase> WaitHandlePool { get; }
|
||||
|
||||
WaitLock GetLock(string key);
|
||||
void LogSeted(bool logSeted);
|
||||
|
||||
/// <summary>
|
||||
/// 设置数据处理适配器
|
||||
|
@@ -36,7 +36,7 @@ public class OtherChannel : SetupConfigObject, IClientChannel
|
||||
public override TouchSocketConfig Config => base.Config ?? ChannelOptions.Config;
|
||||
|
||||
|
||||
public void ResetSign(int minSign = 0, int maxSign = ushort.MaxValue)
|
||||
public void ResetSign(int minSign = 1, int maxSign = ushort.MaxValue - 1)
|
||||
{
|
||||
var pool = WaitHandlePool;
|
||||
WaitHandlePool = new WaitHandlePool<MessageBase>(minSign, maxSign);
|
||||
@@ -68,7 +68,7 @@ public class OtherChannel : SetupConfigObject, IClientChannel
|
||||
/// <summary>
|
||||
/// 等待池
|
||||
/// </summary>
|
||||
public WaitHandlePool<MessageBase> WaitHandlePool { get; internal set; } = new(0, ushort.MaxValue);
|
||||
public WaitHandlePool<MessageBase> WaitHandlePool { get; internal set; } = new(1, ushort.MaxValue - 1);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public WaitLock WaitLock => ChannelOptions.WaitLock;
|
||||
@@ -98,7 +98,10 @@ public class OtherChannel : SetupConfigObject, IClientChannel
|
||||
|
||||
logSet = false;
|
||||
}
|
||||
|
||||
public void LogSeted(bool logSeted)
|
||||
{
|
||||
logSet = logSeted;
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置数据处理适配器。
|
||||
/// </summary>
|
||||
|
@@ -31,7 +31,7 @@ public class SerialPortChannel : SerialPortClient, IClientChannel
|
||||
|
||||
public override TouchSocketConfig Config => base.Config ?? ChannelOptions.Config;
|
||||
|
||||
public void ResetSign(int minSign = 0, int maxSign = ushort.MaxValue)
|
||||
public void ResetSign(int minSign = 1, int maxSign = ushort.MaxValue - 1)
|
||||
{
|
||||
var pool = WaitHandlePool;
|
||||
WaitHandlePool = new WaitHandlePool<MessageBase>(minSign, maxSign);
|
||||
@@ -71,6 +71,11 @@ public class SerialPortChannel : SerialPortClient, IClientChannel
|
||||
logSet = false;
|
||||
}
|
||||
|
||||
public void LogSeted(bool logSeted)
|
||||
{
|
||||
logSet = logSeted;
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc/>
|
||||
public ChannelEventHandler Started { get; } = new();
|
||||
@@ -86,7 +91,7 @@ public class SerialPortChannel : SerialPortClient, IClientChannel
|
||||
/// <summary>
|
||||
/// 等待池
|
||||
/// </summary>
|
||||
public WaitHandlePool<MessageBase> WaitHandlePool { get; internal set; } = new(0, ushort.MaxValue);
|
||||
public WaitHandlePool<MessageBase> WaitHandlePool { get; internal set; } = new(1, ushort.MaxValue - 1);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public WaitLock WaitLock => ChannelOptions.WaitLock;
|
||||
|
@@ -28,7 +28,7 @@ public class TcpClientChannel : TcpClient, IClientChannel
|
||||
ResetSign();
|
||||
}
|
||||
public override TouchSocketConfig Config => base.Config ?? ChannelOptions.Config;
|
||||
public void ResetSign(int minSign = 0, int maxSign = ushort.MaxValue)
|
||||
public void ResetSign(int minSign = 1, int maxSign = ushort.MaxValue - 1)
|
||||
{
|
||||
var pool = WaitHandlePool;
|
||||
WaitHandlePool = new WaitHandlePool<MessageBase>(minSign, maxSign);
|
||||
@@ -51,6 +51,10 @@ public class TcpClientChannel : TcpClient, IClientChannel
|
||||
|
||||
logSet = false;
|
||||
}
|
||||
public void LogSeted(bool logSeted)
|
||||
{
|
||||
logSet = logSeted;
|
||||
}
|
||||
/// <inheritdoc/>
|
||||
public ChannelReceivedEventHandler ChannelReceived { get; } = new();
|
||||
|
||||
@@ -79,7 +83,7 @@ public class TcpClientChannel : TcpClient, IClientChannel
|
||||
/// <summary>
|
||||
/// 等待池
|
||||
/// </summary>
|
||||
public WaitHandlePool<MessageBase> WaitHandlePool { get; internal set; } = new(0, ushort.MaxValue);
|
||||
public WaitHandlePool<MessageBase> WaitHandlePool { get; internal set; } = new(1, ushort.MaxValue - 1);
|
||||
public virtual WaitLock GetLock(string key) => WaitLock;
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
@@ -210,7 +210,7 @@ public class TcpServiceChannel<TClient> : TcpServiceChannelBase<TClient>, IChann
|
||||
}
|
||||
public int MinSign { get; private set; } = 0;
|
||||
public int MaxSign { get; private set; } = ushort.MaxValue;
|
||||
public void ResetSign(int minSign = 0, int maxSign = ushort.MaxValue)
|
||||
public void ResetSign(int minSign = 1, int maxSign = ushort.MaxValue - 1)
|
||||
{
|
||||
MinSign = minSign;
|
||||
MaxSign = maxSign;
|
||||
|
@@ -43,8 +43,11 @@ public class TcpSessionClientChannel : TcpSessionClient, IClientChannel
|
||||
|
||||
logSet = false;
|
||||
}
|
||||
|
||||
public void ResetSign(int minSign = 0, int maxSign = ushort.MaxValue)
|
||||
public void LogSeted(bool logSeted)
|
||||
{
|
||||
logSet = logSeted;
|
||||
}
|
||||
public void ResetSign(int minSign = 1, int maxSign = ushort.MaxValue - 1)
|
||||
{
|
||||
var pool = WaitHandlePool;
|
||||
WaitHandlePool = new WaitHandlePool<MessageBase>(minSign, maxSign);
|
||||
@@ -79,7 +82,7 @@ public class TcpSessionClientChannel : TcpSessionClient, IClientChannel
|
||||
/// <summary>
|
||||
/// 等待池
|
||||
/// </summary>
|
||||
public WaitHandlePool<MessageBase> WaitHandlePool { get; private set; } = new(0, ushort.MaxValue);
|
||||
public WaitHandlePool<MessageBase> WaitHandlePool { get; private set; } = new(1, ushort.MaxValue - 1);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public WaitLock WaitLock { get; internal set; } = new(nameof(TcpSessionClientChannel));
|
||||
|
@@ -40,6 +40,10 @@ public class UdpSessionChannel : UdpSession, IClientChannel
|
||||
handleAdapter.Logger = log;
|
||||
}
|
||||
}
|
||||
public void LogSeted(bool logSeted)
|
||||
{
|
||||
logSet = logSeted;
|
||||
}
|
||||
/// <inheritdoc/>
|
||||
public void SetDataHandlingAdapter(DataHandlingAdapter adapter)
|
||||
{
|
||||
@@ -50,7 +54,7 @@ public class UdpSessionChannel : UdpSession, IClientChannel
|
||||
}
|
||||
|
||||
|
||||
public void ResetSign(int minSign = 0, int maxSign = ushort.MaxValue)
|
||||
public void ResetSign(int minSign = 1, int maxSign = ushort.MaxValue - 1)
|
||||
{
|
||||
var pool = WaitHandlePool;
|
||||
WaitHandlePool = new WaitHandlePool<MessageBase>(minSign, maxSign);
|
||||
@@ -89,7 +93,7 @@ public class UdpSessionChannel : UdpSession, IClientChannel
|
||||
/// <summary>
|
||||
/// 等待池
|
||||
/// </summary>
|
||||
public WaitHandlePool<MessageBase> WaitHandlePool { get; set; } = new(0, ushort.MaxValue);
|
||||
public WaitHandlePool<MessageBase> WaitHandlePool { get; internal set; } = new(1, ushort.MaxValue - 1);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public WaitLock WaitLock => ChannelOptions.WaitLock;
|
||||
|
@@ -569,7 +569,7 @@ public abstract class DeviceBase : AsyncAndSyncDisposableObject, IDevice
|
||||
{
|
||||
timeoutStatus = reusableTimeout.TimeoutStatus;
|
||||
return timeoutStatus
|
||||
? new MessageBase(new TimeoutException())
|
||||
? new MessageBase(new TimeoutException()) { ErrorMessage = $"Timeout, sign: {sign}" }
|
||||
: new MessageBase(new OperationCanceledException());
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -583,9 +583,15 @@ public abstract class DeviceBase : AsyncAndSyncDisposableObject, IDevice
|
||||
_reusableTimeouts.Return(reusableTimeout);
|
||||
}
|
||||
|
||||
return waitData.Status == WaitDataStatus.Success
|
||||
? waitData.CompletedData
|
||||
: new MessageBase(waitData.Check(timeoutStatus));
|
||||
if (waitData.Status == WaitDataStatus.Success)
|
||||
{
|
||||
return waitData.CompletedData;
|
||||
}
|
||||
else
|
||||
{
|
||||
var operResult = waitData.Check(timeoutStatus);
|
||||
return new MessageBase(operResult) { ErrorMessage = $"{operResult.ErrorMessage}, sign: {sign}" };
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -978,6 +984,7 @@ public abstract class DeviceBase : AsyncAndSyncDisposableObject, IDevice
|
||||
{
|
||||
lock (Channel)
|
||||
{
|
||||
|
||||
Channel.Starting.Remove(ChannelStarting);
|
||||
Channel.Stoped.Remove(ChannelStoped);
|
||||
Channel.Started.Remove(ChannelStarted);
|
||||
@@ -1018,6 +1025,11 @@ public abstract class DeviceBase : AsyncAndSyncDisposableObject, IDevice
|
||||
}
|
||||
|
||||
Channel.Collects.Remove(this);
|
||||
if (Channel is IClientChannel clientChannel)
|
||||
{
|
||||
clientChannel.LogSeted(false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
_reusableTimeouts?.SafeDispose();
|
||||
@@ -1070,6 +1082,12 @@ public abstract class DeviceBase : AsyncAndSyncDisposableObject, IDevice
|
||||
}
|
||||
|
||||
Channel.Collects.Remove(this);
|
||||
|
||||
if (Channel is IClientChannel clientChannel)
|
||||
{
|
||||
clientChannel.LogSeted(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
_reusableTimeouts?.SafeDispose();
|
||||
|
@@ -11,8 +11,8 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="$(NET9Version)" />
|
||||
<PackageReference Include="TouchSocket" Version="4.0.0-beta.27" />
|
||||
<PackageReference Include="TouchSocket.SerialPorts" Version="4.0.0-beta.27" />
|
||||
<PackageReference Include="TouchSocket" Version="4.0.0-beta.28" />
|
||||
<PackageReference Include="TouchSocket.SerialPorts" Version="4.0.0-beta.28" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@@ -482,7 +482,6 @@ public abstract partial class CollectBase : DriverBase
|
||||
|
||||
protected virtual Task TestOnline(object? state, CancellationToken cancellationToken)
|
||||
{
|
||||
CurrentDevice.SetDeviceStatus(TimerX.Now, false, null);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
@@ -11,9 +11,9 @@
|
||||
<PackageReference Include="Riok.Mapperly" Version="4.2.1" ExcludeAssets="runtime" PrivateAssets="all" />
|
||||
<PackageReference Include="Rougamo.Fody" Version="5.0.1" />
|
||||
<PackageReference Include="System.Linq.Async" Version="6.0.3" />
|
||||
<PackageReference Include="TouchSocket.Dmtp" Version="4.0.0-beta.27" />
|
||||
<!--<PackageReference Include="TouchSocket.WebApi.Swagger" Version="4.0.0-beta.27" />-->
|
||||
<PackageReference Include="TouchSocket.WebApi" Version="4.0.0-beta.27" />
|
||||
<PackageReference Include="TouchSocket.Dmtp" Version="4.0.0-beta.28" />
|
||||
<!--<PackageReference Include="TouchSocket.WebApi.Swagger" Version="4.0.0-beta.28" />-->
|
||||
<PackageReference Include="TouchSocket.WebApi" Version="4.0.0-beta.28" />
|
||||
<PackageReference Include="ThingsGateway.Authentication" Version="$(AuthenticationVersion)" />
|
||||
<!--<ProjectReference Include="..\..\PluginPro\ThingsGateway.Authentication\ThingsGateway.Authentication.csproj" />-->
|
||||
|
||||
|
@@ -19,7 +19,6 @@ using Longbow.TcpSocket;
|
||||
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
using System.IO.Pipelines;
|
||||
using System.Net.Sockets;
|
||||
|
||||
using ThingsGateway.Foundation.Modbus;
|
||||
|
@@ -17,8 +17,6 @@ using HslCommunication.Profinet.Siemens;
|
||||
|
||||
using S7.Net;
|
||||
|
||||
using System.IO.Pipelines;
|
||||
|
||||
using ThingsGateway.Foundation.SiemensS7;
|
||||
|
||||
using TouchSocket.Core;
|
||||
|
@@ -20,9 +20,9 @@ namespace BenchmarkConsoleApp
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
public static int ClientCount = 50;
|
||||
public static int TaskNumberOfItems = 1;
|
||||
public static int NumberOfItems = 50;
|
||||
public static int ClientCount = 30;
|
||||
public static int TaskNumberOfItems = 30;
|
||||
public static int NumberOfItems = 30;
|
||||
|
||||
private static async Task Main(string[] args)
|
||||
{
|
||||
|
@@ -49,7 +49,7 @@
|
||||
<PackageReference Include="S7netplus" Version="0.20.0" />
|
||||
<!--<PackageReference Include="ThingsGateway.Foundation.Modbus" Version="$(DefaultVersion)" />
|
||||
<PackageReference Include="ThingsGateway.Foundation.SiemensS7" Version="$(DefaultVersion)" />-->
|
||||
<PackageReference Include="TouchSocket.Modbus" Version="4.0.0-beta.27" />
|
||||
<PackageReference Include="TouchSocket.Modbus" Version="4.0.0-beta.28" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@@ -28,14 +28,14 @@ public class ModbusTest
|
||||
|
||||
|
||||
[Theory]
|
||||
[InlineData("400045", true, "00010000002F01032C0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")]
|
||||
[InlineData("300045", true, "00010000002F01042C0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")]
|
||||
[InlineData("100045", true, "000100000009010206000000000000")]
|
||||
[InlineData("000045", true, "000100000009010106000000000000")]
|
||||
[InlineData("400045", false, "0001000000060106002C0001", "1", DataTypeEnum.UInt16)]
|
||||
[InlineData("000045", false, "0001000000060105002CFF00", "true", DataTypeEnum.Boolean)]
|
||||
[InlineData("400045;w=16", false, "0001000000090110002C0001020001", "1", DataTypeEnum.UInt16)]
|
||||
[InlineData("000045;w=15", false, "000100000008010F002C00010101", "true", DataTypeEnum.Boolean)]
|
||||
[InlineData("400045", true, "00020000002F01032C0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")]
|
||||
[InlineData("300045", true, "00020000002F01042C0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")]
|
||||
[InlineData("100045", true, "000200000009010206000000000000")]
|
||||
[InlineData("000045", true, "000200000009010106000000000000")]
|
||||
[InlineData("400045", false, "0002000000060106002C0001", "1", DataTypeEnum.UInt16)]
|
||||
[InlineData("000045", false, "0002000000060105002CFF00", "true", DataTypeEnum.Boolean)]
|
||||
[InlineData("400045;w=16", false, "0002000000090110002C0001020001", "1", DataTypeEnum.UInt16)]
|
||||
[InlineData("000045;w=15", false, "000200000008010F002C00010101", "true", DataTypeEnum.Boolean)]
|
||||
public async Task ModbusTcp_ReadWrite_OK(string address, bool read, string data, string writeData = null, DataTypeEnum dataTypeEnum = DataTypeEnum.UInt16)
|
||||
{
|
||||
var modbusChannel = new TouchSocketConfig().GetChannel(new ChannelOptions()
|
||||
|
@@ -29,8 +29,8 @@ public class SiemensS7Test
|
||||
|
||||
|
||||
[Theory]
|
||||
[InlineData("M100", true, "03 00 00 1B 02 F0 80 32 03 00 00 00 01 00 02 00 06 00 00 04 01 FF 04 00 10 00 00")]
|
||||
[InlineData("M100", false, "03 00 00 16 02 F0 80 32 03 00 00 00 01 00 02 00 01 00 00 05 01 FF", "1", DataTypeEnum.UInt16)]
|
||||
[InlineData("M100", true, "03 00 00 1B 02 F0 80 32 03 00 00 00 02 00 02 00 06 00 00 04 01 FF 04 00 10 00 00")]
|
||||
[InlineData("M100", false, "03 00 00 16 02 F0 80 32 03 00 00 00 02 00 02 00 01 00 00 05 01 FF", "1", DataTypeEnum.UInt16)]
|
||||
public async Task SiemensS7_ReadWrite_OK(string address, bool read, string data, string writeData = null, DataTypeEnum dataTypeEnum = DataTypeEnum.UInt16)
|
||||
{
|
||||
var siemensS7Channel = new TouchSocketConfig().GetChannel(new ChannelOptions()
|
||||
|
Reference in New Issue
Block a user