release:6.0.3.60
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
<BodyTemplate>
|
||||
@foreach (var menu in AppContext.UserWorkbenchOutputs ?? new List<SysResource>())
|
||||
{
|
||||
<LinkButton Url="@menu.Href" Target="@menu.Target.ToString()" Color="Color.Primary">
|
||||
<LinkButton class="mx-2" Url="@menu.Href" Target="@menu.Target.ToString()" Color="Color.Primary">
|
||||
<i class="@menu.Icon"></i>
|
||||
<span>@menu.Title</span>
|
||||
</LinkButton>
|
||||
|
||||
@@ -54,72 +54,82 @@ public class ProtocolSingleStreamDataHandleAdapter<TRequest> : CustomDataHandlin
|
||||
{
|
||||
if (Logger.LogLevel <= LogLevel.Trace)
|
||||
Logger?.Trace($"{ToString()}- Receive:{(IsHexData ? byteBlock.AsSegmentTake().ToHexString() : byteBlock.ToString(byteBlock.Position))}");
|
||||
|
||||
try
|
||||
{
|
||||
//非并发协议,复用对象
|
||||
if (IsSingleThread)
|
||||
request = Request == null ? GetInstance() : Request;
|
||||
else
|
||||
{
|
||||
if (!beCached)
|
||||
request = GetInstance();
|
||||
}
|
||||
|
||||
var pos = byteBlock.Position;
|
||||
|
||||
if (request.HeaderLength > byteBlock.CanReadLength)
|
||||
{
|
||||
return FilterResult.Cache;//当头部都无法解析时,直接缓存
|
||||
}
|
||||
|
||||
//检查头部合法性
|
||||
if (request.CheckHead(ref byteBlock))
|
||||
{
|
||||
byteBlock.Position = pos;
|
||||
if (request.BodyLength > this.MaxPackageSize)
|
||||
//非并发协议,复用对象
|
||||
if (IsSingleThread)
|
||||
request = Request == null ? GetInstance() : Request;
|
||||
else
|
||||
{
|
||||
this.OnError(default, $"Received BodyLength={request.BodyLength}, greater than the set MaxPackageSize={this.MaxPackageSize}", true, true);
|
||||
return FilterResult.GoOn;
|
||||
if (!beCached)
|
||||
request = GetInstance();
|
||||
}
|
||||
if (request.BodyLength + request.HeaderLength > byteBlock.CanReadLength)
|
||||
|
||||
var pos = byteBlock.Position;
|
||||
|
||||
if (request.HeaderLength > byteBlock.CanReadLength)
|
||||
{
|
||||
//body不满足解析,开始缓存,然后保存对象
|
||||
tempCapacity = request.BodyLength + request.HeaderLength;
|
||||
return FilterResult.Cache;
|
||||
return FilterResult.Cache;//当头部都无法解析时,直接缓存
|
||||
}
|
||||
//if (request.BodyLength <= 0)
|
||||
//{
|
||||
// //如果body长度无法确定,直接读取全部
|
||||
// request.BodyLength = byteBlock.Length;
|
||||
//}
|
||||
var headPos = pos + request.HeaderLength;
|
||||
byteBlock.Position = headPos;
|
||||
var result = request.CheckBody(ref byteBlock);
|
||||
if (result == FilterResult.Cache)
|
||||
|
||||
//检查头部合法性
|
||||
if (request.CheckHead(ref byteBlock))
|
||||
{
|
||||
if (Logger.LogLevel <= LogLevel.Trace)
|
||||
Logger.Trace($"{ToString()}-Received incomplete, cached message, current length:{byteBlock.Length} {request?.ErrorMessage}");
|
||||
tempCapacity = request.BodyLength + request.HeaderLength;
|
||||
byteBlock.Position = pos;
|
||||
if (request.BodyLength > this.MaxPackageSize)
|
||||
{
|
||||
this.OnError(default, $"Received BodyLength={request.BodyLength}, greater than the set MaxPackageSize={this.MaxPackageSize}", true, true);
|
||||
return FilterResult.GoOn;
|
||||
}
|
||||
if (request.BodyLength + request.HeaderLength > byteBlock.CanReadLength)
|
||||
{
|
||||
//body不满足解析,开始缓存,然后保存对象
|
||||
tempCapacity = request.BodyLength + request.HeaderLength;
|
||||
return FilterResult.Cache;
|
||||
}
|
||||
//if (request.BodyLength <= 0)
|
||||
//{
|
||||
// //如果body长度无法确定,直接读取全部
|
||||
// request.BodyLength = byteBlock.Length;
|
||||
//}
|
||||
var headPos = pos + request.HeaderLength;
|
||||
byteBlock.Position = headPos;
|
||||
var result = request.CheckBody(ref byteBlock);
|
||||
if (result == FilterResult.Cache)
|
||||
{
|
||||
if (Logger.LogLevel <= LogLevel.Trace)
|
||||
Logger.Trace($"{ToString()}-Received incomplete, cached message, current length:{byteBlock.Length} {request?.ErrorMessage}");
|
||||
tempCapacity = request.BodyLength + request.HeaderLength;
|
||||
request.OperCode = -1;
|
||||
}
|
||||
else if (result == FilterResult.GoOn)
|
||||
{
|
||||
if (byteBlock.Position == headPos)
|
||||
byteBlock.Position += 1;
|
||||
request.OperCode = -1;
|
||||
}
|
||||
else if (result == FilterResult.Success)
|
||||
{
|
||||
byteBlock.Position = request.HeaderLength + request.BodyLength + pos;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
byteBlock.Position = byteBlock.Length;//移动游标
|
||||
request.OperCode = -1;
|
||||
return FilterResult.GoOn;//放弃解析
|
||||
}
|
||||
else if (result == FilterResult.GoOn)
|
||||
{
|
||||
if (byteBlock.Position == headPos)
|
||||
byteBlock.Position += 1;
|
||||
request.OperCode = -1;
|
||||
}
|
||||
else if (result == FilterResult.Success)
|
||||
{
|
||||
byteBlock.Position = request.HeaderLength + request.BodyLength + pos;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
byteBlock.Position = byteBlock.Length;//移动游标
|
||||
request.OperCode = -1;
|
||||
return FilterResult.GoOn;//放弃解析
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger?.LogWarning(ex, $"{ToString()} Received parsing error");
|
||||
byteBlock.Position = byteBlock.Length;//移动游标
|
||||
return FilterResult.GoOn;//放弃解析
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -67,70 +67,79 @@ public class ProtocolUdpDataHandleAdapter<TRequest> : UdpDataHandlingAdapter whe
|
||||
/// <inheritdoc/>
|
||||
protected override async Task PreviewReceived(EndPoint remoteEndPoint, ByteBlock byteBlock)
|
||||
{
|
||||
if (Logger.LogLevel <= LogLevel.Trace)
|
||||
Logger?.Trace($"{ToString()}- Receive:{(IsHexData ? byteBlock.AsSegmentTake().ToHexString() : byteBlock.ToString(byteBlock.Position))}");
|
||||
|
||||
TRequest request = null;
|
||||
if (IsSingleThread)
|
||||
request = Request == null ? GetInstance() : Request;
|
||||
else
|
||||
try
|
||||
{
|
||||
request = GetInstance();
|
||||
}
|
||||
if (Logger.LogLevel <= LogLevel.Trace)
|
||||
Logger?.Trace($"{ToString()}- Receive:{(IsHexData ? byteBlock.AsSegmentTake().ToHexString() : byteBlock.ToString(byteBlock.Position))}");
|
||||
|
||||
var pos = byteBlock.Position;
|
||||
|
||||
if (request.HeaderLength > byteBlock.CanReadLength)
|
||||
{
|
||||
return;//当头部都无法解析时,直接缓存
|
||||
}
|
||||
|
||||
//检查头部合法性
|
||||
if (request.CheckHead(ref byteBlock))
|
||||
{
|
||||
byteBlock.Position = pos;
|
||||
|
||||
if (request.BodyLength > this.MaxPackageSize)
|
||||
TRequest request = null;
|
||||
if (IsSingleThread)
|
||||
request = Request == null ? GetInstance() : Request;
|
||||
else
|
||||
{
|
||||
this.OnError(default, $"Received BodyLength={request.BodyLength}, greater than the set MaxPackageSize={this.MaxPackageSize}", true, true);
|
||||
request = GetInstance();
|
||||
}
|
||||
|
||||
var pos = byteBlock.Position;
|
||||
|
||||
if (request.HeaderLength > byteBlock.CanReadLength)
|
||||
{
|
||||
return;//当头部都无法解析时,直接缓存
|
||||
}
|
||||
|
||||
//检查头部合法性
|
||||
if (request.CheckHead(ref byteBlock))
|
||||
{
|
||||
byteBlock.Position = pos;
|
||||
|
||||
if (request.BodyLength > this.MaxPackageSize)
|
||||
{
|
||||
this.OnError(default, $"Received BodyLength={request.BodyLength}, greater than the set MaxPackageSize={this.MaxPackageSize}", true, true);
|
||||
return;
|
||||
}
|
||||
if (request.BodyLength + request.HeaderLength > byteBlock.CanReadLength)
|
||||
{
|
||||
//body不满足解析,开始缓存,然后保存对象
|
||||
return;
|
||||
}
|
||||
//if (request.BodyLength <= 0)
|
||||
//{
|
||||
// //如果body长度无法确定,直接读取全部
|
||||
// request.BodyLength = byteBlock.Length;
|
||||
//}
|
||||
var headPos = pos + request.HeaderLength;
|
||||
byteBlock.Position = headPos;
|
||||
var result = request.CheckBody(ref byteBlock);
|
||||
if (result == FilterResult.Cache)
|
||||
{
|
||||
if (Logger.LogLevel <= LogLevel.Trace)
|
||||
Logger.Trace($"{ToString()}-Received incomplete, cached message, current length:{byteBlock.Length} {request?.ErrorMessage}");
|
||||
request.OperCode = -1;
|
||||
}
|
||||
else if (result == FilterResult.GoOn)
|
||||
{
|
||||
if (byteBlock.Position == headPos)
|
||||
byteBlock.Position += 1;
|
||||
request.OperCode = -1;
|
||||
}
|
||||
else if (result == FilterResult.Success)
|
||||
{
|
||||
byteBlock.Position = request.HeaderLength + request.BodyLength + pos;
|
||||
await GoReceived(remoteEndPoint, null, request);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (request.BodyLength + request.HeaderLength > byteBlock.CanReadLength)
|
||||
else
|
||||
{
|
||||
//body不满足解析,开始缓存,然后保存对象
|
||||
byteBlock.Position = byteBlock.Length;//移动游标
|
||||
request.OperCode = -1;
|
||||
return;
|
||||
}
|
||||
//if (request.BodyLength <= 0)
|
||||
//{
|
||||
// //如果body长度无法确定,直接读取全部
|
||||
// request.BodyLength = byteBlock.Length;
|
||||
//}
|
||||
var headPos = pos + request.HeaderLength;
|
||||
byteBlock.Position = headPos;
|
||||
var result = request.CheckBody(ref byteBlock);
|
||||
if (result == FilterResult.Cache)
|
||||
{
|
||||
if (Logger.LogLevel <= LogLevel.Trace)
|
||||
Logger.Trace($"{ToString()}-Received incomplete, cached message, current length:{byteBlock.Length} {request?.ErrorMessage}");
|
||||
request.OperCode = -1;
|
||||
}
|
||||
else if (result == FilterResult.GoOn)
|
||||
{
|
||||
if (byteBlock.Position == headPos)
|
||||
byteBlock.Position += 1;
|
||||
request.OperCode = -1;
|
||||
}
|
||||
else if (result == FilterResult.Success)
|
||||
{
|
||||
byteBlock.Position = request.HeaderLength + request.BodyLength + pos;
|
||||
await GoReceived(remoteEndPoint, null, request);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger?.LogWarning(ex, $"{ToString()} Received parsing error");
|
||||
byteBlock.Position = byteBlock.Length;//移动游标
|
||||
request.OperCode = -1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ public class DtuPlugin : PluginBase, ITcpReceivingPlugin
|
||||
if (DtuService.HeartbeatHexString == e.ByteBlock.AsSegment(0, len).ToHexString(default))
|
||||
{
|
||||
await socket.WaitLock.WaitOneAsync();
|
||||
await Task.Delay(500);
|
||||
|
||||
//回应心跳包
|
||||
await socket.SendAsync(e.ByteBlock.AsSegment());
|
||||
@@ -62,7 +63,7 @@ public class DtuPlugin : PluginBase, ITcpReceivingPlugin
|
||||
if (socket.Logger.LogLevel <= LogLevel.Trace)
|
||||
socket.Logger?.Trace($"{socket}- Heartbeat");
|
||||
|
||||
await Task.Delay(1000);
|
||||
await Task.Delay(500);
|
||||
socket.WaitLock.Reset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="8.0.6" />
|
||||
<PackageReference Include="TouchSocket" Version="2.1.0-alpha.23" />
|
||||
<PackageReference Include="TouchSocket.SerialPorts" Version="2.1.0-alpha.23" />
|
||||
<PackageReference Include="TouchSocket" Version="2.1.0-alpha.24" />
|
||||
<PackageReference Include="TouchSocket.SerialPorts" Version="2.1.0-alpha.24" />
|
||||
<ProjectReference Include="$(SolutionDir)\ThingsGateway.NewLife.X\ThingsGateway.NewLife.X.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<PackageReference Include="SqlSugar.TDengineCore" Version="4.18.0" />
|
||||
<PackageReference Include="Rougamo.Fody" Version="3.0.0" />
|
||||
<PackageReference Include="CS-Script" Version="4.8.16" />
|
||||
<PackageReference Include="TouchSocket.Dmtp" Version="2.1.0-alpha.23" />
|
||||
<PackageReference Include="TouchSocket.Dmtp" Version="2.1.0-alpha.24" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -186,7 +186,7 @@ public partial class LogConsole : IDisposable
|
||||
var result = TextFileReader.LastLog(files.FirstOrDefault().FullName, 0);
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
Messages = result.Content.Select(a => new LogMessage((int)a.LogLevel, $"{a.LogTime} - {a.Message}{(a.ExceptionString.IsNullOrWhiteSpace() ? null : $"-{a.ExceptionString}")}")).ToList();
|
||||
Messages = result.Content.Select(a => new LogMessage((int)a.LogLevel, $"{a.LogTime} - {a.Message}{(a.ExceptionString.IsNullOrWhiteSpace() ? null : $"{Environment.NewLine}{a.ExceptionString}")}")).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<BodyTemplate>
|
||||
@foreach (var menu in AppContext.UserWorkbenchOutputs ?? new List<SysResource>())
|
||||
{
|
||||
<LinkButton Url="@menu.Href" Target="@menu.Target.ToString()" Color="Color.Primary">
|
||||
<LinkButton class="mx-2" Url="@menu.Href" Target="@menu.Target.ToString()" Color="Color.Primary">
|
||||
<i class="@menu.Icon"></i>
|
||||
<span>@menu.Title</span>
|
||||
</LinkButton>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<Version>6.0.3.59</Version>
|
||||
<Version>6.0.3.60</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<PackageReference Include="ThingsGateway.Foundation.SiemensS7" Version="6.0.3.57" />
|
||||
<PackageReference Include="ThingsGateway.Foundation.Variable" Version="8.6.0" />
|
||||
<PackageReference Include="ThingsGateway.Foundation.Modbus" Version="6.0.3.57" />
|
||||
<PackageReference Include="TouchSocket.Modbus" Version="2.1.0-alpha.23" />
|
||||
<PackageReference Include="TouchSocket.Modbus" Version="2.1.0-alpha.24" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user