From df93e50c747a585aa3acad599ba9be7d9617872d Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期四, 21 四月 2022 10:28:48 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/wjc' into Dev-Branch

---
 HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs | 1738 ++++++++++++++++++++++++++++++-----------------------------
 1 files changed, 872 insertions(+), 866 deletions(-)

diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs
index 942d93a..8bfe344 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs
@@ -6,497 +6,499 @@
 namespace HDL_ON.UI.UI2.Intelligence.Automation
 {
 
-  public class LogicMethod
-  {
-    /// <summary>
-    /// 瀹氫箟涓�涓潤鎬佸璞�
-    /// </summary>
-    private static LogicMethod logicMethod = null;
-    /// <summary>
-    /// 鑾峰彇闈欐�佸璞�
-    /// </summary>
-    public static LogicMethod CurrLogicMethod
+    public class LogicMethod
     {
-      get
-      {
-        if (logicMethod == null)
+        /// <summary>
+        /// 瀹氫箟涓�涓潤鎬佸璞�
+        /// </summary>
+        private static LogicMethod logicMethod = null;
+        /// <summary>
+        /// 鑾峰彇闈欐�佸璞�
+        /// </summary>
+        public static LogicMethod CurrLogicMethod
         {
-          return new LogicMethod();
+            get
+            {
+                if (logicMethod == null)
+                {
+                    return new LogicMethod();
+                }
+                return logicMethod;
+            }
+
         }
-        return logicMethod;
-      }
 
-    }
+        /// <summary>
+        /// 琛ㄧず鏄潯浠�
+        /// </summary>
+        public const string condition_if = "鏉′欢";
+        /// <summary>
+        /// 琛ㄧず鏄洰鏍�
+        /// </summary>
+        public const string target_if = "鐩爣";
+        /// <summary>
+        /// 绉婚櫎鎵�鏈�"Logic"鐣岄潰
+        /// </summary>
+        public void RemoveAllView()
+        {
+            MainPage.BasePageView.RemoveViewByTag("Logic");
+        }
 
-    /// <summary>
-    /// 琛ㄧず鏄潯浠�
-    /// </summary>
-    public const string condition_if = "鏉′欢";
-    /// <summary>
-    /// 琛ㄧず鏄洰鏍�
-    /// </summary>
-    public const string target_if = "鐩爣";
-    /// <summary>
-    /// 绉婚櫎鎵�鏈�"Logic"鐣岄潰
-    /// </summary>
-    public 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)
+        {
+            System.Text.StringBuilder sb = new System.Text.StringBuilder();
+            foreach (byte b in data)
+            {
+                sb.Append(Convert.ToString(b, 16).PadLeft(2, '0'));
+            }
 
-    /// <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)
-    {
-      System.Text.StringBuilder sb = new System.Text.StringBuilder();
-      foreach (byte b in data)
-      {
-        sb.Append(Convert.ToString(b, 16).PadLeft(2, '0'));
-      }
+            return sb.ToString().ToUpper();
+        }
 
-      return sb.ToString().ToUpper();
-    }
-
-    /**
-* int杞琤yte[]
-* 璇ユ柟娉曞皢涓�涓猧nt绫诲瀷鐨勬暟鎹浆鎹负byte[]褰㈠紡锛屽洜涓篿nt涓�32bit锛岃�宐yte涓�8bit鎵�浠ュ湪杩涜绫诲瀷杞崲鏃讹紝鐭ヤ細鑾峰彇浣�8浣嶏紝
-* 涓㈠純楂�24浣嶃�傞�氳繃浣嶇Щ鐨勬柟寮忥紝灏�32bit鐨勬暟鎹浆鎹㈡垚4涓�8bit鐨勬暟鎹�傛敞鎰� &0xff锛屽湪杩欏綋涓紝&0xff绠�鍗曠悊瑙d负涓�鎶婂壀鍒�锛�
-* 灏嗘兂瑕佽幏鍙栫殑8浣嶆暟鎹埅鍙栧嚭鏉ャ��
-* @param i 涓�涓猧nt鏁板瓧
-* @return byte[]
+        /**
+    * int杞琤yte[]
+    * 璇ユ柟娉曞皢涓�涓猧nt绫诲瀷鐨勬暟鎹浆鎹负byte[]褰㈠紡锛屽洜涓篿nt涓�32bit锛岃�宐yte涓�8bit鎵�浠ュ湪杩涜绫诲瀷杞崲鏃讹紝鐭ヤ細鑾峰彇浣�8浣嶏紝
+    * 涓㈠純楂�24浣嶃�傞�氳繃浣嶇Щ鐨勬柟寮忥紝灏�32bit鐨勬暟鎹浆鎹㈡垚4涓�8bit鐨勬暟鎹�傛敞鎰� &0xff锛屽湪杩欏綋涓紝&0xff绠�鍗曠悊瑙d负涓�鎶婂壀鍒�锛�
+    * 灏嗘兂瑕佽幏鍙栫殑8浣嶆暟鎹埅鍙栧嚭鏉ャ��
+    * @param i 涓�涓猧nt鏁板瓧
+    * @return byte[]
 */
-    public byte[] int2ByteArray(int i)
-    {
-      byte[] result = new byte[4];
-      result[0] = (byte)((i >> 24) & 0xFF);
-      result[1] = (byte)((i >> 16) & 0xFF);
-      result[2] = (byte)((i >> 8) & 0xFF);
-      result[3] = (byte)(i & 0xFF);
-      return result;
-    }
-    /// <summary>
-    /// 鑾峰彇鏃堕棿鎴�
-    /// </summary>
-    /// <returns></returns>
-    public 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()
-    {
-      string logicId = "";
-      try
-      {
-        string sOidBeginsWith = "000101";//鍘傚晢 + 閫氳鏂瑰紡
-        DateTime dt = DateTime.Now;
-        DateTime startTime = TimeZoneInfo.ConvertTimeToUtc(new DateTime(2020, 1, 1));
-        long m = (long)((dt - startTime).TotalMilliseconds / 10);
-        string sTimeSpan = byteArrayToHexString(int2ByteArray(getTimeStamp()));
-
-
-
-        logicId = sOidBeginsWith + sTimeSpan;
-
-        logicId += "15";
-        logicId += "1501";
-        //1501 鐗╂ā鍨嬩负閫昏緫锛� 0001 琛ㄧず 1 鍙烽�昏緫鍔熻兘
-        int maxId = 1;
-
-
-        for (int i = 0; i < Logic.LogicList.Count; i++)
+        public byte[] int2ByteArray(int i)
         {
-          string s = Logic.LogicList[i].sid.Substring(20, 4);
-          int iThisSceneId = Convert.ToInt16(s, 16);
-          if (iThisSceneId > maxId)
-            maxId = iThisSceneId;
+            byte[] result = new byte[4];
+            result[0] = (byte)((i >> 24) & 0xFF);
+            result[1] = (byte)((i >> 16) & 0xFF);
+            result[2] = (byte)((i >> 8) & 0xFF);
+            result[3] = (byte)(i & 0xFF);
+            return result;
+        }
+        /// <summary>
+        /// 鑾峰彇鏃堕棿鎴�
+        /// </summary>
+        /// <returns></returns>
+        public 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()
+        {
+            string logicId = "";
+            try
+            {
+                string sOidBeginsWith = "000101";//鍘傚晢 + 閫氳鏂瑰紡
+                DateTime dt = DateTime.Now;
+                DateTime startTime = TimeZoneInfo.ConvertTimeToUtc(new DateTime(2020, 1, 1));
+                long m = (long)((dt - startTime).TotalMilliseconds / 10);
+                string sTimeSpan = byteArrayToHexString(int2ByteArray(getTimeStamp()));
+
+
+
+                logicId = sOidBeginsWith + sTimeSpan;
+
+                logicId += "15";
+                logicId += "1501";
+                //1501 鐗╂ā鍨嬩负閫昏緫锛� 0001 琛ㄧず 1 鍙烽�昏緫鍔熻兘
+                int maxId = 1;
+
+
+                for (int i = 0; i < Logic.LogicList.Count; i++)
+                {
+                    string s = Logic.LogicList[i].sid.Substring(20, 4);
+                    int iThisSceneId = Convert.ToInt16(s, 16);
+                    if (iThisSceneId > maxId)
+                        maxId = iThisSceneId;
+                }
+
+                logicId += (maxId + 1).ToString("X4");//閫昏緫鍙� 涓や釜byte 
+                logicId += "0000";
+            }
+            catch
+            {
+                return logicId;
+            }
+            return logicId;
+        }
+        /// <summary>
+        /// 灏佽Dictionary瀵硅薄
+        /// </summary>
+        /// <param name="dic">Dictionary绫�</param>
+        /// <param name="key">鍋�</param>
+        /// <param name="value">鍊�</param>
+        public void dictionary(Dictionary<string, string> dic, string key, string value)
+        {
+            if (dic.ContainsKey(key)) //鍒ゆ柇鏄惁瀛樺湪閿��
+            {
+                //閿瓨鍦ㄧЩ闄�
+                dic.Remove(key);
+            }
+            //娣诲姞閿��
+            dic.Add(key, value);
+        }
+        /// <summary>
+        /// 鑾峰彇缃戝叧鎴块棿鍒楄〃
+        /// </summary>
+        /// <returns></returns>
+        public List<HDL_ON.Entity.Room> GetGatewayRoomList()
+        {
+            return HDL_ON.Entity.SpatialInfo.CurrentSpatial.RoomList;
+        }
+        /// <summary>
+        /// 鑾峰彇缃戝叧鎴块棿鍒楄〃
+        /// </summary>
+        /// <returns></returns>
+        public 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;//鑷畾涔夐粯璁や竴涓埧闂村悕涓�:6688
+            room1.roomId = "6688";//鑷畾涔夐粯璁d鐢ㄨ瘑鍒鎴块棿
+            roomList.Add(room1);//榛樿娣诲姞鍒版埧闂村垪琛ㄩ噷
+            var roomLists = GetGatewayRoomList();
+            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>
+        /// 鑾峰彇缃戝叧璁惧鍒楄〃
+        /// </summary>
+        /// <returns></returns>
+        public List<HDL_ON.Entity.Function> GetGatewayDeviceList()
+        {
+            return Entity.FunctionList.List.GetDeviceFunctionList();
+        }
+        /// <summary>
+        /// 鑾峰彇鍦烘櫙鍒楄〃
+        /// </summary>
+        /// <returns></returns>
+        public List<HDL_ON.Entity.Scene> GetSceneList()
+        {
+            return HDL_ON.Entity.FunctionList.List.scenes;
         }
 
-        logicId += (maxId + 1).ToString("X4");//閫昏緫鍙� 涓や釜byte 
-        logicId += "0000";
-      }
-      catch
-      {
-        return logicId;
-      }
-      return logicId;
-    }
-    /// <summary>
-    /// 灏佽Dictionary瀵硅薄
-    /// </summary>
-    /// <param name="dic">Dictionary绫�</param>
-    /// <param name="key">鍋�</param>
-    /// <param name="value">鍊�</param>
-    public void dictionary(Dictionary<string, string> dic, string key, string value)
-    {
-      if (dic.ContainsKey(key)) //鍒ゆ柇鏄惁瀛樺湪閿��
-      {
-        //閿瓨鍦ㄧЩ闄�
-        dic.Remove(key);
-      }
-      //娣诲姞閿��
-      dic.Add(key, value);
-    }
-    /// <summary>
-    /// 鑾峰彇缃戝叧鎴块棿鍒楄〃
-    /// </summary>
-    /// <returns></returns>
-    public List<HDL_ON.Entity.Room> GetGatewayRoomList()
-    {
-      return HDL_ON.Entity.SpatialInfo.CurrentSpatial.RoomList;
-    }
-    /// <summary>
-    /// 鑾峰彇缃戝叧鎴块棿鍒楄〃
-    /// </summary>
-    /// <returns></returns>
-    public 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;//鑷畾涔夐粯璁や竴涓埧闂村悕涓�:6688
-      room1.roomId = "6688";//鑷畾涔夐粯璁d鐢ㄨ瘑鍒鎴块棿
-      roomList.Add(room1);//榛樿娣诲姞鍒版埧闂村垪琛ㄩ噷
-      var roomLists = GetGatewayRoomList();
-      for (int i = 0; i < roomLists.Count; i++)
-      {
-        var room = roomLists[i];
-        var devlist = GetRoomDevice(room);
-        if (devlist.Count == 0)
+        /// <summary>
+        /// 鑾峰彇瀹夐槻鍒楄〃
+        /// </summary>
+        /// <returns></returns>
+        public List<HDL_ON.Entity.SecurityAlarm> GetSecurityList()
         {
-          //杩囨护鎺夋病鏈夎澶囩殑鎴块棿;
-          continue;
+            return FunctionList.List.securities;
         }
-        roomList.Add(room);
-      }
-      return roomList;
-    }
-    /// <summary>
-    /// 鑾峰彇缃戝叧璁惧鍒楄〃
-    /// </summary>
-    /// <returns></returns>
-    public List<HDL_ON.Entity.Function> GetGatewayDeviceList()
-    {
-      return Entity.FunctionList.List.GetDeviceFunctionList();
-    }
-    /// <summary>
-    /// 鑾峰彇鍦烘櫙鍒楄〃
-    /// </summary>
-    /// <returns></returns>
-    public List<HDL_ON.Entity.Scene> GetSceneList()
-    {
-      return HDL_ON.Entity.FunctionList.List.scenes;
-    }
-
-    /// <summary>
-    /// 鑾峰彇瀹夐槻鍒楄〃
-    /// </summary>
-    /// <returns></returns>
-    public List<HDL_ON.Entity.SecurityAlarm> GetSecurityList()
-    {
-      return FunctionList.List.securities;
-    }
-    /// <summary>
-    /// 鑾峰彇鎴块棿鐨勮澶囧垪琛�
-    /// </summary>
-    /// <param name="room">褰撳墠鎴块棿</param>
-    /// <returns></returns>
-    public 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();
-      if (room.roomId == "6688")
-      {
-        //榛樿涓�涓埧闂村悕锛�6688
-        //鏄剧ず缃戝叧鍏ㄩ儴璁惧
-        deviceLists = lists;
-      }
-      else
-      {
-        for (int i = 0; i < lists.Count; i++)
+        /// <summary>
+        /// 鑾峰彇鎴块棿鐨勮澶囧垪琛�
+        /// </summary>
+        /// <param name="room">褰撳墠鎴块棿</param>
+        /// <returns></returns>
+        public List<HDL_ON.Entity.Function> GetRoomDevice(HDL_ON.Entity.Room room)
         {
-          var dev = lists[i];
-          if (dev.roomIds.Find((id) => id == room.roomId) != null)
-          {
-            //娣诲姞灞炰簬杩欎釜鎴块棿鐨勮澶�;
-            deviceLists.Add(dev);
-          }
+            List<HDL_ON.Entity.Function> deviceLists = new List<Entity.Function>();
+            List<HDL_ON.Entity.Function> lists = GetGatewayDeviceList();
+            if (room.roomId == "6688")
+            {
+                //榛樿涓�涓埧闂村悕锛�6688
+                //鏄剧ず缃戝叧鍏ㄩ儴璁惧
+                deviceLists = lists;
+            }
+            else
+            {
+                for (int i = 0; i < lists.Count; i++)
+                {
+                    var dev = lists[i];
+                    if (dev.roomIds.Find((id) => id == room.roomId) != null)
+                    {
+                        //娣诲姞灞炰簬杩欎釜鎴块棿鐨勮澶�;
+                        deviceLists.Add(dev);
+                    }
+
+                }
+            }
+            return deviceLists;
+        }
+        /// <summary>
+        /// 鑾峰彇璁惧锛堝姛鑳斤級瀵硅薄
+        /// </summary>
+        /// <param name="sid">璁惧鍞竴鏍囪瘑</param>
+        /// <returns></returns>
+        public HDL_ON.Entity.Function GetDevice(string sid)
+        {
+            HDL_ON.Entity.Function device = new Entity.Function() { name = "Unknown" };
+            List<HDL_ON.Entity.Function> deviceLists = GetGatewayDeviceList();
+            for (int i = 0; i < deviceLists.Count; i++)
+            {
+                var dev = deviceLists[i];
+                if (dev.sid == sid)
+                {
+                    device = dev;
+                    break;
+                }
+            }
+            return device;
+        }
+
+        /// <summary>
+        /// 鑾峰彇鍦烘櫙瀵硅薄
+        /// </summary>
+        /// <param name="sid">鍦烘櫙鍞竴鏍囪瘑</param>
+        /// <returns></returns>
+        public HDL_ON.Entity.Scene GetSecne(string sid)
+        {
+            HDL_ON.Entity.Scene scene = new Entity.Scene() { name = "Unknown" };
+            List<HDL_ON.Entity.Scene> sceneLists = GetSceneList();
+            for (int i = 0; i < sceneLists.Count; i++)
+            {
+                var sce = sceneLists[i];
+                if (sce.sid == sid)
+                {
+                    scene = sce;
+                    break;
+                }
+            }
+            return scene;
+        }
+        /// <summary>
+        /// 鑾峰彇瀹夐槻瀵硅薄
+        /// </summary>
+        /// <param name="sid">瀹夐槻鍞竴鏍囪瘑</param>
+        /// <returns></returns>
+        public HDL_ON.Entity.SecurityAlarm GetSecurity(string sid)
+        {
+            HDL_ON.Entity.SecurityAlarm security = new Entity.SecurityAlarm() { name = "Unknown" };
+            List<HDL_ON.Entity.SecurityAlarm> SecurityLists = GetSecurityList();
+            for (int i = 0; i < SecurityLists.Count; i++)
+            {
+                var sce = SecurityLists[i];
+                if (sce.sid == sid)
+                {
+                    security = sce;
+                    break;
+                }
+            }
+            return security;
+        }
+        /// <summary>
+        /// 鑾峰彇鎴块棿鍚�(鍗虫槸=鍖哄煙鍚嶇О)
+        /// </summary>
+        /// <param name="device">璁惧</param>
+        /// <returns></returns>
+        public string GetGetRoomName(HDL_ON.Entity.Function device)
+        {
+            string roomName = "";
+            List<HDL_ON.Entity.Room> roomLists = GetGatewayRoomList();
+            for (int i = 0; i < device.roomIds.Count; i++)
+            {
+                var dev = device.roomIds[i];
+                var room = roomLists.Find((c) => c.roomId == dev);
+                if (room != null)
+                {
+                    roomName += room.floorName + "." + room.roomName + ",";
+                }
+            }
+
+            return roomName.TrimEnd(',');
+        }
+        #region   鍔ㄤ竴鏀瑰洓
+        /// <summary>
+        /// 鑾峰彇璁惧绫诲瀷鍥炬爣
+        /// </summary>
+        /// <param name="functionType">璁惧绫诲瀷</param>
+        /// <returns></returns>
+        public string GetIconPath(string functionType)
+        {
+            string strPath = "";
+            switch (functionType)
+            {
+
+                case SPK.AirSwitch:
+                    {
+                        strPath = "FunctionIcon/Icon/electricalbreaker.png";
+                    }
+                    break;
+                case SPK.PanelSocket:
+                case SPK.ElectricSocket:
+                    {
+                        strPath = "FunctionIcon/Icon/electricalsocket.png";
+                    }
+                    break;
+                case SPK.LightSwitch:
+                case SPK.LightRGB:
+                case SPK.LightRGBW:
+                case SPK.LightCCT:
+                case SPK.LightDimming:
+                    {
+                        strPath = "LogicIcon/lightloguc.png";
+                    }
+                    break;
+                case SPK.CurtainSwitch:
+                case SPK.CurtainRoller:
+                case SPK.CurtainTrietex:
+                    {
+                        strPath = "LogicIcon/curtainlogic.png";
+                    }
+                    break;
+                case SPK.AcStandard:
+                case SPK.HvacAC:
+                    {
+                        strPath = "LogicIcon/airconditionerlogic.png";
+                    }
+                    break;
+                case SPK.HvacCac:
+                    strPath = "FunctionIcon/Icon/hvaccac.png";
+                    break;
+                case SPK.FloorHeatStandard:
+                case SPK.HvacFloorHeat:
+                    {
+                        strPath = "LogicIcon/heatlogic.png";
+                    }
+                    break;
+                case SPK.AirFreshStandard:
+                case SPK.HvacAirFresh:
+                    {
+                        strPath = "LogicIcon/heatlogic.png";
+                    }
+                    break;
+                case SPK.SensorSmoke:
+                case SPK.SensorWater:
+                case SPK.SensorGas:
+                case SPK.SensorDryContact:
+                case SPK.SensorDryContact2:
+                case SPK.SensorShanLan:
+                case SPK.SensorDuiShe:
+                case SPK.SensorPir:
+                case SPK.SensorDoorWindow:
+                case SPK.SensorUtrasonic:
+                case SPK.SenesorMegahealth:
+                case SPK.SenesorMegahealth2:
+                case SPK.SensorEnvironment:
+                case SPK.SensorEnvironment2:
+                case SPK.SensorEnvironment3:
+                case SPK.SensorTemperature:
+                case SPK.SensorHumidity:
+                case SPK.SensorCO2:
+                case SPK.SensorPm25:
+                case SPK.SensorTVOC:
+                case SPK.SensorHcho:
+                case SPK.SensorHelp:
+                    {
+                        strPath = "LogicIcon/sensor.png";
+                    }
+                    break;
+
+            }
+            return strPath;
+        }
+        /// <summary>
+        /// 璁惧绫诲瀷鐨勫垪琛�(鐏厜绫伙紝绐楀笜绫汇�傘�傘��)
+        /// </summary>
+        /// <param name="deviceList">璁惧鍒楄〃</param>
+        /// <returns></returns>
+        public List<string> GetDeviceTypeList(List<HDL_ON.Entity.Function> deviceList)
+        {
+            List<string> deviceStrTypeList = new List<string>();
+            deviceStrTypeList.Clear();
+            ///鐏厜绫�
+            var lightjosn = deviceList.Find((device) =>
+            device.spk == SPK.LightSwitch
+            || device.spk == SPK.LightDimming
+            || device.spk == SPK.LightCCT
+            || device.spk == SPK.LightRGB
+            || device.spk == SPK.LightRGBW
+            );
+            if (lightjosn != null)
+            {
+                deviceStrTypeList.Add(Language.StringByID(StringId.Lights));
+            }
+
+            ///绐楀笜绫�
+            var curtainjosn = deviceList.Find((device) =>
+            device.spk == SPK.CurtainSwitch
+            || device.spk == SPK.CurtainTrietex
+            || device.spk == SPK.CurtainRoller);
+            if (curtainjosn != null)
+            {
+                deviceStrTypeList.Add(Language.StringByID(StringId.Curtain));
+            }
+            ///绌鸿皟绫�
+            var ac = deviceList.Find((device) => device.spk == SPK.AcStandard || device.spk == SPK.HvacAC);
+            if (ac != null)
+            {
+                deviceStrTypeList.Add(Language.StringByID(StringId.AC));
+            }
+            ///鍦版殩绫�
+            var floorHeating = deviceList.Find((device) => device.spk == SPK.FloorHeatStandard || device.spk == SPK.HvacFloorHeat);
+            if (floorHeating != null)
+            {
+                deviceStrTypeList.Add(Language.StringByID(StringId.FloorHeating));
+            }
+            ///鏂伴绫�
+            var airFresh = deviceList.Find((device) => device.spk == SPK.AirFreshStandard || device.spk == SPK.HvacAirFresh);
+            if (airFresh != null)
+            {
+                deviceStrTypeList.Add(Language.StringByID(StringId.AirFresh));
+            }
+            ///浼犳劅鍣ㄧ被
+            var sensor = deviceList.Find((device) =>
+            device.spk == SPK.SensorWater
+            || device.spk == SPK.SensorGas
+            || device.spk == SPK.SensorSmoke
+            || device.spk == SPK.SensorDryContact || device.spk == SPK.SensorDryContact2
+            || device.spk == SPK.SensorShanLan
+            || device.spk == SPK.SensorDuiShe
+            || device.spk == SPK.SensorPir
+            || device.spk == SPK.SensorDoorWindow
+            || device.spk == SPK.SensorUtrasonic
+            || device.spk == SPK.SenesorMegahealth
+            || device.spk == SPK.SenesorMegahealth2
+            || device.spk == SPK.SensorEnvironment
+             || device.spk == SPK.SensorEnvironment2
+              || device.spk == SPK.SensorEnvironment3
+                || device.spk == SPK.SensorTemperature
+                  || device.spk == SPK.SensorHumidity
+                    || device.spk == SPK.SensorCO2
+                      || device.spk == SPK.SensorPm25
+                        || device.spk == SPK.SensorTVOC
+                          || device.spk == SPK.SensorHcho
+                          || device.spk == SPK.SensorHelp
+            );
+            if (sensor != null)
+            {
+                deviceStrTypeList.Add(Language.StringByID(StringId.Sensor));
+            }
+            ///瀹剁數绫�
+            var electric = deviceList.Find((device) =>
+            device.spk == SPK.AirSwitch
+            || device.spk == SPK.PanelSocket
+            || device.spk == SPK.ElectricSocket
+            );
+            if (electric != null)
+            {
+                deviceStrTypeList.Add(Language.StringByID(StringId.Electric));
+            }
+            return deviceStrTypeList;
 
         }
-      }
-      return deviceLists;
-    }
-    /// <summary>
-    /// 鑾峰彇璁惧锛堝姛鑳斤級瀵硅薄
-    /// </summary>
-    /// <param name="sid">璁惧鍞竴鏍囪瘑</param>
-    /// <returns></returns>
-    public HDL_ON.Entity.Function GetDevice(string sid)
-    {
-      HDL_ON.Entity.Function device = new Entity.Function() { name = "Unknown" };
-      List<HDL_ON.Entity.Function> deviceLists = GetGatewayDeviceList();
-      for (int i = 0; i < deviceLists.Count; i++)
-      {
-        var dev = deviceLists[i];
-        if (dev.sid == sid)
+        /// <summary>
+        /// 璁惧绫诲瀷FunctionType鍒楄〃
+        /// </summary>
+        /// <param name="deviceType">璁惧绫诲瀷(鐏厜绫伙紝绐楀笜绫汇��)</param>
+        /// <returns></returns>
+        public List<string> GetDeviceTypeFunctionList(string deviceType)
         {
-          device = dev;
-          break;
-        }
-      }
-      return device;
-    }
-
-    /// <summary>
-    /// 鑾峰彇鍦烘櫙瀵硅薄
-    /// </summary>
-    /// <param name="sid">鍦烘櫙鍞竴鏍囪瘑</param>
-    /// <returns></returns>
-    public HDL_ON.Entity.Scene GetSecne(string sid)
-    {
-      HDL_ON.Entity.Scene scene = new Entity.Scene() { name = "Unknown" };
-      List<HDL_ON.Entity.Scene> sceneLists = GetSceneList();
-      for (int i = 0; i < sceneLists.Count; i++)
-      {
-        var sce = sceneLists[i];
-        if (sce.sid == sid)
-        {
-          scene = sce;
-          break;
-        }
-      }
-      return scene;
-    }
-    /// <summary>
-    /// 鑾峰彇瀹夐槻瀵硅薄
-    /// </summary>
-    /// <param name="sid">瀹夐槻鍞竴鏍囪瘑</param>
-    /// <returns></returns>
-    public HDL_ON.Entity.SecurityAlarm GetSecurity(string sid)
-    {
-      HDL_ON.Entity.SecurityAlarm security = new Entity.SecurityAlarm() { name = "Unknown" };
-      List<HDL_ON.Entity.SecurityAlarm> SecurityLists = GetSecurityList();
-      for (int i = 0; i < SecurityLists.Count; i++)
-      {
-        var sce = SecurityLists[i];
-        if (sce.sid == sid)
-        {
-          security = sce;
-          break;
-        }
-      }
-      return security;
-    }
-    /// <summary>
-    /// 鑾峰彇鎴块棿鍚�(鍗虫槸=鍖哄煙鍚嶇О)
-    /// </summary>
-    /// <param name="device">璁惧</param>
-    /// <returns></returns>
-    public string GetGetRoomName(HDL_ON.Entity.Function device)
-    {
-      string roomName = "";
-      List<HDL_ON.Entity.Room> roomLists = GetGatewayRoomList();
-      for (int i = 0; i < device.roomIds.Count; i++)
-      {
-        var dev = device.roomIds[i];
-        var room = roomLists.Find((c) => c.roomId == dev);
-        if (room != null)
-        {
-          roomName += room.floorName + "." + room.roomName + ",";
-        }
-      }
-
-      return roomName.TrimEnd(',');
-    }
-    #region   鍔ㄤ竴鏀瑰洓
-    /// <summary>
-    /// 鑾峰彇璁惧绫诲瀷鍥炬爣
-    /// </summary>
-    /// <param name="functionType">璁惧绫诲瀷</param>
-    /// <returns></returns>
-    public string GetIconPath(string functionType)
-    {
-      string strPath = "";
-      switch (functionType)
-      {
-
-        case SPK.AirSwitch:
-          {
-            strPath = "FunctionIcon/Icon/electricalbreaker.png";
-          }
-          break;
-        case SPK.PanelSocket:
-        case SPK.ElectricSocket:
-          {
-            strPath = "FunctionIcon/Icon/electricalsocket.png";
-          }
-          break;
-        case SPK.LightSwitch:
-        case SPK.LightRGB:
-        case SPK.LightRGBW:
-        case SPK.LightCCT:
-        case SPK.LightDimming:
-          {
-            strPath = "LogicIcon/lightloguc.png";
-          }
-          break;
-        case SPK.CurtainSwitch:
-        case SPK.CurtainRoller:
-        case SPK.CurtainTrietex:
-          {
-            strPath = "LogicIcon/curtainlogic.png";
-          }
-          break;
-        case SPK.AcStandard:
-        case SPK.HvacAC:
-          {
-            strPath = "LogicIcon/airconditionerlogic.png";
-          }
-          break;
-        case SPK.HvacCac:
-            strPath = "FunctionIcon/Icon/hvaccac.png";
-            break;
-        case SPK.FloorHeatStandard:
-        case SPK.HvacFloorHeat:
-          {
-            strPath = "LogicIcon/heatlogic.png";
-          }
-          break;
-        case SPK.AirFreshStandard:
-        case SPK.HvacAirFresh:
-          {
-            strPath = "LogicIcon/heatlogic.png";
-          }
-          break;
-        case SPK.SensorSmoke:
-        case SPK.SensorWater:
-        case SPK.SensorGas:
-        case SPK.SensorDryContact:
-        case SPK.SensorDryContact2:
-        case SPK.SensorShanLan:
-        case SPK.SensorDuiShe:
-        case SPK.SensorPir:
-        case SPK.SensorDoorWindow:
-        case SPK.SensorUtrasonic:
-        case SPK.SenesorMegahealth:
-        case SPK.SenesorMegahealth2:
-        case SPK.SensorEnvironment:
-        case SPK.SensorEnvironment2:
-        case SPK.SensorEnvironment3:
-        case SPK.SensorTemperature:
-        case SPK.SensorHumidity:
-        case SPK.SensorCO2:
-        case SPK.SensorPm25:
-        case SPK.SensorTVOC:
-        case SPK.SensorHcho:
-          {
-            strPath = "LogicIcon/sensor.png";
-          }
-          break;
-
-      }
-      return strPath;
-    }
-    /// <summary>
-    /// 璁惧绫诲瀷鐨勫垪琛�(鐏厜绫伙紝绐楀笜绫汇�傘�傘��)
-    /// </summary>
-    /// <param name="deviceList">璁惧鍒楄〃</param>
-    /// <returns></returns>
-    public List<string> GetDeviceTypeList(List<HDL_ON.Entity.Function> deviceList)
-    {
-      List<string> deviceStrTypeList = new List<string>();
-      deviceStrTypeList.Clear();
-      ///鐏厜绫�
-      var lightjosn = deviceList.Find((device) =>
-      device.spk == SPK.LightSwitch
-      || device.spk == SPK.LightDimming
-      || device.spk == SPK.LightCCT
-      || device.spk == SPK.LightRGB
-      || device.spk == SPK.LightRGBW
-      );
-      if (lightjosn != null)
-      {
-        deviceStrTypeList.Add(Language.StringByID(StringId.Lights));
-      }
-
-      ///绐楀笜绫�
-      var curtainjosn = deviceList.Find((device) =>
-      device.spk == SPK.CurtainSwitch
-      || device.spk == SPK.CurtainTrietex
-      || device.spk == SPK.CurtainRoller);
-      if (curtainjosn != null)
-      {
-        deviceStrTypeList.Add(Language.StringByID(StringId.Curtain));
-      }
-      ///绌鸿皟绫�
-      var ac = deviceList.Find((device) => device.spk == SPK.AcStandard || device.spk == SPK.HvacAC);
-      if (ac != null)
-      {
-        deviceStrTypeList.Add(Language.StringByID(StringId.AC));
-      }
-      ///鍦版殩绫�
-      var floorHeating = deviceList.Find((device) => device.spk == SPK.FloorHeatStandard || device.spk == SPK.HvacFloorHeat);
-      if (floorHeating != null)
-      {
-        deviceStrTypeList.Add(Language.StringByID(StringId.FloorHeating));
-      }
-      ///鏂伴绫�
-      var airFresh = deviceList.Find((device) => device.spk == SPK.AirFreshStandard || device.spk == SPK.HvacAirFresh);
-      if (airFresh != null)
-      {
-        deviceStrTypeList.Add(Language.StringByID(StringId.AirFresh));
-      }
-      ///浼犳劅鍣ㄧ被
-      var sensor = deviceList.Find((device) =>
-      device.spk == SPK.SensorWater
-      || device.spk == SPK.SensorGas
-      || device.spk == SPK.SensorSmoke
-      || device.spk == SPK.SensorDryContact || device.spk == SPK.SensorDryContact2
-      || device.spk == SPK.SensorShanLan
-      || device.spk == SPK.SensorDuiShe
-      || device.spk == SPK.SensorPir
-      || device.spk == SPK.SensorDoorWindow
-      || device.spk == SPK.SensorUtrasonic
-      || device.spk == SPK.SenesorMegahealth
-      || device.spk == SPK.SenesorMegahealth2
-      || device.spk == SPK.SensorEnvironment
-       || device.spk == SPK.SensorEnvironment2
-        || device.spk == SPK.SensorEnvironment3
-          || device.spk == SPK.SensorTemperature
-            || device.spk == SPK.SensorHumidity
-              || device.spk == SPK.SensorCO2
-                || device.spk == SPK.SensorPm25
-                  || device.spk == SPK.SensorTVOC
-                    || device.spk == SPK.SensorHcho
-      );
-      if (sensor != null)
-      {
-        deviceStrTypeList.Add(Language.StringByID(StringId.Sensor));
-      }
-      ///瀹剁數绫�
-      var electric = deviceList.Find((device) =>
-      device.spk == SPK.AirSwitch
-      || device.spk == SPK.PanelSocket
-      || device.spk == SPK.ElectricSocket
-      );
-      if (electric != null)
-      {
-        deviceStrTypeList.Add(Language.StringByID(StringId.Electric));
-      }
-      return deviceStrTypeList;
-
-    }
-    /// <summary>
-    /// 璁惧绫诲瀷FunctionType鍒楄〃
-    /// </summary>
-    /// <param name="deviceType">璁惧绫诲瀷(鐏厜绫伙紝绐楀笜绫汇��)</param>
-    /// <returns></returns>
-    public List<string> GetDeviceTypeFunctionList(string deviceType)
-    {
-      List<string> functionTypeList = new List<string>();
+            List<string> functionTypeList = new List<string>();
             ///鐏厜绫�
             if (deviceType == Language.StringByID(StringId.Lights))
             {
@@ -556,6 +558,7 @@
                 functionTypeList.Add(SPK.SensorPm25);
                 functionTypeList.Add(SPK.SensorTVOC);
                 functionTypeList.Add(SPK.SensorHcho);
+                functionTypeList.Add(SPK.SensorHelp);
 
 
             }
@@ -566,7 +569,8 @@
                 functionTypeList.Add(SPK.PanelSocket);
                 functionTypeList.Add(SPK.ElectricSocket);
             }
