黄学彪
2020-12-17 9f326f4000847e6167d8166fa2f6a66f53cb3734
ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/MutilfunctionPanelMethod.cs
@@ -11,7 +11,9 @@
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
    {
@@ -21,29 +23,25 @@
        /// </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;
        /// <summary>
        /// 多功能面板中被绑定的目标
        /// </summary>
        public static System.Collections.Generic.Dictionary<string, List<BindListAllInfo>> bindTargetsFromMutilfunctionPanelList = new System.Collections.Generic.Dictionary<string, List<BindListAllInfo>>();
        #endregion
        /// <summary>
        /// 获取面板已经绑定的匹配类型的列表
        /// <param name="curBindType">当前类型 0:场景  1:开关  2:插座  3:灯光  4:遮阳 5:空调 6:新风</param>
        /// <param name="curBindType">当前类型 0:场景  1:开关   2:插座   3:灯光  4:遮阳  5:空调  6:新风 </param>
        /// </summary>
        /// <returns></returns>
        public static List<BindListAllInfo> GetMatchBindList(int curBindType)
        public static List<BindListAllInfo> GetMatchBindList(Panel curControlDev, int curBindType)
        {
            var tempList = new List<BindListAllInfo>();
            int count1 = 0;
@@ -63,9 +61,9 @@
                    break;
            }
            foreach (var key in bindTargetsFromMutilfunctionPanelList.Keys)
            foreach (var key in curControlDev.bindTargetsFromMutilfunctionPanelList.Keys)
            {
                var bList = bindTargetsFromMutilfunctionPanelList[key];
                var bList = curControlDev.bindTargetsFromMutilfunctionPanelList[key];
                foreach (var bDev in bList)
                {
                    if (curBindType == 0)
@@ -76,7 +74,7 @@
                        }
                    }
                    var device = LocalDevice.Current.GetDevice(bDev.BindMacAddr, bDev.BindEpoint);
                    var device = HdlDeviceCommonLogic.Current.GetDevice(bDev.BindMacAddr, bDev.BindEpoint);
                    if (device == null)
                    {
                        continue;
@@ -173,6 +171,66 @@
        }
        /// <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 = HdlDeviceCommonLogic.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>
@@ -234,12 +292,12 @@
        /// <param name="curBindType">当前类型 0:场景  1:开关  2:插座  3:灯光  4:遮阳 5:空调 6:新风</param>
        /// </summary>
        /// <returns></returns>
        public static List<int> GetMatchEpointList(int curBindType)
        public static List<int> GetMatchEpointList(Panel curControlDev, int curBindType)
        {
            var tempList = MatchEpointList(curBindType);
            foreach (var key in bindTargetsFromMutilfunctionPanelList.Keys)
            foreach (var key in curControlDev.bindTargetsFromMutilfunctionPanelList.Keys)
            {
                var bList = bindTargetsFromMutilfunctionPanelList[key];
                var bList = curControlDev.bindTargetsFromMutilfunctionPanelList[key];
                foreach (var bDev in bList)
                {
                    if (curBindType == 0)
@@ -250,7 +308,7 @@
                        }
                    }
                    var device = LocalDevice.Current.GetDevice(bDev.BindMacAddr, bDev.BindEpoint);
                    var device = HdlDeviceCommonLogic.Current.GetDevice(bDev.BindMacAddr, bDev.BindEpoint);
                    if (device == null)
                    {
                        continue;
@@ -384,7 +442,7 @@
                {
                    foreach (var de in room.ListDevice)
                    {
                        var device = LocalDevice.Current.GetDevice(de);
                        var device = HdlDeviceCommonLogic.Current.GetDevice(de);
                        if (device != null)
                        {
                            var tempDev = curBindTypeList.Find(obj => obj.BindMacAddr + obj.BindEpoint == device.DeviceAddr + device.DeviceEpoint);
@@ -505,7 +563,7 @@
        /// <returns></returns>
        public static string MatchTypeBindTextTip(int curBindType, int countDynamic = 0)
        {
            string[] msgArry = Language.StringByID(R.MyInternationalizationString.AddMoreTip).Split(new string[] { "{0}" }, StringSplitOptions.RemoveEmptyEntries);
            string[] msgArry = Language.StringByID(R.MyInternationalizationString.AddMoreTip).Split(new string[] { "{0}" }, StringSplitOptions.RemoveEmptyEntries);
            var tipText = msgArry[0];
            switch (curBindType)
@@ -569,7 +627,7 @@
                }
                foreach (var deviceKeys in r.ListDevice)
                {
                    var device = LocalDevice.Current.GetDevice(deviceKeys);
                    var device = HdlDeviceCommonLogic.Current.GetDevice(deviceKeys);
                    if (device == null)
                    {
                        continue;
@@ -702,7 +760,7 @@
            List<CommonDevice> UndistributeCommonDeviceListTemp = new List<CommonDevice>();
            //获取本地设备列表
            foreach (var tempDev in Shared.Common.LocalDevice.Current.listAllDevice)
            foreach (var tempDev in HdlDeviceCommonLogic.Current.listAllDevice)
            {
                //获取设备所属房间
                var tempDevRoom = HdlRoomLogic.Current.GetRoomByDevice(tempDev);
@@ -816,11 +874,11 @@
            List<CommonDevice> curRoomDeviceListTemp = new List<CommonDevice>();
            foreach (var deviceKeys in curRoom.ListDevice)
            {
                var device = LocalDevice.Current.GetDevice(deviceKeys);
                var device = HdlDeviceCommonLogic.Current.GetDevice(deviceKeys);
                if (device != null)
                {
                    //获取设备类型的
                    var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
                    var deviceEnumInfo = HdlDeviceCommonLogic.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
                    var tempDev = curBindTypeList.Find(obj => obj.BindMacAddr + obj.BindEpoint == device.DeviceAddr + device.DeviceEpoint);
                    if (tempDev != null)
                    {
@@ -860,7 +918,7 @@
                        case 4:
                            if (device.Type == DeviceType.WindowCoveringDevice)
                            {
                                if (deviceEnumInfo.ConcreteType != Common.DeviceConcreteType.ButtonPanel_SimpleMultifunction)
                                if (deviceEnumInfo.ConcreteType != DeviceConcreteType.ButtonPanel_SimpleMultifunction)
                                {
                                    curRoomDeviceListTemp.Add(device);
                                }