From 48ba446936b51fffafa7c3600c0dadc6ac0e8c20 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期五, 10 七月 2020 10:52:13 +0800
Subject: [PATCH] 2020-07-10-01

---
 ZigbeeApp/Shared/Phone/ZigBee/Device/Panel.cs | 3451 +++++++++++++++--------------------------------------------
 1 files changed, 896 insertions(+), 2,555 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/Panel.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/Panel.cs
index 3eb06bc..b408bbd 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,25 +17,107 @@
         /// <summary>
         /// 鎸夐敭妯″紡锛堢鏈夊姛鑳斤級
         /// </summary>
-        public int panelMode = -1;
-        /// <summary>
-        ///鎸夐敭寮�鐘舵�侊紙鎸囩ず锛変寒搴�
-        /// </summary>
-        public int panelDirectionsLevel = -1;
+        public int panelMode = 65535;
 
         /// <summary>
-        /// 鎸夐敭鍏崇姸鎬侊紙鑳屽厜锛変寒搴�
+        /// 褰撳墠閫夋嫨妯″紡
         /// </summary>
-        public int panelBacklightLevel = -1;
+        [Newtonsoft.Json.JsonIgnore]
+        public string currentKeySelectModeText = "";
+        /// <summary>
+        /// 褰撳墠閫夋嫨鐨勬ゼ灞侷D
+        /// </summary>
+        [Newtonsoft.Json.JsonIgnore]
+        public string currentSelectFloorId = string.Empty;
+        /// <summary>
+        /// 褰撳墠閫夋嫨鐨勬埧闂碔D銆愭柊椋庨潰鏉裤��
+        /// </summary>
+        [Newtonsoft.Json.JsonIgnore]
+        public string currentSelectRoomId = string.Empty;
 
         /// <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> { };
+        [Newtonsoft.Json.JsonIgnore]
+        public List<BindListResponseObj> bindList = new List<BindListResponseObj>();
+
         /// <summary>
-        /// 鎸夐敭鏀寔鐨勭鏈夋ā寮忓垪琛�
+        /// 绉佹湁鍔熻兘绫�
+        /// <para>256:Key,鎸夐敭绫荤被 </para>
+        /// <para>768:PIR,PIR绫�</para>
+        /// <para>1024:Light,鐏被</para>
         /// </summary>
-        public System.Collections.Generic.List<string> priFunList = new System.Collections.Generic.List<string> { };
+        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>
         ///鑾峰彇闈㈡澘鐨勭鏈変俊鎭�
@@ -67,8 +151,7 @@
 
                     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());
+                        var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString());
 
                         if (temp == null)
                         {
@@ -83,18 +166,17 @@
 
                     if (topic == gatewayID + "/" + "ZbDataPassthrough")
                     {
-                        var gatewayTemp = new ZbGateway() { DataID = jobject.Value<int>("Data_ID") };
-                        gatewayTemp.clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
+                        var clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
 
-                        if (gatewayTemp.clientDataPassthroughResponseData == null)
+                        if (clientDataPassthroughResponseData == null)
                         {
                             result = new PanelPrivateFunctionsResponseAllInfo { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
                         }
                         else
                         {
-                            if (gatewayTemp.clientDataPassthroughResponseData?.PassData != null)
+                            if (clientDataPassthroughResponseData?.PassData != null)
                             {
-                                var data = gatewayTemp.clientDataPassthroughResponseData.PassData;
+                                var data = clientDataPassthroughResponseData.PassData;
 
                                 if (data.Length > 12)
                                 {
@@ -120,6 +202,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 +221,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,19 +248,30 @@
                                                     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;
                                         }
-                                        panelPrivateFunctionsResponseInfo = tempD;
                                         result = new PanelPrivateFunctionsResponseAllInfo { panelPrivateFunctionsResponseInfo = tempD };
                                         System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0003_{topic}");
                                     }
@@ -181,11 +286,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 { }
@@ -214,17 +318,8 @@
         /// PIR閰嶇疆鍙傛暟鍥炲
         /// </summary>
         [System.Serializable]
-        public class PanelPrivateFunctionsResponseAllInfo
+        public class PanelPrivateFunctionsResponseAllInfo:ErrorResponCommon
         {
-            /// <summary>
-            /// 閿欒淇℃伅
-            /// </summary>
-            public string errorMessageBase;
-            /// <summary>
-            /// 缃戝叧淇℃伅閿欒鍙嶉
-            /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para>
-            /// </summary>
-            public ErrorResponData errorResponData;
             /// <summary>
             /// 鍏夋劅绛夌骇涓暟锛圠ux鑳藉姏锛�
             /// <para>鏈夊嚑涓瓑绾у氨鏄剧ず鍑犱釜鍒诲害</para>
@@ -233,9 +328,8 @@
         }
 
         /// <summary>
-        /// PIR閰嶇疆鍙傛暟鍥炲
+        /// 閰嶇疆鍙傛暟鍥炲
         /// </summary>
-        public PanelPrivateFunctionsResponseInfo panelPrivateFunctionsResponseInfo;
         [System.Serializable]
         public class PanelPrivateFunctionsResponseInfo
         {
@@ -245,8 +339,8 @@
             /// <para>2:绗簩绾у埆</para>
             /// <para>3:绗笁绾у埆</para>
             /// </summary>
-            public int funLevel = -1;
-
+            public int funLevel = -1;
+
             /// <summary>
             /// 绉佹湁鍔熻兘绫�
             /// <para>256:Key,鎸夐敭绫荤被 </para>
@@ -285,8 +379,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 +400,7 @@
             string addDataLength = "";
             string value0 = "";
             string value1 = "";
-            string value2 = "";
+            string value2 = "";
             try
             {
 
@@ -316,18 +410,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 +430,7 @@
                         switch (args.Length)
                         {
                             case 1:
-                                value0 = "02";
+                                value0 = "02";
                                 switch (args[0])
                                 {
                                     case 1024:
@@ -396,15 +490,15 @@
                                     case 768:
                                         value1 = "0003";
                                         break;
-                                }
-
-                                break;
-                        }
+                                }
+
+                                break;
+                        }
                     }
 
-                }
-                else
-                {
+                }
+                else
+                {
                     dataLength = "05";
                     addDataLength = "01";
                     value0 = "01";
@@ -412,8 +506,8 @@
                 data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength +
                         value0 + value1 + value2;
             }
-            catch { };
-
+            catch { };
+
             return data;
         }
 
@@ -428,7 +522,7 @@
             /// <para>768:PIR,PIR绫�</para>
             /// <para>1024:Light,鐏被</para>
             /// </summary>
-            public int privateFuncTypeOne;
+            public int privateFuncTypeOne;
         }
 
         /// <summary>
