From e747e6d8524e3146bb48dc304a713f309966b1c6 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期二, 19 五月 2020 13:10:03 +0800
Subject: [PATCH] 新版本

---
 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs |  404 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 379 insertions(+), 25 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs
index de95fbe..97a36c8 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs
@@ -3,6 +3,7 @@
 using System.Text;
 using ZigBee.Device;
 using System.Threading.Tasks;
+using Newtonsoft.Json.Linq;
 
 namespace Shared.Phone.UserCenter
 {
@@ -37,13 +38,13 @@
         #region 鈻� 鑾峰彇璁惧涓嬮潰缁戝畾鐨勮澶嘷____________
 
         /// <summary>
-        /// 鑾峰彇璁惧涓嬮潰缁戝畾鐨勮澶�(閿欒鏃惰繑鍥瀗ull)
+        /// 鑾峰彇璁惧涓嬮潰缁戝畾鐨勮澶�(閿欒鏃惰繑鍥瀗ull),杩欎釜鏄粰pir浼犳劅鍣ㄧ敤鐨�
         /// </summary>
         /// <param name="mainDevice">璁惧瀵硅薄</param>
         /// <returns></returns>
-        public async Task<List<CommonDevice>> GetBindTargetDevice(CommonDevice mainDevice)
+        public List<CommonDevice> GetBindTargetDevice(CommonDevice mainDevice)
         {
-            var result = (BindObj.GetDeviceBindResponseAllData)await this.LoadDeviceMethodByNameAsync(mainDevice, "GetDeviceBindAsync");
+            var result = this.GetDeviceBindAsync(mainDevice);
             if (result == null || result.getAllBindResponseData == null)
             {
                 //鑾峰彇璁惧鐨勭粦瀹氱洰鏍囧け璐�
@@ -67,6 +68,37 @@
             return listDevice;
         }
 
+        /// <summary>
+        ///鑾峰彇鎵�鏈夌粦瀹�
+        /// </summary>
+        public BindObj.GetDeviceBindResponseAllData GetDeviceBindAsync(CommonDevice device)
+        {
+            //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹�
+            if (Common.Config.Instance.Home.IsVirtually == true)
+            {
+                var listBind = ModelData.DeviceModelDataLogic.Current.GetDeviceBindList(device, "Bind/GetDeviceBind");
+                return new BindObj.GetDeviceBindResponseAllData()
+                {
+                    getAllBindResponseData = new BindObj.GetDeviceBindResponseData
+                    {
+                        Result = 0,
+                        BindList = listBind
+                    }
+                };
+            }
+
+            var jObject = new JObject { { "DeviceAddr", device.DeviceAddr }, { "Epoint", device.DeviceEpoint }, { "Cluster_ID", 0 }, { "Command", 5007 } };
+            string sendData = jObject.ToString();
+            //鍙戦��
+            var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "Bind/GetDeviceBind", sendData, "Bind/GetDeviceBind_Respon", 6);
+            if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
+            {
+                return null;
+            }
+            var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<BindObj.GetDeviceBindResponseData>(result.ReceiptData);
+            return new BindObj.GetDeviceBindResponseAllData() { getAllBindResponseData = tempData };
+        }
+
         #endregion
 
         #region 鈻� 鎵ц缁戝畾璁惧鐩爣___________________
@@ -78,7 +110,7 @@
         /// <param name="listDevice">瑕佺粦瀹氱殑鐩爣璁惧</param>
         /// <param name="BindCluster">BindCluster</param>
         /// <returns></returns>
-        public async Task<List<CommonDevice>> BindDeviceTarget(CommonDevice mainDevice, List<CommonDevice> listDevice, int BindCluster = 6)
+        public List<CommonDevice> BindDeviceTarget(CommonDevice mainDevice, List<CommonDevice> listDevice, int BindCluster = 6)
         {
             if (listDevice.Count == 0)
             {
@@ -105,8 +137,8 @@
                 string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
                 dicDevice[mainkeys] = device;
             }
-
-            var result = (BindObj.AddedDeviceBindResponseAllData)await this.LoadDeviceMethodByNameAsync(mainDevice, "AddDeviceBindAsync", addData);
+            //鎵ц缁戝畾
+            var result = this.AddDeviceBindAsync(addData);
             if (result == null || result.addedDeviceBindResponseData == null)
             {
                 //缁戝畾鐩爣璁剧疆澶辫触
@@ -137,6 +169,63 @@
             return listSuccess;
         }
 
+        /// <summary>
+        ///璁惧缁戝畾
+        /// </summary>
+        public BindObj.AddedDeviceBindResponseAllData AddDeviceBindAsync(BindObj.AddBindData addBindData)
+        {
+            //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹�
+            if (Common.Config.Instance.Home.IsVirtually == true)
+            {
+                return ModelData.DeviceModelDataLogic.Current.AddDeviceBindList(addBindData, "Bind/GetDeviceBind");
+            }
+
+            var device = Common.LocalDevice.Current.GetDevice(addBindData.DeviceAddr, addBindData.Epoint);
+            //鑾峰彇鍙戦�佺殑鍛戒护瀛楃
+            var sendData = this.GetAddDeviceListBindCommandText(addBindData);
+            //鍙戦��
+            var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "Bind/SetBind", sendData, "Bind/SetBind_Respon", 20);
+            if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
+            {
+                return null;
+            }
+
+            //淇敼缂撳瓨
+            ModelData.DeviceModelDataLogic.Current.AddDeviceBindList(addBindData, "Bind/GetDeviceBind");
+
+            var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<BindObj.AddedDeviceBindResponseData>(result.ReceiptData);
+            return new BindObj.AddedDeviceBindResponseAllData() { addedDeviceBindResponseData = tempData };
+        }
+
+        /// <summary>
+        /// 鑾峰彇娣诲姞璁惧缁戝畾鐨勫懡浠ゅ瓧绗�
+        /// </summary>
+        /// <param name="addBindData"></param>
+        /// <returns></returns>
+        public string GetAddDeviceListBindCommandText(BindObj.AddBindData addBindData)
+        {
+            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);
+            return jObject.ToString();
+        }
+
         #endregion
 
         #region 鈻� 鍒犻櫎璁惧缁戝畾鐨勭洰鏍嘷________________
