From c1de48884fa145a16a0f8bcee93274dcfaa0ff82 Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期四, 07 五月 2020 10:40:28 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/dev-tzy' into dev-2020xm --- ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/BindInfo.cs | 402 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 402 insertions(+), 0 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/BindInfo.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/BindInfo.cs new file mode 100644 index 0000000..720426a --- /dev/null +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/BindInfo.cs @@ -0,0 +1,402 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Shared.Common; +using Shared.Phone.UserCenter.Device; +using ZigBee.Device; +using static ZigBee.Device.Panel; + +namespace Shared.Phone.UserCenter.DeviceBind +{ + public class BindInfo + { + /// <summary> + /// 褰撳墠鎸夐敭閰嶇疆鐨勫姛鑳� + /// </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]; + break; + } + return null; + } + + /// <summary> + /// 鑾峰彇褰撳墠妤煎眰 + /// </summary> + /// <returns></returns> + public static string GetCurrentSelectFloorId() + { + var dicFloor = HdlRoomLogic.Current.GetFloorSortList();// + foreach (var floorId in dicFloor.Keys) + { + //绗竴涓ゼ灞� + return floorId; + break; + } + return null; + } + + /// <summary> + /// 鑾峰彇褰撳墠妤煎眰鍚嶇О + /// </summary> + /// <returns></returns> + public static string GetCurrentSelectFloorIdName() + { + var dicFloor = HdlRoomLogic.Current.GetFloorSortList(); + foreach (var floorId in dicFloor.Keys) + { + //绗竴涓ゼ灞� + return dicFloor[floorId]; + break; + } + 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]; + break; + } + } + return null; + } + + /// <summary> + /// 妫�娴嬫帶鍒堕潰鏉�(鎸夐敭绫�)鎵�鎷ユ湁鐨勫姛鑳�,鐜版敮鎸佺殑鏈変互涓嬪嚑绉�(蹇呭畾瀛樺湪閿��,鍑洪敊浼氳繑鍥瀗ull) + /// </summary> + /// <returns>The panel key function level2.</returns> + /// <param name="key">Key.</param> + public static async System.Threading.Tasks.Task<Dictionary<string, bool>> CheckPanelKeyFunctionLevel3(Panel key) + { + Dictionary<string, bool> dicCheck = new Dictionary<string, bool>(); + dicCheck["鍦烘櫙:瑙﹀彂"] = false; + dicCheck["寮�鍏�:寮�"] = false; + dicCheck["寮�鍏�:鍏�"] = false; + dicCheck["寮�鍏�:鍒囨崲"] = false; + dicCheck["浜害:鎸夌瓑绾ц皟澶�"] = false; + dicCheck["浜害:鎸夌瓑绾ц皟灏�"] = false; + dicCheck["浜害:鎸夌瓑绾у垏鎹�"] = false; + dicCheck["浜害:鎵撳紑"] = false; + dicCheck["浜害:鍏抽棴"] = false; + dicCheck["浜害:鍒囨崲"] = false; + dicCheck["绐楀笜:寮�"] = false; + dicCheck["绐楀笜:鍏�"] = false; + dicCheck["绐楀笜:鍋�"] = false; + dicCheck["绐楀笜:涓婂崌鍋�"] = false; + dicCheck["绐楀笜:涓嬮檷鍋�"] = false; + + + List<int> result = null; + //鑾峰彇绗竴绾у姛鑳� + if (key.privateFuncFirstLevelList.Count == 0 || key.privateFuncFirstLevelList.Contains(256) == false) + { + result = await key.GetPanelDeviceFunctionLevel1(); + if (result == null) + { + return null; + } + key.privateFuncFirstLevelList = result; + //闈㈡澘娌℃湁鎸夐敭绫� + if (result.Contains(256) == false) + { + return dicCheck; + } + } + else + { + result = key.privateFuncFirstLevelList; + } + + if (key.privateFuncSecondLevelList.Count == 0 || key.privateFuncSecondLevelList.Contains(1) == false || key.privateFuncSecondLevelList.Contains(100) == false || key.privateFuncSecondLevelList.Contains(200) == false || key.privateFuncSecondLevelList.Contains(300) == false) + { + //鑾峰彇绗簩绾у姛鑳� + result = await key.GetPanelDeviceFunctionLevel2(256); + if (result == null) + { + return null; + } + key.privateFuncSecondLevelList = result; + } + else + { + result = key.privateFuncSecondLevelList; + } + + //鐗规畩鍔熻兘 + if (result.Contains(1) == true) + { + List<int> result3 = null; + //鑾峰彇绗笁绾у姛鑳� + if (key.privateFuncThirdLevelList.Count == 0 || key.privateFuncThirdLevelList.Contains(1) == false) + { + result3 = await key.GetPanelDeviceFunctionLevel3(256, 1); + foreach (var l3 in result3) + { + key.privateFuncThirdLevelList.Add(l3); + } + } + else + { + result3 = key.privateFuncThirdLevelList; + } + if (result3 != null) + { + if (result3.Contains(1) == true) + { + dicCheck["鍦烘櫙:瑙﹀彂"] = true; + } + } + } + //鎸夐敭寮�鍏崇被 + if (result.Contains(100) == true) + { + + List<int> result3 = null; + //鑾峰彇绗笁绾у姛鑳� + if (key.privateFuncThirdLevelList.Count == 0 || key.privateFuncThirdLevelList.Contains(100) == false || key.privateFuncThirdLevelList.Contains(101) == false || key.privateFuncThirdLevelList.Contains(102) == false) + { + result3 = await key.GetPanelDeviceFunctionLevel3(256, 100); + foreach (var l3 in result3) + { + key.privateFuncThirdLevelList.Add(l3); + } + } + else + { + result3 = key.privateFuncThirdLevelList; + } + if (result3 != null) + { + if (result3.Contains(100) == true) + { + dicCheck["寮�鍏�:寮�"] = true; + } + if (result3.Contains(101) == true) + { + dicCheck["寮�鍏�:鍏�"] = true; + } + if (result3.Contains(102) == true) + { + dicCheck["寮�鍏�:鍒囨崲"] = true; + } + } + } + //鎸夐敭璋冨厜绫� + if (result.Contains(200) == true) + { + List<int> result3 = null; + //鑾峰彇绗笁绾у姛鑳� + if (key.privateFuncThirdLevelList.Count == 0 || key.privateFuncThirdLevelList.Contains(200) == false || key.privateFuncThirdLevelList.Contains(201) == false || key.privateFuncThirdLevelList.Contains(202) == false) + { + result3 = await key.GetPanelDeviceFunctionLevel3(256, 200); + foreach (var l3 in result3) + { + key.privateFuncThirdLevelList.Add(l3); + } + } + else + { + result3 = key.privateFuncThirdLevelList; + } + if (result3 != null) + { + if (result3.Contains(200) == true) + { + dicCheck["浜害:鎸夌瓑绾ц皟澶�"] = true; + } + if (result3.Contains(201) == true) + { + dicCheck["浜害:鎸夌瓑绾ц皟灏�"] = true; + } + if (result3.Contains(202) == true) + { + dicCheck["浜害:鎸夌瓑绾у垏鎹�"] = true; + } + if (result3.Contains(203) == true) + { + dicCheck["浜害:鎵撳紑"] = true; + } + if (result3.Contains(204) == true) + { + dicCheck["浜害:鍏抽棴"] = true; + } + if (result3.Contains(205) == true) + { + dicCheck["浜害:鍒囨崲"] = true; + } + } + } + //绐楀笜绫� + if (result.Contains(300) == true) + { + List<int> result3 = null; + //鑾峰彇绗笁绾у姛鑳� + if (key.privateFuncThirdLevelList.Count == 0 || (key.privateFuncThirdLevelList.Contains(300) == false && key.privateFuncThirdLevelList.Contains(301) == false && key.privateFuncThirdLevelList.Contains(302) == false && key.privateFuncThirdLevelList.Contains(303) == false && key.privateFuncThirdLevelList.Contains(304) == false)) + { + result3 = await key.GetPanelDeviceFunctionLevel3(256, 300); + foreach (var l3 in result3) + { + key.privateFuncThirdLevelList.Add(l3); + } + } + else + { + result3 = key.privateFuncThirdLevelList; + } + + if (result3 != null) + { + if (result3.Contains(300) == true) + { + dicCheck["绐楀笜:寮�"] = true; + } + if (result3.Contains(301) == true) + { + dicCheck["绐楀笜:鍏�"] = true; + } + if (result3.Contains(302) == true) + { + dicCheck["绐楀笜:鍋�"] = true; + } + if (result3.Contains(303) == true) + { + dicCheck["绐楀笜:涓婂崌鍋�"] = true; + } + if (result3.Contains(304) == true) + { + dicCheck["绐楀笜:涓嬮檷鍋�"] = true; + } + } + } + return dicCheck; + } + } +} -- Gitblit v1.8.0