mirror of
https://gitee.com/ThingsGateway/ThingsGateway.git
synced 2025-11-02 16:43:59 +08:00
update code collation
This commit is contained in:
@@ -165,7 +165,7 @@ namespace ThingsGateway.Foundation
|
||||
return SendThenResponse(byteBlock.Buffer, 0, byteBlock.Len, timeout, token);
|
||||
}
|
||||
/// <summary>
|
||||
/// 异步发送
|
||||
/// 异步发送,,非线程安全
|
||||
/// </summary>
|
||||
/// <param name="buffer">数据缓存区</param>
|
||||
/// <param name="offset">偏移</param>
|
||||
@@ -178,6 +178,7 @@ namespace ThingsGateway.Foundation
|
||||
/// <returns>返回的数据</returns>
|
||||
public async Task<ResponsedData> SendThenResponseAsync(byte[] buffer, int offset, int length, int timeout = 1000 * 5, CancellationToken token = default)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
breaked = false;
|
||||
|
||||
@@ -202,17 +202,18 @@ public class CollectDeviceCore : DisposableObject
|
||||
break;
|
||||
|
||||
//连读变量
|
||||
var readTime = DateTime.Now;
|
||||
if (deviceVariableSourceRead.CheckIfRequestAndUpdateTime(DateTime.Now))
|
||||
{
|
||||
var read = await _driver.ReadSourceAsync(deviceVariableSourceRead, StoppingToken.Token);
|
||||
if (read != null && read.IsSuccess)
|
||||
{
|
||||
_logger?.LogTrace(_device.Name + "采集[" + deviceVariableSourceRead.Address + " -" + deviceVariableSourceRead.Length + "] 数据成功" + read.Content?.ToHexString(" "));
|
||||
_logger?.LogTrace(_device.Name +" - "+ readTime+" - 采集[" + deviceVariableSourceRead.Address + " - " + deviceVariableSourceRead.Length + "] 数据成功" + read.Content?.ToHexString(" "));
|
||||
deviceSourceVariableSuccessNum += 1;
|
||||
}
|
||||
else if (read != null && read.IsSuccess == false)
|
||||
{
|
||||
_logger?.LogWarning(_device.Name + "采集[" + deviceVariableSourceRead.Address + " -" + deviceVariableSourceRead.Length + "] 数据失败 - " + read?.Message);
|
||||
_logger?.LogWarning(_device.Name +" - "+ readTime+ " - 采集[" + deviceVariableSourceRead.Address + " -" + deviceVariableSourceRead.Length + "] 数据失败 - " + read?.Message);
|
||||
deviceSourceVariableFailedNum += 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,6 +270,7 @@ public class CollectDeviceHostService : BackgroundService
|
||||
_logger?.LogError(ex, device.Name);
|
||||
}
|
||||
}
|
||||
await Task.Delay(2000);
|
||||
await base.StopAsync(cancellationToken);
|
||||
}
|
||||
private CancellationToken _stoppingToken;
|
||||
|
||||
Reference in New Issue
Block a user