From 34e965100d635346e2d4cd6e6013bdaed66b3004 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期四, 02 一月 2020 19:52:13 +0800
Subject: [PATCH] 2019.1.2-3
---
ZigbeeApp/Shared/Phone/ZigBee/Device/BindObj.cs | 139 ++++++++++++++++++++++++++--------------------
1 files changed, 78 insertions(+), 61 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/BindObj.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/BindObj.cs
index ebed365..728bea6 100755
--- a/ZigbeeApp/Shared/Phone/ZigBee/Device/BindObj.cs
+++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/BindObj.cs
@@ -15,11 +15,11 @@
{
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) =>
@@ -44,37 +44,38 @@
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 tempBindList = Newtonsoft.Json.Linq.JArray.Parse(jobject["Data"]["BindList"].ToString());
+ 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}");
- }
+ //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 = new AddedDeviceBindResponseAllData { addedDeviceBindResponseData = tempResult };
+ 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());
+ //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;
- }
- DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{topic}");
- }
+ // if (tempData != null)
+ // {
+ // result = new AddedDeviceBindResponseAllData { addBindResultResponseData = tempData };
+ // }
+ // DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{topic}");
+ //}
};
mainGateway.Actions += action;
DebugPrintLog("Bind/SetBind_Actions 鍚姩" + "_" + System.DateTime.Now.ToLongTimeString() + " " + System.DateTime.Now.Millisecond);
@@ -111,7 +112,6 @@
{ "BindList", bindList }
};
jObject.Add("Data", data);
- //ZbGateway.MainGateWay.CurrentGateWayId = ZbGateway.MainGateWay.getGatewayBaseInfo?.gwID;
mainGateway.Send("Bind/SetBind", jObject.ToString());
}
}
@@ -120,42 +120,54 @@
}
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 && obj.Result == 1).Count)
- {
- if (result.addBindResultResponseData != null)
- {
- break;
- }
- }
- else if (0 < result.addedDeviceBindResponseData.BindList.FindAll((obj) => obj.BindType == 0 && obj.Result == 2).Count)
- {
- if (result.addBindResultResponseData != null)
- {
- break;
- }
- }
- else if (0 < result.addedDeviceBindResponseData.BindList.FindAll((obj) => obj.BindType == 0 && obj.Result == 3).Count)
- {
- if (result.addBindResultResponseData != null)
- {
- break;
- }
- }
- else
+ await System.Threading.Tasks.Task.Delay(10);
+ if (result != null)
{
break;
}
}
if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
{
- result.errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔";
+ result = new AddedDeviceBindResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
+ }
+ //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 && obj.Result == 1).Count)
+ //{
+ // if (result.addBindResultResponseData != null)
+ // {
+ // break;
+ // }
+ //}
+ //else if (0 < result.addedDeviceBindResponseData.BindList.FindAll((obj) => obj.BindType == 0 && obj.Result == 2).Count)
+ //{
+ // if (result.addBindResultResponseData != null)
+ // {
+ // break;
+ // }
+ //}
+ //else if (0 < result.addedDeviceBindResponseData.BindList.FindAll((obj) => obj.BindType == 0 && obj.Result == 3).Count)
+ //{
+ // if (result.addBindResultResponseData != null)
+ // {
+ // break;
+ // }
+ //}
+ //else
+ //{
+ // break;
+ //}
+ //}
+ if ((DateTime.Now - dateTime).TotalMilliseconds > 20 * 1000)
+ {
+ result = new AddedDeviceBindResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
}
mainGateway.Actions -= action;
System.Console.WriteLine($"Bind/SetBind_Actions 閫�鍑� { System.DateTime.Now.ToLongTimeString() + " " + System.DateTime.Now.Millisecond}");
@@ -203,7 +215,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>
@@ -637,7 +654,7 @@
/// 0锛氱Щ闄ゆ垚鍔燂紙璇ョ姸鎬佸彧閫傜敤鐢ㄤ簬璺ㄧ綉鍏崇粦瀹氥�佺粦瀹氬満鏅�佸け鏁堣澶囷紙璁惧宸茬粡浠庣綉鍏崇殑璁惧鍒楄〃涓垹闄わ級銆傚悓缃戝叧璁惧闂寸殑瑙i櫎缁戝畾闇�瑕佽妭鐐硅澶囩殑纭鎴愬姛淇℃伅锛屼笉浼氱洿鎺ュ弽棣堟垚鍔熴�傦級
///<para>1锛氬け璐ワ紝璁惧涓嶅湪缁戝畾鍒楄〃涓�</para>
///<para>3锛氬け璐ワ紝鍦ㄧ瓑寰呰妭鐐硅澶囩‘璁ゆ槸鍚﹁В闄ょ粦瀹氭垚鍔燂紙褰撶綉鍏宠繕鍦ㄧ瓑寰呮煇鑺傜偣璁惧纭鏄惁瑙i櫎缁戝畾鎴愬姛鐨勫弽棣堜俊鎭椂锛屽鎴风鍐嶆鍙戦�佽В闄ょ粦瀹氳鑺傜偣璁惧鐨勬寚浠わ紝灏嗗弽棣堣鐘舵�併�傦級</para>
- ///<para>4锛氭湭鐭ワ紝鐢辫妭鐐硅澶囧弽棣堝彂閫佲�淏ind/RemoveBindResult鈥濅富棰樻秷鎭‘瀹氭槸鍚︽垚鍔熴��</para>
+ ///<para>2锛氭湭鐭ワ紝鐢辫妭鐐硅澶囧弽棣堝彂閫佲�淏ind/RemoveBindResult鈥濅富棰樻秷鎭‘瀹氭槸鍚︽垚鍔熴��</para>
/// </summary>
public int Result;
@@ -1115,7 +1132,7 @@
catch { }
var dateTime = DateTime.Now;
- while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime)
+ while ((DateTime.Now - dateTime).TotalMilliseconds < 25 * 1000)
{
await System.Threading.Tasks.Task.Delay(10);
if (d != null)
@@ -1123,8 +1140,8 @@
break;
}
}
- //涓�閿竻闄ょ洰鏍囷紝浼氬洜涓虹洰鏍囨暟閲忓鑰屽姞闀挎椂闂达紝鐩墠鏆傚畾10绉�
- if ((DateTime.Now - dateTime).TotalMilliseconds > 10 * 1000)
+ //涓�閿竻闄ょ洰鏍囷紝浼氬洜涓虹洰鏍囨暟閲忓鑰屽姞闀挎椂闂达紝鐩墠鏆傚畾20绉�
+ if ((DateTime.Now - dateTime).TotalMilliseconds > 25 * 1000)
{
d = new ClearBindInfoResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
}
--
Gitblit v1.8.0