update code collation

This commit is contained in:
2248356998 qq.com
2023-03-27 08:49:10 +08:00
parent 6b96aff6e8
commit 55f267d0fc
3 changed files with 6 additions and 3 deletions

View File

@@ -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;

View File

@@ -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;
}
}

View File

@@ -270,6 +270,7 @@ public class CollectDeviceHostService : BackgroundService
_logger?.LogError(ex, device.Name);
}
}
await Task.Delay(2000);
await base.StopAsync(cancellationToken);
}
private CancellationToken _stoppingToken;