-            else {
+            else
+            {
                 functionTypeList.Add(SPK.LightSwitch);
                 functionTypeList.Add(SPK.LightDimming);
                 functionTypeList.Add(SPK.LightRGB);
@@ -609,410 +613,412 @@
                 functionTypeList.Add(SPK.PanelSocket);
                 functionTypeList.Add(SPK.ElectricSocket);
                 functionTypeList.Add(SPK.HvacCac);
+                functionTypeList.Add(SPK.SensorHelp);
 
             }
 
 
-      return functionTypeList;
+            return functionTypeList;
 
-    }
-    /// <summary>
-    /// 鏉′欢/鐩爣鏀寔璁惧
-    /// </summary>
-    /// <returns></returns>
-    public List<string> GetSupportEquipment(string if_type)
-    {
-      List<string> deviceTypeList = new List<string>();
-      switch (if_type)
-      {
-        case condition_if:
-          {
-            deviceTypeList.Add(SPK.LightSwitch);
-            deviceTypeList.Add(SPK.LightRGB);
-            deviceTypeList.Add(SPK.LightRGBW);
-            deviceTypeList.Add(SPK.LightDimming);
-            deviceTypeList.Add(SPK.LightCCT);
-            deviceTypeList.Add(SPK.CurtainSwitch);
-            deviceTypeList.Add(SPK.CurtainRoller);
-            deviceTypeList.Add(SPK.CurtainTrietex);
-            deviceTypeList.Add(SPK.AcStandard); deviceTypeList.Add(SPK.HvacAC);
-            deviceTypeList.Add(SPK.AirFreshStandard); deviceTypeList.Add(SPK.HvacAirFresh);
-            deviceTypeList.Add(SPK.FloorHeatStandard); deviceTypeList.Add(SPK.HvacFloorHeat);
-            deviceTypeList.Add(SPK.SensorSmoke);
-            deviceTypeList.Add(SPK.SensorWater);
-            deviceTypeList.Add(SPK.SensorGas);
-            deviceTypeList.Add(SPK.SensorDryContact); deviceTypeList.Add(SPK.SensorDryContact2);
-            deviceTypeList.Add(SPK.SensorShanLan);
-            deviceTypeList.Add(SPK.SensorDuiShe);
-            deviceTypeList.Add(SPK.SensorPir);
-            deviceTypeList.Add(SPK.SensorDoorWindow);
-            deviceTypeList.Add(SPK.SensorUtrasonic);
-            deviceTypeList.Add(SPK.SenesorMegahealth);
-            deviceTypeList.Add(SPK.SenesorMegahealth2);
-            deviceTypeList.Add(SPK.SensorEnvironment);
-            deviceTypeList.Add(SPK.SensorEnvironment2);
-            deviceTypeList.Add(SPK.SensorEnvironment3);
-            deviceTypeList.Add(SPK.SensorTemperature);
-            deviceTypeList.Add(SPK.SensorHumidity);
-            deviceTypeList.Add(SPK.SensorCO2);
-            deviceTypeList.Add(SPK.SensorPm25);
-            deviceTypeList.Add(SPK.SensorTVOC);
-            deviceTypeList.Add(SPK.SensorHcho);
-            deviceTypeList.Add(SPK.AirSwitch);
-            deviceTypeList.Add(SPK.PanelSocket);
-            deviceTypeList.Add(SPK.ElectricSocket);
-                        deviceTypeList.Add(SPK.HvacCac);
-
-          }
-          break;
-        case target_if:
-          {
-            deviceTypeList.Add(SPK.LightSwitch);
-            deviceTypeList.Add(SPK.LightRGB);
-            deviceTypeList.Add(SPK.LightRGBW);
-            deviceTypeList.Add(SPK.LightDimming);
-            deviceTypeList.Add(SPK.LightCCT);
-            deviceTypeList.Add(SPK.CurtainSwitch);
-            deviceTypeList.Add(SPK.CurtainRoller);
-            deviceTypeList.Add(SPK.CurtainTrietex);
-            deviceTypeList.Add(SPK.AcStandard); deviceTypeList.Add(SPK.HvacAC);
-            deviceTypeList.Add(SPK.FloorHeatStandard); deviceTypeList.Add(SPK.HvacFloorHeat);
-            deviceTypeList.Add(SPK.AirFreshStandard); deviceTypeList.Add(SPK.HvacAirFresh);
-            deviceTypeList.Add(SPK.AirSwitch);
-            deviceTypeList.Add(SPK.PanelSocket);
-            deviceTypeList.Add(SPK.ElectricSocket);
-          }
-          break;
-      }
-      return deviceTypeList;
-    }
-    #endregion
-    /// <summary>
-    /// 鏄剧ず鐨勮澶囧垪琛�
-    /// </summary>
-    /// <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)
-    {
-      List<HDL_ON.Entity.Function> devList = new List<Entity.Function>();
-      for (int i = 0; i < deviceList.Count; i++)
-      {
-        var dev = deviceList[i];
-        //杩囨护鎺変笉闇�瑕佹樉绀虹殑璁惧
-        if (functionType.Contains(dev.spk))
-        {
-          devList.Add(dev);
         }
-
-      }
-
-      return devList;
-    }
-    /// <summary>
-    /// 杩斿洖鏈�缁堟敮鎸佹樉绀哄嚭鏉ョ殑璁惧鍒楄〃
-    /// </summary>
-    /// <param name="room">褰撳墠鎴块棿</param>
-    /// <param name="str">鍒ゆ柇绗︼紙琛ㄧず=杈撳叆璁惧鍜岃緭鍑鸿澶囷級</param>
-    /// <returns></returns>
-    public List<Entity.Function> GetFunctionDeviceList(Entity.Room room, string str)
-    {
-      List<string> functionTypeList = GetSupportEquipment(str);
-      //杩斿洖鎴块棿璁惧鍒楄〃
-      var roomDeviceList = GetRoomDevice(room);
-      //杩斿洖鏈�缁堟敮鎸佹樉绀哄嚭鏉ョ殑璁惧鍒楄〃
-      var list = GetShowDeviceList(functionTypeList, roomDeviceList);
-      return list;
-    }
-    /// <summary>
-    /// 缃戝叧ID(鑾峰彇鍢変箰缃戝叧ID)
-    /// </summary>
-    public string GatewayId
-    {
-      get
-      {
-        if (Entity.DB_ResidenceData.Instance.HomeGateway == null)
+        /// <summary>
+        /// 鏉′欢/鐩爣鏀寔璁惧
+        /// </summary>
+        /// <returns></returns>
+        public List<string> GetSupportEquipment(string if_type)
         {
-          return DriverLayer.Control.Ins.GatewayId;
-        }
-        return Entity.DB_ResidenceData.Instance.HomeGateway.gatewayId;
-      }
-    }
-    /// <summary>
-    /// 浣忓畢ID
-    /// </summary>
-    public string HomeId
-    {
-      get
-      {
-        return Entity.DB_ResidenceData.Instance.CurrentRegion.id;
-      }
-    }
-    /// <summary>
-    /// 鏄惁涓哄叾浠栦富鐢ㄦ埛鍒嗕韩杩囨潵鐨勪綇瀹�
-    /// </summary>
-    public bool IsOthreShare
-    {
-      get
-      {
-        return Entity.DB_ResidenceData.Instance.CurrentRegion.isOtherShare;
-      }
-    }
-
-    #region 楂樺痉鍧愭爣杞琖GS84鍧愭爣
-    /// <summary>
-    /// 楂樺痉鍧愭爣杞琖GS84鍧愭爣
-    /// </summary>
-    /// <param name="in_lng"></param>
-    /// <param name="in_lat"></param>
-    /// <param name="out_lng"></param>
-    /// <param name="out_lat"></param>
-    public void GCJ02_to_WGS84(double in_lng, double in_lat, out double out_lng, out double out_lat)
-    {
-      if (OutOfChina(in_lat, in_lng))
-      {
-        out_lng = in_lng;
-        out_lat = in_lat;
-        return;
-      }
-
-      CalculateDev(in_lng, in_lat, out out_lng, out out_lat);
-      out_lng = in_lng - out_lng;
-      out_lat = in_lat - out_lat;
-    }
-    #endregion
-
-    #region WGS84鍧愭爣杞珮寰峰潗鏍�
-    /// <summary>
-    /// WGS84鍧愭爣杞珮寰峰潗鏍�
-    /// </summary>
-    /// <param name="in_lng">缁忓害</param>
-    /// <param name="in_lat">绾害</param>
-    /// <param name="out_lng"></param>
-    /// <param name="out_lat"></param>
-    public void WGS84_to_GCJ02(double in_lng, double in_lat, out double out_lng, out double out_lat)
-    {
-      if (OutOfChina(in_lat, in_lng))
-      {
-        out_lng = in_lng;
-        out_lat = in_lat;
-        return;
-      }
-
-      CalculateDev(in_lng, in_lat, out out_lng, out out_lat);
-      out_lng = in_lng + out_lng;
-      out_lat = in_lat + out_lat;
-    }
-    #endregion
-
-    /// <summary>
-    /// 鍧愭爣鏄惁鍦ㄤ腑鍥藉鍐�
-    /// </summary>
-    /// <param name="lat"></param>
-    /// <param name="lng"></param>
-    /// <returns></returns>
-    public bool OutOfChina(double lat, double lng)
-    {
-      if (lng < 72.004 || lng > 137.8347)
-        return true;
-      if (lat < 0.8293 || lat > 55.8271)
-        return true;
-      return false;
-    }
-    /// <summary>
-    /// 璁$畻鍋忓樊
-    /// </summary>
-    /// <param name="in_lng"></param>
-    /// <param name="in_lat"></param>
-    /// <param name="dLng"></param>
-    /// <param name="dLat"></param>
-    private void CalculateDev(double in_lng, double in_lat, out double dLng, out double dLat)
-    {
-      dLat = TransformLat(in_lng - 105.0, in_lat - 35.0);
-      dLng = TransformLng(in_lng - 105.0, in_lat - 35.0);
-
-      double radLat = in_lat / 180.0 * pi;
-      double magic = Math.Sin(radLat);
-      magic = 1 - ee * magic * magic;
-      double sqrtMagic = Math.Sqrt(magic);
-      dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi);
-      dLng = (dLng * 180.0) / (a / sqrtMagic * Math.Cos(radLat) * pi);
-    }
-
-    private double TransformLat(double x, double y)
-    {
-      double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.Sqrt(Math.Abs(x));
-      ret += (20.0 * Math.Sin(6.0 * x * pi) + 20.0 * Math.Sin(2.0 * x * pi)) * 2.0 / 3.0;
-      ret += (20.0 * Math.Sin(y * pi) + 40.0 * Math.Sin(y / 3.0 * pi)) * 2.0 / 3.0;
-      ret += (160.0 * Math.Sin(y / 12.0 * pi) + 320 * Math.Sin(y * pi / 30.0)) * 2.0 / 3.0;
-      return ret;
-    }
-    private double TransformLng(double x, double y)
-    {
-      double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.Sqrt(Math.Abs(x));
-      ret += (20.0 * Math.Sin(6.0 * x * pi) + 20.0 * Math.Sin(2.0 * x * pi)) * 2.0 / 3.0;
-      ret += (20.0 * Math.Sin(x * pi) + 40.0 * Math.Sin(x / 3.0 * pi)) * 2.0 / 3.0;
-      ret += (150.0 * Math.Sin(x / 12.0 * pi) + 300.0 * Math.Sin(x / 30.0 * pi)) * 2.0 / 3.0;
-      return ret;
-    }
-    // 妞悆鍙傛暟-鍦嗗懆鐜�
-    private const double pi = 3.14159265358979324;
-
-    // (鍖椾含54)妞悆闀垮崐杞达紝鍗槦妞悆鍧愭爣鎶曞奖鍒板钩闈㈠湴鍥惧潗鏍囩郴鐨勬姇褰卞洜瀛�
-    private const double a = 6378245.0;
-    /*
-        * Krasovsky 1940 (鍖椾含54)妞悆闀垮崐杞寸涓�鍋忓績鐜囧钩鏂�
-        * 璁$畻鏂瑰紡锛�
-        * 闀垮崐杞达細
-        * a = 6378245.0
-        * 鎵佺巼锛�
-        * 1/f = 298.3锛堝彉閲忕浉鍏宠绠椾负锛�(a-b)/a锛�
-        * 鐭崐杞达細
-        * b = 6356863.0188 (鍙橀噺鐩稿叧璁$畻鏂规硶涓猴細b = a * (1 - f))
-        * 绗竴鍋忓績鐜囧钩鏂�:
-        * e2 = (a^2 - b^2) / a^2;
-    */
-    private const double ee = 0.00669342162296594323;
-
-    /// <summary>
-    /// APP涓婃姤GPS缁忕含搴�
-    /// </summary>
-    /// <param name="lon">APP GPS缁忓害</param>
-    /// <param name="lat">APP GPS绾害</param>
-    public void AppLatAndLonEvent(double lon, double lat)
-    {
-      Console.WriteLine($"GPS缁忓害===={lon}  \nGPS绾害===={lat}");
-      //Application.LocationAction += (lon, lat) =>
-      //{
-      //  Console.WriteLine($"GPS缁忓害===={lon}");
-      //  Console.WriteLine($"GPS绾害===={lat}");
-      //  ////GPS鍧愭爣杞垚楂樺痉鍧愭爣
-      //  //double out_lng, out_lat;
-      //  //this.WGS84_to_GCJ02(lon, lat, out out_lng, out out_lat);
-      //  //涓婃姤缁忕含搴�
-      //  this.AutomatedGeofenceStatusReporting(lon, lat);
-      //};
-      //涓婃姤缁忕含搴�<gps 涓婃姤鏉′欢澶т簬30绉掍笖绉诲姩璺濈澶т簬100绫筹紝涓婃姤缁忕含搴�>
-      this.AutomatedGeofenceStatusReporting(lon, lat);
-    }
-
-    /// <summary>
-    /// 鑷姩鍖栧湴鐞嗗洿鏍忕姸鎬佷笂鎶ヤ簯绔�
-    /// </summary>
-    /// <param name="out_lng">APP GPS缁忓害</param>
-    /// <param name="out_lat">APP GPS绾害</param>
-    private void AutomatedGeofenceStatusReporting(double out_lng, double out_lat)
-    {
-      if (IsOthreShare)
-      {
-        //涓嶆槸涓昏处鍙风洿鎺ヨ繑鍥�
-        return;
-      }
-      List<LogicData> logicDataList = new List<LogicData>();
-      logicDataList.Clear();
-      System.Threading.Tasks.Task.Run(() =>
-      {
-        try
-        {
-          //鑾峰彇閫昏緫ID鍒楄〃锛岀洰鍓嶉拡瀵规墍鏈�<澶囨敞:濡傛灉鍙拡瀵瑰綋鍓嶆墜鏈虹殑璇濓紝鍙互鐩存帴鎷跨紦瀛樻暟鎹嚜鍔ㄥ寲鍒楄〃閬嶅巻>
-          var idStr = Send.GetLogicIdList();
-          if (idStr.Code == "0" && idStr.Data != null && idStr.Data.ToString() != "")
-          {
-            var date = Newtonsoft.Json.JsonConvert.SerializeObject(idStr.Data);
-            logicDataList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<LogicData>>(date);
-          }
-          ///鏈夎嚜鍔ㄥ垪琛ㄦ墠澶勭悊
-          if (logicDataList.Count > 0)
-          {
-            ///閬嶅巻鎵�鏈夊垪琛�
-            for (int i = 0; i < logicDataList.Count; i++)
+            List<string> deviceTypeList = new List<string>();
+            switch (if_type)
             {
-              var logicDate = logicDataList[i];
-              ///鑷姩鍖栨病鏈夐厤缃湴鐞嗗洿鏍忎笉澶勭悊
-              if (string.IsNullOrEmpty(logicDate.geo_fence.latitude) || string.IsNullOrEmpty(logicDate.geo_fence.longitude))
-              {
-                //缁忕含搴︿负绌�,璁や负鑷姩鍖栨病鏈夐厤缃湴鐞嗗洿鏍忥紝涓嶅鐞�;
-                continue;
-              }
-              //鑷姩鍖栭厤缃緭鍏ユ潯浠剁含搴�
-              double lat = Convert.ToDouble(logicDate.geo_fence.latitude.Replace(",", "."));
-              //鑷姩鍖栭厤缃緭鍏ユ潯浠剁粡搴�
-              double lon = Convert.ToDouble(logicDate.geo_fence.longitude.Replace(",", "."));
-              //鑷姩鍖栭厤缃緭鍏ユ潯浠�<鍦扮悊鍥存爮鍗婂緞><鍗曚綅锛屽叕閲屻�佸崈绫�.绫�>
-              int radius = int.Parse(logicDate.geo_fence.radius);
-              //璁$畻2涓粡绾害涔嬮棿鐨勮窛绂�
-              int r = Infrastructure.Service.Helper.CalculatedDistance.Distance(out_lat, out_lng, lat, lon);
-              //瀹氫箟涓�涓眬閮ㄥ彉閲�
-              string direction = string.Empty;
-              //涓ょ偣璺濈灏忎簬閰嶇疆璺濈<鏃㈣嚜鍔ㄥ寲閰嶇疆杈撳叆鏉′欢鍦扮悊鍥存爮鍗婂緞>,璇存槑杩涘叆鍖哄煙
-              if (r < radius)
-              {
-                //鍒拌揪鏌愬湴
-                direction = "arrive";
-              }
-              else
-              {
-                //绂诲紑
-                direction = "leave";
-              }
-              ///閬嶅巻缂撳瓨鍒楄〃<涓嶄负绌鸿鏄庢暟鎹凡缁忔帹閫佽繃锛屼笉鍐嶆帹閫�>
-              var isPush = pushList.Find((o) => o.homeId == HomeId && o.userId == UserInfo.Current.ID && o.userLogicId == logicDate.userLogicId && o.arriveOnLeave == direction);
-              if (isPush == null)
-              {
-                //鎺ㄩ�佺粰浜戠鏄惁鎴愬姛
-                bool push = Send.GeoFenceStateReport(logicDate.userLogicId, logicDate.sid, direction);
-                if (push)
+                case condition_if:
+                    {
+                        deviceTypeList.Add(SPK.LightSwitch);
+                        deviceTypeList.Add(SPK.LightRGB);
+                        deviceTypeList.Add(SPK.LightRGBW);
+                        deviceTypeList.Add(SPK.LightDimming);
+                        deviceTypeList.Add(SPK.LightCCT);
+                        deviceTypeList.Add(SPK.CurtainSwitch);
+                        deviceTypeList.Add(SPK.CurtainRoller);
+                        deviceTypeList.Add(SPK.CurtainTrietex);
+                        deviceTypeList.Add(SPK.AcStandard); deviceTypeList.Add(SPK.HvacAC);
+                        deviceTypeList.Add(SPK.AirFreshStandard); deviceTypeList.Add(SPK.HvacAirFresh);
+                        deviceTypeList.Add(SPK.FloorHeatStandard); deviceTypeList.Add(SPK.HvacFloorHeat);
+                        deviceTypeList.Add(SPK.SensorSmoke);
+                        deviceTypeList.Add(SPK.SensorWater);
+                        deviceTypeList.Add(SPK.SensorGas);
+                        deviceTypeList.Add(SPK.SensorDryContact); deviceTypeList.Add(SPK.SensorDryContact2);
+                        deviceTypeList.Add(SPK.SensorShanLan);
+                        deviceTypeList.Add(SPK.SensorDuiShe);
+                        deviceTypeList.Add(SPK.SensorPir);
+                        deviceTypeList.Add(SPK.SensorDoorWindow);
+                        deviceTypeList.Add(SPK.SensorUtrasonic);
+                        deviceTypeList.Add(SPK.SenesorMegahealth);
+                        deviceTypeList.Add(SPK.SenesorMegahealth2);
+                        deviceTypeList.Add(SPK.SensorEnvironment);
+                        deviceTypeList.Add(SPK.SensorEnvironment2);
+                        deviceTypeList.Add(SPK.SensorEnvironment3);
+                        deviceTypeList.Add(SPK.SensorTemperature);
+                        deviceTypeList.Add(SPK.SensorHumidity);
+                        deviceTypeList.Add(SPK.SensorCO2);
+                        deviceTypeList.Add(SPK.SensorPm25);
+                        deviceTypeList.Add(SPK.SensorTVOC);
+                        deviceTypeList.Add(SPK.SensorHcho);
+                        deviceTypeList.Add(SPK.AirSwitch);
+                        deviceTypeList.Add(SPK.PanelSocket);
+                        deviceTypeList.Add(SPK.ElectricSocket);
+                        deviceTypeList.Add(SPK.HvacCac);
+                        deviceTypeList.Add(SPK.SensorHelp);
+
+                    }
+                    break;
+                case target_if:
+                    {
+                        deviceTypeList.Add(SPK.LightSwitch);
+                        deviceTypeList.Add(SPK.LightRGB);
+                        deviceTypeList.Add(SPK.LightRGBW);
+                        deviceTypeList.Add(SPK.LightDimming);
+                        deviceTypeList.Add(SPK.LightCCT);
+                        deviceTypeList.Add(SPK.CurtainSwitch);
+                        deviceTypeList.Add(SPK.CurtainRoller);
+                        deviceTypeList.Add(SPK.CurtainTrietex);
+                        deviceTypeList.Add(SPK.AcStandard); deviceTypeList.Add(SPK.HvacAC);
+                        deviceTypeList.Add(SPK.FloorHeatStandard); deviceTypeList.Add(SPK.HvacFloorHeat);
+                        deviceTypeList.Add(SPK.AirFreshStandard); deviceTypeList.Add(SPK.HvacAirFresh);
+                        deviceTypeList.Add(SPK.AirSwitch);
+                        deviceTypeList.Add(SPK.PanelSocket);
+                        deviceTypeList.Add(SPK.ElectricSocket);
+                    }
+                    break;
+            }
+            return deviceTypeList;
+        }
+        #endregion
+        /// <summary>
+        /// 鏄剧ず鐨勮澶囧垪琛�
+        /// </summary>
+        /// <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)
+        {
+            List<HDL_ON.Entity.Function> devList = new List<Entity.Function>();
+            for (int i = 0; i < deviceList.Count; i++)
+            {
+                var dev = deviceList[i];
+                //杩囨护鎺変笉闇�瑕佹樉绀虹殑璁惧
+                if (functionType.Contains(dev.spk))
                 {
-                  ///娣诲姞鍒版帹閫佸垪琛�
-                  pushList.Add(new Push
-                  {
-                    homeId = HomeId,
-                    userId = UserInfo.Current.ID,
-                    userLogicId = logicDate.userLogicId,
-                    sid = logicDate.sid,
-                    arriveOnLeave = direction,
-                  });
+                    devList.Add(dev);
                 }
-              }
+
             }
 
-          }
+            return devList;
         }
-        catch { }
-      });
+        /// <summary>
+        /// 杩斿洖鏈�缁堟敮鎸佹樉绀哄嚭鏉ョ殑璁惧鍒楄〃
+        /// </summary>
+        /// <param name="room">褰撳墠鎴块棿</param>
+        /// <param name="str">鍒ゆ柇绗︼紙琛ㄧず=杈撳叆璁惧鍜岃緭鍑鸿澶囷級</param>
+        /// <returns></returns>
+        public List<Entity.Function> GetFunctionDeviceList(Entity.Room room, string str)
+        {
+            List<string> functionTypeList = GetSupportEquipment(str);
+            //杩斿洖鎴块棿璁惧鍒楄〃
+            var roomDeviceList = GetRoomDevice(room);
+            //杩斿洖鏈�缁堟敮鎸佹樉绀哄嚭鏉ョ殑璁惧鍒楄〃
+            var list = GetShowDeviceList(functionTypeList, roomDeviceList);
+            return list;
+        }
+        /// <summary>
+        /// 缃戝叧ID(鑾峰彇鍢変箰缃戝叧ID)
+        /// </summary>
+        public string GatewayId
+        {
+            get
+            {
+                if (Entity.DB_ResidenceData.Instance.HomeGateway == null)
+                {
+                    return DriverLayer.Control.Ins.GatewayId;
+                }
+                return Entity.DB_ResidenceData.Instance.HomeGateway.gatewayId;
+            }
+        }
+        /// <summary>
+        /// 浣忓畢ID
+        /// </summary>
+        public string HomeId
+        {
+            get
+            {
+                return Entity.DB_ResidenceData.Instance.CurrentRegion.id;
+            }
+        }
+        /// <summary>
+        /// 鏄惁涓哄叾浠栦富鐢ㄦ埛鍒嗕韩杩囨潵鐨勪綇瀹�
+        /// </summary>
+        public bool IsOthreShare
+        {
+            get
+            {
+                return Entity.DB_ResidenceData.Instance.CurrentRegion.isOtherShare;
+            }
+        }
+
+        #region 楂樺痉鍧愭爣杞琖GS84鍧愭爣
+        /// <summary>
+        /// 楂樺痉鍧愭爣杞琖GS84鍧愭爣
+        /// </summary>
+        /// <param name="in_lng"></param>
+        /// <param name="in_lat"></param>
+        /// <param name="out_lng"></param>
+        /// <param name="out_lat"></param>
+        public void GCJ02_to_WGS84(double in_lng, double in_lat, out double out_lng, out double out_lat)
+        {
+            if (OutOfChina(in_lat, in_lng))
+            {
+                out_lng = in_lng;
+                out_lat = in_lat;
+                return;
+            }
+
+            CalculateDev(in_lng, in_lat, out out_lng, out out_lat);
+            out_lng = in_lng - out_lng;
+            out_lat = in_lat - out_lat;
+        }
+        #endregion
+
+        #region WGS84鍧愭爣杞珮寰峰潗鏍�
+        /// <summary>
+        /// WGS84鍧愭爣杞珮寰峰潗鏍�
+        /// </summary>
+        /// <param name="in_lng">缁忓害</param>
+        /// <param name="in_lat">绾害</param>
+        /// <param name="out_lng"></param>
+        /// <param name="out_lat"></param>
+        public void WGS84_to_GCJ02(double in_lng, double in_lat, out double out_lng, out double out_lat)
+        {
+            if (OutOfChina(in_lat, in_lng))
+            {
+                out_lng = in_lng;
+                out_lat = in_lat;
+                return;
+            }
+
+            CalculateDev(in_lng, in_lat, out out_lng, out out_lat);
+            out_lng = in_lng + out_lng;
+            out_lat = in_lat + out_lat;
+        }
+        #endregion
+
+        /// <summary>
+        /// 鍧愭爣鏄惁鍦ㄤ腑鍥藉鍐�
+        /// </summary>
+        /// <param name="lat"></param>
+        /// <param name="lng"></param>
+        /// <returns></returns>
+        public bool OutOfChina(double lat, double lng)
+        {
+            if (lng < 72.004 || lng > 137.8347)
+                return true;
+            if (lat < 0.8293 || lat > 55.8271)
+                return true;
+            return false;
+        }
+        /// <summary>
+        /// 璁$畻鍋忓樊
+        /// </summary>
+        /// <param name="in_lng"></param>
+        /// <param name="in_lat"></param>
+        /// <param name="dLng"></param>
+        /// <param name="dLat"></param>
+        private void CalculateDev(double in_lng, double in_lat, out double dLng, out double dLat)
+        {
+            dLat = TransformLat(in_lng - 105.0, in_lat - 35.0);
+            dLng = TransformLng(in_lng - 105.0, in_lat - 35.0);
+
+            double radLat = in_lat / 180.0 * pi;
+            double magic = Math.Sin(radLat);
+            magic = 1 - ee * magic * magic;
+            double sqrtMagic = Math.Sqrt(magic);
+            dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi);
+            dLng = (dLng * 180.0) / (a / sqrtMagic * Math.Cos(radLat) * pi);
+        }
+
+        private double TransformLat(double x, double y)
+        {
+            double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.Sqrt(Math.Abs(x));
+            ret += (20.0 * Math.Sin(6.0 * x * pi) + 20.0 * Math.Sin(2.0 * x * pi)) * 2.0 / 3.0;
+            ret += (20.0 * Math.Sin(y * pi) + 40.0 * Math.Sin(y / 3.0 * pi)) * 2.0 / 3.0;
+            ret += (160.0 * Math.Sin(y / 12.0 * pi) + 320 * Math.Sin(y * pi / 30.0)) * 2.0 / 3.0;
+            return ret;
+        }
+        private double TransformLng(double x, double y)
+        {
+            double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.Sqrt(Math.Abs(x));
+            ret += (20.0 * Math.Sin(6.0 * x * pi) + 20.0 * Math.Sin(2.0 * x * pi)) * 2.0 / 3.0;
+            ret += (20.0 * Math.Sin(x * pi) + 40.0 * Math.Sin(x / 3.0 * pi)) * 2.0 / 3.0;
+            ret += (150.0 * Math.Sin(x / 12.0 * pi) + 300.0 * Math.Sin(x / 30.0 * pi)) * 2.0 / 3.0;
+            return ret;
+        }
+        // 妞悆鍙傛暟-鍦嗗懆鐜�
+        private const double pi = 3.14159265358979324;
+
+        // (鍖椾含54)妞悆闀垮崐杞达紝鍗槦妞悆鍧愭爣鎶曞奖鍒板钩闈㈠湴鍥惧潗鏍囩郴鐨勬姇褰卞洜瀛�
+        private const double a = 6378245.0;
+        /*
+            * Krasovsky 1940 (鍖椾含54)妞悆闀垮崐杞寸涓�鍋忓績鐜囧钩鏂�
+            * 璁$畻鏂瑰紡锛�
+            * 闀垮崐杞达細
+            * a = 6378245.0
+            * 鎵佺巼锛�
+            * 1/f = 298.3锛堝彉閲忕浉鍏宠绠椾负锛�(a-b)/a锛�
+            * 鐭崐杞达細
+            * b = 6356863.0188 (鍙橀噺鐩稿叧璁$畻鏂规硶涓猴細b = a * (1 - f))
+            * 绗竴鍋忓績鐜囧钩鏂�:
+            * e2 = (a^2 - b^2) / a^2;
+        */
+        private const double ee = 0.00669342162296594323;
+
+        /// <summary>
+        /// APP涓婃姤GPS缁忕含搴�
+        /// </summary>
+        /// <param name="lon">APP GPS缁忓害</param>
+        /// <param name="lat">APP GPS绾害</param>
+        public void AppLatAndLonEvent(double lon, double lat)
+        {
+            Console.WriteLine($"GPS缁忓害===={lon}  \nGPS绾害===={lat}");
+            //Application.LocationAction += (lon, lat) =>
+            //{
+            //  Console.WriteLine($"GPS缁忓害===={lon}");
+            //  Console.WriteLine($"GPS绾害===={lat}");
+            //  ////GPS鍧愭爣杞垚楂樺痉鍧愭爣
+            //  //double out_lng, out_lat;
+            //  //this.WGS84_to_GCJ02(lon, lat, out out_lng, out out_lat);
+            //  //涓婃姤缁忕含搴�
+            //  this.AutomatedGeofenceStatusReporting(lon, lat);
+            //};
+            //涓婃姤缁忕含搴�<gps 涓婃姤鏉′欢澶т簬30绉掍笖绉诲姩璺濈澶т簬100绫筹紝涓婃姤缁忕含搴�>
+            this.AutomatedGeofenceStatusReporting(lon, lat);
+        }
+
+        /// <summary>
+        /// 鑷姩鍖栧湴鐞嗗洿鏍忕姸鎬佷笂鎶ヤ簯绔�
+        /// </summary>
+        /// <param name="out_lng">APP GPS缁忓害</param>
+        /// <param name="out_lat">APP GPS绾害</param>
+        private void AutomatedGeofenceStatusReporting(double out_lng, double out_lat)
+        {
+            if (IsOthreShare)
+            {
+                //涓嶆槸涓昏处鍙风洿鎺ヨ繑鍥�
+                return;
+            }
+            List<LogicData> logicDataList = new List<LogicData>();
+            logicDataList.Clear();
+            System.Threading.Tasks.Task.Run(() =>
+            {
+                try
+                {
+              //鑾峰彇閫昏緫ID鍒楄〃锛岀洰鍓嶉拡瀵规墍鏈�<澶囨敞:濡傛灉鍙拡瀵瑰綋鍓嶆墜鏈虹殑璇濓紝鍙互鐩存帴鎷跨紦瀛樻暟鎹嚜鍔ㄥ寲鍒楄〃閬嶅巻>
+              var idStr = Send.GetLogicIdList();
+                    if (idStr.Code == "0" && idStr.Data != null && idStr.Data.ToString() != "")
+                    {
+                        var date = Newtonsoft.Json.JsonConvert.SerializeObject(idStr.Data);
+                        logicDataList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<LogicData>>(date);
+                    }
+              ///鏈夎嚜鍔ㄥ垪琛ㄦ墠澶勭悊
+              if (logicDataList.Count > 0)
+                    {
+                  ///閬嶅巻鎵�鏈夊垪琛�
+                  for (int i = 0; i < logicDataList.Count; i++)
+                        {
+                            var logicDate = logicDataList[i];
+                      ///鑷姩鍖栨病鏈夐厤缃湴鐞嗗洿鏍忎笉澶勭悊
+                      if (string.IsNullOrEmpty(logicDate.geo_fence.latitude) || string.IsNullOrEmpty(logicDate.geo_fence.longitude))
+                            {
+                          //缁忕含搴︿负绌�,璁や负鑷姩鍖栨病鏈夐厤缃湴鐞嗗洿鏍忥紝涓嶅鐞�;
+                          continue;
+                            }
+                      //鑷姩鍖栭厤缃緭鍏ユ潯浠剁含搴�
+                      double lat = Convert.ToDouble(logicDate.geo_fence.latitude.Replace(",", "."));
+                      //鑷姩鍖栭厤缃緭鍏ユ潯浠剁粡搴�
+                      double lon = Convert.ToDouble(logicDate.geo_fence.longitude.Replace(",", "."));
+                      //鑷姩鍖栭厤缃緭鍏ユ潯浠�<鍦扮悊鍥存爮鍗婂緞><鍗曚綅锛屽叕閲屻�佸崈绫�.绫�>
+                      int radius = int.Parse(logicDate.geo_fence.radius);
+                      //璁$畻2涓粡绾害涔嬮棿鐨勮窛绂�
+                      int r = Infrastructure.Service.Helper.CalculatedDistance.Distance(out_lat, out_lng, lat, lon);
+                      //瀹氫箟涓�涓眬閮ㄥ彉閲�
+                      string direction = string.Empty;
+                      //涓ょ偣璺濈灏忎簬閰嶇疆璺濈<鏃㈣嚜鍔ㄥ寲閰嶇疆杈撳叆鏉′欢鍦扮悊鍥存爮鍗婂緞>,璇存槑杩涘叆鍖哄煙
+                      if (r < radius)
+                            {
+                          //鍒拌揪鏌愬湴
+                          direction = "arrive";
+                            }
+                            else
+                            {
+                          //绂诲紑
+                          direction = "leave";
+                            }
+                      ///閬嶅巻缂撳瓨鍒楄〃<涓嶄负绌鸿鏄庢暟鎹凡缁忔帹閫佽繃锛屼笉鍐嶆帹閫�>
+                      var isPush = pushList.Find((o) => o.homeId == HomeId && o.userId == UserInfo.Current.ID && o.userLogicId == logicDate.userLogicId && o.arriveOnLeave == direction);
+                            if (isPush == null)
+                            {
+                          //鎺ㄩ�佺粰浜戠鏄惁鎴愬姛
+                          bool push = Send.GeoFenceStateReport(logicDate.userLogicId, logicDate.sid, direction);
+                                if (push)
+                                {
+                              ///娣诲姞鍒版帹閫佸垪琛�
+                              pushList.Add(new Push
+                                    {
+                                        homeId = HomeId,
+                                        userId = UserInfo.Current.ID,
+                                        userLogicId = logicDate.userLogicId,
+                                        sid = logicDate.sid,
+                                        arriveOnLeave = direction,
+                                    });
+                                }
+                            }
+                        }
+
+                    }
+                }
+                catch { }
+            });
+        }
+        /// <summary>
+        /// 鎺ㄩ�佸垪琛�<杩欓噷鏁版嵁宸茬粡鎺ㄩ�佽繃>
+        /// </summary>
+        private static List<Push> pushList = new List<Push>();
+
     }
