From 26d1cdf2f5246c1ad7890e6740444c4a6a80e6fb Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期二, 11 八月 2020 13:21:10 +0800
Subject: [PATCH] 合并了新代码

---
 ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/MutilfunctionPanelMethod.cs |  163 ++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 122 insertions(+), 41 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/MutilfunctionPanelMethod.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/MutilfunctionPanelMethod.cs
index c1bac93..30314e1 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/MutilfunctionPanelMethod.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/MutilfunctionPanelMethod.cs
@@ -48,20 +48,41 @@
             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 bindTargetsFromMutilfunctionPanelList.Keys)
             {
                 var bList = 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 +149,6 @@
                                     //绌鸿皟缁戝畾绫诲瀷
                                     if (device.Type == DeviceType.Thermostat && bDev.BindCluster == 513)
                                     {
-                                        //Thermostat鏄┖璋�
                                         tempList.Add(bDev);
                                     }
                                 }
@@ -151,6 +171,66 @@
             }
             return tempList;
         }
+
+        /// <summary>
+        /// 璋冨厜鐏拰缁х數鍣ㄧ壒娈婂鐞嗘柟娉�
+        /// <param name="curBindType">褰撳墠绫诲瀷 0:鍦烘櫙  1:寮�鍏�  2:鎻掑骇  3:鐏厜  4:閬槼 5:绌鸿皟 6:鏂伴</param>
+        /// </summary>
+        /// <returns></returns>
+        public static void UpdateLightCount(int curBindType)
+        {
+
+            if (curBindType == 1 || curBindType == 2 || curBindType == 3)
+            {
+                curSwitchCount = 0;
+                curSocketCount = 0;
+                curLightFromRelayCount = 0;
+                curLightCount = 0;
+
+                foreach (var key in bindTargetsFromMutilfunctionPanelList.Keys)
+                {
+                    var bList = 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>
         /// 鏀寔鍖归厤鐨勭鐐逛釜鏁�
@@ -222,15 +302,21 @@
                 var bList = 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 +382,6 @@
                                     //绌鸿皟缁戝畾绫诲瀷
                                     if (device.Type == DeviceType.Thermostat && bDev.BindCluster == 513)
                                     {
-                                        //Thermostat鏄┖璋�
                                         tempList.Remove(bDev.KeyEpoint);
                                     }
                                 }
@@ -393,10 +478,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 +492,10 @@
                                     case 5:
                                         if (device.Type == DeviceType.Thermostat)
                                         {
-                                            //Thermostat鏄┖璋�
+                                            if (BindInfo.checkRealAcDevice(device) == false)
+                                            {
+                                                continue;
+                                            }
                                             roomIncludeMatchDevice.Add(device);
                                         }
                                         break;
@@ -579,10 +667,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 +681,10 @@
                             case 5:
                                 if (device.Type == DeviceType.Thermostat)
                                 {
-                                    //Thermostat鏄┖璋�
+                                    if (BindInfo.checkRealAcDevice(device) == false)
+                                    {
+                                        continue;
+                                    }
                                     currentPanelBindSupportDeviceListTemp.Add(device);
                                 }
                                 break;
@@ -715,10 +806,6 @@
                                     undistruibuteDevList.Add(device);
                                 }
                             }
-                            if (device.Type == DeviceType.DimmableLight)
-                            {
-                                undistruibuteDevList.Add(device);
-                            }
                             break;
                         case 4:
                             if (device.Type == DeviceType.WindowCoveringDevice)
@@ -729,7 +816,10 @@
                         case 5:
                             if (device.Type == DeviceType.Thermostat)
                             {
-                                //Thermostat鏄┖璋�
+                                if (BindInfo.checkRealAcDevice(device) == false)
+                                {
+                                    continue;
+                                }
                                 undistruibuteDevList.Add(device);
                             }
                             break;
@@ -826,21 +916,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 +929,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