@@ -148,7 +237,7 @@
         /// <param name="deleteDevice">瑕佸垹闄ょ殑缁戝畾鐩爣璁惧</param>
         /// <param name="BindCluster">BindCluster</param>
         /// <returns></returns>
-        public async Task<bool> DeleteDeviceTarget(CommonDevice mainDevice, CommonDevice deleteDevice, int BindCluster = 6)
+        public bool DeleteDeviceTarget(CommonDevice mainDevice, CommonDevice deleteDevice, int BindCluster = 6)
         {
             //缁勮鏁版嵁
             var deleteData = new IASZone.DelDeviceBindData();
@@ -163,7 +252,8 @@
 
             deleteData.RemoveBindList.Add(info);
 
-            var result = (BindObj.DelDeviceBindResponseAllData)await this.LoadDeviceMethodByNameAsync(mainDevice, "DelDeviceBindAsync", deleteData);
+            //鎵ц鍒犻櫎
+            var result = this.DelDeviceBindAsync(deleteData);
             if (result == null || result.delDeviceBindResponseData == null)
             {
                 //鍒犻櫎缁戝畾鐩爣澶辫触
@@ -233,7 +323,7 @@
         /// <param name="listDeleteDevice">瑕佸垹闄ょ殑缁戝畾鐩爣璁惧</param>
         /// <param name="BindCluster">BindCluster</param>
         /// <returns>杩斿洖鐨勬槸鎴愬姛鍒犻櫎鐨勮澶�</returns>
-        public async Task<List<CommonDevice>> DeleteDeviceTarget(CommonDevice mainDevice, List<CommonDevice> listDeleteDevice, int BindCluster = 6)
+        public List<CommonDevice> DeleteDeviceTarget(CommonDevice mainDevice, List<CommonDevice> listDeleteDevice, int BindCluster = 6)
         {
             //缁勮鏁版嵁
             var deleteData = new IASZone.DelDeviceBindData();
@@ -256,7 +346,7 @@
             }
             var listSuccess = new List<CommonDevice>();
 
-            var result = (BindObj.DelDeviceBindResponseAllData)await this.LoadDeviceMethodByNameAsync(mainDevice, "DelDeviceBindAsync", deleteData);
+            var result = this.DelDeviceBindAsync(deleteData);
             if (result == null || result.delDeviceBindResponseData == null)
             {
                 //鍒犻櫎缁戝畾鐩爣澶辫触
@@ -320,25 +410,289 @@
             return listSuccess;
         }
 
+        /// <summary>
+        /// 鍒犻櫎璁惧鐨勭粦瀹氱洰鏍�
+        /// </summary>
+        /// <param name="delDeviceBindData"></param>
+        /// <returns></returns>
+        public BindObj.DelDeviceBindResponseAllData DelDeviceBindAsync(BindObj.DelDeviceBindData delDeviceBindData)
+        {
+            //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹�
+            if (Common.Config.Instance.Home.IsVirtually == true)
+            {
+                return ModelData.DeviceModelDataLogic.Current.DeleteDeviceBindList(delDeviceBindData);
+            }
+            var device = Common.LocalDevice.Current.GetDevice(delDeviceBindData.DeviceAddr, delDeviceBindData.Epoint);
+            //鑾峰彇闇�瑕佸彂閫佺殑鏁版嵁
+            var sendData = this.GetDeleteDeviceBindCommandText(delDeviceBindData);
+            //鍙戦�佸懡浠�
+            var result = this.SendDeleteBindJobjectDataToGateway(device, "Bind/RemoveBind",
+                sendData, new List<string>() { "Bind/RemoveBind_Respon", "Bind/RemoveBindResult" }, 6);
+
+            if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
+            {
+                return null;
+            }
+            var responseData = new BindObj.DelDeviceBindResponseAllData();
+            if (result.listReceiptData[0] != null)
+            {
+                var tempData1 = Newtonsoft.Json.JsonConvert.DeserializeObject<BindObj.DelDeviceBindResponseData>(result.listReceiptData[0]);
+                responseData.delDeviceBindResponseData = tempData1;
+            }
+
+            if (result.listReceiptData[1] != null)
+            {
+                var tempData2 = Newtonsoft.Json.JsonConvert.DeserializeObject<BindObj.RemoveBindResultResponseData>(result.listReceiptData[1]);
+                responseData.removeBindResultResponseData = tempData2;
+            }
+
+            //淇敼缂撳瓨
+            ModelData.DeviceModelDataLogic.Current.DeleteDeviceBindList(delDeviceBindData);
+
+            return responseData;
+        }
+
+        /// <summary>
+        ///鍒犻櫎涓�涓帶鍒惰澶囨墍鏈夌粦瀹氫俊鎭�
+        /// </summary>
+        public BindObj.ClearBindInfoResponseAllData ClearBindInfoAsync(CommonDevice device)
+        {
+            //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹�
+            if (Common.Config.Instance.Home.IsVirtually == true)
+            {
+                return ModelData.DeviceModelDataLogic.Current.ClearDeviceAllBind(device);
+            }
+
+            var jObject = new JObject { { "DeviceAddr", device.DeviceAddr }, { "Epoint", device.DeviceEpoint }, { "Cluster_ID", 0 }, { "Command", 5006 } };
+            var sendData = jObject.ToString();
+            var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "Bind/ClearBindInfo", sendData, "Bind/ClearBindInfo_Respon", 25);
+            if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
+            {
+                return null;
+            }
+
+            //淇敼缂撳瓨
+            ModelData.DeviceModelDataLogic.Current.ClearDeviceAllBind(device);
+
+            var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<BindObj.ClearBindInfoResponseData>(result.ReceiptData);
+            return new BindObj.ClearBindInfoResponseAllData { clearBindInfoResponseData = tempData };
+        }
+
+
+        /// <summary>
+        /// 鑾峰彇鍒犻櫎璁惧缁戝畾鍒楄〃鐨勫懡浠ゅ瓧绗�
+        /// </summary>
+        /// <param name="delDeviceBindData"></param>
+        /// <returns></returns>
+        public string GetDeleteDeviceBindCommandText(BindObj.DelDeviceBindData delDeviceBindData)
+        {
+            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);
+
+            return jObject.ToString();
+        }
+
+        /// <summary>
+        /// 鍙戦�佸垹闄ょ粦瀹氱殑鏁版嵁鍒扮綉鍏筹紝骞舵帴鍙楃綉鍏宠繑鍥炵殑鏁版嵁,listReceiptData涓鸿繑鍥炲��(鍒犻櫎缁戝畾鐨勬帴鍙e緢鐗规畩,闇�瑕佺嫭绔嬪嚭鏉�)
+        /// </summary>
+        /// <param name="device">璁惧瀵硅薄</param>
+        /// <param name="sendTopic">鍙戦�佺殑涓婚</param>
+        /// <param name="sendData">闇�瑕佸彂閫佺殑鏁版嵁  JObject.ToString()鐨勪笢瑗�</param>
+        /// <param name="listReceiptTopic">鎸囧畾鎺ユ敹鍝簺涓婚</param>
+        /// <param name="waitTime">瓒呮椂鏃堕棿(绉�)</param>
+        /// <returns>缃戝叧杩斿洖鐨勬暟鎹�</returns>
+        private ReceiptGatewayResult SendDeleteBindJobjectDataToGateway(CommonDevice device, string sendTopic, string sendData, List<string> listReceiptTopic, int waitTime = 3)
+        {
+            var reResult = new ReceiptGatewayResult();
+            reResult.listReceiptData = new string[listReceiptTopic.Count];
+            var myGateway = device.Gateway;
+            if (myGateway == null)
+            {
+                //鑾峰彇缃戝叧瀵硅薄澶辫触
+                reResult.ErrorMsg = Language.StringByID(R.MyInternationalizationString.uGetGatewayTagartFail);
+                reResult.ErrorMsgDiv = -1;
+                return reResult;
+            }
+            //缃戝叧ID
+            string gatewayID = HdlGatewayLogic.Current.GetGatewayId(device.Gateway);
+            //閿欒涓婚
+            string errorTopic = gatewayID + "/" + "Error_Respon";
+            //妫�娴嬪璞$殑涓婚
+            for (int i = 0; i < listReceiptTopic.Count; i++)
+            {
+                listReceiptTopic[i] = gatewayID + "/" + listReceiptTopic[i];
+            }
+
+            bool canbreak = false;
+            Action<string, string> receiptAction = (topic, message) =>
+            {
+                var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
+
+                //缃戝叧鍥炲閿欒
+                if (topic == errorTopic)
+                {
+                    var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString());
+                    reResult.ErrorMsg = HdlCheckLogic.Current.CheckCommonErrorCode(temp.Error);
+                }
+                //濡傛灉鏄寚瀹氱殑涓婚
+                for (int i = 0; i < listReceiptTopic.Count; i++)
+                {
+                    if (topic == listReceiptTopic[i])
+                    {
+                        string deviceMac = jobject["DeviceAddr"].ToString();
+                        int deviceEpoint = Convert.ToInt32(jobject["Epoint"].ToString());
+                        if (device.DeviceAddr != deviceMac)
+                        {
+                            //涓嶆槸鍚屼竴涓笢瑗縈ac
+                            return;
+                        }
+                        if (device.DeviceEpoint != deviceEpoint && deviceEpoint != 200)
+                        {
+                            //涓嶆槸鍚屼竴涓笢瑗�,杩欓噷搴旇闇�瑕佺壒娈婂鐞�200绔偣
+                            return;
+                        }
+                        reResult.listReceiptData[i] = jobject["Data"].ToString();
+                        if (i == 0)
+                        {
+                            //鍙湁鏄疊ind/RemoveBind_Respon涓婚,鎵嶈兘涓柇
+                            canbreak = true;
+                        }
+                    }
+                }
+
+            };
+            myGateway.Actions += receiptAction;
+            //鍙戦�佹暟鎹�
+            myGateway.Send(sendTopic, sendData);
+
+            //瓒呮椂鏃堕棿
+            int TimeOut = 0;
+            waitTime = 20 * waitTime;
+            while (canbreak == false && TimeOut < waitTime)
+            {
+                //鍏ㄩ儴鎺ユ敹鎵嶉��鍑�
+                System.Threading.Thread.Sleep(50);
+                TimeOut++;
+            }
+            myGateway.Actions -= receiptAction;
+            receiptAction = null;
+            if (canbreak == false)
+            {
+                //瓒呮椂
+                reResult.ErrorMsgDiv = 0;
+            }
+            else
+            {
+                //姝e父鎺ユ敹鍒扮綉鍏宠繑鍥炵殑鏁版嵁
+                if (reResult.listReceiptData.Length == 1)
+                {
+                    //濡傛灉鍙湁涓�涓富棰�,鍒欐浛鎹㈠彉閲�
+                    reResult.ReceiptData = reResult.listReceiptData[0];
+                    reResult.listReceiptData = null;
+                }
+            }
+
+            return reResult;
+        }
+
+
+        #endregion
+
+        #region 鈻� 閰嶇疆闈㈡澘鍔熻兘_______________________
+
+        ///<summary >
+        ///閰嶇疆闈㈡澘鍔熻兘
+        ///<para>value:缁欓潰鏉块厤缃殑妯″紡</para>
+        /// </summary>
+        public CommonDevice.SetWritableValueResponAllData ConfigureHdlKeyValueAsync(CommonDevice device, Panel.KeyMode value, int clusterID = 6)
+        {
+            //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹�
+            if (Common.Config.Instance.Home.IsVirtually == true)
+            {
+                return ModelData.DeviceModelDataLogic.Current.ConfigurePanelKeyModel(device, value, clusterID, "SetWritableValue");
+            }
+            //鑾峰彇鍙戦�佹暟鎹�
+            var sendData = this.GetConfigureHdlKeyCommandText(device.DeviceAddr, device.DeviceEpoint, value, clusterID);
+            var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "SetWritableValue", sendData, "SetWritableValue_Respon");
+            if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
+            {
+                return null;
+            }
+
+            //淇敼缂撳瓨
+            ModelData.DeviceModelDataLogic.Current.ConfigurePanelKeyModel(device, value, clusterID, "SetWritableValue");
+
+            var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.SetWritableValueResponData>(result.ReceiptData);
+            return new CommonDevice.SetWritableValueResponAllData { setWritableValueResponData = tempData };
+        }
+
+        /// <summary>
+        /// 璇诲彇闈㈡澘鐨勯厤缃俊鎭�
+        /// </summary>
+        public Panel.PanelConfigureInfoResponAllData ReadPanelConfigureInfoAsync(CommonDevice device)
+        {
+            //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹�
+            if (Common.Config.Instance.Home.IsVirtually == true)
+            {
+                return ModelData.DeviceModelDataLogic.Current.ReadPanelConfigureKeyModel(device);
+            }
+
+            var JObject = new JObject {{ "DeviceAddr",device.DeviceAddr },{ "Epoint", device.DeviceEpoint },
+                { "Cluster_ID", (int)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);
+
+            //鍙戦�佹暟鎹�
+            var sendData = JObject.ToString();
+            string receiptTopic = "DeviceStatusReport/" + device.DeviceAddr + "/" + device.DeviceEpoint + "/" + (int)Cluster_ID.HdlKey + "/" + (int)AttriButeId.HdlKey;
+            var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "GetDeviceStatus", sendData, receiptTopic);
+            if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
+            {
+                return null;
+            }
+
+            var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.DeviceStatusReportData>(result.ReceiptData);
+            return new Panel.PanelConfigureInfoResponAllData { deviceStatusReportData = tempData };
+        }
+
+        /// <summary>
+        /// 鑾峰彇閰嶇疆闈㈡澘鍔熻兘鐨勫懡浠ゅ瓧绗�
+        /// </summary>
+        /// <param name="device">璁惧瀵硅薄</param>
+        /// <param name="value">閿��</param>
+        /// <param name="clusterID">闀濱D</param>
+        /// <returns></returns>
+        public string GetConfigureHdlKeyCommandText(string DeviceAddr, int DeviceEpoint, Panel.KeyMode value, int clusterID = 6)
+        {
+            var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", clusterID }, { "Command", 120 } };
+            var data = new JObject { { "Undivided", 0 }, { "AttributeId", 6533 }, { "AttributeDataType", 33 }, { "AttributeData", (int)value } };
+            jObject.Add("Data", data);
+            return jObject.ToString();
+        }
 
         #endregion
 
         #region 鈻� 涓�鑸柟娉昣__________________________