@@ -448,8 +542,8 @@
             /// <para>102:RGBLevel,RGB鎸囩ず鐏寒搴︼紙鐏被锛�</para>
             /// </summary>
             public int privateFuncTypeTwo;
-        }
-
+        }
+
         /// <summary>
         /// 绉佹湁鍔熻兘绫伙紙绗笁绾у埆锛変俊鎭�
         /// </summary>
@@ -488,6 +582,7 @@
             {
                 return null;
             }
+
             return result.panelPrivateFunctionsResponseInfo.privateFuncTypeLevelFirstList;
         }
 
@@ -567,8 +662,7 @@
 
                     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());
+                        var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString());
 
                         if (temp == null)
                         {
@@ -583,28 +677,31 @@
 
                     if (topic == gatewayID + "/" + "ZbDataPassthrough")
                     {
-                        var gatewayTemp = new ZbGateway() { DataID = jobject.Value<int>("Data_ID") };
-                        gatewayTemp.clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
+                        var clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
 
-                        if (gatewayTemp.clientDataPassthroughResponseData == null)
+                        if (clientDataPassthroughResponseData == null)
                         {
                             result = new ResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
                         }
                         else
                         {
-                            if (gatewayTemp.clientDataPassthroughResponseData?.PassData != null)
+                            if (clientDataPassthroughResponseData?.PassData != null)
                             {
-                                var data = gatewayTemp.clientDataPassthroughResponseData.PassData;
+                                var data = clientDataPassthroughResponseData.PassData;
                                 if (data.Length == 16)
                                 {
                                     var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString();
                                     if (command == "0002")
                                     {
                                         var tempD = new ResponseData();
-                                        tempD.command = Convert.ToInt32(data[10].ToString() + data[11].ToString() + data[12].ToString() + data[13].ToString(), 16);
+                                        tempD.command = data[12].ToString() + data[13].ToString() + data[10].ToString() + data[11].ToString();
                                         tempD.status = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16);
-                                        result = new ResponseAllData { responseData = tempD };
-                                        System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0400_{ topic}");
+                                        if (tempD.command == "0400")
+                                        {
+                                            result = new ResponseAllData { responseData = tempD };
+                                            System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0400_{ topic}");
+                                        }
+
                                     }
                                 }
                             }
@@ -617,11 +714,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 { }
@@ -677,7 +773,6 @@
             string dataSerialNum = "01";
             string addDataLength = "03";
             string kStatus = "";
-            string kNum = "";
             int attributeData = 0;
 
             try
@@ -697,8 +792,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:
@@ -723,103 +818,6 @@
         #endregion
 
         #region 閰嶇疆鎸夐敭鎸囩ず鐏鑹�.
-        ///<summary >
-        ///閰嶇疆鎸夐敭鎸囩ず鐏鑹�
-        /// </summary>
-        public async System.Threading.Tasks.Task<ResponseAllData> SetPanelColorInfoAsync(KeyColorData keyColorData, KeyNumStatus keyNumStatus)
-        {
-            ResponseAllData result = null;
-            if (Gateway == null)
-            {
-                result = new ResponseAllData { 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 ResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
-                        }
-
-                        else
-                        {
-                            result = new ResponseAllData { 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 ResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
-                        }
-                        else
-                        {
-                            if (gatewayTemp.clientDataPassthroughResponseData?.PassData != null)
-                            {
-                                var data = gatewayTemp.clientDataPassthroughResponseData.PassData;
-                                if (data.Length == 16)
-                                {
-                                    var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString();
-                                    if (command == "0002")
-                                    {
-                                        var tempD = new ResponseData();
-                                        tempD.command = Convert.ToInt32(data[10].ToString() + data[11].ToString() + data[12].ToString() + data[13].ToString(), 16);
-                                        tempD.status = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16);
-                                        result = new ResponseAllData { responseData = tempD };
-                                        System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0401_{ topic}");
-                                    }
-                                }
-                            }
-                        }
-                    }
-                };
-
-                Gateway.Actions += action;
-                System.Console.WriteLine("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString());
-
-                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);
-                    Gateway.Send(("ClientDataPassthrough"), jObject.ToString());
-                }
-                catch { }
-
-                var dateTime = DateTime.Now;
-                while ((DateTime.Now - dateTime).TotalMilliseconds < 9000)// WaitReceiveDataTime)
-                {
-                    await System.Threading.Tasks.Task.Delay(10);
-                    if (result != null)
-                    {
-                        break;
-                    }
-                }
-                if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
-                {
-                    result = new ResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
-                }
-                Gateway.Actions -= action;
-                System.Console.WriteLine("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString());
-
-                return result;
-            });
-        }
 
         /// <summary>
         /// 缁戝畾璁惧淇℃伅,缃戝叧鍙嶉淇℃伅
@@ -842,136 +840,6 @@
             public KeyColorData keyColorData;
         }
 
