| | |
| | | /// </summary> |
| | | public int BindEpoint; |
| | | } |
| | | #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 gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID }; |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.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 gatewayTemp = new ZbGateway() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID }; |
| | | 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 < WaitReceiveDataTime) |
| | | { |
| | | await System.Threading.Tasks.Task.Delay(10); |
| | | if (d != null) |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) |
| | | { |
| | | d = new ClearBindInfoResponseAllData { errorMessageBase = " 回复超时,请重新操作" }; |
| | | } |
| | | Gateway.Actions -= action; |
| | | DebugPrintLog("Bind/ClearBindInfo_Actions 退出" + System.DateTime.Now.ToString()); |
| | | |
| | | return d; |
| | | }); |
| | | } |
| | | |
| | | /// <summary> |
| | | ///删除一个控制设备所有绑定数据,网关反馈信息 |
| | | /// </summary> |
| | | public ClearBindInfoResponseAllData clearBindInfoResponseAllData; |
| | | [System.Serializable] |
| | | public class ClearBindInfoResponseAllData |
| | | { |
| | | /// <summary> |
| | | /// 错误信息 |
| | | /// </summary> |
| | | public string errorMessageBase; |
| | | /// <summary> |
| | | /// 网关信息错误反馈 |
| | | /// <para>当网关接收到客户端信息后,出现以下异常情况将反馈错误。</para> |
| | | /// </summary> |
| | | public ErrorResponData errorResponData; |
| | | /// <summary> |
| | | /// 控制设备绑定的设备列表回复数据 |
| | | /// </summary> |
| | | public ClearBindInfoResponseData clearBindInfoResponseData; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 删除一个控制设备所有绑定信息回复的数据 |
| | | /// </summary> |
| | | public ClearBindInfoResponseData clearBindInfoResponseData; |
| | | [System.Serializable] |
| | | public class ClearBindInfoResponseData |
| | | { |
| | | /// <summary> |
| | | /// 0:成功 |
| | | ///<para>1:绑定信息不存在</para> |
| | | /// </summary> |
| | | public int Result; |
| | | } |
| | | |
| | | #endregion |
| | | } |
| | | } |