From 94e4e5b9fd3da964c44b7b14227d6fe2bbb426d7 Mon Sep 17 00:00:00 2001
From: WJC <wjc@hdlchina.com.cn>
Date: 星期四, 02 四月 2020 13:56:39 +0800
Subject: [PATCH] 2020-04-02-2

---
 ZigbeeApp/Shared/Phone/ZigBee/Device/BindObj.cs |  351 +++++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 285 insertions(+), 66 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/BindObj.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/BindObj.cs
index 1116805..e852fa5 100755
--- a/ZigbeeApp/Shared/Phone/ZigBee/Device/BindObj.cs
+++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/BindObj.cs
@@ -5,7 +5,7 @@
 namespace ZigBee.Device
 {
     [System.Serializable]
-    public class BindObj :CommonDevice
+    public class BindObj : CommonDevice
     {
         #region 璁惧缁戝畾
         /// <summary>
@@ -13,14 +13,13 @@
         /// </summary>
         public async System.Threading.Tasks.Task<AddedDeviceBindResponseAllData> AddDeviceBindAsync(AddBindData addBindData)
         {
-
             return await System.Threading.Tasks.Task.Run(async () =>
             {
-                var result = new AddedDeviceBindResponseAllData();
+                AddedDeviceBindResponseAllData result = null;
                 var mainGateway = ZbGateway.MainGateWay;
                 if (mainGateway == null)
                 {
-                    result.errorMessageBase = "褰撳墠娌℃湁涓荤綉鍏�";
+                    result = new AddedDeviceBindResponseAllData { errorMessageBase = "褰撳墠娌℃湁涓荤綉鍏�" };
                     return result;
                 }
                 Action<string, string> action = (topic, message) =>
@@ -45,39 +44,20 @@
                     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 = ZbGateway.MainGateWay.getGatewayBaseInfo.gwID };
-                        var tempBindList = Newtonsoft.Json.Linq.JArray.Parse(jobject["Data"]["BindList"].ToString());
-                        if (tempBindList == null)
+                        var tempResult = Newtonsoft.Json.JsonConvert.DeserializeObject<AddedDeviceBindResponseData>(jobject["Data"].ToString());
+                        if (tempResult == null)
                         {
-                            result.errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�";
+                            result = new AddedDeviceBindResponseAllData { 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;
-                                DebugPrintLog($"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 = ZbGateway.MainGateWay.getGatewayBaseInfo.gwID };
-                        var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<AddBindResultResponseData>(jobject["Data"].ToString());
-
-                        if (tempData != null)
-                        {
-                            result.addBindResultResponseData = tempData;
+                            result = new AddedDeviceBindResponseAllData { addedDeviceBindResponseData = tempResult };
+                            DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{topic}");
                         }
                     }
                 };
                 mainGateway.Actions += action;
-                DebugPrintLog("Bind/SetBind_Actions 鍚姩" + "_" + System.DateTime.Now.ToString());
+                DebugPrintLog("Bind/SetBind_Actions 鍚姩" + "_" + System.DateTime.Now.ToLongTimeString() + " " + System.DateTime.Now.Millisecond);
                 try
                 {
                     if (addBindData != null)
@@ -90,9 +70,9 @@
                             {
                                 var dInfo = new JObject{
                             { "BindMacAddr",bindInfo.BindMacAddr},
-                         { "BindEpoint", bindInfo.BindEpoint} ,
-                         { "BindCluster", bindInfo.BindCluster} ,
-                         { "BindType",bindInfo.BindType}
+                            { "BindEpoint", bindInfo.BindEpoint} ,
+                            { "BindCluster", bindInfo.BindCluster} ,
+                            { "BindType",bindInfo.BindType}
                             };
                                 bindList.Add(dInfo);
                             }
@@ -100,18 +80,17 @@
                             {
                                 var dInfo = new JObject{
                              { "BindCluster", bindInfo.BindCluster} ,
-                         { "BindType",bindInfo.BindType},
-                         { "BindScenesId", bindInfo.BindScenesId}
+                             { "BindType",bindInfo.BindType},
+                             { "BindScenesId", bindInfo.BindScenesId}
                             };
                                 bindList.Add(dInfo);
                             }
                         }
                         var data = new JObject{
-                    {"BindName",addBindData.BindName},
-                    { "BindList", bindList }
+                            {"BindName",addBindData.BindName},
+                             { "BindList", bindList }
                     };
                         jObject.Add("Data", data);
-                        //ZbGateway.MainGateWay.CurrentGateWayId = ZbGateway.MainGateWay.getGatewayBaseInfo?.gwID;
                         mainGateway.Send("Bind/SetBind", jObject.ToString());
                     }
                 }
@@ -120,31 +99,20 @@
                 }
 
                 var dateTime = DateTime.Now;
-                while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime)
+                while ((DateTime.Now - dateTime).TotalMilliseconds < 20 * 1000)
                 {
-                    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
+                    await System.Threading.Tasks.Task.Delay(10);
+                    if (result != null)
                     {
                         break;
                     }
                 }
-                if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
+                if ((DateTime.Now - dateTime).TotalMilliseconds > 20 * 1000)
                 {
-                    result.errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔";
+                    result = new AddedDeviceBindResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
                 }
                 mainGateway.Actions -= action;
-                System.Console.WriteLine($"Bind/SetBind_Actions 閫�鍑� {System.DateTime.Now}");
+                System.Console.WriteLine($"Bind/SetBind_Actions 閫�鍑� { System.DateTime.Now.ToLongTimeString() + " " + System.DateTime.Now.Millisecond}");
                 return result;
             });
         }
