From ec34983e291d1c85284472a27109d55891f9a6b5 Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期五, 07 八月 2020 16:20:16 +0800 Subject: [PATCH] 不是新代码,别 合并 --- ZigbeeApp/Shared/Common/Device.cs | 153 ++++++++++++++++++++++++++++++--------------------- 1 files changed, 90 insertions(+), 63 deletions(-) diff --git a/ZigbeeApp/Shared/Common/Device.cs b/ZigbeeApp/Shared/Common/Device.cs old mode 100644 new mode 100755 index 7f12108..1e86a70 --- a/ZigbeeApp/Shared/Common/Device.cs +++ b/ZigbeeApp/Shared/Common/Device.cs @@ -99,7 +99,7 @@ this.dicDeviceEpoint.Clear(); //鍒濆鍖栬澶囨灇涓� - this.InitDeviceModelIdEnum(); + this.InitDeviceModelIdEnum(); //鑾峰彇鏈湴鍏ㄩ儴鐨勮澶囨枃浠� List<string> listFile = this.GetAllDeviceFile(); @@ -267,22 +267,8 @@ listDriveDevice.Add(device); } } - if (listDriveDevice.Count > 0) - { - //濡傛灉铏氭嫙璁惧杩樻病鏈夊悕瀛楃殑璇� - HdlThreadLogic.Current.RunThread(() => - { - //濡傛灉涓嶈繖鏍锋斁鍦ㄤ竴涓嚎绋嬮噷,鏈夊彲鑳藉Dictionary浜х敓褰卞搷 - foreach (var myDevice in listDriveDevice) - { - //鏍规嵁璁惧绫诲瀷鑾峰彇鍚嶇О - var dName = this.GetDeviceObjectText(new List<CommonDevice>() { myDevice }, false); - //鍦ㄧ鐐瑰悕瀛楃殑鍚庨潰闄勫姞銆愬洖璺�戝瓧鏍� - dName += "(" + myDevice.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + ")"; - this.ReName(myDevice, dName, ShowErrorMode.NO); - } - }); - } + //璁剧疆铏氭嫙璁惧鐨勯粯璁ゅ悕瀛� + this.SetDriveDeviceDefultName(listDriveDevice); //鍙湁瀹屽叏鑾峰彇鐨勬椂鍊�,鎵嶄細鍘诲鐞嗗垹闄ょ殑闂 if (statu != 1) @@ -534,6 +520,42 @@ return true; } + /// <summary> + /// 璁剧疆铏氭嫙璁惧鐨勯粯璁ゅ悕瀛� + /// </summary> + /// <param name="listDriveDevice">铏氭嫙璁惧鍒楄〃</param> + private void SetDriveDeviceDefultName(List<CommonDevice> listDriveDevice) + { + if (listDriveDevice.Count == 0) + { + return; + } + //濡傛灉铏氭嫙璁惧杩樻病鏈夊悕瀛楃殑璇� + HdlThreadLogic.Current.RunThread(() => + { + //濡傛灉涓嶈繖鏍锋斁鍦ㄤ竴涓嚎绋嬮噷,鏈夊彲鑳藉Dictionary浜х敓褰卞搷 + foreach (var myDevice in listDriveDevice) + { + string dName = string.Empty; + if (this.IsMiniLight(myDevice) == true) + { + //Mini澶滅伅 + dName = Language.StringByID(R.MyInternationalizationString.uMiniNightLight); + } + else + { + //鏍规嵁璁惧绫诲瀷鑾峰彇鍚嶇О + dName = this.GetDeviceObjectText(new List<CommonDevice>() { myDevice }, false); + //鍦ㄧ鐐瑰悕瀛楃殑鍚庨潰闄勫姞銆愬洖璺�戝瓧鏍� + dName += "(" + myDevice.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + ")"; + } + this.ReName(myDevice, dName, ShowErrorMode.NO); + + System.Threading.Thread.Sleep(100); + } + }); + } + ///<summary > /// 淇敼璁惧mac鍚嶇О /// <para>macName:璁惧鍚嶇О</para> @@ -543,7 +565,7 @@ //濡傛灉褰撳墠鏄櫄鎷熶綇瀹� if (Common.Config.Instance.Home.IsVirtually == true) { - return Phone.ModelData.DeviceModelDataLogic.Current.ReDeviceMacName(device, macName, "MacRename"); + return Phone.TemplateData.TemplateDeviceDataLogic.Current.ReDeviceMacName(device, macName); } //鑾峰彇缂栬緫璁惧Mac鍚嶅瓧鐨勫懡浠ゅ瓧绗� @@ -554,7 +576,7 @@ return null; } //鍔犵紦瀛� - Phone.ModelData.DeviceModelDataLogic.Current.ReDeviceMacName(device, macName, "MacRename"); + Phone.TemplateData.TemplateDeviceDataLogic.Current.ReDeviceMacName(device, macName); var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.RenameDeviceMacNameData>(result.ReceiptData); return new CommonDevice.RenameDeviceMacNameAllData { renameDeviceMacNameData = tempData }; @@ -571,7 +593,7 @@ //濡傛灉褰撳墠鏄櫄鎷熶綇瀹� if (Common.Config.Instance.Home.IsVirtually == true) { - return Phone.ModelData.DeviceModelDataLogic.Current.ReDeviceEpointName(device, deviceName, "DeviceRename"); + return Phone.TemplateData.TemplateDeviceDataLogic.Current.ReDeviceEpointName(device, deviceName); } //鑾峰彇缂栬緫璁惧绔偣鍚嶅瓧鐨勫懡浠ゅ瓧绗� var sendData = this.GetReDeviceEpointNameCommandText(device.DeviceAddr, device.DeviceEpoint, deviceName); @@ -581,7 +603,7 @@ return null; } //鍔犵紦瀛� - Phone.ModelData.DeviceModelDataLogic.Current.ReDeviceEpointName(device, deviceName, "DeviceRename"); + Phone.TemplateData.TemplateDeviceDataLogic.Current.ReDeviceEpointName(device, deviceName); var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.DeviceRenameResponseData>(result.ReceiptData); return new CommonDevice.DeviceRenameAllData { deviceRenameData = tempData }; @@ -847,9 +869,9 @@ //闂ㄩ攣娌℃湁瀹氫綅鍔熻兘 return false; } + var myTypeInfo = this.GetMyDeviceEnumInfo(new List<CommonDevice>() { device }); if (device.Type == DeviceType.IASZone) { - var myTypeInfo = this.GetMyDeviceEnumInfo(new List<CommonDevice>() { device }); if (myTypeInfo.ConcreteType == DeviceConcreteType.Sensor_Pir) { //浼犳劅鍣ㄩ櫎浜哖ir閮芥病鏈夊畾浣嶅姛鑳� @@ -860,6 +882,11 @@ //鐞冨瀷绉诲姩浼犳劅鍣ㄨ櫧鐒舵槸鐢垫睜璁惧,浣嗘槸瀹冩湁瀹氫綅鍔熻兘 return true; } + return false; + } + //娓╂箍搴︿紶鎰熷櫒娌℃湁瀹氫綅鍔熻兘 + if (myTypeInfo.ConcreteType == DeviceConcreteType.Sensor_TemperatureHumidity) + { return false; } @@ -1359,6 +1386,16 @@ //闈㈡澘鐨勬俯搴︽帰澶村彨 闈㈡澘鍚嶅瓧+娓╁害 return deviceInfoType.DeviceDefultName + Language.StringByID(R.MyInternationalizationString.uTemperature); } + else if (((TemperatureSensor)device).SensorDiv == 1) + { + //娓╁害浼犳劅鍣� + return Language.StringByID(R.MyInternationalizationString.TemperatureSensor); + } + else if (((TemperatureSensor)device).SensorDiv == 2) + { + //婀垮害浼犳劅鍣� + return Language.StringByID(R.MyInternationalizationString.HumiditySensor); + } } //鍏朵粬鎯呭喌,浣跨敤瀹冪殑榛樿鍚嶇О return deviceInfoType.DeviceDefultName + epointNo; @@ -1393,7 +1430,7 @@ /// <param name="device">璁惧瀵硅薄</param> /// <param name="macName">Mac鍚嶅瓧</param> /// <returns></returns> - private void SetMacName(CommonDevice device, string macName) + public void SetMacName(CommonDevice device, string macName) { device.DeviceName = macName; } @@ -1404,7 +1441,7 @@ /// <param name="device">璁惧瀵硅薄</param> /// <param name="epointName">绔偣鍚嶅瓧</param> /// <returns></returns> - private void SetEpointName(CommonDevice device, string epointName) + public void SetEpointName(CommonDevice device, string epointName) { device.DeviceEpointName = epointName; } @@ -1854,7 +1891,8 @@ info.ObjectTypeName = this.dicDeviceModelIdEnum["A418"].A绫诲瀷鍚嶅瓧;//璋冨厜妯″潡 } else if (info.BeloneType == DeviceBeloneType.A浼犳劅鍣� - || device.Type == DeviceType.TemperatureSensor) + || device.Type == DeviceType.TemperatureSensor + || device.Type == DeviceType.FreshAirHumiditySensor) { //浼犳劅鍣ㄥ悎骞� info.ConcreteType = DeviceConcreteType.Sensor; @@ -2159,12 +2197,6 @@ //闂ㄧ獥浼犳劅鍣� info.ConcreteType = DeviceConcreteType.Sensor_DoorWindow; info.ConcreteText = Language.StringByID(R.MyInternationalizationString.uSensorDoorWindow); - } - else if (iasZone.IasDeviceType == 541) - { - //鐞冨瀷绉诲姩浼犳劅鍣� - info.ConcreteType = DeviceConcreteType.Sensor_SphericalMotion; - info.ConcreteText = this.dicDeviceModelIdEnum["MSPIRB-ZB.10"].A瀹樻柟鍚嶅瓧; } } @@ -2563,7 +2595,7 @@ { if (this.dicDeviceModelIdEnum.ContainsKey(strKey) == false) { - return null; + return new DeviceNameContent(); } return this.dicDeviceModelIdEnum[strKey]; } @@ -2707,15 +2739,14 @@ listCheck.Add(mainkeys); //鍒锋柊涓�涓嬫湰鍦扮紦瀛� var localDevice = this.GetDevice(mainkeys); - if (localDevice != null) + var tempDevice = localDevice == null ? device : localDevice; + + //鍒锋柊灞炴�� + this.SetDeviceInfoToMain(tempDevice, device); + if (this.RefreshDeviceFunctionType(tempDevice, device, false) == true) { - //鍒锋柊灞炴�� - this.SetDeviceInfoToMain(localDevice, device); - if (this.RefreshDeviceFunctionType(localDevice, device, false) == true) - { - //闇�瑕佸彂閫佸姛鑳界被鍨嬬粰缃戝叧 - listFucDevice.Add(localDevice); - } + //闇�瑕佸彂閫佸姛鑳界被鍨嬬粰缃戝叧 + listFucDevice.Add(tempDevice); } } } @@ -2850,14 +2881,8 @@ /// <param name="device">璁剧疆婧愯澶囧璞�</param> public void SetDeviceInfoToMain(CommonDevice mainDevice, CommonDevice device) { - if (string.IsNullOrEmpty(device.DeviceInfo.MacName) == false) - { - mainDevice.DeviceName = device.DeviceInfo.MacName; - } - if (string.IsNullOrEmpty(device.DeviceInfo.DeviceName) == false) - { - mainDevice.DeviceEpointName = device.DeviceInfo.DeviceName; - } + mainDevice.DeviceName = device.DeviceInfo.MacName; + mainDevice.DeviceEpointName = device.DeviceInfo.DeviceName; mainDevice.CurrentGateWayId = device.CurrentGateWayId; mainDevice.ZigbeeType = device.DeviceInfo.ZigbeeType; mainDevice.IsOnline = device.DeviceInfo.IsOnline; @@ -2890,6 +2915,8 @@ mainDevice.InClusterList.AddRange(device.DeviceInfo.InClusterList); mainDevice.OutClusterList.Clear(); mainDevice.OutClusterList.AddRange(device.DeviceInfo.OutClusterList); + mainDevice.AttributeStatus.Clear(); + mainDevice.AttributeStatus.AddRange(device.DeviceInfo.AttributeStatus); //濡傛灉鏄俯搴︿紶鎰熷櫒 if (mainDevice.Type == DeviceType.TemperatureSensor) @@ -3178,18 +3205,18 @@ System.IO.StreamReader streamReader = null; var listText = new List<string>(); try - { -#if iOS - string textFile = Foundation.NSBundle.MainBundle.PathForResource("DeviceName.ini", null); - streamReader = new System.IO.StreamReader(textFile, Encoding.UTF8); + { +#if iOS + string textFile = Foundation.NSBundle.MainBundle.PathForResource("DeviceName.ini", null); + streamReader = new System.IO.StreamReader(textFile, Encoding.UTF8); string text; while ((text = streamReader.ReadLine()) != null) { listText.Add(text.Trim()); } - return listText; -#endif -#if Android + return listText; +#endif +#if Android var stream = Application.Activity.Assets.Open("DeviceName.ini"); streamReader = new System.IO.StreamReader(stream, Encoding.UTF8); string text; @@ -3217,10 +3244,10 @@ } } -#endregion + #endregion } -#region 鈻� 鑷畾涔夎澶囩被鍨媉________________________ + #region 鈻� 鑷畾涔夎澶囩被鍨媉________________________ /// <summary> /// <para>璁惧鐨勫叿浣撱�愯澶囩被鍨嬨��,鍙橀噺鍚嶅彲浠ヤ綔涓恒�愯澶囩被鍨嬨�戝浘鐗�,杩欎釜鍊兼槸鐬庡啓鐨�,娌′粈涔堢壒娈婃剰涔�</para> @@ -3371,6 +3398,10 @@ /// PM2.5绌烘皵璐ㄩ噺浼犳劅鍣� /// </summary> Sensor_PMTwoPointFive = 1307, + /// <summary> + /// 娓╂箍搴︿紶鎰熷櫒(杩欎釜鍗曡瘝鎷奸敊浜�,浣嗘槸閿欎簡灏遍敊浜嗗憲,灏辫繖鏍蜂簡) + /// </summary> + Sensor_TemperatureHumidity = 1308, /// <summary> /// 杩愬姩浼犳劅鍣� @@ -3381,11 +3412,7 @@ /// </summary> Sensor_Keyfob = -1307, /// <summary> - /// 娓╂箍搴︿紶鎰熷櫒 - /// </summary> - Sensor_TemperatureHumidity = -1308, - /// <summary> - /// 娓╁害浼犳劅鍣� + /// 娓╁害浼犳劅鍣�(杩欎釜鍗曡瘝鎷奸敊浜�,浣嗘槸閿欎簡灏遍敊浜嗗憲,灏辫繖鏍蜂簡) /// </summary> Sensor_Temperature = -1309, /// <summary> @@ -3595,5 +3622,5 @@ A骞叉帴鐐� = 16, } -#endregion + #endregion } -- Gitblit v1.8.0