| | |
| | | using System.Collections.Generic; |
| | | using System.Threading.Tasks; |
| | | using Shared.Common; |
| | | using Shared.Phone.Device.Category; |
| | | using Shared.Phone.UserCenter.Device; |
| | | using ZigBee.Device; |
| | | using static ZigBee.Device.Panel; |
| | |
| | | /// 当前按键配置的功能 |
| | | /// </summary> |
| | | public static int clusterID = 0; |
| | | /// <summary> |
| | | /// 记录旧的目标列表 |
| | | /// </summary> |
| | | public static List<CommonDevice> oldTargetList = new List<CommonDevice>(); |
| | | |
| | | /// <summary> |
| | | /// 检测该设备能否显示 |
| | | /// </summary> |
| | | /// <param name="device"></param> |
| | | /// <returns></returns> |
| | | public static bool CheckCanShowDevice(ZigBee.Device.CommonDevice device, string curDeviceBindType = "AddSwitch") |
| | | { |
| | | if (device == null) |
| | | { |
| | | return false; |
| | | } |
| | | //如果是传感器,或者是没有开关簇的话(这里判断的是输入簇) |
| | | if ((device.Type == ZigBee.Device.DeviceType.IASZone) || InMatchDevice(device, curDeviceBindType) == false) |
| | | { |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 检测该房间能否显示 |
| | | /// </summary> |
| | | /// <param name="room"></param> |
| | | /// <returns></returns> |
| | | public static bool CheckCanShowRoom(Common.Room room, string curDeviceBindType = "AddSwitch") |
| | | { |
| | | if (room.ListDevice.Count == 0) |
| | | { |
| | | return false; |
| | | } |
| | | if (room.IsLove == true) |
| | | { |
| | | return false; |
| | | } |
| | | foreach (var deviceKeys in room.ListDevice) |
| | | { |
| | | var device = Common.LocalDevice.Current.GetDevice(deviceKeys); |
| | | //检测该设备能否显示 |
| | | if (CheckCanShowDevice(device, curDeviceBindType) == false) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | //存在设备的话,此房间可以显示 |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 检测设备是否拥有开关的功能(输入簇) |
| | | /// </summary> |
| | | /// <param name="device"></param> |
| | | /// <returns></returns> |
| | | public static bool InMatchDevice(CommonDevice device, string curDeviceBindType = "AddSwitch") |
| | | { |
| | | foreach (var data in device.InClusterList) |
| | | { |
| | | switch (curDeviceBindType) |
| | | { |
| | | case "AddSwitch": |
| | | //拥有on/off功能的,才支持测试 |
| | | if (data.InCluster == 6) |
| | | { |
| | | return true; |
| | | } |
| | | break; |
| | | case "AddDimmer": |
| | | if (data.InCluster == 8) |
| | | { |
| | | return true; |
| | | } |
| | | break; |
| | | case "AddCurtain": |
| | | if (data.InCluster == 258) |
| | | { |
| | | return true; |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 底部完成按钮显示 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static void FinishDisplay(List<Room> roomTempList, Button btnFinish) |
| | | { |
| | | if (roomTempList.Count == 0) |
| | | { |
| | | btnFinish.Enable = false; |
| | | btnFinish.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect; |
| | | } |
| | | else |
| | | { |
| | | btnFinish.Enable = true; |
| | | btnFinish.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取当前楼层名称 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static string GetCurrentKeyAllRoomList() |
| | | { |
| | | var dicFloor = HdlRoomLogic.Current.GetFloorSortList(); |
| | | foreach (var floorId in dicFloor.Keys) |
| | | { |
| | | //第一个楼层 |
| | | return dicFloor[floorId]; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取当前楼层 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static string GetCurrentSelectFloorId() |
| | | { |
| | | var dicFloor = HdlRoomLogic.Current.GetFloorSortList();// |
| | | foreach (var floorId in dicFloor.Keys) |
| | | { |
| | | //第一个楼层 |
| | | return floorId; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取当前楼层名称 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static string GetCurrentSelectFloorIdName() |
| | | { |
| | | var dicFloor = HdlRoomLogic.Current.GetFloorSortList(); |
| | | foreach (var floorId in dicFloor.Keys) |
| | | { |
| | | //第一个楼层 |
| | | return dicFloor[floorId]; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取当前楼层名称 |
| | | /// fllodID:楼层ID |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static string GetBindTargetsFloorIdName(string curFllodID) |
| | | { |
| | | var dicFloor = HdlRoomLogic.Current.GetFloorSortList(); |
| | | foreach (var floorId in dicFloor.Keys) |
| | | { |
| | | //当前楼层 |
| | | if (curFllodID == floorId) |
| | | { |
| | | return dicFloor[floorId]; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 检测控制面板(按键类)所拥有的功能,现支持的有以下几种(必定存在键值,出错会返回null) |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | return dicCheck; |
| | | } |
| | | |
| | | |
| | | } |
| | | } |