From 66a9965c44ecc32a6696abca876ab9d1cd091584 Mon Sep 17 00:00:00 2001 From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local> Date: 星期五, 28 二月 2020 15:25:13 +0800 Subject: [PATCH] 2020.2.28 --- ZigbeeApp/Shared/Phone/ZigBee/Device/Panel.cs | 2167 +++++++++++++++++++-------------------------------------- 1 files changed, 731 insertions(+), 1,436 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/Panel.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/Panel.cs index 3eb06bc..df7711c 100755 --- a/ZigbeeApp/Shared/Phone/ZigBee/Device/Panel.cs +++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/Panel.cs @@ -1,7 +1,9 @@ 锘縰sing System; using System.Collections.Generic; using System.Threading.Tasks; +using MQTTnet; using Newtonsoft.Json.Linq; +using Shared.Common; namespace ZigBee.Device { @@ -15,7 +17,7 @@ /// <summary> /// 鎸夐敭妯″紡锛堢鏈夊姛鑳斤級 /// </summary> - public int panelMode = -1; + public int panelMode = 65535; /// <summary> ///鎸夐敭寮�鐘舵�侊紙鎸囩ず锛変寒搴� /// </summary> @@ -27,13 +29,132 @@ public int panelBacklightLevel = -1; /// <summary> + /// 褰撳墠閫夋嫨妯″紡 + /// </summary> + public string currentKeySelectModeText = ""; + /// <summary> + /// 褰撳墠閫夋嫨鐨勬ゼ灞侷D + /// </summary> + public string currentSelectFloorId = string.Empty; + /// <summary> + /// 褰撳墠寮�鍏虫ā寮� + /// </summary> + public string CurrentSwitchMode = ""; + /// <summary> + /// 褰撳墠灞炴�фā寮� + /// </summary> + public int currentClusterID; + + /// <summary> + /// 褰撳墠璋冨厜妯″紡 + /// </summary> + public string CurrentDimmerMode = ""; + + /// <summary> + /// 褰撳墠閬槼妯″紡 + /// </summary> + public string CurrentCurtainMode = ""; + + /// <summary> + /// 褰撳墠鎴块棿ID + /// </summary> + public string RoomId = ""; + + /// <summary> + /// 褰撳墠鎴块棿ID + /// </summary> + public string curSelectSceneID = ""; + + /// <summary> + /// 鏈湴妤煎眰鎴块棿缁戝畾鍒楄〃 + /// </summary> + public Dictionary<int, FloorRoomBindObj> FloorRoomBindObjList = new Dictionary<int, FloorRoomBindObj> { }; + /// <summary> + /// 缁戝畾鐨勬ゼ灞傛埧闂翠俊鎭� + /// </summary> + [System.Serializable] + public class FloorRoomBindObj + { + /// <summary> + /// 妤煎眰ID + /// </summary> + public string floodID; + /// <summary> + /// 妤煎眰鍚嶇О + /// </summary> + public string floodName; + /// <summary> + /// 鎴块棿ID + /// </summary> + public string roomID; + /// <summary> + /// 鎴块棿鍚嶇О + /// </summary> + public string roomName; + /// <summary> + /// 缁戝畾鐩爣ID + /// </summary> + public string BindID; + /// <summary> + /// 缁戝畾鐩爣鍚嶇О + /// </summary> + public string BindName; + /// <summary> + /// 鍥剧墖璺緞 + /// </summary> + public string IconPath = ""; + + } + + // <summary> /// 鎸夐敭涓缁戝畾鐨勭洰鏍囧垪琛� /// </summary> public System.Collections.Generic.List<BindListResponseObj> bindList = new System.Collections.Generic.List<BindListResponseObj> { }; + /// <summary> /// 鎸夐敭鏀寔鐨勭鏈夋ā寮忓垪琛� /// </summary> - public System.Collections.Generic.List<string> priFunList = new System.Collections.Generic.List<string> { }; + public System.Collections.Generic.Dictionary<int, string> priDeviceModeFunList = new System.Collections.Generic.Dictionary<int, string> { }; + + /// <summary> + /// 绉佹湁鍔熻兘绫� + /// <para>256:Key,鎸夐敭绫荤被 </para> + /// <para>768:PIR,PIR绫�</para> + /// <para>1024:Light,鐏被</para> + /// </summary> + public List<int> privateFuncFirstLevelList = new List<int>(); + + /// <summary> + /// 绗簩绾т俊鎭� + /// <para>1:鐗规畩鍔熻兘</para> + /// <para>100:Switch,寮�鍏筹紙鎸夐敭绫伙級</para> + /// <para>200:Dimmer,璋冨厜锛堟寜閿被锛�</para> + /// <para>300:Curtain,绐楀笜锛堟寜閿被锛�</para> + /// <para>0:EnergySavingMode,鑺傝兘妯″紡锛堢伅绫伙級</para> + /// <para>1:SleepMode,鐫$湢妯″紡锛堢伅绫伙級</para> + /// <para>100:WhiteBalance,鐧藉钩琛★紙鐏被锛�</para> + /// <para>101:RGBColor,RGB鎸囩ず鐏鑹诧紙鐏被锛�</para> + /// <para>102:RGBLevel,RGB鎸囩ず鐏寒搴︼紙鐏被锛�</para> + /// </summary> + public List<int> privateFuncSecondLevelList = new List<int>(); + + /// <summary> + /// 绗笁绾т俊鎭� + /// <para>1:鍦烘櫙瑙﹀彂锛堢壒娈婂姛鑳斤級</para> + /// <para>65535:绂佹鍙戦�佸姛鑳斤紙鐗规畩鍔熻兘锛�</para> + /// <para>100:SwitchOpen,寮�鍏冲紑锛堟寜閿被锛�</para> + /// <para>101:SwitchClose,寮�鍏冲叧锛堟寜閿被锛�</para> + /// <para>102:SwitchChange,寮�鍏冲垏鎹紙鎸夐敭绫伙級</para> + /// <para>200:DimmerStepUp,澧炲ぇ璋冨厜锛堟寜閿被锛�</para> + /// <para>201:DimmerStepDown,闄嶄綆璋冨厜锛堟寜閿被锛�</para> + /// <para>202:DimmerStepChange,璋冨厜鍒囨崲锛堟寜閿被锛�</para> + /// <para>300:CurtainOpen,绐楀笜寮�锛堟寜閿被锛�</para> + /// <para>301:CurtainClose,绐楀笜鍏筹紙鎸夐敭绫伙級</para> + /// <para>302:CurtainStop,绐楀笜鍋�</para> + /// <para>303:CurtainUpStop,绐楀笜涓婂崌鍋�</para> + /// <para>304:CurtainDownstop,绐楀笜涓嬮檷鍋�</para> + /// </summary> + public List<int> privateFuncThirdLevelList = new List<int>(); #region 鑾峰彇闈㈡澘鐨勭鏈変俊鎭�. /// <summary> ///鑾峰彇闈㈡澘鐨勭鏈変俊鎭� @@ -120,6 +241,11 @@ { int curIndex = 4 * j; tempD.privateFuncTypeLevelFirstList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16)); + //if (privateFuncFirstLevelList.Contains(256) == false) + //{ + // privateFuncFirstLevelList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16)); + + //} } break; case 2: @@ -134,12 +260,19 @@ if (j == 0) { tempD.privateFuncTypeLevelFirstList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16)); + //if (privateFuncFirstLevelList.Contains(256) == false) + //{ + // privateFuncFirstLevelList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16)); + //} } else { tempD.privateFuncTypeLevelSecondList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16)); + //if (privateFuncSecondLevelList.Contains(1) == false || privateFuncSecondLevelList.Contains(100) == false || privateFuncSecondLevelList.Contains(200) == false || privateFuncSecondLevelList.Contains(300) == false) + //{ + // privateFuncSecondLevelList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16)); + //} } - } break; case 3: @@ -154,14 +287,26 @@ if (j == 0) { tempD.privateFuncTypeLevelFirstList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16)); + //if (privateFuncFirstLevelList.Contains(256) == false) + //{ + // privateFuncFirstLevelList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16)); + //} } else if (j == 1) { tempD.privateFuncTypeLevelSecondList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16)); + //if (privateFuncSecondLevelList.Contains(1) == false || privateFuncSecondLevelList.Contains(100) == false || privateFuncSecondLevelList.Contains(200) == false || privateFuncSecondLevelList.Contains(300) == false) + //{ + // privateFuncSecondLevelList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16)); + //} } else { tempD.privateFuncTypeLevelThirdList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16)); + //if (privateFuncThirdLevelList.Contains(1) == false || privateFuncThirdLevelList.Contains(65535) == false || privateFuncThirdLevelList.Contains(100) == false || privateFuncThirdLevelList.Contains(101) == false || privateFuncThirdLevelList.Contains(102) == false || privateFuncThirdLevelList.Contains(200) == false || privateFuncThirdLevelList.Contains(201) == false || privateFuncThirdLevelList.Contains(202) == false || privateFuncThirdLevelList.Contains(300) == false || privateFuncThirdLevelList.Contains(301) == false || privateFuncThirdLevelList.Contains(302) == false || privateFuncThirdLevelList.Contains(303) == false || privateFuncThirdLevelList.Contains(304) == false) + //{ + // privateFuncThirdLevelList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16)); ; + //} } } break; @@ -181,11 +326,10 @@ try { - OpenPassthroughControl(Gateway); var passData = SendPanelPrivateFunctions(args); var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; var data = new JObject { { "PassData", passData } }; - jObject.Add("Data", data); + jObject.Add("Data", data); Gateway.Send("ClientDataPassthrough", jObject.ToString()); } catch { } @@ -233,7 +377,7 @@ } /// <summary> - /// PIR閰嶇疆鍙傛暟鍥炲 + /// 閰嶇疆鍙傛暟鍥炲 /// </summary> public PanelPrivateFunctionsResponseInfo panelPrivateFunctionsResponseInfo; [System.Serializable] @@ -245,8 +389,8 @@ /// <para>2:绗簩绾у埆</para> /// <para>3:绗笁绾у埆</para> /// </summary> - public int funLevel = -1; - + public int funLevel = -1; + /// <summary> /// 绉佹湁鍔熻兘绫� /// <para>256:Key,鎸夐敭绫荤被 </para> @@ -285,8 +429,8 @@ /// <para>303:CurtainUpStop,绐楀笜涓婂崌鍋�</para> /// <para>304:CurtainDownstop,绐楀笜涓嬮檷鍋�</para> /// </summary> - public List<int> privateFuncTypeLevelThirdList = new List<int>(); - + public List<int> privateFuncTypeLevelThirdList = new List<int>(); + } /// <summary> @@ -306,7 +450,7 @@ string addDataLength = ""; string value0 = ""; string value1 = ""; - string value2 = ""; + string value2 = ""; try { @@ -316,18 +460,18 @@ { dataLength = string.Concat(0, 2 * args.Length + 5); } - else - { + else + { dataLength = Convert.ToString(2 * args.Length + 5, 16); - } - - + } + + if (Convert.ToString(2 * args.Length, 16).Length == 1) { addDataLength = string.Concat(0, 2 * args.Length + 1); } else - { + { addDataLength = Convert.ToString(2 * args.Length + 1, 16); } @@ -336,7 +480,7 @@ switch (args.Length) { case 1: - value0 = "02"; + value0 = "02"; switch (args[0]) { case 1024: @@ -396,15 +540,15 @@ case 768: value1 = "0003"; break; - } - - break; - } + } + + break; + } } - } - else - { + } + else + { dataLength = "05"; addDataLength = "01"; value0 = "01"; @@ -412,8 +556,8 @@ data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength + value0 + value1 + value2; } - catch { }; - + catch { }; + return data; } @@ -428,7 +572,7 @@ /// <para>768:PIR,PIR绫�</para> /// <para>1024:Light,鐏被</para> /// </summary> - public int privateFuncTypeOne; + public int privateFuncTypeOne; } /// <summary> @@ -448,8 +592,8 @@ /// <para>102:RGBLevel,RGB鎸囩ず鐏寒搴︼紙鐏被锛�</para> /// </summary> public int privateFuncTypeTwo; - } - + } + /// <summary> /// 绉佹湁鍔熻兘绫伙紙绗笁绾у埆锛変俊鎭� /// </summary> @@ -488,6 +632,7 @@ { return null; } + return result.panelPrivateFunctionsResponseInfo.privateFuncTypeLevelFirstList; } @@ -617,11 +762,10 @@ try { - OpenPassthroughControl(Gateway); var passData = ControlKeyData(keyNum, keyStatus); var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; var data = new JObject { { "PassData", passData } }; - jObject.Add("Data", data); + jObject.Add("Data", data); Gateway.Send(("ClientDataPassthrough"), jObject.ToString()); } catch { } @@ -697,8 +841,8 @@ string td = attributeData.ToString("X4"); char[] td1 = td.ToCharArray(); - string tempAttributeData = string.Concat(td1[2].ToString(), td1[3].ToString(), td1[0].ToString(), td1[1].ToString()); - + string tempAttributeData = string.Concat(td1[2].ToString(), td1[3].ToString(), td1[0].ToString(), td1[1].ToString()); + switch (keyStatus) { case KeyStatus.close: @@ -792,11 +936,10 @@ try { - OpenPassthroughControl(Gateway); var passData = SetPanelColorData(keyColorData, keyNumStatus); var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; var data = new JObject { { "PassData", passData } }; - jObject.Add("Data", data); + jObject.Add("Data", data); Gateway.Send(("ClientDataPassthrough"), jObject.ToString()); } catch { } @@ -866,14 +1009,14 @@ Type type = keyNumStatus.GetType(); var obj = type.InvokeMember("Key" + i, System.Reflection.BindingFlags.GetField, null, keyNumStatus, null); int value0 = 0; - if (Convert.ToBoolean(obj) == true) - { + if (Convert.ToBoolean(obj) == true) + { value0 = 1; } int v = (int)Math.Pow(2, i - 1); attributeData += value0 * v; - } - + } + string td = attributeData.ToString("X4"); char[] td1 = td.ToCharArray(); string tempAttributeData = string.Concat(td1[2].ToString(), td1[3].ToString(), td1[0].ToString(), td1[1].ToString()); @@ -1099,8 +1242,8 @@ #region 閰嶇疆鎸夐敭鎸囩ず鐏潰鏉夸寒搴﹀睘鎬�. ///<summary > ///閰嶇疆鎸夐敭鎸囩ず鐏潰鏉夸寒搴﹀睘鎬� - /// <para>directionsLevel:鎸囩ず鐏寒搴� 0-100</para> - /// <para>backlightLevel:鑳屽厜鐏寒搴� 0-100</para> + /// <para>directionsLevel:鎸囩ず鐏寒搴� 0-100(杩欎釜鏄偣鍑诲悗鐨勫��)</para> + /// <para>backlightLevel:鑳屽厜鐏寒搴� 0-100(杩欎釜鏄偣鍑诲墠鐨勫��)</para> /// </summary> public async System.Threading.Tasks.Task<ResponseAllData> SetKeyLevelAsync(int directionsLevel, int backlightLevel) { @@ -1168,11 +1311,10 @@ try { - OpenPassthroughControl(Gateway); var passData = SetPanelLevelData(directionsLevel, backlightLevel); var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; var data = new JObject { { "PassData", passData } }; - jObject.Add("Data", data); + jObject.Add("Data", data); Gateway.Send(("ClientDataPassthrough"), jObject.ToString()); } catch { } @@ -1320,11 +1462,10 @@ try { - OpenPassthroughControl(Gateway); var passData = SetPanelModeModeData(modeEnable, modeTime, level); var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; var data = new JObject { { "PassData", passData } }; - jObject.Add("Data", data); + jObject.Add("Data", data); Gateway.Send(("ClientDataPassthrough"), jObject.ToString()); } catch { } @@ -1362,7 +1503,7 @@ string addDataLength = "03"; string mode = ""; string time = ""; - string level = ""; + string level = ""; try { if (modeEnable) @@ -1396,7 +1537,7 @@ level = temp2; break; } - + sbString1.Append(time.ToUpper()); sbString2.Append(level.ToUpper()); data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength + @@ -1535,11 +1676,10 @@ try { - OpenPassthroughControl(Gateway); var passData = GetkeyColorData(keyNum); var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; var data = new JObject { { "PassData", passData } }; - jObject.Add("Data", data); + jObject.Add("Data", data); Gateway.Send(("ClientDataPassthrough"), jObject.ToString()); } catch { } @@ -1734,11 +1874,10 @@ try { - OpenPassthroughControl(Gateway); var passData = SendPanelSwitchLevelData(reserve); var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; var data = new JObject { { "PassData", passData } }; - jObject.Add("Data", data); + jObject.Add("Data", data); Gateway.Send(("ClientDataPassthrough"), jObject.ToString()); } catch { } @@ -1803,12 +1942,12 @@ /// </summary> public ErrorResponData errorResponData; /// <summary> - ///鎸夐敭寮�鐘舵�侊紙鎸囩ず锛変寒搴� + ///鎸夐敭寮�鐘舵�侊紙鎸囩ず锛変寒搴�(杩欎釜鏄偣鍑诲悗鐨勫��) /// </summary> public int panelDirectionsLevel = -1; /// <summary> - /// 鎸夐敭鍏崇姸鎬侊紙鑳屽厜锛変寒搴� + /// 鎸夐敭鍏崇姸鎬侊紙鑳屽厜锛変寒搴�(杩欎釜鏄偣鍑诲墠鐨勫��) /// </summary> public int panelBacklightLevel = -1; } @@ -1890,15 +2029,14 @@ }; Gateway.Actions += action; - System.Console.WriteLine("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString()); - + System.Console.WriteLine("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString()); + try { - OpenPassthroughControl(Gateway); var passData = SendPanelSaveEnergyModeData(reserve); var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; var data = new JObject { { "PassData", passData } }; - jObject.Add("Data", data); + jObject.Add("Data", data); Gateway.Send(("ClientDataPassthrough"), jObject.ToString()); } catch { } @@ -1991,407 +2129,407 @@ /// 鑺傝兘妯″紡浜害(0-100) /// </summary> public int level = -1; - } + } #endregion - + #region 閰嶇疆鎸夐敭鎸囩ず鐏潯鐪犵粍鍒嗭紙鏆傛椂涓嶅仛锛� ///<summary > ///鑾峰彇鎸夐敭鎸囩ず鐏潯鐪犵粍 ///<para>sleepGroup:鐫$湢缁勫彿</para> /// </summary> - //public async System.Threading.Tasks.Task<PanelSleepGroupResponseAllData> GetPanelSleepGroupAsync(SleepGroup sleepGroup) - //{ - // PanelSleepGroupResponseAllData result = null; - // if (Gateway == null) - // { - // result = new PanelSleepGroupResponseAllData { errorMessageBase = "褰撳墠娌℃湁缃戝叧" }; - // return result; - // } - // return await System.Threading.Tasks.Task.Run(async () => - // { - // Action<string, string> action = (topic, message) => - // { - // var gatewayID = topic.Split('/')[0]; - // var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); - - // if (topic == gatewayID + "/" + "Error_Respon") - // { - // var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID }; - // var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString()); - - // if (temp == null) - // { - // result = new PanelSleepGroupResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" }; - // } - - // else - // { - // result = new PanelSleepGroupResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; - // } - // } - // if (topic == gatewayID + "/" + "ZbDataPassthrough") - // { - // var gatewayTemp = new ZbGateway() { DataID = jobject.Value<int>("Data_ID") }; - // gatewayTemp.clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString()); - - // if (gatewayTemp.clientDataPassthroughResponseData == null) - // { - // result = new PanelSleepGroupResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - // } - // else - // { - // if (gatewayTemp.clientDataPassthroughResponseData?.PassData != null) - // { - // var data = gatewayTemp.clientDataPassthroughResponseData.PassData; - // if (data.Length == 14) - // { - // var tempR = new PanelSleepGroupResponseData(); - // tempR.status = int.Parse(data[12].ToString() + data[13].ToString()); - // switch (data[10].ToString() + data[11].ToString()) - // { - // case "01": - // tempR.sleepGroupNum = SleepGroupNum.Group1; - // break; - // case "02": - // tempR.sleepGroupNum = SleepGroupNum.Group2; - // break; - // case "03": - // tempR.sleepGroupNum = SleepGroupNum.Group3; - // break; - // case "04": - // tempR.sleepGroupNum = SleepGroupNum.Group4; - // break; - // case "05": - // tempR.sleepGroupNum = SleepGroupNum.Group5; - // break; - // case "06": - // tempR.sleepGroupNum = SleepGroupNum.Group6; - // break; - // case "07": - // tempR.sleepGroupNum = SleepGroupNum.Group7; - // break; - // case "08": - // tempR.sleepGroupNum = SleepGroupNum.Group8; - // break; - // case "09": - // tempR.sleepGroupNum = SleepGroupNum.Group9; - // break; - // case "0a": - // tempR.sleepGroupNum = SleepGroupNum.Group10; - // break; - // case "0b": - // tempR.sleepGroupNum = SleepGroupNum.Group11; - // break; - // case "0c": - // tempR.sleepGroupNum = SleepGroupNum.Group12; - // break; - // case "0d": - // tempR.sleepGroupNum = SleepGroupNum.Group13; - // break; - // case "0e": - // tempR.sleepGroupNum = SleepGroupNum.Group14; - // break; - // case "0f": - // tempR.sleepGroupNum = SleepGroupNum.Group15; - // break; - // } - // result = new PanelSleepGroupResponseAllData { panelSleepGroupResponseData = tempR }; - // } - // } - // System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); - // } - // } - // }; - - // Gateway.Actions += action; - // System.Console.WriteLine("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString()); - - // try - // { - // OpenPassthroughControl(Gateway); - // var passData = SetPanelSleepGroupData(sleepGroup); - // var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; - // var data = new JObject { { "PassData", passData } }; - // jObject.Add("Data", data); - // CurrentGateWayId = Gateway.getGatewayBaseInfo?.gwID; - // Gateway.Send(("ClientDataPassthrough"), jObject.ToString()); - // } - // catch { } - - // var dateTime = DateTime.Now; - // while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime) - // { - // await System.Threading.Tasks.Task.Delay(10); - // if (result != null) - // { - // break; - // } - // } - // if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) - // { - // result = new PanelSleepGroupResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; - // } - // Gateway.Actions -= action; - // System.Console.WriteLine("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString()); - - // return result; - // }); - //} - - ///// <summary> - ///// 缁戝畾璁惧淇℃伅,缃戝叧鍙嶉淇℃伅 - ///// </summary> - //public PanelSleepGroupResponseAllData panelSleepGroupResponseAllData; - //[System.Serializable] - //public class PanelSleepGroupResponseAllData - //{ - // /// <summary> - // /// 閿欒淇℃伅 - // /// </summary> - // public string errorMessageBase; - // /// <summary> - // /// 缃戝叧淇℃伅閿欒鍙嶉 - // /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para> - // /// </summary> - // public ErrorResponData errorResponData; - // /// <summary> - // /// 缁戝畾璁惧淇℃伅 - // /// </summary> - // public PanelSleepGroupResponseData panelSleepGroupResponseData; - //} - - ///// <summary> - ///// 缁戝畾璁惧淇℃伅,缃戝叧鍙嶉淇℃伅 - ///// </summary> - //public PanelSleepGroupResponseData panelSleepGroupResponseData; - //[System.Serializable] - //public class PanelSleepGroupResponseData - //{ - // /// <summary> - // /// 鐫$湢缁勫彿 - // /// </summary> - // public SleepGroupNum sleepGroupNum; - // /// <summary> - // /// 鐘舵�� - // /// <para>0--鎵ц 1鈥斿敜閱�</para> - // /// </summary> - // public int status; - //} - - ///// <summary> - ///// 閰嶇疆鎸夐敭鎸囩ず鐏潯鐪犵粍鍒嗗尯 - ///// </summary> - //string SetPanelSleepGroupData(SleepGroup sleepGroup) - //{ - // string data = ""; - // string dataLength = "06"; - // string dataComand1 = "0a"; - // string dataComand2 = "04"; - // string dataSerialNum = "01"; - // string addDataLength = "02"; - // int attributeData = 0; - - // try - // { - // int bit0 = 0, bit1 = 0, bit2 = 0, bit3 = 0, bit4 = 0, bit5 = 0, bit6 = 0, bit7 = 0, bit8 = 0, bit9 = 0, bit10 = 0, bit11 = 0, bit12 = 0, bit13 = 0, bit14 = 0, bit15 = 0; - // if (sleepGroup != null) - // { - // if (sleepGroup.bit0) - // { - // bit0 = 1; - // } - // if (sleepGroup.bit1) - // { - // bit1 = 1; - // } - // if (sleepGroup.bit2) - // { - // bit2 = 1; - // } - // if (sleepGroup.bit3) - // { - // bit3 = 1; - // } - // if (sleepGroup.bit4) - // { - // bit4 = 1; - // } - // if (sleepGroup.bit5) - // { - // bit5 = 1; - // } - // if (sleepGroup.bit6) - // { - // bit6 = 1; - // } - // if (sleepGroup.bit7) - // { - // bit7 = 1; - // } - // if (sleepGroup.bit8) - // { - // bit8 = 1; - // } - // if (sleepGroup.bit9) - // { - // bit9 = 1; - // } - // if (sleepGroup.bit10) - // { - // bit10 = 1; - // } - // if (sleepGroup.bit11) - // { - // bit11 = 1; - // } - // if (sleepGroup.bit12) - // { - // bit12 = 1; - // } - // if (sleepGroup.bit13) - // { - // bit13 = 1; - // } - // if (sleepGroup.bit14) - // { - // bit14 = 1; - // } - // if (sleepGroup.bit15) - // { - // bit15 = 1; - // } - // attributeData = bit0 * 1 + bit1 * 2 + bit2 * 4 + bit3 * 8 + bit4 * 16 + bit5 * 32 + bit6 * 64 + bit7 * 128 + bit8 * 256 + bit9 * 512 + bit10 * 1024 + bit11 * 2048 + bit12 * 4096 + bit13 * 8192 + bit14 * 16384 + bit15 * 32768; - // } - // string tempAttributeData = attributeData.ToString("X4"); - - // if (sleepGroup != null) - // { - // data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength + - // tempAttributeData; - // } - // } - // catch { }; - - // return data; - //} - - ///// <summary> - ///// 鐫$湢缁勫彿锛堝彲浣嶆垨锛� - ///// </summary> - //public class SleepGroup - //{ - // /// <summary> - // /// false:鍏� - // /// true:寮� - // /// </summary> - // public bool bit0; - // /// <summary> - // /// false:鍏� - // /// true:寮� - // /// </summary> - // public bool bit1; - // /// <summary> - // /// false:鍏� - // /// true:寮� - // /// </summary> - // public bool bit2; - // /// <summary> - // /// false:鍏� - // /// true:寮� - // /// </summary> - // public bool bit3; - // /// <summary> - // /// false:鍏� - // /// true:寮� - // /// </summary> - // public bool bit4; - // /// <summary> - // /// false:鍏� - // /// true:寮� - // /// </summary> - // public bool bit5; - // /// <summary> - // /// false:鍏� - // /// true:寮� - // /// </summary> - // public bool bit6; - // /// <summary> - // /// false:鍏� - // /// true:寮� - // /// </summary> - // public bool bit7; - // /// <summary> - // /// false:鍏� - // /// true:寮� - // /// </summary> - // public bool bit8; - // /// <summary> - // /// false:鍏� - // /// true:寮� - // /// </summary> - // public bool bit9; - // /// <summary> - // /// false:鍏� - // /// true:寮� - // /// </summary> - // public bool bit10; - // /// <summary> - // /// false:鍏� - // /// true:寮� - // /// </summary> - // public bool bit11; - // /// <summary> - // /// false:鍏� - // /// true:寮� - // /// </summary> - // public bool bit12; - // /// <summary> - // /// false:鍏� - // /// true:寮� - // /// </summary> - // public bool bit13; - // /// <summary> - // /// false:鍏� - // /// true:寮� - // /// </summary> - // public bool bit14; - // /// <summary> - // /// false:鍏� - // /// true:寮� - // /// </summary> - // public bool bit15; - //} - - ///// <summary> - ///// 鎵ц鎸夐敭鎸囩ず鐏潯鐪犵粍 - ///// </summary> - //public enum SleepGroupNum - //{ - // Group1 = 1, - // Group2 = 2, - // Group3 = 3, - // Group4 = 4, - // Group5 = 5, - // Group6 = 6, - // Group7 = 7, - // Group8 = 8, - // Group9 = 9, - // Group10 = 10, - // Group11 = 11, - // Group12 = 12, - // Group13 = 13, - // Group14 = 14, - // Group15 = 15, - // Group16 = 16, - //} + //public async System.Threading.Tasks.Task<PanelSleepGroupResponseAllData> GetPanelSleepGroupAsync(SleepGroup sleepGroup) + //{ + // PanelSleepGroupResponseAllData result = null; + // if (Gateway == null) + // { + // result = new PanelSleepGroupResponseAllData { errorMessageBase = "褰撳墠娌℃湁缃戝叧" }; + // return result; + // } + // return await System.Threading.Tasks.Task.Run(async () => + // { + // Action<string, string> action = (topic, message) => + // { + // var gatewayID = topic.Split('/')[0]; + // var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); + + // if (topic == gatewayID + "/" + "Error_Respon") + // { + // var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID }; + // var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString()); + + // if (temp == null) + // { + // result = new PanelSleepGroupResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" }; + // } + + // else + // { + // result = new PanelSleepGroupResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; + // } + // } + // if (topic == gatewayID + "/" + "ZbDataPassthrough") + // { + // var gatewayTemp = new ZbGateway() { DataID = jobject.Value<int>("Data_ID") }; + // gatewayTemp.clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString()); + + // if (gatewayTemp.clientDataPassthroughResponseData == null) + // { + // result = new PanelSleepGroupResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; + // } + // else + // { + // if (gatewayTemp.clientDataPassthroughResponseData?.PassData != null) + // { + // var data = gatewayTemp.clientDataPassthroughResponseData.PassData; + // if (data.Length == 14) + // { + // var tempR = new PanelSleepGroupResponseData(); + // tempR.status = int.Parse(data[12].ToString() + data[13].ToString()); + // switch (data[10].ToString() + data[11].ToString()) + // { + // case "01": + // tempR.sleepGroupNum = SleepGroupNum.Group1; + // break; + // case "02": + // tempR.sleepGroupNum = SleepGroupNum.Group2; + // break; + // case "03": + // tempR.sleepGroupNum = SleepGroupNum.Group3; + // break; + // case "04": + // tempR.sleepGroupNum = SleepGroupNum.Group4; + // break; + // case "05": + // tempR.sleepGroupNum = SleepGroupNum.Group5; + // break; + // case "06": + // tempR.sleepGroupNum = SleepGroupNum.Group6; + // break; + // case "07": + // tempR.sleepGroupNum = SleepGroupNum.Group7; + // break; + // case "08": + // tempR.sleepGroupNum = SleepGroupNum.Group8; + // break; + // case "09": + // tempR.sleepGroupNum = SleepGroupNum.Group9; + // break; + // case "0a": + // tempR.sleepGroupNum = SleepGroupNum.Group10; + // break; + // case "0b": + // tempR.sleepGroupNum = SleepGroupNum.Group11; + // break; + // case "0c": + // tempR.sleepGroupNum = SleepGroupNum.Group12; + // break; + // case "0d": + // tempR.sleepGroupNum = SleepGroupNum.Group13; + // break; + // case "0e": + // tempR.sleepGroupNum = SleepGroupNum.Group14; + // break; + // case "0f": + // tempR.sleepGroupNum = SleepGroupNum.Group15; + // break; + // } + // result = new PanelSleepGroupResponseAllData { panelSleepGroupResponseData = tempR }; + // } + // } + // System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); + // } + // } + // }; + + // Gateway.Actions += action; + // System.Console.WriteLine("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString()); + + // try + // { + // OpenPassthroughControl(Gateway); + // var passData = SetPanelSleepGroupData(sleepGroup); + // var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; + // var data = new JObject { { "PassData", passData } }; + // jObject.Add("Data", data); + // CurrentGateWayId = Gateway.getGatewayBaseInfo?.gwID; + // Gateway.Send(("ClientDataPassthrough"), jObject.ToString()); + // } + // catch { } + + // var dateTime = DateTime.Now; + // while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime) + // { + // await System.Threading.Tasks.Task.Delay(10); + // if (result != null) + // { + // break; + // } + // } + // if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) + // { + // result = new PanelSleepGroupResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; + // } + // Gateway.Actions -= action; + // System.Console.WriteLine("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString()); + + // return result; + // }); + //} + + ///// <summary> + ///// 缁戝畾璁惧淇℃伅,缃戝叧鍙嶉淇℃伅 + ///// </summary> + //public PanelSleepGroupResponseAllData panelSleepGroupResponseAllData; + //[System.Serializable] + //public class PanelSleepGroupResponseAllData + //{ + // /// <summary> + // /// 閿欒淇℃伅 + // /// </summary> + // public string errorMessageBase; + // /// <summary> + // /// 缃戝叧淇℃伅閿欒鍙嶉 + // /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para> + // /// </summary> + // public ErrorResponData errorResponData; + // /// <summary> + // /// 缁戝畾璁惧淇℃伅 + // /// </summary> + // public PanelSleepGroupResponseData panelSleepGroupResponseData; + //} + + ///// <summary> + ///// 缁戝畾璁惧淇℃伅,缃戝叧鍙嶉淇℃伅 + ///// </summary> + //public PanelSleepGroupResponseData panelSleepGroupResponseData; + //[System.Serializable] + //public class PanelSleepGroupResponseData + //{ + // /// <summary> + // /// 鐫$湢缁勫彿 + // /// </summary> + // public SleepGroupNum sleepGroupNum; + // /// <summary> + // /// 鐘舵�� + // /// <para>0--鎵ц 1鈥斿敜閱�</para> + // /// </summary> + // public int status; + //} + + ///// <summary> + ///// 閰嶇疆鎸夐敭鎸囩ず鐏潯鐪犵粍鍒嗗尯 + ///// </summary> + //string SetPanelSleepGroupData(SleepGroup sleepGroup) + //{ + // string data = ""; + // string dataLength = "06"; + // string dataComand1 = "0a"; + // string dataComand2 = "04"; + // string dataSerialNum = "01"; + // string addDataLength = "02"; + // int attributeData = 0; + + // try + // { + // int bit0 = 0, bit1 = 0, bit2 = 0, bit3 = 0, bit4 = 0, bit5 = 0, bit6 = 0, bit7 = 0, bit8 = 0, bit9 = 0, bit10 = 0, bit11 = 0, bit12 = 0, bit13 = 0, bit14 = 0, bit15 = 0; + // if (sleepGroup != null) + // { + // if (sleepGroup.bit0) + // { + // bit0 = 1; + // } + // if (sleepGroup.bit1) + // { + // bit1 = 1; + // } + // if (sleepGroup.bit2) + // { + // bit2 = 1; + // } + // if (sleepGroup.bit3) + // { + // bit3 = 1; + // } + // if (sleepGroup.bit4) + // { + // bit4 = 1; + // } + // if (sleepGroup.bit5) + // { + // bit5 = 1; + // } + // if (sleepGroup.bit6) + // { + // bit6 = 1; + // } + // if (sleepGroup.bit7) + // { + // bit7 = 1; + // } + // if (sleepGroup.bit8) + // { + // bit8 = 1; + // } + // if (sleepGroup.bit9) + // { + // bit9 = 1; + // } + // if (sleepGroup.bit10) + // { + // bit10 = 1; + // } + // if (sleepGroup.bit11) + // { + // bit11 = 1; + // } + // if (sleepGroup.bit12) + // { + // bit12 = 1; + // } + // if (sleepGroup.bit13) + // { + // bit13 = 1; + // } + // if (sleepGroup.bit14) + // { + // bit14 = 1; + // } + // if (sleepGroup.bit15) + // { + // bit15 = 1; + // } + // attributeData = bit0 * 1 + bit1 * 2 + bit2 * 4 + bit3 * 8 + bit4 * 16 + bit5 * 32 + bit6 * 64 + bit7 * 128 + bit8 * 256 + bit9 * 512 + bit10 * 1024 + bit11 * 2048 + bit12 * 4096 + bit13 * 8192 + bit14 * 16384 + bit15 * 32768; + // } + // string tempAttributeData = attributeData.ToString("X4"); + + // if (sleepGroup != null) + // { + // data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength + + // tempAttributeData; + // } + // } + // catch { }; + + // return data; + //} + + ///// <summary> + ///// 鐫$湢缁勫彿锛堝彲浣嶆垨锛� + ///// </summary> + //public class SleepGroup + //{ + // /// <summary> + // /// false:鍏� + // /// true:寮� + // /// </summary> + // public bool bit0; + // /// <summary> + // /// false:鍏� + // /// true:寮� + // /// </summary> + // public bool bit1; + // /// <summary> + // /// false:鍏� + // /// true:寮� + // /// </summary> + // public bool bit2; + // /// <summary> + // /// false:鍏� + // /// true:寮� + // /// </summary> + // public bool bit3; + // /// <summary> + // /// false:鍏� + // /// true:寮� + // /// </summary> + // public bool bit4; + // /// <summary> + // /// false:鍏� + // /// true:寮� + // /// </summary> + // public bool bit5; + // /// <summary> + // /// false:鍏� + // /// true:寮� + // /// </summary> + // public bool bit6; + // /// <summary> + // /// false:鍏� + // /// true:寮� + // /// </summary> + // public bool bit7; + // /// <summary> + // /// false:鍏� + // /// true:寮� + // /// </summary> + // public bool bit8; + // /// <summary> + // /// false:鍏� + // /// true:寮� + // /// </summary> + // public bool bit9; + // /// <summary> + // /// false:鍏� + // /// true:寮� + // /// </summary> + // public bool bit10; + // /// <summary> + // /// false:鍏� + // /// true:寮� + // /// </summary> + // public bool bit11; + // /// <summary> + // /// false:鍏� + // /// true:寮� + // /// </summary> + // public bool bit12; + // /// <summary> + // /// false:鍏� + // /// true:寮� + // /// </summary> + // public bool bit13; + // /// <summary> + // /// false:鍏� + // /// true:寮� + // /// </summary> + // public bool bit14; + // /// <summary> + // /// false:鍏� + // /// true:寮� + // /// </summary> + // public bool bit15; + //} + + ///// <summary> + ///// 鎵ц鎸夐敭鎸囩ず鐏潯鐪犵粍 + ///// </summary> + //public enum SleepGroupNum + //{ + // Group1 = 1, + // Group2 = 2, + // Group3 = 3, + // Group4 = 4, + // Group5 = 5, + // Group6 = 6, + // Group7 = 7, + // Group8 = 8, + // Group9 = 9, + // Group10 = 10, + // Group11 = 11, + // Group12 = 12, + // Group13 = 13, + // Group14 = 14, + // Group15 = 15, + // Group16 = 16, + //} #endregion - + #region 閰嶇疆闈㈡澘鍔熻兘 ///<summary > ///閰嶇疆闈㈡澘鍔熻兘 ///<para>value:缁欓潰鏉块厤缃殑妯″紡</para> /// </summary> - public async System.Threading.Tasks.Task<SetWritableValueResponAllData> ConfigureHdlKeyValueAsync(KeyMode value) + public async System.Threading.Tasks.Task<SetWritableValueResponAllData> ConfigureHdlKeyValueAsync(KeyMode value, int clusterID = 6) { if (Gateway == null) { @@ -2440,9 +2578,9 @@ System.Console.WriteLine("SetWritableValue_Actions 鍚姩" + "_" + System.DateTime.Now.ToString()); try { - var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 6 }, { "Command", 120 } }; + var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", clusterID }, { "Command", 120 } }; var data = new JObject { { "Undivided", 0 }, { "AttributeId", 6533 }, { "AttributeDataType", 33 }, { "AttributeData", (int)value } }; - jObject.Add("Data", data); + jObject.Add("Data", data); Gateway.Send("SetWritableValue", jObject.ToString()); } catch { } @@ -2487,20 +2625,30 @@ /// 寮�鍏崇被鍨嬧�斺�斿彇鍙�. /// </summary> OnOff_OnOff = 102, - /// <summary> - /// 浜害绫诲瀷鈥斺�旇皟澶�. + /// 浜害绫诲瀷鈥斺�旀寜绛夌骇璋冨ぇ. /// </summary> Level_Step_Up = 200, /// <summary> - /// 浜害绫诲瀷鈥斺�旇皟灏�. + /// 浜害绫诲瀷鈥斺�旀寜绛夌骇璋冨皬. /// </summary> Level_Step_Down = 201, /// <summary> - /// 浜害绫诲瀷鈥斺�斿彇鍙�. + /// 浜害绫诲瀷鈥斺�旀寜绛夌骇鍙栧弽. /// </summary> Level_Step_Up_Down = 202, - + /// <summary> + /// 浜害绫诲瀷鈥斺�斿彇鍙�. + /// </summary> + Level_Up = 203, + /// <summary> + /// 浜害绫诲瀷鈥斺�斿彇鍙�. + /// </summary> + Level_Down = 204, + /// <summary> + /// 浜害绫诲瀷鈥斺�斿彇鍙�. + /// </summary> + Level_Up_Down = 205, /// <summary> /// 绐楀笜绫诲瀷鈥斺�斿紑. /// </summary> @@ -2521,6 +2669,10 @@ /// 绐楀笜绫诲瀷鈥斺�斾笅闄嶅仠姝�. /// </summary> Wcd_Down_Stop = 304, + /// <summary> + /// 绐楀笜绫诲瀷鈥斺�斾笅闄嶅仠姝�. + /// </summary> + Default = 65535, } #endregion @@ -2618,7 +2770,7 @@ } }; var data = new JObject { { "AttriBute", attriBute } }; - JObject.Add("Data", data); + JObject.Add("Data", data); Gateway?.Send(("GetDeviceStatus"), JObject.ToString()); } catch @@ -2644,8 +2796,8 @@ return d; }); - } - + } + /// <summary> /// 缃戝叧鎭㈠鍑哄巶璁剧疆杩斿洖鏁版嵁 /// </summary> @@ -2668,993 +2820,136 @@ } #endregion - //#region 璁惧缁戝畾 - ///// <summary> - /////璁惧缁戝畾 - ///// </summary> - //public async System.Threading.Tasks.Task<AddedDeviceBindResponseAllData> AddDeviceBindAsync(AddBindData addBindData) - //{ - // return await System.Threading.Tasks.Task.Run(async () => - // { - // var result = new AddedDeviceBindResponseAllData(); - // var mainGateway = ZbGateway.MainGateWay; - // if (mainGateway == null) - // { - // result.errorMessageBase = "褰撳墠娌℃湁涓荤綉鍏�"; - // return result; - // } - // Action<string, string> action = (topic, message) => - // { - // System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); - // var gatewayID = topic.Split('/')[0]; - // var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); - // if (topic == gatewayID + "/" + "Error_Respon") - // { - // var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = mainGateway.getGatewayBaseInfo.gwID }; - // var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString()); + #region 鑾峰彇缃戝叧涓殑鍦烘櫙 + /// <summary> + /// 鍙兘鑾峰彇鍦烘櫙淇℃伅锛屾病鏈夊満鏅腑鐨勮澶囦俊鎭� + /// </summary> + /// <returns></rxeturns> + public async System.Threading.Tasks.Task<GetOnlySceneAllData> GetSceneInfoAsync() + { + GetOnlySceneAllData result = null; + if (ZbGateway.MainGateWay == null) + { + result = new GetOnlySceneAllData { errorMessageBase = "娌℃湁涓荤綉鍏�" }; + } + return await System.Threading.Tasks.Task.Run(async () => + { + Action<string, string> action = (topic, message) => + { + var gatewayID = topic.Split('/')[0]; + var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); + if (topic == gatewayID + "/" + "Error_Respon") + { + var tempResult = Newtonsoft.Json.JsonConvert.DeserializeObject<ErrorResponData>(jobject["Data"].ToString()); + if (tempResult == null) + { + result = new GetOnlySceneAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" }; + } + else + { + result = new GetOnlySceneAllData { errorResponData = tempResult }; + } + } - // if (temp == null) - // { - // result.errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖"; - // } - // else - // { - // result.errorResponData = temp; - // result.errorMessageBase = ErrorMess(temp.Error); - // } - // } - // else if (topic == gatewayID + "/" + "Bind/SetBind_Respon") - // { - // var gatewayTemp = new ZbGateway() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = mainGateway.getGatewayBaseInfo.gwID }; - // //var tempBindName = Newtonsoft.Json.JsonConvert.DeserializeObject<string>(jobject["Data"]["BindName"].ToString()); - // var tempBindList = Newtonsoft.Json.Linq.JArray.Parse(jobject["Data"]["BindList"].ToString()); - // if (tempBindList == null) - // { - // result.errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�"; - // } - // else - // { - // var dataBindRes = new AddedDeviceBindResponseData(); - // for (int m = 0; tempBindList != null && m < tempBindList.Count; m++) - // { - // var tempBind = tempBindList[m]; - // dataBindRes.BindList.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<AddBindListResponseObj>(tempBind.ToString())); - // } - // if (dataBindRes != null) - // { - // result.addedDeviceBindResponseData = dataBindRes; - // System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{topic}"); - // } - // } - // } - // else if (topic == gatewayID + "/" + "Bind/BindResult") - // { - // var gatewayTemp = new ZbGateway() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = mainGateway.getGatewayBaseInfo.gwID }; - // var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<AddBindResultResponseData>(jobject["Data"].ToString()); + if (topic == gatewayID + "/" + "Scene/GetInfo_Respon") + { + var getSceneInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<GetSceneInfo>(jobject["Data"].ToString()); + if (getSceneInfo == null) + { + result = new GetOnlySceneAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" }; + } + else + { + result = new GetOnlySceneAllData { getSceneInfo = getSceneInfo }; + } + } + }; + ZbGateway.MainGateWay.Actions += action; + System.Console.WriteLine("Scene/GetInfo_Actions 鍚姩" + System.DateTime.Now.ToString()); + var jobjectData = new JObject { { "Cluster_ID", 0 }, { "Command", 805 } }; + await ZbGateway.MainGateWay.Send(("Scene/GetInfo"), System.Text.Encoding.UTF8.GetBytes(jobjectData.ToString())); - // if (tempData != null) - // { - // result.addBindResultResponseData = tempData; - // } - // } - // }; - // mainGateway.Actions += action; - // System.Console.WriteLine("Bind/SetBind_Actions 鍚姩" + "_" + System.DateTime.Now.ToString()); - // try - // { - // if (addBindData != null) - // { - // var jObject = new JObject { { "DeviceAddr", addBindData.DeviceAddr }, { "Epoint", addBindData.Epoint }, { "Cluster_ID", 0 }, { "Command", 5001 } }; - // var bindList = new JArray { }; - // foreach (var bindInfo in addBindData.BindList) - // { - // if (bindInfo.BindType == 0) - // { - // var dInfo = new JObject{ - // { "BindMacAddr",bindInfo.BindMacAddr}, - // { "BindEpoint", bindInfo.BindEpoint} , - // { "BindCluster", bindInfo.BindCluster} , - // { "BindType",bindInfo.BindType} - // }; - // bindList.Add(dInfo); - // } - // else if (bindInfo.BindType == 1) - // { - // var dInfo = new JObject{ - // { "BindCluster", bindInfo.BindCluster} , - // { "BindType",bindInfo.BindType}, - // { "BindScenesId", bindInfo.BindScenesId} - // }; - // bindList.Add(dInfo); - // } - // } - // var data = new JObject{ - // {"BindName",addBindData.BindName}, - // { "BindList", bindList } - // }; - // jObject.Add("Data", data); - // mainGateway.Send("Bind/SetBind", jObject.ToString()); - // } - // } - // catch - // { - // } - - // var dateTime = DateTime.Now; - // while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime) - // { - // await System.Threading.Tasks.Task.Delay(100); - // if (result == null || result.addedDeviceBindResponseData == null) - // { - // continue; - // } - // if (0 < result.addedDeviceBindResponseData.BindList.FindAll((obj) => obj.BindType == 0).Count) - // { - // if (result.addBindResultResponseData != null) - // { - // break; - // } - // } - // else - // { - // break; - // } - // } - // if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) - // { - // result.errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔"; - // } - // mainGateway.Actions -= action; - // System.Console.WriteLine($"Bind/SetBind_Actions 閫�鍑� {System.DateTime.Now}"); - // return result; - // }); - //} - - ///// <summary> - ///// 缁戝畾璁惧淇℃伅,缃戝叧鍙嶉淇℃伅 - ///// </summary> - //public AddedDeviceBindResponseAllData addedDeviceBindResponseAllData; - //[System.Serializable] - //public class AddedDeviceBindResponseAllData - //{ - // /// <summary> - // /// 閿欒淇℃伅 - // /// </summary> - // public string errorMessageBase; - // /// <summary> - // /// 缃戝叧淇℃伅閿欒鍙嶉 - // /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para> - // /// </summary> - // public ErrorResponData errorResponData; - // /// <summary> - // /// 缃戝叧鐩存帴鍙嶉缁戝畾璁惧淇℃伅 - // /// </summary> - // public AddedDeviceBindResponseData addedDeviceBindResponseData; - // /// <summary> - // /// 鎸夐敭璁惧鐨勭‘璁ゅ弽棣堢粦瀹氳澶囦俊鎭� - // /// </summary> - // public AddBindResultResponseData addBindResultResponseData; - //} - - ///// <summary> - ///// 缁戝畾璁惧淇℃伅 - ///// </summary> - //public AddedDeviceBindResponseData addedDeviceBindResponseData; - //[System.Serializable] - //public class AddedDeviceBindResponseData - //{ - // /// <summary> - // ///缁戝畾鍚嶇О - // /// </summary> - // public string BindName; - // /// <summary> - // ///缁戝畾鍒楄〃 锛屽綋Status=0鏃跺瓨鍦� - // /// </summary> - // public List<AddBindListResponseObj> BindList = new List<AddBindListResponseObj>(); - //} - - ///// <summary> - ///// 缁戝畾鍒楄〃鐨勪俊鎭� - ///// </summary> - //[System.Serializable] - //public class AddBindListResponseObj : BindListResponseObj - //{ - // /// <summary> - // /// 0锛氬姞鍏ユ垚鍔燂紙璇ョ姸鎬佸彧閫傜敤鐢ㄤ簬璺ㄧ綉鍏崇粦瀹氬拰缁戝畾鍦烘櫙銆傚悓缃戝叧璁惧闂寸殑缁戝畾闇�瑕佽妭鐐硅澶囩殑纭鎴愬姛淇℃伅锛屼笉浼氱洿鎺ュ弽棣堟垚鍔熴�傦級 - // ///<para>1锛氬け璐ワ紝鑺傜偣璁惧鎴栧満鏅笉瀛樺湪銆�</para> - // ///<para>2锛氭湭鐭ワ紝鐢辫妭鐐硅澶囧弽棣堝彂閫佲�淏ind/BindResult鈥濅富棰樻秷鎭‘瀹氭槸鍚︽垚鍔熴��</para> - // ///<para>3锛氱粦瀹氬凡缁忓瓨鍦ㄣ��</para> - // /// </summary> - // public int Result; - //} - - ///// <summary> - ///// 鎸夐敭璁惧鐨勭‘璁ょ殑淇℃伅 - ///// </summary> - //[System.Serializable] - //public class AddBindResultResponseData - //{ - // /// <summary> - // ///缁戝畾缁撴灉 - // ///<para>0锛氭垚鍔�</para> - // ///<para>140锛氬け璐ワ紝鎺у埗璁惧鐨勭粦瀹氬垪琛ㄥ凡婊�</para> - // ///<para>鍏朵粬锛氬け璐�</para> - // /// </summary> - // public int Result; - // /// <summary> - // /// 缁戝畾鐨刢luster - // /// </summary> - // public int BindCluster; - // /// <summary> - // /// 缁戝畾璁惧Mac鍦板潃锛� 褰揃indType=0鏃跺瓨鍦� - // /// </summary> - // public string BindMacAddr; - // /// <summary> - // /// 缁戝畾璁惧鐨勭鍙e彿锛屽綋BindType=0鏃跺瓨鍦� - // /// </summary> - // public int BindEpoint; - // /// <summary> - // /// 缁戝畾鍦烘櫙锛屽綋BindType=2鏃跺瓨鍦� - // /// </summary> - // public int BindScenesId; - // /// <summary> - // /// 缁戝畾璁惧鐨勫悕绉� - // /// </summary> - // public string DeviceName; - //} - - ///// <summary> - ///// 缁戝畾璁惧鐨勬暟鎹� - ///// </summary> - //public AddBindData addBindData; - //[System.Serializable] - //public class AddBindData - //{ - // /// <summary> - // /// 鎺у埗璁惧鑺傜偣鐨刴ac鍦板潃 - // /// </summary> - // public string DeviceAddr; - // /// <summary> - // /// 閿欒淇℃伅 - // /// </summary> - // public int Epoint; - // /// <summary> - // ///缁戝畾鍚嶇О锛屼笉淇敼鍚嶇О鏃跺拷鐣ヨ閫夐」 - // /// </summary> - // public string BindName; - // /// <summary> - // ///缁戝畾鍒楄〃锛屼笉淇敼缁戝畾鍒楄〃鏃跺拷鐣ヨ閫夐」銆� - // /// </summary> - // public List<AddBindListObj> BindList = new List<AddBindListObj>(); - //} - - ///// <summary> - ///// 鎺у埗璁惧缁戝畾鐨勪俊鎭� - ///// </summary> - //[System.Serializable] - //public class AddBindListObj - //{ - // /// <summary> - // /// 缁戝畾绫诲瀷 - // ///<para>0锛氱粦瀹氳澶� </para> - // ///<para>1锛氱粦瀹氬満鏅�</para> - // /// </summary> - // public int BindType; - // /// <summary> - // /// 缁戝畾鐨刢luster,闇�瑕佹帶鍒惰澶囩殑OutCluster鍒楄〃涓瓨鍦ㄨcluster銆� - // ///濡傜粦瀹氭煇涓澶囩殑on/off锛屼负6銆� - // /// </summary> - // public int BindCluster; - // /// <summary> - // /// 缁戝畾璁惧Mac鍦板潃锛� 褰揃indType=0鏃跺瓨鍦� - // /// </summary> - // public string BindMacAddr; - // /// <summary> - // /// 缁戝畾璁惧鐨勭鍙e彿锛屽綋BindType=0鏃跺瓨鍦� - // /// </summary> - // public int BindEpoint; - // /// <summary> - // /// 缁戝畾鍦烘櫙锛屽綋BindType=1鏃跺瓨鍦� - // /// </summary> - // public int BindScenesId; - //} - //#endregion - - //#region 瑙i櫎缁戝畾 - ///// <summary> - ///// 瑙i櫎缁戝畾 - ///// </summary> - //public async System.Threading.Tasks.Task<DelDeviceBindResponseAllData> DelDeviceBindAsync(DelDeviceBindData delDeviceBindData) - //{ - // return await System.Threading.Tasks.Task.Run(async () => - // { - // var responseData = new DelDeviceBindResponseAllData(); - // var mainGateway = ZbGateway.MainGateWay; - // if (mainGateway == null) - // { - // responseData.errorMessageBase = "褰撳墠娌℃湁涓荤綉鍏�"; - // return responseData; - // } - - // Action<string, string> action = (topic, message) => - // { - // var gatewayID = topic.Split('/')[0]; - // var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); - - // if (topic == gatewayID + "/" + "Error_Respon") - // { - // var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = mainGateway.getGatewayBaseInfo.gwID }; - // var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString()); - - // if (temp == null) - // { - // responseData.errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖"; - // } - // else - // { - // responseData.errorResponData = temp; - // responseData.errorMessageBase = ErrorMess(temp.Error); - // } - // } - - // if (topic == gatewayID + "/" + "Bind/RemoveBind_Respon") - // { - // var gatewayTemp = new ZbGateway() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID }; - // var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<DelDeviceBindResponseData>(jobject["Data"].ToString()); - - // if (tempData == null) - // { - // responseData.errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�"; - - // } - // else - // { - // responseData.delDeviceBindResponseData = tempData; - // System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); - // } - // } - - // if (topic == gatewayID + "/" + "Bind/RemoveBindResult") - // { - // var gatewayTemp = new ZbGateway() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = mainGateway.getGatewayBaseInfo.gwID }; - // var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<RemoveBindResultResponseData>(jobject["Data"].ToString()); - - // if (tempData != null) - // { - // responseData.removeBindResultResponseData = tempData; - // System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); - // } - // } - // }; - // mainGateway.Actions += action; - // System.Console.WriteLine("DeviceBind/DelBind_Actions 鍚姩" + "_" + System.DateTime.Now.ToString()); - // try - // { - // if (delDeviceBindData != null) - // { - // var jObject = new JObject { { "DeviceAddr", delDeviceBindData.DeviceAddr }, { "Epoint", delDeviceBindData.Epoint }, { "Cluster_ID", 0 }, { "Command", 5003 } }; - // var removeBindList = new JArray { }; - // foreach (var removeBindInfo in delDeviceBindData.RemoveBindList) - // { - // if (removeBindInfo.BindType == 0) - // { - // var dInfo = new JObject{ - // { "BindMacAddr",removeBindInfo.BindMacAddr}, - // { "BindEpoint", removeBindInfo.BindEpoint} , - // { "BindCluster", removeBindInfo.BindCluster} , - // { "BindType",removeBindInfo.BindType} - // }; - // removeBindList.Add(dInfo); - // } - // else if (removeBindInfo.BindType == 1) - // { - // var dInfo = new JObject{ - // { "BindCluster", removeBindInfo.BindCluster} , - // { "BindType",removeBindInfo.BindType}, - // { "BindScenesId", removeBindInfo.BindScenesId} - // }; - // removeBindList.Add(dInfo); - // } - // } - // var data = new JObject { - // {"RemoveBindList",removeBindList} - // }; - // jObject.Add("Data", data); - // mainGateway.Send("Bind/RemoveBind", jObject.ToString()); - // } - // } - // catch { } - - - // var dateTime = DateTime.Now; - // while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime) - // { - // await System.Threading.Tasks.Task.Delay(100); - // if (responseData == null || responseData.delDeviceBindResponseData == null) - // { - // continue; - // } - // if (0 < responseData.delDeviceBindResponseData.RemoveBindList.FindAll((obj) => obj.BindType == 0).Count) - // { - // if (responseData.removeBindResultResponseData != null) - // { - // break; - // } - // } - // else - // { - // break; - // } - // } - - // if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) - // { - // responseData.errorMessageBase = "鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔"; - // } - // mainGateway.Actions -= action; - // System.Console.WriteLine("DeviceBind/DelBind_Actions 閫�鍑�" + System.DateTime.Now.ToString()); - - // return responseData; - // }); - //} - - ///// <summary> - /////瑙i櫎缁戝畾鏁版嵁,缃戝叧鍙嶉淇℃伅 - ///// </summary> - //public DelDeviceBindResponseAllData delDeviceBindResponseAllData; - ///// <summary> - /////瑙i櫎缁戝畾鏁版嵁,缃戝叧鍙嶉淇℃伅 - ///// </summary> - //[System.Serializable] - //public class DelDeviceBindResponseAllData - //{ - // /// <summary> - // /// 閿欒淇℃伅 - // /// </summary> - // public string errorMessageBase; - // /// <summary> - // /// 缃戝叧淇℃伅閿欒鍙嶉 - // /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para> - // /// </summary> - // public ErrorResponData errorResponData; - // /// <summary> - // /// 瑙i櫎缁戝畾鏁版嵁淇℃伅 - // /// </summary> - // public DelDeviceBindResponseData delDeviceBindResponseData; - - // /// <summary> - // /// 瑙i櫎缁戝畾鎸夐敭纭鏁版嵁淇℃伅 - // /// </summary> - // public RemoveBindResultResponseData removeBindResultResponseData; - //} - - ///// <summary> - ///// 瑙i櫎缁戝畾鏁版嵁 - ///// </summary> - //public DelDeviceBindResponseData delDeviceBindResponseData; - ///// <summary> - ///// 瑙i櫎缁戝畾鏁版嵁 - ///// </summary> - //[System.Serializable] - //public class DelDeviceBindResponseData - //{ - // /// <summary> - // ///缁戝畾鍒楄〃 锛屽綋Status=0鏃跺瓨鍦� - // /// </summary> - // public List<RemoveBindListResponseObj> RemoveBindList = new List<RemoveBindListResponseObj>(); - //} - - ///// <summary> - ///// 绉婚櫎璁惧缁戝畾鐨勪俊鎭� - ///// </summary> - //[System.Serializable] - //public class RemoveBindListResponseObj : BindListResponseObj - //{ - // /// <summary> - // /// 0锛氱Щ闄ゆ垚鍔燂紙璇ョ姸鎬佸彧閫傜敤鐢ㄤ簬璺ㄧ綉鍏崇粦瀹氥�佺粦瀹氬満鏅�佸け鏁堣澶囷紙璁惧宸茬粡浠庣綉鍏崇殑璁惧鍒楄〃涓垹闄わ級銆傚悓缃戝叧璁惧闂寸殑瑙i櫎缁戝畾闇�瑕佽妭鐐硅澶囩殑纭鎴愬姛淇℃伅锛屼笉浼氱洿鎺ュ弽棣堟垚鍔熴�傦級 - // ///<para>1锛氬け璐ワ紝璁惧涓嶅湪缁戝畾鍒楄〃涓�</para> - // ///<para>3锛氬け璐ワ紝鍦ㄧ瓑寰呰妭鐐硅澶囩‘璁ゆ槸鍚﹁В闄ょ粦瀹氭垚鍔燂紙褰撶綉鍏宠繕鍦ㄧ瓑寰呮煇鑺傜偣璁惧纭鏄惁瑙i櫎缁戝畾鎴愬姛鐨勫弽棣堜俊鎭椂锛屽鎴风鍐嶆鍙戦�佽В闄ょ粦瀹氳鑺傜偣璁惧鐨勬寚浠わ紝灏嗗弽棣堣鐘舵�併�傦級</para> - // ///<para>4锛氭湭鐭ワ紝鐢辫妭鐐硅澶囧弽棣堝彂閫佲�淏ind/RemoveBindResult鈥濅富棰樻秷鎭‘瀹氭槸鍚︽垚鍔熴��</para> - // /// </summary> - // public int Result; - - //} - - ///// <summary> - ///// 绉婚櫎璁惧缁戝畾鎸夐敭纭鐨勪俊鎭� - ///// </summary> - //[System.Serializable] - //public class RemoveBindResultResponseData - //{ - // /// <summary> - // ///缁戝畾缁撴灉 - // ///<para>0锛氭垚鍔�</para> - // ///<para>136锛氭帶鍒惰澶囨湰鍦扮粦瀹氬垪琛ㄤ腑鏃犳缁戝畾</para> - // ///<para>鍏朵粬锛氬け璐�</para> - // /// </summary> - // public int Result; - - // /// <summary> - // /// 缁戝畾璁惧Mac鍦板潃 - // /// </summary> - // public string BindMacAddr; - // /// <summary> - // /// 缁戝畾璁惧鐨勭鍙e彿 - // /// </summary> - // public int BindEpoint; - // /// <summary> - // /// 缁戝畾鐨刢luster - // /// </summary> - // public int BindCluster; - // /// <summary> - // /// 缁戝畾璁惧鍚嶇О - // /// </summary> - // public string DeviceName; - //} - - ///// <summary> - ///// 瑙i櫎缁戝畾鏁版嵁 - ///// </summary> - //public DelDeviceBindData delDeviceBindData; - ///// <summary> - ///// 瑙i櫎缁戝畾鏁版嵁 - ///// </summary> - //[System.Serializable] - //public class DelDeviceBindData - //{ - // /// <summary> - // /// 鎺у埗璁惧鑺傜偣鐨刴ac鍦板潃 - // /// </summary> - // public string DeviceAddr; - // /// <summary> - // /// 閿欒淇℃伅 - // /// </summary> - // public int Epoint; - // /// <summary> - // ///缁戝畾鍒楄〃 锛屽綋Status=0鏃跺瓨鍦� - // /// </summary> - // public List<RemoveBindListObj> RemoveBindList = new List<RemoveBindListObj>(); - //} - - ///// <summary> - ///// 绉婚櫎璁惧缁戝畾鐨勪俊鎭� - ///// </summary> - //[System.Serializable] - //public class RemoveBindListObj - //{ - - // /// <summary> - // /// 缁戝畾绫诲瀷 - // ///<para>0锛氱Щ闄よ澶� </para> - // ///<para>1锛氱Щ闄ゅ満鏅�</para> - // /// </summary> - // public int BindType; - // /// <summary> - // /// 缁戝畾鐨刢luster - // /// </summary> - // public int BindCluster; - // /// <summary> - // /// 缁戝畾璁惧Mac鍦板潃锛� 褰揃indType=0鏃跺瓨鍦� - // /// </summary> - // public string BindMacAddr; - // /// <summary> - // /// 缁戝畾璁惧鐨勭鍙e彿锛屽綋BindType=0鏃跺瓨鍦� - // /// </summary> - // public int BindEpoint; - // /// <summary> - // /// 缁戝畾鍦烘櫙锛屽綋BindType=1鏃跺瓨鍦� - // /// </summary> - // public int BindScenesId; - //} - //#endregion - - //#region 鑾峰彇鎵�鏈夌粦瀹� - ///// <summary> - /////鑾峰彇鎵�鏈夌粦瀹� - ///// </summary> - //public async System.Threading.Tasks.Task<GetDeviceBindResponseAllData> GetDeviceBindAsyncAsync() - //{ - // return await System.Threading.Tasks.Task.Run(async () => - // { - // GetDeviceBindResponseAllData d = null; - // var mainGateway = ZbGateway.MainGateWay; - // if (mainGateway == null) - // { - // d = new GetDeviceBindResponseAllData { errorMessageBase = "褰撳墠娌℃湁涓荤綉鍏�" }; - // return d; - // } - - // Action<string, string> action = (topic, message) => - // { - // var gatewayID = topic.Split('/')[0]; - // var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); - - // if (topic == gatewayID + "/" + "Error_Respon") - // { - // var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = mainGateway.getGatewayBaseInfo.gwID }; - // var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString()); - - // if (temp == null) - // { - // d = new GetDeviceBindResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" }; - // } - // else - // { - // d = new GetDeviceBindResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; - // } - // } - - // if (topic == gatewayID + "/" + "Bind/GetDeviceBind_Respon") - // { - // var gatewayTemp = new ZbGateway() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = mainGateway.getGatewayBaseInfo.gwID }; - // var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<GetDeviceBindResponseData>(jobject["Data"].ToString()); - // //var tempBindList = Newtonsoft.Json.Linq.JArray.Parse(jobject["Data"]["BindList"].ToString()); - // if (tempData == null) - // { - // d = new GetDeviceBindResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - // } - // else - // { - // d = new GetDeviceBindResponseAllData { getAllBindResponseData = tempData }; - // System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); - // } - // } - // }; - // mainGateway.Actions += action; - - // try - // { - // System.Console.WriteLine("Bind/GetDeviceBind_Actions 鍚姩" + "_" + System.DateTime.Now.ToString()); - // var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 0 }, { "Command", 5007 } }; - // mainGateway.Send("Bind/GetDeviceBind", jObject.ToString()); - // } - // catch { } - - // var dateTime = DateTime.Now; - // while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime) - // { - // await System.Threading.Tasks.Task.Delay(10); - // if (d != null) - // { - // break; - // } - // } - // if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) - // { - // d = new GetDeviceBindResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; - // } - // mainGateway.Actions -= action; - // System.Console.WriteLine("Bind/GetDeviceBind_Actions 閫�鍑�" + System.DateTime.Now.ToString()); - - // return d; - // }); - //} - - ///// <summary> - /////鑾峰彇鎵�鏈夌粦瀹氭暟鎹�,缃戝叧鍙嶉淇℃伅 - ///// </summary> - //public GetDeviceBindResponseAllData getAllBindResponseAllData; - //[System.Serializable] - //public class GetDeviceBindResponseAllData - //{ - // /// <summary> - // /// 閿欒淇℃伅 - // /// </summary> - // public string errorMessageBase; - // /// <summary> - // /// 缃戝叧淇℃伅閿欒鍙嶉 - // /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para> - // /// </summary> - // public ErrorResponData errorResponData; - // /// <summary> - // /// 鎺у埗璁惧缁戝畾鐨勮澶囧垪琛ㄥ洖澶嶆暟鎹� - // /// </summary> - // public GetDeviceBindResponseData getAllBindResponseData; - //} - - ///// <summary> - ///// 鑾峰彇鎵�鏈夌粦瀹氬洖澶嶇殑鏁版嵁 - ///// </summary> - //public GetDeviceBindResponseData getAllBindResponseData; - //[System.Serializable] - //public class GetDeviceBindResponseData - //{ - // /// <summary> - // /// 0锛氭垚鍔� - // ///<para>1锛氱粦瀹氫笉瀛樺湪</para> - // /// </summary> - // public int Result; - // /// <summary> - // /// 缁戝畾鍒楄〃 锛屽綋Status=0鏃跺瓨鍦ㄣ�� - // /// </summary> - // public List<BindListResponseObj> BindList = new List<BindListResponseObj>(); - //} - - ///// <summary> - ///// 鑾峰彇鎵�鏈夌粦瀹氱殑淇℃伅 - ///// </summary> - //public class BindListResponseObj - //{ - // /// <summary> - // /// 缁戝畾绫诲瀷 - // ///<para>0锛氱Щ闄よ澶囷紝鍚岀綉鍏宠澶囬棿鐨勭Щ闄�</para> - // ///<para>1锛氱Щ闄よ澶囷紝璺ㄧ綉鍏宠澶囬棿鐨勭Щ闄�</para> - // ///<para>2锛氱Щ闄ょ粦瀹氬満鏅�</para> - // /// </summary> - // public int BindType; - // /// <summary> - // /// 缁戝畾鐨刢luster - // /// </summary> - // public int BindCluster; - // /// <summary> - // /// 缁戝畾璁惧Mac鍦板潃锛� 褰揃indType=0鏃跺瓨鍦� - // /// </summary> - // public string BindMacAddr; - // /// <summary> - // /// 缁戝畾璁惧鐨勭鍙e彿锛屽綋BindType=0鏃跺瓨鍦� - // /// </summary> - // public int BindEpoint; - // /// <summary> - // /// 缁戝畾鍦烘櫙锛屽綋BindType=1鏃跺瓨鍦� - // /// </summary> - // public int BindScenesId; - // /// <summary> - // /// 缁戝畾鐨勮澶囨垨鍦烘櫙鍚嶇О - // /// </summary> - // public string ESName; - //} - //#endregion - - //#region 鍒犻櫎涓�涓帶鍒惰澶囨墍鏈夌粦瀹氫俊鎭� - ///// <summary> - /////鍒犻櫎涓�涓帶鍒惰澶囨墍鏈夌粦瀹氫俊鎭� - ///// </summary> - //public async System.Threading.Tasks.Task<ClearBindInfoResponseAllData> ClearBindInfoAsync() - //{ - // if (Gateway == null) - // { - // return null; - // } - // return await System.Threading.Tasks.Task.Run(async () => - // { - // ClearBindInfoResponseAllData d = null; - // Action<string, string> action = (topic, message) => - // { - // var gatewayID = topic.Split('/')[0]; - // var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); - - // if (topic == gatewayID + "/" + "Error_Respon") - // { - // var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID }; - // var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString()); - - // if (temp == null) - // { - // d = new ClearBindInfoResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" }; - // } - // else - // { - // d = new ClearBindInfoResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; - // } - // } - - // if (topic == gatewayID + "/" + "Bind/ClearBindInfo_Respon") - // { - // var gatewayTemp = new ZbGateway() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID }; - // var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClearBindInfoResponseData>(jobject["Data"].ToString()); - // if (tempData == null) - // { - // d = new ClearBindInfoResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - // } - // else - // { - // d = new ClearBindInfoResponseAllData { clearBindInfoResponseData = tempData }; - // System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); - // } - // } - // }; - // Gateway.Actions += action; - // System.Console.WriteLine("Bind/ClearBindInfo_Actions 鍚姩" + "_" + System.DateTime.Now.ToString()); - - // try - // { - // var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 0 }, { "Command", 5006 } }; - // Gateway.Send("Bind/ClearBindInfo", jObject.ToString()); - // } - // catch { } - - // var dateTime = DateTime.Now; - // while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime) - // { - // await System.Threading.Tasks.Task.Delay(10); - // if (d != null) - // { - // break; - // } - // } - // if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) - // { - // d = new ClearBindInfoResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; - // } - // Gateway.Actions -= action; - // System.Console.WriteLine("Bind/ClearBindInfo_Actions 閫�鍑�" + System.DateTime.Now.ToString()); - - // return d; - // }); - //} - - ///// <summary> - /////鍒犻櫎涓�涓帶鍒惰澶囨墍鏈夌粦瀹氭暟鎹�,缃戝叧鍙嶉淇℃伅 - ///// </summary> - //public ClearBindInfoResponseAllData clearBindInfoResponseAllData; - //[System.Serializable] - //public class ClearBindInfoResponseAllData - //{ - // /// <summary> - // /// 閿欒淇℃伅 - // /// </summary> - // public string errorMessageBase; - // /// <summary> - // /// 缃戝叧淇℃伅閿欒鍙嶉 - // /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para> - // /// </summary> - // public ErrorResponData errorResponData; - // /// <summary> - // /// 鎺у埗璁惧缁戝畾鐨勮澶囧垪琛ㄥ洖澶嶆暟鎹� - // /// </summary> - // public ClearBindInfoResponseData clearBindInfoResponseData; - //} - - ///// <summary> - ///// 鍒犻櫎涓�涓帶鍒惰澶囨墍鏈夌粦瀹氫俊鎭洖澶嶇殑鏁版嵁 - ///// </summary> - //public ClearBindInfoResponseData clearBindInfoResponseData; - //[System.Serializable] - //public class ClearBindInfoResponseData - //{ - // /// <summary> - // /// 0锛氭垚鍔� - // ///<para>1锛氱粦瀹氫俊鎭笉瀛樺湪</para> - // /// </summary> - // public int Result; - //} - - //#endregion + var dateTime = DateTime.Now; + while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime) + { + await System.Threading.Tasks.Task.Delay(10); + if (result != null) + { + break; + } + } + if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) + { + result = new GetOnlySceneAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; + } + return result; + }); + } + /// <summary> + ///鑾峰彇鍦烘櫙淇℃伅,缃戝叧鍙嶉淇℃伅 + /// </summary> + [System.Serializable] + public class GetOnlySceneAllData + { + /// <summary> + /// 閿欒淇℃伅 + /// </summary> + public string errorMessageBase; + /// <summary> + /// 缃戝叧淇℃伅閿欒鍙嶉 + /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para> + /// </summary> + public ErrorResponData errorResponData; + /// <summary> + /// 鑾峰彇鍦烘櫙淇℃伅 + /// </summary> + public GetSceneInfo getSceneInfo; + } /// <summary> - /// 璇诲彇闈㈡澘鐨勯厤缃俊鎭�(淇℃伅瀛樺埌褰撳墠鐨勫璞″叿浣撳�间腑锛� + /// 鑾峰彇鍦烘櫙淇℃伅 /// </summary> - //public void ReadPanelConfigureInfo() - //{ - // ReadAttri(Device.Cluster_ID.HdlKey, AttriButeId.HdlKey); - //} + public GetSceneInfo sceneGetInfo; + /// <summary> + /// 鑾峰彇鍦烘櫙淇℃伅 + /// </summary> + [System.Serializable] + public class GetSceneInfo + { + /// <summary> + ///鍦烘櫙鎬绘暟 + /// </summary> + public int ScenesSum; - //#region 鑾峰彇鎵�鏈夊仛浜嗙粦瀹氱殑鎺у埗璁惧 - ///// <summary> - /////鑾峰彇鎵�鏈夊仛浜嗙粦瀹氱殑鎺у埗璁惧 - ///// </summary> - //public async System.Threading.Tasks.Task<GetControlDeviceBindResponseAllData> GetControlDeviceAsync() - //{ - // if (Gateway == null) - // { - // return null; - // } - // return await System.Threading.Tasks.Task.Run(async () => - // { - // var d = new GetControlDeviceBindResponseAllData { }; - // Action<string, string> action = (topic, message) => - // { - // var gatewayID = topic.Split('/')[0]; - // var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); + /// <summary> + /// 鍦烘櫙鍒楄〃 + /// </summary> + public List<ScenesListInfo> ScenesList = new List<ScenesListInfo>(); + } - // if (topic == gatewayID + "/" + "Error_Respon") - // { - // var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID }; - // var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString()); + /// <summary> + /// 鍦烘櫙鍒楄〃涓殑鍏蜂綋淇℃伅 + /// </summary> + [System.Serializable] + public class ScenesListInfo + { + /// <summary> + /// 鍦烘櫙ID + /// </summary> + public int ScenesId; - // if (temp == null) - // { - // d.errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖"; - // } - // else - // { - // d.errorResponData = temp; - // d.errorMessageBase = ErrorMess(temp.Error); - // } - // } + /// <summary> + /// 鍚嶇О + /// </summary> + public string ScenesName; - // if (topic == gatewayID + "/" + "DeviceBind_AddBind_Respon") - // { - // var gatewayTemp = new ZbGateway() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID }; - // var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<GetControlDeviceBindResponseData>(jobject["Data"].ToString()); - - // if (tempData == null) - // { - // d.errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�"; - // } - // else - // { - // d.getControlDeviceBindResponseData = tempData; - // } - // } - // }; - // Gateway.Actions += action; - // System.Console.WriteLine("GetControlDevice_Actions 鍚姩" + "_" + Gateway.getGatewayBaseInfo.gwID + System.DateTime.Now.ToString()); - - // var jObject = new JObject {{ "Cluster_ID", 0 }, { "Command", 154 } }; - // Gateway.Send("DeviceBind/GetControlDevice", jObject.ToString()); - - // var dateTime = DateTime.Now; - // while ((DateTime.Now - dateTime).TotalMilliseconds < 1000) - // { - // await System.Threading.Tasks.Task.Delay(10); - // if (d.getControlDeviceBindResponseData != null) - // { - // break; - // } - // } - // if ((DateTime.Now - dateTime).TotalMilliseconds > 10000) - // { - // d.errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔"; - // } - // Gateway.Actions -= action; - // System.Console.WriteLine("GetControlDevice_Actions 閫�鍑�" + System.DateTime.Now.ToString()); - - // return d; - // }); - //} - - ///// <summary> - ///// 鑾峰彇鎵�鏈夊仛浜嗙粦瀹氱殑鎺у埗璁惧鏁版嵁,缃戝叧鍙嶉淇℃伅 - ///// </summary> - //public GetControlDeviceBindResponseAllData getControlDeviceBindResponseAllData; - //[System.Serializable] - //public class GetControlDeviceBindResponseAllData - //{ - // /// <summary> - // /// 閿欒淇℃伅 - // /// </summary> - // public string errorMessageBase; - // /// <summary> - // /// 缃戝叧淇℃伅閿欒鍙嶉 - // /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para> - // /// </summary> - // public ErrorResponData errorResponData; - // /// <summary> - // /// 鑾峰彇鎵�鏈夊仛浜嗙粦瀹氱殑鎺у埗璁惧鏁版嵁 - // /// </summary> - // public GetControlDeviceBindResponseData getControlDeviceBindResponseData; - //} - - - ///// <summary> - ///// 鑾峰彇鎵�鏈夊仛浜嗙粦瀹氱殑鎺у埗璁惧鏁版嵁 - ///// </summary> - //public GetControlDeviceBindResponseData getControlDeviceBindResponseData; - //[System.Serializable] - //public class GetControlDeviceBindResponseData - //{ - // /// <summary> - // /// 璁惧灞炴�у垪琛� - // /// </summary> - // public List<DeviceObj> DeviceObj = new List<DeviceObj>(); - //} - - ///// <summary> - ///// Command鏁扮粍 - ///// </summary> - //public class DeviceObj - //{ - // /// <summary> - // /// 鎺у埗璁惧鐨刴ac鍦板潃 - // /// </summary> - // public string DeviceAddr; - - // /// <summary> - // /// 鎺у埗璁惧鐨勭鍙e彿 - // /// </summary> - // public int Epoint; - //} - //#endregion + /// <summary> + /// 鏄惁澶勪簬寮�鍚姸鎬� + ///0锛氬満鏅病鏈夎寮�鍚� + ///1锛氬満鏅浜庡紑鍚姸鎬� + /// </summary> + public int IsOpen; + } + #endregion } } -- Gitblit v1.8.0