From 9c16d3614d9b88c637f967518a329f239fcd3aaf Mon Sep 17 00:00:00 2001 From: lss <316519258@qq.com> Date: 星期五, 12 六月 2020 09:22:04 +0800 Subject: [PATCH] 2020.06.12 --- ZigbeeApp/Shared/Phone/ZigBee/Device/CommonDevice.cs | 169 ++++++-------------------------------------------------- 1 files changed, 18 insertions(+), 151 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/CommonDevice.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/CommonDevice.cs index 92b3442..2e80273 100755 --- a/ZigbeeApp/Shared/Phone/ZigBee/Device/CommonDevice.cs +++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/CommonDevice.cs @@ -199,12 +199,12 @@ { return null; } - var gateWay = ZbGateway.GateWayList.Find(obj => (obj != null) && (obj.getGatewayBaseInfo != null) && (obj.getGatewayBaseInfo.gwID == CurrentGateWayId)); + var gateWay = ZbGateway.GateWayList.Find(obj => (obj != null) && (obj.GwId == CurrentGateWayId)); if (gateWay == null) { gateWay = new ZbGateway { IsVirtual = true, }; - gateWay.getGatewayBaseInfo.gwID = CurrentGateWayId; - gateWay.getGatewayBaseInfo.HomeId = Shared.Common.Config.Instance.HomeId; + gateWay.GwId = CurrentGateWayId; + gateWay.HomeId = Shared.Common.Config.Instance.HomeId; ZbGateway.GateWayList.Add(gateWay); } @@ -296,6 +296,14 @@ { device = Newtonsoft.Json.JsonConvert.DeserializeObject<FreshAir>(strDeviceByte); } + else if (strDeviceType == ZigBee.Device.DeviceType.PMSensor.ToString()) + { + return Newtonsoft.Json.JsonConvert.DeserializeObject<PMSensor>(strDeviceByte); + } + else if (strDeviceType == ZigBee.Device.DeviceType.ColorTemperatureLight.ToString()) + { + return Newtonsoft.Json.JsonConvert.DeserializeObject<ColorTemperatureLight>(strDeviceByte); + } else { return null; } //鑳藉皯瀛樹竴涓彉閲忓氨灏戝瓨涓�涓� device.Type = (DeviceType)device.DeviceID; @@ -365,6 +373,11 @@ { //璋冨厜鍣� IconPath = "Device/Light.png"; + } + else if (this.Type == DeviceType.ColorTemperatureLight) + { + //鑹叉俯鐏� + IconPath = "Device/ColorLightTemperature.png"; } else if (this.Type == DeviceType.OnOffOutput) { @@ -472,6 +485,8 @@ /// 娓╁害娴嬮噺鍔熻兘鐨勮澶囧锛氭俯搴︿紶鎰熷櫒銆傘�傘�� /// <para>1029:Relative Humidity Measurement,璁惧鏀寔鈥滄箍搴︽祴閲忓姛鑳解��</para> /// 婀垮害娴嬮噺鍔熻兘鐨勮澶囧锛氭箍搴︿紶鎰熷櫒銆傘�傘�� + /// <para>1066:Pm2.5 Measurement,璁惧鏀寔鈥減m2.5娴嬮噺鍔熻兘鈥�</para> + /// Pm2.5娴嬮噺鍔熻兘鐨勮澶囧锛歅m2.5浼犳劅鍣ㄣ�傘�傘�� /// </summary> public int InCluster; } @@ -742,80 +757,6 @@ #endregion #region 淇敼璁惧绔彛鍚嶇О - ///<summary > - /// 淇敼璁惧绔彛锛堟寜閿級鍚嶇О - /// <para>Gateway:璁惧鎵�灞炵綉鍏筹紙璋冪敤鏂规硶锛歞evice.Gateway)</para> - /// <para>deviceName:鎸夐敭鍚嶇О</para> - /// </summary> - public async System.Threading.Tasks.Task<DeviceRenameAllData> RenameDeviceNameAsync(string deviceAddr, int deviceEpoint, string deviceName) - { - if (Gateway == null) - { - return null; - } - return await System.Threading.Tasks.Task.Run(async () => - { - DeviceRenameAllData 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 DeviceRenameAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" }; - } - else - { - d = new DeviceRenameAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; - } - } - - if (topic == gatewayID + "/" + "DeviceRenameRespon") - { - var receiptData = Newtonsoft.Json.JsonConvert.DeserializeObject<DeviceRenameResponseData>(jobject["Data"].ToString()); - d = new DeviceRenameAllData { deviceRenameData = receiptData }; - } - }; - Gateway.Actions += action; - System.Console.WriteLine("DeviceRename_Actions 鍚姩" + "_" + System.DateTime.Now.ToString()); - try - { - var bytes = new byte[64]; - var reamarkGwBytes = Encoding.UTF8.GetBytes(deviceName); - System.Array.Copy(reamarkGwBytes, 0, bytes, 0, 64 < reamarkGwBytes.Length ? 64 : reamarkGwBytes.Length); - deviceName = Encoding.UTF8.GetString(bytes); - - var jObject = new JObject { { "DeviceAddr", deviceAddr }, { "Epoint", deviceEpoint }, { "Cluster_ID", 0 }, { "Command", 96 } }; - var data = new JObject { { "DeviceName", deviceName } }; - jObject.Add("Data", data); - Gateway?.Send(("DeviceRename"), 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 DeviceRenameAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; - } - - Gateway.Actions -= action; - System.Console.WriteLine("DeviceRename_Actions閫�鍑�" + System.DateTime.Now.ToString()); - return d; - }); - } /// <summary> /// 閲嶅懡鍚嶈澶�,缃戝叧鍙嶉鍏蜂綋淇℃伅 @@ -857,80 +798,6 @@ #endregion #region 淇敼璁惧mac鍚嶇О - ///<summary > - /// 淇敼璁惧mac鍚嶇О - /// <para>macName:璁惧鍚嶇О</para> - /// </summary> - public async System.Threading.Tasks.Task<RenameDeviceMacNameAllData> RenameDeviceMacNameAsync(string deviceAddr, int deviceEpoint, string macName) - { - if (Gateway == null) - { - return null; - } - return await System.Threading.Tasks.Task.Run(async () => - { - RenameDeviceMacNameAllData 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 RenameDeviceMacNameAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" }; - } - else - { - d = new RenameDeviceMacNameAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; - } - } - - if (topic == gatewayID + "/" + "MacRename_Respon") - { - var deviceID = jobject.Value<int>("Device_ID"); - d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<ToggleLight.RenameDeviceMacNameData>(jobject["Data"].ToString()) }; - } - }; - Gateway.Actions += action; - System.Console.WriteLine("MacRename_Actions 鍚姩" + "_" + System.DateTime.Now.ToString()); - try - { - var bytes = new byte[64]; - var reamarkGwBytes = Encoding.UTF8.GetBytes(macName); - System.Array.Copy(reamarkGwBytes, 0, bytes, 0, 64 < reamarkGwBytes.Length ? 64 : reamarkGwBytes.Length); - macName = Encoding.UTF8.GetString(bytes); - - var jObject = new JObject { { "DeviceAddr", deviceAddr }, { "Epoint", deviceEpoint }, { "Cluster_ID", 0 }, { "Command", 100 } }; - var data = new JObject { { "MacName", macName } }; - jObject.Add("Data", data); - Gateway?.Send(("MacRename"), 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 RenameDeviceMacNameAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; - } - - Gateway.Actions -= action; - System.Console.WriteLine("MacRename_Action閫�鍑�" + System.DateTime.Now.ToString()); - return d; - }); - } /// <summary> /// 淇敼璁惧mac鍚嶇О鏁版嵁,缃戝叧鍙嶉鍏蜂綋淇℃伅 -- Gitblit v1.8.0