@@ -189,7 +157,12 @@
             /// <summary>
             ///缁戝畾鍒楄〃 锛屽綋Status=0鏃跺瓨鍦�
             /// </summary>
-            public List<AddBindListResponseObj> BindList = new List<AddBindListResponseObj>();
+            public List<BindListResponseObj> BindList = new List<BindListResponseObj>();
+            /// <summary>
+            /// 0锛氱粦瀹氭墍鏈夌洰鏍囨垚鍔�
+            ///<para>1锛氱粦瀹氱洰鏍囧け璐ワ紝缁戝畾璁惧鐩爣鏈夋紡鎺�</para> 
+            /// </summary>
+            public int Result = -1;
         }
 
         /// <summary>
@@ -303,6 +276,124 @@
         /// <summary>
         /// 瑙i櫎缁戝畾
         /// </summary>
+        //public async System.Threading.Tasks.Task<DelDeviceBindResponseAllData> DelDeviceBindAsync(DelDeviceBindData delDeviceBindData)
+        //{
+        //    return await System.Threading.Tasks.Task.Run(async () =>
+        //    {
+        //        DelDeviceBindResponseAllData responseData = null;
+        //        var mainGateway = ZbGateway.MainGateWay;
+        //        if (mainGateway == null)
+        //        {
+        //            responseData = new DelDeviceBindResponseAllData { errorMessageBase = "褰撳墠娌℃湁涓荤綉鍏�" };
+        //        }
+
+        //        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 = new DelDeviceBindResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
+        //                }
+        //                else
+        //                {
+        //                    responseData = new DelDeviceBindResponseAllData { errorResponData = temp, 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 = new DelDeviceBindResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
+        //                }
+        //                else
+        //                {
+        //                    responseData = new DelDeviceBindResponseAllData { 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 = new DelDeviceBindResponseAllData { 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(10);
+        //            if (responseData != null)
+        //            {
+        //                break;
+        //            }
+        //        }
+        //        if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
+        //        {
+        //            responseData = new DelDeviceBindResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
+        //        }
+        //        mainGateway.Actions -= action;
+        //        System.Console.WriteLine("DeviceBind/DelBind_Actions 閫�鍑�" + System.DateTime.Now.ToString());
+        //        return responseData;
+        //    });
+        //}
+
+        //涔嬪墠2绉嶆柟寮忓弽棣堢粨鏋�
         public async System.Threading.Tasks.Task<DelDeviceBindResponseAllData> DelDeviceBindAsync(DelDeviceBindData delDeviceBindData)
         {
             return await System.Threading.Tasks.Task.Run(async () =>
@@ -405,7 +496,6 @@
                 }
                 catch { }
 
-
                 var dateTime = DateTime.Now;
                 while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime)
                 {
@@ -414,7 +504,21 @@
                     {
                         continue;
                     }
-                    if (0 < responseData.delDeviceBindResponseData.RemoveBindList.FindAll((obj) => obj.BindType == 0).Count)
+                    if (0 < responseData.delDeviceBindResponseData.RemoveBindList.FindAll((obj) => obj.BindType == 0 && obj.Result == 1).Count)
+                    {
+                        if (responseData.removeBindResultResponseData != null)
+                        {
+                            break;
+                        }
+                    }
+                    else if (0 < responseData.delDeviceBindResponseData.RemoveBindList.FindAll((obj) => obj.BindType == 0 && obj.Result == 3).Count)
+                    {
+                        if (responseData.removeBindResultResponseData != null)
+                        {
+                            break;
+                        }
+                    }
+                    else if (0 < responseData.delDeviceBindResponseData.RemoveBindList.FindAll((obj) => obj.BindType == 0 && obj.Result == 2).Count)
                     {
                         if (responseData.removeBindResultResponseData != null)
                         {
@@ -426,14 +530,12 @@
                         break;
                     }
                 }
-
                 if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
                 {
                     responseData.errorMessageBase = "鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔";
                 }
                 mainGateway.Actions -= action;
                 System.Console.WriteLine("DeviceBind/DelBind_Actions 閫�鍑�" + System.DateTime.Now.ToString());
-
                 return responseData;
             });
         }
