From 171bf03f3664226eeff2b20ee9bd2e914b63a17d Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期五, 13 三月 2020 09:18:50 +0800 Subject: [PATCH] 20200313 --- HDL_ON/Entity/Function/Function.cs | 143 +++++++++++++++++++++++++++++++++++------------ 1 files changed, 105 insertions(+), 38 deletions(-) diff --git a/HDL_ON/Entity/Function/Function.cs b/HDL_ON/Entity/Function/Function.cs index 6d2f2e6..1b5bf0e 100644 --- a/HDL_ON/Entity/Function/Function.cs +++ b/HDL_ON/Entity/Function/Function.cs @@ -1,52 +1,21 @@ 锘縰sing System; using System.Collections.Generic; +using System.Linq; +using Newtonsoft.Json.Linq; namespace HDL_ON.Entity { - public class Function + public class Function : A_Protocol_FunctionInfo { - /* - HDL缁熶竴鍗忚鏍煎紡锛�16bytes - 鍘傚晢浠e彿锛�2bytes - 閫氳鏂瑰紡锛氭湁绾�/鏃犵嚎/ZIGBEE绛�1bytes - 浜у搧璇嗗埆鐮侊細浠ユ坊鍔犺澶囩殑骞存湀鏃ユ椂鍒嗙 + 闅忔満鏁�8bytes - 鍔熻兘绫诲埆锛�1bytes - 鏁版嵁琛ㄧ储寮曞湴鍧�锛�2bytes - 鍥炶矾锛�2bytes - 涓句緥锛� 0001-00-201910120900002567-01-0001-0001 - */ - public Function() - { - } /// <summary> - /// 褰撳墠璁惧绫诲瀷 + /// 鍔熻兘闄勫甫鐨勫睘鎬т笌鍊肩殑鍒楄〃 /// </summary> - public FunctionType funcType = FunctionType.UnKown; + public Dictionary<string, byte> dicPropert = new Dictionary<string, byte>(); /// <summary> - /// 鍔熻兘鍒嗙被 + /// 鏄惁鏀惰棌 /// </summary> - public string funcClassification; - /// <summary> - /// 鍔熻兘ID - /// </summary> - public string sid; - /// <summary> - /// 澶囨敞 - /// </summary> - public string Name; - /// <summary> - /// 淇濆瓨鏁版嵁鏃剁殑鏂囦欢鍚� - /// </summary> - public string SavePath = ""; - /// <summary> - /// A鍗忚鏁版嵁鏍煎紡 - /// </summary> - public string A_Protocol; - /// <summary> - /// bus鍗忚鏁版嵁鏍煎紡 - /// </summary> - public string Bus_Protocol; + public bool collection = false; /// <summary> /// 鎴块棿ID鍒楄〃 /// 璇ュ姛鑳芥坊鍔犲埌鍒版埧闂村垪琛� @@ -57,5 +26,103 @@ /// </summary> public string lastState = ""; + /// <summary> + /// 鍔熻兘绫诲瀷锛� + /// 濡傦細鐏笅闈㈢殑缁х數鍣�/璋冨厜鍣�/RGB灞炰簬鍚屼竴绉嶅姛鑳戒笉鍚岀被鍨嬬殑鐏� + /// </summary> + public string functionType { + get + { + return GetFunctionType(); + } + } + + /// <summary> + /// bus鍗忚鏁版嵁鏍煎紡 + /// </summary> + public BusData bus_Data; + + /// <summary> + /// 浣跨敤娆℃暟 + /// </summary> + public double usageCount = 0; + /// <summary> + /// 浣跨敤棰戠巼 + /// </summary> + public double usageFrequency = 0; + /// <summary> + /// 鍥哄畾鐨勫簭鍙� + /// </summary> + public int fixedSerialNumber = int.MaxValue; + + /// <summary> + /// A鍗忚鏁版嵁 + /// </summary> + public List<string> PropertyArray + { + get + { + var proArr = trait.Split(',').ToList(); + foreach(var pro in proArr) + { + if (!dicPropert.ContainsKey(pro)) + { + dicPropert.TryAdd(pro, 0); + } + } + return proArr; + } + } + + /// <summary> + /// 鑾峰彇A鍗忚鎺у埗瀛楃涓� + /// </summary> + /// <param name="command">鎺у埗鍛戒护锛歸rite锛宺ead</param> + /// <returns></returns> + public virtual JObject GetSendJObject(string command) + { + var sendJob = new JObject { { "Namespace", a_Protocol_Namespace }, { "Command", command }, { "Type", "device" }, }; + var data = new JObject { { "sid", sid } }; + sendJob.Add("objects", data); + return sendJob; + } + + /// <summary> + /// 杩斿洖鍔熻兘绫诲瀷 + /// </summary> + protected virtual string GetFunctionType() + { + return functionCategory.ToString(); + } + + + public string GetBusId () + { + string busId = ""; + if(bus_Data!=null) + { + busId = bus_Data.SubnetID + "_" + bus_Data.DeviceID + "_" + bus_Data.LoopID; + } + return busId; + } + + /// <summary> + /// 鑾峰彇璁惧娣诲姞鍒版埧闂寸殑鎴块棿鍚嶇О + /// </summary> + /// <returns></returns> + public string GetRoomListName() + { + string roomNameList = ""; + foreach(var roomId in roomIdList) + { + var findRoom = DB_ResidenceData.residenceData.rooms.Find(obj => obj.sid == roomId); + if(roomNameList != "") + { + roomNameList += ","; + } + roomNameList += findRoom.floor + "路" + findRoom.name; + } + return roomNameList; + } } } -- Gitblit v1.8.0