HDL Home App 第二版本 旧平台金堂用 正在使用
hxb
2022-08-30 25429f085093d89d543a0b90e30d0d62d1b7dac9
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,47 +23,64 @@
        /// </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;
            int count2 = 0;
            foreach (var key in bindTargetsFromMutilfunctionPanelList.Keys)
            switch (curBindType)
            {
                var bList = bindTargetsFromMutilfunctionPanelList[key];
                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 0:
                            if (bDev.KeyEpoint >= 32 && bDev.KeyEpoint <= 51)
                            {
                                tempList.Add(bDev);
                            }
                            break;
                        case 1:
                            if (bDev.KeyEpoint >= 52 && bDev.KeyEpoint <= 61)
                            {
@@ -128,7 +147,6 @@
                                    //空调绑定类型
                                    if (device.Type == DeviceType.Thermostat && bDev.BindCluster == 513)
                                    {
                                        //Thermostat是空调
                                        tempList.Add(bDev);
                                    }
                                }
@@ -151,6 +169,66 @@
            }
            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>
        /// 支持匹配的端点个数
@@ -214,23 +292,29 @@
        /// <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)
                    {
                        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 0:
                            if (bDev.KeyEpoint >= 32 && bDev.KeyEpoint <= 51)
                            {
                                tempList.Remove(bDev.KeyEpoint);
                            }
                            break;
                        case 1:
                        case 2:
                            if (bDev.KeyEpoint >= 52 && bDev.KeyEpoint <= 61)
@@ -296,7 +380,6 @@
                                    //空调绑定类型
                                    if (device.Type == DeviceType.Thermostat && bDev.BindCluster == 513)
                                    {
                                        //Thermostat是空调
                                        tempList.Remove(bDev.KeyEpoint);
                                    }
                                }
@@ -393,10 +476,10 @@
                                                roomIncludeMatchDevice.Add(device);
                                            }
                                        }
                                        if (device.Type == DeviceType.DimmableLight)
                                        {
                                            roomIncludeMatchDevice.Add(device);
                                        }
                                        //if (device.Type == DeviceType.DimmableLight)
                                        //{
                                        //    roomIncludeMatchDevice.Add(device);
                                        //}
                                        break;
                                    case 4:
                                        if (device.Type == DeviceType.WindowCoveringDevice)
@@ -407,7 +490,10 @@
                                    case 5:
                                        if (device.Type == DeviceType.Thermostat)
                                        {
                                            //Thermostat是空调
                                            if (BindInfo.checkRealAcDevice(device) == false)
                                            {
                                                continue;
                                            }
                                            roomIncludeMatchDevice.Add(device);
                                        }
                                        break;
@@ -477,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)
@@ -579,10 +665,10 @@
                                {
                                    currentPanelBindSupportDeviceListTemp.Add(device);
                                }
                                if (device.Type == DeviceType.DimmableLight)
                                {
                                    currentPanelBindSupportDeviceListTemp.Add(device);
                                }
                                //if (device.Type == DeviceType.DimmableLight)
                                //{
                                //    currentPanelBindSupportDeviceListTemp.Add(device);
                                //}
                                break;
                            case 4:
                                if (device.Type == DeviceType.WindowCoveringDevice)
@@ -593,7 +679,10 @@
                            case 5:
                                if (device.Type == DeviceType.Thermostat)
                                {
                                    //Thermostat是空调
                                    if (BindInfo.checkRealAcDevice(device) == false)
                                    {
                                        continue;
                                    }
                                    currentPanelBindSupportDeviceListTemp.Add(device);
                                }
                                break;
@@ -715,10 +804,6 @@
                                    undistruibuteDevList.Add(device);
                                }
                            }
                            if (device.Type == DeviceType.DimmableLight)
                            {
                                undistruibuteDevList.Add(device);
                            }
                            break;
                        case 4:
                            if (device.Type == DeviceType.WindowCoveringDevice)
@@ -729,7 +814,10 @@
                        case 5:
                            if (device.Type == DeviceType.Thermostat)
                            {
                                //Thermostat是空调
                                if (BindInfo.checkRealAcDevice(device) == false)
                                {
                                    continue;
                                }
                                undistruibuteDevList.Add(device);
                            }
                            break;
@@ -826,21 +914,12 @@
                                    curRoomDeviceListTemp.Add(device);
                                }
                            }
                            if (device.Type == DeviceType.DimmableLight)
                            {
                                if (deviceEnumInfo.ConcreteType != Common.DeviceConcreteType.ButtonPanel_SimpleMultifunction)
                                {
                                    //Thermostat是空调
                                    curRoomDeviceListTemp.Add(device);
                                }
                            }
                            break;
                        case 4:
                            if (device.Type == DeviceType.WindowCoveringDevice)
                            {
                                if (deviceEnumInfo.ConcreteType != Common.DeviceConcreteType.ButtonPanel_SimpleMultifunction)
                                {
                                    //Thermostat是空调
                                    curRoomDeviceListTemp.Add(device);
                                }
                            }
@@ -848,11 +927,11 @@
                        case 5:
                            if (device.Type == DeviceType.Thermostat)
                            {
                                if (deviceEnumInfo.ConcreteType != Common.DeviceConcreteType.ButtonPanel_SimpleMultifunction)
                                if (BindInfo.checkRealAcDevice(device) == false)
                                {
                                    //Thermostat是空调
                                    curRoomDeviceListTemp.Add(device);
                                    continue;
                                }
                                curRoomDeviceListTemp.Add(device);
                            }
                            break;
                        case 6: