From ed25f1dd70fb96ee181c8c2e53c7d57a3412afbe Mon Sep 17 00:00:00 2001
From: wei <kaede@kaededeMacBook-Air.local>
Date: 星期一, 01 二月 2021 19:05:16 +0800
Subject: [PATCH] 1

---
 HDL_ON/Entity/FunctionList.cs |   70 +++++++++++++++++++++++++++++++----
 1 files changed, 62 insertions(+), 8 deletions(-)

diff --git a/HDL_ON/Entity/FunctionList.cs b/HDL_ON/Entity/FunctionList.cs
index 7e43be8..0a3615e 100644
--- a/HDL_ON/Entity/FunctionList.cs
+++ b/HDL_ON/Entity/FunctionList.cs
@@ -261,7 +261,7 @@
         /// <summary>
         /// 鑾峰彇璁惧鍔熻兘鍒楄〃
         /// </summary>
-        public List<Function> GetDeviceFunctionList()
+        public List<Function> GetDeviceFunctionList(SPK.BrandType brandType = SPK.BrandType.All)
         {
             if (deviceFunctionList == null || deviceFunctionList.Count == 0)
             {
@@ -274,17 +274,50 @@
                 deviceFunctionList.AddRange(sensorsEnvironmentalScience);
                 deviceFunctionList.AddRange(sensorsArm);
                 deviceFunctionList.AddRange(UI.Music.A31MusicModel.A31MusicModelList);
+                try
+                {
+                    deviceFunctionList = deviceFunctionList.OrderByDescending(o => o.controlCounter).ToList();
+                }
+                catch (Exception ex)
+                {
+                    MainPage.Log($"璁惧鍔熻兘鎺掑簭寮傚父锛歿ex.Message}");
+                }
             }
-            try
+
+            List<Function> resultFunctions = new List<Function>();
+            if (brandType == SPK.BrandType.All)
             {
-                deviceFunctionList = deviceFunctionList.OrderByDescending(o => o.controlCounter).ToList();
             }
-            catch (Exception ex)
-            {
-                MainPage.Log($"璁惧鍔熻兘鎺掑簭寮傚父锛歿ex.Message}");
+            else
+            { 
+                switch (brandType)
+                {
+                    case SPK.BrandType.Hdl:
+                        foreach (var function in deviceFunctionList)
+                        {
+                            if (!SPK.Get3tySpk(SPK.BrandType.All3tyBrand).Contains(function.spk))
+                            {
+                                resultFunctions.Add(function);
+                            }
+                        }
+                        break;
+
+                    case SPK.BrandType.Tuya:
+                        foreach (var function in deviceFunctionList)
+                        {
+                            if (SPK.Get3tySpk(SPK.BrandType.Tuya).Contains(function.spk))
+                            {
+                                resultFunctions.Add(function);
+                            }
+                        }
+                        break;
+                }
+                return resultFunctions;
             }
+
             return deviceFunctionList;
         }
+
         /// <summary>
         /// 娓呯┖璁惧鍔熻兘鍒楄〃
         /// </summary>
@@ -553,12 +586,31 @@
                 lockReadFunctionStatus = true;
                 try
                 {
+                    //璇诲彇娑傞甫璁惧鐘舵��
+                    if (GetDeviceFunctionList(SPK.BrandType.Tuya).Count > 0)
+                    {
+                        var page = new List<string>();
+                        int count = 0;
+                        foreach (var function in GetDeviceFunctionList(SPK.BrandType.Tuya))
+                        {
+                            page.Add(function.deviceId);
+                            count++;
+                            if (count > 9)
+                            {
+                                DriverLayer.Control.Ins.ReadFunctionsInfo(page);
+                                page.Clear();
+                                count = 0;
+                            }
+                        }
+                        DriverLayer.Control.Ins.ReadFunctionsInfo(page);
+                    }
+
                     if (DriverLayer.Control.Ins.IsRemote)
                     {
                         var page = new List<string>();
                         int count = 0;
 
-                        foreach (var function in GetDeviceFunctionList())
+                        foreach (var function in GetDeviceFunctionList(SPK.BrandType.Hdl))
                         {
                             page.Add(function.deviceId);
                             count++;
@@ -573,7 +625,7 @@
                     }
                     else
                     {
-                        foreach (var function in GetDeviceFunctionList())
+                        foreach (var function in GetDeviceFunctionList(SPK.BrandType.Hdl))
                         {
                             switch (function.Spk_Prefix)
                             {
@@ -597,6 +649,8 @@
                     lockReadFunctionStatus = false;
                     MainPage.Log($"缁撴潫--璇诲彇");
                 }
+
+                
             })
             { IsBackground = true }.Start();
         }

--
Gitblit v1.8.0