-
-        /// <summary>
-        /// 鎵ц鎸囧畾璁惧瀵硅薄绫婚噷闈㈢殑鏂规硶(娉ㄦ剰锛氳繖涓槸涓撻棬璋冪敤寮傛锛屽苟涓旂瓑寰呭紓姝ュ畬鎴愮殑楂樼鎶�鍑芥暟,涓嶈皟鐢ㄥ紓姝ョ殑鎯呭喌锛屽埆浣跨敤姝ゅ嚱鏁�)
-        /// </summary>
-        /// <param name="device">闇�瑕佹墽琛岀殑璁惧鐨勮澶囧璞�</param>
-        /// <param name="method">鎸囧畾瑕佸姞杞界殑鏂规硶鍚�</param>
-        /// <param name="parameter">鍚姩鍙傛暟</param>
-        private async Task<object> LoadDeviceMethodByNameAsync(CommonDevice device, string method, params object[] parameter)
-        {
-            var task = device.GetType().InvokeMember(method, System.Reflection.BindingFlags.InvokeMethod, null, device, parameter) as Task;
-            await task;
-
-            var result = task.GetType().GetProperty("Result").GetValue(task, null);
-            return result;
-        }
 
         /// <summary>
         /// 鏄剧ず閿欒淇℃伅绐楀彛

--
Gitblit v1.8.0