From 627093aca723d4bfb971b97c828e8b3a22dbda78 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期五, 17 七月 2020 17:26:19 +0800
Subject: [PATCH] 2020-07-17-1
---
ZigbeeApp/Shared/Phone/ZigBee/Device/BindObj.cs | 554 ++++---------------------------------------------------
1 files changed, 43 insertions(+), 511 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/BindObj.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/BindObj.cs
index 1116805..5b956bf 100755
--- a/ZigbeeApp/Shared/Phone/ZigBee/Device/BindObj.cs
+++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/BindObj.cs
@@ -5,180 +5,19 @@
namespace ZigBee.Device
{
[System.Serializable]
- public class BindObj :CommonDevice
+ public class BindObj : CommonDevice
{
#region 璁惧缁戝畾
- /// <summary>
- ///璁惧缁戝畾
- /// </summary>
- public async System.Threading.Tasks.Task<AddedDeviceBindResponseAllData> AddDeviceBindAsync(AddBindData addBindData)
- {
- return await System.Threading.Tasks.Task.Run(async () =>
- {
- var result = new AddedDeviceBindResponseAllData();
- var mainGateway = ZbGateway.MainGateWay;
- if (mainGateway == null)
- {
- result.errorMessageBase = "褰撳墠娌℃湁涓荤綉鍏�";
- return result;
- }
- 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 = ZbGateway.MainGateWay.getGatewayBaseInfo.gwID };
- var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString());
-
- if (temp == null)
- {
- result.errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖";
- }
- else
- {
- result.errorResponData = temp;
- result.errorMessageBase = ErrorMess(temp.Error);
- }
- }
- 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)
- {
- result.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;
- }
- }
- };
- mainGateway.Actions += action;
- DebugPrintLog("Bind/SetBind_Actions 鍚姩" + "_" + System.DateTime.Now.ToString());
- try
- {
- if (addBindData != null)
- {
- 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);
- //ZbGateway.MainGateWay.CurrentGateWayId = ZbGateway.MainGateWay.getGatewayBaseInfo?.gwID;
- mainGateway.Send("Bind/SetBind", jObject.ToString());
- }
- }
- catch
- {
- }
-
- var dateTime = DateTime.Now;
- while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime)
- {
- 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
- {
- break;
- }
- }
- if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
- {
- result.errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔";
- }
- mainGateway.Actions -= action;
- System.Console.WriteLine($"Bind/SetBind_Actions 閫�鍑� {System.DateTime.Now}");
- return result;
- });
- }
-
- /// <summary>
- /// 缁戝畾璁惧淇℃伅,缃戝叧鍙嶉淇℃伅
- /// </summary>
- public AddedDeviceBindResponseAllData addedDeviceBindResponseAllData;
[System.Serializable]
- public class AddedDeviceBindResponseAllData
+ public class AddedDeviceBindResponseAllData : ErrorResponCommon
{
- /// <summary>
- /// 閿欒淇℃伅
- /// </summary>
- public string errorMessageBase;
- /// <summary>
- /// 缃戝叧淇℃伅閿欒鍙嶉
- /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para>
- /// </summary>
- public ErrorResponData errorResponData;
/// <summary>
/// 缃戝叧鐩存帴鍙嶉缁戝畾璁惧淇℃伅
/// </summary>
public AddedDeviceBindResponseData addedDeviceBindResponseData;
- /// <summary>
- /// 鎸夐敭璁惧鐨勭‘璁ゅ弽棣堢粦瀹氳澶囦俊鎭�
- /// </summary>
- public AddBindResultResponseData addBindResultResponseData;
}
- /// <summary>
- /// 缁戝畾璁惧淇℃伅
- /// </summary>
- public AddedDeviceBindResponseData addedDeviceBindResponseData;
[System.Serializable]
public class AddedDeviceBindResponseData
{
@@ -189,7 +28,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>
@@ -245,7 +89,6 @@
/// <summary>
/// 缁戝畾璁惧鐨勬暟鎹�
/// </summary>
- public AddBindData addBindData;
[System.Serializable]
public class AddBindData
{
@@ -300,163 +143,13 @@
#endregion
#region 瑙i櫎缁戝畾
- /// <summary>
- /// 瑙i櫎缁戝畾
- /// </summary>
- public async System.Threading.Tasks.Task<DelDeviceBindResponseAllData> DelDeviceBindAsync(DelDeviceBindData delDeviceBindData)
- {
- return await System.Threading.Tasks.Task.Run(async () =>
- {
- var responseData = new DelDeviceBindResponseAllData();
- var mainGateway = ZbGateway.MainGateWay;
- if (mainGateway == null)
- {
- responseData.errorMessageBase = "褰撳墠娌℃湁涓荤綉鍏�";
- return responseData;
- }
-
- 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.errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖";
- }
- else
- {
- responseData.errorResponData = temp;
- responseData.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.errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�";
-
- }
- else
- {
- responseData.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.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);
- //ZbGateway.MainGateWay.CurrentGateWayId = ZbGateway.MainGateWay.getGatewayBaseInfo?.gwID;
- mainGateway.Send("Bind/RemoveBind", jObject.ToString());
- }
- }
- catch { }
-
-
- var dateTime = DateTime.Now;
- while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime)
- {
- await System.Threading.Tasks.Task.Delay(100);
- if (responseData == null || responseData.delDeviceBindResponseData == null)
- {
- continue;
- }
- if (0 < responseData.delDeviceBindResponseData.RemoveBindList.FindAll((obj) => obj.BindType == 0).Count)
- {
- if (responseData.removeBindResultResponseData != null)
- {
- break;
- }
- }
- else
- {
- break;
- }
- }
-
- if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
- {
- responseData.errorMessageBase = "鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔";
- }
- mainGateway.Actions -= action;
- System.Console.WriteLine("DeviceBind/DelBind_Actions 閫�鍑�" + System.DateTime.Now.ToString());
-
- return responseData;
- });
- }
-
- /// <summary>
- ///瑙i櫎缁戝畾鏁版嵁,缃戝叧鍙嶉淇℃伅
- /// </summary>
- public DelDeviceBindResponseAllData delDeviceBindResponseAllData;
+
/// <summary>
///瑙i櫎缁戝畾鏁版嵁,缃戝叧鍙嶉淇℃伅
/// </summary>
[System.Serializable]
- public class DelDeviceBindResponseAllData
+ public class DelDeviceBindResponseAllData : ErrorResponCommon
{
- /// <summary>
- /// 閿欒淇℃伅
- /// </summary>
- public string errorMessageBase;
- /// <summary>
- /// 缃戝叧淇℃伅閿欒鍙嶉
- /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para>
- /// </summary>
- public ErrorResponData errorResponData;
/// <summary>
/// 瑙i櫎缁戝畾鏁版嵁淇℃伅
/// </summary>
@@ -468,10 +161,6 @@
public RemoveBindResultResponseData removeBindResultResponseData;
}
- /// <summary>
- /// 瑙i櫎缁戝畾鏁版嵁
- /// </summary>
- public DelDeviceBindResponseData delDeviceBindResponseData;
/// <summary>
/// 瑙i櫎缁戝畾鏁版嵁
/// </summary>
@@ -494,7 +183,7 @@
/// 0锛氱Щ闄ゆ垚鍔燂紙璇ョ姸鎬佸彧閫傜敤鐢ㄤ簬璺ㄧ綉鍏崇粦瀹氥�佺粦瀹氬満鏅�佸け鏁堣澶囷紙璁惧宸茬粡浠庣綉鍏崇殑璁惧鍒楄〃涓垹闄わ級銆傚悓缃戝叧璁惧闂寸殑瑙i櫎缁戝畾闇�瑕佽妭鐐硅澶囩殑纭鎴愬姛淇℃伅锛屼笉浼氱洿鎺ュ弽棣堟垚鍔熴�傦級
///<para>1锛氬け璐ワ紝璁惧涓嶅湪缁戝畾鍒楄〃涓�</para>
///<para>3锛氬け璐ワ紝鍦ㄧ瓑寰呰妭鐐硅澶囩‘璁ゆ槸鍚﹁В闄ょ粦瀹氭垚鍔燂紙褰撶綉鍏宠繕鍦ㄧ瓑寰呮煇鑺傜偣璁惧纭鏄惁瑙i櫎缁戝畾鎴愬姛鐨勫弽棣堜俊鎭椂锛屽鎴风鍐嶆鍙戦�佽В闄ょ粦瀹氳鑺傜偣璁惧鐨勬寚浠わ紝灏嗗弽棣堣鐘舵�併�傦級</para>
- ///<para>4锛氭湭鐭ワ紝鐢辫妭鐐硅澶囧弽棣堝彂閫佲�淏ind/RemoveBindResult鈥濅富棰樻秷鎭‘瀹氭槸鍚︽垚鍔熴��</para>
+ ///<para>2锛氭湭鐭ワ紝鐢辫妭鐐硅澶囧弽棣堝彂閫佲�淏ind/RemoveBindResult鈥濅富棰樻秷鎭‘瀹氭槸鍚︽垚鍔熴��</para>
/// </summary>
public int Result;
@@ -532,10 +221,6 @@
public string DeviceName;
}
- /// <summary>
- /// 瑙i櫎缁戝畾鏁版嵁
- /// </summary>
- public DelDeviceBindData delDeviceBindData;
/// <summary>
/// 瑙i櫎缁戝畾鏁版嵁
/// </summary>
@@ -589,103 +274,13 @@
#endregion
#region 锛堜粠缃戝叧涓級鑾峰彇鎵�鏈夌粦瀹�
- /// <summary>
- ///鑾峰彇鎵�鏈夌粦瀹�
- /// </summary>
- public async System.Threading.Tasks.Task<GetDeviceBindResponseAllData> GetDeviceBindAsync()
- {
- return await System.Threading.Tasks.Task.Run(async () =>
- {
- GetDeviceBindResponseAllData d = null;
- var mainGateway = ZbGateway.MainGateWay;
- if (mainGateway == null)
- {
- d = new GetDeviceBindResponseAllData { errorMessageBase = "褰撳墠娌℃湁涓荤綉鍏�" };
- return d;
- }
-
- 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)
- {
- d = new GetDeviceBindResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
- }
- else
- {
- d = new GetDeviceBindResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
- }
- }
-
- if (topic == gatewayID + "/" + "Bind/GetDeviceBind_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<GetDeviceBindResponseData>(jobject["Data"].ToString());
- //var tempBindList = Newtonsoft.Json.Linq.JArray.Parse(jobject["Data"]["BindList"].ToString());
- if (tempData == null)
- {
- d = new GetDeviceBindResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
- }
- else
- {
- d = new GetDeviceBindResponseAllData { getAllBindResponseData = tempData };
- System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
- }
- }
- };
- mainGateway.Actions += action;
-
- try
- {
- System.Console.WriteLine("Bind/GetDeviceBind_Actions 鍚姩" + "_" + System.DateTime.Now.ToString());
- var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 0 }, { "Command", 5007 } };
- mainGateway.Send("Bind/GetDeviceBind", jObject.ToString());
- }
- catch { }
-
- var dateTime = DateTime.Now;
- while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime)
- {
- await System.Threading.Tasks.Task.Delay(10);
- if (d != null)
- {
- break;
- }
- }
- if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
- {
- d = new GetDeviceBindResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
- }
- mainGateway.Actions -= action;
- System.Console.WriteLine("Bind/GetDeviceBind_Actions 閫�鍑�" + System.DateTime.Now.ToString());
-
- return d;
- });
- }
/// <summary>
///鑾峰彇鎵�鏈夌粦瀹氭暟鎹�,缃戝叧鍙嶉淇℃伅
/// </summary>
- public GetDeviceBindResponseAllData getAllBindResponseAllData;
[System.Serializable]
- public class GetDeviceBindResponseAllData
+ public class GetDeviceBindResponseAllData : ErrorResponCommon
{
- /// <summary>
- /// 閿欒淇℃伅
- /// </summary>
- public string errorMessageBase;
- /// <summary>
- /// 缃戝叧淇℃伅閿欒鍙嶉
- /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para>
- /// </summary>
- public ErrorResponData errorResponData;
/// <summary>
/// 鎺у埗璁惧缁戝畾鐨勮澶囧垪琛ㄥ洖澶嶆暟鎹�
/// </summary>
@@ -695,7 +290,6 @@
/// <summary>
/// 鑾峰彇鎵�鏈夌粦瀹氬洖澶嶇殑鏁版嵁
/// </summary>
- public GetDeviceBindResponseData getAllBindResponseData;
[System.Serializable]
public class GetDeviceBindResponseData
{
@@ -746,103 +340,13 @@
#endregion
#region 浠庤妭鐐硅澶囨湰鍦拌褰曡鍙栫粦瀹氬垪琛ㄤ俊鎭�
- /// <summary>
- ///浠庤妭鐐硅澶囨湰鍦拌褰曡鍙栫粦瀹氬垪琛ㄤ俊鎭�
- /// </summary>
- public async System.Threading.Tasks.Task<GetDeviceLocalBindResponseAllData> GetDeviceLocalBindAsync(int startIndex=0)
- {
- return await System.Threading.Tasks.Task.Run(async () =>
- {
- GetDeviceLocalBindResponseAllData d = null;
- var mainGateway = ZbGateway.MainGateWay;
- if (mainGateway == null)
- {
- d = new GetDeviceLocalBindResponseAllData { errorMessageBase = "褰撳墠娌℃湁涓荤綉鍏�" };
- return d;
- }
-
- 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)
- {
- d = new GetDeviceLocalBindResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
- }
- else
- {
- d = new GetDeviceLocalBindResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
- }
- }
-
- 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)
- {
- d = new GetDeviceLocalBindResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
- }
- else
- {
- d = new GetDeviceLocalBindResponseAllData { getDeviceLocalBindResponseData = tempData };
- DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
- }
- }
- };
- mainGateway.Actions += action;
-
- 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 } };
- mainGateway.Send("Bind/GetDeviceLocalBind", jObject.ToString());
- }
- catch { }
-
- var dateTime = DateTime.Now;
- while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime)
- {
- await System.Threading.Tasks.Task.Delay(10);
- if (d != null)
- {
- break;
- }
- }
- if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
- {
- d = new GetDeviceLocalBindResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
- }
- mainGateway.Actions -= action;
- DebugPrintLog("Bind/GetDeviceLocalBind_Actions 閫�鍑�" + System.DateTime.Now.ToString());
-
- return d;
- });
- }
/// <summary>
///浠庤妭鐐硅澶囨湰鍦拌褰曡鍙栫粦瀹氬垪琛ㄤ俊鎭洖澶嶇殑鏁版嵁,缃戝叧鍙嶉淇℃伅
/// </summary>
- public GetDeviceLocalBindResponseAllData getDeviceLocalBindResponseAllData;
[System.Serializable]
- public class GetDeviceLocalBindResponseAllData
+ public class GetDeviceLocalBindResponseAllData : ErrorResponCommon
{
- /// <summary>
- /// 閿欒淇℃伅
- /// </summary>
- public string errorMessageBase;
- /// <summary>
- /// 缃戝叧淇℃伅閿欒鍙嶉
- /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para>
- /// </summary>
- public ErrorResponData errorResponData;
/// <summary>
/// 浠庤妭鐐硅澶囨湰鍦拌褰曡鍙栫粦瀹氬垪琛ㄤ俊鎭洖澶嶇殑鏁版嵁
/// </summary>
@@ -852,7 +356,6 @@
/// <summary>
/// 浠庤妭鐐硅澶囨湰鍦拌褰曡鍙栫粦瀹氬垪琛ㄤ俊鎭洖澶嶇殑鏁版嵁
/// </summary>
- public GetDeviceLocalBindResponseData getDeviceLocalBindResponseData;
[System.Serializable]
public class GetDeviceLocalBindResponseData
{
@@ -872,7 +375,7 @@
/// <summary>
/// 璇ユ璇诲彇杩斿洖缁戝畾鍒楄〃涓暟
/// </summary>
- public int ReturnBindNum;
+ public int ReturnBindNum;
/// <summary>
/// 缁戝畾鍒楄〃锛屽綋Result=0鏃跺瓨鍦�
/// </summary>
@@ -912,5 +415,34 @@
public int BindEpoint;
}
#endregion
+
+ #region 鍒犻櫎涓�涓帶鍒惰澶囨墍鏈夌粦瀹氫俊鎭�
+
+ /// <summary>
+ ///鍒犻櫎涓�涓帶鍒惰澶囨墍鏈夌粦瀹氭暟鎹�,缃戝叧鍙嶉淇℃伅
+ /// </summary>
+ [System.Serializable]
+ public class ClearBindInfoResponseAllData : ErrorResponCommon
+ {
+ /// <summary>
+ /// 鎺у埗璁惧缁戝畾鐨勮澶囧垪琛ㄥ洖澶嶆暟鎹�
+ /// </summary>
+ public ClearBindInfoResponseData clearBindInfoResponseData;
+ }
+
+ /// <summary>
+ /// 鍒犻櫎涓�涓帶鍒惰澶囨墍鏈夌粦瀹氫俊鎭洖澶嶇殑鏁版嵁
+ /// </summary>
+ [System.Serializable]
+ public class ClearBindInfoResponseData
+ {
+ /// <summary>
+ /// 0锛氭垚鍔�
+ ///<para>1锛氱粦瀹氫俊鎭笉瀛樺湪</para>
+ /// </summary>
+ public int Result;
+ }
+
+ #endregion
}
}
--
Gitblit v1.8.0