From cbdf3a99cbcaea7b7cae74e376bcfd0544b4b37d Mon Sep 17 00:00:00 2001 From: iioter <535915157@qq.com> Date: Fri, 14 Oct 2022 13:29:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=87=87=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Plugins/Plugin/DeviceThread.cs | 16 ++++++---------- Plugins/Plugin/Plugin.csproj | 2 -- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Plugins/Plugin/DeviceThread.cs b/Plugins/Plugin/DeviceThread.cs index 9a2d049..ecc22f9 100644 --- a/Plugins/Plugin/DeviceThread.cs +++ b/Plugins/Plugin/DeviceThread.cs @@ -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 }; + 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 }; - myMqttClient.PublishTelemetryAsync(Device, sendModel); - } } } else diff --git a/Plugins/Plugin/Plugin.csproj b/Plugins/Plugin/Plugin.csproj index 5b7286d..5758b1f 100644 --- a/Plugins/Plugin/Plugin.csproj +++ b/Plugins/Plugin/Plugin.csproj @@ -4,8 +4,6 @@ net6.0 enable enable - false - true