From d89a8ccb3d48d39f920b294c1966a3522ee8adbc Mon Sep 17 00:00:00 2001 From: wei <kaede@kaededeMacBook-Air.local> Date: 星期二, 23 二月 2021 17:17:37 +0800 Subject: [PATCH] 11 --- HDL_ON/Entity/FunctionList.cs | 157 +++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 130 insertions(+), 27 deletions(-) diff --git a/HDL_ON/Entity/FunctionList.cs b/HDL_ON/Entity/FunctionList.cs old mode 100755 new mode 100644 index 2a6d2bd..e9376a3 --- a/HDL_ON/Entity/FunctionList.cs +++ b/HDL_ON/Entity/FunctionList.cs @@ -75,12 +75,17 @@ { 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(airCleaners); list.AddRange(weepRobots); + list.AddRange(waterValveList); return list; } } @@ -104,12 +109,20 @@ /// 鎵湴鏈哄櫒浜哄垪琛� /// </summary> public List<WeepRobot> weepRobots = new List<WeepRobot>(); + /// <summary> + /// 姘撮榾鍒楄〃 + /// </summary> + public List<Function> waterValveList = new List<Function>(); #endregion /// <summary> /// 鐜浼犳劅鍣ㄥ垪琛� /// </summary> public List<Sensor> sensorsEnvironmentalScience = new List<Sensor>(); + /// <summary> + /// 瀹夐槻璁惧鍒楄〃 + /// </summary> + public List<Sensor> sensorsArm = new List<Sensor>(); public List<Scene> scenes = new List<Scene>(); /// <summary> @@ -136,6 +149,7 @@ /// <param name="filePath"></param> public void IniFunctionList(string filePath) { + // todo 澧炲姞璁惧锛屽鍔犲姛鑳借繘鍔熻兘鍒楄〃 if (filePath.StartsWith("FunctionData_")) { var functionDataBytes = Common.FileUtlis.Files.ReadFile(filePath); @@ -201,7 +215,7 @@ deviceFunctionList.Add(tv); break; case SPK.ElectricFan: - var fan = Newtonsoft.Json.JsonConvert.DeserializeObject<Fan>(functionDataString); + var fan = Newtonsoft.Json.JsonConvert.DeserializeObject<Fan>(functionDataString); List.fans.Add(fan); deviceFunctionList.Add(fan); break; @@ -220,6 +234,19 @@ 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: + case SPK.SensorDoorWindow: + case SPK.SensorPir: + var ser = Newtonsoft.Json.JsonConvert.DeserializeObject<Sensor>(functionDataString); + List.sensorsArm.Add(ser); + deviceFunctionList.Add(ser); + break; } } } @@ -235,7 +262,7 @@ /// <summary> /// 鑾峰彇璁惧鍔熻兘鍒楄〃 /// </summary> - public List<Function> GetDeviceFunctionList() + public List<Function> GetDeviceFunctionList(SPK.BrandType brandType = SPK.BrandType.All) { if (deviceFunctionList == null || deviceFunctionList.Count == 0) { @@ -246,18 +273,52 @@ deviceFunctionList.AddRange(floorHeatings); deviceFunctionList.AddRange(electricals); 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> @@ -384,7 +445,7 @@ } break; case FunctionCategory.Sensor: - switch(f.spk) + switch (f.spk) { case SPK.SensorTVOC: case SPK.SensorCO2: @@ -392,6 +453,17 @@ case SPK.SensorHumidity: case SPK.SensorTemperature: List.sensorsEnvironmentalScience.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<Sensor>(obj.ToString())); + break; + case SPK.SensorWater: + case SPK.SensorSmoke: + case SPK.SensorGas: + case SPK.SensorDryContact: + case SPK.SensorShanLan: + case SPK.SensorDuiShe: + case SPK.SensorPir: + case SPK.SensorDoorWindow: + case SPK.SensoruUtrasonic: + List.sensorsArm.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<Sensor>(obj.ToString())); break; } break; @@ -494,6 +566,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> @@ -515,27 +614,11 @@ lockReadFunctionStatus = true; try { - if (DriverLayer.Control.Ins.IsRemote) - { - var page = new List<string>(); - int count = 0; + Read3tyFunctionStatus(); - foreach (var function in GetDeviceFunctionList()) - { - page.Add(function.deviceId); - count++; - if (count > 9) - { - DriverLayer.Control.Ins.SendApiReadCommand(page); - page.Clear(); - count = 0; - } - } - DriverLayer.Control.Ins.SendApiReadCommand(page); - } - else + if(DriverLayer.Control.Ins.GatewayOnline_Local) { - foreach (var function in GetDeviceFunctionList()) + foreach (var function in GetDeviceFunctionList(SPK.BrandType.Hdl)) { switch (function.Spk_Prefix) { @@ -549,6 +632,24 @@ } } } + else + { + var page = new List<string>(); + int count = 0; + + foreach (var function in GetDeviceFunctionList(SPK.BrandType.Hdl)) + { + page.Add(function.deviceId); + count++; + if (count > 9) + { + DriverLayer.Control.Ins.SendApiReadCommand(page); + page.Clear(); + count = 0; + } + } + DriverLayer.Control.Ins.SendApiReadCommand(page); + } } catch (Exception ex) { @@ -559,6 +660,8 @@ lockReadFunctionStatus = false; MainPage.Log($"缁撴潫--璇诲彇"); } + + }) { IsBackground = true }.Start(); } -- Gitblit v1.8.0