From dc0309e64f02227d8e1468b7326c07955f804612 Mon Sep 17 00:00:00 2001
From: chenqiyang <1406175257@qq.com>
Date: 星期三, 22 六月 2022 11:22:18 +0800
Subject: [PATCH] 修改引用路径

---
 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceCommonLogic.cs |  611 +++++++++++++++++++++++++++++-------------------------
 1 files changed, 326 insertions(+), 285 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceCommonLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceCommonLogic.cs
old mode 100755
new mode 100644
index d9e3d0c..68de7b7
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceCommonLogic.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceCommonLogic.cs
@@ -1,295 +1,336 @@
-锘縰sing System;
-using System.Collections.Generic;
-using System.Text;
-using ZigBee.Device;
-
-namespace Shared.Phone.UserCenter
-{
-    /// <summary>
-    /// 璁惧鐨勫叡閫氶�昏緫
-    /// </summary>
-    public class HdlDeviceCommonLogic
-    {
-        #region 鈻� 鍙橀噺澹版槑___________________________
-
-        /// <summary>
-        /// 璁惧鐨勫叡閫氶�昏緫
+锘縰sing System;
+using System.Collections.Generic;
+using System.Text;
+using ZigBee.Device;
+
+namespace Shared.Phone.UserCenter
+{
+    /// <summary>
+    /// 璁惧鐨勫叡閫氶�昏緫
+    /// </summary>
+    public class HdlDeviceCommonLogic
+    {
+        #region 鈻� 鍙橀噺澹版槑___________________________
+
+        /// <summary>
+        /// 璁惧鐨勫叡閫氶�昏緫
         /// </summary>
-        private static HdlDeviceCommonLogic m_Current = null;
-        /// <summary>
-        /// 璁惧鐨勫叡閫氶�昏緫
+        private static HdlDeviceCommonLogic m_Current = null;
+        /// <summary>
+        /// 璁惧鐨勫叡閫氶�昏緫
         /// </summary>
-        public static HdlDeviceCommonLogic Current
-        {
-            get
-            {
-                if (m_Current == null)
-                {
-                    m_Current = new HdlDeviceCommonLogic();
-                }
-                return m_Current;
-            }
-            set
-            {
-                m_Current = value;
-            }
-        }
-
-        #endregion
-
-        #region 鈻� 鍙戦�佹暟鎹甠__________________________
-
-        /// <summary>
-        /// 鍙戦�佹暟鎹埌缃戝叧锛屽苟鎺ュ彈缃戝叧杩斿洖鐨勬暟鎹�(闈為�忎紶,ReceiptData涓鸿繑鍥炲��)
-        /// </summary>
-        /// <param name="device">璁惧瀵硅薄</param>
-        /// <param name="sendTopic">鍙戦�佺殑涓婚</param>
-        /// <param name="sendData">闇�瑕佸彂閫佺殑鏁版嵁  JObject.ToString()鐨勪笢瑗�</param>
-        /// <param name="receiptTopic">鎸囧畾鎺ユ敹鍝釜涓婚</param>
-        /// <param name="waitTime">瓒呮椂鏃堕棿(绉�)</param>
-        /// <returns>缃戝叧杩斿洖鐨勬暟鎹�</returns>
-        public ReceiptGatewayResult SendJobjectDataToGateway(CommonDevice device, string sendTopic, string sendData, string receiptTopic, int waitTime = 5)
-        {
-            //鍙戦�佹暟鎹埌缃戝叧锛屽苟鎺ュ彈缃戝叧杩斿洖鐨勬暟鎹�
-            return this.SendJobjectDataToGateway(device, sendTopic, sendData, new List<string>() { receiptTopic }, waitTime);
-        }
-
-        /// <summary>
-        /// 鍙戦�佹暟鎹埌缃戝叧锛屽苟鎺ュ彈缃戝叧杩斿洖鐨勬暟鎹�(闈為�忎紶),listReceiptData涓鸿繑鍥炲��(鍏ㄩ儴涓婚鍏ㄩ儴鎺ユ敹寰楀埌,鎵嶄細杩斿洖,涓嶇劧浼氳繑鍥炶秴鏃�)
-        /// </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>
-        public ReceiptGatewayResult SendJobjectDataToGateway(CommonDevice device, string sendTopic, string sendData, List<string> listReceiptTopic, int waitTime = 5)
-        {
-            var reResult = new ReceiptGatewayResult();
-            reResult.listReceiptData = new string[listReceiptTopic.Count];
-            reResult.JsonData = new string[listReceiptTopic.Count];
-
-            var myGateway = device.Gateway;
+        public static HdlDeviceCommonLogic Current
+        {
+            get
+            {
+                if (m_Current == null)
+                {
+                    m_Current = new HdlDeviceCommonLogic();
+                }
+                return m_Current;
+            }
+            set
+            {
+                m_Current = value;
+            }
+        }
+
+        #endregion
+
+        #region 鈻� 鍙戦�佹暟鎹甠__________________________
+
+        /// <summary>
+        /// 鍙戦�佹暟鎹埌缃戝叧锛屽苟鎺ュ彈缃戝叧杩斿洖鐨勬暟鎹�(闈為�忎紶,ReceiptData涓鸿繑鍥炲��)
+        /// </summary>
+        /// <param name="device">璁惧瀵硅薄</param>
+        /// <param name="sendTopic">鍙戦�佺殑涓婚</param>
+        /// <param name="sendData">闇�瑕佸彂閫佺殑鏁版嵁  JObject.ToString()鐨勪笢瑗�</param>
+        /// <param name="receiptTopic">鎸囧畾鎺ユ敹鍝釜涓婚</param>
+        /// <param name="waitTime">瓒呮椂鏃堕棿(绉�)</param>
+        /// <returns>缃戝叧杩斿洖鐨勬暟鎹�</returns>
+        public ReceiptGatewayResult SendJobjectDataToGateway(CommonDevice device, string sendTopic, string sendData, string receiptTopic, int waitTime = 5)
+        {
+            //鍙戦�佹暟鎹埌缃戝叧锛屽苟鎺ュ彈缃戝叧杩斿洖鐨勬暟鎹�
+            return this.SendJobjectDataToGateway(device, sendTopic, sendData, new List<string>() { receiptTopic }, waitTime);
+        }
+
+        /// <summary>
+        /// 鍙戦�佹暟鎹埌缃戝叧锛屽苟鎺ュ彈缃戝叧杩斿洖鐨勬暟鎹�(闈為�忎紶),listReceiptData涓鸿繑鍥炲��(鍏ㄩ儴涓婚鍏ㄩ儴鎺ユ敹寰楀埌,鎵嶄細杩斿洖,涓嶇劧浼氳繑鍥炶秴鏃�)
+        /// </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>
+        public ReceiptGatewayResult SendJobjectDataToGateway(CommonDevice device, string sendTopic, string sendData, List<string> listReceiptTopic, int waitTime = 5)
+        {
+            var reResult = new ReceiptGatewayResult();
+            reResult.listReceiptData = new string[listReceiptTopic.Count];
+            reResult.JsonData = new string[listReceiptTopic.Count];
+
+            var myGateway = device.Gateway;
             if (myGateway == null)
             {
                 //鑾峰彇缃戝叧瀵硅薄澶辫触
-                reResult.ErrorMsg = Language.StringByID(R.MyInternationalizationString.uGetGatewayTagartFail);
-                reResult.ErrorMsgDiv = -1;
+                reResult.ErrorMsg = Language.StringByID(R.MyInternationalizationString.uGetGatewayTagartFail);
+                reResult.ErrorMsgDiv = -1;
                 return reResult;
-            }
-            //缃戝叧ID
-            string gatewayID = device.Gateway.GwId;
-            //閿欒涓婚
-            string errorTopic = gatewayID + "/" + "Error_Respon";
-            //妫�娴嬪璞$殑涓婚
-            for (int i = 0; i < listReceiptTopic.Count; i++)
-            {
-                listReceiptTopic[i] = gatewayID + "/" + listReceiptTopic[i];
-            }
-
-            //钃濇墠鍒氭暣浜嗕釜鍚屼竴涓富棰樺彲鑳戒細鎺ㄩ�佸涓繃鏉ョ殑鏈鸿兘
-            var listCheckTopic = new HashSet<string>();
-            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])
-                    {
-                        if (listCheckTopic.Contains(topic) == true)
-                        {
-                            //杩欓噷鍐欒繖涓笢瑗挎槸鏈夌偣鐢ㄥ鐨�
-                            continue;
-                        }
-                        string deviceMac = jobject["DeviceAddr"].ToString();
-                        int deviceEpoint = 200;
-                        if (jobject.Property("Epoint") != null)
-                        {
-                            //鎷ユ湁姝ら敭鍊�
-                            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 (jobject.Property("Time") != null)
-                        {
-                            //闇�瑕佺Щ闄ime杩欎釜瀛楁
-                            jobject.Remove("Time");
-                        }
-                        reResult.JsonData[i] = jobject.ToString();
-                        if (listCheckTopic.Contains(topic) == false)
-                        {
-                            //鍔犲埌妫�娴嬩富棰樺璞′腑
-                            listCheckTopic.Add(topic);
-                        }
-                    }
-                }
-
-            };
-            myGateway.Actions += receiptAction;
-            //鍙戦�佹暟鎹�
-            myGateway.Send(sendTopic, sendData);
-
-            //瓒呮椂鏃堕棿
-            int TimeOut = 0;
-            waitTime = 20 * waitTime;
-            while (listCheckTopic.Count != listReceiptTopic.Count && TimeOut < waitTime)
-            {
-                //鍏ㄩ儴鎺ユ敹鎵嶉��鍑�
-                System.Threading.Thread.Sleep(50);
-                TimeOut++;
-            }
-            myGateway.Actions -= receiptAction;
-            receiptAction = null;
-            if (listCheckTopic.Count != listReceiptTopic.Count)
-            {
-                reResult.ErrorMsgDiv = 0;
-            }
-            else
-            {
-                //姝e父鎺ユ敹鍒扮綉鍏宠繑鍥炵殑鏁版嵁
-                if (reResult.listReceiptData.Length == 1)
-                {
-                    //濡傛灉鍙湁涓�涓富棰�,鍒欐浛鎹㈠彉閲�
-                    reResult.ReceiptData = reResult.listReceiptData[0];
-                }
-            }
-
-            return reResult;
-        }
-
-        /// <summary>
-        /// 鍙戦�佹暟鎹埌缃戝叧锛屽苟鎺ュ彈缃戝叧杩斿洖鐨勬暟鎹�(閫忎紶涓撶敤)
-        /// </summary>
-        /// <param name="device">璁惧瀵硅薄</param>
-        /// <param name="sendData">闇�瑕佸彂閫佺殑鏁版嵁  JObject.ToString()鐨勪笢瑗�</param>
-        /// <param name="receiptCommand">鎸囧畾鎺ユ敹鍛戒护绗�</param>
-        /// <param name="receiptDataLength">鎸囧畾鎺ユ敹鏁版嵁鐨勯暱搴�</param>
-        /// <param name="waitTime">瓒呮椂鏃堕棿(绉�)</param>
-        /// <param name="listReceiptLength">闄勫姞妫�娴嬫暟鎹帴鏀堕暱搴�,褰撴帴鏀剁殑闀垮害鍦ㄨ繖鍒楄〃閲岄潰鏃�,浠h〃鎺ユ敹鎴愬姛(鏃ㄥ湪瀵瑰簲鏂版棫璁惧,閫忎紶鍥炲鐨勯暱搴﹀彲鑳戒笉鍚�)</param>
-        /// <returns>缃戝叧杩斿洖鐨勬暟鎹�</returns>
-        public ReceiptGatewayResult SendJobjectDataToGateway2(CommonDevice device, string sendData, string receiptCommand, int receiptDataLength,
-            int waitTime = 5, List<int> listReceiptLength = null)
-        {
-            var reResult = new ReceiptGatewayResult();
-            var myGateway = device.Gateway;
+            }
+            //缃戝叧ID
+            string gatewayID = device.Gateway.GwId;
+            //閿欒涓婚
+            string errorTopic = gatewayID + "/" + "Error_Respon";
+            //妫�娴嬪璞$殑涓婚
+            for (int i = 0; i < listReceiptTopic.Count; i++)
+            {
+                listReceiptTopic[i] = gatewayID + "/" + listReceiptTopic[i];
+            }
+
+            //钃濇墠鍒氭暣浜嗕釜鍚屼竴涓富棰樺彲鑳戒細鎺ㄩ�佸涓繃鏉ョ殑鏈鸿兘
+            var listCheckTopic = new HashSet<string>();
+            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])
+                    {
+                        if (listCheckTopic.Contains(topic) == true)
+                        {
+                            //杩欓噷鍐欒繖涓笢瑗挎槸鏈夌偣鐢ㄥ鐨�
+                            continue;
+                        }
+                        string deviceMac = jobject["DeviceAddr"].ToString();
+                        int deviceEpoint = 200;
+                        if (jobject.Property("Epoint") != null)
+                        {
+                            //鎷ユ湁姝ら敭鍊�
+                            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 (jobject.Property("Time") != null)
+                        {
+                            //闇�瑕佺Щ闄ime杩欎釜瀛楁
+                            jobject.Remove("Time");
+                        }
+                        reResult.JsonData[i] = jobject.ToString();
+                        if (listCheckTopic.Contains(topic) == false)
+                        {
+                            //鍔犲埌妫�娴嬩富棰樺璞′腑
+                            listCheckTopic.Add(topic);
+                        }
+                    }
+                }
+
+            };
+            myGateway.Actions += receiptAction;
+            //鍙戦�佹暟鎹�
+            myGateway.Send(sendTopic, sendData);
+
+            //瓒呮椂鏃堕棿
+            int TimeOut = 0;
+            waitTime = 20 * waitTime;
+            while (listCheckTopic.Count != listReceiptTopic.Count && TimeOut < waitTime)
+            {
+                //鍏ㄩ儴鎺ユ敹鎵嶉��鍑�
+                System.Threading.Thread.Sleep(50);
+                TimeOut++;
+            }
+            myGateway.Actions -= receiptAction;
+            receiptAction = null;
+
+            int receveCount = listCheckTopic.Count;
+            if (receveCount > 1)
+            {
+                //鐪嬬湅閲岄潰鏈夋病鏈夐噸澶嶇殑
+                var listTemp = new HashSet<string>();
+                foreach (var value in listCheckTopic)
+                {
+                    if (listTemp.Contains(value) == false)
+                    {
+                        listTemp.Add(value);
+                    }
+                }
+                receveCount = listTemp.Count;
+            }
+
+            if (receveCount != listReceiptTopic.Count)
+            {
+                reResult.ErrorMsgDiv = 0;
+            }
+            else
+            {
+                //姝e父鎺ユ敹鍒扮綉鍏宠繑鍥炵殑鏁版嵁
+                if (reResult.listReceiptData.Length == 1)
+                {
+                    //濡傛灉鍙湁涓�涓富棰�,鍒欐浛鎹㈠彉閲�
+                    reResult.ReceiptData = reResult.listReceiptData[0];
+                }
+            }
+
+            return reResult;
+        }
+
+        /// <summary>
+        /// 鍙戦�佹暟鎹埌缃戝叧锛屽苟鎺ュ彈缃戝叧杩斿洖鐨勬暟鎹�(閫忎紶涓撶敤)
+        /// </summary>
+        /// <param name="device">璁惧瀵硅薄</param>
+        /// <param name="sendData">闇�瑕佸彂閫佺殑鏁版嵁  JObject.ToString()鐨勪笢瑗�</param>
+        /// <param name="receiptCommand">鎸囧畾鎺ユ敹鍛戒护绗�</param>
+        /// <param name="receiptDataLength">鎸囧畾鎺ユ敹鏁版嵁鐨勯暱搴�</param>
+        /// <param name="waitTime">瓒呮椂鏃堕棿(绉�)</param>
+        /// <param name="listReceiptLength">闄勫姞妫�娴嬫暟鎹帴鏀堕暱搴�,褰撴帴鏀剁殑闀垮害鍦ㄨ繖鍒楄〃閲岄潰鏃�,浠h〃鎺ユ敹鎴愬姛(鏃ㄥ湪瀵瑰簲鏂版棫璁惧,閫忎紶鍥炲鐨勯暱搴﹀彲鑳戒笉鍚�)</param>
+        /// <returns>缃戝叧杩斿洖鐨勬暟鎹�</returns>
+        public ReceiptGatewayResult SendJobjectDataToGateway2(CommonDevice device, string sendData, string receiptCommand, int receiptDataLength,
+            int waitTime = 5, List<int> listReceiptLength = null)
+        {
+            var reResult = new ReceiptGatewayResult();
+            var myGateway = device.Gateway;
             if (myGateway == null)
             {
                 //鑾峰彇缃戝叧瀵硅薄澶辫触
-                reResult.ErrorMsg = Language.StringByID(R.MyInternationalizationString.uGetGatewayTagartFail);
-                reResult.ErrorMsgDiv = -1;
+                reResult.ErrorMsg = Language.StringByID(R.MyInternationalizationString.uGetGatewayTagartFail);
+                reResult.ErrorMsgDiv = -1;
                 return reResult;
-            }
-            //缃戝叧ID
-            string gatewayID = device.Gateway.GwId;
-            //閿欒涓婚
-            string errorTopic = gatewayID + "/" + "Error_Respon";
-            //妫�娴嬪璞$殑涓婚
-            string checkTopic = gatewayID + "/ZbDataPassthrough";
-
-            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);
-                }
-                //濡傛灉鏄寚瀹氱殑涓婚
-                if (topic == checkTopic)
-                {
-                    string deviceMac = jobject["DeviceAddr"].ToString();
-                    int deviceEpoint = 200;
-                    if (jobject.Property("Epoint") != null)
-                    {
-                        //鎷ユ湁姝ら敭鍊�
-                        deviceEpoint = Convert.ToInt32(jobject["Epoint"].ToString());
-                    }
-                    if (device.DeviceAddr != deviceMac)
-                    {
-                        //涓嶆槸鍚屼竴涓笢瑗縈ac
-                        return;
-                    }
-                    if (device.DeviceEpoint != deviceEpoint && deviceEpoint != 200)
-                    {
-                        //涓嶆槸鍚屼竴涓笢瑗�,杩欓噷搴旇闇�瑕佺壒娈婂鐞�200绔偣
-                        return;
-                    }
-
-                    var responseData = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ClientDataPassthroughResponseData>(jobject["Data"].ToString());
-                    //闀垮害涓嶄竴鑷�
-                    if (responseData.PassData.Length != receiptDataLength)
-                    {
-                        if (listReceiptLength == null)
-                        {
-                            //濡傛灉娌℃湁闄勫姞妫�娴嬮暱搴�,鍒欑洿鎺ヨ繑鍥�
-                            return;
-                        }
-                        if (listReceiptLength.Contains(responseData.PassData.Length) == false)
-                        {
-                            //濡傛灉闄勫姞鐨勬娴嬮暱搴﹂噷闈�,杩樹笉瀛樺湪鐨勮瘽,鐩存帴杩斿洖
-                            return;
-                        }
-                    }
-
-                    var command = responseData.PassData[4].ToString()
-                        + responseData.PassData[5].ToString()
-                        + responseData.PassData[2].ToString()
-                        + responseData.PassData[3].ToString();
-                    //骞朵笖鏄繖涓懡浠�
-                    if (command == receiptCommand)
-                    {
-                        reResult.ReceiptData = responseData.PassData;
-                        reResult.JsonData = new string[1];
-                        if (jobject.Property("Time") != null)
-                        {
-                            //闇�瑕佺Щ闄ime杩欎釜瀛楁
-                            jobject.Remove("Time");
-                        }
-                        reResult.JsonData[0] = jobject.ToString();
-                    }
-                }
-            };
-            myGateway.Actions += receiptAction;
-            //鍙戦�佹暟鎹�
-            myGateway.Send("ClientDataPassthrough", sendData);
-
-            //瓒呮椂鏃堕棿
-            int TimeOut = 0;
-            waitTime = 20 * waitTime;
-            while (reResult.ReceiptData == null && TimeOut < waitTime)
-            {
-                System.Threading.Thread.Sleep(50);
-                TimeOut++;
-            }
-            myGateway.Actions -= receiptAction;
-            receiptAction = null;
-            if (reResult.ReceiptData == null)
-            {
-                //瓒呮椂
-                reResult.ErrorMsgDiv = 0;
-            }
-            return reResult;
-        }
-
-        #endregion
-    }
-}
+            }
+            //缃戝叧ID
+            string gatewayID = device.Gateway.GwId;
+            //閿欒涓婚
+            string errorTopic = gatewayID + "/" + "Error_Respon";
+            //妫�娴嬪璞$殑涓婚
+            string checkTopic = gatewayID + "/ZbDataPassthrough";
+
+            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);
+                }
+                //濡傛灉鏄寚瀹氱殑涓婚
+                if (topic == checkTopic)
+                {
+                    string deviceMac = jobject["DeviceAddr"].ToString();
+                    int deviceEpoint = 200;
+                    if (jobject.Property("Epoint") != null)
+                    {
+                        //鎷ユ湁姝ら敭鍊�
+                        deviceEpoint = Convert.ToInt32(jobject["Epoint"].ToString());
+                    }
+                    if (device.DeviceAddr != deviceMac)
+                    {
+                        //涓嶆槸鍚屼竴涓笢瑗縈ac
+                        return;
+                    }
+                    if (device.DeviceEpoint != deviceEpoint && deviceEpoint != 200)
+                    {
+                        //涓嶆槸鍚屼竴涓笢瑗�,杩欓噷搴旇闇�瑕佺壒娈婂鐞�200绔偣
+                        return;
+                    }
+
+                    var responseData = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ClientDataPassthroughResponseData>(jobject["Data"].ToString());
+                    //闀垮害涓嶄竴鑷�
+                    if (responseData.PassData.Length != receiptDataLength)
+                    {
+                        if (listReceiptLength == null)
+                        {
+                            //濡傛灉娌℃湁闄勫姞妫�娴嬮暱搴�,鍒欑洿鎺ヨ繑鍥�
+                            return;
+                        }
+                        if (listReceiptLength.Contains(responseData.PassData.Length) == false)
+                        {
+                            //濡傛灉闄勫姞鐨勬娴嬮暱搴﹂噷闈�,杩樹笉瀛樺湪鐨勮瘽,鐩存帴杩斿洖
+                            return;
+                        }
+                    }
+
+                    var command = responseData.PassData[4].ToString()
+                        + responseData.PassData[5].ToString()
+                        + responseData.PassData[2].ToString()
+                        + responseData.PassData[3].ToString();
+                    //骞朵笖鏄繖涓懡浠�
+                    if (command == receiptCommand)
+                    {
+                        reResult.ReceiptData = responseData.PassData;
+                        reResult.JsonData = new string[1];
+                        if (jobject.Property("Time") != null)
+                        {
+                            //闇�瑕佺Щ闄ime杩欎釜瀛楁
+                            jobject.Remove("Time");
+                        }
+                        reResult.JsonData[0] = jobject.ToString();
+                    }
+                }
+            };
+            myGateway.Actions += receiptAction;
+            //鍙戦�佹暟鎹�
+            myGateway.Send("ClientDataPassthrough", sendData);
+
+            //瓒呮椂鏃堕棿
+            int TimeOut = 0;
+            waitTime = 20 * waitTime;
+            while (reResult.ReceiptData == null && TimeOut < waitTime)
+            {
+                System.Threading.Thread.Sleep(50);
+                TimeOut++;
+            }
+            myGateway.Actions -= receiptAction;
+            receiptAction = null;
+            if (reResult.ReceiptData == null)
+            {
+                //瓒呮椂
+                reResult.ErrorMsgDiv = 0;
+            }
+            return reResult;
+        }
+
+        #endregion
+
+        #region 鈻� 涓�鑸柟娉昣__________________________
+
+        /// <summary>
+        /// 璁$畻鐏殑浜害鍊兼墍鍗犵殑鐧惧垎姣�(渚嬪:杩斿洖35,浠h〃鏄�35%)
+        /// </summary>
+        /// <param name="i_Level">鐏殑浜害鍊�</param>
+        /// <returns></returns>
+        public int CalculateLightLevelPersent(decimal i_Level)
+        {
+            return (int)((i_Level / 255) * 100);
+        }
+
+        /// <summary>
+        /// 璁$畻鎸囧畾鐧惧垎姣斿搴旂伅鐨勪寒搴﹀��
+        /// </summary>
+        /// <param name="i_Persent">鐧惧垎姣斿��(姣斿35,浠h〃35%)</param>
+        /// <returns></returns>
+        public int CalculateLightLevel(decimal i_Persent)
+        {
+            //闇�瑕佸悜涓婂彇鏁�,鎵嶈兘寰楀嚭
+            return (int)Math.Ceiling((i_Persent / 100) * 255);
+        }
+
+        #endregion
+    }
+}

--
Gitblit v1.8.0