@@ -494,7 +596,7 @@
             /// 0锛氱Щ闄ゆ垚鍔燂紙璇ョ姸鎬佸彧閫傜敤鐢ㄤ簬璺ㄧ綉鍏崇粦瀹氥�佺粦瀹氬満鏅�佸け鏁堣澶囷紙璁惧宸茬粡浠庣綉鍏崇殑璁惧鍒楄〃涓垹闄わ級銆傚悓缃戝叧璁惧闂寸殑瑙i櫎缁戝畾闇�瑕佽妭鐐硅澶囩殑纭鎴愬姛淇℃伅锛屼笉浼氱洿鎺ュ弽棣堟垚鍔熴�傦級
             ///<para>1锛氬け璐ワ紝璁惧涓嶅湪缁戝畾鍒楄〃涓�</para>
             ///<para>3锛氬け璐ワ紝鍦ㄧ瓑寰呰妭鐐硅澶囩‘璁ゆ槸鍚﹁В闄ょ粦瀹氭垚鍔燂紙褰撶綉鍏宠繕鍦ㄧ瓑寰呮煇鑺傜偣璁惧纭鏄惁瑙i櫎缁戝畾鎴愬姛鐨勫弽棣堜俊鎭椂锛屽鎴风鍐嶆鍙戦�佽В闄ょ粦瀹氳鑺傜偣璁惧鐨勬寚浠わ紝灏嗗弽棣堣鐘舵�併�傦級</para>
-            ///<para>4锛氭湭鐭ワ紝鐢辫妭鐐硅澶囧弽棣堝彂閫佲�淏ind/RemoveBindResult鈥濅富棰樻秷鎭‘瀹氭槸鍚︽垚鍔熴��</para>
+            ///<para>2锛氭湭鐭ワ紝鐢辫妭鐐硅澶囧弽棣堝彂閫佲�淏ind/RemoveBindResult鈥濅富棰樻秷鎭‘瀹氭槸鍚︽垚鍔熴��</para>
             /// </summary>
             public int Result;
 
@@ -749,7 +851,7 @@
         /// <summary>
         ///浠庤妭鐐硅澶囨湰鍦拌褰曡鍙栫粦瀹氬垪琛ㄤ俊鎭�
         /// </summary>
-        public async System.Threading.Tasks.Task<GetDeviceLocalBindResponseAllData> GetDeviceLocalBindAsync(int startIndex=0)
+        public async System.Threading.Tasks.Task<GetDeviceLocalBindResponseAllData> GetDeviceLocalBindAsync(int startIndex = 0)
         {
             return await System.Threading.Tasks.Task.Run(async () =>
             {
@@ -784,8 +886,8 @@
                     if (topic == gatewayID + "/" + "Bind/GetDeviceLocalBind_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<GetDeviceLocalBindResponseData>(jobject["Data"].ToString());
-                         if (tempData == null)
+                        var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<GetDeviceLocalBindResponseData>(jobject["Data"].ToString());
+                        if (tempData == null)
                         {
                             d = new GetDeviceLocalBindResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
                         }
@@ -801,8 +903,8 @@
                 try
                 {
                     DebugPrintLog("Bind/GetDeviceLocalBind_Actions 鍚姩" + "_" + System.DateTime.Now.ToString());
-                    var jObject = new JObject { { "DeviceAddr", DeviceAddr },{ "Cluster_ID", 0 }, { "Command", 5008 } };
-                    var data = new JObject {{ "StartIndex", startIndex } };
+                    var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Cluster_ID", 0 }, { "Command", 5008 } };
+                    var data = new JObject { { "StartIndex", startIndex } };
                     mainGateway.Send("Bind/GetDeviceLocalBind", jObject.ToString());
                 }
                 catch { }
@@ -872,7 +974,7 @@
             /// <summary>
             /// 璇ユ璇诲彇杩斿洖缁戝畾鍒楄〃涓暟
             /// </summary>
-            public int ReturnBindNum;
+            public int ReturnBindNum;
             /// <summary>
             /// 缁戝畾鍒楄〃锛屽綋Result=0鏃跺瓨鍦�
             /// </summary>
@@ -912,5 +1014,122 @@
             public int BindEpoint;
         }
         #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;
+                DebugPrintLog("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 < 25 * 1000)
+                {
+                    await System.Threading.Tasks.Task.Delay(10);
+                    if (d != null)
+                    {
+                        break;
+                    }
+                }
+                //涓�閿竻闄ょ洰鏍囷紝浼氬洜涓虹洰鏍囨暟閲忓鑰屽姞闀挎椂闂达紝鐩墠鏆傚畾20绉�
+                if ((DateTime.Now - dateTime).TotalMilliseconds > 25 * 1000)
+                {
+                    d = new ClearBindInfoResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
+                }
+                Gateway.Actions -= action;
+                DebugPrintLog("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
     }
 }

--
Gitblit v1.8.0