From 83d3a5b39efa7bea47ed418cab8ebc2f9fec8b14 Mon Sep 17 00:00:00 2001 From: wei <kaede@kaededeMacBook-Air.local> Date: 星期三, 23 十二月 2020 12:44:24 +0800 Subject: [PATCH] 20201223-4 --- HDL_ON/Entity/Function/Sensor.cs | 41 ++++++++++------------------------------- 1 files changed, 10 insertions(+), 31 deletions(-) diff --git a/HDL_ON/Entity/Function/Sensor.cs b/HDL_ON/Entity/Function/Sensor.cs index 598d621..17475e4 100644 --- a/HDL_ON/Entity/Function/Sensor.cs +++ b/HDL_ON/Entity/Function/Sensor.cs @@ -49,46 +49,25 @@ { if (trait_values == null) { - trait_values = function.Find((obj) => obj.key == "values"); + trait_values = attributes.Find((obj) => obj.key == FunctionAttributeKey.Value); //鎵句笉鍒板睘鎬ч渶瑕佸0鏄庝竴涓紝闃叉鎶ラ敊闂�� if (trait_values == null) { trait_values = new FunctionAttributes() { - key = "values", + key = FunctionAttributeKey.Value, value = new List<string> { "29" }, max = 10000, min = 0, }; trait_values.curValue = trait_values.min; } -#if DEBUG - //if ( Convert.ToInt32(trait_values.value) == 0) - { - double level = 1; - Random random = new Random(); - switch (functionType) - { - case FunctionType.PM25: - level = Math.Round(random.NextDouble() * 130, 0); - break; - case FunctionType.CO2: - level = Math.Round(random.NextDouble() * 6000, 0); - break; - case FunctionType.Temp: - level = Math.Round(random.NextDouble() * 40, 0); - break; - case FunctionType.TVOC: - level = Math.Round(random.NextDouble() * 10, 1); - break; - case FunctionType.Humidity: - level = Math.Round(random.NextDouble() * 100, 0); - break; - } - trait_values.curValue = level; - } -#endif - + } + if (trait_values.curValue.ToString() == "{}") + trait_values.curValue = 0; + if(spk == SPK.SensorTVOC) + { + return Convert.ToDouble(trait_values.curValue.ToString()) / 100000; } return Convert.ToDouble(trait_values.curValue); } @@ -99,13 +78,13 @@ { if (trait_values == null) { - trait_values = function.Find((obj) => obj.key == "values"); + trait_values = attributes.Find((obj) => obj.key == FunctionAttributeKey.Value); //鎵句笉鍒板睘鎬ч渶瑕佸0鏄庝竴涓紝闃叉鎶ラ敊闂�� if (trait_values == null) { trait_values = new FunctionAttributes() { - key = "values", + key = FunctionAttributeKey.Value, value = new List<string> { "up" }, max = 100, min = 0, -- Gitblit v1.8.0