-        /// <summary>
-        /// 閰嶇疆鎸夐敭鎸囩ず鐏鑹叉暟鎹�
-        /// <para>鍙戦厤缃寜閿寚绀虹伅棰滆壊鍛戒护鏃讹紝姝ゆ椂涓哄彂閫佸埌缃戝叧鐨勯�忎紶鏁版嵁</para>
-        /// </summary>
-        /// <returns>The passthorugh data.</returns>
-        /// <param name="keyColorData">Key color data.</param>
-        /// <param name="keyNum">Key number.</param>
-        string SetPanelColorData(KeyColorData keyColorData, KeyNumStatus keyNumStatus)
-        {
-            string data = "";
-            string dataLength = "0c";
-            string dataComand1 = "01";
-            string dataComand2 = "04";
-            string dataSerialNum = "01";
-            string addDataLength = "08";
-            int attributeData = 0;
-
-            try
-            {
-                for (int i = 1; i <= 16; i++)
-                {
-                    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)
-                    {
-                        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());
-                string temp = "";
-                var tempColor1 = keyColorData.OpenColorR.ToString();
-                var sbString1 = new System.Text.StringBuilder();
-                switch (tempColor1.Length)
-                {
-                    case 1:
-                        temp = "0" + tempColor1;
-                        break;
-                    case 2:
-                        temp = tempColor1;
-                        break;
-                }
-                sbString1.Append(temp.ToUpper());
-
-                var tempColor2 = keyColorData.OpenColorG.ToString();
-                var sbString2 = new System.Text.StringBuilder();
-                switch (tempColor2.Length)
-                {
-                    case 1:
-                        temp = "0" + tempColor2;
-                        break;
-                    case 2:
-                        temp = tempColor2;
-                        break;
-                }
-                sbString2.Append(temp.ToUpper());
-
-                var tempColor3 = keyColorData.OpenColorB.ToString();
-                var sbString3 = new System.Text.StringBuilder();
-                switch (tempColor3.Length)
-                {
-                    case 1:
-                        temp = "0" + tempColor3;
-                        break;
-                    case 2:
-                        temp = tempColor3;
-                        break;
-                }
-                sbString3.Append(temp.ToUpper());
-
-                var tempColor4 = keyColorData.CloseColorR.ToString();
-                var sbString4 = new System.Text.StringBuilder();
-                switch (tempColor3.Length)
-                {
-                    case 1:
-                        temp = "0" + tempColor4;
-                        break;
-                    case 2:
-                        temp = tempColor4;
-                        break;
-                }
-                sbString4.Append(temp.ToUpper());
-
-                var tempColor5 = keyColorData.CloseColorG.ToString();
-                var sbString5 = new System.Text.StringBuilder();
-                switch (tempColor5.Length)
-                {
-                    case 1:
-                        temp = "0" + tempColor5;
-                        break;
-                    case 2:
-                        temp = tempColor5;
-                        break;
-                }
-                sbString5.Append(temp.ToUpper());
-
-                var tempColor6 = keyColorData.CloseColorB.ToString();
-                var sbString6 = new System.Text.StringBuilder();
-                switch (tempColor6.Length)
-                {
-                    case 1:
-                        temp = "0" + tempColor6;
-                        break;
-                    case 2:
-                        temp = tempColor6;
-                        break;
-                }
-                sbString6.Append(temp.ToUpper());
-
-                if (keyColorData != null)
-                {
-                    data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength +
-                           tempAttributeData + sbString1 + sbString2 + sbString3 +
-                           sbString4 + sbString5 + sbString6;
-                }
-            }
-            catch { };
-
-            return data;
-        }
-
-        /// <summary>
-        /// 鎸夐敭鎸囩ず鐏鑹蹭俊鎭�
-        /// </summary>
-        public KeyColorData keyColorData;
         // <summary>
         /// 鎸夐敭鎸囩ず鐏鑹蹭俊鎭�
         /// </summary>
@@ -1096,13 +964,12 @@
         }
         #endregion
 
-        #region 閰嶇疆鎸夐敭鎸囩ず鐏潰鏉夸寒搴﹀睘鎬�.
+        #region  閰嶇疆鎺ヨ繎浼犳劅
         ///<summary >
-        ///閰嶇疆鎸夐敭鎸囩ず鐏潰鏉夸寒搴﹀睘鎬�
-        /// <para>directionsLevel:鎸囩ず鐏寒搴� 0-100</para>
-        /// <para>backlightLevel:鑳屽厜鐏寒搴� 0-100</para>
+        /// 閰嶇疆鎺ヨ繎浼犳劅
+        /// <para>sensorEnable:浼犳劅鍣ㄤ娇鑳�</para> 
         /// </summary>
-        public async System.Threading.Tasks.Task<ResponseAllData> SetKeyLevelAsync(int directionsLevel, int backlightLevel)
+        public async System.Threading.Tasks.Task<ResponseAllData> SetProximitySensor(bool sensorEnable)
         {
             ResponseAllData result = null;
             if (Gateway == null)
@@ -1119,8 +986,7 @@
 
                     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());
