From c44b10e4447e84dbdfa9105edf460ef364a8f2b3 Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期一, 30 十一月 2020 19:53:35 +0800 Subject: [PATCH] Merge branch 'master' into WJC --- HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs | 267 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 265 insertions(+), 2 deletions(-) diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs index 7630684..17ebb5e 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs @@ -1,10 +1,27 @@ 锘縰sing System; using System.Collections.Generic; +using Shared; namespace HDL_ON.UI.UI2.Intelligence.Automation { + public class LogicMethod { + /// <summary> + /// 琛ㄧず鏄潯浠� + /// </summary> + public const string condition_if = "鏉′欢"; + /// <summary> + /// 琛ㄧず鏄洰鏍� + /// </summary> + public const string target_if = "鐩爣"; + /// <summary> + /// 绉婚櫎鎵�鏈�"Logic"鐣岄潰 + /// </summary> + public static void RemoveAllView() + { + MainPage.BasePageView.RemoveViewByTag("Logic"); + } /// <summary> /// 鐢熸垚閫昏緫sid鏂规硶 /// </summary> @@ -72,10 +89,256 @@ //娣诲姞閿�� dic.Add(key, value); } - + /// <summary> + /// 鑾峰彇缃戝叧鎴块棿鍒楄〃 + /// </summary> + /// <returns></returns> + public static List<HDL_ON.Entity.Room> GetGatewayRoomList() + { + return HDL_ON.Entity.DB_ResidenceData.rooms; + } + /// <summary> + /// 鑾峰彇缃戝叧鎴块棿鍒楄〃 + /// </summary> + /// <returns></returns> + public static List<HDL_ON.Entity.Room> GetGatewayRoomList(string name) + { - public static void InputCondition() { + List<Entity.Room> roomList = new List<Entity.Room>(); + Entity.Room room1 = new Entity.Room(); + room1.name = name;//榛樿涓�涓埧闂村悕涓�:鍏ㄩ儴鍖哄煙 + room1.sid = "鍏ㄩ儴鍖哄煙";//榛樿sid鐢ㄨ瘑鍒鎴块棿 + roomList.Add(room1);//榛樿娣诲姞鍒版埧闂村垪琛ㄩ噷 + var roomLists = GetGatewayRoomList(); + foreach (var room in roomLists) + { + roomList.Add(room); + } + + return roomList; + } + /// <summary> + /// 鑾峰彇缃戝叧璁惧鍒楄〃 + /// </summary> + /// <returns></returns> + public static List<HDL_ON.Entity.Function> GetGatewayDeviceList() + { + + return HDL_ON.Entity.DB_ResidenceData.functionList.GetAllFunction(); + } + /// <summary> + /// 鑾峰彇缃戝叧鍦烘櫙鍒楄〃 + /// </summary> + /// <returns></returns> + public static List<HDL_ON.Entity.Scene> GetSceneList() + { + return HDL_ON.Entity.DB_ResidenceData.functionList.scenes; + } + /// <summary> + /// 鑾峰彇鎴块棿鐨勮澶囧垪琛� + /// </summary> + /// <param name="room">褰撳墠鎴块棿</param> + /// <returns></returns> + public static List<HDL_ON.Entity.Function> GetRoomDevice(HDL_ON.Entity.Room room) + { + List<HDL_ON.Entity.Function> deviceLists = new List<Entity.Function>(); + List<HDL_ON.Entity.Function> lists = GetGatewayDeviceList(); + foreach (var dev in lists) + { + if (dev.roomIdList.Find((id) => id == room.sid) != null) + { + deviceLists.Add(dev); + } + if (room.sid == "鍏ㄩ儴鍖哄煙") + { + //鎴块棿鍚嶄负鍏ㄩ儴鍖哄煙鏃讹紝鏄剧ず缃戝叧鍏ㄩ儴璁惧 + deviceLists = lists; + } + + } + return deviceLists; + } + /// <summary> + /// 鑾峰彇褰撲釜璁惧 + /// </summary> + /// <param name="sid">璁惧鍞竴鏍囪瘑</param> + /// <returns></returns> + public static HDL_ON.Entity.Function GetDevice(string sid) + { + HDL_ON.Entity.Function device = new Entity.Function() { name= "Unknown",sid="璁惧涓嶅瓨鍦�"}; + List<HDL_ON.Entity.Function> deviceLists = GetGatewayDeviceList(); + foreach (var dev in deviceLists) + { + if (dev.sid == sid) + { + device = dev; + break; + } + } + return device; } + /// <summary> + /// 鑾峰彇褰撲釜鍦烘櫙 + /// </summary> + /// <param name="sid">鍦烘櫙鍞竴鏍囪瘑</param> + /// <returns></returns> + public static HDL_ON.Entity.Scene GetSecne(string sid) + { + HDL_ON.Entity.Scene scene = new Entity.Scene() { name = "Unknown", sid = "鍦烘櫙涓嶅瓨鍦�" }; + List<HDL_ON.Entity.Scene> sceneLists = GetSceneList(); + foreach (var sce in sceneLists) + { + if (sce.sid == sid) + { + scene = sce; + break; + } + } + return scene; + } + /// <summary> + /// 鑾峰彇鎴块棿鍚�(鍗虫槸=鍖哄煙鍚嶇О) + /// </summary> + /// <param name="device">璁惧</param> + /// <returns></returns> + public static string GetGetRoomName(HDL_ON.Entity.Function device) + { + string roomName = ""; + List<HDL_ON.Entity.Room> roomLists = GetGatewayRoomList(); + + foreach (var dev in device.roomIdList) + { + var room = roomLists.Find((c) => c.sid == dev); + if (room != null) + { + roomName += room.floorName + "." + room.name + ","; + } + } + + return roomName.TrimEnd(','); + } + /// <summary> + /// 鑾峰彇璁惧绫诲瀷鍥炬爣 + /// </summary> + /// <param name="functionType">璁惧绫诲瀷</param> + /// <returns></returns> + public static string GetIconPath(FunctionType functionType) + { + string strPath = ""; + switch (functionType) + { + case FunctionType.Relay: + { + strPath = "LogicIcon/lightloguc.png"; + } + break; + + } + return strPath; + } + /// <summary> + /// 璁惧绫诲瀷鐨勫垪琛�(鐏厜绫伙紝绐楀笜绫汇�傘�傘��) + /// </summary> + /// <param name="deviceList">璁惧鍒楄〃</param> + /// <returns></returns> + public static List<string> GetDeviceTypeList(List<HDL_ON.Entity.Function> deviceList) + { + List<string> deviceStrTypeList = new List<string>(); + deviceStrTypeList.Clear(); + var lightjosn = deviceList.Find((device) => device.functionType == FunctionType.Relay || device.functionType == FunctionType.Dimmer); + if (lightjosn != null) + { + deviceStrTypeList.Add(Language.StringByID(StringId.Lights)); + } + + var curtainjosn = deviceList.Find((device) => device.functionType ==FunctionType.Curtain); + if (curtainjosn != null) + { + deviceStrTypeList.Add(Language.StringByID(StringId.Curtain)); + } + + var ac = deviceList.Find((device) => device.functionType == FunctionType.AC); + if (ac != null) + { + deviceStrTypeList.Add(Language.StringByID(StringId.AC)); + } + return deviceStrTypeList; + + } + /// <summary> + /// 璁惧绫诲瀷FunctionType鍒楄〃 + /// </summary> + /// <param name="deviceType">璁惧绫诲瀷(鐏厜绫伙紝绐楀笜绫汇��)</param> + /// <returns></returns> + public static List<FunctionType> GetDeviceTypeFunctionList(string deviceType) + { + List<FunctionType> functionTypeList = new List<FunctionType>(); + if (deviceType == Language.StringByID(StringId.Lights)) + { + functionTypeList.Add(FunctionType.Relay); + functionTypeList.Add(FunctionType.Dimmer); + } + else if (deviceType == Language.StringByID(StringId.Curtain)) + { + functionTypeList.Add(FunctionType.Curtain); + } + return functionTypeList; + + } + /// <summary> + /// 鏉′欢/鐩爣鏀寔璁惧 + /// </summary> + /// <returns></returns> + public static List<FunctionType> GetSupportEquipment(string if_type) + { + List<FunctionType> deviceTypeList = new List<FunctionType>(); + switch (if_type) { + case condition_if: { + deviceTypeList.Add(FunctionType.Relay); + } + break; + case target_if: + { + deviceTypeList.Add(FunctionType.Relay); + } + break; + } + return deviceTypeList; + } + /// <summary> + /// 鏄剧ず鐨勮澶囧垪琛� + /// </summary> + /// <param name="functionType">婧愭暟鎹垪琛�1</param> + /// <param name="deviceList">婧愭暟鎹垪琛�2</param> + /// <returns></returns> + public static List<Entity.Function> GetShowDeviceList(List<FunctionType> functionType, List<HDL_ON.Entity.Function> deviceList) + { + List<HDL_ON.Entity.Function> devList = new List<Entity.Function>(); + foreach (var dev in deviceList) + { + if (functionType.Contains(dev.functionType)) + { + ///杩囨护鎺変笉闇�瑕佹樉绀虹殑璁惧 + devList.Add(dev); + } + } + return devList; + } + /// <summary> + /// 杩斿洖鏈�缁堟敮鎸佹樉绀哄嚭鏉ョ殑璁惧鍒楄〃 + /// </summary> + /// <param name="room">褰撳墠鎴块棿</param> + /// <param name="str">鍒ゆ柇绗︼紙琛ㄧず=杈撳叆璁惧鍜岃緭鍑鸿澶囷級</param> + /// <returns></returns> + public static List<Entity.Function> GetFunctionDeviceList(Entity.Room room, string str) + { + List<FunctionType> functionTypeList = GetSupportEquipment(str); + //杩斿洖鎴块棿璁惧鍒楄〃 + var roomDeviceList = GetRoomDevice(room); + //杩斿洖鏈�缁堟敮鎸佹樉绀哄嚭鏉ョ殑璁惧鍒楄〃 + var list = GetShowDeviceList(functionTypeList, roomDeviceList); + return list; + } } } -- Gitblit v1.8.0