From 45e4e387f3ef259b9e225fdd543e20be285a5112 Mon Sep 17 00:00:00 2001 From: WJC <wjc@hdlchina.com.cn> Date: 星期二, 29 十月 2019 13:42:57 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/dev-tzy' into dev-wjc --- ZigbeeApp/Shared/Common/Room.cs | 262 ++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 192 insertions(+), 70 deletions(-) diff --git a/ZigbeeApp/Shared/Common/Room.cs b/ZigbeeApp/Shared/Common/Room.cs index 363128b..676bce3 100755 --- a/ZigbeeApp/Shared/Common/Room.cs +++ b/ZigbeeApp/Shared/Common/Room.cs @@ -140,11 +140,28 @@ /// <summary> /// 鎵�鏈夋埧闂寸殑鎵�鏈夎澶囩被鍨� - /// 鍏堣皟鐢� GetAllRoomDeviceTypeList() /// </summary> /// <value>All room device type list.</value> [Newtonsoft.Json.JsonIgnore] - public static List<DeviceType> AllRoomDeviceTypeList = new List<DeviceType> { }; + public static List<DeviceType> AllRoomDeviceTypeList + { + get + { + var typeList = new List<DeviceType> { }; + foreach (var deviceUI in AllRoomDeviceUIList) + { + if (deviceUI == null || deviceUI.CommonDevice == null) + { + continue; + } + if (!typeList.Contains(deviceUI.CommonDevice.Type)) + { + typeList.Add(deviceUI.CommonDevice.Type); + } + } + return typeList; + } + } /// <summary> /// 鑾峰彇鎵�鏈夋埧闂寸殑鎵�鏈夊満鏅� @@ -191,11 +208,41 @@ /// <summary> /// 鑾峰彇鎵�鏈夋埧闂寸殑鎵�鏈夎澶� - /// 璇峰厛璋冪敤 GetAllRoomDeviceUIList()鏂规硶 /// </summary> /// <value>All room device UIL ist.</value> [Newtonsoft.Json.JsonIgnore] - public static List<DeviceUI> AllRoomDeviceUIList = new List<DeviceUI> { }; + public static List<DeviceUI> AllRoomDeviceUIList + { + get + { + List<DeviceUI> deviceList = new List<DeviceUI>(); + for (int i = 0; i < Lists.Count; i++) + { + var room = Lists[i]; + if (room.IsSharedRoom) + { + continue; + } + if (room.DeviceUIList.Count == 0) + { + continue; + } + for (int j = 0; j < room.DeviceUIList.Count; j++) + { + var device = room.DeviceUIList[j]; + if (device == null || device.CommonDevice == null) + { + continue; + } + if (deviceList.Find((obj) => obj.FileName == device.FileName) == null) + { + deviceList.Add(device); + } + } + } + return deviceList; + } + } #endregion @@ -491,7 +538,7 @@ deviceUI.DeviceAddr = device.DeviceAddr; deviceUI.DeviceEpoint = device.DeviceEpoint; - return Lists.Find((obj) => obj.DeviceUIFilePathList.Contains(deviceUI.FileName)); + return Lists.Find((obj) => obj.IsLove == false && obj.DeviceUIFilePathList.Contains(deviceUI.FileName)); } /// <summary> @@ -802,39 +849,6 @@ #region 鈼� 鑾峰彇璁惧_________________________ /// <summary> - /// 鑾峰彇鎵�鏈夋埧闂寸殑鎵�鏈夎澶� - /// </summary> - public static void GetAllRoomDeviceUIList() - { - List<string> devicePathList = new List<string>(); - //鎵�鏈夋埧闂寸殑鎵�鏈夎澶� - AllRoomDeviceUIList.Clear(); - foreach (var room in Shared.Common.Room.Lists) - { - if(room.IsSharedRoom) - { - continue; - } - if (room.DeviceUIList.Count == 0) - { - continue; - } - foreach (var device in room.DeviceUIList) - { - if (device == null || device.CommonDevice == null) - { - continue; - } - if (!devicePathList.Contains(device.FileName)) - { - AllRoomDeviceUIList.Add(device); - devicePathList.Add(device.FileName); - } - } - } - } - - /// <summary> /// 鏍规嵁璁惧鑾峰彇瀹冪殑UI瀵硅薄锛屽鏋滀笉瀛樺湪鍒欐柊寤� /// </summary> /// <returns>The device user interface.</returns> @@ -844,23 +858,106 @@ return Common.LocalDevice.Current.GetDeviceUI(device); } + /// <summary> + /// 鑾峰彇褰撳墠鎴块棿涓嬬殑鍏ㄩ儴璁惧 + /// </summary> + /// <returns></returns> + public List<CommonDevice> GetRoomListDevice() + { + var listDevice = new List<CommonDevice>(); + foreach (var device in this.DeviceUIList) + { + if (device == null || device.CommonDevice == null) + { + continue; + } + listDevice.Add(device.CommonDevice); + } + if (listDevice.Count == 0) + { + return listDevice; + } + return Common.LocalDevice.Current.SortDevice(listDevice); + } + /// <summary> - /// 閲嶆柊鑾峰彇-鎵�鏈夋埧闂寸殑鎵�鏈夎澶囩被鍨� + /// 鑾峰彇鎴块棿璁惧绫诲瀷 /// </summary> - public static void GetAllRoomDeviceTypeList() + /// <param name="room"></param> + /// <returns></returns> + public static List<DeviceType> GetdeviceTypes(Room room) { - AllRoomDeviceTypeList.Clear(); - foreach (var deviceUI in AllRoomDeviceUIList) + List<DeviceType> typeList = new List<DeviceType> { }; + foreach (var deviceUI in room.DeviceUIList) { if (deviceUI == null || deviceUI.CommonDevice == null) { continue; } - if (!AllRoomDeviceTypeList.Contains(deviceUI.CommonDevice.Type)) + if (!typeList.Contains(deviceUI.CommonDevice.Type)) { - AllRoomDeviceTypeList.Add(deviceUI.CommonDevice.Type); + typeList.Add(deviceUI.CommonDevice.Type); } } + return typeList; + } + + /// <summary> + /// 鑾峰彇璇ョ被鍨嬬殑璁惧 + /// </summary> + /// <param name="room"></param> + /// <param name="deviceType"></param> + /// <returns></returns> + public static List<DeviceUI> GetDeviceUIs(Room room ,DeviceType deviceType) + { + List<DeviceUI> typeList = new List<DeviceUI> { }; + foreach (var deviceUI in room.DeviceUIList) + { + if (deviceUI == null || deviceUI.CommonDevice == null) + { + continue; + } + if(deviceUI.CommonDevice.Type!=deviceType) + { + continue; + } + if (!typeList.Contains(deviceUI)) + { + typeList.Add(deviceUI); + } + } + return typeList; + } + + /// <summary> + /// 鑾峰彇璇ユゼ灞傜殑鍦烘櫙 + /// </summary> + /// <param name="floorId"></param> + /// <returns></returns> + public List<SceneUI> GetSceneUIsByFloorId(string floorId) + { + var rooms = GetRoomsByFloorId(floorId); + if (rooms == null) + { + return null; + } + var sceneList = new List<SceneUI> { }; + foreach (var r in rooms) + { + if (r.SceneUIList.Count == 0) + { + continue; + } + foreach (var sceneUI in r.SceneUIList) + { + if (sceneUI == null) + { + continue; + } + sceneList.Add(sceneUI); + } + } + return sceneList; } /// <summary> @@ -949,25 +1046,21 @@ /// <param name="iconPathType">I鍦烘櫙鑳屾櫙鍥剧墖鏉ユ簮绫诲瀷 鍥剧墖鏉ユ簮 0--鏈湴鍥惧簱 1--鎷嶇収 2--绯荤粺鍥惧簱 榛樿0</param> public async System.Threading.Tasks.Task<int> AddScene(string sceneName, string sceneIconPath, List<ZigBee.Device.Scene.AddSceneMemberData> commons, int iconPathType = 0) { - if (AllRoomSceneUIList.Find(s => s.Name == sceneName) != null) + var scenes = GetSceneUIsByFloorId(FloorId); + if(scenes!=null && scenes.Count>0) { - return -1; + if (scenes.Find(s => s.Name == sceneName) != null) + { + return -1; + } } + var getSceneIdAllData = await ZigBee.Device.Scene.GetSceneNewIdAsync(sceneName); if (getSceneIdAllData == null || getSceneIdAllData.getSceneIdData == null) { return 0; } var getSceneIdData = getSceneIdAllData.getSceneIdData; - //寰幆鐩稿悓鎶ラ敊 - foreach (var tempSceneUI in AllRoomSceneUIList) - { - if (tempSceneUI.Id == getSceneIdAllData.getSceneIdData.NewScenesId) - { - //鍦烘櫙宸插瓨鍦� - return -1; - } - } bool result = true; foreach (var common in commons) @@ -975,12 +1068,13 @@ //娣诲姞鏂版垚鍛� var addSceneMemberData = new ZigBee.Device.Scene.AddSceneMemberData { - DeviceAddr = common.DeviceAddr, Type = common.Type, + DeviceAddr = common.DeviceAddr, Epoint = common.Epoint, ScenesId = getSceneIdData.NewScenesId, TaskList = common.TaskList, DelayTime = common.DelayTime, + MemberNumber=common.MemberNumber, ElseScenesId = common.ElseScenesId }; //common.ScenesId = getSceneIdData.NewScenesId; @@ -1030,17 +1124,30 @@ /// <param name="scene">Scene.</param> public void AddScene(SceneUI scene) { - var sceneUI = new SceneUI - { - Name = scene.Name, - Id = scene.Id, - IconPath = scene.IconPath, - IconPathType = scene.IconPathType, - AddSceneMemberDataList = scene.AddSceneMemberDataList - }; - SceneUIList.Add(sceneUI); - SceneUIFilePathList.Add(sceneUI.FileName); - sceneUI.Save(); + //var sceneUI = new SceneUI + //{ + // Name = scene.Name, + // Id = scene.Id, + // IconPath = scene.IconPath, + // IconPathType = scene.IconPathType, + // AddSceneMemberDataList = scene.AddSceneMemberDataList + //}; + SceneUIList.Add(scene); + SceneUIFilePathList.Add(scene.FileName); + scene.Save(); + Save(); + } + + /// <summary> + /// 鍒犻櫎鍦烘櫙 + /// </summary> + /// <param name="scene"></param> + public void DeleteScene(SceneUI scene) + { + //scene.IsCollected = false; + scene.Save(); + SceneUIList.Remove(scene); + SceneUIFilePathList.Remove(scene.FileName); Save(); } @@ -1112,7 +1219,8 @@ ScenesId = sceneUI.Id, TaskList = addCommon.TaskList, DelayTime = addCommon.DelayTime, - ElseScenesId = addCommon.ElseScenesId + ElseScenesId = addCommon.ElseScenesId, + MemberNumber=addCommon.MemberNumber }; //娣诲姞鏂版垚鍛� 杩斿洖缁撴灉 var addSceneMemberResponseAllData = await ZigBee.Device.Scene.AddSceneMemberAsync(addSceneMemberData); @@ -1183,7 +1291,21 @@ } return null; } - + /// <summary> + /// 鑾峰彇璇ユゼ灞傛墍鏈夊満鏅� + /// </summary> + /// <param name="floorId"></param> + /// <returns></returns> + public List<SceneUI> GetSameFloorScenes(string floorId) + { + List<SceneUI> sceneUIs = new List<SceneUI> { }; + var rooms= CurrentRoom.GetRoomsByFloorId(floorId); + foreach(var r in rooms) + { + sceneUIs.AddRange(r.SceneUIList); + } + return sceneUIs; + } #endregion #region 鈼� 鍒锋柊鍦烘櫙_________________________ @@ -1418,6 +1540,6 @@ } #endregion - + } } -- Gitblit v1.8.0