HDL Home App 第二版本 旧平台金堂用 正在使用
WJC
2019-10-29 45e4e387f3ef259b9e225fdd543e20be285a5112
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
    }
}