wei
2021-07-05 90fadf3023d54d780154eaa2a839e2106317297f
HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs
@@ -8,22 +8,6 @@
    public class LogicMethod
    {
        private static LogicMethod logicMethod = null;
        public static LogicMethod CurrLogicMethod
        {
            get
            {
                if (logicMethod == null)
                {
                    return new LogicMethod();
                }
                return logicMethod;
            }
        }
        /// <summary>
        /// 表示是条件
        /// </summary>
@@ -35,15 +19,15 @@
        /// <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)
@@ -62,7 +46,7 @@
  * @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);
@@ -75,7 +59,7 @@
        /// 获取时间戳
        /// </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;
@@ -83,7 +67,7 @@
        /// <summary>
        /// 生成逻辑sid方法
        /// </summary>
        public string NewSid()
        public static string NewSid()
        {
            string logicId = "";
            try
@@ -127,7 +111,7 @@
        /// <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)) //判断是否存在键值
            {
@@ -141,7 +125,7 @@
        /// 获取网关房间列表
        /// </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;
        }
@@ -149,7 +133,7 @@
        /// 获取网关房间列表
        /// </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();
@@ -174,7 +158,7 @@
        /// 获取网关设备列表
        /// </summary>
        /// <returns></returns>
        public List<HDL_ON.Entity.Function> GetGatewayDeviceList()
        public static List<HDL_ON.Entity.Function> GetGatewayDeviceList()
        {
            return Entity.FunctionList.List.GetDeviceFunctionList();
        }
@@ -182,7 +166,7 @@
        /// 获取网关场景列表
        /// </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;
        }
@@ -191,7 +175,7 @@
        /// </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();
@@ -221,7 +205,7 @@
        /// </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();
@@ -242,7 +226,7 @@
        /// </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();
@@ -262,7 +246,7 @@
        /// </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();
@@ -284,7 +268,7 @@
        /// </summary>
        /// <param name="functionType">设备类型</param>
        /// <returns></returns>
        public string GetIconPath(string functionType)
        public static string GetIconPath(string functionType)
        {
            string strPath = "";
            switch (functionType)
@@ -325,7 +309,6 @@
                case SPK.SensorDoorWindow:
                case SPK.SensoruUtrasonic:
                case SPK.SenesorMegahealth:
                case SPK.SenesorEnvironment:
                    {
                        strPath = "LogicIcon/sensor.png";
                    }
@@ -339,7 +322,7 @@
        /// </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();
@@ -384,7 +367,6 @@
            || device.spk == SPK.SensorDoorWindow
            || device.spk == SPK.SensoruUtrasonic
            || device.spk == SPK.SenesorMegahealth
            || device.spk == SPK.SenesorEnvironment
            );
            if (sensor != null)
            {
@@ -398,7 +380,7 @@
        /// </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))
@@ -435,8 +417,6 @@
                functionTypeList.Add(SPK.SensorDoorWindow);
                functionTypeList.Add(SPK.SensoruUtrasonic);
                functionTypeList.Add(SPK.SenesorMegahealth);
                functionTypeList.Add(SPK.SenesorEnvironment);
            }
            return functionTypeList;
@@ -446,7 +426,7 @@
        /// 条件/目标支持设备
        /// </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)
@@ -473,8 +453,6 @@
                        deviceTypeList.Add(SPK.SensorDoorWindow);
                        deviceTypeList.Add(SPK.SensoruUtrasonic);
                        deviceTypeList.Add(SPK.SenesorMegahealth);
                        deviceTypeList.Add(SPK.SenesorEnvironment);
                    }
                    break;
                case target_if:
@@ -501,7 +479,7 @@
        /// <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++)
@@ -523,7 +501,7 @@
        /// <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);
            //返回房间设备列表
@@ -535,7 +513,7 @@
        /// <summary>
        /// 网关ID(获取嘉乐网关ID)
        /// </summary>
        public string GatewayId
        public static string GatewayId
        {
            get
            {
@@ -549,7 +527,7 @@
        /// <summary>
        /// 住宅ID
        /// </summary>
        public string HomeId
        public static string HomeId
        {
            get
            {
@@ -559,14 +537,12 @@
        /// <summary>
        /// 是否为其他主用户分享过来的住宅
        /// </summary>
        public bool IsOthreShare
        public static bool IsOthreShare
        {
            get
            {
                return Entity.DB_ResidenceData.Instance.CurrentRegion.isOtherShare;
            }
        }
    }
}