From 1a0a7f736c6d2e7129e7591d40bed67ec7c0f09a Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期五, 05 二月 2021 10:47:42 +0800 Subject: [PATCH] 2021-02-05 1.编译冲突修改 --- HDL_ON/Entity/Function/Function.cs | 858 +++++++++++++++++++++++++++++++-------------------------- 1 files changed, 465 insertions(+), 393 deletions(-) diff --git a/HDL_ON/Entity/Function/Function.cs b/HDL_ON/Entity/Function/Function.cs index 9376caf..772be78 100644 --- a/HDL_ON/Entity/Function/Function.cs +++ b/HDL_ON/Entity/Function/Function.cs @@ -1,5 +1,7 @@ 锘縰sing System; using System.Collections.Generic; +using HDL_ON.Common; +using HDL_ON.DAL.Server; using HDL_ON.DriverLayer; using Shared; @@ -33,25 +35,25 @@ #region base info /// <summary> - /// HDL缁熶竴鍗忚鏍煎紡锛�14bytes - /// 涓句緥锛� 鏉ユ簮 鍘傚晢浠g爜 閫氳鏂瑰紡 浜у搧鏃堕棿鎴� 浜у搧绫诲埆 鐗╂ā鍨嬬被 閫氶亾鍙� 澶у皬绫诲埆 + /// HDL缁熶竴鍗忚鏍煎紡锛�14bytes + /// 涓句緥锛� 鏉ユ簮 鍘傚晢浠g爜 閫氳鏂瑰紡 浜у搧鏃堕棿鎴� 浜у搧绫诲埆 鐗╂ā鍨嬬被 閫氶亾鍙� 澶у皬绫诲埆 /// 1byte 1byte 1byte 4byte 1byte 2byte 2byte 2byte - /// 鏉ユ簮锛�00 榛樿鍘熺敓鎬佺郴缁熸暟鎹� 銆�01 缃戝叧鎴栬�呭叾浠朅璁惧銆�02 璋冭瘯杞欢銆�03 APP搴旂敤绋嬪簭銆�04 绗笁鏂圭綉鍏虫垨鑰呭钩鍙� - /// 鍘傚晢浠g爜锛�01 HDL + /// 鏉ユ簮锛�00 榛樿鍘熺敓鎬佺郴缁熸暟鎹� 銆�01 缃戝叧鎴栬�呭叾浠朅璁惧銆�02 璋冭瘯杞欢銆�03 APP搴旂敤绋嬪簭銆�04 绗笁鏂圭綉鍏虫垨鑰呭钩鍙� + /// 鍘傚晢浠g爜锛�01 HDL /// 閫氳鏂瑰紡锛�01 HDL Bus銆�02 Zigbee銆�03 KNX銆�04 Z-Wave - /// 浜у搧鏃堕棿鎴筹細4bytes 浠�2020骞�1鏈�1鏃ョ畻鍑虹殑鏃堕棿鎴�0.1s涓哄崟浣� - /// 浜у搧绫诲埆锛�01 璋冨厜鍣ㄣ��02 缁х數鍣ㄣ��03 骞叉帴鐐规ā鍧椼��04 浼犳劅鍣ㄣ��05 闈㈡澘 - /// 鐗╂ā鍨嬬被鍨嬶細 - /// 01 寮�鍏崇被锛�01 寮�鍏炽��02 鎻掑骇銆�03 - /// 02 鐓ф槑锛� 01 寮�鍏炽��02 璋冨厜銆�03 鑹叉俯銆�04 LED - /// 03 閬槼锛� 01 绐楀笜鐢垫満銆�02 鐧惧彾绐椼��03 寮�鍚堝笜銆�04 鍗峰笜 + /// 浜у搧鏃堕棿鎴筹細4bytes 浠�2020骞�1鏈�1鏃ョ畻鍑虹殑鏃堕棿鎴�0.1s涓哄崟浣� + /// 浜у搧绫诲埆锛�01 璋冨厜鍣ㄣ��02 缁х數鍣ㄣ��03 骞叉帴鐐规ā鍧椼��04 浼犳劅鍣ㄣ��05 闈㈡澘 + /// 鐗╂ā鍨嬬被鍨嬶細 + /// 01 寮�鍏崇被锛�01 寮�鍏炽��02 鎻掑骇銆�03 + /// 02 鐓ф槑锛� 01 寮�鍏炽��02 璋冨厜銆�03 鑹叉俯銆�04 LED + /// 03 閬槼锛� 01 绐楀笜鐢垫満銆�02 鐧惧彾绐椼��03 寮�鍚堝笜銆�04 鍗峰笜 /// 04 鎭掓俯鍣細01 绌鸿皟銆�02 鍦版殩銆�03 姣涚粏绌鸿皟 /// 05 鏂伴 /// 06 褰遍煶 /// 07 闊充箰 /// 08 鑳芥簮 /// 09 瀹夐槻 - /// 澶х被鍒� 1bytes 锛堥鐣欙級 + /// 澶х被鍒� 1bytes 锛堥鐣欙級 /// 灏忕被鍒� 1byte 锛堥鐣欙級 /// </summary> public string sid = "0301011234567801012301230123"; @@ -68,39 +70,82 @@ /// 璁惧spk /// </summary> public string spk = ""; - /// <summary> - /// 鍔熻兘绫诲埆 - /// 濡傦細绌鸿皟绫汇�佺伅鍏夌被銆佺獥甯樼被 - /// </summary> - public FunctionCategory functionCategory - { - get - { - try - { - var _functionCategoryString = sid.Substring(16, 2); - var _functionCategory = Convert.ToInt32(_functionCategoryString, 16); - return (FunctionCategory)Enum.ToObject(typeof(FunctionCategory), _functionCategory); - } - catch (Exception ex) - { - MainPage.Log($"get FunctionCategory error : {ex.Message}"); - return FunctionCategory.UnKown; - } - } - } + ///// <summary> + ///// 鍔熻兘绫诲埆 + ///// 濡傦細绌鸿皟绫汇�佺伅鍏夌被銆佺獥甯樼被 + ///// </summary> + //public FunctionCategory Spk_Prefix + //{ + // get + // { + // try + // { + // var _functionCategoryString = sid.Substring(16, 2); + // var _functionCategory = Convert.ToInt32(_functionCategoryString, 16); + // return (FunctionCategory)Enum.ToObject(typeof(FunctionCategory), _functionCategory); + // } + // catch (Exception ex) + // { + // MainPage.Log($"get FunctionCategory error : {ex.Message}"); + // return FunctionCategory.UnKown; + // } + // } + //} + ///// <summary> ///// 鍔熻兘绫诲瀷 ///// </summary> - public FunctionType functionType + //public FunctionType spk + //{ + // get + // { + // var _functionTypeString = sid.Substring(16, 4); + // return (FunctionType)Enum.ToObject(typeof(FunctionType), Convert.ToInt32(_functionTypeString, 16)); + // } + //} + + string spk_Prefix; + /// <summary> + /// spk鍓嶇紑 + /// 澶х被 + /// 鍔熻兘绫诲埆 + /// 濡傦細绌鸿皟绫汇�佺伅鍏夌被銆佺獥甯樼被 + /// </summary> + public string Spk_Prefix { get { - var _functionTypeString = sid.Substring(16, 4); - return (FunctionType)Enum.ToObject(typeof(FunctionType), Convert.ToInt32(_functionTypeString, 16)); - + if (string.IsNullOrEmpty(spk_Prefix)) + { + spk_Prefix = spk.Split(".")[0]; + } + return spk_Prefix; } } + string spk_Suffix; + ///// <summary> + ///// spk鍚庣紑 + ///// 灏忕被 + ///// 鍔熻兘绫诲瀷 + ///// </summary> + //public string spk + //{ + // get + // { + // if (string.IsNullOrEmpty(spk_Suffix)) + // { + // try + // { + // spk_Suffix = spk.Split(".")[1]; + // } + // catch + // { + // spk_Suffix = ""; + // } + // } + // return spk_Suffix; + // } + //} /// <summary> /// A鍗忚鍔熻兘鐨勭壒鎬� @@ -108,27 +153,22 @@ /// attri /// </summary> public List<FunctionAttributes> attributes = new List<FunctionAttributes>(); + /// <summary> + /// 鍔熻兘鐘舵�佸垪琛� + /// </summary> + public List<AttributesStatus> status = new List<AttributesStatus>(); /// <summary> /// 鎴块棿ID鍒楄〃 /// 璇ュ姛鑳芥坊鍔犲埌鍒版埧闂村垪琛� /// </summary> public List<string> roomIds = new List<string>(); - /// <summary> - /// 缁戝畾鎴块棿 - /// </summary> - public void BindRoom(string roomId) - { - roomIds.Add(roomId); - var pm = new DAL.Server.HttpServerRequest(); - pm.BindDeviceToRoom(deviceId, roomId); - } /// <summary> /// bus鍗忚鏁版嵁鏍煎紡 /// 浣跨敤A鍗忚鎺у埗鏃讹紝鏀瑰睘鎬т负绌� /// </summary> - public BusData bus_Data; + public BusData bus; /// <summary> /// 鏄惁鏀惰棌 /// </summary> @@ -158,37 +198,6 @@ /// </summary> public int delay = 0; /// <summary> - /// 寤舵椂鏄剧ず鐨勬枃鏈� - /// </summary> - [Newtonsoft.Json.JsonIgnore] - public string delayText - { - get - { - string text = ""; - switch (delay) - { - case 0: - text = Language.StringByID(StringId.NoDelay); - break; - case 30: - text = "30s"; - break; - case 60: - text = "1min"; - break; - case 120: - text = "2min"; - break; - case 300: - text = "5min"; - break; - } - return text; - } - } - - /// <summary> /// 鏈�鍚庢帶鍒剁殑涓�娆$姸鎬� /// </summary> [Newtonsoft.Json.JsonIgnore] @@ -202,7 +211,7 @@ { if (_trait_on_off == null) { - _trait_on_off = attributes.Find((obj) => obj.key == "on_off"); + _trait_on_off = attributes.Find((obj) => obj.key == FunctionAttributeKey.OnOff); //鎵句笉鍒板睘鎬ч渶瑕佸0鏄庝竴涓紝闃叉鎶ラ敊闂�� if (_trait_on_off == null) { @@ -213,28 +222,29 @@ max = 1, min = 0, }; + _trait_on_off.curValue = "off"; } - _trait_on_off.curValue = "on"; + } + if(_trait_on_off.curValue.ToString() != "on"&& _trait_on_off.curValue.ToString() != "off" && _trait_on_off.curValue.ToString() != "stop") + { + _trait_on_off.curValue = "off"; } return _trait_on_off; } - //set - //{ - // _trait_on_off = value; - //} } /// <summary> /// 浣跨敤娆℃暟 /// </summary> - public double usageCount = 0; + public double controlCounter = 0; /// <summary> /// 浣跨敤棰戠巼 /// </summary> - public double usageFrequency { + public double usageFrequency + { get { - return usageCount / 7; + return controlCounter / 7; } } /// <summary> @@ -242,12 +252,72 @@ /// </summary> public int fixedSerialNumber = int.MaxValue; + /// <summary> + /// 鏀惰棌鍔熻兘 + /// </summary> + public void CollectFunction() + { + var result = ""; + //var waitPage = new Loading(); + + new System.Threading.Thread(() => + { + if (collect) + { + result = ApiUtlis.Ins.HttpRequest.CollectDevice(deviceId).Code; + } + else + { + result = ApiUtlis.Ins.HttpRequest.CancelCollectDevice(deviceId).Code; + } + //鎻愮ず閿欒 + if (result != StateCode.SUCCESS) + { + Application.RunOnMainThread(() => + { + collect = !collect; + IMessageCommon.Current.ShowErrorInfoAlter(result); + }); + } + }) + { IsBackground = true }.Start(); + } + /// <summary> + /// 缂栬緫鍔熻兘缁戝畾鎴块棿淇℃伅 + /// </summary> + public void EditBindRoomInfo(string roomId) + { + var result = ""; + + new System.Threading.Thread(() => + { + if (collect) + { + result = ApiUtlis.Ins.HttpRequest.BindDeviceToRoom(new List<string>() { deviceId }, new List<string>() { roomId }).Code; + } + else + { + result = ApiUtlis.Ins.HttpRequest.UnbindDeviceToRoom(deviceId,roomId); + } + //鎻愮ず閿欒 + if (result != StateCode.SUCCESS) + { + Application.RunOnMainThread(() => + { + collect = !collect; + IMessageCommon.Current.ShowErrorInfoAlter(result); + }); + } + }) + { IsBackground = true }.Start(); + } + public string GetBusId() { string busId = ""; - if (bus_Data != null) + if (bus != null) { - busId = bus_Data.SubnetID + "_" + bus_Data.DeviceID + "_" + bus_Data.loopId; + busId = bus.SubnetID + "_" + bus.DeviceID + "_" + bus.LoopId; } return busId; } @@ -261,7 +331,7 @@ string roomNameList = ""; foreach (var roomId in roomIds) { - var findRoom = DB_ResidenceData.residenceData.Rooms.Find(obj => obj.uid == roomId); + var findRoom = SpatialInfo.CurrentSpatial.RoomList.Find(obj => obj.roomId == roomId); if (findRoom == null) { continue; @@ -270,11 +340,11 @@ { roomNameList += ","; } - roomNameList += findRoom.floorName + findRoom.roomName; + roomNameList += findRoom.floorName +"-"+ findRoom.roomName; } - if (roomNameList == "" && functionType == FunctionType.Scene) + if (roomNameList == "" ) { - roomNameList = Language.StringByID(StringId.WholeHouseScene); + roomNameList = Language.StringByID(StringId.WholeZone); } return roomNameList; } @@ -289,33 +359,105 @@ return "FunctionData_" + sid; } } + /// <summary> - /// 淇濆瓨鍔熻兘鏁版嵁 + /// 淇濆瓨鍔熻兘鏂囦欢 /// </summary> - public void SaveFunctionData(bool upSevser) + public void SaveFunctionFile() { - if (upSevser) + var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this)); + FileUtlis.Files.WriteFileByBytes(savePath, ssd); + } + /// <summary> + /// 淇濆瓨鎴块棿缁戝畾淇℃伅 + /// </summary> + public void UpdataRoomIds() + { + new System.Threading.Thread(() => { - var pm = new DAL.Server.HttpServerRequest(); - var pack = pm.UpdataDevcieInfo(this); - if (pack.Code == DAL.Server.StateCode.SUCCESS) + var pack = ApiUtlis.Ins.HttpRequest.UpdataDevcieBindRoomInfo(this); + //鐩存帴淇濆瓨鏈湴锛� + SaveFunctionFile(); + if (pack.Code == StateCode.SUCCESS) { - var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this)); - FileUtils.WriteFileByBytes(savePath, ssd); - MainPage.Log($"Save FunctionData {this.functionType} : {this.sid}"); } else { - Utlis.ShowTip(Language.StringByID(StringId.EditFunctionInfoFail) + "Code:" + pack.Code); + IMessageCommon.Current.ShowErrorInfoAlter(pack.Code); } - } - else - { - var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this)); - FileUtils.WriteFileByBytes(savePath, ssd); - MainPage.Log($"Save FunctionData {this.functionType} : {this.sid}"); - } + }) + { IsBackground = true }.Start(); } + /// <summary> + /// 鏇存柊鍔熻兘淇℃伅 + /// </summary> + public void UpdataFuncitonInfo() + { + new System.Threading.Thread(() => + { + var pm = new HttpServerRequest(); + var pack = pm.UpdataDevcieInfo(this); + SaveFunctionFile(); + if (pack.Code == StateCode.SUCCESS) + { + } + else + { + IMessageCommon.Current.ShowErrorInfoAlter(pack.Code); + } + }) + { IsBackground = true }.Start(); + } + /// <summary> + /// 鏇存柊鍔熻兘鍚嶇О + /// </summary> + public void UpdataFunctionName() + { + new System.Threading.Thread(() => + { + var pm = new HttpServerRequest(); + var pack = pm.UpdataDevcieInfo(this); + SaveFunctionFile(); + if (pack.Code == StateCode.SUCCESS) + { + } + else + { + IMessageCommon.Current.ShowErrorInfoAlter(pack.Code); + } + }) + { IsBackground = true }.Start(); + } + /// <summary> + /// 淇濆瓨鍔熻兘鏁版嵁 + /// </summary> + //public void SaveFunctionData(bool upSevser) + //{ + // if (upSevser) + // { + // new System.Threading.Thread(() => + // { + // var pm = new HttpServerRequest(); + // var pack = pm.UpdataDevcieInfo(this); + // if (pack.Code == StateCode.SUCCESS) + // { + // var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this)); + // FileUtlis.Files.WriteFileByBytes(savePath, ssd); + // } + // else + // { + // IMessageCommon.Current.ShowErrorInfoAlter(pack.Code); + // } + // }) + // { IsBackground = true }.Start(); + // } + // else + // { + // var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this)); + // FileUtlis.Files.WriteFileByBytes(savePath, ssd); + // } + //} + /// <summary> /// 杞崲鎴愬満鏅姛鑳藉璞� @@ -326,8 +468,40 @@ var sFunc = new SceneFunction(); foreach (var attr in attributes) { - sFunc.status.Add(new SceneFunctionStatus() { key = attr.key, value = attr.curValue.ToString() }); + switch (attr.key) + { + case FunctionAttributeKey.OnOff: + case FunctionAttributeKey.Brightness: + case FunctionAttributeKey.Mode: + case FunctionAttributeKey.SetTemp: + case FunctionAttributeKey.FanSpeed: + case FunctionAttributeKey.Percent: + //case FunctionAttributeKey.FadeTime: + if (attr.curValue.ToString() == "{}") + { + if (attr.key == FunctionAttributeKey.OnOff) + { + attr.curValue = "off"; + } + else + { + attr.curValue = "0"; + } + } + if (attr.key == FunctionAttributeKey.SetTemp) + { + double vv = 16; + Double.TryParse(attr.curValue.ToString(), out vv); + sFunc.status.Add(new SceneFunctionStatus() { key = attr.key, value = Convert.ToInt32(vv).ToString() }); + } + else + { + sFunc.status.Add(new SceneFunctionStatus() { key = attr.key, value = attr.curValue.ToString() }); + } + break; + } } + sFunc.sid = this.sid; return sFunc; } @@ -348,9 +522,9 @@ var acd = new AlinkControlData(); acd.sid = sid; - var aca = new AlinkControlAttributes(); foreach (var dic in commandDictionary) { + var aca = new AttributesStatus(); aca.key = dic.Key; aca.value = dic.Value; acd.status.Add(aca); @@ -369,9 +543,10 @@ ApiAlinkControlActionObj aaao = new ApiAlinkControlActionObj(); aaao.deviceId = this.deviceId; aaao.spk = this.spk; + aaao.bus = this.bus; foreach (var kv in keyValues) { - aaao.attributes.Add(new AlinkControlAttributes() + aaao.attributes.Add(new AttributesStatus() { key = kv.Key, value = kv.Value, @@ -397,7 +572,7 @@ /// </summary> public string spk = ""; - public List<AlinkControlAttributes> attributes = new List<AlinkControlAttributes>(); + public List<AttributesStatus> attributes = new List<AttributesStatus>(); //[Newtonsoft.Json.JsonIgnore] public BusData bus = new BusData(); } @@ -428,12 +603,12 @@ public class AlinkControlData { public string sid = ""; - public List<AlinkControlAttributes> status = new List<AlinkControlAttributes>(); + public List<AttributesStatus> status = new List<AttributesStatus>(); } /// <summary> /// a鍗忚鎺у埗鍔ㄤ綔鏁版嵁 /// </summary> - public class AlinkControlAttributes + public class AttributesStatus { /// <summary> /// 灞炴�у悕 @@ -451,6 +626,7 @@ /// 鍔熻兘灞炴�� /// 灞炴�у瓧娈佃В鏋愶細attri :灞炴�у唴瀹癸紝value 灞炴�х殑鍊硷紝max 鏈�澶у�� min 鏈�灏忓�� /// </summary> + [System.Serializable] public class FunctionAttributes { /// <summary> @@ -464,11 +640,11 @@ /// <summary> /// 鏈�澶у�� /// </summary> - public int max=100; + public int max = 100; /// <summary> /// 鏈�灏忓�� /// </summary> - public int min=0; + public int min = 0; /// <summary> /// 鏁版嵁绫诲瀷 /// </summary> @@ -477,271 +653,19 @@ /// 褰撳墠鍊� /// </summary> public object curValue = new object(); - - //----app鑷畾涔� - /// <summary> - /// 灞炴�у�煎崟浣� - /// </summary> - string _uintString; - [Newtonsoft.Json.JsonIgnore] - public string uintString - { - get - { - if (!string.IsNullOrEmpty(_uintString)) - { - return _uintString; - } - var us = ""; - switch (key) - { - case "temperature": - case "set_temperature": - us = "掳C"; - break; - case "percent": - case "brightness": - us = "%"; - break; - } - return us; - } - } - - /// <summary> - /// 灞炴�у悕绉版樉绀烘枃鏈� - /// 涓嫳鏂囨樉绀� - /// </summary> - [Newtonsoft.Json.JsonIgnore] - public string name_text - { - get - { - string text = ""; - switch (key) - { - case "on_off": - text = Language.StringByID(StringId.OnOff); - break; - case "brightness": - text = Language.StringByID(StringId.Brightness); - break; - case "color": - text = Language.StringByID(StringId.ColorValue); - break; - case "mode": - text = Language.StringByID(StringId.Mode); - break; - case "fan": - text = Language.StringByID(StringId.FanSpeed); - break; - case "temperature": - case "set_temperature": - text = Language.StringByID(StringId.Temp); - break; - case "delay": - text = Language.StringByID(StringId.Delay); - break; - case "cct": - text = "CCT"; - break; - //case "fade_time": - case "percent": - text = Language.StringByID(StringId.PercentAdjustment); - break; - //case "lock": - //case "ico": - //case "swing": - //case "set_point": - //case "pm25": - //case "volume": - //case "vol_step": - //case "source": - //case "treble": - //case "bass": - //case "playlist": - //case "song_name": - //case "current_status": - //case "enable": - //case "lux": - //case "adjust_value": - //case "range": - //case "humidity": - //case "type": - //case "state": - //case "sensitivity": - //case "pm25value": - } - return text; - } - } - - /// <summary> - /// 鑾峰彇褰撳墠灞炴�х殑鏄剧ず鏂囨湰 - /// 涓嫳鏂囨樉绀� - /// </summary> - public string GetCurValueText() - { - return GetValueText(curValue.ToString()); - } - - /// <summary> - /// 鑾峰彇鎸囧畾灞炴�х殑鏄剧ず鏂囨湰 - /// 涓嫳鏂囨樉绀� - /// </summary> - public string GetValueText(string value) - { - string text = ""; - value = value.Replace("{}", ""); - switch (key) - { - case "on_off": - text = value == "on" ? Language.StringByID(StringId.On) : Language.StringByID(StringId.OFF); - break; - case "temperature": - case "set_temperature": - case "brightness": - case "percent": - if (value == "") - { - this.curValue = this.min; - text = this.min.ToString(); - } - else - { - text = value; - } - break; - //case "color": - case "mode": - switch (value) - { - //----绌鸿皟 - case "auto": - text = Language.StringByID(StringId.Auto); - break; - case "cool": - text = Language.StringByID(StringId.Cool); - break; - case "heat": - text = Language.StringByID(StringId.Heat); - break; - case "dry": - text = Language.StringByID(StringId.Dry); - break; - case "fan": - text = Language.StringByID(StringId.AirSupply); - break; - //-----鍦扮儹 - case "day": - text = Language.StringByID(StringId.Day); - break; - case "night": - text = Language.StringByID(StringId.Night); - break; - case "away": - text = Language.StringByID(StringId.Away); - break; - case "normal": - text = Language.StringByID(StringId.Normal); - break; - case "timer": - text = Language.StringByID(StringId.Timer); - break; - default: - if (this.value.Contains("cool")) - { - this.curValue = "cool"; - text = Language.StringByID(StringId.Cool); - } - else if (this.value.Contains("day")) - { - this.curValue = "day"; - text = Language.StringByID(StringId.Day); - } - else - { - foreach (var v in this.value) - { - this.curValue = v; - text = GetCurValueText(); - } - } - break; - } - break; - case "fan": - switch (value) - { - case "high": - text = Language.StringByID(StringId.HighWindSpeed); - break; - case "medium": - text = Language.StringByID(StringId.MiddleWindSpeed); - break; - case "low": - text = Language.StringByID(StringId.LowWindSpeed); - break; - case "auto": - text = Language.StringByID(StringId.Auto); - break; - default: - if (this.value.Contains("low")) - { - this.curValue = "low"; - text = Language.StringByID(StringId.LowWindSpeed); - } - else - { - foreach (var v in this.value) - { - this.curValue = v; - text = GetCurValueText(); - } - } - break; - } - break; - //case "delay": - //case "cct": - //case "fade_time": - //case "lock": - //case "ico": - //case "swing": - //case "set_point": - //case "pm25": - //case "volume": - //case "vol_step": - //case "source": - //case "treble": - //case "bass": - //case "playlist": - //case "song_name": - //case "current_status": - //case "enable": - //case "lux": - //case "adjust_value": - //case "range": - //case "humidity": - //case "type": - //case "state": - //case "sensitivity": - //case "pm25value": - case "high": - text = Language.StringByID(StringId.HighWindSpeed); - break; - case "medium": - text = Language.StringByID(StringId.MiddleWindSpeed); - break; - case "low": - text = Language.StringByID(StringId.LowWindSpeed); - break; - case "auto": - text = Language.StringByID(StringId.Auto); - break; - } - return text; - } + ///// <summary> + ///// curValue鐨勭炕璇戝��,鏈�鍧忕殑缁撴灉涔熷彧浼氳繑鍥瀞tring.Empty + ///// </summary> + //public string realValue + //{ + // get + // { + // var myValue = curValue.ToString(); + // //娌欓洉瀹氫箟鐨刼bject绫诲瀷 + // if (myValue.Contains("{") == true) { return string.Empty; } + // return myValue; + // } + //} } /// <summary> /// 鍔熻兘灞炴�ч敭鍚嶅垪琛� @@ -759,7 +683,11 @@ /// <summary> /// 棰滆壊 /// </summary> - public const string Color = "color"; + public const string RGB = "rgb"; + /// <summary> + /// 娓愬彉鏃堕棿 + /// </summary> + public const string FadeTime = "fade_time"; /// <summary> /// 妯″紡 /// </summary> @@ -769,9 +697,9 @@ /// </summary> public const string FanSpeed = "fan"; /// <summary> - /// 娓╁害 + /// 璁剧疆娓╁害 /// </summary> - public const string Temp = "temperature"; + public const string SetTemp = "set_temp"; /// <summary> /// 寤舵椂 /// </summary> @@ -784,6 +712,14 @@ /// 鐧惧垎姣� /// </summary> public const string Percent = "percent"; + /// <summary> + /// 瀹ゅ唴娓╁害 + /// </summary> + public const string IndoorTemp = "room_temp"; + /// <summary> + /// value + /// </summary> + public const string Value = "value"; } /// <summary> /// 璁惧鍔熻兘oid @@ -820,7 +756,15 @@ return Convert.ToByte(addresses.Substring(2, 2), 16); } } - public byte loopId; + public byte LoopId + { + get + { + return Convert.ToByte(loopId, 16); + } + } + + public string loopId; } public static class SPK @@ -891,11 +835,11 @@ public const string SensorPir = "sensor.pir"; /// <summary> /// 锛堥棬绐椾紶鎰熷櫒锛� - /// </summary> + /// </summary> public const string SensorDoorWindow = "sensor.doorwindow"; /// <summary> /// 锛圥M2.5浼犳劅鍣級 - /// </summary> + /// </summary> public const string SensorPm25 = "sensor.pm25"; /// <summary> /// co2浼犳劅鍣� @@ -909,22 +853,150 @@ /// 婀垮害浼犳劅鍣� /// </summary> public const string SensorHumidity = "sensor.humidity"; + + /// <summary> + /// 鐑熼浘浼犳劅鍣� + /// </summary> + public const string SensorSmoke = "sensor.smoke"; + /// <summary> + /// 姘存蹈浼犳劅鍣� + /// </summary> + public const string SensorWater = "sensor.water"; + /// <summary> + /// 鐕冩皵浼犳劅鍣� + /// </summary> + public const string SensorGas= "sensor.gas"; + /// <summary> + /// 绾㈠鐝婃爮浼犳劅鍣� + /// </summary> + public const string SensorShanLan = "sensor.shanlan"; + /// <summary> + /// 绾㈠瀵瑰皠浼犳劅鍣� + /// </summary> + public const string SensorDuiShe = "sensor.duishe"; + /// <summary> + /// 瓒呭0娉紶鎰熷櫒 + /// </summary> + public const string SensoruUtrasonic = "sensor.ultrasonic"; + /// <summary> /// 锛堝共鎺ョ偣锛� - /// </summary> - public const string DryContact = "dryContact.standard"; + /// </summary> + public const string SensorDryContact = "sensor.dryContact"; /// <summary> /// 瀹剁數銆佹彃搴� /// </summary> - public const string ElectricSocket = "electric.socket "; + public const string ElectricSocket = "electrical.socket"; /// <summary> /// 瀹剁數銆佺數瑙� /// </summary> - public const string ElectricTV = "electric.tv"; + public const string ElectricTV = "electrical.tv"; /// <summary> /// 瀹剁數銆侀鎵� /// </summary> - public const string ElectricFan = "electric.fan"; + public const string ElectricFan = "electrical.fan"; + /// <summary> + /// 瀹剁數銆佹秱楦︾┖姘斿噣鍖栧櫒 + /// </summary> + public const string ElectricTuyaAirCleaner = "electrical.Q1RsefNf91tIXyyQ"; + /// <summary> + /// 瀹剁數銆佹秱楦︾數椋庢墖 + /// </summary> + public const string ElectricTuyaFan = "electrical.tyqborgovyzytytz"; + /// <summary> + /// 瀹剁數銆佹秱楦︽壂鍦版満鍣ㄤ汉 + /// </summary> + public const string ElectricTuyaWeepRobot = "electrical.ai6HtccKFIw3dxo3"; + /// <summary> + /// 瀹剁數銆佹秱楦︽按闃� + /// </summary> + public const string ElectricTuyaWaterValve = "electrical.koiGhMKwLf2ZP81g"; + + + /// <summary> + /// 鑾峰彇绗笁鏂硅澶噑pk + /// </summary> + /// <returns></returns> + public static List<string> Get3tySpk(BrandType brandType) + { + var list = new List<string>(); + + switch (brandType) + { + case BrandType.All3tyBrand: + case BrandType.Tuya: + list.Add(ElectricTuyaAirCleaner); + list.Add(ElectricTuyaFan); + list.Add(ElectricTuyaWaterValve); + list.Add(ElectricTuyaWeepRobot); + break; + } + return list; + } + + /// <summary> + /// 绗笁鏂瑰搧鐗屽垪琛� + /// </summary> + public enum BrandType + { + All = 0, + Hdl = 1, + Tuya = 2, + + + All3tyBrand = 999, + } + + } + + /// <summary> + /// 鍔熻兘绫诲埆 + /// </summary> + public static class FunctionCategory + { + /// <summary> + ///锛堢伅锛� + /// </summary> + public const string Light = "light"; + /// <summary> + /// 锛堢獥甯橈級 + /// </summary> + public const string Curtain = "curtain"; + /// <summary> + /// 锛堢┖璋冿級 + /// </summary> + public const string AC = "ac"; + /// <summary> + /// 锛堝湴鐑級 + /// </summary> + public const string FloorHeat = "floorHeat"; + /// <summary> + /// 锛堟柊椋庯級 + /// </summary> + public const string AirFresh = "airFresh"; + /// <summary> + /// 锛堥煶涔愶級 + /// </summary> + public const string Music = "music"; + /// <summary> + /// 锛堜紶鎰熷櫒锛� + /// </summary> + public const string Sensor = "sensor"; + /// <summary> + /// 锛堝共鎺ョ偣锛� + /// </summary> + public const string DryContact = "dryContact"; + /// <summary> + /// 瀹剁數 + /// </summary> + public const string Electric = "electrical"; + + //Music = 0x09, + + + } + + } -- Gitblit v1.8.0