-    /// <summary>
-    /// 鎺ㄩ�佸垪琛�<杩欓噷鏁版嵁宸茬粡鎺ㄩ�佽繃>
-    /// </summary>
-    private static List<Push> pushList = new List<Push>();
+    public class Push
+    {
+        /// <summary>
+        /// 浜戠鍞竴id
+        /// </summary>
+        public string userLogicId = "";
+        /// <summary>
+        /// 缃戝叧id
+        /// </summary>
+        public string gatewayId = "";
+        /// <summary>
+        /// 閫昏緫鍞竴鏍囪瘑
+        /// </summary>
+        public string sid = "";
+        /// <summary>
+        /// 浣忓畢id
+        /// </summary>
+        public string homeId = "";
+        /// <summary>
+        /// 鍒拌揪鏌愬湴 绂诲紑
+        /// </summary>
+        public string arriveOnLeave = "";
+        /// <summary>
+        /// 聽鐢ㄦ埛id
+        /// </summary>
+        public string userId = "";
 
-  }
-  public class Push
-  {
-    /// <summary>
-    /// 浜戠鍞竴id
-    /// </summary>
-    public string userLogicId = "";
-    /// <summary>
-    /// 缃戝叧id
-    /// </summary>
-    public string gatewayId = "";
-    /// <summary>
-    /// 閫昏緫鍞竴鏍囪瘑
-    /// </summary>
-    public string sid = "";
-    /// <summary>
-    /// 浣忓畢id
-    /// </summary>
-    public string homeId = "";
-    /// <summary>
-    /// 鍒拌揪鏌愬湴 绂诲紑
-    /// </summary>
-    public string arriveOnLeave = "";
-    /// <summary>
-    /// 聽鐢ㄦ埛id
-    /// </summary>
-    public string userId = "";
-
-  }
+    }
 }

--
Gitblit v1.8.0