From cbc156bc38d8b8eae7aef60cb186ab2b52fa701f Mon Sep 17 00:00:00 2001 From: wxr <wxr@hdlchina.com.cn> Date: 星期二, 16 七月 2024 13:59:56 +0800 Subject: [PATCH] 增加全部挂断 --- HDL_ON/Entity/Function/Sensor.cs | 274 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 237 insertions(+), 37 deletions(-) diff --git a/HDL_ON/Entity/Function/Sensor.cs b/HDL_ON/Entity/Function/Sensor.cs index 82ed611..1cf5bab 100644 --- a/HDL_ON/Entity/Function/Sensor.cs +++ b/HDL_ON/Entity/Function/Sensor.cs @@ -1,5 +1,7 @@ 锘縰sing System; using System.Collections.Generic; +using Newtonsoft.Json.Linq; +using Shared; namespace HDL_ON.Entity { @@ -61,10 +63,14 @@ case SPK.SensorHumidity: attr = function.GetAttribute(FunctionAttributeKey.Humidity); break; + case SPK.SensorPm10: + attr = function.GetAttribute(FunctionAttributeKey.Pm10); + break; + } } double value = 0.0; - double.TryParse( attr.state,out value); + double.TryParse(attr.state, out value); return Convert.ToDouble(value); } @@ -78,15 +84,37 @@ function.SetAttrState(FunctionAttributeKey.Value, value); } + /// <summary> /// 姣忎釜绛夌骇瀵瑰尯闂村�� /// </summary> - public List<string> GetIntervalValue(string spk) + public List<string> GetIntervalValue(Function function) { - var _intervalValue = new List<string>(); - switch (spk) + List<string> _intervalValue = new List<string>(); + if (function.attrKeyConfigs.Count > 0) + { + foreach (var attrKey in function.attrKeyConfigs) + { + if (function.spk.Replace(".", "").Contains(attrKey.key.Replace(".", ""))) + { + foreach (var info in attrKey.configs) + { + _intervalValue.Add(info.start + " ~ " + info.end); + } + return _intervalValue; + } + } + } + + switch (function.spk) { case SPK.SensorPm25: + _intervalValue.Add("0 ~ 50"); + _intervalValue.Add("51 ~ 100"); + _intervalValue.Add("101 ~ 150"); + _intervalValue.Add("151 ~"); + break; + case SPK.SensorPm10: _intervalValue.Add("0 ~ 35"); _intervalValue.Add("36 ~ 75"); _intervalValue.Add("76 ~ 115"); @@ -128,13 +156,69 @@ return _intervalValue; } + public string Unit(Function function) + { + string unit = ""; + + if (function.attrKeyConfigs.Count > 0) + { + foreach (var attrKey in function.attrKeyConfigs) + { + if (function.spk.Replace(".", "").Contains(attrKey.key.Replace(".", ""))) + { + if (!string.IsNullOrEmpty(attrKey.unit)) + return attrKey.unit; + } + } + } + + switch (function.spk) + { + case SPK.SensorPm25: + unit = "ug/m鲁"; + break; + case SPK.SensorTemperature: + unit = "掳C"; + break; + case SPK.SensorTVOC: + unit = "mg/m鲁"; + break; + case SPK.SensorCO2: + unit = "PPM"; + break; + case SPK.SensorHumidity: + unit = "%"; + break; + case SPK.SensorHcho: + unit = "mg/m3"; + break; + } + + return unit; + } + /// <summary> /// 姣忎釜绛夌骇鐨勯鑹插�� /// </summary> - public List<uint> GetLevelColorList(string spk) + public List<uint> GetLevelColorList(Function function) { var _levelColorList = new List<uint>(); - switch (spk) + if (function.attrKeyConfigs.Count > 0) + { + foreach (var attrKey in function.attrKeyConfigs) + { + if (function.spk.Replace(".", "").Contains(attrKey.key.Replace(".", ""))) + { + foreach (var info in attrKey.configs) + { + _levelColorList.Add(Convert.ToUInt32(info.color, 16)); + } + return _levelColorList; + } + } + } + + switch (function.spk) { case SPK.SensorPm25: _levelColorList.Add(0xFFADE764); @@ -158,6 +242,7 @@ _levelColorList.Add(0xFFFF3D3D); break; case SPK.SensorTVOC: + case SPK.SensorPm10: _levelColorList.Add(0xFFADE764); _levelColorList.Add(0xFFFFD154); _levelColorList.Add(0xFFFF9D54); @@ -187,56 +272,136 @@ /// <summary> /// 姣忎釜绛夌骇鐨勫悕绉� /// </summary> - public List<int> GetLevelTextList(string spk) + public List<string> GetLevelTextList(Function function) { - var _levelTextList = new List<int>(); - switch (spk) + var _levelTextList = new List<string>(); + if (function.attrKeyConfigs.Count > 0) + { + foreach (var attrKey in function.attrKeyConfigs) + { + if (function.spk.Replace(".", "").Contains(attrKey.key.Replace(".", ""))) + { + foreach (var info in attrKey.configs) + { + _levelTextList.Add(info.desc); + } + return _levelTextList; + } + } + } + + + switch (function.spk) { case SPK.SensorPm25: - _levelTextList.Add(StringId.Great); - _levelTextList.Add(StringId.Good); - _levelTextList.Add(StringId.MildPollution); - _levelTextList.Add(StringId.HeavyPollution); + case SPK.SensorPm10: + _levelTextList.Add(Language.StringByID(StringId.Great)); + _levelTextList.Add(Language.StringByID(StringId.Good)); + _levelTextList.Add(Language.StringByID(StringId.MildPollution)); + _levelTextList.Add(Language.StringByID(StringId.HeavyPollution)); break; case SPK.SensorCO2: - _levelTextList.Add(StringId.SensorReferenceTipCO2Level1); - _levelTextList.Add(StringId.SensorReferenceTipCO2Level2); - _levelTextList.Add(StringId.SensorReferenceTipCO2Level3); - _levelTextList.Add(StringId.SensorReferenceTipCO2Level4); + _levelTextList.Add(Language.StringByID(StringId.SensorReferenceTipCO2Level1)); + _levelTextList.Add(Language.StringByID(StringId.SensorReferenceTipCO2Level2)); + _levelTextList.Add(Language.StringByID(StringId.SensorReferenceTipCO2Level3)); + _levelTextList.Add(Language.StringByID(StringId.SensorReferenceTipCO2Level4)); break; case SPK.SensorTemperature: - _levelTextList.Add(StringId.ExtremelyCold); - _levelTextList.Add(StringId.Cold); - _levelTextList.Add(StringId.SlightlyCold); - _levelTextList.Add(StringId.Comfortable); - _levelTextList.Add(StringId.TepidFever); - _levelTextList.Add(StringId.Heat_SensorTip); - _levelTextList.Add(StringId.ExtremeHeat); + _levelTextList.Add(Language.StringByID(StringId.ExtremelyCold)); + _levelTextList.Add(Language.StringByID(StringId.Cold)); + _levelTextList.Add(Language.StringByID(StringId.SlightlyCold)); + _levelTextList.Add(Language.StringByID(StringId.Comfortable)); + _levelTextList.Add(Language.StringByID(StringId.TepidFever)); + _levelTextList.Add(Language.StringByID(StringId.Heat_SensorTip)); + _levelTextList.Add(Language.StringByID(StringId.ExtremeHeat)); break; case SPK.SensorTVOC: - _levelTextList.Add(StringId.SensorReferenceTVOCTipLevel1); - _levelTextList.Add(StringId.SensorReferenceTVOCTipLevel2); - _levelTextList.Add(StringId.SensorReferenceTVOCTipLevel3); - _levelTextList.Add(StringId.SensorReferenceTVOCTipLevel4); + _levelTextList.Add(Language.StringByID(StringId.SensorReferenceTVOCTipLevel1)); + _levelTextList.Add(Language.StringByID(StringId.SensorReferenceTVOCTipLevel2)); + _levelTextList.Add(Language.StringByID(StringId.SensorReferenceTVOCTipLevel3)); + _levelTextList.Add(Language.StringByID(StringId.SensorReferenceTVOCTipLevel4)); break; case SPK.SensorHumidity: - _levelTextList.Add(StringId.SensorReferenceHumidityTipLevel1); - _levelTextList.Add(StringId.SensorReferenceHumidityTipLevel2); - _levelTextList.Add(StringId.SensorReferenceHumidityTipLevel3); + _levelTextList.Add(Language.StringByID(StringId.SensorReferenceHumidityTipLevel1));//娼箍 + _levelTextList.Add(Language.StringByID(StringId.SensorReferenceHumidityTipLevel2)); + _levelTextList.Add(Language.StringByID(StringId.SensorReferenceHumidityTipLevel3));//骞茬嚗 break; case SPK.SensorHcho: - _levelTextList.Add(StringId.Class_I_BuildingStandard); - _levelTextList.Add(StringId.SecondaryBuildingStandard); - _levelTextList.Add(StringId.ExceedingTheStandard); + _levelTextList.Add(Language.StringByID(StringId.Class_I_BuildingStandard)); + _levelTextList.Add(Language.StringByID(StringId.SecondaryBuildingStandard)); + _levelTextList.Add(Language.StringByID(StringId.ExceedingTheStandard)); break; default: - _levelTextList.Add(99999999); - _levelTextList.Add(99999999); - _levelTextList.Add(99999999); + _levelTextList.Add(""); + _levelTextList.Add(""); + _levelTextList.Add(""); break; } return _levelTextList; } + + /// <summary> + /// 鑾峰彇 + /// </summary> + /// <param name="function"></param> + /// <returns></returns> + public uint GetCurColor(Function function) + { + var spk = function.spk; + var values = GetValues(function); + uint level = 0x00000000; + if (function.attrKeyConfigs.Count > 0) + { + + foreach (var attrKey in function.attrKeyConfigs) + { + if (function.spk.Replace(".", "").Contains(attrKey.key.Replace(".", ""))) + { + foreach (var info in attrKey.configs) + { + if ((Convert.ToInt32(info.start) >= values) && (Convert.ToInt32(info.end) < values)) + { + return Convert.ToUInt32(info.color, 16); + } + } + } + } + } + + return level; + } + + /// <summary> + /// 鑾峰彇鏂囨湰 + /// </summary> + /// <param name="function"></param> + /// <returns></returns> + public string GetCurText(Function function) + { + var spk = function.spk; + var values = GetValues(function); + var level = ""; + if (function.attrKeyConfigs.Count > 0) + { + + foreach (var attrKey in function.attrKeyConfigs) + { + if (function.spk.Replace(".", "").Contains(attrKey.key.Replace(".", ""))) + { + foreach (var info in attrKey.configs) + { + if ((Convert.ToInt32(info.start) >= values) && (Convert.ToInt32(info.end) < values)) + { + return info.desc; + } + } + } + } + } + + return level; + } + /// <summary> /// 褰撳墠绛夌骇 /// </summary> @@ -245,6 +410,37 @@ var spk = function.spk; var values = GetValues(function); int level = 1; + + + + if (function.attrKeyConfigs.Count > 0) + { + + foreach (var attrKey in function.attrKeyConfigs) + { + if (function.spk.Replace(".", "").Contains(attrKey.key.Replace(".", ""))) + { + level = 1; + if(attrKey.configs.Count == 0) + { + break; + } + foreach (var info in attrKey.configs) + { + if ((Convert.ToDouble(info.start) <= values) && (Convert.ToDouble(info.end) >= values)) + { + return level; + } + level++; + + } + } + } + return 1; + } + + + switch (spk) { case SPK.SensorPm25: @@ -309,6 +505,10 @@ else level = 3; break; + default: + level = 1; + break; + } return level; } -- Gitblit v1.8.0