+                        var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString());
 
                         if (temp == null)
                         {
@@ -1132,30 +998,33 @@
                             result = new ResponseAllData { 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());
+                        var clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
 
-                        if (gatewayTemp.clientDataPassthroughResponseData == null)
+                        if (clientDataPassthroughResponseData == null)
                         {
                             result = new ResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
                         }
                         else
-                        {
-                            if (gatewayTemp.clientDataPassthroughResponseData?.PassData != null)
+                        {
+                            if (clientDataPassthroughResponseData?.PassData != null)
                             {
-                                var data = gatewayTemp.clientDataPassthroughResponseData.PassData;
+                                var data = clientDataPassthroughResponseData.PassData;
                                 if (data.Length == 16)
                                 {
                                     var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString();
                                     if (command == "0002")
                                     {
                                         var tempD = new ResponseData();
-                                        tempD.command = Convert.ToInt32(data[10].ToString() + data[11].ToString() + data[12].ToString() + data[13].ToString(), 16);
+                                        tempD.command = data[12].ToString() + data[13].ToString() + data[10].ToString() + data[11].ToString();
                                         tempD.status = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16);
-                                        result = new ResponseAllData { responseData = tempD };
-                                        System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0402_{ topic}");
+                                        if (tempD.command == "0500")
+                                        {
+                                            result = new ResponseAllData { responseData = tempD };
+                                            DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0500_{ topic}");
+                                        }
                                     }
                                 }
                             }
@@ -1168,8 +1037,7 @@
 
                 try
                 {
-                    OpenPassthroughControl(Gateway);
-                    var passData = SetPanelLevelData(directionsLevel, backlightLevel);
+                    var passData = SetProximitySensorData(sensorEnable);
                     var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
                     var data = new JObject { { "PassData", passData } };
                     jObject.Add("Data", data);
@@ -1198,209 +1066,33 @@
         }
 
         /// <summary>
-        /// 鎺у埗鎸夐敭鎸囩ず鐏�
+        /// 閰嶇疆鎺ヨ繎浼犳劅
+        /// [璇ユ潯鍗忚鍙﹀2涓弬鏁癠I鍜岃澶囬兘涓嶉渶瑕侊紝璁惧閮藉悓浜嬭姹備紶鎰熷櫒璺濈鍜屼紶鎰熷櫒瑙﹀彂寤惰繜鏃堕棿閮介粯璁ゆ槸FFFF]
         /// </summary>
-        string SetPanelLevelData(int level1, int level2)
+        /// <param name="sensorEnable">浼犳劅鍣ㄤ娇鑳�  0-disable  1-enable</param> 
+        /// <returns></returns>
+        string SetProximitySensorData(bool sensorEnable)
         {
             string data = "";
-            string dataLength = "06";
-            string dataComand1 = "02";
-            string dataComand2 = "04";
+            string dataLength = "09";
+            string dataComand1 = "00";
+            string dataComand2 = "05";
             string dataSerialNum = "01";
-            string addDataLength = "02";
-            string l1 = "";
-            string l2 = "";
+            string addDataLength = "05";
+            string sEnable = "";
             try
             {
-                var sbString1 = new System.Text.StringBuilder();
-                var sbString2 = new System.Text.StringBuilder();
-                string temp1 = Convert.ToString(level1, 16);
-                string temp2 = Convert.ToString(level2, 16);
-
-                switch (temp1.Length)
+                if (sensorEnable)
                 {
-                    case 1:
-                        l1 = "0" + temp1;
-                        break;
-                    case 2:
-                        l1 = temp1;
-                        break;
-                }
-                switch (temp2.Length)
-                {
-                    case 1:
-                        l2 = "0" + temp2;
-                        break;
-                    case 2:
-                        l2 = temp2;
-                        break;
-                }
-                sbString1.Append(l1.ToString().ToUpper());
-                sbString2.Append(l2.ToString().ToUpper());
-                data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength +
-                    sbString1 + sbString2;
-            }
-            catch { };
-
-            return data;
-        }
-        #endregion
-
-        #region  閰嶇疆鎸夐敭鎸囩ず鐏潰鏉胯妭鑳芥ā寮�.
-        ///<summary >
-        /// 閰嶇疆鎸夐敭鎸囩ず鐏潰鏉胯妭鑳芥ā寮�
-        /// <para>modeEnable:鑺傝兘妯″紡浣胯兘</para>
-        /// <para>modeTime:鏃犳搷浣滆繘鍏ヨ妭鑳芥ā寮忔椂闂� 0-ff</para>
-        /// <para>鑺傝兘妯″紡浜害:0-100</para>
-        /// </summary>
-        public async System.Threading.Tasks.Task<ResponseAllData> SetKeyModeAsync(bool modeEnable, int modeTime, int level)
-        {
-            ResponseAllData result = null;
-            if (Gateway == null)
-            {
-                result = new ResponseAllData { 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 ResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
-                        }
-
-                        else
-                        {
-                            result = new ResponseAllData { 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 ResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
-                        }
-                        else
-                        {
-                            if (gatewayTemp.clientDataPassthroughResponseData?.PassData != null)
-                            {
-                                var data = gatewayTemp.clientDataPassthroughResponseData.PassData;
-                                if (data.Length == 16)
-                                {
-                                    var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString();
-                                    if (command == "0002")
-                                    {
-                                        var tempD = new ResponseData();
-                                        tempD.command = Convert.ToInt32(data[10].ToString() + data[11].ToString() + data[12].ToString() + data[13].ToString(), 16);
-                                        tempD.status = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16);
-                                        result = new ResponseAllData { responseData = tempD };
-                                        System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0403_{ topic}");
-                                    }
-                                }
-                            }
-                        }
-                    }
-                };
-
-                Gateway.Actions += action;
-                System.Console.WriteLine("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString());
-
-                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);
-                    Gateway.Send(("ClientDataPassthrough"), jObject.ToString());
-                }
-                catch { }
-
-                var dateTime = DateTime.Now;
-                while ((DateTime.Now - dateTime).TotalMilliseconds < 9000)// WaitReceiveDataTime)
-                {
-                    await System.Threading.Tasks.Task.Delay(10);
-                    if (result != null)
-                    {
-                        break;
-                    }
-                }
-                if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
-                {
-                    result = new ResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
-                }
-                Gateway.Actions -= action;
-                System.Console.WriteLine("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString());
-
-                return result;
-            });
-        }
-
-        /// <summary>
-        /// 閰嶇疆鎸夐敭鎸囩ず鐏潰鏉胯妭鑳芥ā寮�
-        /// </summary>
-        string SetPanelModeModeData(bool modeEnable, int modeTime, int modelevel)
-        {
-            string data = "";
-            string dataLength = "07";
-            string dataComand1 = "03";
-            string dataComand2 = "04";
-            string dataSerialNum = "01";
-            string addDataLength = "03";
-            string mode = "";
-            string time = "";
-            string level = "";
-            try
-            {
-                if (modeEnable)
-                {
-                    mode = "01";
+                    sEnable = "01";
                 }
                 else
                 {
-                    mode = "00";
-                }
-                var sbString1 = new System.Text.StringBuilder();
-                string temp = Convert.ToString(modeTime, 16);
-                switch (temp.Length)
-                {
-                    case 1:
-                        time = "0" + temp;
-                        break;
-                    case 2:
-                        time = temp;
-                        break;
+                    sEnable = "00";
                 }
 
-                var sbString2 = new System.Text.StringBuilder();
-                string temp2 = Convert.ToString(modelevel, 16);
-                switch (temp2.Length)
-                {
-                    case 1:
-                        level = "0" + temp2;
-                        break;
-                    case 2:
-                        level = temp2;
-                        break;
-                }
-
-                sbString1.Append(time.ToUpper());
-                sbString2.Append(level.ToUpper());
                 data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength +
-                   mode + sbString1 + sbString2;
+                  sEnable + "FFFFFFFF";
             }
             catch { };
 
@@ -1409,234 +1101,6 @@
         #endregion
 
         #region 鑾峰彇鎸夐敭鎸囩ず鐏紑鍏抽鑹�.
-        ///<summary >
-        ///鑾峰彇鎸夐敭鎸囩ず鐏紑鍏抽鑹�.
-        /// </summary>
-        public async System.Threading.Tasks.Task<KeyColorDataResponseAllData> GetPanelColorInfoAsync(KeyNum keyNum)
-        {
-            KeyColorDataResponseAllData result = null;
-            if (Gateway == null)
-            {
-                result = new KeyColorDataResponseAllData { 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 KeyColorDataResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
-                        }
-
-                        else
-                        {
-                            result = new KeyColorDataResponseAllData { 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 KeyColorDataResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
-                        }
-                        else
-                        {
-                            if (gatewayTemp.clientDataPassthroughResponseData?.PassData != null)
-                            {
-                                var data = gatewayTemp.clientDataPassthroughResponseData.PassData;
-                                if (data.Length == 24)
-                                {
-                                    var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString();
-                                    if (command == "0405")
-                                    {
-                                        var key1 = data[10] + data[11];
-                                        var key = data[10].ToString() + data[11].ToString();
-                                        var tempR = new KeyColorData();
-                                        tempR.OpenColorR = data[12].ToString() + data[13].ToString(); ;
-                                        tempR.OpenColorG = data[14].ToString() + data[15].ToString(); ;
-                                        tempR.OpenColorB = data[16].ToString() + data[17].ToString(); ;
-                                        tempR.CloseColorR = data[18].ToString() + data[19].ToString(); ;
-                                        tempR.CloseColorG = data[20].ToString() + data[21].ToString(); ;
-                                        tempR.CloseColorB = data[22].ToString() + data[23].ToString(); ;
-
-                                        switch (key)
-                                        {
-                                            case "01":
-                                                tempR.keyNum = KeyNum.Key1;
-                                                break;
-                                            case "02":
-                                                tempR.keyNum = KeyNum.Key2;
-                                                break;
-                                            case "03":
-                                                tempR.keyNum = KeyNum.Key3;
-                                                break;
-                                            case "04":
-                                                tempR.keyNum = KeyNum.Key4;
-                                                break;
-                                            case "05":
-                                                tempR.keyNum = KeyNum.Key5;
-                                                break;
-                                            case "06":
-                                                tempR.keyNum = KeyNum.Key6;
-                                                break;
-                                            case "07":
-                                                tempR.keyNum = KeyNum.Key7;
-                                                break;
-                                            case "08":
-                                                tempR.keyNum = KeyNum.Key8;
-                                                break;
-                                            case "09":
-                                                tempR.keyNum = KeyNum.Key9;
-                                                break;
-                                            case "0a":
-                                                tempR.keyNum = KeyNum.Key10;
-                                                break;
-                                            case "0b":
-                                                tempR.keyNum = KeyNum.Key11;
-                                                break;
-                                            case "0c":
-                                                tempR.keyNum = KeyNum.Key12;
-                                                break;
-                                            case "0d":
-                                                tempR.keyNum = KeyNum.Key13;
-                                                break;
-                                            case "0e":
-                                                tempR.keyNum = KeyNum.Key14;
-                                                break;
-                                            case "0f":
-                                                tempR.keyNum = KeyNum.Key15;
-                                                break;
-                                        }
-                                        keyColorData = tempR;
-                                        result = new KeyColorDataResponseAllData { keyColorData = tempR };
-                                        System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0404_{ topic}");
-                                    }
-                                }
-                            }
-                        }
-                    }
-                };
-
-                Gateway.Actions += action;
-                System.Console.WriteLine("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString());
-
-                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);
-                    Gateway.Send(("ClientDataPassthrough"), jObject.ToString());
-                }
-                catch { }
-
-                var dateTime = DateTime.Now;
-                while ((DateTime.Now - dateTime).TotalMilliseconds < 9000)// WaitReceiveDataTime)
-                {
-                    await System.Threading.Tasks.Task.Delay(10);
-                    if (result != null)
-                    {
-                        break;
-                    }
-                }
-                if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
-                {
-                    result = new KeyColorDataResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
-                }
-                Gateway.Actions -= action;
-                System.Console.WriteLine("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString());
-
-                return result;
-            });
-        }
-
-        /// <summary>
-        /// 鑾峰彇鎸夐敭鎸囩ず鐏紑鍏抽鑹�
-        /// </summary>
-        string GetkeyColorData(KeyNum keyNum)
-        {
-            string data = "";
-            string dataLength = "05";
-            string dataComand1 = "04";
-            string dataComand2 = "04";
-            string dataSerialNum = "01";
-            string addDataLength = "01";
-            string kNum = "";
-
-            try
-            {
-                switch (keyNum)
-                {
-                    case KeyNum.Key1:
-                        kNum = "01";
-                        break;
-                    case KeyNum.Key2:
-                        kNum = "02";
-                        break;
-                    case KeyNum.Key3:
-                        kNum = "03";
-                        break;
-                    case KeyNum.Key4:
-                        kNum = "04";
-                        break;
-                    case KeyNum.Key5:
-                        kNum = "05";
-                        break;
-                    case KeyNum.Key6:
-                        kNum = "06";
-                        break;
-                    case KeyNum.Key7:
-                        kNum = "07";
-                        break;
-                    case KeyNum.Key8:
-                        kNum = "08";
-                        break;
-                    case KeyNum.Key9:
-                        kNum = "09";
-                        break;
-                    case KeyNum.Key10:
-                        kNum = "0A";
-                        break;
-                    case KeyNum.Key11:
-                        kNum = "0B";
-                        break;
-                    case KeyNum.Key12:
-                        kNum = "0C";
-                        break;
-                    case KeyNum.Key13:
-                        kNum = "0D";
-                        break;
-                    case KeyNum.Key14:
-                        kNum = "0E";
-                        break;
-                    case KeyNum.Key15:
-                        kNum = "0F";
-                        break;
-                    case KeyNum.Key16:
-                        kNum = "10";
-                        break;
-                }
-
-                data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength + kNum;
-            }
-            catch { };
-
-            return data;
-        }
 
         /// <summary>
         /// 鎸夐敭鎸囩ず鐏鑹蹭俊鎭搴旈『搴忓彿(鐫$湢缁勫彿)
