New file |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Threading.Tasks; |
| | | using Shared.Common; |
| | | using Shared.Phone.UserCenter.Device; |
| | | using Shared.Phone.UserCenter.DeviceBind; |
| | | using ZigBee.Device; |
| | | using static ZigBee.Device.BindObj; |
| | | using static ZigBee.Device.Panel; |
| | | |
| | | namespace Shared.Phone.UserCenter.Device.Bind |
| | | { |
| | | /// <summary> |
| | | /// 只使用于简约多功能面板的方法 |
| | | /// 【一个按键只能一个目标,一对一绑定。但是多功能面板60按键,最多绑定60个目标】 |
| | | /// 绑定个数 最多20个场景(按键31~52) 最多10个开关(按键52~61) 最多10个插座(按键52~61) 最多17个灯光(按键52~61或者22~28) 最多8个遮阳(按键14~21) 最多3个空调(按键2~4) 最多1个新风(按键13)</param> |
| | | /// </summary> |
| | | public class MutilfunctionPanelMethod |
| | | { |
| | | #region 变量申明 |
| | | /// <summary> |
| | | /// 开关的个数 [每次进入到多功能绑定界面,都要被重新取值] |
| | | /// </summary> |
| | | public static int curSwitchCount = 0; |
| | | /// <summary> |
| | | /// 插座的个数 [每次进入到多功能绑定界面,都要被重新取值] |
| | | /// </summary> |
| | | public static int curSocketCount = 0; |
| | | /// <summary> |
| | | /// 灯光个数 [从继电器中分配的功能类型是灯光][每次进入到多功能绑定界面,都要被重新取值] |
| | | /// </summary> |
| | | public static int curLightFromRelayCount = 0; |
| | | /// <summary> |
| | | /// 调光个数 [每次进入到多功能绑定界面,都要被重新取值] |
| | | /// </summary> |
| | | public static int curLightCount = 0; |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | /// 获取面板已经绑定的匹配类型的列表 |
| | | /// <param name="curBindType">当前类型 0:场景 1:开关 2:插座 3:灯光 4:遮阳 5:空调 6:新风 </param> |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static List<BindListAllInfo> GetMatchBindList(Panel curControlDev, int curBindType) |
| | | { |
| | | var tempList = new List<BindListAllInfo>(); |
| | | int count1 = 0; |
| | | int count2 = 0; |
| | | |
| | | switch (curBindType) |
| | | { |
| | | case 1: |
| | | curSwitchCount = 0; |
| | | break; |
| | | case 2: |
| | | curSocketCount = 0; |
| | | break; |
| | | case 3: |
| | | curLightFromRelayCount = 0; |
| | | curLightCount = 0; |
| | | break; |
| | | } |
| | | |
| | | foreach (var key in curControlDev.bindTargetsFromMutilfunctionPanelList.Keys) |
| | | { |
| | | var bList = curControlDev.bindTargetsFromMutilfunctionPanelList[key]; |
| | | foreach (var bDev in bList) |
| | | { |
| | | if (curBindType == 0) |
| | | { |
| | | if (bDev.KeyEpoint >= 32 && bDev.KeyEpoint <= 51) |
| | | { |
| | | tempList.Add(bDev); |
| | | } |
| | | } |
| | | |
| | | var device = LocalDevice.Current.GetDevice(bDev.BindMacAddr, bDev.BindEpoint); |
| | | if (device == null) |
| | | { |
| | | continue; |
| | | } |
| | | switch (curBindType) |
| | | { |
| | | case 1: |
| | | if (bDev.KeyEpoint >= 52 && bDev.KeyEpoint <= 61) |
| | | { |
| | | if (device != null) |
| | | { |
| | | if (device.DfunctionType == DeviceFunctionType.A开关) |
| | | { |
| | | tempList.Add(bDev); |
| | | } |
| | | } |
| | | } |
| | | curSwitchCount = tempList.Count; |
| | | break; |
| | | case 2: |
| | | if (bDev.KeyEpoint >= 52 && bDev.KeyEpoint <= 61) |
| | | { |
| | | if (device != null) |
| | | { |
| | | if (device.DfunctionType == DeviceFunctionType.A插座) |
| | | { |
| | | tempList.Add(bDev); |
| | | } |
| | | } |
| | | } |
| | | curSocketCount = tempList.Count; |
| | | break; |
| | | case 3: |
| | | if (bDev.KeyEpoint >= 52 && bDev.KeyEpoint <= 61) |
| | | { |
| | | if (device != null) |
| | | { |
| | | if (device.DfunctionType == DeviceFunctionType.A灯光) |
| | | { |
| | | tempList.Add(bDev); |
| | | count1++; |
| | | } |
| | | } |
| | | } |
| | | curLightFromRelayCount = count1; |
| | | if (bDev.KeyEpoint >= 22 && bDev.KeyEpoint <= 28) |
| | | { |
| | | if (device != null) |
| | | { |
| | | if (device.Type == DeviceType.DimmableLight && bDev.BindCluster == 8) |
| | | { |
| | | tempList.Add(bDev); |
| | | count2++; |
| | | } |
| | | } |
| | | } |
| | | curLightCount = count2; |
| | | break; |
| | | case 4: |
| | | if (bDev.KeyEpoint >= 14 && bDev.KeyEpoint <= 21 && bDev.BindCluster == 258) |
| | | { |
| | | tempList.Add(bDev); |
| | | } |
| | | break; |
| | | case 5: |
| | | if (bDev.KeyEpoint >= 2 && bDev.KeyEpoint <= 4) |
| | | { |
| | | if (device != null) |
| | | { |
| | | //空调绑定类型 |
| | | if (device.Type == DeviceType.Thermostat && bDev.BindCluster == 513) |
| | | { |
| | | tempList.Add(bDev); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | case 6: |
| | | if (bDev.KeyEpoint == 13) |
| | | { |
| | | if (device != null) |
| | | { |
| | | if (device.Type == DeviceType.FreshAir && bDev.BindCluster == 514) |
| | | { |
| | | tempList.Add(bDev); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | return tempList; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 调光灯和继电器特殊处理方法 |
| | | /// <param name="curBindType">当前类型 0:场景 1:开关 2:插座 3:灯光 4:遮阳 5:空调 6:新风</param> |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static void UpdateLightCount(Panel curControlDev, int curBindType) |
| | | { |
| | | |
| | | if (curBindType == 1 || curBindType == 2 || curBindType == 3) |
| | | { |
| | | curSwitchCount = 0; |
| | | curSocketCount = 0; |
| | | curLightFromRelayCount = 0; |
| | | curLightCount = 0; |
| | | |
| | | foreach (var key in curControlDev.bindTargetsFromMutilfunctionPanelList.Keys) |
| | | { |
| | | var bList = curControlDev.bindTargetsFromMutilfunctionPanelList[key]; |
| | | foreach (var bDev in bList) |
| | | { |
| | | var device = LocalDevice.Current.GetDevice(bDev.BindMacAddr, bDev.BindEpoint); |
| | | if (device == null) |
| | | { |
| | | continue; |
| | | } |
| | | if (bDev.KeyEpoint >= 52 && bDev.KeyEpoint <= 61) |
| | | { |
| | | if (device != null) |
| | | { |
| | | if (device.DfunctionType == DeviceFunctionType.A开关) |
| | | { |
| | | curSwitchCount++; |
| | | } |
| | | else if (device.DfunctionType == DeviceFunctionType.A插座) |
| | | { |
| | | curSocketCount++; |
| | | } |
| | | else if (device.DfunctionType == DeviceFunctionType.A灯光) |
| | | { |
| | | curLightFromRelayCount++; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (bDev.KeyEpoint >= 22 && bDev.KeyEpoint <= 28) |
| | | { |
| | | if (device != null) |
| | | { |
| | | if (device.Type == DeviceType.DimmableLight && bDev.BindCluster == 8) |
| | | { |
| | | curLightCount++; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 支持匹配的端点个数 |
| | | /// <param name="curBindType">当前类型 0:场景 1:开关 2:插座 3:灯光 4:遮阳 5:空调 6:新风</param> |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | private static List<int> MatchEpointList(int curBindType) |
| | | { |
| | | var tempList = new List<int>(); |
| | | switch (curBindType) |
| | | { |
| | | case 0: |
| | | for (int i = 32; i < 52; i++) |
| | | { |
| | | tempList.Add(i); |
| | | } |
| | | break; |
| | | case 1: |
| | | case 2: |
| | | for (int i = 52; i < 62; i++) |
| | | { |
| | | tempList.Add(i); |
| | | } |
| | | break; |
| | | case 3: |
| | | //最大有10个继电器的灯光,7个调光 |
| | | for (int i = 52; i < 62; i++) |
| | | { |
| | | tempList.Add(i); |
| | | } |
| | | for (int i = MutilfunctionPanelMethod.curLightCount + 22; i < 29; i++) |
| | | { |
| | | tempList.Add(i); |
| | | } |
| | | break; |
| | | case 4: |
| | | for (int i = 14; i < 22; i++) |
| | | { |
| | | tempList.Add(i); |
| | | } |
| | | break; |
| | | case 5: |
| | | for (int i = 2; i < 5; i++) |
| | | { |
| | | tempList.Add(i); |
| | | } |
| | | break; |
| | | case 6: |
| | | for (int i = 13; i < 14; i++) |
| | | { |
| | | tempList.Add(i); |
| | | } |
| | | break; |
| | | //5~12地热 簇 0x0201 |
| | | } |
| | | return tempList; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取面板支持绑定的端点列表 |
| | | /// <param name="curBindType">当前类型 0:场景 1:开关 2:插座 3:灯光 4:遮阳 5:空调 6:新风</param> |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static List<int> GetMatchEpointList(Panel curControlDev, int curBindType) |
| | | { |
| | | var tempList = MatchEpointList(curBindType); |
| | | foreach (var key in curControlDev.bindTargetsFromMutilfunctionPanelList.Keys) |
| | | { |
| | | var bList = curControlDev.bindTargetsFromMutilfunctionPanelList[key]; |
| | | foreach (var bDev in bList) |
| | | { |
| | | if (curBindType == 0) |
| | | { |
| | | if (bDev.KeyEpoint >= 32 && bDev.KeyEpoint <= 51) |
| | | { |
| | | tempList.Remove(bDev.KeyEpoint); |
| | | } |
| | | } |
| | | |
| | | var device = LocalDevice.Current.GetDevice(bDev.BindMacAddr, bDev.BindEpoint); |
| | | if (device == null) |
| | | { |
| | | continue; |
| | | } |
| | | switch (curBindType) |
| | | { |
| | | case 1: |
| | | case 2: |
| | | if (bDev.KeyEpoint >= 52 && bDev.KeyEpoint <= 61) |
| | | { |
| | | if (device != null) |
| | | { |
| | | if (device.DfunctionType == DeviceFunctionType.A开关) |
| | | { |
| | | tempList.Remove(bDev.KeyEpoint); |
| | | } |
| | | if (device.DfunctionType == DeviceFunctionType.A插座) |
| | | { |
| | | tempList.Remove(bDev.KeyEpoint); |
| | | } |
| | | if (device.DfunctionType == DeviceFunctionType.A灯光) |
| | | { |
| | | tempList.Remove(bDev.KeyEpoint); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | case 3: |
| | | if (bDev.KeyEpoint >= 52 && bDev.KeyEpoint <= 61) |
| | | { |
| | | if (device != null) |
| | | { |
| | | if (device.DfunctionType == DeviceFunctionType.A开关) |
| | | { |
| | | tempList.Remove(bDev.KeyEpoint); |
| | | } |
| | | if (device.DfunctionType == DeviceFunctionType.A插座) |
| | | { |
| | | tempList.Remove(bDev.KeyEpoint); |
| | | } |
| | | if (device.DfunctionType == DeviceFunctionType.A灯光) |
| | | { |
| | | tempList.Remove(bDev.KeyEpoint); |
| | | } |
| | | } |
| | | } |
| | | if (bDev.KeyEpoint >= 22 && bDev.KeyEpoint <= 28) |
| | | { |
| | | if (device != null) |
| | | { |
| | | if (device.Type == DeviceType.DimmableLight && bDev.BindCluster == 8) |
| | | { |
| | | tempList.Remove(bDev.KeyEpoint); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | case 4: |
| | | if (bDev.KeyEpoint >= 14 && bDev.KeyEpoint <= 21 && bDev.BindCluster == 258) |
| | | { |
| | | tempList.Remove(bDev.KeyEpoint); |
| | | } |
| | | break; |
| | | case 5: |
| | | if (bDev.KeyEpoint >= 2 && bDev.KeyEpoint <= 4) |
| | | { |
| | | if (device != null) |
| | | { |
| | | //空调绑定类型 |
| | | if (device.Type == DeviceType.Thermostat && bDev.BindCluster == 513) |
| | | { |
| | | tempList.Remove(bDev.KeyEpoint); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | case 6: |
| | | if (bDev.KeyEpoint == 13) |
| | | { |
| | | if (device != null) |
| | | { |
| | | if (device.Type == DeviceType.FreshAir && bDev.BindCluster == 514) |
| | | { |
| | | tempList.Remove(bDev.KeyEpoint); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | return tempList; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 能显示的房间列表 |
| | | /// </summary> |
| | | public static List<Room> GetSupportRoomList(Panel curControlDev, List<Room> supportRoomList, List<BindListAllInfo> curBindTypeList, int curDeviceBindType) |
| | | { |
| | | var roomTempList = new List<Room>(); |
| | | for (int i = 0; i < supportRoomList.Count; i++) |
| | | { |
| | | var room = supportRoomList[i]; |
| | | //如果房间为喜爱[后来改名为常用房间],则不显示 |
| | | if (room.IsLove == true) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | List<CommonDevice> roomIncludeMatchDevice = new List<CommonDevice>(); |
| | | List<SceneUI> roomIncludeMatchScene = new List<SceneUI>(); |
| | | if (curDeviceBindType == 0) |
| | | { |
| | | foreach (var sceneId in room.ListSceneId) |
| | | { |
| | | var scene = HdlSceneLogic.Current.GetSceneUIBySceneId(sceneId); |
| | | if (scene == null) |
| | | { |
| | | continue; |
| | | } |
| | | var tempSc = curBindTypeList.Find(obj => obj.BindScenesId == sceneId); |
| | | if (tempSc == null) |
| | | { |
| | | //被绑定目标不能再次出现 |
| | | roomIncludeMatchScene.Add(scene); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | foreach (var de in room.ListDevice) |
| | | { |
| | | var device = LocalDevice.Current.GetDevice(de); |
| | | if (device != null) |
| | | { |
| | | var tempDev = curBindTypeList.Find(obj => obj.BindMacAddr + obj.BindEpoint == device.DeviceAddr + device.DeviceEpoint); |
| | | if (tempDev == null) |
| | | { |
| | | switch (curDeviceBindType) |
| | | { |
| | | case 1: |
| | | if (device.DfunctionType == DeviceFunctionType.A开关) |
| | | { |
| | | if (device.Type != DeviceType.AirSwitch) |
| | | { |
| | | roomIncludeMatchDevice.Add(device); |
| | | } |
| | | } |
| | | break; |
| | | case 2: |
| | | if (device.DfunctionType == DeviceFunctionType.A插座) |
| | | { |
| | | if (device.Type != DeviceType.AirSwitch) |
| | | { |
| | | roomIncludeMatchDevice.Add(device); |
| | | } |
| | | } |
| | | break; |
| | | case 3: |
| | | if (device.DfunctionType == DeviceFunctionType.A灯光) |
| | | { |
| | | if (device.Type != DeviceType.AirSwitch) |
| | | { |
| | | roomIncludeMatchDevice.Add(device); |
| | | } |
| | | } |
| | | //if (device.Type == DeviceType.DimmableLight) |
| | | //{ |
| | | // roomIncludeMatchDevice.Add(device); |
| | | //} |
| | | break; |
| | | case 4: |
| | | if (device.Type == DeviceType.WindowCoveringDevice) |
| | | { |
| | | roomIncludeMatchDevice.Add(device); |
| | | } |
| | | break; |
| | | case 5: |
| | | if (device.Type == DeviceType.Thermostat) |
| | | { |
| | | if (BindInfo.checkRealAcDevice(device) == false) |
| | | { |
| | | continue; |
| | | } |
| | | roomIncludeMatchDevice.Add(device); |
| | | } |
| | | break; |
| | | case 6: |
| | | if (device.Type == DeviceType.FreshAir) |
| | | { |
| | | if (BindInfo.checkRealFreshAirDevice(device) == false) |
| | | { |
| | | continue; |
| | | } |
| | | roomIncludeMatchDevice.Add(device); |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (curDeviceBindType == 0) |
| | | { |
| | | if (room.ListSceneId.Count == 0) |
| | | { |
| | | continue; |
| | | } |
| | | if (roomIncludeMatchScene.Count == 0) |
| | | { |
| | | continue; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (room.ListDevice.Count == 0) |
| | | { |
| | | continue; |
| | | } |
| | | if (roomIncludeMatchDevice.Count == 0) |
| | | { |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | |
| | | if (!string.IsNullOrEmpty(room.FloorId)) |
| | | { |
| | | //有楼层 |
| | | if (room.FloorId == curControlDev.currentSelectFloorId) |
| | | { |
| | | roomTempList.Add(room); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //没有楼层 |
| | | roomTempList.Add(room); |
| | | } |
| | | } |
| | | return roomTempList; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 匹配的类型绑定文本个数提示 |
| | | /// </summary> |
| | | /// <param name="curBindType">当前类型 0:场景 1:开关 2:插座 3:灯光 4:遮阳 5:空调 6:新风</param> |
| | | /// <param name="countTemp">开关和灯光动态个数</param> |
| | | /// <returns></returns> |
| | | public static string MatchTypeBindTextTip(int curBindType, int countDynamic = 0) |
| | | { |
| | | string[] msgArry = Language.StringByID(R.MyInternationalizationString.AddMoreTip).Split(new string[] { "{0}" }, StringSplitOptions.RemoveEmptyEntries);
|
| | | var tipText = msgArry[0]; |
| | | |
| | | switch (curBindType) |
| | | { |
| | | case 0: |
| | | //场景共20个 |
| | | var temp0 = 20 - countDynamic; |
| | | tipText += temp0 + msgArry[1] + Language.StringByID(R.MyInternationalizationString.scene); |
| | | break; |
| | | case 1: |
| | | //开关共10个 |
| | | var temp1 = 10 - countDynamic; |
| | | tipText += temp1 + msgArry[1] + Language.StringByID(R.MyInternationalizationString.uDeviceBelongId13); |
| | | break; |
| | | case 2: |
| | | //开关共10个 |
| | | var temp2 = 10 - countDynamic; |
| | | tipText += temp2 + msgArry[1] + Language.StringByID(R.MyInternationalizationString.uDeviceBelongId14); |
| | | break; |
| | | case 3: |
| | | //开关中可分配灯光功能共10个,调光占7个 |
| | | var temp3 = 17 - countDynamic; |
| | | tipText += temp3 + msgArry[1] + Language.StringByID(R.MyInternationalizationString.uDeviceBelongId15); |
| | | break; |
| | | case 4: |
| | | //遮阳共8个 |
| | | var temp4 = 8 - countDynamic; |
| | | tipText += temp4 + msgArry[1] + Language.StringByID(R.MyInternationalizationString.uDeviceBelongId100); |
| | | break; |
| | | case 5: |
| | | //空调共3个 |
| | | var temp5 = 3 - countDynamic; |
| | | tipText += temp5 + msgArry[1] + Language.StringByID(R.MyInternationalizationString.uDeviceBelongId3600); |
| | | break; |
| | | case 6: |
| | | //新风共1个 |
| | | var temp6 = 1 - countDynamic; |
| | | tipText += temp6 + msgArry[1] + Language.StringByID(R.MyInternationalizationString.uDeviceBelongId2310); |
| | | break; |
| | | } |
| | | return tipText; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 所有房间中匹配的支持绑定的所有目标列表 |
| | | /// </summary> |
| | | /// <param name="currentPanelSupportBindDeviceList"></param> |
| | | /// <param name="supportRoomList"></param> |
| | | /// <param name="curDeviceBindType">当前设备绑定类型 1:开关 2:插座 3:灯光 4:遮阳 5:空调 6:新风</param> |
| | | /// <param name="curBindTypeList">当前类型的绑定表</param> |
| | | /// <returns></returns> |
| | | public static List<CommonDevice> GetAllRoomSupportDeviceList(List<CommonDevice> currentPanelSupportBindDeviceList, List<Room> supportRoomList, List<BindListAllInfo> curBindTypeList, int curDeviceBindType) |
| | | { |
| | | currentPanelSupportBindDeviceList.Clear(); |
| | | List<CommonDevice> currentPanelBindSupportDeviceListTemp = new List<CommonDevice>(); |
| | | foreach (var r in supportRoomList) |
| | | { |
| | | if (r.ListDevice.Count == 0) |
| | | { |
| | | continue; |
| | | } |
| | | foreach (var deviceKeys in r.ListDevice) |
| | | { |
| | | var device = LocalDevice.Current.GetDevice(deviceKeys); |
| | | if (device == null) |
| | | { |
| | | continue; |
| | | } |
| | | var tempDev = curBindTypeList.Find(obj => obj.BindMacAddr + obj.BindEpoint == deviceKeys); |
| | | if (tempDev == null) |
| | | { |
| | | //被绑定目标不能再次出现 |
| | | switch (curDeviceBindType) |
| | | { |
| | | case 1: |
| | | if (device.DfunctionType == DeviceFunctionType.A开关) |
| | | { |
| | | if (device.Type != DeviceType.AirSwitch) |
| | | { |
| | | currentPanelBindSupportDeviceListTemp.Add(device); |
| | | } |
| | | } |
| | | break; |
| | | case 2: |
| | | if (device.DfunctionType == DeviceFunctionType.A插座) |
| | | { |
| | | if (device.Type != DeviceType.AirSwitch) |
| | | { |
| | | if (device.Type != DeviceType.AirSwitch) |
| | | { |
| | | currentPanelBindSupportDeviceListTemp.Add(device); |
| | | } |
| | | } |
| | | } |
| | | |
| | | break; |
| | | case 3: |
| | | if (device.DfunctionType == DeviceFunctionType.A灯光) |
| | | { |
| | | currentPanelBindSupportDeviceListTemp.Add(device); |
| | | } |
| | | //if (device.Type == DeviceType.DimmableLight) |
| | | //{ |
| | | // currentPanelBindSupportDeviceListTemp.Add(device); |
| | | //} |
| | | break; |
| | | case 4: |
| | | if (device.Type == DeviceType.WindowCoveringDevice) |
| | | { |
| | | currentPanelBindSupportDeviceListTemp.Add(device); |
| | | } |
| | | break; |
| | | case 5: |
| | | if (device.Type == DeviceType.Thermostat) |
| | | { |
| | | if (BindInfo.checkRealAcDevice(device) == false) |
| | | { |
| | | continue; |
| | | } |
| | | currentPanelBindSupportDeviceListTemp.Add(device); |
| | | } |
| | | break; |
| | | case 6: |
| | | if (device.Type == DeviceType.FreshAir) |
| | | { |
| | | if (BindInfo.checkRealFreshAirDevice(device) == false) |
| | | { |
| | | continue; |
| | | } |
| | | currentPanelBindSupportDeviceListTemp.Add(device); |
| | | } |
| | | break; |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return currentPanelBindSupportDeviceListTemp; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 所有房间中匹配的支持绑定的所有目标列表 |
| | | /// </summary> |
| | | /// <param name="currentPanelSupportBindSceneList"></param> |
| | | /// <param name="supportRoomList"></param> |
| | | /// <param name="curBindTypeList">当前类型的绑定表</param> |
| | | /// <param name="curDeviceBindType">当前设备绑定类型 0:场景</param> |
| | | /// <returns></returns> |
| | | public static List<SceneUI> GetAllRoomSupportSceneList(List<SceneUI> currentPanelSupportBindSceneList, List<Room> supportRoomList, List<BindListAllInfo> curBindTypeList, int curDeviceBindType = 0) |
| | | { |
| | | currentPanelSupportBindSceneList.Clear(); |
| | | List<SceneUI> currentPanelBindSupportSceneListTemp = new List<SceneUI>(); |
| | | foreach (var room in supportRoomList) |
| | | { |
| | | //如果房间为喜爱,则不显示 |
| | | if (room.IsLove == true) |
| | | { |
| | | continue; |
| | | } |
| | | //如果房间中没有场景,则不显示 |
| | | if (room.ListSceneId.Count == 0) |
| | | { |
| | | continue; |
| | | } |
| | | foreach (var sceneId in room.ListSceneId) |
| | | { |
| | | var scene = HdlSceneLogic.Current.GetSceneUIBySceneId(sceneId); |
| | | if (scene == null) |
| | | { |
| | | continue; |
| | | } |
| | | var tempSc = curBindTypeList.Find(obj => obj.BindScenesId == sceneId); |
| | | if (tempSc == null) |
| | | { |
| | | //被绑定目标不能再次出现 |
| | | currentPanelSupportBindSceneList.Add(scene); |
| | | } |
| | | } |
| | | } |
| | | return currentPanelSupportBindSceneList; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 获取本地未分配的支持当前类型的绑定设备列表 |
| | | /// </summary> |
| | | /// <param name="undistruibuteDevList"></param> |
| | | /// <param name="curBindTypeList"></param> |
| | | /// <param name="curDeviceBindType">当前类型的绑定表</param> |
| | | /// <returns></returns> |
| | | public static List<CommonDevice> GetUndistributeDeviceList(List<CommonDevice> undistruibuteDevList, List<BindListAllInfo> curBindTypeList, int curDeviceBindType) |
| | | { |
| | | undistruibuteDevList.Clear(); |
| | | List<CommonDevice> UndistributeCommonDeviceListTemp = new List<CommonDevice>(); |
| | | |
| | | //获取本地设备列表 |
| | | foreach (var tempDev in Shared.Common.LocalDevice.Current.listAllDevice) |
| | | { |
| | | //获取设备所属房间 |
| | | var tempDevRoom = HdlRoomLogic.Current.GetRoomByDevice(tempDev); |
| | | if (tempDevRoom == null) |
| | | { |
| | | UndistributeCommonDeviceListTemp.Add(tempDev); |
| | | } |
| | | } |
| | | foreach (var device in UndistributeCommonDeviceListTemp) |
| | | { |
| | | var tempDev = curBindTypeList.Find(obj => obj.BindMacAddr + obj.BindEpoint == device.DeviceAddr + device.DeviceEpoint); |
| | | if (tempDev == null) |
| | | { |
| | | //被绑定目标不能再次出现 |
| | | switch (curDeviceBindType) |
| | | { |
| | | case 1: |
| | | if (device.DfunctionType == DeviceFunctionType.A开关) |
| | | { |
| | | if (device.Type != DeviceType.AirSwitch) |
| | | { |
| | | undistruibuteDevList.Add(device); |
| | | } |
| | | } |
| | | break; |
| | | case 2: |
| | | if (device.DfunctionType == DeviceFunctionType.A插座) |
| | | { |
| | | if (device.Type != DeviceType.AirSwitch) |
| | | { |
| | | undistruibuteDevList.Add(device); |
| | | } |
| | | } |
| | | |
| | | break; |
| | | case 3: |
| | | if (device.DfunctionType == DeviceFunctionType.A灯光) |
| | | { |
| | | if (device.Type != DeviceType.AirSwitch) |
| | | { |
| | | undistruibuteDevList.Add(device); |
| | | } |
| | | } |
| | | break; |
| | | case 4: |
| | | if (device.Type == DeviceType.WindowCoveringDevice) |
| | | { |
| | | undistruibuteDevList.Add(device); |
| | | } |
| | | break; |
| | | case 5: |
| | | if (device.Type == DeviceType.Thermostat) |
| | | { |
| | | if (BindInfo.checkRealAcDevice(device) == false) |
| | | { |
| | | continue; |
| | | } |
| | | undistruibuteDevList.Add(device); |
| | | } |
| | | break; |
| | | case 6: |
| | | if (device.Type == DeviceType.FreshAir) |
| | | { |
| | | if (BindInfo.checkRealFreshAirDevice(device) == false) |
| | | { |
| | | continue; |
| | | } |
| | | undistruibuteDevList.Add(device); |
| | | } |
| | | break; |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | return undistruibuteDevList; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取当前房间中匹配的支持绑定的场景列表 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static List<SceneUI> GetCurRoomSupportSceneList(Room curRoom, List<SceneUI> currentRoomSupportBindSceneList, List<BindListAllInfo> curBindTypeList, int curDeviceBindType = 0) |
| | | { |
| | | currentRoomSupportBindSceneList.Clear(); |
| | | List<SceneUI> curRoomDeviceListTemp = new List<SceneUI>(); |
| | | foreach (var sceneId in curRoom.ListSceneId) |
| | | { |
| | | var tempSc = curBindTypeList.Find(obj => obj.BindScenesId == sceneId); |
| | | if (tempSc != null) |
| | | { |
| | | //被绑定目标不能再次出现 |
| | | continue; |
| | | } |
| | | var scene = HdlSceneLogic.Current.GetSceneUIBySceneId(sceneId); |
| | | if (scene != null) |
| | | { |
| | | curRoomDeviceListTemp.Add(scene); |
| | | } |
| | | } |
| | | return curRoomDeviceListTemp; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取当前房间中匹配的支持绑定的设备列表 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static List<CommonDevice> GetCurRoomSupportDeviceList(Room curRoom, List<CommonDevice> currentRoomSupportBindDeviceList, List<BindListAllInfo> curBindTypeList, int curDeviceBindType) |
| | | { |
| | | currentRoomSupportBindDeviceList.Clear(); |
| | | List<CommonDevice> curRoomDeviceListTemp = new List<CommonDevice>(); |
| | | foreach (var deviceKeys in curRoom.ListDevice) |
| | | { |
| | | var device = LocalDevice.Current.GetDevice(deviceKeys); |
| | | if (device != null) |
| | | { |
| | | //获取设备类型的 |
| | | var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device }); |
| | | var tempDev = curBindTypeList.Find(obj => obj.BindMacAddr + obj.BindEpoint == device.DeviceAddr + device.DeviceEpoint); |
| | | if (tempDev != null) |
| | | { |
| | | //被绑定目标不能再次出现 |
| | | continue; |
| | | } |
| | | switch (curDeviceBindType) |
| | | { |
| | | case 1: |
| | | if (device.DfunctionType == DeviceFunctionType.A开关) |
| | | { |
| | | if (device.Type != DeviceType.AirSwitch) |
| | | { |
| | | curRoomDeviceListTemp.Add(device); |
| | | } |
| | | } |
| | | break; |
| | | case 2: |
| | | if (device.DfunctionType == DeviceFunctionType.A插座) |
| | | { |
| | | if (device.Type != DeviceType.AirSwitch) |
| | | { |
| | | curRoomDeviceListTemp.Add(device); |
| | | } |
| | | } |
| | | |
| | | break; |
| | | case 3: |
| | | if (device.DfunctionType == DeviceFunctionType.A灯光) |
| | | { |
| | | if (device.Type != DeviceType.AirSwitch) |
| | | { |
| | | curRoomDeviceListTemp.Add(device); |
| | | } |
| | | } |
| | | break; |
| | | case 4: |
| | | if (device.Type == DeviceType.WindowCoveringDevice) |
| | | { |
| | | if (deviceEnumInfo.ConcreteType != Common.DeviceConcreteType.ButtonPanel_SimpleMultifunction) |
| | | { |
| | | curRoomDeviceListTemp.Add(device); |
| | | } |
| | | } |
| | | break; |
| | | case 5: |
| | | if (device.Type == DeviceType.Thermostat) |
| | | { |
| | | if (BindInfo.checkRealAcDevice(device) == false) |
| | | { |
| | | continue; |
| | | } |
| | | curRoomDeviceListTemp.Add(device); |
| | | } |
| | | break; |
| | | case 6: |
| | | if (device.Type == DeviceType.FreshAir) |
| | | { |
| | | if (BindInfo.checkRealFreshAirDevice(device) == false) |
| | | { |
| | | continue; |
| | | } |
| | | curRoomDeviceListTemp.Add(device); |
| | | } |
| | | break; |
| | | |
| | | } |
| | | } |
| | | } |
| | | return curRoomDeviceListTemp; |
| | | } |
| | | |
| | | } |
| | | } |