From 25429f085093d89d543a0b90e30d0d62d1b7dac9 Mon Sep 17 00:00:00 2001
From: hxb <hxb@hdlchina.com.cn>
Date: 星期二, 30 八月 2022 09:37:38 +0800
Subject: [PATCH] 合并了IOS的代码

---
 ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/MutilfunctionPanelMethod.cs |  193 ++++++++++++++++++++++++++++++++++--------------
 1 files changed, 136 insertions(+), 57 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/MutilfunctionPanelMethod.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/MutilfunctionPanelMethod.cs
index c1bac93..288b3c3 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/MutilfunctionPanelMethod.cs
+++ b/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:

--
Gitblit v1.8.0