From 9a4b76398009cf76c508d61f7e48fb6f5cb7ac2d Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期二, 21 七月 2020 09:46:53 +0800 Subject: [PATCH] 请合并最新多功能面板代码 --- ZigbeeApp/Shared/Common/Device.cs | 157 +++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 118 insertions(+), 39 deletions(-) diff --git a/ZigbeeApp/Shared/Common/Device.cs b/ZigbeeApp/Shared/Common/Device.cs index a436fb3..1435f45 100755 --- a/ZigbeeApp/Shared/Common/Device.cs +++ b/ZigbeeApp/Shared/Common/Device.cs @@ -434,7 +434,7 @@ if (Common.Config.Instance.Home.IsVirtually == true) { //淇敼璁惧鍚嶅瓧鐨勮瘽,涓婚〉闇�瑕侀噸鏂板埛鏂� - Phone.UserView.UserPage.Instance.RefreshForm = true; + Phone.UserView.UserPage.Instance.RefreshAllForm = true; return true; } @@ -458,7 +458,7 @@ } } //淇敼璁惧鍚嶅瓧鐨勮瘽,涓婚〉闇�瑕侀噸鏂板埛鏂� - Phone.UserView.UserPage.Instance.RefreshForm = true; + Phone.UserView.UserPage.Instance.RefreshAllForm = true; return true; } @@ -719,7 +719,7 @@ public void DeleteMemmoryDevice(CommonDevice device, bool deleteRoom = true) { //鍒犻櫎缂撳瓨璁惧鐨勮瘽,涓婚〉闇�瑕侀噸鏂板埛鏂� - Phone.UserView.UserPage.Instance.RefreshForm = true; + Phone.UserView.UserPage.Instance.RefreshAllForm = true; if (deleteRoom == true) { @@ -796,6 +796,35 @@ #endregion + #region 鈻� 鍚屾璁惧___________________________ + /// <summary> + /// 鍚屾璁惧骞朵笖鍒锋柊缂撳瓨(鍚屾澶辫触鏃讹紝浼氭樉绀轰俊鎭�) + /// </summary> + /// <param name="litdevice">璁惧瀵硅薄(MAC鍦板潃蹇呴』瑕佺浉鍚�)</param> + public async Task<bool> SynchronizationDevice(List<CommonDevice> listdevice) + { + //铏氭嫙浣忓畢鐨勮瘽,涓嶉渶瑕佸垹闄ょ綉鍏崇殑璁惧 + if (Config.Instance.Home.IsVirtually == false) + { + //鍚屾 + var result = await listdevice[0].SyncMsgToBindSource(listdevice[0].DeviceAddr, listdevice[0].DeviceEpoint); + if (result == null || result.result != 0) + { + //鍚屾鍒犻櫎澶辫触 + string msg = Language.StringByID(R.MyInternationalizationString.SynchronizationFailed); + //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg + msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result); + + this.ShowErrorMsg(msg); + return false; + } + } + return true; + } + #endregion + + + #region 鈻� 娴嬭瘯璁惧___________________________ /// <summary> @@ -831,6 +860,11 @@ //浼犳劅鍣ㄩ櫎浜哖ir閮芥病鏈夊畾浣嶅姛鑳� return true; } + else if (myTypeInfo.ConcreteType == DeviceConcreteType.Sensor_SphericalMotion) + { + //鐞冨瀷绉诲姩浼犳劅鍣ㄨ櫧鐒舵槸鐢垫睜璁惧,浣嗘槸瀹冩湁瀹氫綅鍔熻兘 + return true; + } return false; } @@ -841,6 +875,22 @@ { return true; } + } + return false; + } + + /// <summary> + /// 妫�娴嬭澶囨槸鍚︽嫢鏈変竴閿悓姝ュ姛鑳� + /// </summary> + /// <param name="device"></param> + /// <returns></returns> + public bool DeviceIsCanSynchronization(CommonDevice device) + { + //鑾峰彇璁惧绫诲瀷鐨� + var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device }); + if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleMultifunction) + { + return true; } return false; } @@ -1044,8 +1094,9 @@ if (sort == false) { return list; - } - list.Sort((obj1, obj2) => { + } + list.Sort((obj1, obj2) => + { if (obj1.DeviceEpoint > obj2.DeviceEpoint) { @@ -1110,7 +1161,7 @@ public List<string> GetAllDeviceFile() { List<string> listDeviceFile = new List<string>(); - List<string> listAllFile = Global.FileListByHomeId(); + List<string> listAllFile = HdlFileLogic.Current.GetRootPathListFile(); foreach (string file in listAllFile) { @@ -2179,12 +2230,21 @@ private void InitRealDeviceRoomId() { this.dicDeviceRoomId = new Dictionary<string, string>(); - string fullName = UserCenterLogic.CombinePath(DirNameResourse.DeviceRoomIdFile); - var strData = UserCenterLogic.LoadFileContent(fullName); + string fullName = DirNameResourse.DeviceRoomIdFile; + var strData = HdlFileLogic.Current.ReadFileTextContent(fullName); if (strData != null) { this.dicDeviceRoomId = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(strData); } + } + + /// <summary> + /// 鑾峰彇鍏ㄩ儴鐗╃悊璁惧鎵�灞炴埧闂寸殑璁板綍 + /// </summary> + /// <returns></returns> + public Dictionary<string, string> GetAllRealDeviceRoomData() + { + return this.dicDeviceRoomId; } /// <summary> @@ -2238,8 +2298,7 @@ if (save == true) { //淇濆瓨璁板綍 - string fullName = UserCenterLogic.CombinePath(DirNameResourse.DeviceRoomIdFile); - UserCenterLogic.SaveFileContent(fullName, this.dicDeviceRoomId); + HdlFileLogic.Current.SaveFileContent(DirNameResourse.DeviceRoomIdFile, this.dicDeviceRoomId); //娣诲姞鑷姩澶囦唤 HdlAutoBackupLogic.AddOrEditorFile(DirNameResourse.DeviceRoomIdFile); @@ -2259,7 +2318,7 @@ return Language.StringByID(R.MyInternationalizationString.uDeviceNotAssignedRoom); } var room = HdlRoomLogic.Current.GetRoomById(this.dicDeviceRoomId[device.DeviceAddr]); - return HdlRoomLogic.Current.GetFloorRoomName(room); + return HdlRoomLogic.Current.GetRoomName(room); } /// <summary> @@ -2307,8 +2366,7 @@ return; } //淇濆瓨璁板綍 - string fullName = UserCenterLogic.CombinePath(DirNameResourse.DeviceRoomIdFile); - UserCenterLogic.SaveFileContent(fullName, this.dicDeviceRoomId); + HdlFileLogic.Current.SaveFileContent(DirNameResourse.DeviceRoomIdFile, this.dicDeviceRoomId); //娣诲姞鑷姩澶囦唤 HdlAutoBackupLogic.AddOrEditorFile(DirNameResourse.DeviceRoomIdFile); @@ -2454,15 +2512,6 @@ return false; } } - //濡傛灉鏄柊椋庨潰鏉跨殑鏂伴璁惧,鍒欎笉鏄剧ず - else if (i_device.Type == DeviceType.FreshAir) - { - var myInfoType = LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { i_device }); - if (myInfoType.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir) - { - return false; - } - } //2020.03.30杩藉姞寮忔牱:濡傛灉鏄潰鏉跨殑娓╁害鎺㈠ご,涓嶆樉绀� else if (i_device.Type == DeviceType.TemperatureSensor && ((TemperatureSensor)i_device).SensorDiv == 1) { @@ -2476,6 +2525,20 @@ { //鏂伴鐨勬箍搴︿紶鎰熷櫒涓嶆樉绀� return false; + } + + //濡傛灉鏄柊椋庨潰鏉挎垨鐜闈㈡澘,鍒欓兘涓嶆樉绀轰换浣曞洖璺� + var myInfoTypeTemp = LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { i_device }); + if (myInfoTypeTemp.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir || myInfoTypeTemp.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleEnvironment) + { + return false; + } + else if (myInfoTypeTemp.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleMultifunction) + { + if (i_device.Type != DeviceType.OnOffOutput) + { + return false; + } } return true; } @@ -2891,23 +2954,17 @@ else if (mainDevice.Type == DeviceType.OnOffOutput) { //2020.05.13鍙樻洿:缁х數鍣ㄩ兘榛樿涓虹伅鍏� - //var myType = this.GetHdlMyDeviceEnumInfo(mainDevice); - //if (myType != null && myType.ConcreteType == DeviceConcreteType.Relay_ThreeLoad) + if (mainDevice.DfunctionType == DeviceFunctionType.A鏈畾涔�) { - if (mainDevice.DfunctionType == DeviceFunctionType.A鏈畾涔�) + mainDevice.DfunctionType = DeviceFunctionType.A鐏厜; + if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A鐏厜) { - mainDevice.DfunctionType = DeviceFunctionType.A鐏厜; - if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A鐏厜) - { - //缁х數鍣ㄩ粯璁や负鐏厜 - this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A鐏厜); - } - } - if (mainDevice.IsCustomizeImage == false) - { - mainDevice.IconPath = "Device/Light.png"; + //缁х數鍣ㄩ粯璁や负鐏厜 + this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A鐏厜); } } + //鏍规嵁鍔熻兘绫诲瀷,閲嶆柊璁剧疆璁惧鍥炶矾鍥炬爣 + this.ResetIconPathByDeviceFunctionType(mainDevice); } //濡傛灉鏄┖姘斿紑鍏崇殑璇� else if (mainDevice.Type == DeviceType.AirSwitch) @@ -2922,10 +2979,8 @@ this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A寮�鍏�); } } - if (mainDevice.IsCustomizeImage == false) - { - mainDevice.IconPath = "Device/Switch.png"; - } + //鏍规嵁鍔熻兘绫诲瀷,閲嶆柊璁剧疆璁惧鍥炶矾鍥炬爣 + this.ResetIconPathByDeviceFunctionType(mainDevice); } //濡傛灉鏄僵鐏殑璇� else if (mainDevice.Type == DeviceType.ColorDimmableLight) @@ -2944,6 +2999,30 @@ } /// <summary> + /// 鏍规嵁鍔熻兘绫诲瀷,閲嶆柊璁剧疆璁惧鍥炶矾鍥炬爣 + /// </summary> + /// <param name="device"></param> + private void ResetIconPathByDeviceFunctionType(CommonDevice device) + { + if (device.IsCustomizeImage == true) + { + return; + } + if (device.DfunctionType == DeviceFunctionType.A寮�鍏�) + { + device.IconPath = "Device/Switch.png"; + } + else if (device.DfunctionType == DeviceFunctionType.A鎻掑骇) + { + device.IconPath = "Device/Socket1.png"; + } + else + { + device.IconPath = "Device/Light.png"; + } + } + + /// <summary> /// 鏍规嵁璁惧Type鍒涘缓瀵瑰簲鐨勮澶囧璞� /// </summary> /// <param name="deviceType">璁惧Type</param> -- Gitblit v1.8.0