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 |   84 +++++++++++++++++++++++++++++++++++++++--
 1 files changed, 79 insertions(+), 5 deletions(-)

diff --git a/ZigbeeApp/Shared/Common/Room.cs b/ZigbeeApp/Shared/Common/Room.cs
index 50956db..676bce3 100755
--- a/ZigbeeApp/Shared/Common/Room.cs
+++ b/ZigbeeApp/Shared/Common/Room.cs
@@ -216,8 +216,9 @@
             get
             {
                 List<DeviceUI> deviceList = new List<DeviceUI>();
-                foreach (var room in Lists)
-                {
+                for (int i = 0; i < Lists.Count; i++)
+                {
+                    var room = Lists[i];
                     if (room.IsSharedRoom)
                     {
                         continue;
@@ -226,8 +227,9 @@
                     {
                         continue;
                     }
-                    foreach (var device in room.DeviceUIList)
+                    for (int j = 0; j < room.DeviceUIList.Count; j++)
                     {
+                        var device = room.DeviceUIList[j];
                         if (device == null || device.CommonDevice == null)
                         {
                             continue;
@@ -958,6 +960,78 @@
             return sceneList;
         }
 
+        /// <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>
+        /// <param name="room"></param>
+        /// <returns></returns>
+        public static List<DeviceType> GetdeviceTypes(Room room)
+        {
+            List<DeviceType> typeList = new List<DeviceType> { };
+            foreach (var deviceUI in room.DeviceUIList)
+            {
+                if (deviceUI == null || deviceUI.CommonDevice == null)
+                {
+                    continue;
+                }
+                if (!typeList.Contains(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;
+        }
+
+
         #endregion
 
         #region 鈼� 娣诲姞鍦烘櫙_________________________
@@ -980,7 +1054,7 @@
                     return -1;
                 }
             }
-            
+
             var getSceneIdAllData = await ZigBee.Device.Scene.GetSceneNewIdAsync(sceneName);
             if (getSceneIdAllData == null || getSceneIdAllData.getSceneIdData == null)
             {
@@ -1466,6 +1540,6 @@
         }
 
         #endregion
-       
+
     }
 }

--
Gitblit v1.8.0