From 4f0ab0ad21ce450b7856d50f98322a7899361386 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期二, 22 九月 2020 10:30:01 +0800
Subject: [PATCH] 不要下载这个备份
---
ZigbeeApp/Shared/Phone/ZigBee/Device/BindObj.cs | 800 ++++++++++++++-------------------------------------------
1 files changed, 198 insertions(+), 602 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/BindObj.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/BindObj.cs
index 562405e..10053b4 100755
--- a/ZigbeeApp/Shared/Phone/ZigBee/Device/BindObj.cs
+++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/BindObj.cs
@@ -8,112 +8,6 @@
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 () =>
- {
- AddedDeviceBindResponseAllData result = null;
- var mainGateway = ZbGateway.MainGateWay;
- if (mainGateway == null)
- {
- result = new AddedDeviceBindResponseAllData { 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 temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.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 tempResult = Newtonsoft.Json.JsonConvert.DeserializeObject<AddedDeviceBindResponseData>(jobject["Data"].ToString());
- if (tempResult == null)
- {
- result = new AddedDeviceBindResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
- }
- else
- {
- result = new AddedDeviceBindResponseAllData { addedDeviceBindResponseData = tempResult };
- DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{topic}");
- }
- }
- };
- mainGateway.Actions += action;
- DebugPrintLog("Bind/SetBind_Actions 鍚姩" + "_" + System.DateTime.Now.ToLongTimeString() + " " + System.DateTime.Now.Millisecond);
- 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);
- mainGateway.Send("Bind/SetBind", jObject.ToString());
- }
- }
- catch
- {
- }
-
- var dateTime = DateTime.Now;
- while ((DateTime.Now - dateTime).TotalMilliseconds < 20 * 1000)
- {
- await System.Threading.Tasks.Task.Delay(10);
- if (result != null)
- {
- 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}");
- return result;
- });
- }
[System.Serializable]
public class AddedDeviceBindResponseAllData : ErrorResponCommon
@@ -122,10 +16,15 @@
/// 缃戝叧鐩存帴鍙嶉缁戝畾璁惧淇℃伅
/// </summary>
public AddedDeviceBindResponseData addedDeviceBindResponseData;
+ }
+
+ [System.Serializable]
+ public class AddedDeviceSingleBindResponseAllData : ErrorResponCommon
+ {
/// <summary>
- /// 鎸夐敭璁惧鐨勭‘璁ゅ弽棣堢粦瀹氳澶囦俊鎭�
+ /// 缃戝叧鐩存帴鍙嶉缁戝畾璁惧淇℃伅
/// </summary>
- public AddBindResultResponseData addBindResultResponseData;
+ public AddedDeviceSingleBindResponseData addedDeviceSingleBindResponseData;
}
[System.Serializable]
@@ -145,6 +44,56 @@
/// </summary>
public int Result = -1;
}
+
+ [System.Serializable]
+ public class AddedDeviceSingleBindResponseData
+ {
+ /// <summary>
+ /// 鎺у埗璁惧鑺傜偣鐨刴ac鍦板潃
+ /// </summary>
+ public string DeviceAddr;
+ /// <summary>
+ /// 鎺у埗璁惧鑺傜偣鐨勭鍙e彿
+ /// </summary>
+ public int Epoint;
+ /// <summary>
+ ///缁戝畾鍚嶇О
+ /// </summary>
+ public string BindName;
+ /// <summary>
+ /// 0锛氭垚鍔燂紝閽堝鍦烘櫙鍜岃法缃戝叧缁戝畾
+ ///<para>1锛氬け璐ワ紝鑺傜偣璁惧鎴栧満鏅笉瀛樺湪銆�</para>
+ ///<para>2锛氬悓缃戝叧璁惧缁戝畾锛岀瓑寰呮帶鍒舵簮璁惧鍐欏叆鍙嶉缁撴灉锛涗互涓嬮潰涓婚缁撴灉涓哄噯</para>
+ /// </summary>
+ public int Result = -1;
+ /// <summary>
+ /// 缁戝畾绫诲瀷
+ ///<para>0锛氱粦瀹氳澶� </para>
+ ///<para>1锛氱粦瀹氬満鏅�</para>
+ /// </summary>
+ public int BindType;
+ /// <summary>
+ ///缁戝畾鐨刢luster鏁扮粍
+ /// </summary>
+ public List<int> BindClusterList = new List<int>();
+ /// <summary>
+ /// 缁戝畾璁惧Mac鍦板潃锛� 褰揃indType=0鏃跺瓨鍦�
+ /// </summary>
+ public string BindMacAddr;
+ /// <summary>
+ /// 缁戝畾璁惧鐨勭鍙e彿锛屽綋BindType=0鏃跺瓨鍦�
+ /// </summary>
+ public int BindEpoint;
+ /// <summary>
+ /// 缁戝畾鍦烘櫙锛屽綋BindType=2鏃跺瓨鍦�
+ /// </summary>
+ public int BindScenesId;
+ /// <summary>
+ ///缁戝畾鐨勮澶囨垨鍦烘櫙鐨勫悕绉�
+ /// </summary>
+ public string ESName;
+ }
+
/// <summary>
/// 缁戝畾鍒楄〃鐨勪俊鎭�
@@ -250,269 +199,53 @@
/// </summary>
public int BindScenesId;
}
+
+ /// <summary>
+ /// 鍗曚釜璁惧鐨勬暟鎹�
+ /// </summary>
+ [System.Serializable]
+ public class AddSingleBindData
+ {
+ /// <summary>
+ /// 鎺у埗璁惧鑺傜偣鐨刴ac鍦板潃
+ /// </summary>
+ public string DeviceAddr;
+ /// <summary>
+ /// 閿欒淇℃伅
+ /// </summary>
+ public int Epoint;
+ /// <summary>
+ ///缁戝畾鍚嶇О锛屼笉淇敼鍚嶇О鏃跺拷鐣ヨ閫夐」
+ /// </summary>
+ public string BindName;
+ /// <summary>
+ /// 缁戝畾绫诲瀷
+ ///<para>0锛氱粦瀹氳澶� </para>
+ ///<para>1锛氱粦瀹氬満鏅�</para>
+ /// </summary>
+ public int BindType;
+ /// <summary>
+ ///缁戝畾鐨刢lusters鏁扮粍锛岄渶瑕佹帶鍒惰澶囩殑OutCluster鍒楄〃涓瓨鍦ㄨcluster銆傚缁戝畾鏌愪釜璁惧鐨刼n/off锛屼负6銆傚缁戝畾鍦烘櫙锛屽~鏃廔d涓�6
+ /// </summary>
+ public List<int> BindClusterList = new List<int>();
+ /// <summary>
+ /// 缁戝畾璁惧Mac鍦板潃锛� 褰揃indType=0鏃跺瓨鍦�
+ /// </summary>
+ public string BindMacAddr;
+ /// <summary>
+ /// 缁戝畾璁惧鐨勭鍙e彿锛屽綋BindType=0鏃跺瓨鍦�
+ /// </summary>
+ public int BindEpoint;
+ /// <summary>
+ /// 缁戝畾鍦烘櫙锛屽綋BindType=1鏃跺瓨鍦�
+ /// </summary>
+ public int BindScenesId;
+
+ }
+
#endregion
#region 瑙i櫎缁戝畾
- /// <summary>
- /// 瑙i櫎缁戝畾
- /// </summary>
- //public async System.Threading.Tasks.Task<DelDeviceBindResponseAllData> DelDeviceBindAsync(DelDeviceBindData delDeviceBindData)
- //{
- // return await System.Threading.Tasks.Task.Run(async () =>
- // {
- // DelDeviceBindResponseAllData responseData = null;
- // var mainGateway = ZbGateway.MainGateWay;
- // if (mainGateway == null)
- // {
- // responseData = new DelDeviceBindResponseAllData { errorMessageBase = "褰撳墠娌℃湁涓荤綉鍏�" };
- // }
-
- // 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 temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString());
-
- // if (temp == null)
- // {
- // responseData = new DelDeviceBindResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
- // }
- // else
- // {
- // responseData = new DelDeviceBindResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
- // }
- // }
- // //鍦烘櫙绉婚櫎
- // if (topic == gatewayID + "/" + "Bind/RemoveBind_Respon")
- // {
- // var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<DelDeviceBindResponseData>(jobject["Data"].ToString());
-
- // if (tempData == null)
- // {
- // responseData = new DelDeviceBindResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
- // }
- // else
- // {
- // responseData = new DelDeviceBindResponseAllData { delDeviceBindResponseData = tempData };
- // System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
- // }
- // }
- // //璁惧绉婚櫎
- // if (topic == gatewayID + "/" + "Bind/RemoveBindResult")
- // {
- // var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<RemoveBindResultResponseData>(jobject["Data"].ToString());
-
- // if (tempData != null)
- // {
- // responseData = new DelDeviceBindResponseAllData { 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);
- // mainGateway.Send("Bind/RemoveBind", jObject.ToString());
- // }
- // }
- // catch { }
-
- // var dateTime = DateTime.Now;
- // while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime)
- // {
- // await System.Threading.Tasks.Task.Delay(10);
- // if (responseData != null)
- // {
- // break;
- // }
- // }
- // if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
- // {
- // responseData = new DelDeviceBindResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
- // }
- // mainGateway.Actions -= action;
- // System.Console.WriteLine("DeviceBind/DelBind_Actions 閫�鍑�" + System.DateTime.Now.ToString());
- // return responseData;
- // });
- //}
-
- //涔嬪墠2绉嶆柟寮忓弽棣堢粨鏋�
- 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 temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.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 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 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 && obj.Result == 1).Count)
- {
- if (responseData.removeBindResultResponseData != null)
- {
- break;
- }
- }
- else if (0 < responseData.delDeviceBindResponseData.RemoveBindList.FindAll((obj) => obj.BindType == 0 && obj.Result == 3).Count)
- {
- if (responseData.removeBindResultResponseData != null)
- {
- break;
- }
- }
- else if (0 < responseData.delDeviceBindResponseData.RemoveBindList.FindAll((obj) => obj.BindType == 0 && obj.Result == 2).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櫎缁戝畾鏁版嵁,缃戝叧鍙嶉淇℃伅
@@ -644,84 +377,6 @@
#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 temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.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 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>
///鑾峰彇鎵�鏈夌粦瀹氭暟鎹�,缃戝叧鍙嶉淇℃伅
@@ -759,9 +414,47 @@
{
/// <summary>
/// 缁戝畾绫诲瀷
- ///<para>0锛氱Щ闄よ澶囷紝鍚岀綉鍏宠澶囬棿鐨勭Щ闄�</para>
- ///<para>1锛氱Щ闄よ澶囷紝璺ㄧ綉鍏宠澶囬棿鐨勭Щ闄�</para>
- ///<para>2锛氱Щ闄ょ粦瀹氬満鏅�</para>
+ ///<para>0锛氬悓缃戝叧璁惧</para>
+ ///<para>1锛氳法缃戝叧璁惧闂�</para>
+ ///<para>2锛氬満鏅�</para>
+ /// </summary>
+ public int BindType;
+ /// <summary>
+ /// 缁戝畾鐨刢luster
+ /// </summary>
+ public int BindCluster;
+ /// <summary>
+ /// 缁戝畾璁惧Mac鍦板潃锛� 褰揃indType=0鏃跺瓨鍦�
+ /// </summary>
+ public string BindMacAddr;
+ /// <summary>
+ /// 缁戝畾璁惧鐨勭鍙e彿锛屽綋BindType=0鏃跺瓨鍦�
+ /// </summary>
+ public int BindEpoint;
+ /// <summary>
+ /// 缁戝畾鍦烘櫙锛屽綋BindType=1鏃跺瓨鍦�
+ /// </summary>
+ public int BindScenesId;
+ }
+
+ /// <summary>
+ /// 鑾峰彇鎵�鏈夌粦瀹氱殑淇℃伅
+ /// </summary>
+ public class BindListAllInfo
+ {
+ /// <summary>
+ /// 鎺у埗婧愯澶嘙ac鍦板潃
+ /// </summary>
+ public string KeyMacAddr;
+ /// <summary>
+ /// 鎺у埗婧愯澶囩殑绔彛鍙�
+ /// </summary>
+ public int KeyEpoint;
+ /// <summary>
+ /// 缁戝畾绫诲瀷
+ ///<para>0锛氬悓缃戝叧璁惧</para>
+ ///<para>1锛氳法缃戝叧璁惧闂�</para>
+ ///<para>2锛氬満鏅�</para>
/// </summary>
public int BindType;
/// <summary>
@@ -785,87 +478,65 @@
/// </summary>
public string ESName;
}
+
+ /// <summary>
+ /// 鑾峰彇闈㈡澘缁戝畾鍥炲鐨勬暟鎹�愰�氳繃mac鑾峰彇鐨勫洖澶峕
+ /// </summary>
+ [System.Serializable]
+ public class GetPanelBindResponseDataByMac
+ {
+ /// <summary>
+ /// 0锛氭垚鍔�
+ ///<para>1锛氱粦瀹氫笉瀛樺湪</para>
+ /// </summary>
+ public int Result;
+ /// <summary>
+ /// MaxNumItems
+ /// </summary>
+ public int MaxNumItems;
+ /// <summary>
+ /// StartIndex
+ /// </summary>
+ public int StartIndex;
+ /// <summary>
+ /// ReturnBindNum
+ /// </summary>
+ public int ReturnBindNum;
+ /// <summary>
+ /// 缁戝畾鍒楄〃 锛屽綋Status=0鏃跺瓨鍦ㄣ��
+ /// </summary>
+ public List<BindDeviceByMacObj> BindList = new List<BindDeviceByMacObj>();
+ }
+
+ /// <summary>
+ /// 鑾峰彇闈㈡澘缁戝畾鍥炲鐨勬暟鎹�愰�氳繃mac鑾峰彇鐨勫洖澶峕
+ /// </summary>
+ public class BindDeviceByMacObj
+ {
+ /// <summary>
+ /// ControllerEpoint
+ /// </summary>
+ public int ControllerEpoint;
+ /// <summary>
+ /// 缁戝畾鐨刢luster
+ /// </summary>
+ public int BindCluster;
+ /// <summary>
+ /// 缁戝畾璁惧Mac鍦板潃锛� 褰揃indType=0鏃跺瓨鍦�
+ /// </summary>
+ public string BindMacAddr;
+ /// <summary>
+ /// 缁戝畾璁惧鐨勭鍙e彿锛屽綋BindType=0鏃跺瓨鍦�
+ /// </summary>
+ public int BindEpoint;
+ /// <summary>
+ /// BindMode
+ /// </summary>
+ public int BindMode;
+ }
#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 temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.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 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>
///浠庤妭鐐硅澶囨湰鍦拌褰曡鍙栫粦瀹氬垪琛ㄤ俊鎭洖澶嶇殑鏁版嵁,缃戝叧鍙嶉淇℃伅
@@ -943,81 +614,6 @@
#endregion
#region 鍒犻櫎涓�涓帶鍒惰澶囨墍鏈夌粦瀹氫俊鎭�
- /// <summary>
- ///鍒犻櫎涓�涓帶鍒惰澶囨墍鏈夌粦瀹氫俊鎭�
- /// </summary>
- public async System.Threading.Tasks.Task<ClearBindInfoResponseAllData> ClearBindInfoAsync()
- {
- if (Gateway == null)
- {
- return null;
- }
- return await System.Threading.Tasks.Task.Run(async () =>
- {
- ClearBindInfoResponseAllData d = null;
- 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 temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString());
-
- if (temp == null)
- {
- d = new ClearBindInfoResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
- }
- else
- {
- d = new ClearBindInfoResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
- }
- }
-
- if (topic == gatewayID + "/" + "Bind/ClearBindInfo_Respon")
- {
- var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClearBindInfoResponseData>(jobject["Data"].ToString());
- if (tempData == null)
- {
- d = new ClearBindInfoResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
- }
- else
- {
- d = new ClearBindInfoResponseAllData { clearBindInfoResponseData = tempData };
- System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
- }
- }
- };
- Gateway.Actions += action;
- DebugPrintLog("Bind/ClearBindInfo_Actions 鍚姩" + "_" + System.DateTime.Now.ToString());
-
- try
- {
- var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 0 }, { "Command", 5006 } };
- Gateway.Send("Bind/ClearBindInfo", jObject.ToString());
- }
- catch { }
-
- var dateTime = DateTime.Now;
- while ((DateTime.Now - dateTime).TotalMilliseconds < 25 * 1000)
- {
- await System.Threading.Tasks.Task.Delay(10);
- if (d != null)
- {
- break;
- }
- }
- //涓�閿竻闄ょ洰鏍囷紝浼氬洜涓虹洰鏍囨暟閲忓鑰屽姞闀挎椂闂达紝鐩墠鏆傚畾20绉�
- if ((DateTime.Now - dateTime).TotalMilliseconds > 25 * 1000)
- {
- d = new ClearBindInfoResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
- }
- Gateway.Actions -= action;
- DebugPrintLog("Bind/ClearBindInfo_Actions 閫�鍑�" + System.DateTime.Now.ToString());
-
- return d;
- });
- }
/// <summary>
///鍒犻櫎涓�涓帶鍒惰澶囨墍鏈夌粦瀹氭暟鎹�,缃戝叧鍙嶉淇℃伅
--
Gitblit v1.8.0