@@ -1663,129 +1127,6 @@
         #endregion
 
         #region 鑾峰彇鎸夐敭鎸囩ず鐏潰鏉垮紑鍏充寒搴﹂厤缃�.
-        ///<summary >
-        ///鑾峰彇鎸夐敭鎸囩ず鐏潰鏉垮紑鍏充寒搴﹂厤缃�
-        /// </summary>
-        public async System.Threading.Tasks.Task<PanelSwitchLevelInfo> GetPanelSwitchLevelAsync(string reserve = "01")
-        {
-            PanelSwitchLevelInfo result = null;
-            if (Gateway == null)
-            {
-                result = new PanelSwitchLevelInfo { 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 PanelSwitchLevelInfo { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
-                        }
-
-                        else
-                        {
-                            result = new PanelSwitchLevelInfo { 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 PanelSwitchLevelInfo { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
-                        }
-                        else
-                        {
-                            if (gatewayTemp.clientDataPassthroughResponseData?.PassData != null)
-                            {
-                                var data = gatewayTemp.clientDataPassthroughResponseData.PassData;
-                                if (data.Length == 14)
-                                {
-                                    var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString();
-                                    if (command == "0407")
-                                    {
-                                        var level1 = Convert.ToInt32(data[10].ToString() + data[11].ToString(), 16);
-                                        var level2 = Convert.ToInt32(data[12].ToString() + data[13].ToString(), 16);
-                                        panelDirectionsLevel = level1;
-                                        panelBacklightLevel = level2;
-                                        result = new PanelSwitchLevelInfo { panelDirectionsLevel = level1, panelBacklightLevel = level2 };
-                                        System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0406_{ topic}");
-                                    }
-                                }
-                            }
-                        }
-                    }
-                };
-
-                Gateway.Actions += action;
-                System.Console.WriteLine("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString());
-
-                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);
-                    Gateway.Send(("ClientDataPassthrough"), jObject.ToString());
-                }
-                catch { }
-
-                var dateTime = DateTime.Now;
-                while ((DateTime.Now - dateTime).TotalMilliseconds < 9000)//WaitReceiveDataTime)
-                {
-                    await System.Threading.Tasks.Task.Delay(10);
-                    if (result != null)
-                    {
-                        break;
-                    }
-                }
-                if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
-                {
-                    result = new PanelSwitchLevelInfo { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
-                }
-                Gateway.Actions -= action;
-                System.Console.WriteLine("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString());
-
-                return result;
-            });
-        }
-
-        /// <summary>
-        /// 鑾峰彇鎸夐敭鎸囩ず鐏潰鏉垮紑鍏充寒搴﹂厤缃暟鎹�
-        /// <para>鍙戦厤缃寜閿寚绀虹伅棰滆壊鍛戒护鏃讹紝姝ゆ椂涓哄彂閫佸埌缃戝叧鐨勯�忎紶鏁版嵁</para>
-        /// </summary>
-        string SendPanelSwitchLevelData(string reserve)
-        {
-            string data = "";
-            string dataLength = "05";
-            string dataComand1 = "06";
-            string dataComand2 = "04";
-            string dataSerialNum = "01";
-            string addDataLength = "01";
-            string reserveData = reserve;
-
-            try
-            {
-                data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength +
-                    reserveData;
-            }
-            catch { };
-
-            return data;
-        }
 
         /// <summary>
         /// 鎸夐敭鎸囩ず鐏潰鏉垮紑鍏充寒搴﹂厤缃洖澶�
@@ -1803,148 +1144,18 @@
             /// </summary>
             public ErrorResponData errorResponData;
             /// <summary>
-            ///鎸夐敭寮�鐘舵�侊紙鎸囩ず锛変寒搴�
+            ///鎸夐敭寮�鐘舵�侊紙鎸囩ず锛変寒搴�(杩欎釜鏄偣鍑诲悗鐨勫��)
             /// </summary>
             public int panelDirectionsLevel = -1;
 
             /// <summary>
-            /// 鎸夐敭鍏崇姸鎬侊紙鑳屽厜锛変寒搴�
+            /// 鎸夐敭鍏崇姸鎬侊紙鑳屽厜锛変寒搴�(杩欎釜鏄偣鍑诲墠鐨勫��)
             /// </summary>
             public int panelBacklightLevel = -1;
         }
         #endregion
 
         #region 鑾峰彇鎸夐敭鑺傝兘妯″紡閰嶇疆鐘舵��.
