| | |
| | | |
| | | namespace HDL_ON.Entity |
| | | { |
| | | public class Sensor :Function |
| | | public class Sensor |
| | | { |
| | | public Sensor() |
| | | { |
| | | |
| | | } |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public int functionTypeNameId |
| | | { |
| | | get |
| | | /// <summary> |
| | | /// 获取名称文本ID |
| | | /// </summary> |
| | | /// <param name="spk"></param> |
| | | /// <returns></returns> |
| | | public int GetFunctionTypeNameId(string spk) |
| | | { |
| | | int nameId = 0; |
| | | switch (spk) |
| | |
| | | } |
| | | return nameId; |
| | | } |
| | | } |
| | | |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public FunctionAttributes trait_values; |
| | | /// <summary> |
| | | /// 值 |
| | | /// |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public double values |
| | | public double GetValues(Function function) |
| | | { |
| | | get |
| | | { |
| | | if (trait_values == null) |
| | | { |
| | | trait_values = attributes.Find((obj) => obj.key == FunctionAttributeKey.Value); |
| | | //找不到属性需要声明一个,防止报错闪退 |
| | | if (trait_values == null) |
| | | { |
| | | trait_values = new FunctionAttributes() |
| | | { |
| | | key = FunctionAttributeKey.Value, |
| | | value = new List<string> { "29" }, |
| | | max = 10000, |
| | | min = 0, |
| | | }; |
| | | trait_values.curValue = trait_values.min; |
| | | var value = function.GetAttrState(FunctionAttributeKey.Value); |
| | | return Convert.ToDouble(value); |
| | | } |
| | | } |
| | | if (trait_values.curValue.ToString() == "{}") |
| | | trait_values.curValue = 0; |
| | | if(spk == SPK.SensorTVOC) |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="value"></param> |
| | | /// <param name="function"></param> |
| | | public void SetValues(int value, Function function) |
| | | { |
| | | return Convert.ToDouble(trait_values.curValue.ToString()) / 100000; |
| | | } |
| | | return Convert.ToDouble(trait_values.curValue); |
| | | } |
| | | set |
| | | { |
| | | try |
| | | |
| | | { |
| | | if (trait_values == null) |
| | | { |
| | | trait_values = attributes.Find((obj) => obj.key == FunctionAttributeKey.Value); |
| | | //找不到属性需要声明一个,防止报错闪退 |
| | | if (trait_values == null) |
| | | { |
| | | trait_values = new FunctionAttributes() |
| | | { |
| | | key = FunctionAttributeKey.Value, |
| | | value = new List<string> { "up" }, |
| | | max = 100, |
| | | min = 0, |
| | | }; |
| | | } |
| | | trait_values.curValue = trait_values.min; |
| | | } |
| | | trait_values.curValue = value; |
| | | MainPage.Log($"values 数据刷新{value}."); |
| | | } |
| | | catch |
| | | { |
| | | MainPage.Log("values 数据刷新失败."); |
| | | } |
| | | } |
| | | function.SetAttrState(FunctionAttributeKey.Value, value); |
| | | } |
| | | |
| | | List<string> _intervalValue; |
| | | /// <summary> |
| | | /// 每个等级对区间值 |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public List<string> intervalValue |
| | | public List<string> GetIntervalValue(string spk) |
| | | { |
| | | get |
| | | { |
| | | if (_intervalValue == null) |
| | | { |
| | | _intervalValue = new List<string>(); |
| | | var _intervalValue = new List<string>(); |
| | | switch (spk) |
| | | { |
| | | case SPK.SensorPm25: |
| | |
| | | _intervalValue.Add("0 ~ 39"); |
| | | break; |
| | | } |
| | | } |
| | | return _intervalValue; |
| | | } |
| | | } |
| | | List<uint> _levelColorList; |
| | | |
| | | /// <summary> |
| | | /// 每个等级的颜色值 |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public List<uint> levelColorList |
| | | public List<uint> GetLevelColorList(string spk) |
| | | { |
| | | get |
| | | { |
| | | try |
| | | { |
| | | if (_levelColorList == null) |
| | | { |
| | | _levelColorList = new List<uint>(); |
| | | var _levelColorList = new List<uint>(); |
| | | switch (spk) |
| | | { |
| | | case SPK.SensorPm25: |
| | |
| | | _levelColorList.Add(0xFFFF3D3D); |
| | | break; |
| | | } |
| | | } |
| | | }catch(Exception ex) |
| | | { |
| | | MainPage.Log($"sensor error 1 : {ex.Message}"); |
| | | } |
| | | return _levelColorList; |
| | | |
| | | } |
| | | } |
| | | List<int> _levelTextList; |
| | | |
| | | /// <summary> |
| | | /// 每个等级的名称 |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public List<int> levelTextList |
| | | public List<int> GetLevelTextList(string spk) |
| | | { |
| | | get |
| | | { |
| | | if (_levelTextList == null) |
| | | { |
| | | _levelTextList = new List<int>(); |
| | | var _levelTextList = new List<int>(); |
| | | switch (spk) |
| | | { |
| | | case SPK.SensorPm25: |
| | |
| | | _levelTextList.Add(StringId.TepidFever); |
| | | _levelTextList.Add(StringId.Heat_SensorTip); |
| | | _levelTextList.Add(StringId.ExtremeHeat); |
| | | |
| | | |
| | | break; |
| | | case SPK.SensorTVOC: |
| | | _levelTextList.Add(StringId.SensorReferenceTVOCTipLevel1); |
| | | _levelTextList.Add(StringId.SensorReferenceTVOCTipLevel2); |
| | | _levelTextList.Add(StringId.SensorReferenceTVOCTipLevel3); |
| | | _levelTextList.Add(StringId.SensorReferenceTVOCTipLevel4); |
| | | |
| | | break; |
| | | case SPK.SensorHumidity: |
| | | _levelTextList.Add(StringId.SensorReferenceHumidityTipLevel1); |
| | |
| | | _levelTextList.Add(StringId.SensorReferenceHumidityTipLevel3); |
| | | break; |
| | | } |
| | | } |
| | | return _levelTextList; |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 当前等级 |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public int curLevel |
| | | public int GetCurLevel(Function function) |
| | | { |
| | | get |
| | | { |
| | | var spk = function.spk; |
| | | var values = GetValues(function); |
| | | int level = 1; |
| | | switch (spk) |
| | | { |
| | |
| | | } |
| | | return level; |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |