From 474783457240f62d4f926e628fea2abb1c4b8b0d Mon Sep 17 00:00:00 2001
From: wei <kaede@kaededeMacBook-Air.local>
Date: 星期一, 11 十月 2021 14:53:37 +0800
Subject: [PATCH] spk更新异常,安防中心传感器状态无显示

---
 HDL_ON/Entity/Function/Sensor.cs |   29 ++++++++++++++++++++++++++++-
 1 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/HDL_ON/Entity/Function/Sensor.cs b/HDL_ON/Entity/Function/Sensor.cs
index a51a61c..82ed611 100644
--- a/HDL_ON/Entity/Function/Sensor.cs
+++ b/HDL_ON/Entity/Function/Sensor.cs
@@ -38,7 +38,34 @@
         /// </summary>
         public double GetValues(Function function)
         {
-            var value = function.GetAttrState(FunctionAttributeKey.Value);
+            FunctionAttributes attr = function.GetAttribute(FunctionAttributeKey.Value);
+            if (attr == null)
+            {
+                switch (function.spk)
+                {
+                    case SPK.SensorCO2:
+                        attr = function.GetAttribute(FunctionAttributeKey.Co2);
+                        break;
+                    case SPK.SensorTemperature:
+                        attr = function.GetAttribute(FunctionAttributeKey.Temperature);
+                        break;
+                    case SPK.SensorTVOC:
+                        attr = function.GetAttribute(FunctionAttributeKey.Tvoc);
+                        break;
+                    case SPK.SensorPm25:
+                        attr = function.GetAttribute(FunctionAttributeKey.Pm25);
+                        break;
+                    case SPK.SensorHcho:
+                        attr = function.GetAttribute(FunctionAttributeKey.Hcho);
+                        break;
+                    case SPK.SensorHumidity:
+                        attr = function.GetAttribute(FunctionAttributeKey.Humidity);
+                        break;
+                }
+            }
+            double value = 0.0;
+            double.TryParse( attr.state,out value);
+
             return Convert.ToDouble(value);
         }
         /// <summary>

--
Gitblit v1.8.0