From 48ba446936b51fffafa7c3600c0dadc6ac0e8c20 Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期五, 10 七月 2020 10:52:13 +0800 Subject: [PATCH] 2020-07-10-01 --- ZigbeeApp/Shared/Common/Device.cs | 562 ++++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 461 insertions(+), 101 deletions(-) diff --git a/ZigbeeApp/Shared/Common/Device.cs b/ZigbeeApp/Shared/Common/Device.cs index d9cddaa..bada159 100755 --- a/ZigbeeApp/Shared/Common/Device.cs +++ b/ZigbeeApp/Shared/Common/Device.cs @@ -123,12 +123,6 @@ if (device == null || device.CurrentGateWayId == null) { -#if DEBUG - //璋冩煡,涓轰粈涔堝畠浼氭妸鍏ㄩ儴璁惧鍒犳帀锛� - string file1 = UserCenterLogic.CombinePath(file); - string file2 = UserCenterLogic.CombinePath("Back_" + file); - System.IO.File.Copy(file1, file2, true); -#endif //澶辨晥鐨勬枃浠讹紝娌℃湁缃戝叧id鐨勯兘鍒犻櫎鎺� Global.DeleteFilebyHomeId(file); continue; @@ -143,12 +137,6 @@ } else { -#if DEBUG - //璋冩煡,涓轰粈涔堝畠浼氭妸鍏ㄩ儴璁惧鍒犳帀锛� - string file1 = UserCenterLogic.CombinePath(file); - string file2 = UserCenterLogic.CombinePath("Back_" + file); - System.IO.File.Copy(file1, file2, true); -#endif //濡傛灉鏄富浜�,鎴栬�呯鐞嗗憳,閭d箞杩欎釜鏂囦欢鏄潪娉曠殑,鐩存帴鍒犻櫎 Global.DeleteFilebyHomeId(file); continue; @@ -211,7 +199,7 @@ var listGateway = HdlGatewayLogic.Current.GetAllLocalGateway(); foreach (var gateway in listGateway) { - string gwId = HdlGatewayLogic.Current.GetGatewayId(gateway); + string gwId = gateway.GwId; if (listId.Contains(gwId) == false) { //杩欎釜缃戝叧瀵逛簬褰撳墠杩欎釜鎴愬憳鏉ヨ鏄潪娉曠殑 @@ -242,7 +230,7 @@ listDevice.AddRange(list); //鑾峰彇杩欎釜缃戝叧鐨勬湰鍦版墍鏈夎澶� - string gwID = HdlGatewayLogic.Current.GetGatewayId(zbGateway); + string gwID = zbGateway.GwId; List<CommonDevice> listLocalDevices = this.GetDeviceByGatewayID(gwID); //鑾峰彇ota璁惧 foreach (var ota in this.dicOTADevice.Values) @@ -292,9 +280,9 @@ //鍦ㄧ鐐瑰悕瀛楃殑鍚庨潰闄勫姞銆愬洖璺�戝瓧鏍� dName += "(" + device.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + ")"; - HdlThreadLogic.Current.RunThread(async () => + HdlThreadLogic.Current.RunThread(() => { - await this.ReName(device, dName, ShowErrorMode.NO); + this.ReName(device, dName, ShowErrorMode.NO); }); } } @@ -431,7 +419,7 @@ /// <param name="device">璁惧瀵硅薄</param> /// <param name="newName">鏂板悕瀛�</param> /// <param name="mode">鏄惁鏄剧ず閿欒</param> - public async Task<bool> ReName(CommonDevice device, string newName, ShowErrorMode mode = ShowErrorMode.YES) + public bool ReName(CommonDevice device, string newName, ShowErrorMode mode = ShowErrorMode.YES) { //鍏堝埆绠¢偅涔堝锛屾洿鏀瑰悕瀛楀悗锛屽埛鏂拌澶囩紦瀛� this.SetEpointName(device, newName); @@ -441,6 +429,8 @@ //濡傛灉浣忓畢涓鸿櫄鎷熶綇瀹� if (Common.Config.Instance.Home.IsVirtually == true) { + //淇敼璁惧鍚嶅瓧鐨勮瘽,涓婚〉闇�瑕侀噸鏂板埛鏂� + Phone.UserView.UserPage.Instance.RefreshForm = true; return true; } @@ -448,7 +438,7 @@ //鎴愬憳鍙兘淇敼鑷繁鏈湴鐨勫悕瀛� if (UserCenterResourse.UserInfo.AuthorityNo != 3) { - var result = await device.RenameDeviceNameAsync(device.DeviceAddr, device.DeviceEpoint, newName); + var result = this.RenameDeviceNameAsync(device, newName); if (result == null || result.deviceRenameData == null || result.deviceRenameData.Result == 1) { //璁惧鍚嶇О淇敼澶辫触 @@ -462,9 +452,9 @@ } return false; } - //澶囦唤鏁版嵁 - await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(device, GatewayBackupEnum.A绔偣鍚嶇О, newName); } + //淇敼璁惧鍚嶅瓧鐨勮瘽,涓婚〉闇�瑕侀噸鏂板埛鏂� + Phone.UserView.UserPage.Instance.RefreshForm = true; return true; } @@ -474,7 +464,7 @@ /// <param name="listDevice">璁惧瀵硅薄</param> /// <param name="newMacName">鏂板悕瀛�</param> /// <param name="mode">鏄惁鏄剧ず閿欒</param> - public async Task<bool> ReMacName(List<CommonDevice> listDevice, string newMacName, ShowErrorMode mode = ShowErrorMode.YES) + public bool ReMacName(List<CommonDevice> listDevice, string newMacName, ShowErrorMode mode = ShowErrorMode.YES) { if (listDevice.Count == 0) { @@ -502,7 +492,7 @@ if (UserCenterResourse.UserInfo.AuthorityNo != 3) { //淇敼鐗╃悊鍚嶅瓧 - var result = await device.RenameDeviceMacNameAsync(device.DeviceAddr, device.DeviceEpoint, newMacName); + var result = this.RenameDeviceMacNameAsync(device, newMacName); if (result == null || result.renameDeviceMacNameData == null || result.renameDeviceMacNameData.Result != 0) { //璁惧鍚嶇О淇敼澶辫触 @@ -515,15 +505,13 @@ } return false; } - //澶囦唤鏁版嵁 - await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(device, GatewayBackupEnum.AMac鍚嶇О, newMacName); //濡傛灉瀹冨彧鏈変竴涓洖璺�,鍒欐洿鏀圭鐐瑰悕瀛� if (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == true) { //鍙湁涓�涓鐐� if (this.dicDeviceEpoint[device.DeviceAddr].Count == 1) { - return await this.ReName(device, newMacName); + return this.ReName(device, newMacName); } //濡傛灉瀹冩湁涓や釜绔偣鏃�,pir浼犳劅鍣ㄧ壒娈婂鐞� else if (this.dicDeviceEpoint[device.DeviceAddr].Count == 2) @@ -535,7 +523,7 @@ { if (myDevice.Type == DeviceType.IASZone) { - return await this.ReName(myDevice, newMacName); + return this.ReName(myDevice, newMacName); } } } @@ -543,6 +531,100 @@ } } return true; + } + + ///<summary > + /// 淇敼璁惧mac鍚嶇О + /// <para>macName:璁惧鍚嶇О</para> + /// </summary> + private CommonDevice.RenameDeviceMacNameAllData RenameDeviceMacNameAsync(CommonDevice device, string macName) + { + //濡傛灉褰撳墠鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + return Phone.ModelData.DeviceModelDataLogic.Current.ReDeviceMacName(device, macName, "MacRename"); + } + + //鑾峰彇缂栬緫璁惧Mac鍚嶅瓧鐨勫懡浠ゅ瓧绗� + var sendData = this.GetReDeviceMacNameCommandText(device.DeviceAddr, device.DeviceEpoint, macName); + var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "MacRename", sendData, "MacRename_Respon"); + if (result.ErrorMsg != null || result.ErrorMsgDiv == 0) + { + return null; + } + //鍔犵紦瀛� + Phone.ModelData.DeviceModelDataLogic.Current.ReDeviceMacName(device, macName, "MacRename"); + + var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.RenameDeviceMacNameData>(result.ReceiptData); + return new CommonDevice.RenameDeviceMacNameAllData { renameDeviceMacNameData = tempData }; + } + + /// <summary> + /// 淇敼璁惧绔彛锛堟寜閿級鍚嶇О + /// </summary> + /// <param name="device">璁惧瀵硅薄</param> + /// <param name="deviceName">璁惧绔偣鍚嶅瓧</param> + /// <returns></returns> + private CommonDevice.DeviceRenameAllData RenameDeviceNameAsync(CommonDevice device, string deviceName) + { + //濡傛灉褰撳墠鏄櫄鎷熶綇瀹� + if (Common.Config.Instance.Home.IsVirtually == true) + { + return Phone.ModelData.DeviceModelDataLogic.Current.ReDeviceEpointName(device, deviceName, "DeviceRename"); + } + //鑾峰彇缂栬緫璁惧绔偣鍚嶅瓧鐨勫懡浠ゅ瓧绗� + var sendData = this.GetReDeviceEpointNameCommandText(device.DeviceAddr, device.DeviceEpoint, deviceName); + var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "DeviceRename", sendData, "DeviceRenameRespon"); + if (result.ErrorMsg != null || result.ErrorMsgDiv == 0) + { + return null; + } + //鍔犵紦瀛� + Phone.ModelData.DeviceModelDataLogic.Current.ReDeviceEpointName(device, deviceName, "DeviceRename"); + + var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.DeviceRenameResponseData>(result.ReceiptData); + return new CommonDevice.DeviceRenameAllData { deviceRenameData = tempData }; + } + + /// <summary> + /// 鑾峰彇缂栬緫璁惧Mac鍚嶅瓧鐨勫懡浠ゅ瓧绗� + /// </summary> + /// <param name="deviceAddr"></param> + /// <param name="deviceEpoint"></param> + /// <param name="deviceName"></param> + /// <returns></returns> + public string GetReDeviceMacNameCommandText(string deviceAddr, int deviceEpoint, string deviceName) + { + 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 Newtonsoft.Json.Linq.JObject { { "DeviceAddr", deviceAddr }, { "Epoint", deviceEpoint }, { "Cluster_ID", 0 }, { "Command", 100 } }; + var data = new Newtonsoft.Json.Linq.JObject { { "MacName", deviceName } }; + jObject.Add("Data", data); + return jObject.ToString(); + } + + /// <summary> + /// 鑾峰彇缂栬緫璁惧绔偣鍚嶅瓧鐨勫懡浠ゅ瓧绗� + /// </summary> + /// <param name="deviceAddr"></param> + /// <param name="deviceEpoint"></param> + /// <param name="deviceName"></param> + /// <returns></returns> + public string GetReDeviceEpointNameCommandText(string deviceAddr, int deviceEpoint, string deviceName) + { + 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 Newtonsoft.Json.Linq.JObject { { "DeviceAddr", deviceAddr }, { "Epoint", deviceEpoint }, { "Cluster_ID", 0 }, { "Command", 96 } }; + var data = new Newtonsoft.Json.Linq.JObject { { "DeviceName", deviceName } }; + jObject.Add("Data", data); + + return jObject.ToString(); } /// <summary> @@ -586,22 +668,26 @@ /// <param name="listdevice">璁惧瀵硅薄(MAC鍦板潃蹇呴』瑕佺浉鍚�)</param> public async Task<bool> DeleteDevice(List<CommonDevice> listdevice) { - var data = new CommonDevice.RemoveDeviceData(); - var info = new CommonDevice.RemoveDeviceListInfo(); - info.DeviceAddr = listdevice[0].DeviceAddr; - data.DeviceAddrList.Add(info); - - //鍒犱竴娆$殑鏃跺�欙紝瀹冧細鎶奙AC鍦板潃涓嬮潰鍏ㄩ儴鐨勮澶囬兘鍒犻櫎 - var result = await listdevice[0].DeleteDeviceAsync(data); - if (result == null || result.removeDeviceResponseData == null || result.removeDeviceResponseData.Result != 0) + //铏氭嫙浣忓畢鐨勮瘽,涓嶉渶瑕佸垹闄ょ綉鍏崇殑璁惧 + if (Config.Instance.Home.IsVirtually == false) { - //璁惧鍒犻櫎澶辫触 - string msg = Language.StringByID(R.MyInternationalizationString.uDeviceDeleteFail); - //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg - msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result); + var data = new CommonDevice.RemoveDeviceData(); + var info = new CommonDevice.RemoveDeviceListInfo(); + info.DeviceAddr = listdevice[0].DeviceAddr; + data.DeviceAddrList.Add(info); - this.ShowErrorMsg(msg); - return false; + //鍒犱竴娆$殑鏃跺�欙紝瀹冧細鎶奙AC鍦板潃涓嬮潰鍏ㄩ儴鐨勮澶囬兘鍒犻櫎 + var result = await listdevice[0].DeleteDeviceAsync(data); + if (result == null || result.removeDeviceResponseData == null || result.removeDeviceResponseData.Result != 0) + { + //璁惧鍒犻櫎澶辫触 + string msg = Language.StringByID(R.MyInternationalizationString.uDeviceDeleteFail); + //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg + msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result); + + this.ShowErrorMsg(msg); + return false; + } } //鍒犻櫎缂撳瓨鐨凮ta璁惧 @@ -628,6 +714,9 @@ /// <param name="deleteRoom">鏄惁浠庢埧闂村垹闄�</param> public void DeleteMemmoryDevice(CommonDevice device, bool deleteRoom = true) { + //鍒犻櫎缂撳瓨璁惧鐨勮瘽,涓婚〉闇�瑕侀噸鏂板埛鏂� + Phone.UserView.UserPage.Instance.RefreshForm = true; + if (deleteRoom == true) { //浠庢埧闂翠腑鍒犻櫎 @@ -725,7 +814,7 @@ /// <returns></returns> public bool DeviceIsCanFixedPosition(CommonDevice device) { - if (device.Type == DeviceType.DoorLock) + if (device.Type == DeviceType.DoorLock || device.Type == DeviceType.PMSensor) { //闂ㄩ攣娌℃湁瀹氫綅鍔熻兘 return false; @@ -882,6 +971,47 @@ } /// <summary> + /// 鏍规嵁MAC鍦板潃,鑾峰彇绠�绾﹂潰鏉垮叏閮ㄥ洖璺殑璁惧瀵硅薄 + /// </summary> + /// <param name="listDevice"></param> + /// <returns></returns> + public List<CommonDevice> GetMutilfunctionPanelByMac(List<CommonDevice> listDevice, bool sort = true) + { + //鍜屽姜鍝ャ�佽澶囧拰浜у搧閮ㄥ悓浜嬬‘璁わ細 + //绠�绾﹀鍔熻兘闈㈡澘[涓嶆樉绀哄浣欑殑鍥炶矾锛屽彧鏄剧ず鎼哄甫鐨�2涓户鐢靛櫒鍜�1涓俯婀垮害浼犳劅鍣� + var list = new List<CommonDevice>(); + foreach (var dev in listDevice) + { + if (dev.Type == DeviceType.TemperatureSensor) + { + if (dev.DeviceEpoint == 64) + { + list.Add(dev); + } + } + else if (dev.Type == DeviceType.OnOffOutput) + { + list.Add(dev); + } + } + + if (sort == false) + { + return list; + } + list.Sort((obj1, obj2) => + { + if (obj1.DeviceEpoint > obj2.DeviceEpoint) + { + return 1; + } + return -1; + }); + + return list; + } + + /// <summary> /// 鏍规嵁MAC鍦板潃,鑾峰彇鍏ㄩ儴鍥炶矾鐨勮澶囧璞�(寮哄埗鎺掑簭) /// </summary> /// <param name="DeviceAddr">Mac鍦板潃</param> @@ -1010,6 +1140,12 @@ { return dName; } + if (this.IsMiniLight(device) == true) + { + //Mini澶滅伅 + return Language.StringByID(R.MyInternationalizationString.uMiniNightLight); + } + //濡傛灉杩欎釜璁惧鍙湁涓�涓洖璺殑璇�,杩斿洖Mac鍚嶅瓧缁欏畠 if (this.GetDevicesCountByMac(device.DeviceAddr) <= 1) { @@ -1034,7 +1170,9 @@ } if (device.Type == DeviceType.OnOffOutput - || device.Type == DeviceType.DimmableLight || device.Type == DeviceType.ColorDimmableLight) + || device.Type == DeviceType.DimmableLight + || device.Type == DeviceType.ColorDimmableLight + || device.Type == DeviceType.ColorTemperatureLight) { //缁х數鍣�,鎺夊厜鍣ㄩ兘鍙洖璺� return Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + epointNo; @@ -1098,6 +1236,11 @@ if (string.IsNullOrEmpty(dName) == false) { return dName; + } + if (this.IsMiniLight(device) == true) + { + //Mini澶滅伅 + return Language.StringByID(R.MyInternationalizationString.uMiniNightLight); } //鑾峰彇璁惧绫诲瀷 @@ -1324,7 +1467,7 @@ } /// <summary> - /// 璁剧疆銆愯澶囩被鍨嬨�戠殑鍥炬爣鍒版寚瀹氱殑鎺т欢 + /// 璁剧疆銆愯澶囩被鍨嬨�戠殑鍥炬爣鍒版寚瀹氱殑鎺т欢(姝ゆ柟娉曚笉鑳界敤鍦ㄨ澶囧姛鑳界被鍨嬭彍鍗曠殑鍥炬爣) /// </summary> /// <param name="btnIcon">鎺т欢瀵硅薄</param> /// <param name="listdevice">璁惧瀵硅薄</param> @@ -1346,7 +1489,7 @@ } /// <summary> - /// 鑾峰彇銆愯澶囩被鍨嬨�戠殑鍥炬爣 + /// 鑾峰彇銆愯澶囩被鍨嬨�戠殑鍥炬爣(姝ゆ柟娉曚笉鑳界敤鍦ㄨ澶囧姛鑳界被鍨嬭彍鍗曠殑鍥炬爣) /// </summary> /// <param name="listdevice">璁惧瀵硅薄</param> /// <param name="unSelectPath">鍥剧墖鍦板潃</param> @@ -1362,13 +1505,42 @@ } /// <summary> - /// 鑾峰彇銆愯澶囩被鍨嬨�戠殑鍥炬爣 + /// 鑾峰彇銆愯澶囧姛鑳界被鍨嬨�戠殑鑿滃崟鍥炬爣 /// </summary> /// <param name="specificType">鑷畾涔夎澶囩被鍨�</param> /// <param name="unSelectPath">鍥剧墖鍦板潃</param> /// <param name="selectPath">鍥剧墖鍦板潃</param> /// <returns></returns> - public void GetDeviceObjectIcon(DeviceConcreteType specificType, ref string unSelectPath, ref string selectPath) + public void GetDeviceFunctionTypeMenuIcon(DeviceConcreteType specificType, ref string unSelectPath, ref string selectPath) + { + //鏂伴灏忔ā鍧� + if (specificType == DeviceConcreteType.Relay_FangyueFreshAirModul) + { + unSelectPath = "Device/FreshAirEpoint.png"; + selectPath = "Device/FreshAirEpointSelected.png"; + return; + } + //PM2.5绌烘皵璐ㄩ噺浼犳劅鍣� + else if (specificType == DeviceConcreteType.Sensor_PMTwoPointFive) + { + unSelectPath = "Device/AirQualitySensorEpoint.png"; + selectPath = "Device/AirQualitySensorEpointSelected.png"; + return; + } + //涓婇潰闇�瑕佺壒娈婂鐞� + + //鑾峰彇銆愯澶囩被鍨嬨�戠殑鍥炬爣 + this.GetDeviceObjectIcon(specificType, ref unSelectPath, ref selectPath); + } + + /// <summary> + /// 鑾峰彇銆愯澶囩被鍨嬨�戠殑鍥炬爣 2020.05.13:娆″嚱鏁颁笉鍐嶅叕寮� + /// </summary> + /// <param name="specificType">鑷畾涔夎澶囩被鍨�</param> + /// <param name="unSelectPath">鍥剧墖鍦板潃</param> + /// <param name="selectPath">鍥剧墖鍦板潃</param> + /// <returns></returns> + private void GetDeviceObjectIcon(DeviceConcreteType specificType, ref string unSelectPath, ref string selectPath) { //灏嗗叿浣撶被鍨嬭浆瀛楃涓� string strSpecific = Enum.GetName(typeof(DeviceConcreteType), specificType); @@ -1811,6 +1983,22 @@ info.ConcreteType = DeviceConcreteType.Relay_FangyueFreshAirModul; info.ObjectTypeNameId = 60011;//鏂伴 } + //15 PM2.5浼犳劅鍣ㄨ澶� + else if (dicType.ContainsKey(DeviceType.PMSensor) == true) + { + info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId1307; + info.BeloneType = DeviceBeloneType.APM2鐐�5绌烘皵璐ㄩ噺浼犳劅鍣�; + info.ConcreteType = DeviceConcreteType.Sensor_PMTwoPointFive; + info.ObjectTypeNameId = 60000;//浼犳劅鍣� + } + //16鑹叉俯鐏� + else if (dicType.ContainsKey(DeviceType.ColorTemperatureLight) == true) + { + info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId20000; + info.BeloneType = DeviceBeloneType.A褰╃伅; + info.ConcreteType = DeviceConcreteType.ColorLight_Temperature; + info.ObjectTypeNameId = 60007;//璋冨厜妯″潡 + } int value = (int)info.BeloneType; if (dicDeviceAllNameID.ContainsKey("uDeviceBelongId" + value) == true) @@ -1909,26 +2097,10 @@ /// <param name="saveRoadDevice">濡傛灉鍙湁涓�涓洖璺�,鏄惁鎶婂洖璺殑鎴块棿涓�璧蜂慨鏀�</param> public void SaveRealDeviceRoomId(List<CommonDevice> listDevice, string roomId, bool saveRoadDevice = true) { - if (listDevice != null) + if (listDevice == null) { - if (roomId == string.Empty) - { - //閫夋嫨鐨勬槸鏈垎閰� - this.dicDeviceRoomId.Remove(listDevice[0].DeviceAddr); - } - else - { - this.dicDeviceRoomId[listDevice[0].DeviceAddr] = roomId; - } + return; } - - //淇濆瓨璁板綍 - string fullName = UserCenterLogic.CombinePath(DirNameResourse.DeviceRoomIdFile); - UserCenterLogic.SaveFileContent(fullName, this.dicDeviceRoomId); - - //娣诲姞鑷姩澶囦唤 - HdlAutoBackupLogic.AddOrEditorFile(DirNameResourse.DeviceRoomIdFile); - //濡傛灉璁惧鍙湁涓�涓洖璺紝濡傛灉鏀瑰彉浜嗙湡瀹炶澶囧尯鍩燂紝鍒欏畠鐨勫洖璺殑鍖哄煙涔熶竴璧锋敼浜� if (saveRoadDevice == true && listDevice != null && listDevice.Count == 1) { @@ -1938,6 +2110,41 @@ return; } HdlRoomLogic.Current.ChangedRoom(listDevice[0], roomId, false); + } + bool save = false; + if (roomId == string.Empty) + { + //閫夋嫨鐨勬槸鏈垎閰� + this.dicDeviceRoomId.Remove(listDevice[0].DeviceAddr); + save = true; + } + else + { + if (this.dicDeviceRoomId.ContainsKey(listDevice[0].DeviceAddr) == false) + { + this.dicDeviceRoomId[listDevice[0].DeviceAddr] = roomId; + save = true; + } + else + { + //2020.05.18杩藉姞:濡傛灉璁板綍鐨勬埧闂碔D鏄笉瀛樺湪鐨勮瘽,鍒欓噸鏂拌鐩� + var room = HdlRoomLogic.Current.GetRoomById(this.dicDeviceRoomId[listDevice[0].DeviceAddr]); + if (room == null || this.dicDeviceRoomId[listDevice[0].DeviceAddr] != roomId) + { + this.dicDeviceRoomId[listDevice[0].DeviceAddr] = roomId; + save = true; + } + } + } + + if (save == true) + { + //淇濆瓨璁板綍 + string fullName = UserCenterLogic.CombinePath(DirNameResourse.DeviceRoomIdFile); + UserCenterLogic.SaveFileContent(fullName, this.dicDeviceRoomId); + + //娣诲姞鑷姩澶囦唤 + HdlAutoBackupLogic.AddOrEditorFile(DirNameResourse.DeviceRoomIdFile); } } @@ -1987,9 +2194,19 @@ /// <param name="listMac">璁惧Mac鍦板潃</param> public void DeleteRealDeviceFromRoom(List<string> listMac) { + bool save = false; foreach (var deviceMacAddr in listMac) { - this.dicDeviceRoomId.Remove(deviceMacAddr); + if (this.dicDeviceRoomId.ContainsKey(deviceMacAddr) == true) + { + this.dicDeviceRoomId.Remove(deviceMacAddr); + save = true; + } + } + if (save == false) + { + //娌℃湁鏀瑰彉,涓嶉渶瑕佷繚瀛� + return; } //淇濆瓨璁板綍 string fullName = UserCenterLogic.CombinePath(DirNameResourse.DeviceRoomIdFile); @@ -1997,6 +2214,25 @@ //娣诲姞鑷姩澶囦唤 HdlAutoBackupLogic.AddOrEditorFile(DirNameResourse.DeviceRoomIdFile); + } + + /// <summary> + /// 鏍规嵁鎴块棿ID,绉婚櫎鎸囧畾鐨勭湡瀹炵墿鐞嗚澶囩殑鎵�灞炴埧闂磋褰� + /// </summary> + /// <param name="i_RoomId"></param> + public void DeleteRealDeviceByRoomId(string i_RoomId) + { + var listDeleteKey = new List<string>(); + foreach (var deviceAddr in this.dicDeviceRoomId.Keys) + { + if (this.dicDeviceRoomId[deviceAddr] == i_RoomId + && listDeleteKey.Contains(deviceAddr) == false) + { + listDeleteKey.Add(deviceAddr); + } + } + //灏嗙湡瀹炵墿鐞嗚澶囦粠鎴块棿涓Щ闄� + this.DeleteRealDeviceFromRoom(listDeleteKey); } #endregion @@ -2060,6 +2296,7 @@ list.Add(DeviceBeloneType.A鎻掑骇); list.Add(DeviceBeloneType.A璋冨厜鍣�); list.Add(DeviceBeloneType.A绐楀笜); + list.Add(DeviceBeloneType.A鏂伴); list.Add(DeviceBeloneType.A绌鸿皟); list.Add(DeviceBeloneType.A缁х數鍣�); list.Add(DeviceBeloneType.A骞叉帴鐐�); @@ -2075,7 +2312,61 @@ #endregion + #region 鈻� 鑾峰彇璁惧鍦ㄧ嚎鐘舵�佸垪琛╛______________ + + /// <summary> + /// 鑾峰彇璁惧鍦ㄧ嚎鐘舵�佸垪琛�(娉ㄦ剰,涓�涓澶囧彧杩斿洖涓�涓洖璺�) + /// </summary> + /// <param name="gwId">缃戝叧id</param> + /// <returns></returns> + public List<CommonDevice> GetDeviceOnlineList(string gwId) + { + var zbway = HdlGatewayLogic.Current.GetLocalGateway(gwId); + int statu = 0; + var listDevice = this.GetDeviceListFromGateway(zbway, ref statu, false, ShowErrorMode.NO); + if (statu == -1) + { + //褰撳嚭鐜板紓甯告椂,浣跨敤鍚庡鎿嶄綔,鐩存帴鑾峰彇鏈湴鐨勮澶囧垪琛� + listDevice = this.GetDeviceByGatewayID(gwId); + } + + var listCheck = new HashSet<string>(); + var listReturn = new List<CommonDevice>(); + foreach (var device in listDevice) + { + if (listCheck.Contains(device.DeviceAddr) == false) + { + listCheck.Add(device.DeviceAddr); + listReturn.Add(device); + } + } + return listReturn; + } + + #endregion + #region 鈻� 涓�鑸柟娉昣__________________________ + + /// <summary> + /// 浠庣紦瀛樺彉閲忔娴嬭澶囨槸鍚﹀湪绾� + /// </summary> + /// <param name="i_device"></param> + /// <returns></returns> + public bool CheckDeviceIsOnline(CommonDevice i_device) + { + var listDevice = this.GetDevicesByMac(i_device.DeviceAddr, false); + foreach (var device in listDevice) + { + //0:绂荤嚎 1:鍦ㄧ嚎 2:姝e湪鍒锋柊鐘舵�� + bool statu = i_device.IsOnline == 1 || i_device.IsOnline == 2; + if (statu == true) + { + //鏈変竴涓洖璺湪绾�,鍗冲湪绾� + return true; + } + } + return false; + } /// <summary> /// 鍒ゆ柇璇ヨ澶囨槸鍚﹀彲浠ユ樉绀哄湪涓婚〉 @@ -2092,7 +2383,8 @@ if (i_device.Type == DeviceType.OnOffOutput || i_device.Type == DeviceType.AirSwitch) { //2020.03.23杩藉姞寮忔牱:鏈寚瀹氱被鍨嬬殑缁х數鍣�,涓嶆樉绀� - if (i_device.DfunctionType == DeviceFunctionType.A鏈畾涔�) + if (i_device.DfunctionType == DeviceFunctionType.A鏈畾涔� + || i_device.DfunctionType == DeviceFunctionType.A涓嶆寚瀹�) { return false; } @@ -2115,6 +2407,11 @@ return false; } } + else if (i_device.Type == DeviceType.FreshAirHumiditySensor) + { + //鏂伴鐨勬箍搴︿紶鎰熷櫒涓嶆樉绀� + return false; + } return true; } @@ -2126,6 +2423,16 @@ public bool IsHdlDevice(CommonDevice device) { return device.ManufacturerName == "HDL"; + } + + /// <summary> + /// 鏄惁鏄疢ini澶滅伅 + /// </summary> + /// <param name="device"></param> + /// <returns></returns> + public bool IsMiniLight(CommonDevice device) + { + return device.DriveCode != 0 && device.Type == DeviceType.ColorTemperatureLight; } /// <summary> @@ -2172,16 +2479,22 @@ /// <returns></returns> public string AppendVersion(int versionValue) { + //10101 3涓猙yte 鏄剧ず涓猴細ver.1.01.01 + //涓棿閭d釜byte涓哄鏁版椂锛屼唬琛ㄦ槸娴嬭瘯鐗堟湰,鍦ㄦ樉绀烘渶鏂扮増鏈椂,涓嶉渶瑕佹樉绀猴紝浣嗘槸鍦ㄥ巻鍙茬増鏈偅閲屽彲浠ユ樉绀� + //涓棿閭d釜byte涓哄伓鏁版椂, 浠h〃鏄寮忕増鏈� + //鐩存帴鏄�10杩涘埗 - string txt10 = Convert.ToString(versionValue).PadLeft(4, '0'); - //杩欎釜鏄皬鏁扮偣鍓嶉潰鐨勫�� - int value1 = Convert.ToInt32(txt10.Substring(0, txt10.Length - 2)); - //杩欎釜鏄皬鏁扮偣鍚庨潰鐨勫�� - int value2 = Convert.ToInt32(txt10.Substring(txt10.Length - 2, 2)); + string txt10 = Convert.ToString(versionValue).PadLeft(6, '0'); + //杩欎釜鏄涓�浣� + int value1 = Convert.ToInt32(txt10.Substring(0, 2)); + //杩欎釜鏄浜屼綅 + string value2 = txt10.Substring(2, 2); + //杩欎釜鏄涓変綅 + string value3 = txt10.Substring(4, 2); //Ver. string ver = Language.StringByID(R.MyInternationalizationString.uVersionAbbreviation); - return ver + value1 + "." + value2.ToString().PadLeft(2, '0'); + return ver + value1 + "." + value2 + "." + value3; } /// <summary> @@ -2233,7 +2546,7 @@ { //涓嶆棤瑙嗘椂闂�,杩斿洖鏈湴璁惧鍒楄〃 statu = 1; - return this.GetDeviceByGatewayID(HdlGatewayLogic.Current.GetGatewayId(zbGateway)); + return this.GetDeviceByGatewayID(zbGateway.GwId); } } zbGateway.LastDateTime = DateTime.Now; @@ -2257,7 +2570,7 @@ //鏄惁杈炬垚涓柇鐨勬椂鏈� bool canBreak = false; //缃戝叧ID - string gatewayID = HdlGatewayLogic.Current.GetGatewayId(zbGateway); + string gatewayID = zbGateway.GwId; //瓒呮椂鏃堕棿 int TimeOut = 0; //璁惧鎬绘暟 @@ -2304,8 +2617,14 @@ if (listCheck.Contains(mainkeys) == false) { listDevice.Add(device); - listCheck.Add(mainkeys); + //鍒锋柊涓�涓嬫湰鍦扮紦瀛� + var localDevice = this.GetDevice(mainkeys); + if (localDevice != null) + { + //鍒锋柊灞炴�� + this.SetDeviceInfoToMain(localDevice, device); + } } } } @@ -2388,7 +2707,7 @@ /// <returns></returns> private CommonDevice NewDeviceObjectByDeviceId(DeviceType deviceType, Newtonsoft.Json.Linq.JObject jobject, ZbGateway zbGateway) { - string gwId = HdlGatewayLogic.Current.GetGatewayId(zbGateway); + string gwId = zbGateway.GwId; //鏍规嵁璁惧绫诲瀷鍒涘缓璁惧瀵硅薄鐨勫疄渚� CommonDevice device = this.NewDeviceObjectByDeviceId(deviceType); @@ -2432,6 +2751,7 @@ mainDevice.DeviceEpointName = device.DeviceInfo.DeviceName; } mainDevice.CurrentGateWayId = device.CurrentGateWayId; + mainDevice.ZigbeeType = device.DeviceInfo.ZigbeeType; mainDevice.IsOnline = device.DeviceInfo.IsOnline; mainDevice.DriveCode = device.DeviceInfo.DriveCode; mainDevice.IasDeviceType = device.DeviceInfo.DeviceType; @@ -2455,8 +2775,6 @@ 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) @@ -2483,11 +2801,21 @@ mainDevice.IconPath = "Device/Light.png"; } } + //濡傛灉鏄壊娓╃伅 + else if (mainDevice.Type == DeviceType.ColorTemperatureLight) + { + mainDevice.DfunctionType = DeviceFunctionType.A鐏厜; + if (mainDevice.IsCustomizeImage == false) + { + mainDevice.IconPath = "Device/ColorLightTemperature.png"; + } + } //濡傛灉鏄笁璺户鐢靛櫒鐨勫洖璺殑璇�,榛樿涓虹伅鍏� else if (mainDevice.Type == DeviceType.OnOffOutput) { - var myType = this.GetHdlMyDeviceEnumInfo(mainDevice); - if (myType != null && myType.ConcreteType == DeviceConcreteType.Relay_ThreeLoad) + //2020.05.13鍙樻洿:缁х數鍣ㄩ兘榛樿涓虹伅鍏� + //var myType = this.GetHdlMyDeviceEnumInfo(mainDevice); + //if (myType != null && myType.ConcreteType == DeviceConcreteType.Relay_ThreeLoad) { if (mainDevice.DfunctionType == DeviceFunctionType.A鏈畾涔�) { @@ -2545,7 +2873,10 @@ else if (deviceType == DeviceType.FreshAir) { device = new FreshAir(); } else if (deviceType == DeviceType.DoorLock) { device = new DoorLock(); } else if (deviceType == DeviceType.TemperatureSensor) { device = new TemperatureSensor(); } + else if (deviceType == DeviceType.PMSensor) { device = new PMSensor(); } else if (deviceType == DeviceType.FreshAirHumiditySensor) { device = new HumiditySensor(); } + else if (deviceType == DeviceType.ColorTemperatureLight) { device = new ColorTemperatureLight(); } + else if (deviceType == DeviceType.Buzzer) { device = new Buzzer(); } else if (deviceType == DeviceType.OtaDevice || deviceType == DeviceType.OtaPanelDevice) { device = new OTADevice(); } else { return null; } @@ -2563,11 +2894,9 @@ public void SetNewDeviceMainKeys(CommonDevice device, Newtonsoft.Json.Linq.JObject jobject) { //璁剧疆璁惧涓婚敭绫� - device.Time = jobject.Value<int>("Time"); device.DeviceID = jobject.Value<int>("Device_ID"); device.DeviceAddr = jobject.Value<string>("DeviceAddr"); device.DeviceEpoint = jobject.Value<int>("Epoint"); - device.DataID = jobject.Value<int>("Data_ID"); } #endregion @@ -2630,25 +2959,32 @@ this.dicDeviceModelIdEnum["MPFA/TILE-ZB.18"] = "250-200-60003";//鏂规偊鏂伴闈㈡澘 this.dicDeviceModelIdEnum["MPTE3/TILE-ZB.18"] = "253-200-60003";//鏂规偊鐜闈㈡澘 this.dicDeviceModelIdEnum["MP2W/TILE-ZB.18"] = "256-200-60003";//绐楀笜闈㈡澘 + this.dicDeviceModelIdEnum["MPTL4C/S-ZB.18"] = "212-200-60003";//绠�绾﹀鍔熻兘闈㈡澘 + this.dicDeviceModelIdEnum["MPTE3/S-ZB.18"] = "230-200-60003";//绠�绾︾幆澧冮潰鏉� + //=========鈽呪槄PIR浼犳劅鍣ㄧ被(1200-1299)鈽呪槄========= this.dicDeviceModelIdEnum["MSPIR01-ZB.10"] = "1200-1200-60000";//pir浼犳劅鍣�220 //=========鈽呪槄瀹夐槻绫讳紶鎰熷櫒绫�(1300-2299)鈽呪槄========= //杩欓噷鏄害涔愬厠鐨� - this.dicDeviceModelIdEnum["MULTI-GASE--EA07"] = "1300-1300-60000";//鐕冩皵浼犳劅鍣� - this.dicDeviceModelIdEnum["MULTI-MECI--EA01"] = "1301-1300-60000";//闂ㄧ獥纾佷紶鎰熷櫒 - this.dicDeviceModelIdEnum["MULTI-FIRE--EA05"] = "1302-1300-60000";//鐑熼浘浼犳劅鍣� - this.dicDeviceModelIdEnum["MULTI-MOTI--EA04"] = "1303-1300-60000";//绾㈠浼犳劅鍣� - this.dicDeviceModelIdEnum["MULTI-WATE--EA02"] = "1304-1300-60000";//姘存蹈浼犳劅鍣� - this.dicDeviceModelIdEnum["MULTI-BURO--EA06"] = "1305-1300-60000";//绱ф�ユ寜閿� + this.dicDeviceModelIdEnum["MULTI-GASE--EA07"] = "1300-1200-60000";//鐕冩皵浼犳劅鍣� + this.dicDeviceModelIdEnum["MULTI-MECI--EA01"] = "1301-1200-60000";//闂ㄧ獥纾佷紶鎰熷櫒 + this.dicDeviceModelIdEnum["MULTI-FIRE--EA05"] = "1302-1200-60000";//鐑熼浘浼犳劅鍣� + this.dicDeviceModelIdEnum["MULTI-MOTI--EA04"] = "1303-1200-60000";//绾㈠浼犳劅鍣� + this.dicDeviceModelIdEnum["MULTI-WATE--EA02"] = "1304-1200-60000";//姘存蹈浼犳劅鍣� + this.dicDeviceModelIdEnum["MULTI-BURO--EA06"] = "1305-1200-60000";//绱ф�ユ寜閿� //杩欓噷鏄渤涓滅殑 - this.dicDeviceModelIdEnum["MSG01/M-ZB.10"] = "1300-1300-60000";//鐕冩皵浼犳劅鍣� - this.dicDeviceModelIdEnum["MSDC01/M-ZB.10"] = "1301-1300-60000";//闂ㄧ獥纾佷紶鎰熷櫒 - this.dicDeviceModelIdEnum["MSS01/M-ZB.10"] = "1302-1300-60000";//鐑熼浘浼犳劅鍣� - this.dicDeviceModelIdEnum["MSPIR01/M-ZB.10"] = "1303-1300-60000";//绾㈠浼犳劅鍣� - this.dicDeviceModelIdEnum["MSW01/M-ZB.10"] = "1304-1300-60000";//姘存蹈浼犳劅鍣� - this.dicDeviceModelIdEnum["MBU01/M-ZB.10"] = "1305-1300-60000";//绱ф�ユ寜閿� + this.dicDeviceModelIdEnum["MSG01/M-ZB.10"] = "1300-1200-60000";//鐕冩皵浼犳劅鍣� + this.dicDeviceModelIdEnum["MSDC01/M-ZB.10"] = "1301-1200-60000";//闂ㄧ獥纾佷紶鎰熷櫒 + this.dicDeviceModelIdEnum["MSS01/M-ZB.10"] = "1302-1200-60000";//鐑熼浘浼犳劅鍣� + this.dicDeviceModelIdEnum["MSPIR01/M-ZB.10"] = "1303-1200-60000";//绾㈠浼犳劅鍣� + this.dicDeviceModelIdEnum["MSW01/M-ZB.10"] = "1304-1200-60000";//姘存蹈浼犳劅鍣� + this.dicDeviceModelIdEnum["MBU01/M-ZB.10"] = "1305-1200-60000";//绱ф�ユ寜閿� + this.dicDeviceModelIdEnum["MGCD01/M-ZB.10"] = "1306-1200-60000";//鍚搁《鐕冩皵浼犳劅鍣� + + //PM2.5绌烘皵璐ㄩ噺浼犳劅鍣� 銆愯璁惧灞炰簬绗笁鏂硅澶囷紝娌℃湁闀滃儚ID銆� + this.dicDeviceModelIdEnum["MSPM25/M-ZB.10"] = "1307-1200-60000";//PM2.5绌烘皵璐ㄩ噺浼犳劅鍣� //=========鈽呪槄缁х數鍣ㄧ被(2300-2499)鈽呪槄========= this.dicDeviceModelIdEnum["MPR0310-ZB.10"] = "2300-2300-60001";//3璺户鐢靛櫒灏忔ā鍧� @@ -2695,9 +3031,8 @@ this.dicPictrueShard["ButtonPanel_SimpleFour"] = "ButtonPanel_Four";//绠�绾�4鎸夐敭闈㈡澘 娌跨敤 4鎸夐敭鐨勫浘鏍� this.dicPictrueShard["ButtonPanel_SimpleThree"] = "ButtonPanel_Three";//绠�绾�3鎸夐敭闈㈡澘 娌跨敤 3鎸夐敭鐨勫浘鏍� this.dicPictrueShard["ButtonPanel_SimpleTwo"] = "ButtonPanel_Two";//绠�绾�2鎸夐敭闈㈡澘 娌跨敤 2鎸夐敭鐨勫浘鏍� - this.dicPictrueShard["IntelligentLocks_Sone"] = "IntelligentLocks_H06C";//S-one鐨勯棬閿佸浘鐗囨部鐢℉06C鐨勫浘鏍� - this.dicPictrueShard["Relay_FangyueFreshAirModul"] = "Relay_ThreeLoad";//鏂规偊鏂伴灏忔ā鍧楀浘鐗囨部鐢�3璺户鐢靛櫒鐨勫浘鏍� - + this.dicPictrueShard["IntelligentLocks_Sone"] = "IntelligentLocks_H06C";//S-one鐨勯棬閿佸浘鐗� 娌跨敤 H06C鐨勫浘鏍� + this.dicPictrueShard["Relay_FangyueFreshAirModul"] = "Relay_ThreeLoad";//鏂规偊鏂伴灏忔ā鍧楀浘鐗� 娌跨敤 3璺户鐢靛櫒鐨勫浘鏍� } #endregion @@ -2801,6 +3136,14 @@ /// 绐楀笜闈㈡澘 闀滃儚id锛�256 /// </summary> ButtonPanel_Curtain = 256, + /// <summary> + /// 绠�绾﹀鍔熻兘闈㈡澘 闀滃儚ID锛�212 + /// </summary> + ButtonPanel_SimpleMultifunction = 212, + /// <summary> + /// 绠�绾︾幆澧冮潰鏉� + /// </summary> + ButtonPanel_SimpleEnvironment = 230, //=========鈽呪槄PIR浼犳劅鍣ㄧ被(1200-1299)鈽呪槄========= /// <summary> @@ -2837,6 +3180,15 @@ /// 绱ф�ユ寜閽� /// </summary> Sensor_EmergencyButton = 1305, + /// <summary> + /// 鍚搁《鐕冩皵浼犳劅鍣� + /// </summary> + Sensor_CeilingGas = 1306, + /// <summary> + /// PM2.5绌烘皵璐ㄩ噺浼犳劅鍣� + /// </summary> + Sensor_PMTwoPointFive = 1307, + /// <summary> /// 杩愬姩浼犳劅鍣� /// </summary> @@ -2901,6 +3253,10 @@ /// 褰╃伅 /// </summary> ColorLight = -10, + /// <summary> + /// 鑹叉俯鐏�(瀹冪殑闀滃儚ID鏈畾,鏆傚畾20000) + /// </summary> + ColorLight_Temperature = 20000, //=========鈽呪槄绌鸿皟(3600-3899)鈽呪槄========= /// <summary> @@ -2988,9 +3344,17 @@ /// </summary> A浼犳劅鍣� = 1200, /// <summary> + /// PM2.5绌烘皵璐ㄩ噺浼犳劅鍣� + /// </summary> + APM2鐐�5绌烘皵璐ㄩ噺浼犳劅鍣� = 1307, + /// <summary> /// 缁х數鍣�(2300-2499) /// </summary> A缁х數鍣� = 2300, + /// <summary> + /// 鏂伴 + /// </summary> + A鏂伴 = 2310, /// <summary> /// 璋冨厜鍣�(2500-2799) /// </summary> @@ -3047,10 +3411,6 @@ /// 骞叉帴鐐� /// </summary> A骞叉帴鐐� = 16, - /// <summary> - /// 鏂伴 - /// </summary> - A鏂伴 = 17 } #endregion -- Gitblit v1.8.0