-        ///<summary >
-        ///鑾峰彇鎸夐敭鑺傝兘妯″紡閰嶇疆鐘舵��
-        /// </summary>
-        public async System.Threading.Tasks.Task<PanelSwitchLevelResponInfo> GetPanelSaveEnergyModeAsync(string reserve = "01")
-        {
-            PanelSwitchLevelResponInfo result = null;
-            if (Gateway == null)
-            {
-                result = new PanelSwitchLevelResponInfo { 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 PanelSwitchLevelResponInfo { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
-                        }
-
-                        else
-                        {
-                            result = new PanelSwitchLevelResponInfo { 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 PanelSwitchLevelResponInfo { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
-                        }
-                        else
-                        {
-                            if (gatewayTemp.clientDataPassthroughResponseData?.PassData != null)
-                            {
-                                var data = gatewayTemp.clientDataPassthroughResponseData.PassData;
-                                if (data.Length == 16)
-                                {
-                                    var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString();
-                                    if (command == "0409")
-                                    {
-                                        var tempR = new PanelSaveEnergyModeInfo();
-                                        if (data[10].ToString() + data[11].ToString() == "01")
-                                        {
-                                            tempR.enable = true;
-                                        }
-                                        else
-                                        {
-                                            tempR.enable = false;
-                                        }
-                                        tempR.time = Convert.ToInt32(data[12].ToString() + data[13].ToString(), 16);
-                                        tempR.level = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16);
-                                        panelSaveEnergyModeInfo = tempR;
-                                        result = new PanelSwitchLevelResponInfo { panelSaveEnergyModeInfo = tempR };
-                                        System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0408_{ topic}");
-                                    }
-                                }
-                            }
-                        }
-                    }
-                };
-
-                Gateway.Actions += action;
-                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);
-                    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 > 9000)// WaitReceiveDataTime)
-                {
-                    result = new PanelSwitchLevelResponInfo { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
-                }
-                Gateway.Actions -= action;
-                System.Console.WriteLine("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString());
-
-                return result;
-            });
-        }
-
-        /// <summary>
-        /// 鑾峰彇鎸夐敭鑺傝兘妯″紡閰嶇疆鐘舵�佹暟鎹�
-        /// </summary>
-        string SendPanelSaveEnergyModeData(string reserve)
-        {
-            string data = "";
-            string dataLength = "05";
-            string dataComand1 = "08";
-            string dataComand2 = "04";
-            string dataSerialNum = "01";
-            string addDataLength = "01";
-            string reserveData = reserve;
-
-            try
-            {
-                data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength +
-                    reserveData;
-            }
-            catch { };
-
-            return data;
-        }
 
         /// <summary>
         /// 鑾峰彇鎸夐敭鑺傝兘妯″紡閰嶇疆鐘舵�佹暟鎹洖澶�
