From 1a0a7f736c6d2e7129e7591d40bed67ec7c0f09a Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期五, 05 二月 2021 10:47:42 +0800
Subject: [PATCH] 2021-02-05 1.编译冲突修改

---
 HDL_ON/Entity/FunctionList.cs |  133 +++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 123 insertions(+), 10 deletions(-)

diff --git a/HDL_ON/Entity/FunctionList.cs b/HDL_ON/Entity/FunctionList.cs
index 5898500..d15b97e 100644
--- a/HDL_ON/Entity/FunctionList.cs
+++ b/HDL_ON/Entity/FunctionList.cs
@@ -67,10 +67,25 @@
                 {
                     tVs = new List<TV>();
                 }
+                if (airCleaners == null)
+                {
+                    airCleaners = new List<AirCleaner>();
+                }
+                if (weepRobots == null)
+                {
+                    weepRobots = new List<WeepRobot>();
+                }
+                if(waterValveList == null)
+                {
+                    waterValveList = new List<Function>();
+                }
                 var list = new List<Function>();
                 list.AddRange(fans);
                 list.AddRange(switchSockets);
-                list.AddRange(tVs);
+                list.AddRange(tVs);
+                list.AddRange(airCleaners);
+                list.AddRange(weepRobots);
+                list.AddRange(waterValveList);
                 return list;
             }
         }
@@ -85,7 +100,20 @@
         /// <summary>
         /// 瀹剁數鍒楄〃
         /// </summary>
-        public List<SwitchSocket> switchSockets = new List<SwitchSocket>();
+        public List<SwitchSocket> switchSockets = new List<SwitchSocket>();
+        /// <summary>
+        /// 绌烘皵鍑�鍖栧櫒鍒楄〃
+        /// </summary>
+        public List<AirCleaner> airCleaners = new List<AirCleaner>();
+        /// <summary>
+        /// 鎵湴鏈哄櫒浜哄垪琛�
+        /// </summary>
+        public List<WeepRobot> weepRobots = new List<WeepRobot>();
+        /// <summary>
+        /// 姘撮榾鍒楄〃
+        /// </summary>
+        public List<Function> waterValveList = new List<Function>();
+
         #endregion
         /// <summary>
         /// 鐜浼犳劅鍣ㄥ垪琛�
@@ -121,6 +149,7 @@
         /// <param name="filePath"></param>
         public void IniFunctionList(string filePath)
         {
+            // todo 澧炲姞璁惧锛屽鍔犲姛鑳借繘鍔熻兘鍒楄〃
             if (filePath.StartsWith("FunctionData_"))
             {
                 var functionDataBytes = Common.FileUtlis.Files.ReadFile(filePath);
@@ -189,6 +218,26 @@
                             var fan = Newtonsoft.Json.JsonConvert.DeserializeObject<Fan>(functionDataString);
                             List.fans.Add(fan);
                             deviceFunctionList.Add(fan);
+                            break;
+                        case SPK.ElectricTuyaAirCleaner:
+                            var airCleaner = Newtonsoft.Json.JsonConvert.DeserializeObject<AirCleaner>(functionDataString);
+                            List.airCleaners.Add(airCleaner);
+                            deviceFunctionList.Add(airCleaner);
+                            break;
+                        case SPK.ElectricTuyaFan:
+                            var tuyaFan = Newtonsoft.Json.JsonConvert.DeserializeObject<Fan>(functionDataString);
+                            List.fans.Add(tuyaFan);
+                            deviceFunctionList.Add(tuyaFan);
+                            break;
+                        case SPK.ElectricTuyaWeepRobot:
+                            var tuyaWeepRobot = Newtonsoft.Json.JsonConvert.DeserializeObject<WeepRobot>(functionDataString);
+                            List.weepRobots.Add(tuyaWeepRobot);
+                            deviceFunctionList.Add(tuyaWeepRobot);
+                            break;
+                        case SPK.ElectricTuyaWaterValve:
+                            var tuyaWaterValve = Newtonsoft.Json.JsonConvert.DeserializeObject<Function>(functionDataString);
+                            List.waterValveList.Add(tuyaWaterValve);
+                            deviceFunctionList.Add(tuyaWaterValve);
                             break;
                         case SPK.SensorSmoke:
                         case SPK.SensorWater:
@@ -212,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)
             {
@@ -225,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>
@@ -483,6 +565,33 @@
         }
 
         bool lockReadFunctionStatus = false;
+
+        /// <summary>
+        /// 璇诲彇绗笁鏂硅澶囩姸鎬�
+        /// </summary>
+        public void Read3tyFunctionStatus()
+        {
+            //璇诲彇娑傞甫璁惧鐘舵��
+            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);
+            }
+
+        }
+
         /// <summary>
         /// 璇诲彇鍏ㄩ儴鍔熻兘鐨勭姸鎬�
         /// </summary>
@@ -504,12 +613,14 @@
                 lockReadFunctionStatus = true;
                 try
                 {
+                    Read3tyFunctionStatus();
+
                     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++;
@@ -524,7 +635,7 @@
                     }
                     else
                     {
-                        foreach (var function in GetDeviceFunctionList())
+                        foreach (var function in GetDeviceFunctionList(SPK.BrandType.Hdl))
                         {
                             switch (function.Spk_Prefix)
                             {
@@ -548,6 +659,8 @@
                     lockReadFunctionStatus = false;
                     MainPage.Log($"缁撴潫--璇诲彇");
                 }
+
+                
             })
             { IsBackground = true }.Start();
         }

--
Gitblit v1.8.0