From 7066c7866a6e6faef9c1cbc0793cecf392454baa Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期二, 05 一月 2021 17:50:15 +0800
Subject: [PATCH] 20201-1-5-1
---
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceCommonLogic.cs | 562 ++++++++++++++++++++++++++++++--------------------------
1 files changed, 300 insertions(+), 262 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 02d698c..f09249f
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceCommonLogic.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceCommonLogic.cs
@@ -1,272 +1,310 @@
-锘縰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];
- 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];
- }
-
- //鎺ユ敹鏁�
- int receiptCount = 0;
- 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 = 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();
- receiptCount++;
- }
- }
-
- };
- myGateway.Actions += receiptAction;
- //鍙戦�佹暟鎹�
- myGateway.Send(sendTopic, sendData);
-
- //瓒呮椂鏃堕棿
- int TimeOut = 0;
- waitTime = 20 * waitTime;
- while (receiptCount != listReceiptTopic.Count && TimeOut < waitTime)
- {
- //鍏ㄩ儴鎺ユ敹鎵嶉��鍑�
- System.Threading.Thread.Sleep(50);
- TimeOut++;
- }
- myGateway.Actions -= receiptAction;
- receiptAction = null;
- if (receiptCount != listReceiptTopic.Count)
- {
- reResult.ErrorMsgDiv = 0;
- }
- else
- {
- //姝e父鎺ユ敹鍒扮綉鍏宠繑鍥炵殑鏁版嵁
- if (reResult.listReceiptData.Length == 1)
- {
- //濡傛灉鍙湁涓�涓富棰�,鍒欐浛鎹㈠彉閲�
- reResult.ReceiptData = reResult.listReceiptData[0];
- reResult.listReceiptData = null;
- }
- }
-
- 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 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;
+ }
+
+ //瓒呮椂鏃堕棿
+ int TimeOut = 0;
+ waitTime = 20 * waitTime;
+ while (receveCount != listReceiptTopic.Count && TimeOut < waitTime)
+ {
+ //鍏ㄩ儴鎺ユ敹鎵嶉��鍑�
+ System.Threading.Thread.Sleep(50);
+ TimeOut++;
+ }
+ myGateway.Actions -= receiptAction;
+ receiptAction = null;
+ 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;
- }
- }
- };
- 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
+ }
+}
--
Gitblit v1.8.0