@@ -1969,10 +1180,6 @@
         }
 
         /// <summary>
-        /// 鎸夐敭鑺傝兘妯″紡淇℃伅
-        /// </summary>
-        public PanelSaveEnergyModeInfo panelSaveEnergyModeInfo;
-        /// <summary>
         /// 鑾峰彇鎸夐敭鑺傝兘妯″紡閰嶇疆鐘舵�佹暟鎹�
         /// </summary>
         [System.Serializable]
@@ -1991,6 +1198,179 @@
             /// 鑺傝兘妯″紡浜害(0-100)
             /// </summary>
             public int level = -1;
+        }
+        #endregion
+
+        #region 鑾峰彇鎺ヨ繎浼犳劅閰嶇疆
+        ///<summary >
+        ///鑾峰彇鎺ヨ繎浼犳劅閰嶇疆
+        /// </summary>
+        public async System.Threading.Tasks.Task<PanelProximitySensorResponInfo> GetProximitySensorAsync(string reserve = "01")
+        {
+            PanelProximitySensorResponInfo result = null;
+            if (Gateway == null)
+            {
+                result = new PanelProximitySensorResponInfo { 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 temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString());
+
+                        if (temp == null)
+                        {
+                            result = new PanelProximitySensorResponInfo { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
+                        }
+
+                        else
+                        {
+                            result = new PanelProximitySensorResponInfo { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
+                        }
+                    }
+
+                    if (topic == gatewayID + "/" + "ZbDataPassthrough")
+                    {
+                        var clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
+
+                        if (clientDataPassthroughResponseData == null)
+                        {
+                            result = new PanelProximitySensorResponInfo { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
+                        }
+                        else
+                        {
+                            if (clientDataPassthroughResponseData?.PassData != null)
+                            {
+                                var data = clientDataPassthroughResponseData.PassData;
+                                if (data.Length == 20)
+                                {
+                                    var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString();
+                                    if (command == "0502")
+                                    {
+                                        var tempR = new PanelProximitySensorInfo();
+                                        if (data[10].ToString() + data[11].ToString() == "01")
+                                        {
+                                            tempR.enable = true;
+                                        }
+                                        else
+                                        {
+                                            tempR.enable = false;
+                                        }
+                                        tempR.sensorDistance = Convert.ToInt32(data[14].ToString() + data[15].ToString() + data[12].ToString() + data[13].ToString(), 16);
+                                        tempR.sensorDelayTime = Convert.ToInt32(data[18].ToString() + data[19].ToString() + data[16].ToString() + data[17].ToString(), 16);
+                                        result = new PanelProximitySensorResponInfo { panelProximitySensorInfo = tempR };
+                                        System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0408_{ topic}");
+                                    }
+                                }
+                            }
+                        }
+                    }
+                };
+
+                Gateway.Actions += action;
+                System.Console.WriteLine("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString());
+
+                try
+                {
+                    var passData = SendProiximitySensorData(reserve);
+                    var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
+                    var data = new JObject { { "PassData", passData } };
+                    jObject.Add("Data", data);
+                    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 > 9000)// WaitReceiveDataTime)
+                {
+                    result = new PanelProximitySensorResponInfo { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
+                }
+                Gateway.Actions -= action;
+                System.Console.WriteLine("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString());
+
+                return result;
+            });
+        }
+
+        /// <summary>
+        /// 鑾峰彇鎺ヨ繎浼犳劅閰嶇疆鏁版嵁
+        /// </summary>
+        string SendProiximitySensorData(string reserve)
+        {
+            string data = "";
+            string dataLength = "05";
+            string dataComand1 = "01";
+            string dataComand2 = "05";
+            string dataSerialNum = "01";
+            string addDataLength = "01";
+            string reserveData = reserve;
+
+            try
+            {
+                data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength +
+                    reserveData;
+            }
+            catch { };
+
+            return data;
+        }
+
+        /// <summary>
+        /// 鑾峰彇鎺ヨ繎浼犳劅閰嶇疆鏁版嵁鍥炲
+        /// </summary>
+        [System.Serializable]
+        public class PanelProximitySensorResponInfo
+        {
+            /// <summary>
+            /// 閿欒淇℃伅
+            /// </summary>
+            public string errorMessageBase;
+            /// <summary>
+            /// 缃戝叧淇℃伅閿欒鍙嶉
+            /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para>
+            /// </summary>
+            public ErrorResponData errorResponData;
+            /// <summary>
+            /// <para>鑾峰彇鎺ヨ繎浼犳劅閰嶇疆鏁版嵁</para>
+            /// </summary>
+            public PanelProximitySensorInfo panelProximitySensorInfo;
+        }
+
+        /// <summary>
+        /// 鑾峰彇鎺ヨ繎浼犳劅閰嶇疆鏁版嵁
+        /// </summary>
+        [System.Serializable]
+        public class PanelProximitySensorInfo
+        {
+            /// <summary>
+            /// 浼犳劅鍣ㄤ娇鑳�
+            ///false-disable  true-enable
+            /// </summary>
+            public bool enable;
+
+            /// <summary>
+            ///浼犳劅鍣ㄨ窛绂�
+            /// </summary> 
+            public int sensorDistance = -1;
+
+            /// <summary>
+            /// 浼犳劅鍣ㄨЕ鍙戝欢杩熸椂闂�
+            /// </summary>
+            public int sensorDelayTime = -1;
         }
         #endregion
 
@@ -1999,472 +1379,392 @@
         ///鑾峰彇鎸夐敭鎸囩ず鐏潯鐪犵粍
         ///<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 temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.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 clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
+
+        //                if (clientDataPassthroughResponseData == null)
+        //                {
+        //                    result = new PanelSleepGroupResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
+        //                }
+        //                else
+        //                {
+        //                    if (clientDataPassthroughResponseData?.PassData != null)
+        //                    {
+        //                        var data = 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)
-        {
-            if (Gateway == null)
-            {
-                return null;
-            }
-            return await System.Threading.Tasks.Task.Run(async () =>
-            {
-                SetWritableValueResponAllData 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 SetWritableValueResponAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
-                        }
-                        else
-                        {
-                            d = new SetWritableValueResponAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
-                        }
-                    }
-
-                    if (topic == gatewayID + "/" + "SetWritableValue_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<SetWritableValueResponData>(jobject["Data"].ToString());
-
-                        if (tempData == null)
-                        {
-                            d = new SetWritableValueResponAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
-                        }
-                        else
-                        {
-                            d = new SetWritableValueResponAllData { setWritableValueResponData = tempData };
-                            System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
-                        }
-                    }
-                };
-                Gateway.Actions += action;
-                System.Console.WriteLine("SetWritableValue_Actions 鍚姩" + "_" + System.DateTime.Now.ToString());
-                try
-                {
-                    var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 6 }, { "Command", 120 } };
-                    var data = new JObject { { "Undivided", 0 }, { "AttributeId", 6533 }, { "AttributeDataType", 33 }, { "AttributeData", (int)value } };
-                    jObject.Add("Data", data);
-                    Gateway.Send("SetWritableValue", 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 SetWritableValueResponAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
-                }
-                Gateway.Actions -= action;
-                System.Console.WriteLine("SetWritableValue_Actions 閫�鍑�" + System.DateTime.Now.ToString());
-                return d;
-            });
-        }
 
         /// <summary>
         /// 閰嶇疆闈㈡澘鐨勫姛鑳芥ā寮�
