| | |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | | using Newtonsoft.Json.Linq; |
| | | using Shared; |
| | | |
| | | namespace ZigBee.Device |
| | | { |
| | |
| | | { |
| | | #region 需要保存的变量 |
| | | |
| | | /// <summary>
|
| | | /// 是否是自定义图片
|
| | | /// <summary> |
| | | /// 是否是自定义图片 |
| | | /// </summary> |
| | | public bool IsCustomizeImage = false; |
| | | /// <summary> |
| | |
| | | /// <para>1026:sensor,传感器,具体类型的传感器DeviceType来区分</para> |
| | | /// </summary> |
| | | public int DeviceID; |
| | | /// <summary>
|
| | | /// <para>2020.09.21追加:为了对应第三方设备,以及之后的多设备ID问题,追加的变量</para>
|
| | | /// <para>这是个特殊的,并且不保存在文件当中的ID, DeviceType由此值映射出来</para>
|
| | | /// <para>当设备是河东设备时,它与DeviceID相等</para>
|
| | | /// <para>当是真正的第三方设备时,它有可能与DeviceID不相等</para>
|
| | | /// <para>比如:2和256都是继电器,那么【DeviceID为2 或者 DeviceID为256】 而 【ExDeviceID固定为2】,【DeviceType为OnOffOutput】</para>
|
| | | /// <para>通俗来说:DeviceID是实际正确的ID,而【ExDeviceID是一种所属概念的ID】</para>
|
| | | /// <summary> |
| | | /// <para>2020.09.21追加:为了对应第三方设备,以及之后的多设备ID问题,追加的变量</para> |
| | | /// <para>这是个特殊的,并且不保存在文件当中的ID, DeviceType由此值映射出来</para> |
| | | /// <para>当设备是河东设备时,它与DeviceID相等</para> |
| | | /// <para>当是真正的第三方设备时,它有可能与DeviceID不相等</para> |
| | | /// <para>比如:2和256都是继电器,那么【DeviceID为2 或者 DeviceID为256】 而 【ExDeviceID固定为2】,【DeviceType为OnOffOutput】</para> |
| | | /// <para>通俗来说:DeviceID是实际正确的ID,而【ExDeviceID是一种所属概念的ID】</para> |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public int ExDeviceID; |
| | |
| | | /// <para>1:设备在线</para> |
| | | /// </summary> |
| | | public int IsOnline; |
| | | /// <summary>
|
| | | /// 1:路由设备
|
| | | /// <para>2:终端设备,电池设备</para>
|
| | | /// </summary>
|
| | | /// <summary> |
| | | /// 1:路由设备 |
| | | /// <para>2:终端设备,电池设备</para> |
| | | /// </summary> |
| | | public int ZigbeeType; |
| | | /// <summary> |
| | | /// 固件版本 |
| | |
| | | |
| | | #region 设备保存及生成 |
| | | |
| | | /// <summary>
|
| | | /// 由设备字符串比特恢复设备对象
|
| | | /// </summary>
|
| | | /// <param name="intDeviceType">设备DeviceType的整型值</param>
|
| | | /// <param name="strDeviceByte">设备Json文件转为比特后再转为的字符串</param>
|
| | | /// <summary> |
| | | /// 由设备字符串比特恢复设备对象 |
| | | /// </summary> |
| | | /// <param name="intDeviceType">设备DeviceType的整型值</param> |
| | | /// <param name="strDeviceByte">设备Json文件转为比特后再转为的字符串</param> |
| | | /// <returns></returns> |
| | | public static CommonDevice CommonDeviceByByteString(int intDeviceType, string strDeviceByte) |
| | | { |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 判断是否是空气质量传感器 |
| | | /// </summary> |
| | | /// <param name="dev"></param> |
| | | /// <returns></returns> |
| | | public bool isAirQualitySensor(CommonDevice dev) |
| | | { |
| | | bool hasT = false; |
| | | bool hasH = false; |
| | | bool hasPM = false; |
| | | bool hasCo2 = false; |
| | | foreach (var clu in dev.InClusterList) |
| | | { |
| | | switch (clu.InCluster) |
| | | { |
| | | case 1026: |
| | | hasT = true; |
| | | break; |
| | | case 1029: |
| | | hasH = true; |
| | | break; |
| | | case 1037: |
| | | hasCo2 = true; |
| | | break; |
| | | case 1066: |
| | | hasPM = true; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (hasT == true && hasH == true && hasPM == true && hasCo2 == true) |
| | | { |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 保存设备图标 |
| | | /// </summary> |
| | | private void SaveDeviceIcon() |
| | |
| | | } |
| | | else if (this.Type == DeviceType.TemperatureSensor) |
| | | { |
| | | if (((TemperatureSensor)this).SensorDiv == 1) |
| | | if (isAirQualitySensor(this)) |
| | | { |
| | | //温度传感器 |
| | | IconPath = "Device/SensorTemperature.png"; |
| | | //空气质量传感器 |
| | | IconPath = "Device/AirQualitySensorEpoint.png"; |
| | | } |
| | | else if (((TemperatureSensor)this).SensorDiv == 2) |
| | | else |
| | | { |
| | | //湿度传感器 |
| | | IconPath = "Device/SensorHumidity.png"; |
| | | if (((TemperatureSensor)this).SensorDiv == 1) |
| | | { |
| | | //温度传感器 |
| | | IconPath = "Device/SensorTemperature.png"; |
| | | } |
| | | else if (((TemperatureSensor)this).SensorDiv == 2) |
| | | { |
| | | //湿度传感器 |
| | | IconPath = "Device/SensorHumidity.png"; |
| | | } |
| | | } |
| | | } |
| | | else if (this.Type != DeviceType.UnKown) |
| | |
| | | /// 驱动代码。为0时,表示zigbee协调器设备。其他值表示为虚拟驱动设备 |
| | | /// </summary> |
| | | public int DriveCode; |
| | | /// <summary>
|
| | | /// 厂商名称
|
| | | /// <summary> |
| | | /// 厂商名称 |
| | | /// </summary> |
| | | public string ManufacturerName = string.Empty; |
| | | /// <summary>
|
| | | /// 模块ID
|
| | | /// <summary> |
| | | /// 模块ID |
| | | /// </summary> |
| | | public string ModelIdentifier = string.Empty; |
| | | /// <summary>
|
| | | /// 好像是序列号
|
| | | /// <summary> |
| | | /// 好像是序列号 |
| | | /// </summary> |
| | | public string ProductCode = string.Empty; |
| | | /// <summary>
|
| | | /// 设备功能类型(空气开关和继电器专用)
|
| | | /// <summary> |
| | | /// 设备功能类型(空气开关和继电器专用) |
| | | /// </summary> |
| | | public int FunctionType = -1; |
| | | /// <summary> |
| | |
| | | SynchronizationDeviceResponseAllData resContent = null; |
| | | Action<string, string> action = (topic, message) => |
| | | { |
| | | var gatewayID = topic.Split('/')[0]; |
| | | var jobject = Newtonsoft.Json.Linq.JObject.Parse(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 (topic == gatewayID + "/" + "Error_Respon") |
| | | { |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); |
| | | |
| | | if (temp == null) |
| | | { |
| | | resContent = new SynchronizationDeviceResponseAllData { errorMessageBase = "网关错误回复,且数据是空" }; |
| | | } |
| | | else |
| | | { |
| | | resContent = new SynchronizationDeviceResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; |
| | | } |
| | | } |
| | | if (temp == null) |
| | | { |
| | | resContent = new SynchronizationDeviceResponseAllData { errorMessageBase = "网关错误回复,且数据是空" }; |
| | | } |
| | | else |
| | | { |
| | | resContent = new SynchronizationDeviceResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; |
| | | } |
| | | } |
| | | |
| | | if (topic == gatewayID + "/" + "Bind/SyncMsgToBindSourceRespon") |
| | | { |
| | | var res = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["Result"].ToString()); |
| | | if (res == null) |
| | | { |
| | | resContent = new SynchronizationDeviceResponseAllData { errorMessageBase = "网关返回的数据为空" }; |
| | | } |
| | | else |
| | | { |
| | | resContent = new SynchronizationDeviceResponseAllData { result = res }; |
| | | System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | } |
| | | } |
| | | }; |
| | | if (topic == gatewayID + "/" + "Bind/SyncMsgToBindSourceRespon") |
| | | { |
| | | var res = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["Result"].ToString()); |
| | | if (res == null) |
| | | { |
| | | resContent = new SynchronizationDeviceResponseAllData { errorMessageBase = "网关返回的数据为空" }; |
| | | } |
| | | else |
| | | { |
| | | resContent = new SynchronizationDeviceResponseAllData { result = res }; |
| | | System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | } |
| | | } |
| | | }; |
| | | Gateway.Actions = action; |
| | | DebugPrintLog("Bind/SyncMsgToBindSourceRespon_Actions 启动" + "_" + System.DateTime.Now.ToString()); |
| | | |
| | |
| | | RemoveDeviceResponseAllData d = null; |
| | | Action<string, string> action = (topic, message) => |
| | | { |
| | | var gatewayID = topic.Split('/')[0]; |
| | | var jobject = Newtonsoft.Json.Linq.JObject.Parse(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 (topic == gatewayID + "/" + "Error_Respon") |
| | | { |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); |
| | | |
| | | if (temp == null) |
| | | { |
| | | d = new RemoveDeviceResponseAllData { errorMessageBase = "网关错误回复,且数据是空" }; |
| | | } |
| | | else |
| | | { |
| | | d = new RemoveDeviceResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; |
| | | } |
| | | } |
| | | if (temp == null) |
| | | { |
| | | d = new RemoveDeviceResponseAllData { errorMessageBase = "网关错误回复,且数据是空" }; |
| | | } |
| | | else |
| | | { |
| | | d = new RemoveDeviceResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; |
| | | } |
| | | } |
| | | |
| | | if (topic == gatewayID + "/" + "RemoveDeviceRespon") |
| | | { |
| | | var removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.RemoveDeviceResponseData>(jobject["Data"].ToString()); |
| | | if (topic == gatewayID + "/" + "RemoveDeviceRespon") |
| | | { |
| | | var removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.RemoveDeviceResponseData>(jobject["Data"].ToString()); |
| | | |
| | | if (removeDeviceResponseData == null) |
| | | { |
| | | d = new RemoveDeviceResponseAllData { errorMessageBase = "网关返回的数据为空" }; |
| | | } |
| | | else |
| | | { |
| | | d = new RemoveDeviceResponseAllData { removeDeviceResponseData = removeDeviceResponseData }; |
| | | System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | } |
| | | } |
| | | }; |
| | | if (removeDeviceResponseData == null) |
| | | { |
| | | d = new RemoveDeviceResponseAllData { errorMessageBase = "网关返回的数据为空" }; |
| | | } |
| | | else |
| | | { |
| | | d = new RemoveDeviceResponseAllData { removeDeviceResponseData = removeDeviceResponseData }; |
| | | System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | } |
| | | } |
| | | }; |
| | | Gateway.Actions += action; |
| | | DebugPrintLog("RemoveDevice_Actions 启动" + "_" + System.DateTime.Now.ToString()); |
| | | |
| | |
| | | } |
| | | await System.Threading.Tasks.Task.Run(async () => |
| | | { |
| | | //Action<string, string> action = (topic, message) => { }; |
| | | //Action<string, string> action = (topic, message) => { }; |
| | | |
| | | // Gateway.Actions += action; |
| | | System.Console.WriteLine("GetDeviceStatus_Actions 启动" + "_" + System.DateTime.Now.ToString()); |
| | | // Gateway.Actions += action; |
| | | System.Console.WriteLine("GetDeviceStatus_Actions 启动" + "_" + System.DateTime.Now.ToString()); |
| | | |
| | | try |
| | | { |
| | |
| | | } |
| | | catch { } |
| | | |
| | | // Gateway.Actions -= action; |
| | | System.Console.WriteLine("GetDeviceStatus_Actions 退出" + System.DateTime.Now.ToString()); |
| | | // Gateway.Actions -= action; |
| | | System.Console.WriteLine("GetDeviceStatus_Actions 退出" + System.DateTime.Now.ToString()); |
| | | }); |
| | | } |
| | | |
| | |
| | | SetWritableValueResponAllData d = null; |
| | | Action<string, string> action = (topic, message) => |
| | | { |
| | | var gatewayID = topic.Split('/')[0]; |
| | | var jobject = Newtonsoft.Json.Linq.JObject.Parse(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 (topic == gatewayID + "/" + "Error_Respon") |
| | | { |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); |
| | | |
| | | if (temp == null) |
| | | { |
| | | d = new SetWritableValueResponAllData { errorMessageBase = "网关错误回复,且数据是空" }; |
| | | } |
| | | else |
| | | { |
| | | d = new SetWritableValueResponAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; |
| | | } |
| | | } |
| | | if (temp == null) |
| | | { |
| | | d = new SetWritableValueResponAllData { errorMessageBase = "网关错误回复,且数据是空" }; |
| | | } |
| | | else |
| | | { |
| | | d = new SetWritableValueResponAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; |
| | | } |
| | | } |
| | | |
| | | if (topic == gatewayID + "/" + "SetWritableValue_Respon") |
| | | { |
| | | var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<SetWritableValueResponData>(jobject["Data"].ToString()); |
| | | if (topic == gatewayID + "/" + "SetWritableValue_Respon") |
| | | { |
| | | var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<SetWritableValueResponData>(jobject["Data"].ToString()); |
| | | |
| | | if (tempData == null) |
| | | { |
| | | d = new SetWritableValueResponAllData { errorMessageBase = "网关返回的数据为空" }; |
| | | } |
| | | else |
| | | { |
| | | d = new SetWritableValueResponAllData { setWritableValueResponData = tempData }; |
| | | System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | } |
| | | } |
| | | }; |
| | | if (tempData == null) |
| | | { |
| | | d = new SetWritableValueResponAllData { errorMessageBase = "网关返回的数据为空" }; |
| | | } |
| | | else |
| | | { |
| | | d = new SetWritableValueResponAllData { setWritableValueResponData = tempData }; |
| | | System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | } |
| | | } |
| | | }; |
| | | Gateway.Actions += action; |
| | | System.Console.WriteLine("SetWritableValue_Actions 启动" + "_" + System.DateTime.Now.ToString()); |
| | | |
| | |
| | | ClusterOwnAttributesResponAllData d = null; |
| | | Action<string, string> action = (topic, message) => |
| | | { |
| | | var gatewayID = topic.Split('/')[0]; |
| | | var jobject = Newtonsoft.Json.Linq.JObject.Parse(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 (topic == gatewayID + "/" + "Error_Respon") |
| | | { |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); |
| | | |
| | | if (temp == null) |
| | | { |
| | | d = new ClusterOwnAttributesResponAllData { errorMessageBase = "网关错误回复,且数据是空" }; |
| | | } |
| | | else |
| | | { |
| | | d = new ClusterOwnAttributesResponAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; |
| | | } |
| | | } |
| | | if (temp == null) |
| | | { |
| | | d = new ClusterOwnAttributesResponAllData { errorMessageBase = "网关错误回复,且数据是空" }; |
| | | } |
| | | else |
| | | { |
| | | d = new ClusterOwnAttributesResponAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; |
| | | } |
| | | } |
| | | |
| | | if (topic == gatewayID + "/" + "Cluster/OwnAttributes_Respon") |
| | | { |
| | | var clusterOwnAttributesResponData = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ClusterOwnAttributesResponData>(jobject["Data"].ToString()); |
| | | var tempAttributes = Newtonsoft.Json.Linq.JArray.Parse(jobject["Data"]["Attribute"].ToString()); |
| | | for (int m = 0; tempAttributes != null && m < tempAttributes.Count; m++) |
| | | { |
| | | var tempAttribute = tempAttributes[m]; |
| | | clusterOwnAttributesResponData.AttributeList.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<AttributeObj>(tempAttribute.ToString())); |
| | | } |
| | | if (topic == gatewayID + "/" + "Cluster/OwnAttributes_Respon") |
| | | { |
| | | var clusterOwnAttributesResponData = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ClusterOwnAttributesResponData>(jobject["Data"].ToString()); |
| | | var tempAttributes = Newtonsoft.Json.Linq.JArray.Parse(jobject["Data"]["Attribute"].ToString()); |
| | | for (int m = 0; tempAttributes != null && m < tempAttributes.Count; m++) |
| | | { |
| | | var tempAttribute = tempAttributes[m]; |
| | | clusterOwnAttributesResponData.AttributeList.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<AttributeObj>(tempAttribute.ToString())); |
| | | } |
| | | |
| | | if (clusterOwnAttributesResponData == null) |
| | | { |
| | | d = new ClusterOwnAttributesResponAllData { errorMessageBase = "网关返回的数据为空" }; |
| | | } |
| | | else |
| | | { |
| | | d = new ClusterOwnAttributesResponAllData { clusterOwnAttributesResponData = clusterOwnAttributesResponData }; |
| | | System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | if (clusterOwnAttributesResponData == null) |
| | | { |
| | | d = new ClusterOwnAttributesResponAllData { errorMessageBase = "网关返回的数据为空" }; |
| | | } |
| | | else |
| | | { |
| | | d = new ClusterOwnAttributesResponAllData { clusterOwnAttributesResponData = clusterOwnAttributesResponData }; |
| | | System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | |
| | | } |
| | | } |
| | | }; |
| | | } |
| | | } |
| | | }; |
| | | gateway.Actions += action; |
| | | System.Console.WriteLine("Cluster/OwnAttributes_Actions 启动" + "_" + System.DateTime.Now.ToString()); |
| | | |
| | |
| | | ClusterOwnCommandResponAllData d = null; |
| | | Action<string, string> action = (topic, message) => |
| | | { |
| | | var gatewayID = topic.Split('/')[0]; |
| | | var jobject = Newtonsoft.Json.Linq.JObject.Parse(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 (topic == gatewayID + "/" + "Error_Respon") |
| | | { |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); |
| | | |
| | | if (temp == null) |
| | | { |
| | | d = new ClusterOwnCommandResponAllData { errorMessageBase = "网关错误回复,且数据是空" }; |
| | | } |
| | | else |
| | | { |
| | | d = new ClusterOwnCommandResponAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; |
| | | if (temp == null) |
| | | { |
| | | d = new ClusterOwnCommandResponAllData { errorMessageBase = "网关错误回复,且数据是空" }; |
| | | } |
| | | else |
| | | { |
| | | d = new ClusterOwnCommandResponAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (topic == gatewayID + "/" + "Cluster/OwnCommand_Respon") |
| | | { |
| | | var clusterOwnCommandResponData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClusterOwnCommandResponData>(jobject["Data"].ToString()); |
| | | if (topic == gatewayID + "/" + "Cluster/OwnCommand_Respon") |
| | | { |
| | | var clusterOwnCommandResponData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClusterOwnCommandResponData>(jobject["Data"].ToString()); |
| | | |
| | | if (clusterOwnCommandResponData == null) |
| | | { |
| | | d = new ClusterOwnCommandResponAllData { errorMessageBase = "网关返回的数据为空" }; |
| | | if (clusterOwnCommandResponData == null) |
| | | { |
| | | d = new ClusterOwnCommandResponAllData { errorMessageBase = "网关返回的数据为空" }; |
| | | |
| | | } |
| | | else |
| | | { |
| | | d = new ClusterOwnCommandResponAllData { clusterOwnCommandResponData = clusterOwnCommandResponData }; |
| | | System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | } |
| | | } |
| | | }; |
| | | } |
| | | else |
| | | { |
| | | d = new ClusterOwnCommandResponAllData { clusterOwnCommandResponData = clusterOwnCommandResponData }; |
| | | System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | } |
| | | } |
| | | }; |
| | | gateway.Actions += action; |
| | | System.Console.WriteLine("Cluster/OwnCommand_Actions 启动" + "_" + System.DateTime.Now.ToString()); |
| | | |
| | |
| | | OTASetImageResponseAllData d = null; ; |
| | | Action<string, string> action = (topic, message) => |
| | | { |
| | | var gatewayID = topic.Split('/')[0]; |
| | | var jobject = Newtonsoft.Json.Linq.JObject.Parse(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 (topic == gatewayID + "/" + "Error_Respon") |
| | | { |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); |
| | | |
| | | if (temp == null) |
| | | { |
| | | d = new OTASetImageResponseAllData { errorMessageBase = "网关错误回复,且数据是空" }; |
| | | } |
| | | if (temp == null) |
| | | { |
| | | d = new OTASetImageResponseAllData { errorMessageBase = "网关错误回复,且数据是空" }; |
| | | } |
| | | |
| | | else |
| | | { |
| | | d = new OTASetImageResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | d = new OTASetImageResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; |
| | | } |
| | | } |
| | | |
| | | if (topic == gatewayID + "/" + "OTA/SetImage_Respon") |
| | | { |
| | | var oTASetImageData = Newtonsoft.Json.JsonConvert.DeserializeObject<OTASetImageData>(jobject["Data"].ToString()); |
| | | if (topic == gatewayID + "/" + "OTA/SetImage_Respon") |
| | | { |
| | | var oTASetImageData = Newtonsoft.Json.JsonConvert.DeserializeObject<OTASetImageData>(jobject["Data"].ToString()); |
| | | |
| | | if (oTASetImageData == null) |
| | | { |
| | | d = new OTASetImageResponseAllData { errorMessageBase = "网关返回的数据为空" }; |
| | | } |
| | | else |
| | | { |
| | | d = new OTASetImageResponseAllData { otaSetImageData = oTASetImageData }; |
| | | System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | } |
| | | } |
| | | }; |
| | | if (oTASetImageData == null) |
| | | { |
| | | d = new OTASetImageResponseAllData { errorMessageBase = "网关返回的数据为空" }; |
| | | } |
| | | else |
| | | { |
| | | d = new OTASetImageResponseAllData { otaSetImageData = oTASetImageData }; |
| | | System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | } |
| | | } |
| | | }; |
| | | gateway.Actions += action; |
| | | System.Console.WriteLine("OTA/SetImage_Actions 启动" + "_" + System.DateTime.Now.ToString()); |
| | | |
| | |
| | | StartDeviceUpdateResponseAllData d = null; ; |
| | | Action<string, string> action = (topic, message) => |
| | | { |
| | | var gatewayID = topic.Split('/')[0]; |
| | | var jobject = Newtonsoft.Json.Linq.JObject.Parse(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 (topic == gatewayID + "/" + "Error_Respon") |
| | | { |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); |
| | | |
| | | if (temp == null) |
| | | { |
| | | d = new StartDeviceUpdateResponseAllData { errorMessageBase = "网关错误回复,且数据是空" }; |
| | | } |
| | | if (temp == null) |
| | | { |
| | | d = new StartDeviceUpdateResponseAllData { errorMessageBase = "网关错误回复,且数据是空" }; |
| | | } |
| | | |
| | | else |
| | | { |
| | | d = new StartDeviceUpdateResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | d = new StartDeviceUpdateResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; |
| | | } |
| | | } |
| | | |
| | | if (topic == gatewayID + "/" + "OTA/StartUpdate_Respon") |
| | | { |
| | | var startUpdateDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<StartDeviceUpdateData>(jobject["Data"].ToString()); |
| | | if (topic == gatewayID + "/" + "OTA/StartUpdate_Respon") |
| | | { |
| | | var startUpdateDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<StartDeviceUpdateData>(jobject["Data"].ToString()); |
| | | |
| | | if (startUpdateDeviceData == null) |
| | | { |
| | | d = new StartDeviceUpdateResponseAllData { errorMessageBase = "网关返回的数据为空" }; |
| | | } |
| | | else |
| | | { |
| | | d = new StartDeviceUpdateResponseAllData { startUpdateDeviceData = startUpdateDeviceData }; |
| | | System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | } |
| | | } |
| | | }; |
| | | if (startUpdateDeviceData == null) |
| | | { |
| | | d = new StartDeviceUpdateResponseAllData { errorMessageBase = "网关返回的数据为空" }; |
| | | } |
| | | else |
| | | { |
| | | d = new StartDeviceUpdateResponseAllData { startUpdateDeviceData = startUpdateDeviceData }; |
| | | System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | } |
| | | } |
| | | }; |
| | | gateway.Actions += action; |
| | | System.Console.WriteLine("OTA/StartUpdate_Actions 启动" + "_" + System.DateTime.Now.ToString()); |
| | | |
| | |
| | | ClientDataPassthroughResponseAllData d = null; ; |
| | | Action<string, string> action = (topic, message) => |
| | | { |
| | | var gatewayID = topic.Split('/')[0]; |
| | | var jobject = Newtonsoft.Json.Linq.JObject.Parse(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 (topic == gatewayID + "/" + "Error_Respon") |
| | | { |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); |
| | | |
| | | if (temp == null) |
| | | { |
| | | d = new ClientDataPassthroughResponseAllData { errorMessageBase = "网关错误回复,且数据是空" }; |
| | | } |
| | | if (temp == null) |
| | | { |
| | | d = new ClientDataPassthroughResponseAllData { errorMessageBase = "网关错误回复,且数据是空" }; |
| | | } |
| | | |
| | | else |
| | | { |
| | | d = new ClientDataPassthroughResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | d = new ClientDataPassthroughResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; |
| | | } |
| | | } |
| | | |
| | | if (topic == gatewayID + "/" + "ZbDataPassthrough") |
| | | { |
| | | var clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString()); |
| | | if (topic == gatewayID + "/" + "ZbDataPassthrough") |
| | | { |
| | | var clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString()); |
| | | |
| | | if (clientDataPassthroughResponseData == null) |
| | | { |
| | | d = new ClientDataPassthroughResponseAllData { errorMessageBase = "网关返回的数据为空" }; |
| | | } |
| | | else |
| | | { |
| | | d = new ClientDataPassthroughResponseAllData { clientDataPassthroughResponseData = clientDataPassthroughResponseData }; |
| | | System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | } |
| | | } |
| | | }; |
| | | if (clientDataPassthroughResponseData == null) |
| | | { |
| | | d = new ClientDataPassthroughResponseAllData { errorMessageBase = "网关返回的数据为空" }; |
| | | } |
| | | else |
| | | { |
| | | d = new ClientDataPassthroughResponseAllData { clientDataPassthroughResponseData = clientDataPassthroughResponseData }; |
| | | System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | } |
| | | } |
| | | }; |
| | | gateway.Actions += action; |
| | | System.Console.WriteLine("ClientDataPassthrough_Actions 启动" + "_" + System.DateTime.Now.ToString()); |
| | | |
| | |
| | | DownloadFileResponAllData d = null; ; |
| | | Action<string, string> action = (topic, message) => |
| | | { |
| | | var gatewayID = topic.Split('/')[0]; |
| | | var jobject = Newtonsoft.Json.Linq.JObject.Parse(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 (topic == gatewayID + "/" + "Error_Respon") |
| | | { |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); |
| | | |
| | | if (temp == null) |
| | | { |
| | | d = new DownloadFileResponAllData { errorMessageBase = "网关错误回复,且数据是空" }; |
| | | } |
| | | else |
| | | { |
| | | d = new DownloadFileResponAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; |
| | | } |
| | | } |
| | | if (temp == null) |
| | | { |
| | | d = new DownloadFileResponAllData { errorMessageBase = "网关错误回复,且数据是空" }; |
| | | } |
| | | else |
| | | { |
| | | d = new DownloadFileResponAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; |
| | | } |
| | | } |
| | | |
| | | if (topic == gatewayID + "/" + "DownloadFile_Respon") |
| | | { |
| | | var downloadFileResponData = Newtonsoft.Json.JsonConvert.DeserializeObject<DownloadFileResponData>(jobject["Data"].ToString()); |
| | | if (topic == gatewayID + "/" + "DownloadFile_Respon") |
| | | { |
| | | var downloadFileResponData = Newtonsoft.Json.JsonConvert.DeserializeObject<DownloadFileResponData>(jobject["Data"].ToString()); |
| | | |
| | | if (downloadFileResponData == null) |
| | | { |
| | | d = new DownloadFileResponAllData { errorMessageBase = "网关返回的数据为空" }; |
| | | } |
| | | else |
| | | { |
| | | d = new DownloadFileResponAllData { downloadFileResponData = downloadFileResponData }; |
| | | System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | } |
| | | } |
| | | }; |
| | | if (downloadFileResponData == null) |
| | | { |
| | | d = new DownloadFileResponAllData { errorMessageBase = "网关返回的数据为空" }; |
| | | } |
| | | else |
| | | { |
| | | d = new DownloadFileResponAllData { downloadFileResponData = downloadFileResponData }; |
| | | System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | } |
| | | } |
| | | }; |
| | | gateway.Actions += action; |
| | | try |
| | | { |
| | |
| | | KillUpdateResponseAllData d = null; ; |
| | | Action<string, string> action = (topic, message) => |
| | | { |
| | | var gatewayID = topic.Split('/')[0]; |
| | | var jobject = Newtonsoft.Json.Linq.JObject.Parse(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 (topic == gatewayID + "/" + "Error_Respon") |
| | | { |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); |
| | | |
| | | if (temp == null) |
| | | { |
| | | d = new KillUpdateResponseAllData { errorMessageBase = "网关错误回复,且数据是空" }; |
| | | } |
| | | if (temp == null) |
| | | { |
| | | d = new KillUpdateResponseAllData { errorMessageBase = "网关错误回复,且数据是空" }; |
| | | } |
| | | |
| | | else |
| | | { |
| | | d = new KillUpdateResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | d = new KillUpdateResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; |
| | | } |
| | | } |
| | | |
| | | if (topic == gatewayID + "/" + "OTA/KillUpdate_Respon") |
| | | { |
| | | var killUpdateData = Newtonsoft.Json.JsonConvert.DeserializeObject<KillUpdateData>(jobject["Data"].ToString()); |
| | | if (topic == gatewayID + "/" + "OTA/KillUpdate_Respon") |
| | | { |
| | | var killUpdateData = Newtonsoft.Json.JsonConvert.DeserializeObject<KillUpdateData>(jobject["Data"].ToString()); |
| | | |
| | | if (killUpdateData == null) |
| | | { |
| | | d = new KillUpdateResponseAllData { errorMessageBase = "网关返回的数据为空" }; |
| | | } |
| | | else |
| | | { |
| | | d = new KillUpdateResponseAllData { killUpdateData = killUpdateData }; |
| | | System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | } |
| | | } |
| | | }; |
| | | if (killUpdateData == null) |
| | | { |
| | | d = new KillUpdateResponseAllData { errorMessageBase = "网关返回的数据为空" }; |
| | | } |
| | | else |
| | | { |
| | | d = new KillUpdateResponseAllData { killUpdateData = killUpdateData }; |
| | | System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | } |
| | | } |
| | | }; |
| | | gateway.Actions += action; |
| | | System.Console.WriteLine("OTA/KillUpdate_Actions 启动" + "_" + System.DateTime.Now.ToString()); |
| | | |