From 2ae36ddb40d28c62b64a2fdd4c3033e7d65d5cfb Mon Sep 17 00:00:00 2001 From: wei <kaede@kaededeMacBook-Air.local> Date: 星期四, 04 三月 2021 15:20:29 +0800 Subject: [PATCH] 2021-0304-1 --- HDL_ON/Entity/Function/Sensor.cs | 119 ++++++++++++++++++++++++----------------------------------- 1 files changed, 49 insertions(+), 70 deletions(-) diff --git a/HDL_ON/Entity/Function/Sensor.cs b/HDL_ON/Entity/Function/Sensor.cs index c8b1c7b..2e4d27c 100644 --- a/HDL_ON/Entity/Function/Sensor.cs +++ b/HDL_ON/Entity/Function/Sensor.cs @@ -15,21 +15,21 @@ get { int nameId = 0; - switch (functionType) + switch (spk) { - case FunctionType.PM25: + case SPK.SensorPm25: nameId = StringId.PM25; break; - case FunctionType.CO2: + case SPK.SensorCO2: nameId = StringId.CO2; break; - case FunctionType.Temp: + case SPK.SensorTemperature: nameId = StringId.Temp; break; - case FunctionType.TVOC: + case SPK.SensorTVOC: nameId = StringId.TVOC; break; - case FunctionType.Humidity: + case SPK.SensorHumidity: nameId = StringId.Humidity; break; } @@ -38,7 +38,7 @@ } [Newtonsoft.Json.JsonIgnore] - public Trait trait_values; + public FunctionAttributes trait_values; /// <summary> /// 鍊� /// </summary> @@ -49,48 +49,27 @@ { if (trait_values == null) { - trait_values = function.Find((obj) => obj.name == "values"); + trait_values = attributes.Find((obj) => obj.key == FunctionAttributeKey.Value); //鎵句笉鍒板睘鎬ч渶瑕佸0鏄庝竴涓紝闃叉鎶ラ敊闂�� if (trait_values == null) { - trait_values = new Trait() + trait_values = new FunctionAttributes() { - name = "values", - value_key = new List<string> { "29" }, + key = FunctionAttributeKey.Value, + value = new List<string> { "29" }, max = 10000, min = 0, }; - trait_values.value = trait_values.min; + 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.value = level; - } -#endif - } - return Convert.ToDouble(trait_values.value); + 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); } set { @@ -99,21 +78,21 @@ { if (trait_values == null) { - trait_values = function.Find((obj) => obj.name == "values"); + trait_values = attributes.Find((obj) => obj.key == FunctionAttributeKey.Value); //鎵句笉鍒板睘鎬ч渶瑕佸0鏄庝竴涓紝闃叉鎶ラ敊闂�� if (trait_values == null) { - trait_values = new Trait() + trait_values = new FunctionAttributes() { - name = "values", - value_key = new List<string> { "up" }, + key = FunctionAttributeKey.Value, + value = new List<string> { "up" }, max = 100, min = 0, }; } - trait_values.value = trait_values.min; + trait_values.curValue = trait_values.min; } - trait_values.value = value; + trait_values.curValue = value; MainPage.Log($"values 鏁版嵁鍒锋柊{value}."); } catch @@ -135,21 +114,21 @@ if (_intervalValue == null) { _intervalValue = new List<string>(); - switch (functionType) + switch (spk) { - case FunctionType.PM25: + case SPK.SensorPm25: _intervalValue.Add("0 ~ 35"); _intervalValue.Add("36 ~ 75"); _intervalValue.Add("76 ~ 115"); _intervalValue.Add("115 ~"); break; - case FunctionType.CO2: + case SPK.SensorCO2: _intervalValue.Add("0 ~ 1000"); _intervalValue.Add("1001 ~ 2000"); _intervalValue.Add("2001 ~ 5000"); _intervalValue.Add("5001 ~"); break; - case FunctionType.Temp: + case SPK.SensorTemperature: _intervalValue.Add("~ 18掳C"); _intervalValue.Add("18 ~ 20掳C"); _intervalValue.Add("20 ~ 25掳C"); @@ -158,13 +137,13 @@ _intervalValue.Add("30 ~ 33掳C"); _intervalValue.Add("33掳C ~"); break; - case FunctionType.TVOC: + case SPK.SensorTVOC: _intervalValue.Add("0 ~ 0.6"); _intervalValue.Add("0.61 ~ 2"); _intervalValue.Add("2.01 ~ 5"); _intervalValue.Add("5 ~"); break; - case FunctionType.Humidity: + case SPK.SensorHumidity: _intervalValue.Add("70 ~"); _intervalValue.Add("71 ~ 40"); _intervalValue.Add("0 ~ 39"); @@ -188,21 +167,21 @@ if (_levelColorList == null) { _levelColorList = new List<uint>(); - switch (functionType) + switch (spk) { - case FunctionType.PM25: + case SPK.SensorPm25: _levelColorList.Add(0xFFADE764); _levelColorList.Add(0xFFFFD154); _levelColorList.Add(0xFFFF9D54); _levelColorList.Add(0xFFFF3D3D); break; - case FunctionType.CO2: + case SPK.SensorCO2: _levelColorList.Add(0xFFADE764); _levelColorList.Add(0xFFFFD154); _levelColorList.Add(0xFFFF9D54); _levelColorList.Add(0xFFFF3D3D); break; - case FunctionType.Temp: + case SPK.SensorTemperature: _levelColorList.Add(0xFF2172FF); _levelColorList.Add(0xCC4484F4); _levelColorList.Add(0x7F4484F4); @@ -211,14 +190,14 @@ _levelColorList.Add(0xFFFF9D54); _levelColorList.Add(0xFFFF3D3D); break; - case FunctionType.TVOC: + case SPK.SensorTVOC: _levelColorList.Add(0xFFADE764); _levelColorList.Add(0xFFFFD154); _levelColorList.Add(0xFFFF9D54); _levelColorList.Add(0xFFFF3D3D); break; - case FunctionType.Humidity: + case SPK.SensorHumidity: _levelColorList.Add(0xFF2172FF); _levelColorList.Add(0xFFADE764); _levelColorList.Add(0xFFFF3D3D); @@ -244,21 +223,21 @@ if (_levelTextList == null) { _levelTextList = new List<int>(); - switch (functionType) + switch (spk) { - case FunctionType.PM25: + case SPK.SensorPm25: _levelTextList.Add(StringId.Great); _levelTextList.Add(StringId.Good); _levelTextList.Add(StringId.MildPollution); _levelTextList.Add(StringId.HeavyPollution); break; - case FunctionType.CO2: + case SPK.SensorCO2: _levelTextList.Add(StringId.SensorReferenceTipCO2Level1); _levelTextList.Add(StringId.SensorReferenceTipCO2Level2); _levelTextList.Add(StringId.SensorReferenceTipCO2Level3); _levelTextList.Add(StringId.SensorReferenceTipCO2Level4); break; - case FunctionType.Temp: + case SPK.SensorTemperature: _levelTextList.Add(StringId.ExtremelyCold); _levelTextList.Add(StringId.Cold); _levelTextList.Add(StringId.SlightlyCold); @@ -269,14 +248,14 @@ break; - case FunctionType.TVOC: + case SPK.SensorTVOC: _levelTextList.Add(StringId.SensorReferenceTVOCTipLevel1); _levelTextList.Add(StringId.SensorReferenceTVOCTipLevel2); _levelTextList.Add(StringId.SensorReferenceTVOCTipLevel3); _levelTextList.Add(StringId.SensorReferenceTVOCTipLevel4); break; - case FunctionType.Humidity: + case SPK.SensorHumidity: _levelTextList.Add(StringId.SensorReferenceHumidityTipLevel1); _levelTextList.Add(StringId.SensorReferenceHumidityTipLevel2); _levelTextList.Add(StringId.SensorReferenceHumidityTipLevel3); @@ -295,9 +274,9 @@ get { int level = 1; - switch (functionType) + switch (spk) { - case FunctionType.PM25: + case SPK.SensorPm25: if (values < 35) level = 1; else if (values < 75) @@ -307,7 +286,7 @@ else if (values > 115) level = 4; break; - case FunctionType.CO2: + case SPK.SensorCO2: if (values < 1000) level = 1; else if (values < 2000) @@ -317,7 +296,7 @@ else if (values > 5000) level = 4; break; - case FunctionType.Temp: + case SPK.SensorTemperature: if (values < 18) level = 1; else if (values < 20) @@ -333,7 +312,7 @@ else if (values > 33) level = 7; break; - case FunctionType.TVOC: + case SPK.SensorTVOC: if (values < 0.6) level = 1; else if (values < 2) @@ -343,7 +322,7 @@ else if (values > 5) level = 4; break; - case FunctionType.Humidity: + case SPK.SensorHumidity: if (values > 70) level = 1; else if (values > 40) -- Gitblit v1.8.0