@@ -2487,20 +1787,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 +1831,10 @@
             /// 绐楀笜绫诲瀷鈥斺�斾笅闄嶅仠姝�.
             /// </summary>
             Wcd_Down_Stop = 304,
+            /// <summary>
+            /// 绐楀笜绫诲瀷鈥斺�斾笅闄嶅仠姝�.
+            /// </summary>
+            Default = 65535,
         }
         #endregion
 
@@ -2533,119 +1847,7 @@
         }
 
         #region  璇诲彇闈㈡澘鐨勯厤缃俊鎭�
-        /// <summary>
-        /// 璇诲彇闈㈡澘鐨勯厤缃俊鎭�
-        /// </summary>
-        public async System.Threading.Tasks.Task<PanelConfigureInfoResponAllData> ReadPanelConfigureInfoAsync(params int[] args)
-        {
-            if (Gateway == null)
-            {
-                return null;
-            }
-            return await System.Threading.Tasks.Task.Run(async () =>
-            {
-                PanelConfigureInfoResponAllData d = null;
-                Action<string, string> action = (topic, message) =>
-                {
-                    var gatewayID = topic.Split('/')[0];//缃戝叧杩斿洖鐨勭綉鍏矷D
-                    var reportStatus = topic.Split('/')[1];//涓婚涓鸿澶囦笂鎶ョ殑涓婚
-                    string addr = "";//涓婃姤鐨勮澶嘺ddr
-                    string epoint = "";//涓婃姤鐨勮澶噀point
-                    string cluID = "";//涓婃姤鐨勮澶嘽luID
-                    string attrId = "";//涓婃姤鐨勮澶嘺ttrId
-                    if (reportStatus == "DeviceStatusReport")
-                    {
-                        addr = topic.Split('/')[2];
-                        epoint = topic.Split('/')[3];
-                        cluID = topic.Split('/')[4];
-                        attrId = topic.Split('/')[5];
-                    }
-                    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 PanelConfigureInfoResponAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
-                        }
-                        else
-                        {
-                            d = new PanelConfigureInfoResponAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
-                        }
-                    }
-                    else if (topic == gatewayID + "/" + "DeviceStatusReport" + "/" + addr + "/" + epoint + "/" + cluID + "/" + attrId)
-                    {
-                        var deviceID = jobject.Value<int>("Device_ID");
-                        var deviceAddr = jobject.Value<string>("DeviceAddr");
-                        var tempEpoint = jobject.Value<int>("Epoint");
-                        var dataId = jobject.Value<int>("Data_ID");
-
-                        var lightSwitch = new Panel { DeviceID = deviceID, DeviceAddr = deviceAddr, DeviceEpoint = tempEpoint, DataID = dataId };
-                        lightSwitch.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.DeviceStatusReportData>(jobject["Data"].ToString());
-                        if ((DeviceType)(deviceID) == DeviceType.OnOffSwitch)
-                        {
-                            var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.DeviceStatusReportData>(jobject["Data"].ToString());
-                            if (tempData == null)
-                            {
-                                d = new PanelConfigureInfoResponAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
-                            }
-                            else
-                            {
-                                d = new PanelConfigureInfoResponAllData { deviceStatusReportData = tempData };
-                                System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
-                            }
-                        }
-                    }
-                };
-
-                Gateway.Actions += action;
-                System.Console.WriteLine("GetDeviceStatus_Actions 鍚姩" + System.DateTime.Now.ToString());
-
-                try
-                {
-                    var JObject = new JObject {
-                { "DeviceAddr",DeviceAddr },
-                { "Epoint", DeviceEpoint },
-                { "Cluster_ID", (int)Device.Cluster_ID.HdlKey },
-                { "Command", 108 }
-                    };
-                    var attriBute = new JArray{
-                  new JObject {
-                    { "AttriButeId", (int)AttriButeId.HdlKey}
-                   }
-                    };
-                    var data = new JObject { { "AttriBute", attriBute } };
-                    JObject.Add("Data", data);
-                    Gateway?.Send(("GetDeviceStatus"), 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 PanelConfigureInfoResponAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
-                }
-                Gateway.Actions -= action;
-                System.Console.WriteLine("GetDeviceStatus_Actions 閫�鍑�" + System.DateTime.Now.ToString());
-
-                return d;
-            });
-        }
-
+
         /// <summary>
         /// 缃戝叧鎭㈠鍑哄巶璁剧疆杩斿洖鏁版嵁
         /// </summary>
@@ -2668,993 +1870,132 @@
         }
         #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);
-        //}
+        [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