| | |
| | | |
| | | namespace HDL_ON.UI.UI2.Intelligence.Automation |
| | | { |
| | | |
| | | |
| | | public class LogicMethod |
| | | { |
| | | /// <summary> |
| | |
| | | long m = (long)((dt - startTime).TotalMilliseconds / 10); |
| | | string sTimeSpan = byteArrayToHexString(int2ByteArray(getTimeStamp())); |
| | | |
| | | |
| | | |
| | | |
| | | logicId = sOidBeginsWith + sTimeSpan; |
| | | |
| | |
| | | string s = Logic.LogicList[i].sid.Substring(20, 4); |
| | | int iThisSceneId = Convert.ToInt16(s, 16); |
| | | if (iThisSceneId > maxId) |
| | | maxId = iThisSceneId ; |
| | | maxId = iThisSceneId; |
| | | } |
| | | |
| | | logicId += (maxId+1).ToString("X4");//逻辑号 两个byte |
| | | logicId += (maxId + 1).ToString("X4");//逻辑号 两个byte |
| | | logicId += "0000"; |
| | | } |
| | | catch |
| | |
| | | } |
| | | return logicId; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 封装Dictionary对象 |
| | | /// </summary> |
| | |
| | | /// 获取网关房间列表 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static List<HDL_ON.Entity.Room> GetGatewayRoomList() |
| | | public static List<HDL_ON.Entity.Room> GetGatewayRoomList() |
| | | { |
| | | return HDL_ON.Entity.DB_ResidenceData.residenceData.Rooms; |
| | | return HDL_ON.Entity.SpatialInfo.CurrentSpatial.RoomList; |
| | | } |
| | | /// <summary> |
| | | /// 获取网关房间列表 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static List<HDL_ON.Entity.Room> GetGatewayRoomList(string name) |
| | | public static List<HDL_ON.Entity.Room> GetGatewayRoomList(string name) |
| | | { |
| | | |
| | | List<Entity.Room> roomList = new List<Entity.Room>(); |
| | | Entity.Room room1 = new Entity.Room(); |
| | | room1.roomName = name;//默认一个房间名为:全部区域 |
| | | room1.uid = "全部区域";//默认sid用识别该房间 |
| | | room1.roomName = name;//自定义默认一个房间名为:6688 |
| | | room1.roomId = "6688";//自定义默认id用识别该房间 |
| | | roomList.Add(room1);//默认添加到房间列表里 |
| | | var roomLists = GetGatewayRoomList(); |
| | | foreach (var room in roomLists) |
| | | for (int i = 0; i < roomLists.Count; i++) |
| | | { |
| | | var room = roomLists[i]; |
| | | var devlist = GetRoomDevice(room); |
| | | if (devlist.Count == 0) |
| | | { |
| | | //过滤掉没有设备的房间; |
| | | continue; |
| | | } |
| | | roomList.Add(room); |
| | | } |
| | | |
| | | return roomList; |
| | | } |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public static List<HDL_ON.Entity.Function> GetGatewayDeviceList() |
| | | { |
| | | return HDL_ON.Entity.DB_ResidenceData.functionList.GetAllFunction(); |
| | | return Entity.FunctionList.List.GetDeviceFunctionList(); |
| | | } |
| | | /// <summary> |
| | | /// 获取网关场景列表 |
| | |
| | | /// <returns></returns> |
| | | public static List<HDL_ON.Entity.Scene> GetSceneList() |
| | | { |
| | | return HDL_ON.Entity.DB_ResidenceData.functionList.scenes; |
| | | return HDL_ON.Entity.FunctionList.List.scenes; |
| | | } |
| | | /// <summary> |
| | | /// 获取房间的设备列表 |
| | |
| | | { |
| | | List<HDL_ON.Entity.Function> deviceLists = new List<Entity.Function>(); |
| | | List<HDL_ON.Entity.Function> lists = GetGatewayDeviceList(); |
| | | foreach (var dev in lists) |
| | | if (room.roomId == "6688") |
| | | { |
| | | if (dev.roomIds.Find((id) => id == room.uid) != null) |
| | | //默认一个房间名:6688 |
| | | //显示网关全部设备 |
| | | deviceLists = lists; |
| | | } |
| | | else |
| | | { |
| | | for (int i = 0; i < lists.Count; i++) |
| | | { |
| | | deviceLists.Add(dev); |
| | | } |
| | | if (room.uid == "全部区域") |
| | | { |
| | | //房间名为全部区域时,显示网关全部设备 |
| | | deviceLists = lists; |
| | | } |
| | | var dev = lists[i]; |
| | | if (dev.roomIds.Find((id) => id == room.roomId) != null) |
| | | { |
| | | //添加属于这个房间的设备; |
| | | deviceLists.Add(dev); |
| | | } |
| | | |
| | | } |
| | | } |
| | | return deviceLists; |
| | | } |
| | |
| | | /// <returns></returns> |
| | | public static HDL_ON.Entity.Function GetDevice(string sid) |
| | | { |
| | | HDL_ON.Entity.Function device = new Entity.Function() { name= "Unknown"}; |
| | | HDL_ON.Entity.Function device = new Entity.Function() { name = "Unknown" }; |
| | | List<HDL_ON.Entity.Function> deviceLists = GetGatewayDeviceList(); |
| | | foreach (var dev in deviceLists) |
| | | for (int i = 0; i < deviceLists.Count; i++) |
| | | { |
| | | var dev = deviceLists[i]; |
| | | if (dev.sid == sid) |
| | | { |
| | | device = dev; |
| | |
| | | /// <returns></returns> |
| | | public static HDL_ON.Entity.Scene GetSecne(string sid) |
| | | { |
| | | HDL_ON.Entity.Scene scene = new Entity.Scene() { name = "Unknown"}; |
| | | HDL_ON.Entity.Scene scene = new Entity.Scene() { name = "Unknown" }; |
| | | List<HDL_ON.Entity.Scene> sceneLists = GetSceneList(); |
| | | foreach (var sce in sceneLists) |
| | | for (int i = 0; i < sceneLists.Count; i++) |
| | | { |
| | | var sce = sceneLists[i]; |
| | | if (sce.sid == sid) |
| | | { |
| | | scene = sce; |
| | |
| | | { |
| | | string roomName = ""; |
| | | List<HDL_ON.Entity.Room> roomLists = GetGatewayRoomList(); |
| | | |
| | | foreach (var dev in device.roomIds) |
| | | for (int i = 0; i < device.roomIds.Count; i++) |
| | | { |
| | | var room = roomLists.Find((c) => c.uid == dev); |
| | | var dev = device.roomIds[i]; |
| | | var room = roomLists.Find((c) => c.roomId == dev); |
| | | if (room != null) |
| | | { |
| | | roomName += room.floorName + "." + room.roomName + ","; |
| | |
| | | /// </summary> |
| | | /// <param name="deviceList">设备列表</param> |
| | | /// <returns></returns> |
| | | public static List<string> GetDeviceTypeList(List<HDL_ON.Entity.Function> deviceList) |
| | | public static List<string> GetDeviceTypeList(List<HDL_ON.Entity.Function> deviceList) |
| | | { |
| | | List<string> deviceStrTypeList = new List<string>(); |
| | | List<string> deviceStrTypeList = new List<string>(); |
| | | deviceStrTypeList.Clear(); |
| | | var lightjosn = deviceList.Find((device) => device.functionType == FunctionType.Relay || device.functionType == FunctionType.Dimmer|| device.functionType == FunctionType.ColorTemperature || device.functionType == FunctionType.RGB|| device.functionType == FunctionType.RGBW); |
| | | var lightjosn = deviceList.Find((device) => device.functionType == FunctionType.Relay || device.functionType == FunctionType.Dimmer || device.functionType == FunctionType.ColorTemperature || device.functionType == FunctionType.RGB || device.functionType == FunctionType.RGBW); |
| | | if (lightjosn != null) |
| | | { |
| | | deviceStrTypeList.Add(Language.StringByID(StringId.Lights)); |
| | | } |
| | | |
| | | var curtainjosn = deviceList.Find((device) => device.functionType ==FunctionType.Curtain|| device.functionType == FunctionType.MotorCurtain|| device.functionType == FunctionType.RollingShutter); |
| | | var curtainjosn = deviceList.Find((device) => device.functionType == FunctionType.Curtain || device.functionType == FunctionType.MotorCurtain || device.functionType == FunctionType.RollingShutter); |
| | | if (curtainjosn != null) |
| | | { |
| | | deviceStrTypeList.Add(Language.StringByID(StringId.Curtain)); |
| | |
| | | /// 条件/目标支持设备 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static List<FunctionType> GetSupportEquipment(string if_type) |
| | | public static List<FunctionType> GetSupportEquipment(string if_type) |
| | | { |
| | | List<FunctionType> deviceTypeList = new List<FunctionType>(); |
| | | switch (if_type) { |
| | | case condition_if: { |
| | | switch (if_type) |
| | | { |
| | | case condition_if: |
| | | { |
| | | deviceTypeList.Add(FunctionType.Relay); |
| | | deviceTypeList.Add(FunctionType.RGB); |
| | | deviceTypeList.Add(FunctionType.RGBW); |
| | |
| | | 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) |
| | | for (int i = 0; i < deviceList.Count; i++) |
| | | { |
| | | var dev = deviceList[i]; |
| | | if (functionType.Contains(dev.functionType)) |
| | | { |
| | | ///过滤掉不需要显示的设备 |
| | | devList.Add(dev); |
| | | } |
| | | |
| | | } |
| | | |
| | | return devList; |
| | | } |
| | | /// <summary> |