优化采集

This commit is contained in:
iioter 2022-10-14 13:29:41 +08:00
parent 93862348c0
commit cbdf3a99cb
2 changed files with 6 additions and 12 deletions

View File

@ -41,7 +41,6 @@ namespace Plugin
if (Device.AutoStart)
{
_logger.LogInformation($"线程已启动:{Device.DeviceName}");
Thread.Sleep(8000);
if (Device.DeviceVariables != null)
{
@ -53,6 +52,7 @@ namespace Plugin
_task = Task.Factory.StartNew(() =>
{
Thread.Sleep(8000);
//上传客户端属性
myMqttClient.UploadAttributeAsync(device.DeviceName,
device.DeviceConfigs.Where(x => x.DataSide == DataSide.ClientSide)
@ -151,10 +151,12 @@ namespace Plugin
payLoad.TS = (long)(DateTime.UtcNow - _tsStartDt).TotalMilliseconds;
if (DeviceValues.Any(x => x.Value.Value == null))
if (DeviceValues.All(x =>
x.Value.StatusType == VaribaleStatusTypeEnum.Good))
{
payLoad.Values = null;
payLoad.DeviceStatus = DeviceStatusTypeEnum.Bad;
payLoad.DeviceStatus = DeviceStatusTypeEnum.Good;
sendModel[Device.DeviceName] = new List<PayLoad> { payLoad };
myMqttClient.PublishTelemetryAsync(Device, sendModel).Wait();
}
else if (DeviceValues.Any(x =>
x.Value.StatusType == VaribaleStatusTypeEnum.Bad))
@ -167,12 +169,6 @@ namespace Plugin
_myMqttClient?.DeviceDisconnected(Device);
}
else
{
payLoad.DeviceStatus = DeviceStatusTypeEnum.Good;
sendModel[Device.DeviceName] = new List<PayLoad> { payLoad };
myMqttClient.PublishTelemetryAsync(Device, sendModel);
}
}
}
else

View File

@ -4,8 +4,6 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<ServerGarbageCollection>false</ServerGarbageCollection>
<ConcurrentGarbageCollection>true</ConcurrentGarbageCollection>
</PropertyGroup>
<ItemGroup>