| | |
| | | |
| | | public class LogicMethod |
| | | { |
| | | |
| | | private static LogicMethod logicMethod = null; |
| | | |
| | | public static LogicMethod CurrLogicMethod |
| | | { |
| | | get |
| | | { |
| | | if (logicMethod == null) |
| | | { |
| | | return new LogicMethod(); |
| | | } |
| | | return logicMethod; |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 表示是条件 |
| | | /// </summary> |
| | |
| | | /// <summary> |
| | | /// 移除所有"Logic"界面 |
| | | /// </summary> |
| | | public void RemoveAllView() |
| | | public static void RemoveAllView() |
| | | { |
| | | MainPage.BasePageView.RemoveViewByTag("Logic"); |
| | | } |
| | | |
| | | |
| | | /// <summary> Converts an array of bytes into a formatted string of hex digits (ex: E4 CA B2)</summary> |
| | | /// <param name="data"> The array of bytes to be translated into a string of hex digits. </param> |
| | | /// <returns> Returns a well formatted string of hex digits with spacing. </returns> |
| | | public string byteArrayToHexString(byte[] data) |
| | | static string byteArrayToHexString(byte[] data) |
| | | { |
| | | System.Text.StringBuilder sb = new System.Text.StringBuilder(); |
| | | foreach (byte b in data) |
| | |
| | | * @param i 一个int数字 |
| | | * @return byte[] |
| | | */ |
| | | public byte[] int2ByteArray(int i) |
| | | public static byte[] int2ByteArray(int i) |
| | | { |
| | | byte[] result = new byte[4]; |
| | | result[0] = (byte)((i >> 24) & 0xFF); |
| | |
| | | /// 获取时间戳 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public int getTimeStamp() |
| | | static int getTimeStamp() |
| | | { |
| | | TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0); |
| | | return (int)ts.TotalSeconds; |
| | |
| | | /// <summary> |
| | | /// 生成逻辑sid方法 |
| | | /// </summary> |
| | | public string NewSid() |
| | | public static string NewSid() |
| | | { |
| | | string logicId = ""; |
| | | try |
| | |
| | | /// <param name="dic">Dictionary类</param> |
| | | /// <param name="key">健</param> |
| | | /// <param name="value">值</param> |
| | | public void dictionary(Dictionary<string, string> dic, string key, string value) |
| | | public static void dictionary(Dictionary<string, string> dic, string key, string value) |
| | | { |
| | | if (dic.ContainsKey(key)) //判断是否存在键值 |
| | | { |
| | |
| | | /// 获取网关房间列表 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public List<HDL_ON.Entity.Room> GetGatewayRoomList() |
| | | public static List<HDL_ON.Entity.Room> GetGatewayRoomList() |
| | | { |
| | | return HDL_ON.Entity.SpatialInfo.CurrentSpatial.RoomList; |
| | | } |
| | |
| | | /// 获取网关房间列表 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public 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(); |
| | |
| | | /// 获取网关设备列表 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public List<HDL_ON.Entity.Function> GetGatewayDeviceList() |
| | | public static List<HDL_ON.Entity.Function> GetGatewayDeviceList() |
| | | { |
| | | return Entity.FunctionList.List.GetDeviceFunctionList(); |
| | | } |
| | |
| | | /// 获取网关场景列表 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public List<HDL_ON.Entity.Scene> GetSceneList() |
| | | public static List<HDL_ON.Entity.Scene> GetSceneList() |
| | | { |
| | | return HDL_ON.Entity.FunctionList.List.scenes; |
| | | } |
| | |
| | | /// </summary> |
| | | /// <param name="room">当前房间</param> |
| | | /// <returns></returns> |
| | | public List<HDL_ON.Entity.Function> GetRoomDevice(HDL_ON.Entity.Room room) |
| | | 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(); |
| | |
| | | /// </summary> |
| | | /// <param name="sid">设备唯一标识</param> |
| | | /// <returns></returns> |
| | | public HDL_ON.Entity.Function GetDevice(string sid) |
| | | public static HDL_ON.Entity.Function GetDevice(string sid) |
| | | { |
| | | HDL_ON.Entity.Function device = new Entity.Function() { name = "Unknown" }; |
| | | List<HDL_ON.Entity.Function> deviceLists = GetGatewayDeviceList(); |
| | |
| | | /// </summary> |
| | | /// <param name="sid">场景唯一标识</param> |
| | | /// <returns></returns> |
| | | public HDL_ON.Entity.Scene GetSecne(string sid) |
| | | public static HDL_ON.Entity.Scene GetSecne(string sid) |
| | | { |
| | | HDL_ON.Entity.Scene scene = new Entity.Scene() { name = "Unknown" }; |
| | | List<HDL_ON.Entity.Scene> sceneLists = GetSceneList(); |
| | |
| | | /// </summary> |
| | | /// <param name="device">设备</param> |
| | | /// <returns></returns> |
| | | public string GetGetRoomName(HDL_ON.Entity.Function device) |
| | | public static string GetGetRoomName(HDL_ON.Entity.Function device) |
| | | { |
| | | string roomName = ""; |
| | | List<HDL_ON.Entity.Room> roomLists = GetGatewayRoomList(); |
| | |
| | | /// </summary> |
| | | /// <param name="functionType">设备类型</param> |
| | | /// <returns></returns> |
| | | public string GetIconPath(string functionType) |
| | | public static string GetIconPath(string functionType) |
| | | { |
| | | string strPath = ""; |
| | | switch (functionType) |
| | |
| | | case SPK.SensorDoorWindow: |
| | | case SPK.SensoruUtrasonic: |
| | | case SPK.SenesorMegahealth: |
| | | case SPK.SenesorEnvironment: |
| | | { |
| | | strPath = "LogicIcon/sensor.png"; |
| | | } |
| | |
| | | /// </summary> |
| | | /// <param name="deviceList">设备列表</param> |
| | | /// <returns></returns> |
| | | public 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>(); |
| | | deviceStrTypeList.Clear(); |
| | |
| | | || device.spk == SPK.SensorDoorWindow |
| | | || device.spk == SPK.SensoruUtrasonic |
| | | || device.spk == SPK.SenesorMegahealth |
| | | || device.spk == SPK.SenesorEnvironment |
| | | ); |
| | | if (sensor != null) |
| | | { |
| | |
| | | /// </summary> |
| | | /// <param name="deviceType">设备类型(灯光类,窗帘类。)</param> |
| | | /// <returns></returns> |
| | | public List<string> GetDeviceTypeFunctionList(string deviceType) |
| | | public static List<string> GetDeviceTypeFunctionList(string deviceType) |
| | | { |
| | | List<string> functionTypeList = new List<string>(); |
| | | if (deviceType == Language.StringByID(StringId.Lights)) |
| | |
| | | functionTypeList.Add(SPK.SensorDoorWindow); |
| | | functionTypeList.Add(SPK.SensoruUtrasonic); |
| | | functionTypeList.Add(SPK.SenesorMegahealth); |
| | | functionTypeList.Add(SPK.SenesorEnvironment); |
| | | |
| | | |
| | | } |
| | | return functionTypeList; |
| | |
| | | /// 条件/目标支持设备 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public List<string> GetSupportEquipment(string if_type) |
| | | public static List<string> GetSupportEquipment(string if_type) |
| | | { |
| | | List<string> deviceTypeList = new List<string>(); |
| | | switch (if_type) |
| | |
| | | deviceTypeList.Add(SPK.SensorDoorWindow); |
| | | deviceTypeList.Add(SPK.SensoruUtrasonic); |
| | | deviceTypeList.Add(SPK.SenesorMegahealth); |
| | | deviceTypeList.Add(SPK.SenesorEnvironment); |
| | | |
| | | } |
| | | break; |
| | | case target_if: |
| | |
| | | /// <param name="functionType">源数据列表1</param> |
| | | /// <param name="deviceList">源数据列表2</param> |
| | | /// <returns></returns> |
| | | public List<Entity.Function> GetShowDeviceList(List<string> functionType, List<HDL_ON.Entity.Function> deviceList) |
| | | public static List<Entity.Function> GetShowDeviceList(List<string> functionType, List<HDL_ON.Entity.Function> deviceList) |
| | | { |
| | | List<HDL_ON.Entity.Function> devList = new List<Entity.Function>(); |
| | | for (int i = 0; i < deviceList.Count; i++) |
| | |
| | | /// <param name="room">当前房间</param> |
| | | /// <param name="str">判断符(表示=输入设备和输出设备)</param> |
| | | /// <returns></returns> |
| | | public List<Entity.Function> GetFunctionDeviceList(Entity.Room room, string str) |
| | | public static List<Entity.Function> GetFunctionDeviceList(Entity.Room room, string str) |
| | | { |
| | | List<string> functionTypeList = GetSupportEquipment(str); |
| | | //返回房间设备列表 |
| | |
| | | /// <summary> |
| | | /// 网关ID(获取嘉乐网关ID) |
| | | /// </summary> |
| | | public string GatewayId |
| | | public static string GatewayId |
| | | { |
| | | get |
| | | { |
| | |
| | | /// <summary> |
| | | /// 住宅ID |
| | | /// </summary> |
| | | public string HomeId |
| | | public static string HomeId |
| | | { |
| | | get |
| | | { |
| | |
| | | /// <summary> |
| | | /// 是否为其他主用户分享过来的住宅 |
| | | /// </summary> |
| | | public bool IsOthreShare |
| | | public static bool IsOthreShare |
| | | { |
| | | get |
| | | { |
| | | return Entity.DB_ResidenceData.Instance.CurrentRegion.isOtherShare; |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |