From 25429f085093d89d543a0b90e30d0d62d1b7dac9 Mon Sep 17 00:00:00 2001
From: hxb <hxb@hdlchina.com.cn>
Date: 星期二, 30 八月 2022 09:37:38 +0800
Subject: [PATCH] 合并了IOS的代码

---
 ZigbeeApp/Shared/Common/Device.cs | 4068 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 4,068 insertions(+), 0 deletions(-)

diff --git a/ZigbeeApp/Shared/Common/Device.cs b/ZigbeeApp/Shared/Common/Device.cs
new file mode 100644
index 0000000..5ff29c8
--- /dev/null
+++ b/ZigbeeApp/Shared/Common/Device.cs
@@ -0,0 +1,4068 @@
+锘縰sing Shared.Phone.UserCenter;
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Threading.Tasks;
+using ZigBee.Device;
+
+namespace Shared.Common
+{
+    /// <summary>
+    /// 鏈湴璁惧
+    /// </summary>
+    public class LocalDevice
+    {
+        #region 鈻� 鍙橀噺澹版槑___________________________
+
+        /// <summary>
+        /// 鏈湴璁惧
+        /// </summary>
+        private static LocalDevice m_Current = null;
+        /// <summary>
+        /// 鏈湴璁惧
+        /// </summary>
+        public static LocalDevice Current
+        {
+            get
+            {
+                if (m_Current == null)
+                {
+                    m_Current = new LocalDevice();
+                }
+                return m_Current;
+            }
+            set
+            {
+                m_Current = value;
+            }
+        }
+        /// <summary>
+        /// 鏈湴鎵�鏈夎澶囩殑缂撳瓨
+        /// </summary>
+        public List<CommonDevice> listAllDevice
+        {
+            get
+            {
+                lock (dicAllDevice)
+                {
+                    //鍏堣幏鍙栧叏閮ㄧ殑Mac
+                    var listMac = new List<string>();
+                    foreach (var strMac in this.dicDeviceEpoint.Keys)
+                    {
+                        listMac.Add(strMac);
+                    }
+                    //鏍规嵁MAC鍦板潃,鑾峰彇鍏ㄩ儴鍥炶矾鐨勮澶囧璞�(寮哄埗鎺掑簭)
+                    return this.GetDevicesByMac(listMac);
+                }
+            }
+        }
+
+        /// <summary>
+        /// 璁惧鐨勬ā鍧桰D鐨勬灇涓� keys:妯″潡ID (Axxx浠h〃鏄涓夋柟璁惧) 
+        /// </summary>
+        private Dictionary<string, DeviceNameContent> dicDeviceModelIdEnum = null;
+        /// <summary>
+        /// 闇�瑕佽浆鎹㈢殑璁惧鐨勬ā鍧桰D(keys:鏃фā鍧桰D,value:鏂版ā鍧桰D)
+        /// </summary>
+        private Dictionary<string, string> dicDeviceModelIdChanged = null;
+        /// <summary>
+        /// 鍥剧墖鍏辨湁(keys:鎸囧畾璁惧鐨勫叿浣撶被鍨� value:鎸囧畾鍏辨湁瀵硅薄鐨勫叿浣撶被鍨�)
+        /// </summary>
+        private Dictionary<string, string> dicPictrueShard = null;
+        /// <summary>
+        /// 鏈湴鎵�鏈夎澶囩殑缂撳瓨(闈炲叕寮�)
+        /// </summary>
+        private Dictionary<string, CommonDevice> dicAllDevice = new Dictionary<string, CommonDevice>();
+        /// <summary>
+        /// 鏈湴鎵�鏈夌殑椤剁偣鍗囩骇璁惧(闈炲叕寮�锛屼富閿槸MAC+200绔彛)
+        /// </summary>
+        private Dictionary<string, OTADevice> dicOTADevice = new Dictionary<string, OTADevice>();
+        /// <summary>
+        /// 璁惧鐨勬�诲洖璺�(keys:Mac鍦板潃  value:鍏ㄩ儴绔彛鍙�)
+        /// </summary>
+        private Dictionary<string, HashSet<int>> dicDeviceEpoint = new Dictionary<string, HashSet<int>>();
+
+        #endregion
+
+        #region 鈻� 鍒锋柊璁惧___________________________
+
+        /// <summary>
+        /// 鍒锋柊鏈湴璁惧淇℃伅
+        /// </summary>
+        public void ReFreshByLocal()
+        {
+            this.dicAllDevice.Clear();
+            this.dicDeviceEpoint.Clear();
+
+            //鍒濆鍖栬澶囨灇涓�
+            this.InitDeviceModelIdEnum();
+
+            //鑾峰彇鏈湴鍏ㄩ儴鐨勮澶囨枃浠�
+            List<string> listFile = this.GetAllDeviceFile();
+            foreach (string file in listFile)
+            {
+                CommonDevice device = null;
+                //鍙嶅簭鍒楀寲涓烘寚瀹氱殑绫伙紝涓嶇劧鏁版嵁浼氫涪澶辫�屽鑷存棤娉曞己杞�
+                try
+                {
+                    //璇诲彇瀹冪殑鍐呭
+                    var fileData = HdlFileLogic.Current.ReadFileTextContent(System.IO.Path.Combine(Config.Instance.FullPath, file));
+                    var jobject = Newtonsoft.Json.Linq.JObject.Parse(fileData);
+                    if (jobject.Property("DeviceID") == null)
+                    {
+                        continue;
+                    }
+                    device = CommonDevice.CommonDeviceByByteString(Convert.ToInt32(jobject["DeviceID"].ToString()), fileData);
+                }
+                catch (Exception ex) { HdlLogLogic.Current.WriteLog(ex); }
+
+                if (device == null || device.CurrentGateWayId == null)
+                {
+                    //澶辨晥鐨勬枃浠讹紝娌℃湁缃戝叧id鐨勯兘鍒犻櫎鎺�
+                    Global.DeleteFilebyHomeId(file);
+                    continue;
+                }
+                //濡傛灉杩欎釜璁惧鐨勭綉鍏矷D涓嶅瓨鍦ㄧ殑璇�
+                if (HdlGatewayLogic.Current.IsGatewayExist(device.CurrentGateWayId) == false)
+                {
+                    if (UserCenterResourse.UserInfo.AuthorityNo == 3)
+                    {
+                        //濡傛灉浠栨槸鎴愬憳鐨勮瘽,甯粬鏂板缓涓�涓綉鍏�
+                        HdlGatewayLogic.Current.AddVirtualGateway(device.CurrentGateWayId);
+                    }
+                    else
+                    {
+                        //濡傛灉鏄富浜�,鎴栬�呯鐞嗗憳,閭d箞杩欎釜鏂囦欢鏄潪娉曠殑,鐩存帴鍒犻櫎
+                        Global.DeleteFilebyHomeId(file);
+                        continue;
+                    }
+                }
+
+                string mainKey = this.GetDeviceMainKeys(device);
+                if (device is OTADevice)
+                {
+                    //200绔彛涓嶉渶瑕佸鐞�
+                    this.dicOTADevice[mainKey] = (OTADevice)device;
+                    continue;
+                }
+                //濡傛灉璁惧鏄櫨琛f灦,鍒欎竴绔偣锛屽叾浠栫鐐癸紙2锝�5锛夎繃婊�,
+                //鍥犱负鍏朵粬绔偣鍙湁鎺у埗浣滅敤锛岋紙2:鎺у埗鐓ф槑锛�3:鎺у埗椋庡共锛�4:鎺у埗鐑樺共锛�5:鎺у埗娑堟瘨锛�
+                //浜у搧缁忕悊涓嶈鏄剧ず
+                if (device is Airer)
+                {
+                    if (device.DeviceEpoint == 2 || device.DeviceEpoint == 3 || device.DeviceEpoint == 4 || device.DeviceEpoint == 5)
+                        continue;
+                }
+                //娣诲姞缂撳瓨
+                this.dicAllDevice[mainKey] = device;
+
+                //鍥炶矾鏀堕泦
+                if (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == false)
+                {
+                    this.dicDeviceEpoint[device.DeviceAddr] = new HashSet<int>();
+                }
+                this.dicDeviceEpoint[device.DeviceAddr].Add(device.DeviceEpoint);
+
+                //瀵瑰簲鏃х増鏈殑璁惧鏂囦欢 Device_OnoffOutput_abcdfrtgg_01
+                bool bolSave = file.Split(new string[] { "_" }, StringSplitOptions.None).Length == 4;
+                if (bolSave == true)
+                {
+                    //鍒犳帀杩欎釜鏂囦欢,閲嶆柊鐢熸垚
+                    HdlAutoBackupLogic.DeleteFile(file);
+                    Global.DeleteFilebyHomeId(file);
+                }
+
+                //妫�娴婾i鍥剧墖鏄惁姝g‘,杩欎釜鍥剧墖鏈湴鏄惁瀛樺湪锛�
+                if (string.IsNullOrEmpty(IO.FileUtils.GetImageFilePath(device.IconPath)) == true)
+                {
+                    //涓嶅瓨鍦ㄧ殑璇濓紝閲嶆柊鐢熸垚
+                    device.IconPath = string.Empty;
+                    device.ReSave();
+                    HdlAutoBackupLogic.AddOrEditorFile(device.FilePath);
+
+                    bolSave = false;
+                }
+                //閲嶆柊鐢熸垚鏂囦欢
+                if (bolSave == true)
+                {
+                    device.ReSave();
+                    HdlAutoBackupLogic.AddOrEditorFile(device.FilePath);
+                }
+            }
+            //鎴愬憳韬唤鐨勬椂鍊�,鍒犻櫎鎺夐潪娉曠殑缃戝叧鏂囦欢
+            this.DeleteGatewayFileByMemberModel();
+            //鍒濆鍖栫墿鐞嗚澶囨墍灞炴埧闂寸殑璁板綍
+            HdlRoomLogic.Current.InitRealDeviceRoomId();
+
+#if DEBUG
+            if (UserCenterResourse.HideOption.CenterHideMenu == 1)
+            {
+                //妫�娴嬩竴浜涗唬鐮侀厤缃�(debug)
+                this.CheckOhtherSettion();
+            }
+#endif
+        }
+
+        /// <summary>
+        /// 鎴愬憳韬唤鐨勬椂鍊�,鍒犻櫎鎺夐潪娉曠殑缃戝叧鏂囦欢
+        /// </summary>
+        private void DeleteGatewayFileByMemberModel()
+        {
+            if (UserCenterResourse.UserInfo.AuthorityNo != 3)
+            {
+                return;
+            }
+            var listId = new HashSet<string>();
+
+            lock (dicAllDevice)
+            {
+                foreach (var device in this.dicAllDevice.Values)
+                {
+                    if (listId.Contains(device.CurrentGateWayId) == false)
+                    {
+                        listId.Add(device.CurrentGateWayId);
+                    }
+                }
+            }
+            var listGateway = HdlGatewayLogic.Current.GetAllLocalGateway();
+            foreach (var gateway in listGateway)
+            {
+                string gwId = gateway.GwId;
+                if (listId.Contains(gwId) == false)
+                {
+                    //杩欎釜缃戝叧瀵逛簬褰撳墠杩欎釜鎴愬憳鏉ヨ鏄潪娉曠殑
+                    HdlGatewayLogic.Current.DeleteGatewayFile(gwId);
+                }
+            }
+        }
+
+        /// <summary>
+        /// 妫�娴嬩竴浜涗唬鐮侀厤缃�(debug)
+        /// </summary>
+        private void CheckOhtherSettion()
+        {
+            foreach (var item in Enum.GetValues(typeof(DeviceType)))
+            {
+                string itemName = item.ToString();
+                int itemValue = (int)item;
+                if (itemName == "UnKown" || itemName == "ZbGateway")
+                {
+                    continue;
+                }
+                var device = this.NewDeviceObjectByDeviceId((DeviceType)itemValue, 1);
+                string strMsg = string.Empty;
+                if (device == null)
+                {
+                    strMsg = itemName + "娌℃湁瀹炶(1)";
+                }
+                device = CommonDevice.CommonDeviceByByteString(itemValue, "{}");
+                if (device == null)
+                {
+                    strMsg += "\r\n" + itemName + "娌℃湁瀹炶(2)";
+                }
+                if (strMsg != string.Empty)
+                {
+                    this.ShowErrorMsg(strMsg);
+                    return;
+                }
+            }
+        }
+
+        #endregion
+
+        #region 鈻� 娣诲姞璁惧___________________________
+
+        /// <summary>
+        /// <para>灏嗘寚瀹氱綉鍏崇殑璁惧瀛樺叆缂撳瓨涓�(浠庢柊鑾峰彇闀滃儚)</para>
+        /// <para>-1:寮傚父 1:姝e父 2:璁惧淇℃伅缂烘崯</para>
+        /// </summary>
+        /// <param name="gatewayId">缃戝叧Id</param>
+        /// <param name="useLocalConnect">鏄惁寮哄埗浣跨敤鏈湴杩炴帴鍙戦��</param>
+        public int SetDeviceToMemmoryByGateway(string gatewayId, bool useLocalConnect)
+        {
+            //浠庣綉鍏宠幏鍙栧叏閮ㄧ殑璁惧
+            int statu = 0;
+            List<CommonDevice> listDevice = new List<CommonDevice>();
+            List<CommonDevice> list = this.GetDeviceListFromGateway(gatewayId, ref statu, useLocalConnect);
+            if (list == null)
+            {
+                return -1;
+            }
+            listDevice.AddRange(list);
+
+            //鑾峰彇杩欎釜缃戝叧鐨勬湰鍦版墍鏈夎澶�
+            List<CommonDevice> listLocalDevices = this.GetDeviceByGatewayID(gatewayId);
+            //鑾峰彇ota璁惧
+            foreach (var ota in this.dicOTADevice.Values)
+            {
+                if (ota.CurrentGateWayId == gatewayId)
+                {
+                    listLocalDevices.Add(ota);
+                }
+            }
+
+            Dictionary<string, CommonDevice> dicExist = new Dictionary<string, CommonDevice>();
+            foreach (var device in listLocalDevices)
+            {
+                string maikey = this.GetDeviceMainKeys(device);
+                dicExist[maikey] = device;
+            }
+
+            //娣诲姞璁惧鐨勭紦瀛�
+            var listDriveDevice = new List<CommonDevice>();
+            for (int i = 0; i < listDevice.Count; i++)
+            {
+                var device = listDevice[i];
+                if (device == null || device.DeviceAddr == null)
+                {
+                    continue;
+                }
+                //娣诲姞缂撳瓨
+                this.AddDeviceToMemory(ref device);
+
+                //绉婚櫎瀛樺湪鐨勮澶囧唴瀛� 
+                string maikey = this.GetDeviceMainKeys(device);
+                if (dicExist.ContainsKey(maikey) == true)
+                {
+                    dicExist.Remove(maikey);
+                }
+                //鑾峰彇璁惧鐨勫浐瀹氬睘鎬�
+                if (HdlDeviceFixedAttributeLogic.Current.SetAllFixedAttributeToDevice(device) == true)
+                {
+                    System.Threading.Thread.Sleep(200);
+                }
+                //瀵规湭鍛藉悕鐨勮櫄鎷熻澶囬噸鏂板懡鍚�
+                if (device.DriveCode > 0 && this.GetSimpleEpointName(device) == string.Empty)
+                {
+                    listDriveDevice.Add(device);
+                }
+            }
+            //璁剧疆铏氭嫙璁惧鐨勯粯璁ゅ悕瀛�
+            this.SetDriveDeviceDefultName(listDriveDevice);
+
+            //鍙湁瀹屽叏鑾峰彇鐨勬椂鍊�,鎵嶄細鍘诲鐞嗗垹闄ょ殑闂
+            if (statu != 1)
+            {
+                return statu;
+            }
+
+            //濡傛灉鏈湴鍜岀綉鍏崇殑璁惧涓嶄竴鑷寸殑鏃跺�欙紝鍒犻櫎鏈湴鐨勮澶�
+            var listDeleteMac = new List<string>();
+            foreach (var device in dicExist.Values)
+            {
+                if (device is OTADevice)
+                {
+                    this.DeleteMemmoryOtaDevice(device.DeviceAddr);
+                }
+                else
+                {
+                    this.DeleteMemmoryDevice(device, true);
+                }
+                if (listDeleteMac.Contains(device.DeviceAddr) == false)
+                {
+                    //鏀堕泦琚垹闄ょ殑Mac
+                    listDeleteMac.Add(device.DeviceAddr);
+                }
+            }
+            if (listDeleteMac.Count > 0)
+            {
+                //灏嗙湡瀹炵墿鐞嗚澶囦粠鎴块棿涓Щ闄�
+                HdlRoomLogic.Current.DeleteRealDeviceFromRoom(listDeleteMac);
+            }
+
+            return statu;
+        }
+
+        /// <summary>
+        /// 娣诲姞璁惧鍒扮紦瀛�,瀛樺湪鏃惰鐩�
+        /// </summary>
+        /// <param name="device">璁惧瀵硅薄(杩欎釜涓滆タ鏈夊彲鑳戒細琚洿鏀�)</param>
+        public void AddDeviceToMemory(ref CommonDevice device)
+        {
+            string mainKeys = this.GetDeviceMainKeys(device);
+            //濡傛灉瀹冩槸鍗囩骇鐨勯《绔鐐�,鍒欎笉鑳借瀹冨姞鍏ュ埌缂撳瓨锛屼絾鏄彲浠ヨ浠栫敓鎴愭枃浠�
+            if (device is OTADevice)
+            {
+                if (this.dicOTADevice.ContainsKey(mainKeys) == false)
+                {
+                    this.dicOTADevice[mainKeys] = (OTADevice)device;
+                }
+                else
+                {
+                    //浜ゆ崲灞炴��
+                    var tempDevice = this.dicOTADevice[mainKeys];
+                    //灏咲eviceInfo鐨勫睘鎬ц缃埌涓诲睘鎬т腑
+                    this.SetDeviceInfoToMain(tempDevice, device);
+                    //鍒锋柊璁惧鍔熻兘绫诲瀷(杩欎釜涓滆タ闇�瑕佺嫭绔嬪嚭鏉�)
+                    this.RefreshDeviceFunctionType(tempDevice, device, false);
+                    device = tempDevice;
+                }
+
+                bool exists = Global.IsExistsByHomeId(device.FilePath);
+                device.ReSave();
+                if (exists == false)
+                {
+                    //娣诲姞鑷姩澶囦唤
+                    HdlAutoBackupLogic.AddOrEditorFile(device.FilePath);
+                }
+                return;
+            }
+
+            //濡傛灉璁惧鏄櫨琛f灦,鍒欎竴绔偣锛屽叾浠栫鐐癸紙2锝�5锛夎繃婊�,
+            //鍥犱负鍏朵粬绔偣鍙湁鎺у埗浣滅敤锛岋紙2:鎺у埗鐓ф槑锛�3:鎺у埗椋庡共锛�4:鎺у埗鐑樺共锛�5:鎺у埗娑堟瘨锛�
+            //浜у搧缁忕悊涓嶈鏄剧ず
+            if (device is Airer)
+            {
+                if (device.DeviceEpoint == 2 || device.DeviceEpoint == 3 || device.DeviceEpoint == 4 || device.DeviceEpoint == 5)
+                    return;
+            }
+
+            lock (dicAllDevice)
+            {
+                if (this.dicAllDevice.ContainsKey(mainKeys) == true)
+                {
+                    //浜ゆ崲灞炴��
+                    var tempDevice = this.dicAllDevice[mainKeys];
+                    //灏咲eviceInfo鐨勫睘鎬ц缃埌涓诲睘鎬т腑
+                    this.SetDeviceInfoToMain(tempDevice, device);
+                    //鍒锋柊璁惧鍔熻兘绫诲瀷(杩欎釜涓滆タ闇�瑕佺嫭绔嬪嚭鏉�)
+                    this.RefreshDeviceFunctionType(tempDevice, device, false);
+                    device = tempDevice;
+                }
+                else
+                {
+                    this.dicAllDevice[mainKeys] = device;
+                }
+            }
+
+            //璁惧鍥炶矾鏀堕泦
+            if (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == false)
+            {
+                this.dicDeviceEpoint[device.DeviceAddr] = new HashSet<int>();
+            }
+            if (this.dicDeviceEpoint[device.DeviceAddr].Contains(device.DeviceEpoint) == false)
+            {
+                this.dicDeviceEpoint[device.DeviceAddr].Add(device.DeviceEpoint);
+            }
+
+            bool exists2 = Global.IsExistsByHomeId(device.FilePath);
+            device.ReSave();
+            if (exists2 == false)
+            {
+                //娣诲姞鑷姩澶囦唤
+                HdlAutoBackupLogic.AddOrEditorFile(device.FilePath);
+            }
+        }
+
+        /// <summary>
+        /// 娣诲姞铏氭嫙璁惧鍒扮紦瀛�
+        /// </summary>
+        /// <param name="device">璁惧瀵硅薄</param>
+        public void AddVirtualDeviceToMemory(CommonDevice device)
+        {
+            string mainKeys = this.GetDeviceMainKeys(device);
+            if (device is OTADevice)
+            {
+                this.dicOTADevice[mainKeys] = (OTADevice)device;
+                device.ReSave();
+                return;
+            }
+            //濡傛灉璁惧鏄櫨琛f灦,鍒欎竴绔偣锛屽叾浠栫鐐癸紙2锝�5锛夎繃婊�,
+            //鍥犱负鍏朵粬绔偣鍙湁鎺у埗浣滅敤锛岋紙2:鎺у埗鐓ф槑锛�3:鎺у埗椋庡共锛�4:鎺у埗鐑樺共锛�5:鎺у埗娑堟瘨锛�
+            //浜у搧缁忕悊涓嶈鏄剧ず
+            if (device is Airer)
+            {
+                if (device.DeviceEpoint == 2 || device.DeviceEpoint == 3 || device.DeviceEpoint == 4 || device.DeviceEpoint == 5)
+                    return;
+            }
+            this.dicAllDevice[mainKeys] = device;
+
+            //璁惧鍥炶矾鏀堕泦
+            if (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == false)
+            {
+                this.dicDeviceEpoint[device.DeviceAddr] = new HashSet<int>();
+            }
+            if (this.dicDeviceEpoint[device.DeviceAddr].Contains(device.DeviceEpoint) == false)
+            {
+                this.dicDeviceEpoint[device.DeviceAddr].Add(device.DeviceEpoint);
+            }
+            device.ReSave();
+        }
+
+        #endregion
+
+        #region 鈻� 淇敼璁惧___________________________
+
+        /// <summary>
+        /// 鏇存敼绔偣鍚嶅瓧骞朵笖鍒锋柊缂撳瓨(淇敼澶辫触鏃讹紝浼氭樉绀轰俊鎭�)
+        /// </summary>
+        /// <param name="device">璁惧瀵硅薄</param>
+        /// <param name="newName">鏂板悕瀛�</param>
+        /// <param name="mode">鏄惁鏄剧ず閿欒</param>
+        public bool ReName(CommonDevice device, string newName, ShowErrorMode mode = ShowErrorMode.YES)
+        {
+            //鍏堝埆绠¢偅涔堝锛屾洿鏀瑰悕瀛楀悗锛屽埛鏂拌澶囩紦瀛�
+            this.SetEpointName(device, newName);
+
+            this.BackupDeviceAfterReName(device);
+
+            //濡傛灉浣忓畢涓鸿櫄鎷熶綇瀹�
+            if (Common.Config.Instance.Home.IsVirtually == true)
+            {
+                //淇敼璁惧鍚嶅瓧鐨勮瘽,涓婚〉闇�瑕侀噸鏂板埛鏂�
+                Phone.UserView.UserPage.Instance.RefreshAllForm = true;
+                return true;
+            }
+
+            //涓嶅啀妫�娴嬪悕瀛楁槸鍚︿竴鏍�
+            //鎴愬憳鍙兘淇敼鑷繁鏈湴鐨勫悕瀛�
+            if (UserCenterResourse.UserInfo.AuthorityNo != 3)
+            {
+                var result = this.RenameDeviceNameAsync(device, newName);
+                if (result == null || result.deviceRenameData == null || result.deviceRenameData.Result == 1)
+                {
+                    //璁惧鍚嶇О淇敼澶辫触
+                    string msg = Language.StringByID(R.MyInternationalizationString.uDeviceReNameFail);
+                    //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
+                    msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
+
+                    if (mode == ShowErrorMode.YES)
+                    {
+                        this.ShowErrorMsg(msg);
+                    }
+                    return false;
+                }
+            }
+            //淇敼璁惧鍚嶅瓧鐨勮瘽,涓婚〉闇�瑕侀噸鏂板埛鏂�
+            Phone.UserView.UserPage.Instance.RefreshAllForm = true;
+            return true;
+        }
+
+        /// <summary>
+        /// 鏇存敼Mac鍚嶅瓧骞朵笖鍒锋柊缂撳瓨(淇敼澶辫触鏃讹紝浼氭樉绀轰俊鎭�)
+        /// </summary>
+        /// <param name="listDevice">璁惧瀵硅薄</param>
+        /// <param name="newMacName">鏂板悕瀛�</param>
+        /// <param name="mode">鏄惁鏄剧ず閿欒</param>
+        public bool ReMacName(List<CommonDevice> listDevice, string newMacName, ShowErrorMode mode = ShowErrorMode.YES)
+        {
+            if (listDevice.Count == 0)
+            {
+                return true;
+            }
+            //鍏堝埆绠¢偅涔堝锛屽厛淇敼缂撳瓨
+            for (int i = 0; i < listDevice.Count; i++)
+            {
+                var device2 = listDevice[i];
+                //杩欎袱涓笢瑗垮緢鐗规畩
+                this.SetMacName(device2, newMacName);
+
+                //鏇存敼鍚嶅瓧鍚庯紝鍒锋柊璁惧缂撳瓨
+                this.BackupDeviceAfterReName(device2);
+            }
+            //濡傛灉浣忓畢涓鸿櫄鎷熶綇瀹�
+            if (Common.Config.Instance.Home.IsVirtually == true)
+            {
+                return true;
+            }
+
+            CommonDevice device = listDevice[0];
+            //涓嶅啀妫�娴嬪悕瀛楁槸鍚︿竴鏍�
+            //鎴愬憳鍙兘淇敼鑷繁鏈湴鐨勫悕瀛�
+            if (UserCenterResourse.UserInfo.AuthorityNo != 3)
+            {
+                //淇敼鐗╃悊鍚嶅瓧
+                var result = this.RenameDeviceMacNameAsync(device, newMacName);
+                if (result == null || result.renameDeviceMacNameData == null || result.renameDeviceMacNameData.Result != 0)
+                {
+                    //璁惧鍚嶇О淇敼澶辫触
+                    string msg = Language.StringByID(R.MyInternationalizationString.uDeviceReNameFail);
+                    //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
+                    msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
+                    if (mode == ShowErrorMode.YES)
+                    {
+                        this.ShowErrorMsg(msg);
+                    }
+                    return false;
+                }
+                //濡傛灉瀹冨彧鏈変竴涓洖璺�,鍒欐洿鏀圭鐐瑰悕瀛�
+                if (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == true)
+                {
+                    //鍙湁涓�涓鐐�
+                    if (this.dicDeviceEpoint[device.DeviceAddr].Count == 1)
+                    {
+                        return this.ReName(device, newMacName);
+                    }
+                    //濡傛灉瀹冩湁涓や釜绔偣鏃�,pir浼犳劅鍣ㄧ壒娈婂鐞�
+                    else if (this.dicDeviceEpoint[device.DeviceAddr].Count == 2)
+                    {
+                        var myType = this.GetMyDeviceEnumInfo(listDevice);
+                        if (myType.ConcreteType == DeviceConcreteType.Sensor_Pir)
+                        {
+                            foreach (var myDevice in listDevice)
+                            {
+                                if (myDevice.Type == DeviceType.IASZone)
+                                {
+                                    return this.ReName(myDevice, newMacName);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            return true;
+        }
+
+        /// <summary>
+        /// 璁剧疆铏氭嫙璁惧鐨勯粯璁ゅ悕瀛�
+        /// </summary>
+        /// <param name="listDriveDevice">铏氭嫙璁惧鍒楄〃</param>
+        private void SetDriveDeviceDefultName(List<CommonDevice> listDriveDevice)
+        {
+            if (listDriveDevice.Count == 0)
+            {
+                return;
+            }
+            //濡傛灉铏氭嫙璁惧杩樻病鏈夊悕瀛楃殑璇�
+            HdlThreadLogic.Current.RunThread(() =>
+            {
+                //濡傛灉涓嶈繖鏍锋斁鍦ㄤ竴涓嚎绋嬮噷,鏈夊彲鑳藉Dictionary浜х敓褰卞搷
+                foreach (var myDevice in listDriveDevice)
+                {
+                    string dName = string.Empty;
+                    if (this.IsMiniLight(myDevice) == true)
+                    {
+                        //Mini澶滅伅
+                        dName = Language.StringByID(R.MyInternationalizationString.uMiniNightLight);
+                    }
+                    else
+                    {
+                        //鏍规嵁璁惧绫诲瀷鑾峰彇鍚嶇О
+                        dName = this.GetDeviceObjectText(new List<CommonDevice>() { myDevice }, false);
+                        //鍦ㄧ鐐瑰悕瀛楃殑鍚庨潰闄勫姞銆愬洖璺�戝瓧鏍�
+                        dName += "(" + myDevice.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + ")";
+                    }
+                    this.ReName(myDevice, dName, ShowErrorMode.NO);
+
+                    System.Threading.Thread.Sleep(100);
+                }
+            });
+        }
+
+        ///<summary >
+        /// 淇敼璁惧mac鍚嶇О
+        /// <para>macName:璁惧鍚嶇О</para>
+        /// </summary>
+        private CommonDevice.RenameDeviceMacNameAllData RenameDeviceMacNameAsync(CommonDevice device, string macName)
+        {
+            //濡傛灉褰撳墠鏄櫄鎷熶綇瀹�
+            if (Common.Config.Instance.Home.IsVirtually == true)
+            {
+                return Phone.TemplateData.TemplateDeviceDataLogic.Current.ReDeviceMacName(device, macName);
+            }
+
+            //鑾峰彇缂栬緫璁惧Mac鍚嶅瓧鐨勫懡浠ゅ瓧绗�
+            var sendData = this.GetReDeviceMacNameCommandText(device.DeviceAddr, device.DeviceEpoint, macName);
+            var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "MacRename", sendData, "MacRename_Respon", 8);
+            if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
+            {
+                return null;
+            }
+            //鍔犵紦瀛�
+            Phone.TemplateData.TemplateDeviceDataLogic.Current.ReDeviceMacName(device, macName);
+
+            var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.RenameDeviceMacNameData>(result.ReceiptData);
+            return new CommonDevice.RenameDeviceMacNameAllData { renameDeviceMacNameData = tempData };
+        }
+
+        /// <summary>
+        /// 淇敼璁惧绔彛锛堟寜閿級鍚嶇О
+        /// </summary>
+        /// <param name="device">璁惧瀵硅薄</param>
+        /// <param name="deviceName">璁惧绔偣鍚嶅瓧</param>
+        /// <returns></returns>
+        private CommonDevice.DeviceRenameAllData RenameDeviceNameAsync(CommonDevice device, string deviceName)
+        {
+            //濡傛灉褰撳墠鏄櫄鎷熶綇瀹�
+            if (Common.Config.Instance.Home.IsVirtually == true)
+            {
+                return Phone.TemplateData.TemplateDeviceDataLogic.Current.ReDeviceEpointName(device, deviceName);
+            }
+            //鑾峰彇缂栬緫璁惧绔偣鍚嶅瓧鐨勫懡浠ゅ瓧绗�
+            var sendData = this.GetReDeviceEpointNameCommandText(device.DeviceAddr, device.DeviceEpoint, deviceName);
+            var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "DeviceRename", sendData, "DeviceRenameRespon", 8);
+            if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
+            {
+                return null;
+            }
+            //鍔犵紦瀛�
+            Phone.TemplateData.TemplateDeviceDataLogic.Current.ReDeviceEpointName(device, deviceName);
+
+            var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.DeviceRenameResponseData>(result.ReceiptData);
+            return new CommonDevice.DeviceRenameAllData { deviceRenameData = tempData };
+        }
+
+        /// <summary>
+        /// 鑾峰彇缂栬緫璁惧Mac鍚嶅瓧鐨勫懡浠ゅ瓧绗�
+        /// </summary>
+        /// <param name="deviceAddr"></param>
+        /// <param name="deviceEpoint"></param>
+        /// <param name="deviceName"></param>
+        /// <returns></returns>
+        public string GetReDeviceMacNameCommandText(string deviceAddr, int deviceEpoint, string deviceName)
+        {
+            var bytes = new byte[64];
+            var reamarkGwBytes = Encoding.UTF8.GetBytes(deviceName);
+            System.Array.Copy(reamarkGwBytes, 0, bytes, 0, 64 < reamarkGwBytes.Length ? 64 : reamarkGwBytes.Length);
+            deviceName = Encoding.UTF8.GetString(bytes);
+
+            var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", deviceAddr }, { "Epoint", deviceEpoint }, { "Cluster_ID", 0 }, { "Command", 100 } };
+            var data = new Newtonsoft.Json.Linq.JObject { { "MacName", deviceName } };
+            jObject.Add("Data", data);
+            return jObject.ToString();
+        }
+
+        /// <summary>
+        /// 鑾峰彇缂栬緫璁惧绔偣鍚嶅瓧鐨勫懡浠ゅ瓧绗�
+        /// </summary>
+        /// <param name="deviceAddr"></param>
+        /// <param name="deviceEpoint"></param>
+        /// <param name="deviceName"></param>
+        /// <returns></returns>
+        public string GetReDeviceEpointNameCommandText(string deviceAddr, int deviceEpoint, string deviceName)
+        {
+            var bytes = new byte[64];
+            var reamarkGwBytes = Encoding.UTF8.GetBytes(deviceName);
+            System.Array.Copy(reamarkGwBytes, 0, bytes, 0, 64 < reamarkGwBytes.Length ? 64 : reamarkGwBytes.Length);
+            deviceName = Encoding.UTF8.GetString(bytes);
+
+            var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", deviceAddr }, { "Epoint", deviceEpoint }, { "Cluster_ID", 0 }, { "Command", 96 } };
+            var data = new Newtonsoft.Json.Linq.JObject { { "DeviceName", deviceName } };
+            jObject.Add("Data", data);
+
+            return jObject.ToString();
+        }
+
+        /// <summary>
+        /// 鏇存敼鍚嶅瓧鍚庯紝鍒锋柊璁惧缂撳瓨
+        /// </summary>
+        /// <param name="device"></param>
+        private void BackupDeviceAfterReName(CommonDevice device)
+        {
+            lock (dicAllDevice)
+            {
+                string mainKeys = this.GetDeviceMainKeys(device);
+                if (this.dicAllDevice.ContainsKey(mainKeys) == true)
+                {
+                    //涓�鑸澶�
+                    this.dicAllDevice[mainKeys] = device;
+                    device.ReSave();
+
+                    //娣诲姞鑷姩澶囦唤
+                    HdlAutoBackupLogic.AddOrEditorFile(device.FilePath);
+                }
+                else if (this.dicOTADevice.ContainsKey(mainKeys) == true)
+                {
+                    //Ota璁惧
+                    this.dicOTADevice[mainKeys] = (OTADevice)device;
+                    device.ReSave();
+
+                    //娣诲姞鑷姩澶囦唤
+                    HdlAutoBackupLogic.AddOrEditorFile(device.FilePath);
+
+                }
+            }
+        }
+
+        #endregion
+
+        #region 鈻� 鍒犻櫎璁惧___________________________
+
+        /// <summary>
+        /// 鍒犻櫎璁惧骞朵笖鍒锋柊缂撳瓨(鍒犻櫎澶辫触鏃讹紝浼氭樉绀轰俊鎭�)
+        /// </summary>
+        /// <param name="listdevice">璁惧瀵硅薄(MAC鍦板潃蹇呴』瑕佺浉鍚�)</param>
+        public async Task<bool> DeleteDevice(List<CommonDevice> listdevice)
+        {
+            //铏氭嫙浣忓畢鐨勮瘽,涓嶉渶瑕佸垹闄ょ綉鍏崇殑璁惧
+            if (Config.Instance.Home.IsVirtually == false)
+            {
+                var data = new CommonDevice.RemoveDeviceData();
+                var info = new CommonDevice.RemoveDeviceListInfo();
+                info.DeviceAddr = listdevice[0].DeviceAddr;
+                data.DeviceAddrList.Add(info);
+
+                //鍒犱竴娆$殑鏃跺�欙紝瀹冧細鎶奙AC鍦板潃涓嬮潰鍏ㄩ儴鐨勮澶囬兘鍒犻櫎
+                var result = await listdevice[0].DeleteDeviceAsync(data);
+                if (result == null || result.removeDeviceResponseData == null || result.removeDeviceResponseData.Result != 0)
+                {
+                    //璁惧鍒犻櫎澶辫触
+                    string msg = Language.StringByID(R.MyInternationalizationString.uDeviceDeleteFail);
+                    //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
+                    msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
+
+                    this.ShowErrorMsg(msg);
+                    return false;
+                }
+            }
+
+            //鍒犻櫎缂撳瓨鐨凮ta璁惧
+            this.DeleteMemmoryOtaDevice(listdevice[0].DeviceAddr);
+            //鍒犻櫎涓�鑸澶囨枃浠�
+            foreach (CommonDevice device in listdevice)
+            {
+                this.DeleteMemmoryDevice(device);
+            }
+            //绉婚櫎鐪熷疄璁惧鐨勬埧闂寸储寮�
+            HdlRoomLogic.Current.DeleteRealDeviceFromRoom(listdevice[0]);
+
+            return true;
+        }
+
+        /// <summary>
+        /// 鍒犻櫎缂撳瓨鐨勪竴鑸澶�
+        /// </summary>
+        /// <param name="device">璁惧瀵硅薄</param>
+        /// <param name="deleteRoom">鏄惁浠庢埧闂村垹闄�</param>
+        public void DeleteMemmoryDevice(CommonDevice device, bool deleteRoom = true)
+        {
+            //鍒犻櫎缂撳瓨璁惧鐨勮瘽,涓婚〉闇�瑕侀噸鏂板埛鏂�
+            Phone.UserView.UserPage.Instance.RefreshAllForm = true;
+
+            if (deleteRoom == true)
+            {
+                //浠庢埧闂翠腑鍒犻櫎
+                HdlRoomLogic.Current.DeleteDevice(device);
+                //鍒犻櫎鎴戠殑鍠滅埍鐨勮澶�
+                HdlRoomLogic.Current.DeleteLoveDevice(device);
+            }
+
+            //鍒犻櫎缂撳瓨
+            string mainKeys = this.GetDeviceMainKeys(device);
+            lock (dicAllDevice)
+            {
+                if (this.dicAllDevice.ContainsKey(mainKeys) == true)
+                {
+                    this.dicAllDevice.Remove(mainKeys);
+                }
+                if (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == true)
+                {
+                    //鍙樻洿绔偣鏁�
+                    this.dicDeviceEpoint[device.DeviceAddr].Remove(device.DeviceEpoint);
+                }
+            }
+            //鍒犻櫎妯℃澘鏁版嵁
+            Phone.TemplateData.TemplateCommonLogic.Current.DeleteDevice(device);
+
+            //鍒犻櫎璁惧鏂囦欢
+            string filePath = device.FilePath;
+            if (Global.IsExistsByHomeId(filePath) == true)
+            {
+                if (UserCenterResourse.UserInfo.AuthorityNo == 3)
+                {
+                    //鎴愬憳鐨勮瘽,鐩存帴鍒犻櫎,娌℃湁鍟嗛噺鐨勪綑鍦�
+                    Global.DeleteFilebyHomeId(filePath);
+                }
+                else
+                {
+                    //鍙樻洿锛氭悶鎺夊畠,涓嶇暀浜�
+                    Global.DeleteFilebyHomeId(filePath);
+                    //鍒犻櫎鑷姩澶囦唤
+                    HdlAutoBackupLogic.DeleteFile(device.FilePath);
+                }
+            }
+        }
+
+        /// <summary>
+        /// 鍒犻櫎缂撳瓨鐨凮ta璁惧
+        /// </summary>
+        /// <param name="macAdrr"></param>
+        /// <param name="ePoint"></param>
+        public void DeleteMemmoryOtaDevice(string macAdrr, int ePoint = 200)
+        {
+            //鍒犻櫎200绔彛鏂囦欢
+            string otaKeys = this.GetDeviceMainKeys(macAdrr, ePoint);
+            if (this.dicOTADevice.ContainsKey(otaKeys) == true)
+            {
+                string otaFile = this.dicOTADevice[otaKeys].FilePath;
+                if (Global.IsExistsByHomeId(otaFile) == true)
+                {
+                    if (UserCenterResourse.UserInfo.AuthorityNo == 3)
+                    {
+                        //鎴愬憳鐨勮瘽,鐩存帴鍒犻櫎,娌℃湁鍟嗛噺鐨勪綑鍦�
+                        Global.DeleteFilebyHomeId(otaFile);
+                    }
+                    else
+                    {
+                        //鍙樻洿锛氭悶鎺夊畠,涓嶇暀浜�
+                        Global.DeleteFilebyHomeId(otaFile);
+                        //鍒犻櫎鑷姩澶囦唤
+                        HdlAutoBackupLogic.DeleteFile(otaFile);
+                    }
+                }
+                this.dicOTADevice.Remove(otaKeys);
+            }
+        }
+
+        #endregion
+
+        #region 鈻� 鍚屾璁惧___________________________
+        /// <summary>
+        ///  鍚屾璁惧骞朵笖鍒锋柊缂撳瓨(鍚屾澶辫触鏃讹紝浼氭樉绀轰俊鎭�)
+        /// </summary>
+        /// <param name="litdevice">璁惧瀵硅薄(MAC鍦板潃蹇呴』瑕佺浉鍚�)</param>
+        public async Task<bool> SynchronizationDevice(List<CommonDevice> listdevice)
+        {
+            //铏氭嫙浣忓畢鐨勮瘽,涓嶉渶瑕佸垹闄ょ綉鍏崇殑璁惧
+            if (Config.Instance.Home.IsVirtually == false)
+            {
+                //鍚屾
+                var result = await listdevice[0].SyncMsgToBindSource(listdevice[0].DeviceAddr, listdevice[0].DeviceEpoint);
+                if (result == null || result.result != 0)
+                {
+                    //鍚屾鍒犻櫎澶辫触
+                    string msg = Language.StringByID(R.MyInternationalizationString.SynchronizationFailed);
+                    //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
+                    msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
+
+                    this.ShowErrorMsg(msg);
+                    return false;
+                }
+            }
+            return true;
+        }
+        #endregion
+
+        #region 鈻� 娴嬭瘯璁惧___________________________
+
+        /// <summary>
+        /// 鍙戦�佸畾浣嶆寚浠ゅ埌璁惧
+        /// </summary>
+        /// <param name="device">璁惧鍥炶矾</param>
+        /// <param name="isRealDevice">鏄惁鏄畾浣嶇湡瀹炶澶�</param>
+        public void SetFixedPositionCommand(CommonDevice device, bool isRealDevice = false)
+        {
+            //濡傛灉褰撳墠浣忓畢涓嶆槸铏氭嫙浣忓畢
+            if (Common.Config.Instance.Home.IsVirtually == false)
+            {
+                int epoint = device.DeviceEpoint;
+                //濡傛灉鏄畾浣嶇湡瀹炶澶囩殑璇�
+                if (isRealDevice == true)
+                {
+                    var myType = this.GetMyDeviceEnumInfo(new List<CommonDevice> { device });
+                    if (myType.ConcreteType == DeviceConcreteType.DimmableLight_OneLoad)
+                    {
+                        //涓�璺皟鍏夊櫒闇�瑕佸彂8鍥炶矾
+                        epoint = 8;
+                    }
+                }
+                device.IdentifyControl(device.DeviceAddr, epoint, 5);
+            }
+        }
+
+        /// <summary>
+        /// 妫�娴嬭澶囨槸鍚︽嫢鏈夊畾浣嶇殑鍔熻兘
+        /// </summary>
+        /// <param name="device"></param>
+        /// <returns></returns>
+        public bool DeviceIsCanFixedPosition(CommonDevice device)
+        {
+            if (device.Type == DeviceType.DoorLock || device.Type == DeviceType.Airer || device.Type == DeviceType.PMSensor)
+            {
+                //闂ㄩ攣鍜屾櫨琛f灦娌℃湁瀹氫綅鍔熻兘锛�
+                return false;
+            }
+            var myTypeInfo = this.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
+            if (device.Type == DeviceType.IASZone)
+            {
+                if (myTypeInfo.ConcreteType == DeviceConcreteType.Sensor_Pir)
+                {
+                    //浼犳劅鍣ㄩ櫎浜哖ir閮芥病鏈夊畾浣嶅姛鑳�
+                    return true;
+                }
+                else if (myTypeInfo.ConcreteType == DeviceConcreteType.Sensor_SphericalMotion)
+                {
+                    //鐞冨瀷绉诲姩浼犳劅鍣ㄨ櫧鐒舵槸鐢垫睜璁惧,浣嗘槸瀹冩湁瀹氫綅鍔熻兘
+                    return true;
+                }
+                return false;
+            }
+            //娓╂箍搴︿紶鎰熷櫒娌℃湁瀹氫綅鍔熻兘
+            if (myTypeInfo.ConcreteType == DeviceConcreteType.Sensor_TemperatureHumidity)
+            {
+                return false;
+            }
+
+            foreach (var data in device.InClusterList)
+            {
+                //鎷ユ湁on/off鍔熻兘鐨勶紝鎵嶆敮鎸佹祴璇�
+                if (data.InCluster == 3)
+                {
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        /// <summary>
+        /// 妫�娴嬭澶囨槸鍚︽嫢鏈変竴閿悓姝ュ姛鑳�
+        /// </summary>
+        /// <param name="device"></param>
+        /// <returns></returns>
+        public bool DeviceIsCanSynchronization(CommonDevice device)
+        {
+            //鑾峰彇璁惧绫诲瀷鐨�
+            var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
+            if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleMultifunction)
+            {
+                return true;
+            }
+            return false;
+        }
+
+        /// <summary>
+        /// 妫�娴嬭澶囨槸鍚︽嫢鏈夊紑鍏崇殑鍔熻兘(杈撳嚭绨�)
+        /// </summary>
+        /// <param name="device"></param>
+        /// <returns></returns>
+        public bool OutDeviceIsCanOnOff(CommonDevice device)
+        {
+            foreach (var data in device.OutClusterList)
+            {
+                //鎷ユ湁on/off鍔熻兘鐨勶紝鎵嶆敮鎸佹祴璇�
+                if (data.OutCluster == 6)
+                {
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        /// <summary>
+        /// 妫�娴嬭澶囨槸鍚︽嫢鏈夊紑鍏崇殑鍔熻兘(杈撳叆绨�)
+        /// </summary>
+        /// <param name="device"></param>
+        /// <returns></returns>
+        public bool InDeviceIsCanOnOff(CommonDevice device)
+        {
+            foreach (var data in device.InClusterList)
+            {
+                //鎷ユ湁on/off鍔熻兘鐨勶紝鎵嶆敮鎸佹祴璇�
+                if (data.InCluster == 6)
+                {
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        #endregion
+
+        #region 鈻� 鑾峰彇璁惧___________________________
+
+        /// <summary>
+        /// 鏍规嵁缃戝叧ID鑾峰彇鎵�鏈夌殑璁惧
+        /// </summary>
+        /// <param name="gwId">缃戝叧ID</param>>
+        /// <returns></returns>
+        public List<CommonDevice> GetDeviceByGatewayID(string gwId)
+        {
+            lock (dicAllDevice)
+            {
+                var listMac = new List<string>();
+                //鍚勭綉鍏崇殑鎵�鏈夎澶囩殑Mac
+                foreach (CommonDevice device in this.dicAllDevice.Values)
+                {
+                    if (gwId == device.CurrentGateWayId)
+                    {
+                        listMac.Add(device.DeviceAddr);
+                    }
+                }
+                return this.GetDevicesByMac(listMac);
+            }
+        }
+
+        /// <summary>
+        /// 鑾峰彇鎸囧畾璁惧(涓婚敭鏄細Mac鍦板潃+绔彛鍙�),涓嶅瓨鍦ㄦ椂锛岃繑鍥瀗ull
+        /// </summary>
+        /// <param name="mainKeys">Mac鍦板潃+绔彛鍙�</param>
+        /// <returns></returns>
+        public CommonDevice GetDevice(string mainKeys)
+        {
+            lock (dicAllDevice)
+            {
+                if (this.dicAllDevice.ContainsKey(mainKeys) == true)
+                {
+                    return this.dicAllDevice[mainKeys];
+                }
+            }
+            return null;
+        }
+
+        /// <summary>
+        /// 鑾峰彇鎸囧畾璁惧,涓嶅瓨鍦ㄦ椂锛岃繑鍥瀗ull
+        /// </summary>
+        /// <param name="DeviceAddr">Mac鍦板潃</param>
+        /// <param name="DeviceEpoint">绔彛鍙�</param>
+        /// <returns></returns>
+        public CommonDevice GetDevice(string DeviceAddr, int DeviceEpoint)
+        {
+            string mainkeys = this.GetDeviceMainKeys(DeviceAddr, DeviceEpoint);
+            return this.GetDevice(mainkeys);
+        }
+
+        /// <summary>
+        /// 鏍规嵁MAC鍦板潃,鑾峰彇鍏ㄩ儴鍥炶矾鐨勮澶囧璞�
+        /// </summary>
+        /// <param name="DeviceAddr">Mac鍦板潃</param>
+        /// <param name="sort">鏄惁鎺掑簭</param>
+        /// <returns></returns>
+        public List<CommonDevice> GetDevicesByMac(string DeviceAddr, bool sort = true)
+        {
+            var list = new List<CommonDevice>();
+            if (dicDeviceEpoint.ContainsKey(DeviceAddr) == false)
+            {
+                return list;
+            }
+            foreach (var point in dicDeviceEpoint[DeviceAddr])
+            {
+                var device = this.GetDevice(DeviceAddr, point);
+                if (device != null)
+                {
+                    list.Add(device);
+                }
+            }
+            if (sort == false)
+            {
+                return list;
+            }
+
+            //鎺掑簭
+            list.Sort((obj1, obj2) =>
+            {
+                if (obj1.DeviceEpoint > obj2.DeviceEpoint)
+                {
+                    return 1;
+                }
+                return -1;
+            });
+            return list;
+        }
+
+        /// <summary>
+        /// 鏍规嵁MAC鍦板潃,鑾峰彇绠�绾﹂潰鏉垮叏閮ㄥ洖璺殑璁惧瀵硅薄
+        /// </summary>
+        /// <param name="listDevice"></param>
+        /// <returns></returns>
+        public List<CommonDevice> GetMutilfunctionPanelByMac(List<CommonDevice> listDevice, bool sort = true)
+        {
+            //鍜屽姜鍝ャ�佽澶囧拰浜у搧閮ㄥ悓浜嬬‘璁わ細
+            //绠�绾﹀鍔熻兘闈㈡澘[涓嶆樉绀哄浣欑殑鍥炶矾锛屽彧鏄剧ず鎼哄甫鐨�2涓户鐢靛櫒锛�1涓俯搴︿紶鎰熷櫒锛�1涓箍搴︿紶鎰熷櫒
+            var list = new List<CommonDevice>();
+            foreach (var dev in listDevice)
+            {
+                if (dev.Type == DeviceType.TemperatureSensor)
+                {
+                    if (dev.DeviceEpoint == 64)
+                    {
+                        list.Add(dev);
+                    }
+                }
+                else if (dev.Type == DeviceType.FreshAirHumiditySensor)
+                {
+                    if (dev.DeviceEpoint == 65)
+                    {
+                        list.Add(dev);
+                    }
+                }
+                else if (dev.Type == DeviceType.OnOffOutput)
+                {
+                    list.Add(dev);
+                }
+            }
+
+            if (sort == false)
+            {
+                return list;
+            }
+            list.Sort((obj1, obj2) =>
+            {
+                if (obj1.DeviceEpoint > obj2.DeviceEpoint)
+                {
+                    return 1;
+                }
+                return -1;
+            });
+
+            return list;
+        }
+
+        /// <summary>
+        /// 鏍规嵁MAC鍦板潃,鑾峰彇鏂伴銆佺畝绾︾幆澧冮潰鏉垮叏閮ㄥ洖璺殑璁惧瀵硅薄
+        /// </summary>
+        /// <param name="listDevice"></param>
+        /// <returns></returns>
+        public List<CommonDevice> GetPanelMatchEpointByMac(List<CommonDevice> listDevice, bool sort = true)
+        {
+            var list = new List<CommonDevice>();
+            foreach (var dev in listDevice)
+            {
+                if (dev.Type == DeviceType.TemperatureSensor)
+                {
+                    list.Add(dev);
+                }
+                else if (dev.Type == DeviceType.FreshAirHumiditySensor)
+                {
+                    list.Add(dev);
+                }
+            }
+            if (sort == false)
+            {
+                return list;
+            }
+            list.Sort((obj1, obj2) =>
+            {
+
+                if (obj1.DeviceEpoint > obj2.DeviceEpoint)
+                {
+                    return 1;
+                }
+                return -1;
+            });
+            return list;
+        }
+
+        /// <summary>
+        /// 鏍规嵁MAC鍦板潃,鑾峰彇鍏ㄩ儴鍥炶矾鐨勮澶囧璞�(寮哄埗鎺掑簭)
+        /// </summary>
+        /// <param name="DeviceAddr">Mac鍦板潃</param>
+        /// <returns></returns>
+        public List<CommonDevice> GetDevicesByMac(List<string> listMacAddr)
+        {
+            //鍏堟帓搴�
+            listMacAddr.Sort();
+
+            var list = new List<CommonDevice>();
+            foreach (string strMac in listMacAddr)
+            {
+                var listEpoint = new List<int>();
+                //鑾峰彇鍏ㄩ儴鐨勭鐐�
+                foreach (int epoint in this.dicDeviceEpoint[strMac])
+                {
+                    listEpoint.Add(epoint);
+                }
+                //鐒跺悗鎺掑簭
+                listEpoint.Sort();
+                foreach (int epoint in listEpoint)
+                {
+                    var device = this.GetDevice(strMac, epoint);
+                    if (device != null)
+                    {
+                        list.Add(device);
+                    }
+                }
+            }
+            return list;
+        }
+
+        /// <summary>
+        /// 鏍规嵁MAC鍦板潃,鑾峰彇鍏ㄩ儴鍥炶矾鐨勬暟閲�
+        /// </summary>
+        /// <param name="DeviceAddr">Mac鍦板潃</param>
+        /// <returns></returns>
+        public int GetDevicesCountByMac(string DeviceAddr)
+        {
+            if (dicDeviceEpoint.ContainsKey(DeviceAddr) == false)
+            {
+                return 0;
+            }
+            return dicDeviceEpoint[DeviceAddr].Count;
+        }
+
+        /// <summary>
+        /// 鑾峰彇鏈湴鍏ㄩ儴鐨勮澶囨枃浠�
+        /// </summary>
+        /// <returns></returns>
+        public List<string> GetAllDeviceFile()
+        {
+            List<string> listDeviceFile = new List<string>();
+            List<string> listAllFile = HdlFileLogic.Current.GetRootPathListFile();
+
+            foreach (string file in listAllFile)
+            {
+                if (file.StartsWith("Device_") == false)
+                {
+                    //濡傛灉涓嶆槸璁惧鏂囦欢
+                    continue;
+                }
+                listDeviceFile.Add(file);
+            }
+            return listDeviceFile;
+        }
+
+        /// <summary>
+        /// 鑾峰彇OTA璁惧(200绔彛鐨�)
+        /// </summary>
+        /// <param name="macAdrr"></param>
+        /// <param name="ePoint"></param>
+        /// <returns></returns>
+        public OTADevice GetOTADevice(string macAdrr, int ePoint = 200)
+        {
+            string mainkeys = this.GetDeviceMainKeys(macAdrr, ePoint);
+            if (this.dicOTADevice.ContainsKey(mainkeys) == false)
+            {
+                return null;
+            }
+            return this.dicOTADevice[mainkeys];
+        }
+
+        /// <summary>
+        /// 鑾峰彇鐗规畩鐨�,娌℃湁鍏朵粬鍥炶矾,鍗曠函鍙湁200绔偣鐨凮TA璁惧
+        /// </summary>
+        /// <param name="gwId">缃戝叧ID</param>
+        /// <returns></returns>
+        public List<OTADevice> GetSpecialOtaDevice(string gwId)
+        {
+            var list = new List<OTADevice>();
+            foreach (var ota in this.dicOTADevice.Values)
+            {
+                if (ota.CurrentGateWayId != gwId)
+                {
+                    //涓嶆槸鍚屼竴涓綉鍏�
+                    continue;
+                }
+                //娌℃湁鍏朵粬鍥炶矾
+                if (dicDeviceEpoint.ContainsKey(ota.DeviceAddr) == false
+                    || dicDeviceEpoint[ota.DeviceAddr].Count == 0)
+                {
+                    //鐩墠鍙拡瀵逛腑澶┖璋�
+                    if (ota.ModelIdentifier == "MAC/GW-ZB.10")
+                    {
+                        list.Add(ota);
+                    }
+                }
+            }
+            return list;
+        }
+
+        #endregion
+
+        #region 鈻� 鑾峰彇璁惧淇℃伅_______________________
+
+        /// <summary>
+        /// 浠庣綉鍏宠鍙栧崟涓鐐瑰洖璺澶囦俊鎭�
+        /// </summary>
+        /// <param name="device">璁惧瀵硅薄</param>
+        /// <returns></returns>
+        public CommonDevice.DeviceInfoData ReadDeviceEpointDeviceInfo(CommonDevice device)
+        {
+            var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", device.DeviceAddr }, { "Epoint", device.DeviceEpoint }, { "Cluster_ID", 0 }, { "Command", 80 } };
+            var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "GetStatusRecord", jObject.ToString(), "GetStatusRecord_Respon");
+            if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
+            {
+                return null;
+            }
+            var info = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.DeviceInfoData>(result.ReceiptData);
+            return info;
+        }
+
+        /// <summary>
+        /// 浠庣綉鍏宠鍙栨寚瀹歁ac涓嬬殑璁惧鍒楄〃(杩斿洖鐨勬槸缃戝叧鍥炲鐨勮澶嘕son,璋冪敤ConvertJObjectToDevice鏂规硶杞负Device瀵硅薄)
+        /// </summary>
+        /// <param name="realGateway">鐪熷疄缃戝叧瀵硅薄</param>
+        /// <param name="i_deviceMac">璁惧Mac</param>
+        /// <param name="useLocalConnect">鏄惁浣跨敤鏈湴杩炴帴鍙戦��</param>
+        /// <param name="listFucDevice">闇�瑕佸彉鏇村姛鑳界被鍨嬬殑鍥炶矾</param>
+        /// <param name="statu">鐘舵��-> -1:寮傚父,浼氳繑鍥瀗ull, 1锛氭病鏈夊紓甯�, 2:鏁版嵁鎺ユ敹涓嶅叏</param>
+        /// <returns></returns>
+        public List<Newtonsoft.Json.Linq.JObject> ReadDeviceListByMacFromGateway(string gatewayId, string i_deviceMac, bool useLocalConnect, ref int statu)
+        {
+            //鏄惁杈炬垚涓柇鐨勬椂鏈�
+            bool canBreak = false;
+            //瓒呮椂鏃堕棿
+            int TimeOut = 0;
+            //璁惧鎬绘暟
+            int deviceCount = -1;
+            //鎺ユ敹鏁�
+            int receiveCount = 0;
+            //璁惧鍒楄〃
+            var listDeviceJson = new List<Newtonsoft.Json.Linq.JObject>();
+
+            HdlGatewayReceiveLogic.Current.AddGatewayReceiveEvent(gatewayId, (topic, message) =>
+            {
+                if (topic == gatewayId + "/GetStatusRecord_Respon")
+                {
+                    lock (listDeviceJson)
+                    {
+                        //璁惧鎺ユ敹鏁�
+                        receiveCount++;
+                        TimeOut = 0;
+                        var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
+                        var totalNum = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["TotalNum"].ToString());
+                        if (totalNum == 0)
+                        {
+                            //杩欎釜缃戝叧娌℃湁璁惧
+                            canBreak = true;
+                            return;
+                        }
+                        if (deviceCount == -1)
+                        {
+                            //璁剧疆闇�瑕佹帴鏀跺灏戜釜璁惧
+                            deviceCount = totalNum;
+                        }
+                        listDeviceJson.Add(jobject);
+                    }
+
+                    if (receiveCount == deviceCount && deviceCount != -1)
+                    {
+                        //璁惧鍏ㄩ儴鎺ユ敹瀹屾垚
+                        canBreak = true;
+                    }
+                }
+            });
+
+            var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", i_deviceMac }, { "Epoint", 255 }, { "Cluster_ID", 0 }, { "Command", 80 } };
+            HdlGatewayLogic.Current.SendJobjectData(gatewayId, "GetStatusRecord", jObject.ToString(), useLocalConnect);
+
+            while (canBreak == false && TimeOut <= 150)
+            {
+                System.Threading.Thread.Sleep(20);
+                TimeOut++;
+            }
+            //绉婚櫎鐩戝惉
+            HdlGatewayReceiveLogic.Current.RemoveGatewayReceiveEvent();
+
+            if (TimeOut > 150)
+            {
+                statu = listDeviceJson.Count == 0 ? -1 : 2;
+            }
+            else
+            {
+                statu = 1;
+            }
+            return listDeviceJson;
+        }
+
+        /// <summary>
+        /// 灏嗚澶囩殑Json杞崲涓鸿澶囧璞�
+        /// </summary>
+        /// <param name="listIObjects">璁惧Json</param>
+        /// <param name="gwId">缃戝叧id</param>
+        /// <param name="listFucDevice">闇�瑕佸彉鏇村姛鑳界被鍨嬬殑鍥炶矾</param>
+        /// <returns></returns>
+        public List<CommonDevice> ConvertJObjectToDevice(List<Newtonsoft.Json.Linq.JObject> listIObjects, string gwId, ref List<CommonDevice> listFucDevice)
+        {
+            //璁惧鍒楄〃
+            var listDevice = new List<CommonDevice>();
+            //缃戝叧閲岄潰鏈夊彲鑳戒細鏈夐噸澶嶇殑鍥炶矾
+            var listCheck = new HashSet<string>();
+
+            foreach (var jobject in listIObjects)
+            {
+                var deviceID = (DeviceType)jobject.Value<int>("Device_ID");
+                //鏍规嵁璁惧绫诲瀷鍒涘缓璁惧瀵硅薄鐨勫疄渚�
+                var device = this.NewDeviceObjectByDeviceId(deviceID, jobject, gwId);
+                if (device != null)
+                {
+                    string mainkeys = this.GetDeviceMainKeys(device);
+                    //缃戝叧閲岄潰鏈夊彲鑳戒細鏈夐噸澶嶇殑鍥炶矾
+                    if (listCheck.Contains(mainkeys) == false)
+                    {
+                        listDevice.Add(device);
+                        listCheck.Add(mainkeys);
+                        //鍒锋柊涓�涓嬫湰鍦扮紦瀛�
+                        var localDevice = this.GetDevice(mainkeys);
+                        var tempDevice = localDevice == null ? device : localDevice;
+
+                        //濡傛灉杩欎釜璁惧ID鍙樻洿浜嗙殑璇�
+                        bool typeNotEquals = localDevice != null && deviceID != localDevice.Type;
+                        if (typeNotEquals == true)
+                        {
+                            //閲嶆柊New杩欎釜瀵硅薄
+                            typeNotEquals = this.ReNewDeviceOnTypeIsChanged(localDevice, deviceID);
+                            //閲嶆柊鍐嶆鑾峰彇瀵硅薄
+                            tempDevice = this.GetDevice(mainkeys);
+                        }
+
+                        //鍒锋柊灞炴��
+                        this.SetDeviceInfoToMain(tempDevice, device);
+                        if (this.RefreshDeviceFunctionType(tempDevice, device, false) == true)
+                        {
+                            //闇�瑕佸彂閫佸姛鑳界被鍨嬬粰缃戝叧
+                            listFucDevice.Add(tempDevice);
+                        }
+                        if (typeNotEquals == true)
+                        {
+                            //閲嶆柊鐢熸垚缂撳瓨
+                            tempDevice.ReSave();
+                            HdlAutoBackupLogic.AddOrEditorFile(tempDevice.FilePath);
+                            //鍏ㄩ儴涓婚〉鑿滃崟闇�瑕佸埛鏂�
+                            Phone.UserView.UserPage.Instance.RefreshAllForm = true;
+                        }
+                    }
+                }
+            }
+            return listDevice;
+        }
+
+        #endregion
+
+        #region 鈻� 璁剧疆璁惧鍔熻兘绫诲瀷___________________
+
+        /// <summary>
+        /// 璁剧疆璁惧鍔熻兘绫诲瀷鍒扮綉鍏�
+        /// </summary>
+        /// <param name="device">璁惧鍥炶矾</param>
+        /// <param name="functionType">鍔熻兘绫诲瀷</param>
+        /// <returns></returns>
+        public bool SendDeviceFunctionTypeToGateway(CommonDevice device, DeviceFunctionType functionType)
+        {
+            //濡傛灉鏄櫄鎷熶綇瀹�
+            if (Common.Config.Instance.Home.IsVirtually == true)
+            {
+                device.DfunctionType = functionType;
+                return true;
+            }
+            //鑾峰彇鍛戒护瀛楃
+            var sendCommond = this.GetDeviceFunctionTypeCommandText(device, functionType);
+            var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "Device/SetEPDeviceFunctionType", sendCommond, "Device/SetEPDeviceFunctionTypeRespon");
+            if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
+            {
+                return false;
+            }
+            var resultData = Newtonsoft.Json.Linq.JObject.Parse(result.ReceiptData);
+            if (resultData.Property("Result") != null)
+            {
+                //0:淇敼鎴愬姛 1:淇敼澶辫触
+                return resultData["Result"].ToString() == "0";
+            }
+            return false;
+        }
+
+        /// <summary>
+        /// 鑾峰彇鏇存敼璁惧鍔熻兘绫诲瀷鐨勫懡浠ゆ枃鏈�
+        /// </summary>
+        /// <param name="device"></param>
+        /// <param name="functionType"></param>
+        /// <returns></returns>
+        public string GetDeviceFunctionTypeCommandText(CommonDevice device, DeviceFunctionType functionType)
+        {
+            var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", device.DeviceAddr }, { "Epoint", device.DeviceEpoint }, { "Cluster_ID", 0 }, { "Command", 110 } };
+            var data = new Newtonsoft.Json.Linq.JObject { { "FunctionType", (int)functionType } };
+            jObject.Add("Data", data);
+            return jObject.ToString();
+        }
+
+        #endregion
+
+        #region 鈻� 鑾峰彇璁惧鍚嶇О_______________________
+
+        /// <summary>
+        /// 鑾峰彇璁惧绔偣鐨勫悕绉�(鏈夌壒鏁�)
+        /// </summary>
+        /// <param name="device">璁惧瀵硅薄</param>
+        /// <returns></returns>
+        public string GetDeviceEpointName(CommonDevice device)
+        {
+            string dName = this.GetSimpleEpointName(device);
+            if (string.IsNullOrEmpty(dName) == false)
+            {
+                return dName;
+            }
+            if (this.IsMiniLight(device) == true)
+            {
+                //Mini澶滅伅
+                return Language.StringByID(R.MyInternationalizationString.uMiniNightLight);
+            }
+
+            //濡傛灉杩欎釜璁惧鍙湁涓�涓洖璺殑璇�,杩斿洖Mac鍚嶅瓧缁欏畠
+            if (this.GetDevicesCountByMac(device.DeviceAddr) <= 1)
+            {
+                return this.GetDeviceMacName(device);
+            }
+
+            //鍚屼竴璁惧閲岄潰,涓嶅悓绫诲瀷鐨勫洖璺�,瀹冪殑鍛藉悕閮戒粠1寮�濮�
+            int epointNo = 0;
+            var listSort = this.GetDevicesByMac(device.DeviceAddr);
+            foreach (var myDevice in listSort)
+            {
+                if (myDevice.Type == device.Type)
+                {
+                    //鍚屼竴绫诲瀷缂栧彿+1
+                    epointNo++;
+                    if (myDevice.DeviceEpoint == device.DeviceEpoint)
+                    {
+                        //宸茬粡鍒拌揪瀹冭嚜宸�
+                        break;
+                    }
+                }
+            }
+
+            if (device.Type == DeviceType.OnOffOutput
+                || device.Type == DeviceType.DimmableLight
+                || device.Type == DeviceType.ColorDimmableLight
+                || device.Type == DeviceType.ColorTemperatureLight)
+            {
+                //缁х數鍣�,鎺夊厜鍣ㄩ兘鍙洖璺�
+                return Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + epointNo;
+            }
+            if (device.Type == DeviceType.Thermostat)
+            {
+                //绌鸿皟閮藉彨瀹ゅ唴鏈�
+                return Language.StringByID(R.MyInternationalizationString.uIndoorUnit) + epointNo;
+            }
+
+            //鑾峰彇璁惧绫诲瀷
+            var deviceInfoType = this.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
+            if (device.Type == DeviceType.OnOffSwitch)
+            {
+                //闈㈡澘鐨勫共鎺ョ偣鍙寜閿�
+                if (deviceInfoType.BeloneType == DeviceBeloneType.A鎸夐敭闈㈡澘)
+                {
+                    return Language.StringByID(R.MyInternationalizationString.uPanelButton) + epointNo;
+                }
+                //鍏朵粬鐨勫共鎺ョ偣鍙共鎺ョ偣
+                else
+                {
+                    var infoContent = this.GetDeviceModelIdNameInfo("A419");
+                    return infoContent != null ? infoContent.A瀹樻柟鍚嶅瓧 + epointNo : string.Empty;
+                }
+            }
+            else if (device.Type == DeviceType.FreshAirHumiditySensor)
+            {
+                //鏂伴闈㈡澘/绠�绾﹀鍔熻兘/绠�绾︾幆澧冮潰鏉挎箍搴︿紶鎰熷櫒
+                return deviceInfoType.DeviceDefultName + Language.StringByID(R.MyInternationalizationString.HumiditySensor);
+            }
+            else if (device.Type == DeviceType.TemperatureSensor)
+            {
+                if (deviceInfoType.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir
+                    || deviceInfoType.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleEnvironment
+                    || deviceInfoType.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueEnvironment
+                    || deviceInfoType.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleMultifunction)
+                {
+                    //鏂伴闈㈡澘/绠�绾﹀鍔熻兘/绠�绾�/鏂规偊鐜闈㈡澘 娓╁害浼犳劅鍣�
+                    return deviceInfoType.DeviceDefultName + Language.StringByID(R.MyInternationalizationString.TemperatureSensor);
+                }
+                else if (deviceInfoType.BeloneType == DeviceBeloneType.A鎸夐敭闈㈡澘)
+                {
+                    //闈㈡澘鐨勬俯搴︽帰澶村彨  闈㈡澘鍚嶅瓧+娓╁害
+                    return deviceInfoType.DeviceDefultName + Language.StringByID(R.MyInternationalizationString.uTemperature);
+                }
+                else if (deviceInfoType.BeloneType == DeviceBeloneType.A绌烘皵璐ㄩ噺)
+                {
+
+                    //绌烘皵璐ㄩ噺浼犳劅鍣ㄧ殑娓╁害鎺㈠ご鍙┖姘旇川閲忎紶鎰熷櫒+娓╁害
+                    return deviceInfoType.DeviceDefultName + Language.StringByID(R.MyInternationalizationString.TemperatureSensor);
+                }
+                else if (((TemperatureSensor)device).SensorDiv == 1)
+                {
+                    //娓╁害浼犳劅鍣�
+                    return Language.StringByID(R.MyInternationalizationString.TemperatureSensor);
+                }
+                else if (((TemperatureSensor)device).SensorDiv == 2)
+                {
+                    //婀垮害浼犳劅鍣�
+                    return Language.StringByID(R.MyInternationalizationString.HumiditySensor);
+                }
+            }
+            //鍏朵粬鎯呭喌,浣跨敤瀹冪殑榛樿鍚嶇О
+            return deviceInfoType.DeviceDefultName + epointNo;
+        }
+
+        /// <summary>
+        /// 鑾峰彇璁惧MAC鍚嶇О
+        /// </summary>
+        /// <param name="device">璁惧瀵硅薄</param>
+        /// <returns></returns>
+        public string GetDeviceMacName(CommonDevice device)
+        {
+            string dName = this.GetSimpleMacName(device);
+            if (string.IsNullOrEmpty(dName) == false)
+            {
+                return dName;
+            }
+            if (this.IsMiniLight(device) == true)
+            {
+                //Mini澶滅伅
+                return Language.StringByID(R.MyInternationalizationString.uMiniNightLight);
+            }
+
+            //鑾峰彇璁惧绫诲瀷
+            var deviceInfoType = this.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
+            return deviceInfoType.DeviceDefultName;
+        }
+
+        /// <summary>
+        /// 闈炲叕寮�,璁剧疆璁惧鐨凪ac鍚嶅瓧(姝ゆ柟娉曞彧鏄崟瀛樼殑鍙樻洿缂撳瓨)
+        /// </summary>
+        /// <param name="device">璁惧瀵硅薄</param>
+        /// <param name="macName">Mac鍚嶅瓧</param>
+        /// <returns></returns>
+        public void SetMacName(CommonDevice device, string macName)
+        {
+            device.DeviceName = macName;
+        }
+
+        /// <summary>
+        /// 闈炲叕寮�,璁剧疆璁惧鐨勭鐐瑰悕瀛�(姝ゆ柟娉曞彧鏄崟瀛樼殑鍙樻洿缂撳瓨)
+        /// </summary>
+        /// <param name="device">璁惧瀵硅薄</param>
+        /// <param name="epointName">绔偣鍚嶅瓧</param>
+        /// <returns></returns>
+        public void SetEpointName(CommonDevice device, string epointName)
+        {
+            device.DeviceEpointName = epointName;
+        }
+
+        /// <summary>
+        /// 鍗曠函鑾峰彇璁惧鐨凪ac鍚嶅瓧
+        /// </summary>
+        /// <param name="device">璁惧瀵硅薄</param>
+        /// <returns></returns>
+        public string GetSimpleMacName(CommonDevice device)
+        {
+            return device.DeviceName;
+        }
+
+        /// <summary>
+        /// 鍗曠函鑾峰彇璁惧鐨勭鐐瑰悕瀛�
+        /// </summary>
+        /// <param name="device">璁惧瀵硅薄</param>
+        /// <returns></returns>
+        public string GetSimpleEpointName(CommonDevice device)
+        {
+            return device.DeviceEpointName;
+        }
+
+        #endregion
+
+        #region 鈻� 璁剧疆鍥炬爣___________________________
+
+        /// <summary>
+        /// 鍙樻洿璁惧鐨勫浘鏍�
+        /// </summary>
+        /// <param name="device">璁惧瀵硅薄</param>
+        /// <param name="unSelPath">鍥剧墖鍦板潃(闈為�夋嫨)</param>
+        public void ChangedDeviceIcon(CommonDevice device, string unSelPath)
+        {
+            if (unSelPath == string.Empty)
+            {
+                return;
+            }
+            device.IconPath = unSelPath;
+            device.IsCustomizeImage = true;
+            device.ReSave();
+
+            HdlAutoBackupLogic.AddOrEditorFile(device.FilePath);
+        }
+
+        /// <summary>
+        /// 璁剧疆璁惧銆愬浘鏍囥�戝埌鎸囧畾鐨勬帶浠�
+        /// </summary>
+        /// <param name="btnIcon">鎺т欢瀵硅薄</param>
+        /// <param name="device">璁惧瀵硅薄</param>
+        /// <returns></returns>
+        public void SetDeviceIconToControl(Button btnIcon, CommonDevice device)
+        {
+            if (device == null)
+            {
+                btnIcon.UnSelectedImagePath = "Device/ThirdPartyDevice.png";
+                return;
+            }
+            string unSelectFilePath = string.Empty;
+            string selectFilePath = string.Empty;
+
+            //鑾峰彇璁惧銆愬浘鏍囥��
+            this.GetDeviceIcon(device, ref unSelectFilePath, ref selectFilePath);
+            if (btnIcon.UnSelectedImagePath != unSelectFilePath)
+            {
+                btnIcon.UnSelectedImagePath = unSelectFilePath;
+            }
+            if (btnIcon.SelectedImagePath != selectFilePath)
+            {
+                btnIcon.SelectedImagePath = selectFilePath;
+            }
+        }
+
+        /// <summary>
+        /// 璁剧疆璁惧銆愬浘鏍囥�戝埌鎸囧畾鐨勬帶浠�(娉ㄦ剰,姝ゅ嚱鏁拌缃殑閫夋嫨鐘舵�佺殑鍥剧墖鏄櫧鑹茬殑)
+        /// </summary>
+        /// <param name="btnIcon">鎺т欢瀵硅薄</param>
+        /// <param name="device">璁惧瀵硅薄</param>
+        /// <returns></returns>
+        public void SetDeviceIconToControl2(Button btnIcon, CommonDevice device)
+        {
+            if (device == null)
+            {
+                btnIcon.UnSelectedImagePath = "Device/ThirdPartyDevice.png";
+                return;
+            }
+            string unSelectFilePath = device.IconPath;
+            string selectFilePath = unSelectFilePath.Replace(".png", "Selected2.png");
+
+            //鑾峰彇璁惧銆愬浘鏍囥��
+            if (btnIcon.UnSelectedImagePath != unSelectFilePath)
+            {
+                btnIcon.UnSelectedImagePath = unSelectFilePath;
+            }
+            if (btnIcon.SelectedImagePath != selectFilePath)
+            {
+                btnIcon.SelectedImagePath = selectFilePath;
+            }
+        }
+
+        /// <summary>
+        /// 鑾峰彇璁惧銆愬浘鏍囥��
+        /// </summary>
+        /// <param name="listdevice">璁惧瀵硅薄</param>
+        /// <param name="unSelectPath">鍥剧墖鍦板潃</param>
+        /// <param name="selectPath">鍥剧墖鍦板潃</param>
+        /// <returns></returns>
+        public void GetDeviceIcon(CommonDevice device, ref string unSelectPath, ref string selectPath)
+        {
+            if (string.IsNullOrEmpty(device.IconPath) == true)
+            {
+                return;
+            }
+            unSelectPath = device.IconPath;
+
+            string selPath = device.OnlineIconPath;
+            if (string.IsNullOrEmpty(selPath) == false)
+            {
+                selectPath = selPath;
+            }
+        }
+
+        /// <summary>
+        /// 璁剧疆璁惧鐨勭湡瀹炲浘鐗囧埌鎸囧畾鐨勬帶浠�
+        /// </summary>
+        /// <param name="btnIcon">鎺т欢瀵硅薄</param>
+        /// <param name="listdevice">璁惧瀵硅薄</param>
+        public void SetRealDeviceIconToControl(Button btnIcon, List<CommonDevice> listdevice)
+        {
+            //鑾峰彇璁惧鐨勭湡瀹炲浘鐗�
+            string imagePath = this.GetRealDeviceIcon(listdevice);
+            btnIcon.UnSelectedImagePath = imagePath;
+        }
+
+        /// <summary>
+        /// 鑾峰彇璁惧鐨勭湡瀹炲浘鐗�
+        /// </summary>
+        /// <param name="listdevice">璁惧瀵硅薄</param>
+        public string GetRealDeviceIcon(List<CommonDevice> listdevice)
+        {
+            //鑾峰彇瀹冨睘浜庝粈涔堢被鍨嬬殑璁惧
+            var myDeviceType = this.GetMyDeviceEnumInfo(listdevice);
+            string strConcrete = Enum.GetName(typeof(DeviceConcreteType), myDeviceType.ConcreteType);
+
+            //鍥剧墖鍏辨湁
+            if (this.dicPictrueShard.ContainsKey(strConcrete) == true)
+            {
+                strConcrete = this.dicPictrueShard[strConcrete];
+            }
+
+            string strType = strConcrete.Replace("_", string.Empty);
+            //灏嗙被鍨嬭浆涓哄浘鐗囧湴鍧�
+            string imageFilePath = "RealDevice/" + strType + ".png";
+            //杩欎釜鍥剧墖鏈湴鏄惁瀛樺湪锛�
+            if (string.IsNullOrEmpty(IO.FileUtils.GetImageFilePath(imageFilePath)) == true)
+            {
+                //涓嶅瓨鍦ㄥ垯浣跨敤鍏遍�氬浘鐗�
+                string[] arry = strConcrete.Split(new string[] { "_" }, StringSplitOptions.None);
+                if (arry.Length == 1)
+                {
+                    //濡傛灉瀹冭嚜宸卞氨鏄叡閫氬浘鐗囩殑璇濓紝涓嶅啀澶勭悊
+                    return "RealDevice/CommonDevice.png";
+                }
+                imageFilePath = "RealDevice/" + arry[0] + ".png";
+                //濡傛灉瀹冭嚜宸辩殑鍏遍�氬浘鐗囪繕鏄笉瀛樺湪鐨勮瘽,鍒欑洿鎺ヤ娇鐢ㄦ墍鏈夎澶囩殑鍏遍�氬浘鐗�
+                if (string.IsNullOrEmpty(IO.FileUtils.GetImageFilePath(imageFilePath)) == true)
+                {
+                    imageFilePath = "RealDevice/CommonDevice.png";
+                }
+            }
+            return imageFilePath;
+        }
+
+        /// <summary>
+        /// 璁剧疆銆愯澶囩被鍨嬨�戠殑鍥炬爣鍒版寚瀹氱殑鎺т欢(姝ゆ柟娉曚笉鑳界敤鍦ㄨ澶囧姛鑳界被鍨嬭彍鍗曠殑鍥炬爣)
+        /// </summary>
+        /// <param name="btnIcon">鎺т欢瀵硅薄</param>
+        /// <param name="listdevice">璁惧瀵硅薄</param>
+        /// <returns></returns>
+        public void SetDeviceObjectIconToControl(Button btnIcon, List<CommonDevice> listdevice)
+        {
+            //鑾峰彇鑷畾涔夎澶囩被鍨�
+            var myDeviceType = this.GetMyDeviceEnumInfo(listdevice);
+
+            string imageUnSelectFilePath = string.Empty;
+            string imageSelectFilePath = string.Empty;
+
+            //鑾峰彇銆愯澶囩被鍨嬨�戠殑鍥炬爣
+            this.GetDeviceObjectIcon(myDeviceType.ConcreteType, ref imageUnSelectFilePath, ref imageSelectFilePath);
+
+            //璁剧疆鍥剧墖
+            btnIcon.UnSelectedImagePath = imageUnSelectFilePath;
+            btnIcon.SelectedImagePath = imageSelectFilePath;
+        }
+
+        /// <summary>
+        /// 鑾峰彇銆愯澶囩被鍨嬨�戠殑鍥炬爣(姝ゆ柟娉曚笉鑳界敤鍦ㄨ澶囧姛鑳界被鍨嬭彍鍗曠殑鍥炬爣)
+        /// </summary>
+        /// <param name="listdevice">璁惧瀵硅薄</param>
+        /// <param name="unSelectPath">鍥剧墖鍦板潃</param>
+        /// <param name="selectPath">鍥剧墖鍦板潃</param>
+        /// <returns></returns>
+        public void GetDeviceObjectIcon(List<CommonDevice> listdevice, ref string unSelectPath, ref string selectPath)
+        {
+            //鑾峰彇鑷畾涔夎澶囩被鍨�
+            var myDeviceType = this.GetMyDeviceEnumInfo(listdevice);
+
+            //鑾峰彇銆愯澶囩被鍨嬨�戠殑鍥炬爣
+            this.GetDeviceObjectIcon(myDeviceType.ConcreteType, ref unSelectPath, ref selectPath);
+        }
+
+        /// <summary>
+        /// 鑾峰彇銆愯澶囧姛鑳界被鍨嬨�戠殑鑿滃崟鍥炬爣
+        /// </summary>
+        /// <param name="deviceEnumInfo">鑷畾涔夎澶囩被鍨�</param>
+        /// <param name="unSelectPath">鍥剧墖鍦板潃</param>
+        /// <param name="selectPath">鍥剧墖鍦板潃</param>
+        /// <returns></returns>
+        public void GetDeviceFunctionTypeMenuIcon(DeviceEnumInfo deviceEnumInfo, ref string unSelectPath, ref string selectPath)
+        {
+            //鏂伴灏忔ā鍧�
+            if (deviceEnumInfo.ConcreteType == DeviceConcreteType.Relay_FangyueFreshAirModul)
+            {
+                unSelectPath = "Device/FreshAirEpoint.png";
+                selectPath = "Device/FreshAirEpointSelected.png";
+                return;
+            }
+            //PM2.5绌烘皵璐ㄩ噺浼犳劅鍣�
+            else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.Sensor_PMTwoPointFive)
+            {
+                unSelectPath = "Device/AirQualitySensorEpoint.png";
+                selectPath = "Device/AirQualitySensorEpointSelected.png";
+                return;
+            }
+            else if (deviceEnumInfo.BeloneType == DeviceBeloneType.A绐楀笜)
+            {
+                unSelectPath = "ZigeeLogic/curtain.png";
+                selectPath = "ZigeeLogic/selectedcurtain.png";
+                return;
+            }
+            //涓婇潰闇�瑕佺壒娈婂鐞�
+
+            //鑾峰彇銆愯澶囩被鍨嬨�戠殑鍥炬爣
+            this.GetDeviceObjectIcon(deviceEnumInfo.ConcreteType, ref unSelectPath, ref selectPath);
+        }
+
+        /// <summary>
+        /// 鑾峰彇銆愯澶囩被鍨嬨�戠殑鍥炬爣 2020.05.13:娆″嚱鏁颁笉鍐嶅叕寮�
+        /// </summary>
+        /// <param name="specificType">鑷畾涔夎澶囩被鍨�</param>
+        /// <param name="unSelectPath">鍥剧墖鍦板潃</param>
+        /// <param name="selectPath">鍥剧墖鍦板潃</param>
+        /// <returns></returns>
+        private void GetDeviceObjectIcon(DeviceConcreteType specificType, ref string unSelectPath, ref string selectPath)
+        {
+            //灏嗗叿浣撶被鍨嬭浆瀛楃涓�
+            string strSpecific = Enum.GetName(typeof(DeviceConcreteType), specificType);
+            //鍥剧墖鍏辨湁
+            if (this.dicPictrueShard.ContainsKey(strSpecific) == true)
+            {
+                strSpecific = this.dicPictrueShard[strSpecific];
+            }
+
+            string strType = strSpecific.Replace("_", string.Empty);
+            //灏嗙被鍨嬭浆涓哄浘鐗囧湴鍧�
+            string imageFilePath = "Device/" + strType + ".png";
+            string imageSelectFilePath = "Device/" + strType + "Selected.png";
+
+            //杩欎釜鍥剧墖鏈湴鏄惁瀛樺湪锛�
+            if (string.IsNullOrEmpty(IO.FileUtils.GetImageFilePath(imageFilePath)) == true)
+            {
+                //涓嶅瓨鍦ㄥ垯浣跨敤鍏遍�氬浘鐗�
+                string[] arry = strSpecific.Split(new string[] { "_" }, StringSplitOptions.None);
+                //濡傛灉瀹冭嚜宸卞氨鏄叡閫氬浘鐗囩殑璇濓紝涓嶅啀澶勭悊
+                if (arry.Length > 1)
+                {
+                    imageFilePath = "Device/" + arry[0] + ".png";
+                    imageSelectFilePath = "Device/" + arry[0] + "Selected.png";
+                }
+            }
+            //濡傛灉閭f璁惧杩炲叡閫氬浘鐗囬兘娌℃湁鐨勮瘽
+            if (string.IsNullOrEmpty(IO.FileUtils.GetImageFilePath(imageFilePath)) == true)
+            {
+                imageFilePath = "Device/ThirdPartyDevice.png";
+                imageSelectFilePath = "Device/ThirdPartyDeviceSelected.png";
+            }
+            //璁剧疆鍥剧墖
+            unSelectPath = imageFilePath;
+            selectPath = imageSelectFilePath;
+        }
+
+        #endregion
+
+        #region 鈻� 鑾峰彇鑷畾涔夌殑璁惧绫诲瀷_______________
+
+        /// <summary>
+        /// 鑾峰彇銆愯嚜瀹氫箟鐨勮澶囩被鍨嬨��,涓ょ绫诲瀷閮借缃簡
+        /// </summary>
+        /// <param name="listdevice">璁惧瀵硅薄</param>
+        /// <returns></returns>
+        public DeviceEnumInfo GetMyDeviceEnumInfo(List<CommonDevice> listdevice)
+        {
+            CommonDevice checkDevice = listdevice[0];
+            foreach (var temp in listdevice)
+            {
+                //鎷挎嫢鏈夋ā鍧桰D鐨勯偅涓洖璺潵鍒ゆ柇
+                if (temp.ModelIdentifier != string.Empty)
+                {
+                    checkDevice = temp;
+                }
+            }
+
+            //鑾峰彇娌充笢璁惧鐨勮澶囩被鍨�
+            DeviceEnumInfo info = this.GetHdlMyDeviceEnumInfo(checkDevice);
+            if (info != null)
+            {
+                return info;
+            }
+            //鑾峰彇绗笁鏂硅澶囩殑銆愯澶囩被鍨嬨��
+            info = this.GetNotHdlMyDeviceEnumInfo(listdevice);
+            //杩欓噷鍐嶆鍒ゆ柇鏄惁鏄渤涓滆澶�,鏈夊彲鑳藉畠鐨勬ā鍧桰D鍐欓敊浜�
+            info.IsHdlDevice = this.IsHdlDevice(checkDevice);
+
+            return info;
+        }
+
+        /// <summary>
+        /// 鑾峰彇璁惧鐨勩�愯澶囩被鍨嬨�戠殑缈昏瘧鏂囨湰(浼樺厛闀滃儚)
+        /// </summary>
+        /// <param name="listDevice"></param>
+        /// <param name="ApendFalge">绗笁鏂规垨鑰呰櫄鎷熻澶囩殑鏃跺�欙紝鏄惁娣诲姞鏍囪瘑</param>
+        /// <returns></returns>
+        public string GetDeviceObjectText(List<CommonDevice> listDevice, bool ApendFalge = true)
+        {
+            CommonDevice checkDevice = listDevice[0];
+            foreach (var temp in listDevice)
+            {
+                //鎷挎嫢鏈夋ā鍧桰D鐨勯偅涓洖璺潵鍒ゆ柇
+                if (temp.ModelIdentifier != string.Empty)
+                {
+                    checkDevice = temp;
+                }
+            }
+            //鑾峰彇鑷畾涔夎澶囩被鍨�
+            var myInfoType = this.GetMyDeviceEnumInfo(listDevice);
+            //鑾峰彇璁惧绫诲瀷鐨勭炕璇戝悕瀛�
+            string strName = myInfoType.ObjectTypeName;
+            if (strName == string.Empty)
+            {
+                //鍔犱竴灞備繚闄�,鏈煡璁惧
+                strName = Language.StringByID(R.MyInternationalizationString.UnknowDevice);
+            }
+
+            if (ApendFalge == true)
+            {
+                if (listDevice[0].DriveCode > 0)
+                {
+                    //铏氭嫙璁惧鍔犱釜鏍囪瘑
+                    strName += "鉁�";
+                }
+                else
+                {
+                    foreach (var temp in listDevice)
+                    {
+                        //鎷挎嫢鏈夋ā鍧桰D鐨勯偅涓洖璺潵鍒ゆ柇
+                        if (temp.ModelIdentifier != string.Empty)
+                        {
+                            if (this.IsHdlDevice(checkDevice) == false)
+                            {
+                                //绗笁鏂硅澶囧姞涓爣璇�
+                                strName += "鈽�";
+                                break;
+                            }
+                        }
+                    }
+                }
+            }
+            return strName;
+        }
+
+        #endregion
+
+        #region 鈻� 鑾峰彇娌充笢璁惧鐨勮澶囩被鍨媉____________
+
+        /// <summary>
+        /// 鑾峰彇Hdl璁惧鐨勩�愯嚜瀹氫箟鐨勮澶囩被鍨嬨��
+        /// </summary>
+        /// <param name="device">闅忎究鏌愪竴鍥炶矾</param>
+        /// <returns></returns>
+        private DeviceEnumInfo GetHdlMyDeviceEnumInfo(CommonDevice device)
+        {
+            //璁惧鍏蜂綋绫诲瀷
+            var info = new DeviceEnumInfo();
+            info.IsHdlDevice = this.IsHdlDevice(device);
+            if (device.ModelIdentifier == string.Empty)
+            {
+                return null;
+            }
+            string modelKeys = device.ModelIdentifier;
+            //浜ゆ崲涓�涓嬫ā鍧桰D(楹︿箰鍏嬮偅杈圭殑浼犳劅鍣�)
+            this.ChangedDeviceModeId(ref modelKeys);
+
+            if (this.dicDeviceModelIdEnum.ContainsKey(modelKeys) == false)
+            {
+                //娌℃湁鍖归厤鍒版ā鍧桰D锛屽垯鐩存帴璧扮涓夋柟璁惧鐨勫垽鏂�
+                return null;
+            }
+
+            var nameContent = this.dicDeviceModelIdEnum[modelKeys];
+            //璁剧疆璁惧鐨勩�愯澶囨墍灞炵被鍨嬨��
+            info.BeloneType = (DeviceBeloneType)nameContent.BeloneTypeValue;
+            info.BeloneText = nameContent.A鎵�灞炲悕瀛�;
+
+            //璁惧鍏蜂綋绫诲瀷
+            info.ConcreteType = (DeviceConcreteType)nameContent.ConcreteTypeValue;
+            if (info.ConcreteType.ToString() == nameContent.ConcreteTypeValue.ToString())
+            {
+                info.ConcreteType = DeviceConcreteType.UnKownDevice;
+            }
+            //璁惧鐨勫畼鏂瑰悕绉�
+            info.ConcreteText = nameContent.A瀹樻柟鍚嶅瓧;
+
+            //璁惧鐨勭被鍨嬬炕璇戝悕绉�
+            info.ObjectTypeName = nameContent.A绫诲瀷鍚嶅瓧;
+
+            //璁惧榛樿鍚嶅瓧
+            info.DeviceDefultName = nameContent.A澶囨敞鍚嶅瓧;
+
+            return info;
+        }
+
+        #endregion
+
+        #region 鈻� 鑾峰彇绗笁鏂硅澶囩殑璁惧绫诲瀷___________
+
+        /// <summary>
+        /// 鑾峰彇璁惧鐨勩�愭墍灞炵被鍨嬩俊鎭��,姝ゆ柟娉曚細鎶婃墍鏈夌殑浼犳劅鍣ㄩ兘褰掍负銆愪紶鎰熷櫒銆�(鍖呮嫭娓╂箍搴︿紶鎰熷櫒)
+        /// </summary>
+        /// <param name="device">璁惧鍥炶矾</param>
+        /// <returns></returns>
+        public DeviceEnumInfo GetDeviceBelongEnumInfo(CommonDevice device)
+        {
+            var info = this.GetNotHdlMyDeviceEnumInfo(new List<CommonDevice>() { device });
+            if (info.BeloneType == DeviceBeloneType.A璋冨厜鍣�
+                || info.BeloneType == DeviceBeloneType.A褰╃伅)
+            {
+                //褰掍负鐏厜
+                info.ConcreteType = DeviceConcreteType.Light;
+                info.ConcreteText = this.dicDeviceModelIdEnum["A418"].A瀹樻柟鍚嶅瓧;
+                info.BeloneType = DeviceBeloneType.A鐏厜;
+                info.BeloneText = this.dicDeviceModelIdEnum["A418"].A瀹樻柟鍚嶅瓧;
+                info.ObjectTypeName = this.dicDeviceModelIdEnum["A418"].A绫诲瀷鍚嶅瓧;//璋冨厜妯″潡
+            }
+            else if (info.BeloneType == DeviceBeloneType.A浼犳劅鍣�
+                || device.Type == DeviceType.TemperatureSensor
+                || device.Type == DeviceType.FreshAirHumiditySensor)
+            {
+                //浼犳劅鍣ㄥ悎骞�
+                info.ConcreteType = DeviceConcreteType.Sensor;
+                info.ConcreteText = this.dicDeviceModelIdEnum["A402"].A瀹樻柟鍚嶅瓧;
+                info.BeloneType = DeviceBeloneType.A浼犳劅鍣�;
+                info.BeloneText = this.dicDeviceModelIdEnum["A402"].A瀹樻柟鍚嶅瓧;
+                info.ObjectTypeName = this.dicDeviceModelIdEnum["A402"].A绫诲瀷鍚嶅瓧;//浼犳劅鍣�
+            }
+
+            return info;
+        }
+
+        /// <summary>
+        /// 鑾峰彇绗笁鏂硅澶囩殑銆愯澶囩被鍨嬨��(涓嶅缓璁娇鐢�)
+        /// </summary>
+        /// <param name="listdevice">Mac閮戒竴鏍风殑璁惧鍒楄〃</param>
+        /// <returns></returns>
+        public DeviceEnumInfo GetNotHdlMyDeviceEnumInfo(List<CommonDevice> listdevice)
+        {
+            var dicType = new Dictionary<DeviceType, CommonDevice>();
+            foreach (CommonDevice device in listdevice)
+            {
+                if (dicType.ContainsKey(device.Type) == false)
+                {
+                    dicType[device.Type] = device;
+                }
+            }
+            var info = new DeviceEnumInfo();
+            info.IsHdlDevice = false;
+            //1鍖呭惈闈㈡澘鐨勮瘽,褰撻潰鏉垮鐞�
+            if (dicType.ContainsKey(DeviceType.OnOffSwitch) == true)
+            {
+                if (listdevice.Count > 1)
+                {
+                    info.ConcreteText = this.dicDeviceModelIdEnum["A401"].A瀹樻柟鍚嶅瓧;
+                    info.BeloneType = DeviceBeloneType.A鎸夐敭闈㈡澘;
+                    info.ConcreteType = DeviceConcreteType.ButtonPanel;
+                }
+                else
+                {
+                    info.ConcreteText = this.dicDeviceModelIdEnum["A419"].A瀹樻柟鍚嶅瓧;
+                    info.BeloneType = DeviceBeloneType.A骞叉帴鐐�;
+                    info.ConcreteType = DeviceConcreteType.DryContact;
+                }
+                info.ObjectTypeName = this.dicDeviceModelIdEnum["A401"].A绫诲瀷鍚嶅瓧;//鏅鸿兘闈㈡澘
+            }
+            //3鍖呭惈绐楀笜鐨勮瘽,褰撶獥甯樺鐞�
+            else if (dicType.ContainsKey(DeviceType.WindowCoveringDevice) == true)
+            {
+                info.ConcreteText = this.dicDeviceModelIdEnum["A400"].A瀹樻柟鍚嶅瓧;
+                info.BeloneType = DeviceBeloneType.A绐楀笜;
+                info.ConcreteType = DeviceConcreteType.Curtain;
+                info.ObjectTypeName = this.dicDeviceModelIdEnum["A400"].A绫诲瀷鍚嶅瓧;//閬槼妯″潡
+            }
+            //4绌烘皵寮�鍏�
+            else if (dicType.ContainsKey(DeviceType.AirSwitch) == true)
+            {
+                //榛樿鍊�
+                info.ConcreteText = this.dicDeviceModelIdEnum["A408"].A瀹樻柟鍚嶅瓧;
+                info.BeloneType = DeviceBeloneType.A寮�鍏�;
+                info.ConcreteType = DeviceConcreteType.AirSwitch;
+                info.ObjectTypeName = this.dicDeviceModelIdEnum["A408"].A绫诲瀷鍚嶅瓧;//寮�鍏虫ā鍧�
+
+                if (dicType[DeviceType.AirSwitch].DfunctionType == DeviceFunctionType.A寮�鍏�)
+                {
+                    info.ConcreteText = this.dicDeviceModelIdEnum["A416"].A瀹樻柟鍚嶅瓧;
+                    info.BeloneType = DeviceBeloneType.A寮�鍏�;
+                    info.ConcreteType = DeviceConcreteType.Switch;
+                }
+                else if (dicType[DeviceType.AirSwitch].DfunctionType == DeviceFunctionType.A鎻掑骇)
+                {
+                    info.ConcreteText = this.dicDeviceModelIdEnum["A417"].A瀹樻柟鍚嶅瓧;
+                    info.BeloneType = DeviceBeloneType.A鎻掑骇;
+                    info.ConcreteType = DeviceConcreteType.Socket1;
+                }
+                else if (dicType[DeviceType.AirSwitch].DfunctionType == DeviceFunctionType.A鐏厜)
+                {
+                    info.ConcreteText = this.dicDeviceModelIdEnum["A418"].A瀹樻柟鍚嶅瓧;
+                    info.BeloneType = DeviceBeloneType.A鐏厜;
+                    info.ConcreteType = DeviceConcreteType.Light;
+                }
+            }
+            //5缁х數鍣�
+            else if (dicType.ContainsKey(DeviceType.OnOffOutput) == true)
+            {
+                //榛樿鍊�
+                info.ConcreteText = this.dicDeviceModelIdEnum["A403"].A瀹樻柟鍚嶅瓧;
+                info.BeloneType = DeviceBeloneType.A缁х數鍣�;
+                info.ConcreteType = DeviceConcreteType.Relay;
+                info.ObjectTypeName = this.dicDeviceModelIdEnum["A403"].A绫诲瀷鍚嶅瓧;//寮�鍏虫ā鍧�
+
+                if (dicType[DeviceType.OnOffOutput].DfunctionType == DeviceFunctionType.A寮�鍏�)
+                {
+                    info.ConcreteText = this.dicDeviceModelIdEnum["A416"].A瀹樻柟鍚嶅瓧;
+                    info.BeloneType = DeviceBeloneType.A寮�鍏�;
+                    info.ConcreteType = DeviceConcreteType.Switch;
+                }
+                else if (dicType[DeviceType.OnOffOutput].DfunctionType == DeviceFunctionType.A鎻掑骇)
+                {
+                    info.ConcreteText = this.dicDeviceModelIdEnum["A417"].A瀹樻柟鍚嶅瓧;
+                    info.BeloneType = DeviceBeloneType.A鎻掑骇;
+                    info.ConcreteType = DeviceConcreteType.Socket1;
+                }
+                else if (dicType[DeviceType.OnOffOutput].DfunctionType == DeviceFunctionType.A鐏厜)
+                {
+                    info.ConcreteText = this.dicDeviceModelIdEnum["A418"].A瀹樻柟鍚嶅瓧;
+                    info.BeloneType = DeviceBeloneType.A鐏厜;
+                    info.ConcreteType = DeviceConcreteType.Light;
+                }
+            }
+            //6璋冨厜鍣�
+            else if (dicType.ContainsKey(DeviceType.DimmableLight) == true)
+            {
+                info.ConcreteText = this.dicDeviceModelIdEnum["A404"].A瀹樻柟鍚嶅瓧;
+                info.BeloneType = DeviceBeloneType.A璋冨厜鍣�;
+                info.ConcreteType = DeviceConcreteType.DimmableLight;
+                info.ObjectTypeName = this.dicDeviceModelIdEnum["A404"].A绫诲瀷鍚嶅瓧;//璋冨厜妯″潡
+            }
+            //7褰╃伅
+            else if (dicType.ContainsKey(DeviceType.ColorDimmableLight) == true)
+            {
+                info.ConcreteText = this.dicDeviceModelIdEnum["A410"].A瀹樻柟鍚嶅瓧;
+                info.BeloneType = DeviceBeloneType.A褰╃伅;
+                info.ConcreteType = DeviceConcreteType.ColorLight;
+                info.ObjectTypeName = this.dicDeviceModelIdEnum["A410"].A绫诲瀷鍚嶅瓧;//璋冨厜妯″潡
+            }
+            //8绌鸿皟
+            else if (dicType.ContainsKey(DeviceType.Thermostat) == true)
+            {
+                info.ConcreteText = this.dicDeviceModelIdEnum["A406"].A瀹樻柟鍚嶅瓧;
+                info.BeloneType = DeviceBeloneType.A绌鸿皟;
+                info.ConcreteType = DeviceConcreteType.AirConditioner;
+                info.ObjectTypeName = this.dicDeviceModelIdEnum["A406"].A绫诲瀷鍚嶅瓧;//绌鸿皟妯″潡
+            }
+            //9涓户鍣�
+            else if (dicType.ContainsKey(DeviceType.Repeater) == true)
+            {
+                info.ConcreteText = this.dicDeviceModelIdEnum["A407"].A瀹樻柟鍚嶅瓧;
+                info.BeloneType = DeviceBeloneType.A涓户鍣�;
+                info.ConcreteType = DeviceConcreteType.Repeater;
+                info.ObjectTypeName = this.dicDeviceModelIdEnum["A407"].A绫诲瀷鍚嶅瓧;//绯荤粺璁惧
+            }
+            //10杞崲鍣�
+            else if (dicType.ContainsKey(DeviceType.Transverter) == true)
+            {
+                info.ConcreteText = this.dicDeviceModelIdEnum["A409"].A瀹樻柟鍚嶅瓧;
+                info.BeloneType = DeviceBeloneType.A杞崲鍣�;
+                info.ConcreteType = DeviceConcreteType.Converter;
+                info.ObjectTypeName = this.dicDeviceModelIdEnum["A409"].A绫诲瀷鍚嶅瓧;//杞崲鍣�
+            }
+            //11鏅鸿兘闂ㄩ攣
+            else if (dicType.ContainsKey(DeviceType.DoorLock) == true)
+            {
+                info.ConcreteText = this.dicDeviceModelIdEnum["A405"].A瀹樻柟鍚嶅瓧;
+                info.BeloneType = DeviceBeloneType.A鏅鸿兘闂ㄩ攣;
+                info.ConcreteType = DeviceConcreteType.IntelligentLocks;
+                info.ObjectTypeName = this.dicDeviceModelIdEnum["A405"].A绫诲瀷鍚嶅瓧;//鏅鸿兘闂ㄩ攣
+            }
+            //12鍖呭惈浼犳劅鍣ㄧ殑璇�,褰撲紶鎰熷櫒澶勭悊
+            else if (dicType.ContainsKey(DeviceType.IASZone) == true)
+            {
+                info.BeloneType = DeviceBeloneType.A浼犳劅鍣�;
+                info.ConcreteType = DeviceConcreteType.Sensor;
+                info.ConcreteText = this.dicDeviceModelIdEnum["A402"].A瀹樻柟鍚嶅瓧;
+                info.ObjectTypeName = this.dicDeviceModelIdEnum["A402"].A绫诲瀷鍚嶅瓧;//浼犳劅鍣�
+                //璁剧疆浼犳劅鍣ㄥ叿浣撶殑绫诲瀷
+                this.SetSensorDeviceSpecificType(ref info, listdevice);
+            }
+            //13鍖呭惈娓╁害浼犳劅鍣ㄧ殑璇�
+            else if (dicType.ContainsKey(DeviceType.TemperatureSensor) == true)
+            {
+                bool temperatrue = false;
+                bool humidity = false;
+                bool airQualitySensor = false;
+                //鑾峰彇鍏ㄩ儴鐨勫洖璺�
+                var listTemp = this.GetDevicesByMac(listdevice[0].DeviceAddr, false);
+                foreach (var device in listTemp)
+                {
+                    if (device is TemperatureSensor)
+                    {
+                        //绌烘皵璐ㄩ噺浼犳劅鍣�
+                        if (device.isAirQualitySensor(device))
+                        {
+                            airQualitySensor = true;
+                        }
+                        //娓╁害浼犳劅鍣�
+                        if (((TemperatureSensor)device).SensorDiv == 1)
+                        {
+                            temperatrue = true;
+                        }
+                        //婀垮害浼犳劅鍣�
+                        else if (((TemperatureSensor)device).SensorDiv == 2)
+                        {
+                            humidity = true;
+                        }
+                    }
+                }
+                if (temperatrue == true && humidity == true)
+                {
+                    //璁剧疆浼犳劅鍣ㄥ叿浣撶殑绫诲瀷
+                    info.BeloneType = DeviceBeloneType.A娓╂箍搴︿紶鎰熷櫒;
+                    info.ConcreteText = this.dicDeviceModelIdEnum["A411"].A瀹樻柟鍚嶅瓧;
+                    info.ConcreteType = DeviceConcreteType.Sensor_TemperatureHumidity;
+                }
+                else if (temperatrue == true && humidity == false)
+                {
+                    //璁剧疆浼犳劅鍣ㄥ叿浣撶殑绫诲瀷
+                    info.BeloneType = DeviceBeloneType.A娓╁害浼犳劅鍣�;
+                    info.ConcreteText = this.dicDeviceModelIdEnum["A412"].A瀹樻柟鍚嶅瓧;
+                    info.ConcreteType = DeviceConcreteType.Sensor_Temperature;
+                }
+                else if (temperatrue == false && humidity == true)
+                {
+                    //璁剧疆浼犳劅鍣ㄥ叿浣撶殑绫诲瀷
+                    info.BeloneType = DeviceBeloneType.A婀垮害浼犳劅鍣�;
+                    info.ConcreteText = this.dicDeviceModelIdEnum["A413"].A瀹樻柟鍚嶅瓧;
+                    info.ConcreteType = DeviceConcreteType.Sensor_Humidity;
+                }
+                info.ObjectTypeName = this.dicDeviceModelIdEnum["A411"].A绫诲瀷鍚嶅瓧;//浼犳劅鍣�
+
+                //绌烘皵璐ㄩ噺浼犳劅鍣�
+                if (airQualitySensor == true)
+                {
+                    info.ConcreteText = this.dicDeviceModelIdEnum["A422"].A瀹樻柟鍚嶅瓧;
+                    info.BeloneType = DeviceBeloneType.A绌烘皵璐ㄩ噺;
+                    info.ConcreteType = DeviceConcreteType.AirQualitySensor;
+                    info.ObjectTypeName = this.dicDeviceModelIdEnum["A422"].A绫诲瀷鍚嶅瓧;
+                }
+            }
+            //14鏂伴璁惧
+            else if (dicType.ContainsKey(DeviceType.FreshAir) == true)
+            {
+                info.ConcreteText = this.dicDeviceModelIdEnum["A414"].A瀹樻柟鍚嶅瓧;
+                info.BeloneType = DeviceBeloneType.A鏂伴;
+                info.ConcreteType = DeviceConcreteType.Relay_FangyueFreshAirModul;
+                info.ObjectTypeName = this.dicDeviceModelIdEnum["A414"].A绫诲瀷鍚嶅瓧;//鏂伴
+            }
+            //15 PM2.5浼犳劅鍣ㄨ澶�
+            else if (dicType.ContainsKey(DeviceType.PMSensor) == true)
+            {
+                info.ConcreteText = this.dicDeviceModelIdEnum["A415"].A瀹樻柟鍚嶅瓧;
+                info.BeloneType = DeviceBeloneType.APM2鐐�5绌烘皵璐ㄩ噺浼犳劅鍣�;
+                info.ConcreteType = DeviceConcreteType.Sensor_PMTwoPointFive;
+                info.ObjectTypeName = this.dicDeviceModelIdEnum["A415"].A绫诲瀷鍚嶅瓧;//浼犳劅鍣�
+            }
+            //16鑹叉俯鐏�
+            else if (dicType.ContainsKey(DeviceType.ColorTemperatureLight) == true)
+            {
+                info.ConcreteText = this.dicDeviceModelIdEnum["A420"].A瀹樻柟鍚嶅瓧;
+                info.BeloneType = DeviceBeloneType.A褰╃伅;
+                info.ConcreteType = DeviceConcreteType.ColorLight_Temperature;
+                info.ObjectTypeName = this.dicDeviceModelIdEnum["A420"].A绫诲瀷鍚嶅瓧;//璋冨厜妯″潡
+            }
+            //17鏅捐。鏋�
+            else if (dicType.ContainsKey(DeviceType.Airer) == true)
+            {
+                info.ConcreteText = this.dicDeviceModelIdEnum["A421"].A瀹樻柟鍚嶅瓧;
+                info.BeloneType = DeviceBeloneType.A鏅捐。鏋�;
+                info.ConcreteType = DeviceConcreteType.Airer;
+                info.ObjectTypeName = this.dicDeviceModelIdEnum["A421"].A绫诲瀷鍚嶅瓧;
+            }
+
+            //璁惧鎵�灞炵被鍨嬬殑缈昏瘧鍚嶅瓧
+            info.BeloneText = info.ConcreteText;
+            info.DeviceDefultName = info.ConcreteText;
+
+            return info;
+        }
+
+        #endregion
+
+        #region 鈻� 浼犳劅鍣ㄥ叿浣撶殑绫诲瀷___________________
+
+        /// <summary>
+        /// 璁剧疆浼犳劅鍣ㄥ叿浣撶殑绫诲瀷
+        /// </summary>
+        /// <param name="info">鑷畾涔夎澶囨灇涓句俊鎭�</param>
+        /// <param name="listdevice">璁惧瀵硅薄</param>
+        private void SetSensorDeviceSpecificType(ref DeviceEnumInfo info, List<CommonDevice> listdevice)
+        {
+            //濡傛灉杩欎釜璁惧鎷ユ湁澶氫釜鍥炶矾鐨勮瘽,鎴戜篃涓嶇煡閬撴�庝箞鍛藉悕,鍙兘缁欎釜榛樿鍚嶅瓧
+            if (listdevice.Count > 1)
+            {
+                return;
+            }
+            var iasZone = (IASZone)listdevice[0];
+            if (iasZone.IasDeviceType == 13)
+            {
+                //杩愬姩浼犳劅鍣�
+                info.ConcreteType = DeviceConcreteType.Sensor_Motion;
+                info.ConcreteText = Language.StringByID(R.MyInternationalizationString.uMotionSensor);
+            }
+            else if (iasZone.IasDeviceType == 40)
+            {
+                //鐑熼浘浼犳劅鍣�
+                info.ConcreteType = DeviceConcreteType.Sensor_Fire;
+                info.ConcreteText = Language.StringByID(R.MyInternationalizationString.uSensorFire);
+            }
+            else if (iasZone.IasDeviceType == 42)
+            {
+                //姘翠镜浼犳劅鍣�
+                info.ConcreteType = DeviceConcreteType.Sensor_Water;
+                info.ConcreteText = Language.StringByID(R.MyInternationalizationString.uSensorWater);
+            }
+            else if (iasZone.IasDeviceType == 43)
+            {
+                //鐕冩皵浼犳劅鍣�
+                info.ConcreteType = DeviceConcreteType.Sensor_CarbonMonoxide;
+                info.ConcreteText = Language.StringByID(R.MyInternationalizationString.uSensorCarbonMonoxide);
+            }
+            else if (iasZone.IasDeviceType == 44)
+            {
+                //绱ф�ユ寜閽�
+                info.ConcreteType = DeviceConcreteType.Sensor_EmergencyButton;
+                info.ConcreteText = Language.StringByID(R.MyInternationalizationString.uSensorEmergencyButton);
+            }
+            else if (iasZone.IasDeviceType == 277)
+            {
+                //閽ュ寵鎵�
+                info.ConcreteType = DeviceConcreteType.Sensor_Keyfob;
+                info.ConcreteText = Language.StringByID(R.MyInternationalizationString.uKeyfob);
+            }
+            else if (iasZone.IasDeviceType == 21 || iasZone.IasDeviceType == 22)
+            {
+                //闂ㄧ獥浼犳劅鍣�
+                info.ConcreteType = DeviceConcreteType.Sensor_DoorWindow;
+                info.ConcreteText = Language.StringByID(R.MyInternationalizationString.uSensorDoorWindow);
+            }
+        }
+
+        #endregion
+
+        #region 鈻� 璁惧鎺掑簭___________________________
+
+        /// <summary>
+        /// 璁惧鎺掑簭
+        /// </summary>
+        /// <param name="i_listDevice">璇风‘淇濊繖涓笢瑗垮凡缁忔寜mac鍜岀鐐规帓搴忎簡</param>
+        /// <returns></returns>
+        public List<CommonDevice> SortDeviceByBelongType(List<CommonDevice> i_listDevice)
+        {
+            //鑾峰彇鎺掑簭瑙勫垯
+            var listRule = this.GetBelongTypeSortRule();
+            var dicDevice = new Dictionary<DeviceBeloneType, List<CommonDevice>>();
+            dicDevice[DeviceBeloneType.A鏈煡璁惧] = new List<CommonDevice>();
+
+            foreach (var device in i_listDevice)
+            {
+                //鑾峰彇鎵�灞炵被鍨�
+                var typeInfo = this.GetDeviceBelongEnumInfo(device);
+                if (listRule.Contains(typeInfo.BeloneType) == false)
+                {
+                    //涓嶅湪鎺掑簭鑼冨洿鍐�,閮戒涪鍦ㄦ渶鍚庨潰
+                    dicDevice[DeviceBeloneType.A鏈煡璁惧].Add(device);
+                    continue;
+                }
+                if (dicDevice.ContainsKey(typeInfo.BeloneType) == false)
+                {
+                    dicDevice[typeInfo.BeloneType] = new List<CommonDevice>();
+                }
+                dicDevice[typeInfo.BeloneType].Add(device);
+            }
+
+            var listSort = new List<CommonDevice>();
+            foreach (var myType in listRule)
+            {
+                //鏍规嵁瑙勫垯椤哄簭,娣诲姞璁惧
+                if (dicDevice.ContainsKey(myType) == false || dicDevice[myType].Count == 0)
+                {
+                    continue;
+                }
+                listSort.AddRange(dicDevice[myType]);
+            }
+
+            return listSort;
+        }
+
+        /// <summary>
+        /// 鑾峰彇璁惧鎵�灞炵被鍨嬬殑鐨勬帓搴忚鍒�
+        /// </summary>
+        /// <returns></returns>
+        public HashSet<DeviceBeloneType> GetBelongTypeSortRule()
+        {
+            //璋佸湪鍓嶉潰,璋佸氨浼樺厛鏄剧ず
+            var list = new HashSet<DeviceBeloneType>();
+            list.Add(DeviceBeloneType.A鐏厜);
+            list.Add(DeviceBeloneType.A褰╃伅);
+            list.Add(DeviceBeloneType.A寮�鍏�);
+            list.Add(DeviceBeloneType.A鎻掑骇);
+            list.Add(DeviceBeloneType.A璋冨厜鍣�);
+            list.Add(DeviceBeloneType.A绐楀笜);
+            list.Add(DeviceBeloneType.A鏂伴);
+            list.Add(DeviceBeloneType.A绌鸿皟);
+            list.Add(DeviceBeloneType.A缁х數鍣�);
+            list.Add(DeviceBeloneType.A骞叉帴鐐�);
+            list.Add(DeviceBeloneType.A鏅鸿兘闂ㄩ攣);
+            list.Add(DeviceBeloneType.A鏅鸿兘绌哄紑);
+            list.Add(DeviceBeloneType.A浼犳劅鍣�);
+
+            //鍏朵粬鐨勭湅鐫�鍔炲憲,閮芥槸鎺掑湪鍚庨潰鐨�,閮藉綊涓鸿繖涓睘鎬�
+            list.Add(DeviceBeloneType.A鏈煡璁惧);
+
+            return list;
+        }
+
+        #endregion
+
+        #region 鈻� 鏅捐。鏋惰澶囨椂闂撮厤缃甠__________________________
+        /// <summary>
+        ///  璁剧疆鏅捐。鏋堕骞诧紝鐑樺共鍜屾秷姣掓椂闂�(璁剧疆澶辫触鏃讹紝浼氭樉绀轰俊鎭�)
+        ///  time:璁剧疆鐨勫垎閽�
+        /// </summary>
+        /// <param name="litdevice">璁惧瀵硅薄(MAC鍦板潃蹇呴』瑕佺浉鍚�)</param>
+        public async Task<bool> SetAirerTimeDevice(List<CommonDevice> listdevice, Airer airer, int time, int controlEpoint)
+        {
+            //铏氭嫙浣忓畢鐨勮瘽,涓嶉渶瑕�
+            if (Config.Instance.Home.IsVirtually == false)
+            {
+                foreach (var dev in listdevice)
+                {
+                    //璁剧疆灞炴�т俊鎭�
+                    CommonDevice.SetWritableValueData dataT = new CommonDevice.SetWritableValueData();
+                    dataT.Undivided = 0;
+                    dataT.AttributeId = 16385;
+                    dataT.AttributeDataType = 33;
+                    dataT.AttributeData = time;
+                    dev.DeviceEpoint = controlEpoint;//鏆傛椂鎹㈡垚鏅捐。鏋跺搴旂殑鎺у埗绔偣
+                    var result = await dev.SetWritableValueAsync(6, dataT);
+                    if (result == null || result.setWritableValueResponData == null || result.setWritableValueResponData.Status != 0)
+                    {
+                        //璁剧疆澶辫触
+                        if (dev.DeviceEpoint == 3)
+                        {
+                            if (airer.WindTime != 0)
+                            {
+                                airer.WindTime = 0;
+                            }
+                            string msg = Language.StringByID(R.MyInternationalizationString.AirerWindTimeFailed);
+                            //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
+                            msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
+                            dev.DeviceEpoint = 1;//灏嗘櫨琛f灦瀵瑰簲鐨勬帶鍒剁鐐硅繕鍘熸垚1绔偣
+                            this.ShowErrorMsg(msg);
+                            return false;
+                        }
+                        if (dev.DeviceEpoint == 4)
+                        {
+                            if (airer.DryTime != 0)
+                            {
+                                airer.DryTime = 0;
+                            }
+                            string msg = Language.StringByID(R.MyInternationalizationString.AirerDryTimeFailed);
+                            //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
+                            msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
+                            dev.DeviceEpoint = 1;//灏嗘櫨琛f灦瀵瑰簲鐨勬帶鍒剁鐐硅繕鍘熸垚1绔偣
+                            this.ShowErrorMsg(msg);
+                            return false;
+                        }
+                        if (dev.DeviceEpoint == 5)
+                        {
+                            if (airer.DisinfectTime != 0)
+                            {
+                                airer.DisinfectTime = 0;
+                            }
+                            string msg = Language.StringByID(R.MyInternationalizationString.AirerDisinfectTimeFailed);
+                            //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
+                            msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
+                            this.ShowErrorMsg(msg);
+                            dev.DeviceEpoint = 1;//灏嗘櫨琛f灦瀵瑰簲鐨勬帶鍒剁鐐硅繕鍘熸垚1绔偣
+                            return false;
+                        }
+                    }
+                }
+            }
+            return true;
+        }
+        #endregion
+
+        #region 鈻� 涓�鑸柟娉昣__________________________
+
+        /// <summary>
+        /// 浠庣紦瀛樺彉閲忔娴嬭澶囨槸鍚﹀湪绾�
+        /// </summary>
+        /// <param name="i_device"></param>
+        /// <param name="checkAll">鏄惁妫�娴嬪叏閮ㄥ洖璺�</param>
+        /// <returns></returns>
+        public bool CheckDeviceIsOnline(CommonDevice i_device, bool checkAll = true)
+        {
+            if (checkAll == false)
+            {
+                //涓嶆娴嬪叏閮ㄥ洖璺�
+                return i_device.IsOnline == 1 || i_device.IsOnline == 2;
+            }
+            var listDevice = this.GetDevicesByMac(i_device.DeviceAddr, false);
+            foreach (var device in listDevice)
+            {
+                //0:绂荤嚎 1:鍦ㄧ嚎 2:姝e湪鍒锋柊鐘舵�� 
+                bool statu = i_device.IsOnline == 1 || i_device.IsOnline == 2;
+                if (statu == true)
+                {
+                    //鏈変竴涓洖璺湪绾�,鍗冲湪绾�
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        /// <summary>
+        /// 鍒ゆ柇璇ヨ澶囨槸鍚﹀彲浠ユ樉绀哄湪涓婚〉
+        /// </summary>
+        /// <param name="i_device"></param>
+        /// <returns></returns>
+        public bool CanShowInHomeHomeMainPage(CommonDevice i_device)
+        {
+            if (i_device == null || i_device.Type == DeviceType.OnOffSwitch)//骞叉帴鐐�
+            {
+                //杩欎釜璁惧涓嶈浜�
+                return false;
+            }
+            if (i_device.Type == DeviceType.OnOffOutput || i_device.Type == DeviceType.AirSwitch)
+            {
+                //2020.03.23杩藉姞寮忔牱:鏈寚瀹氱被鍨嬬殑缁х數鍣�,涓嶆樉绀�
+                if (i_device.DfunctionType == DeviceFunctionType.A鏈畾涔�
+                    || i_device.DfunctionType == DeviceFunctionType.A涓嶆寚瀹�)
+                {
+                    return false;
+                }
+            }
+            //2020.03.30杩藉姞寮忔牱:濡傛灉鏄潰鏉跨殑娓╁害鎺㈠ご,涓嶆樉绀�
+            else if (i_device.Type == DeviceType.TemperatureSensor && ((TemperatureSensor)i_device).SensorDiv == 1)
+            {
+                var myInfoType = LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { i_device });
+                if (myInfoType.BeloneType == DeviceBeloneType.A鎸夐敭闈㈡澘)
+                {
+                    return false;
+                }
+            }
+            else if (i_device.Type == DeviceType.FreshAirHumiditySensor)
+            {
+                //鏂伴鐨勬箍搴︿紶鎰熷櫒涓嶆樉绀�
+                return false;
+            }
+            if (((int)i_device.Type).ToString() == i_device.Type.ToString())
+            {
+                //姝よ澶噄d鍦―eviceType閲岄潰杩樻病鏈夋敞鍐�,鍒欎笉鑳芥樉绀哄嚭鏉�
+                return false;
+            }
+
+            //濡傛灉鏄柊椋庨潰鏉挎垨鐜闈㈡澘,鍒欓兘涓嶆樉绀轰换浣曞洖璺�
+            var myInfoTypeTemp = LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { i_device });
+            if (myInfoTypeTemp.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir || myInfoTypeTemp.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleEnvironment)
+            {
+                return false;
+            }
+            else if (myInfoTypeTemp.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleMultifunction)
+            {
+                if (i_device.Type != DeviceType.OnOffOutput)
+                {
+                    return false;
+                }
+            }
+            return true;
+        }
+
+        /// <summary>
+        /// 鍒ゆ柇鏄笉鏄渤涓滅殑璁惧
+        /// </summary>
+        /// <param name="device"></param>
+        /// <returns></returns>
+        public bool IsHdlDevice(CommonDevice device)
+        {
+            return device.ManufacturerName == "HDL";
+        }
+
+        /// <summary>
+        /// 鏄惁鏄疢ini澶滅伅
+        /// </summary>
+        /// <param name="device"></param>
+        /// <returns></returns>
+        public bool IsMiniLight(CommonDevice device)
+        {
+            return device.DriveCode != 0 && device.Type == DeviceType.ColorTemperatureLight;
+        }
+
+        /// <summary>
+        /// 鑾峰彇璁惧鐨勫敮涓�涓婚敭
+        /// </summary>
+        /// <param name="device"></param>
+        /// <returns></returns>
+        public string GetDeviceMainKeys(CommonDevice device)
+        {
+            return this.GetDeviceMainKeys(device.DeviceAddr, device.DeviceEpoint);
+        }
+
+        /// <summary>
+        /// 鑾峰彇璁惧鐨勫敮涓�涓婚敭
+        /// </summary>
+        /// <param name="DeviceAddr">MAC鍦板潃</param>
+        /// <param name="DeviceEpoint">绔彛鍙�</param>
+        /// <returns></returns>
+        public string GetDeviceMainKeys(string DeviceAddr, int DeviceEpoint)
+        {
+            return DeviceAddr + "_" + DeviceEpoint;
+        }
+
+        /// <summary>
+        /// 浜ゆ崲璁惧鐨勬ā鍧桰D
+        /// </summary>
+        /// <param name="modeId">妯″潡ID</param>
+        /// <returns></returns>
+        public bool ChangedDeviceModeId(ref string modeId)
+        {
+            if (this.dicDeviceModelIdChanged.ContainsKey(modeId) == false)
+            {
+                return false;
+            }
+            modeId = this.dicDeviceModelIdChanged[modeId];
+
+            return true;
+        }
+
+        /// <summary>
+        /// 鑾峰彇妯″潡ID鎵�鎸囧悜鐨勫悇绉嶅悕瀛椾俊鎭�
+        /// </summary>
+        /// <param name="strKey"></param>
+        /// <returns></returns>
+        public DeviceNameContent GetDeviceModelIdNameInfo(string strKey)
+        {
+            if (this.dicDeviceModelIdEnum.ContainsKey(strKey) == false)
+            {
+                return new DeviceNameContent();
+            }
+            return this.dicDeviceModelIdEnum[strKey];
+        }
+
+        /// <summary>
+        /// 闄勫姞璁惧鐨勭増鏈唬鍙�(杩斿洖Ver.XXX)
+        /// </summary>
+        /// <param name="versionValue">鐗堟湰鍙�</param>
+        /// <returns></returns>
+        public string AppendVersion(int versionValue)
+        {
+            //10101 3涓猙yte  鏄剧ず涓猴細ver.1.01.01
+            //涓棿閭d釜byte涓哄鏁版椂锛屼唬琛ㄦ槸娴嬭瘯鐗堟湰,鍦ㄦ樉绀烘渶鏂扮増鏈椂,涓嶉渶瑕佹樉绀猴紝浣嗘槸鍦ㄥ巻鍙茬増鏈偅閲屽彲浠ユ樉绀�
+            //涓棿閭d釜byte涓哄伓鏁版椂, 浠h〃鏄寮忕増鏈�
+
+            //鐩存帴鏄�10杩涘埗
+            string txt10 = Convert.ToString(versionValue).PadLeft(6, '0');
+            //杩欎釜鏄涓�浣�
+            int value1 = Convert.ToInt32(txt10.Substring(0, 2));
+            //杩欎釜鏄浜屼綅
+            string value2 = txt10.Substring(2, 2);
+            //杩欎釜鏄涓変綅
+            string value3 = txt10.Substring(4, 2);
+
+            //Ver.
+            string ver = Language.StringByID(R.MyInternationalizationString.uVersionAbbreviation);
+            return ver + value1 + "." + value2 + "." + value3;
+        }
+
+        /// <summary>
+        /// 鏄剧ず閿欒淇℃伅绐楀彛
+        /// </summary>
+        /// <param name="msg"></param>
+        private void ShowErrorMsg(string msg)
+        {
+            HdlThreadLogic.Current.RunMain(() =>
+            {
+                var contr = new ShowMsgControl(Phone.ShowMsgType.Error, msg);
+                contr.Show();
+            });
+        }
+
+        /// <summary>
+        /// 鏄剧ずTip淇℃伅绐楀彛
+        /// </summary>
+        /// <param name="msg"></param>
+        private void ShowTipMsg(string msg)
+        {
+            HdlThreadLogic.Current.RunMain(() =>
+            {
+                var contr = new ShowMsgControl(Phone.ShowMsgType.Tip, msg);
+                contr.Show();
+            });
+        }
+
+        /// <summary>
+        /// 澶勭悊缃戝叧杩斿洖鐨勬箍搴﹀��
+        /// </summary>
+        /// <param name="value">缃戝叧杩斿洖鐨勫睘鎬у��</param>
+        public decimal AdjustHumidityValue(int value)
+        {
+            if (value == 0)
+            {
+                //0%
+                return 0;
+            }
+            //涓嶄細鍑虹幇璐熸暟
+            else
+            {
+                //灏忔暟鐐归渶瑕佷竴浣�
+                string strValue = value.ToString();
+                strValue = strValue.Substring(0, strValue.Length - 1);
+                //璁板綍娓╁害
+                return strValue == string.Empty ? 0m : Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
+            }
+        }
+
+        /// <summary>
+        /// 澶勭悊缃戝叧杩斿洖鐨勬俯搴﹀��
+        /// </summary>
+        /// <param name="value">缃戝叧杩斿洖鐨勫睘鎬у��</param>
+        public decimal AdjustTemperatrueValue(int value)
+        {
+            if (value == 0)
+            {
+                //0鈩�
+                return 0;
+            }
+            else if (value > 32767)
+            {
+                //璐熸暟(鐗规畩澶勭悊)
+                string strValue = (value - 65536).ToString();
+                //灏忔暟鐐归渶瑕佷竴浣�
+                strValue = strValue.Substring(0, strValue.Length - 1);
+                //璁板綍娓╁害
+                return strValue == string.Empty ? 0m : Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
+            }
+            else
+            {
+                //灏忔暟鐐归渶瑕佷竴浣�
+                string strValue = value.ToString();
+                strValue = strValue.Substring(0, strValue.Length - 1);
+                //璁板綍娓╁害
+                return strValue == string.Empty ? 0m : Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
+            }
+        }
+
+        #endregion
+
+        //----------------------------------鍒嗗壊绾�(鑷畾涔夋帴鍙�)---------------------------------------------
+
+        #region 鈻� 鑾峰彇璁惧鍒楄〃鐨勬帴鍙________________
+
+        /// <summary>
+        /// <para>浠庣綉鍏抽噸鏂拌幏鍙栬澶囧垪琛�(杩斿洖鐨勮澶囦负铏氭嫙鍑烘潵鐨�),涓�娆℃�у叏閮ㄨ幏鍙�</para>
+        /// <para>statu鐘舵�� -1:寮傚父,浼氳繑鍥瀗ull, 1锛氭病鏈夊紓甯�, 2:鏁版嵁鎺ユ敹涓嶅叏</para>
+        /// </summary>
+        /// <param name="gatewayId">缃戝叧id</param>
+        /// <param name="statu">鐘舵��-> -1:寮傚父,浼氳繑鍥瀗ull, 1锛氭病鏈夊紓甯�, 2:鏁版嵁鎺ユ敹涓嶅叏</param>
+        /// <param name="useLocalConnect">鏄惁浣跨敤鏈湴杩炴帴鍙戦��</param>
+        /// <param name="mode">鏄惁鏄剧ず閿欒</param>
+        /// <returns></returns>
+        public List<CommonDevice> GetDeviceListFromGateway(string gatewayId, ref int statu, bool useLocalConnect, ShowErrorMode mode = ShowErrorMode.YES)
+        {
+            //闇�瑕佸彉鏇村姛鑳界被鍨嬬殑鍥炶矾
+            var listFucDevice = new List<CommonDevice>();
+
+            //鏄惁杈炬垚涓柇鐨勬椂鏈�
+            bool canBreak = false;
+            //瓒呮椂鏃堕棿
+            int TimeOut = 0;
+            //褰撳墠璁惧鎺ユ敹鏁�
+            int nowReceiveCount = 0;
+            //璁惧鎬绘暟
+            int deviceCount = -1;
+            //璁惧鍒楄〃
+            var listDevice = new List<CommonDevice>();
+            //缃戝叧閲岄潰鏈夊彲鑳戒細鏈夐噸澶嶇殑鍥炶矾
+            var listCheck = new HashSet<string>();
+            ///Mac鐨勭鐐规�绘暟
+            var dicMacPointCount = new Dictionary<string, int>();
+
+            HdlGatewayReceiveLogic.Current.AddGatewayReceiveEvent(gatewayId, (topic, message) =>
+            {
+                if (topic == gatewayId + "/DeviceInfoRespon")
+                {
+                    lock (listDevice)
+                    {
+                        TimeOut = 0;
+                        var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
+                        var totalNum = Convert.ToInt32(jobject["Data"]["TotalNum"].ToString());
+                        if (totalNum == 0)
+                        {
+                            //杩欎釜缃戝叧娌℃湁璁惧
+                            canBreak = true;
+                            return;
+                        }
+                        if (deviceCount == -1)
+                        {
+                            //璁剧疆闇�瑕佹帴鏀跺灏戜釜璁惧
+                            deviceCount = totalNum;
+                        }
+                        nowReceiveCount++;
+
+                        //璁惧鍥炶矾鏁版敹闆�
+                        string deviceMac = jobject.Value<string>("DeviceAddr");
+                        if (dicMacPointCount.ContainsKey(deviceMac) == false)
+                        {
+                            dicMacPointCount[deviceMac] = 0;
+                        }
+                        dicMacPointCount[deviceMac]++;
+
+                        var deviceID = (DeviceType)jobject.Value<int>("Device_ID");
+                        //鏍规嵁璁惧绫诲瀷鍒涘缓璁惧瀵硅薄鐨勫疄渚�
+                        var device = this.NewDeviceObjectByDeviceId(deviceID, jobject, gatewayId);
+                        if (device != null)
+                        {
+                            string mainkeys = this.GetDeviceMainKeys(device);
+                            //缃戝叧閲岄潰鏈夊彲鑳戒細鏈夐噸澶嶇殑鍥炶矾
+                            if (listCheck.Contains(mainkeys) == false)
+                            {
+                                listDevice.Add(device);
+                                listCheck.Add(mainkeys);
+                                //鍒锋柊涓�涓嬫湰鍦扮紦瀛�
+                                var localDevice = this.GetDevice(mainkeys);
+                                var tempDevice = localDevice == null ? device : localDevice;
+
+                                //濡傛灉杩欎釜璁惧ID鍙樻洿浜嗙殑璇�
+                                bool typeNotEquals = localDevice != null && deviceID != localDevice.Type;
+                                if (typeNotEquals == true)
+                                {
+                                    //閲嶆柊New杩欎釜瀵硅薄
+                                    typeNotEquals = this.ReNewDeviceOnTypeIsChanged(localDevice, deviceID);
+                                    //閲嶆柊鍐嶆鑾峰彇瀵硅薄
+                                    tempDevice = this.GetDevice(mainkeys);
+                                }
+
+                                //鍒锋柊灞炴��
+                                this.SetDeviceInfoToMain(tempDevice, device);
+                                if (this.RefreshDeviceFunctionType(tempDevice, device, false) == true)
+                                {
+                                    //闇�瑕佸彂閫佸姛鑳界被鍨嬬粰缃戝叧
+                                    listFucDevice.Add(tempDevice);
+                                }
+                                if (typeNotEquals == true)
+                                {
+                                    //閲嶆柊鐢熸垚缂撳瓨
+                                    tempDevice.ReSave();
+                                    HdlAutoBackupLogic.AddOrEditorFile(tempDevice.FilePath);
+                                    //鍏ㄩ儴涓婚〉鑿滃崟闇�瑕佸埛鏂�
+                                    Phone.UserView.UserPage.Instance.RefreshAllForm = true;
+                                }
+                            }
+                        }
+                    }
+
+                    if (nowReceiveCount >= deviceCount)
+                    {
+                        //璁惧鍏ㄩ儴鎺ユ敹瀹屾垚
+                        canBreak = true;
+                    }
+                }
+            });
+            //鍙戦�佸懡浠�
+            var jObject = new Newtonsoft.Json.Linq.JObject { { "Cluster_ID", 0 }, { "Command", 93 } };
+            HdlGatewayLogic.Current.SendJobjectData(gatewayId, "GetDeviceInfo", jObject.ToString(), useLocalConnect);
+
+            while (canBreak == false && TimeOut <= 30)
+            {
+                System.Threading.Thread.Sleep(100);
+                TimeOut++;
+            }
+            //绉婚櫎缃戝叧鐩戝惉浜嬩欢
+            HdlGatewayReceiveLogic.Current.RemoveGatewayReceiveEvent();
+
+            if (TimeOut > 30)
+            {
+                if (listDevice.Count > 0)
+                {
+                    //缃戠粶涓嶇ǔ瀹氾紝璁惧鍒楄〃淇℃伅缂烘崯,鍒欓噰鐢ㄦ寜搴忓彿鑾峰彇璁惧
+                    statu = this.GetDeviceListFromGatewayByMac(gatewayId, ref listDevice, ref listFucDevice, dicMacPointCount, useLocalConnect);
+                    if (statu == 2)
+                    {
+                        //缃戠粶涓嶇ǔ瀹氾紝璁惧鍒楄〃淇℃伅缂烘崯
+                        string msg = Language.StringByID(R.MyInternationalizationString.uNetworkUnStableAndDeviceInfoIsNotFull);
+                        this.ShowTipMsg(msg);
+                    }
+                }
+                else
+                {
+                    if (mode == ShowErrorMode.YES)
+                    {
+                        //鑾峰彇璁惧鍒楄〃澶辫触
+                        //[XXXX]缃戝叧鍥炲瓒呮椂,璇风◢鍚庡啀璇�
+                        string msg = Language.StringByID(R.MyInternationalizationString.uGetDeviceListFail);
+                        var localGw = HdlGatewayLogic.Current.GetLocalGateway(gatewayId);
+                        if (localGw != null)
+                        {
+                            msg += "\r\n[" + HdlGatewayLogic.Current.GetGatewayName(localGw).ToString() + "]";
+                        }
+                        msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, null, "鍥炲瓒呮椂", false);
+                        this.ShowTipMsg(msg);
+                    }
+                    statu = -1;
+                    return null;
+                }
+            }
+            else
+            {
+                statu = 1;
+            }
+            if (listFucDevice.Count > 0)
+            {
+                //濡傛灉瀛樺湪闇�瑕佸彉鏇寸殑鍔熻兘绫诲瀷
+                HdlThreadLogic.Current.RunThread(() =>
+                {
+                    for (int i = 0; i < listFucDevice.Count; i++)
+                    {
+                        this.SendDeviceFunctionTypeToGateway(listFucDevice[i], listFucDevice[i].DfunctionType);
+                        System.Threading.Thread.Sleep(100);
+                    }
+                });
+            }
+
+            return listDevice;
+        }
+
+        /// <summary>
+        /// 鏍规嵁搴忓彿鑾峰彇璁惧鍒楄〃淇℃伅(鍙湁鍦ㄨ澶囩己鎹熺殑鏃跺�欐墠璋冪敤杩欎釜鍑芥暟) 1:姝e父 2:璁惧缂烘崯
+        /// </summary>
+        /// <param name="gatewayId">缃戝叧id</param>
+        /// <param name="listDevice">瀛樺偍鐨勮澶囧璞¢泦鍚�</param>
+        /// <param name="listFucDevice">闇�瑕佸彉鏇村姛鑳界被鍨嬬殑鍥炶矾</param>
+        /// <param name="dicNowPointCount">褰撳墠宸茬粡鑾峰彇鐨凪ac鐨勭鐐规�绘暟</param>
+        /// <param name="useLocalConnect">鏄惁浣跨敤鏈湴杩炴帴鍙戦��</param>
+        /// <returns></returns>
+        public int GetDeviceListFromGatewayByMac(string gatewayId, ref List<CommonDevice> listDevice, ref List<CommonDevice> listFucDevice, Dictionary<string, int> dicNowPointCount, bool useLocalConnect)
+        {
+            //棣栧厛鍏堣幏鍙栬澶囩殑mac鍒楄〃
+            var jObject33 = new Newtonsoft.Json.Linq.JObject { { "Cluster_ID", 0 }, { "Command", 87 } };
+            var result = HdlGatewayLogic.Current.SendJobjectDataToGateway(gatewayId, "GetStatusRecord", jObject33.ToString(), "DeviceMACDeviceListRespon", 3, useLocalConnect);
+            if (result.ErrorMsgDiv == -1 || result.ErrorMsgDiv == 0)
+            {
+                //濡傛灉缃戝叧娌℃湁瀵硅繖涓富棰樺仛鍑哄洖搴旂殑璇�,鍒欒鏄庡畠鏄竴涓棫缃戝叧
+                return 2;
+            }
+            var resultMac = Newtonsoft.Json.JsonConvert.DeserializeObject<ReceiptMacResult>(result.ReceiptData);
+
+            //璁惧鍒楄〃
+            var listDeviceJson = new List<Newtonsoft.Json.Linq.JObject>();
+
+            int statu = 0;
+            foreach (var macInfo in resultMac.MACDeviceList)
+            {
+                if (dicNowPointCount.ContainsKey(macInfo.MacAddr) == true
+                    && dicNowPointCount[macInfo.MacAddr] == macInfo.EPTotalNum)
+                {
+                    //濡傛灉杩欎釜mac鐨勭鐐规暟涓�鑷�,鍒欒鏄庡凡缁忔帴鏀堕綈浜�,涓嶉渶瑕佸啀娆℃帴鏀�
+                    continue;
+                }
+                //浠庣綉鍏宠鍙栨寚瀹歁ac涓嬬殑璁惧鍒楄〃
+                var jsonData = this.ReadDeviceListByMacFromGateway(gatewayId, macInfo.MacAddr, useLocalConnect, ref statu);
+                foreach (var myData in jsonData)
+                {
+                    listDeviceJson.Add(myData);
+                }
+                if (statu != 1)
+                {
+                    //娌℃湁姝e父瀹屾垚,鍒欎腑鏂�
+                    break;
+                }
+            }
+            //杞寲涓鸿澶囧垪琛�
+            var listTempDevice = this.ConvertJObjectToDevice(listDeviceJson, gatewayId, ref listFucDevice);
+            for (int i = 0; i < listTempDevice.Count; i++)
+            {
+                listDevice.Add(listTempDevice[i]);
+            }
+            return statu == 1 ? 1 : 2;
+        }
+
+        /// <summary>
+        /// 鍦ㄨ澶嘥ype鍙樻洿鏃�,閲嶆柊New杩欎釜璁惧瀵硅薄(浠呴檺鍦ㄥ埛鏂拌澶囧垪琛ㄤ娇鐢�,骞朵笖鏈湴闇�瑕佸瓨鍦�)
+        /// </summary>
+        /// <param name="oldLocalDevice">鍘熸潵鐨勬湰鍦板璞�</param>
+        /// <param name="newDeviceType">鏂扮殑璁惧Type</param>
+        private bool ReNewDeviceOnTypeIsChanged(CommonDevice oldLocalDevice, DeviceType newDeviceType)
+        {
+            //鍏堣幏鍙栨湰鍦拌繖涓棫璁惧瀵硅薄鐨刯son
+            string oldFile = System.IO.Path.Combine(Config.Instance.FullPath, oldLocalDevice.FilePath);
+            var deviceData = HdlFileLogic.Current.ReadFileTextContent(oldFile);
+            if (deviceData == null)
+            {
+                //搴旇涓嶄細
+                return false;
+            }
+            //鏍规嵁鏂癟ype閲嶆柊New瀵硅薄
+            var newDevice = CommonDevice.CommonDeviceByByteString((int)newDeviceType, deviceData);
+            if (newDevice == null)
+            {
+                //濂藉儚鏈夌偣鍙兘
+                return false;
+            }
+            //鍒犻櫎鏈湴鏂囦欢
+            HdlFileLogic.Current.DeleteFile(oldFile);
+            HdlAutoBackupLogic.DeleteFile(oldLocalDevice.FilePath);
+
+            //閲嶆柊鐢熸垚鏂囦欢
+            if (newDevice.IsCustomizeImage == false)
+            {
+                newDevice.IconPath = string.Empty;
+            }
+            string mainkey = this.GetDeviceMainKeys(newDevice);
+            lock (dicAllDevice)
+            {
+                this.dicAllDevice[mainkey] = newDevice;
+            }
+            return true;
+        }
+
+        /// <summary>
+        /// 鎺ユ敹璁惧Mac鍒楄〃鐨勭被
+        /// </summary>
+        private class ReceiptMacResult
+        {
+            /// <summary>
+            /// mac鎬绘暟
+            /// </summary>
+            public int MACDeviceTotalNum = 0;
+            /// <summary>
+            /// 璁惧mac鍒楄〃
+            /// </summary>
+            public List<MacResult> MACDeviceList = new List<MacResult>();
+        }
+
+        /// <summary>
+        /// 璁惧Mac鐨勫唴瀹�
+        /// </summary>
+        private class MacResult
+        {
+            /// <summary>
+            /// 璁惧Mac
+            /// </summary>
+            public string MacAddr = string.Empty;
+            /// <summary>
+            /// mac绔偣鐨勬�绘暟
+            /// </summary>
+            public int EPTotalNum = 0;
+        }
+
+        #endregion
+
+        #region 鈻� 鍒涘缓鏂拌澶囧璞$浉鍏砡________________
+
+        /// <summary>
+        /// 鏍规嵁璁惧绫诲瀷鍒涘缓璁惧瀵硅薄鐨勫疄渚�(鏁版嵁鍦―eviceInfo涓�)
+        /// </summary>
+        /// <param name="deviceType">璁惧绫诲瀷</param>
+        /// <param name="jobject">涓婚Data</param>
+        /// <param name="gwid">缃戝叧id</param>
+        /// <returns></returns>
+        private CommonDevice NewDeviceObjectByDeviceId(DeviceType deviceType, Newtonsoft.Json.Linq.JObject jobject, string gwid)
+        {
+            //鏍规嵁璁惧绫诲瀷鍒涘缓璁惧瀵硅薄鐨勫疄渚�
+            CommonDevice device = this.NewDeviceObjectByDeviceId(deviceType, jobject.Value<int>("Epoint"));
+            if (device == null)
+            {
+                return null;
+            }
+
+            //璁剧疆璁惧灞炴�х被
+            device.DeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.DeviceInfoData>(jobject["Data"].ToString());
+            if (device.DeviceInfo == null)
+            {
+                return null;
+            }
+
+            //璁剧疆璁惧涓婚敭绫�
+            this.SetNewDeviceMainKeys(device, jobject);
+            device.CurrentGateWayId = gwid;
+
+            return device;
+        }
+
+        /// <summary>
+        /// 灏咲eviceInfo鐨勫睘鎬ц缃埌涓诲睘鎬т腑
+        /// </summary>
+        /// <param name="mainDevice">涓昏澶囧璞�</param>
+        /// <param name="device">璁剧疆婧愯澶囧璞�</param>
+        public void SetDeviceInfoToMain(CommonDevice mainDevice, CommonDevice device)
+        {
+            mainDevice.DeviceName = device.DeviceInfo.MacName;
+            mainDevice.DeviceEpointName = device.DeviceInfo.DeviceName;
+            mainDevice.CurrentGateWayId = device.CurrentGateWayId;
+            mainDevice.ZigbeeType = device.DeviceInfo.ZigbeeType;
+            mainDevice.IsOnline = device.DeviceInfo.IsOnline;
+            mainDevice.DriveCode = device.DeviceInfo.DriveCode;
+            mainDevice.IasDeviceType = device.DeviceInfo.DeviceType;
+            mainDevice.Profile = device.DeviceInfo.Profile;
+            mainDevice.Type = device.Type;
+            mainDevice.DeviceID = (int)device.Type;
+
+            //鍥轰欢鐗堟湰
+            mainDevice.ImgVersion = device.DeviceInfo.ImgVersion;
+            //纭欢鐗堟湰
+            mainDevice.HwVersion = device.DeviceInfo.HwVersion;
+            //闀滃儚ID
+            mainDevice.ImgTypeId = device.DeviceInfo.ImgTypeId;
+            //鍘傚晢鍚嶇О
+            mainDevice.ManufacturerName = device.DeviceInfo.ManufacturerName;
+            //妯″潡ID
+            mainDevice.ModelIdentifier = device.DeviceInfo.ModelIdentifier;
+            //搴忓垪鍙�
+            mainDevice.SerialNumber = device.DeviceInfo.ProductCode;
+            //璁惧鍔熻兘绫诲瀷
+            mainDevice.DfunctionType = (DeviceFunctionType)device.DeviceInfo.FunctionType;
+            if (mainDevice.DfunctionType == DeviceFunctionType.A涓嶆寚瀹�)
+            {
+                //寮忔牱鍙樻洿:鍔熻兘绫诲瀷涓嶅厑璁搁�夋嫨涓虹┖ 缃戝叧榛樿鐨凢unctionType涓�0
+                mainDevice.DfunctionType = DeviceFunctionType.A鏈畾涔�;
+            }
+
+            mainDevice.InClusterList.Clear();
+            mainDevice.InClusterList.AddRange(device.DeviceInfo.InClusterList);
+            mainDevice.OutClusterList.Clear();
+            mainDevice.OutClusterList.AddRange(device.DeviceInfo.OutClusterList);
+            mainDevice.AttributeStatus.Clear();
+            mainDevice.AttributeStatus.AddRange(device.DeviceInfo.AttributeStatus);
+
+            //濡傛灉鏄俯搴︿紶鎰熷櫒
+            if (mainDevice.Type == DeviceType.TemperatureSensor)
+            {
+                //杈撳嚭鏃� 1026:娓╁害浼犳劅鍣� 1029:婀垮害浼犳劅鍣�
+                foreach (var data in mainDevice.OutClusterList)
+                {
+                    if (data.OutCluster == 1029)
+                    {
+                        ((TemperatureSensor)mainDevice).SensorDiv = 2;
+                    }
+                    else if (data.OutCluster == 1026)
+                    {
+                        ((TemperatureSensor)mainDevice).SensorDiv = 1;
+                    }
+                }
+                if (((TemperatureSensor)mainDevice).SensorDiv == 1)
+                {
+                    //鍙樻洿涓�涓嬫俯搴︾殑鍊�
+                    foreach (var data in mainDevice.AttributeStatus)
+                    {
+                        if (data.ClusterId == 1026
+                           && data.AttributeId == (int)AttriButeId.MeasuredValue)
+                        {
+                            //澶勭悊缃戝叧杩斿洖鐨勬俯搴﹀��
+                            decimal temperatrue = this.AdjustTemperatrueValue(data.AttributeData);
+                            ((TemperatureSensor)mainDevice).currentTemperature = temperatrue;
+                        }
+                    }
+                }
+                else if (((TemperatureSensor)mainDevice).SensorDiv == 2)
+                {
+                    //鍙樻洿涓�涓嬫箍搴︾殑鍊�
+                    foreach (var data in mainDevice.AttributeStatus)
+                    {
+                        if (data.ClusterId == 1029
+                           && data.AttributeId == (int)AttriButeId.MeasuredValue)
+                        {
+                            //澶勭悊缃戝叧杩斿洖鐨勬俯搴﹀��
+                            decimal humidity = this.AdjustHumidityValue(data.AttributeData);
+                            ((TemperatureSensor)mainDevice).currentHumidity = humidity;
+                        }
+                    }
+                }
+            }
+        }
+
+        /// <summary>
+        /// 鏍规嵁璁惧Type鍒涘缓瀵瑰簲鐨勮澶囧璞�
+        /// </summary>
+        /// <param name="deviceType">璁惧Type</param>
+        /// <param name="DeviceEpoint">璁惧绔偣(娌℃湁浠�涔堢壒娈婇渶姹傜殑璇�,濉�0鍗冲彲)</param>
+        /// <returns></returns>
+        public CommonDevice NewDeviceObjectByDeviceId(DeviceType deviceType, int DeviceEpoint)
+        {
+            //鏍规嵁璁惧绫诲瀷鍒涘缓璁惧瀵硅薄鐨勫疄渚�
+            var device = CommonDevice.CommonDeviceByByteString((int)deviceType, "{\"DeviceID\":" + (int)deviceType + ",\"DeviceEpoint\":" + DeviceEpoint + "}");
+            if (device == null)
+            {
+                return null;
+            }
+
+            device.DeviceEpointName = string.Empty;
+            device.DeviceName = string.Empty;
+
+            return device;
+        }
+
+        /// <summary>
+        /// 缁欐柊璁惧璁剧疆涓婚敭灞炴��
+        /// </summary>
+        /// <param name="device">璁惧瀵硅薄</param>
+        /// <param name="jobject">涓婚Data</param>
+        public void SetNewDeviceMainKeys(CommonDevice device, Newtonsoft.Json.Linq.JObject jobject)
+        {
+            //璁剧疆璁惧涓婚敭绫�
+            device.DeviceID = jobject.Value<int>("Device_ID");
+            device.DeviceAddr = jobject.Value<string>("DeviceAddr");
+            device.DeviceEpoint = jobject.Value<int>("Epoint");
+        }
+
+        #endregion
+
+        #region 鈻� 鍒锋柊璁惧鍔熻兘绫诲瀷___________________
+
+        /// <summary>
+        /// 鍒锋柊璁惧鐨勫姛鑳界被鍨�,濡傛灉杩斿洖true,浠h〃闇�瑕佸彟澶栬皟鐢ㄣ�怱endDeviceFunctionTypeToGateway銆戝嚱鏁�,sendFucType涓簍rue鏃惰嚜鍔ㄨ皟鐢�
+        /// </summary>
+        /// <param name="mainDevice">涓昏澶囧璞�</param>
+        /// <param name="device">璁剧疆婧愯澶囧璞�</param>
+        /// <param name="sendFucType">褰撻渶瑕佸彉鏇存椂,鏄惁鍙戦�佸姛鑳界被鍨嬪埌缃戝叧(姝ゅ彉閲忕粰鑾峰彇璁惧鍒楄〃鏈夌壒娈婂惈涔�)</param>
+        public bool RefreshDeviceFunctionType(CommonDevice mainDevice, CommonDevice device, bool sendFucType)
+        {
+            //濡傛灉鏄皟鍏夊櫒
+            if (mainDevice.Type == DeviceType.DimmableLight)
+            {
+                if (mainDevice.IsCustomizeImage == false)
+                {
+                    mainDevice.IconPath = "Device/Light.png";
+                }
+                mainDevice.DfunctionType = DeviceFunctionType.A鐏厜;
+                if (device.DeviceInfo != null && device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A鐏厜)
+                {
+                    //璋冨厜鍣ㄥ浐瀹氱伅鍏�
+                    if (sendFucType == true)
+                    {
+                        this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A鐏厜);
+                    }
+                    return true;
+                }
+            }
+            //濡傛灉鏄壊娓╃伅
+            else if (mainDevice.Type == DeviceType.ColorTemperatureLight)
+            {
+                if (mainDevice.IsCustomizeImage == false)
+                {
+                    mainDevice.IconPath = "Device/ColorLightTemperature.png";
+                }
+                mainDevice.DfunctionType = DeviceFunctionType.A鐏厜;
+                if (device.DeviceInfo != null && device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A鐏厜)
+                {
+                    //鑹叉俯鐏浐瀹氱伅鍏�
+                    if (sendFucType == true)
+                    {
+                        this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A鐏厜);
+                    }
+                    return true;
+                }
+            }
+            //濡傛灉鏄笁璺户鐢靛櫒鐨勫洖璺殑璇�,榛樿涓虹伅鍏�
+            else if (mainDevice.Type == DeviceType.OnOffOutput)
+            {
+                //鏍规嵁鍔熻兘绫诲瀷,閲嶆柊璁剧疆璁惧鍥炶矾鍥炬爣
+                this.ResetIconPathByDeviceFunctionType(mainDevice);
+                //2020.05.13鍙樻洿:缁х數鍣ㄩ兘榛樿涓虹伅鍏�
+                if (mainDevice.DfunctionType == DeviceFunctionType.A鏈畾涔�)
+                {
+                    mainDevice.DfunctionType = DeviceFunctionType.A鐏厜;
+                    if (device.DeviceInfo != null && device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A鐏厜)
+                    {
+                        //缁х數鍣ㄩ粯璁や负鐏厜
+                        if (sendFucType == true)
+                        {
+                            this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A鐏厜);
+                        }
+                        return true;
+                    }
+                }
+            }
+            //濡傛灉鏄┖姘斿紑鍏崇殑璇�
+            else if (mainDevice.Type == DeviceType.AirSwitch)
+            {
+                //鏍规嵁鍔熻兘绫诲瀷,閲嶆柊璁剧疆璁惧鍥炶矾鍥炬爣
+                this.ResetIconPathByDeviceFunctionType(mainDevice);
+                //绌烘皵寮�鍏抽粯璁や负寮�鍏�
+                if (mainDevice.DfunctionType == DeviceFunctionType.A鏈畾涔�)
+                {
+                    mainDevice.DfunctionType = DeviceFunctionType.A寮�鍏�;
+                    if (device.DeviceInfo != null && device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A寮�鍏�)
+                    {
+                        //绌烘皵寮�鍏抽粯璁や负寮�鍏�
+                        if (sendFucType == true)
+                        {
+                            this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A寮�鍏�);
+                        }
+                        return true;
+                    }
+                }
+            }
+            //濡傛灉鏄僵鐏殑璇�
+            else if (mainDevice.Type == DeviceType.ColorDimmableLight)
+            {
+                if (mainDevice.IsCustomizeImage == false)
+                {
+                    mainDevice.IconPath = "Device/ColorLight.png";
+                }
+                mainDevice.DfunctionType = DeviceFunctionType.A鐏厜;
+                if (device.DeviceInfo != null && device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A鐏厜)
+                {
+                    //褰╃伅榛樿涓哄紑鍏�
+                    if (sendFucType == true)
+                    {
+                        this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A寮�鍏�);
+                    }
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        /// <summary>
+        /// 鏍规嵁鍔熻兘绫诲瀷,閲嶆柊璁剧疆璁惧鍥炶矾鍥炬爣
+        /// </summary>
+        /// <param name="device"></param>
+        private void ResetIconPathByDeviceFunctionType(CommonDevice device)
+        {
+            if (device.IsCustomizeImage == true)
+            {
+                return;
+            }
+            if (device.DfunctionType == DeviceFunctionType.A寮�鍏�)
+            {
+                device.IconPath = "Device/Switch.png";
+            }
+            else if (device.DfunctionType == DeviceFunctionType.A鎻掑骇)
+            {
+                device.IconPath = "Device/Socket1.png";
+            }
+            else
+            {
+                device.IconPath = "Device/Light.png";
+            }
+        }
+
+        #endregion
+
+        //----------------------------------鍒嗗壊绾�(璁惧妯″潡ID)---------------------------------------------
+
+        #region 鈻� 鑷畾涔夎澶囨ā鍧桰D___________________
+
+        /// <summary>
+        /// 鍒濆鍖栬澶囩殑妯″潡ID鐨勬灇涓�
+        /// </summary>
+        private void InitDeviceModelIdEnum()
+        {
+            //*********************************************************************
+            //鏂拌澶囨坊鍔犳柟娉曪細
+            //1銆佸湪鏈�涓嬮潰娣诲姞 DeviceConcreteType 锛岀劧鍚庢槸 DeviceBeloneType
+            //2銆佷互璁惧鐨勫叿浣撶被鍨嬩负鍚嶅瓧DeviceConcreteType(鍘绘帀銆�-銆�)娣诲姞璁惧鐨勩�愭墍灞炲浘鐗囥�戯紝銆愮湡瀹炵墿鐞嗗浘鐗囥�戙�傚洖璺浘鐗囬渶瑕佺壒娈婂鐞�
+            //3銆佸鏋滈渶瑕佸叡鏈夊浘鐗�,鍒欏湪杩欎釜鍑芥暟鐨勬渶搴曚笅娣诲姞
+            //4銆佹樉绀虹殑妯″潡ID闇�瑕佷氦鎹㈢殑璇�,鍒欏湪杩欎釜鍑芥暟鐨勬渶搴曚笅娣诲姞
+            //*********************************************************************
+
+            if (this.dicDeviceModelIdEnum != null)
+            {
+                return;
+            }
+            this.dicDeviceModelIdEnum = new Dictionary<string, DeviceNameContent>();
+
+            var listText = this.GetDeviceNameFileContent();
+            foreach (var dataText in listText)
+            {
+                if (dataText == string.Empty || dataText.StartsWith(";") == true)
+                {
+                    //杩欐槸娉ㄩ噴
+                    continue;
+                }
+                string[] strArry1 = dataText.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
+                if (strArry1.Length != 2)
+                {
+                    //闈炴硶璁剧疆
+                    continue;
+                }
+                string[] strArry2 = strArry1[1].Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
+                if (strArry2.Length < 6)
+                {
+                    //闈炴硶璁剧疆
+                    continue;
+                }
+                var content = new DeviceNameContent();
+                content.ConcreteTypeValue = Convert.ToInt32(strArry2[0].Trim());
+                content.A瀹樻柟鍚嶅瓧 = strArry2[1].Trim();
+                content.A澶囨敞鍚嶅瓧 = strArry2[2].Trim();
+                content.BeloneTypeValue = Convert.ToInt32(strArry2[3].Trim());
+                content.A鎵�灞炲悕瀛� = strArry2[4].Trim();
+                content.A绫诲瀷鍚嶅瓧 = strArry2[5].Trim();
+                this.dicDeviceModelIdEnum[strArry1[0].Trim()] = content;
+            }
+
+            //鉁┾湬鉁┾湬鉁╅渶瑕佷氦鎹㈢殑妯″潡ID鉁┾湬鉁┾湬鉁�
+            this.dicDeviceModelIdChanged = new Dictionary<string, string>();
+            //=========鈽呪槄瀹夐槻绫讳紶鎰熷櫒绫烩槄鈽�=========
+            this.dicDeviceModelIdChanged["MULTI-GASE--EA07"] = "MSG01/M-ZB.10";//鐕冩皵浼犳劅鍣�
+            this.dicDeviceModelIdChanged["MULTI-MECI--EA01"] = "MSDC01/M-ZB.10";//闂ㄧ獥纾佷紶鎰熷櫒
+            this.dicDeviceModelIdChanged["MULTI-FIRE--EA05"] = "MSS01/M-ZB.10";//鐑熼浘浼犳劅鍣�
+            this.dicDeviceModelIdChanged["MULTI-MOTI--EA04"] = "MSPIR01/M-ZB.10";//绾㈠浼犳劅鍣�
+            this.dicDeviceModelIdChanged["MULTI-WATE--EA02"] = "MSW01/M-ZB.10";//姘存蹈浼犳劅鍣�
+            this.dicDeviceModelIdChanged["MULTI-BURO--EA06"] = "MBU01/M-ZB.10";//绱ф�ユ寜閿�
+
+            //鉁┾湬鉁┾湬鉁╅渶瑕佸叡鏈夌殑鍥剧墖瀵硅薄鉁┾湬鉁┾湬鉁�
+            //涓よ�呴兘鏄疍eviceConcreteType
+            //Keys:鎸囧畾鐨勮澶�    value:娌跨敤鐨勫浘鐗囨槸鍝璁惧鐨�
+            this.dicPictrueShard = new Dictionary<string, string>();
+            this.dicPictrueShard["ButtonPanel_SimpleFour"] = "ButtonPanel_Four";//绠�绾�4鎸夐敭闈㈡澘 娌跨敤 4鎸夐敭鐨勫浘鏍�
+            this.dicPictrueShard["ButtonPanel_SimpleThree"] = "ButtonPanel_Three";//绠�绾�3鎸夐敭闈㈡澘 娌跨敤 3鎸夐敭鐨勫浘鏍�
+            this.dicPictrueShard["ButtonPanel_SimpleTwo"] = "ButtonPanel_Two";//绠�绾�2鎸夐敭闈㈡澘 娌跨敤 2鎸夐敭鐨勫浘鏍�
+            this.dicPictrueShard["IntelligentLocks_Sone"] = "IntelligentLocks_H06C";//S-One Pro鐨勯棬閿佸浘鐗� 娌跨敤 H06C鐨勫浘鏍�
+            this.dicPictrueShard["IntelligentLocks_AT1TF"] = "IntelligentLocks_H06C";//鍏ㄨ嚜鍔ㄦ櫤鑳介棬閿� AT-1TF鍥剧墖 娌跨敤 H06C鐨勫浘鏍�
+            this.dicPictrueShard["IntelligentLocks_AT1F"] = "IntelligentLocks_H06C";//鍏ㄨ嚜鍔ㄦ櫤鑳介棬閿� AT-1F鍥剧墖 娌跨敤 H06C鐨勫浘鏍�
+            this.dicPictrueShard["IntelligentLocks_AT1T"] = "IntelligentLocks_H06C";//鍏ㄨ嚜鍔ㄦ櫤鑳介棬閿� AT-1T鍥剧墖 娌跨敤 H06C鐨勫浘鏍�
+            this.dicPictrueShard["IntelligentLocks_HAT1B"] = "IntelligentLocks_H06C";//鏅鸿兘闂ㄩ攣 HAT-1B鍥剧墖 娌跨敤 H06C鐨勫浘鏍� 
+            this.dicPictrueShard["IntelligentLocks_HAT1T"] = "IntelligentLocks_H06C";//鏅鸿兘闂ㄩ攣 HAT-1T鍥剧墖 娌跨敤 H06C鐨勫浘鏍� 
+            this.dicPictrueShard["IntelligentLocks_ATFT"] = "IntelligentLocks_H06C";//鏅鸿兘闂ㄩ攣 HAT-1T鍥剧墖 娌跨敤 H06C鐨勫浘鏍�   
+            this.dicPictrueShard["Relay_FangyueFreshAirModul"] = "Relay_ThreeLoad";//鏂规偊鏂伴灏忔ā鍧楀浘鐗� 娌跨敤 3璺户鐢靛櫒鐨勫浘鏍�
+            this.dicPictrueShard["ButtonPanel_FourButtonScene"] = "ButtonPanel_Four";//绠�绾�4鎸夐敭鍦烘櫙闈㈡澘 娌跨敤 4鎸夐敭闈㈡澘鐨勫浘鏍�
+        }
+
+        /// <summary>
+        /// 鑾峰彇璁惧鍚嶅瓧鏂囦欢鐨勫唴瀹�
+        /// </summary>
+        /// <returns></returns>
+        private List<string> GetDeviceNameFileContent()
+        {
+            System.IO.StreamReader streamReader = null;
+            var listText = new List<string>();
+            try
+            {
+#if iOS
+                string textFile = Foundation.NSBundle.MainBundle.PathForResource("DeviceName.ini", null);
+                streamReader = new System.IO.StreamReader(textFile, Encoding.UTF8);
+                string text;
+                while ((text = streamReader.ReadLine()) != null)
+                {
+                    listText.Add(text.Trim());
+                }
+                return listText;
+#endif
+#if Android
+                var stream = Application.Activity.Assets.Open("DeviceName.ini");
+                streamReader = new System.IO.StreamReader(stream, Encoding.UTF8);
+                string text;
+                while ((text = streamReader.ReadLine()) != null)
+                {
+                    listText.Add(text.Trim());
+                }
+                stream.Close();
+                return listText;
+#endif
+            }
+            catch
+            {
+                return listText;
+            }
+            finally
+            {
+                try
+                {
+                    streamReader?.Close();
+                }
+                catch
+                {
+                }
+            }
+        }
+
+        #endregion
+    }
+
+    #region 鈻� 鑷畾涔夎澶囩被鍨媉________________________
+
+    /// <summary>
+    /// <para>璁惧鐨勫叿浣撱�愯澶囩被鍨嬨��,鍙橀噺鍚嶅彲浠ヤ綔涓恒�愯澶囩被鍨嬨�戝浘鐗�,杩欎釜鍊兼槸鐬庡啓鐨�,娌′粈涔堢壒娈婃剰涔�</para>
+    /// </summary>
+    public enum DeviceConcreteType
+    {
+        /// <summary>
+        /// 鏈煡璁惧
+        /// </summary>
+        UnKownDevice = -1,
+
+        //=========鈽呪槄绐楀笜绫�(100-199)鈽呪槄=========
+        /// <summary>
+        /// 绐楀笜
+        /// </summary>
+        Curtain = -100,
+        /// <summary>
+        /// 鏅鸿兘寮�鍚堝笜鐢垫満 闀滃儚id锛�100
+        /// </summary>
+        Curtain_AutoOpen = 100,
+        /// <summary>
+        /// 鏅鸿兘绠$姸鐢垫満 闀滃儚id锛�101
+        /// </summary>
+        Curtain_Siphonate = 101,
+
+        //=========鈽呪槄鎸夐敭闈㈡澘绫�(200-1199)鈽呪槄=========
+        /// <summary>
+        /// 鎸夐敭闈㈡澘
+        /// </summary>
+        ButtonPanel = -200,
+        /// <summary>
+        /// 4鎸夐敭澶氬姛鑳借Е鎽搁潰鏉�(甯�4璺户鐢靛櫒搴曞骇) 闀滃儚id锛�200
+        /// </summary>
+        ButtonPanel_Four = 200,
+        /// <summary>
+        /// 3鎸夐敭澶氬姛鑳借Е鎽搁潰鏉�(甯�3璺户鐢靛櫒搴曞骇) 闀滃儚id锛�201
+        /// </summary>
+        ButtonPanel_Three = 201,
+        /// <summary>
+        /// 2鎸夐敭澶氬姛鑳借Е鎽搁潰鏉�(甯�2璺户鐢靛櫒搴曞骇) 闀滃儚id锛�202
+        /// </summary>
+        ButtonPanel_Two = 202,
+        /// <summary>
+        /// 12鎸夐敭澶氬姛鑳借Е鎽搁潰鏉�(甯�1璺户鐢靛櫒搴曞骇) 闀滃儚id锛�203
+        /// </summary>
+        ButtonPanel_Twelve = 203,
+        /// <summary>
+        /// 4鎸夐敭澶氬姛鑳借Е鎽搁潰鏉匡紙鍙甫鐢垫簮搴曞骇锛� 闀滃儚id锛�210
+        /// </summary>
+        ButtonPanel_FourNotPower = 210,
+        /// <summary>
+        /// 绠�绾�4鎸夐敭闈㈡澘 闀滃儚id锛�220
+        /// </summary>
+        ButtonPanel_SimpleFour = 220,
+        /// <summary>
+        /// 绠�绾�3鎸夐敭闈㈡澘 闀滃儚id锛�221
+        /// </summary>
+        ButtonPanel_SimpleThree = 221,
+        /// <summary>
+        /// 绠�绾�2鎸夐敭闈㈡澘 闀滃儚id锛�222
+        /// </summary>
+        ButtonPanel_SimpleTwo = 222,
+        /// <summary>
+        /// 绠�绾�4鎸夐敭鍦烘櫙闈㈡澘 闀滃儚id锛�224
+        /// </summary>
+        ButtonPanel_FourButtonScene = 224,
+        /// <summary>
+        /// 绠�绾�2璺獥甯橀潰鏉� 闀滃儚id锛�226
+        /// </summary>
+        ButtonPanel_TwoButtonCurtain = 226,
+        /// <summary>
+        /// 鏂规偊2鎸夐敭杞昏Е寮忛潰鏉� 闀滃儚id锛�240
+        /// </summary>
+        ButtonPanel_FangyueTwo = 240,
+        /// <summary>
+        /// 鏂规偊4鎸夐敭杞昏Е寮忛潰鏉� 闀滃儚id锛�241
+        /// </summary>
+        ButtonPanel_FangyueFour = 241,
+        /// <summary>
+        /// 鏂规偊8鎸夐敭杞昏Е寮忛潰鏉� 闀滃儚id锛�242
+        /// </summary>
+        ButtonPanel_FangyueEight = 242,
+        /// <summary>
+        /// 鏂规偊鏂伴闈㈡澘 闀滃儚id锛�250
+        /// </summary>
+        ButtonPanel_FangyueFreshAir = 250,
+        /// <summary>
+        /// 鏂规偊鐜闈㈡澘 闀滃儚id锛�253
+        /// </summary>
+        ButtonPanel_FangyueEnvironment = 253,
+        /// <summary>
+        /// 绐楀笜闈㈡澘 闀滃儚id锛�256
+        /// </summary>
+        ButtonPanel_Curtain = 256,
+        /// <summary>
+        /// 绠�绾﹀鍔熻兘闈㈡澘 闀滃儚ID锛�212
+        /// </summary>
+        ButtonPanel_SimpleMultifunction = 212,
+        /// <summary>
+        /// 绠�绾︾幆澧冮潰鏉�
+        /// </summary>
+        ButtonPanel_SimpleEnvironment = 230,
+
+        //=========鈽呪槄PIR浼犳劅鍣ㄧ被(1200-1299)鈽呪槄=========
+        /// <summary>
+        /// 浼犳劅鍣�
+        /// </summary>
+        Sensor = -1200,
+        /// <summary>
+        /// pir浼犳劅鍣�220 闀滃儚id锛�1200
+        /// </summary>
+        Sensor_Pir = 1200,
+        /// <summary>
+        /// 鐞冨舰绉诲姩浼犳劅鍣� 闀滃儚id锛�1205
+        /// </summary>
+        Sensor_SphericalMotion = 1205,
+
+        //=========鈽呪槄瀹夐槻绫讳紶鎰熷櫒绫�(1300-2299)鈽呪槄=========
+        /// <summary>
+        /// 鐕冩皵浼犳劅鍣�
+        /// </summary>
+        Sensor_CarbonMonoxide = 1300,
+        /// <summary>
+        /// 闂ㄧ獥浼犳劅鍣�
+        /// </summary>
+        Sensor_DoorWindow = 1301,
+        /// <summary>
+        /// 鐑熼浘浼犳劅鍣�
+        /// </summary>
+        Sensor_Fire = 1302,
+        /// <summary>
+        /// 绾㈠浼犳劅鍣�
+        /// </summary>
+        Sensor_Infrared = 1303,
+        /// <summary>
+        /// 姘翠镜浼犳劅鍣�
+        /// </summary>
+        Sensor_Water = 1304,
+        /// <summary>
+        /// 绱ф�ユ寜閽�
+        /// </summary>
+        Sensor_EmergencyButton = 1305,
+        /// <summary>
+        /// 鍚搁《鐕冩皵浼犳劅鍣�
+        /// </summary>
+        Sensor_CeilingGas = 1306,
+        /// <summary>
+        /// PM2.5绌烘皵璐ㄩ噺浼犳劅鍣�
+        /// </summary>
+        Sensor_PMTwoPointFive = 1307,
+        /// <summary>
+        /// 娓╂箍搴︿紶鎰熷櫒(杩欎釜鍗曡瘝鎷奸敊浜�,浣嗘槸閿欎簡灏遍敊浜嗗憲,灏辫繖鏍蜂簡)
+        /// </summary>
+        Sensor_TemperatureHumidity = 1308,
+
+        /// <summary>
+        /// 杩愬姩浼犳劅鍣�
+        /// </summary>
+        Sensor_Motion = -1306,
+        /// <summary>
+        /// 閽ュ寵鎵�
+        /// </summary>
+        Sensor_Keyfob = -1307,
+        /// <summary>
+        /// 娓╁害浼犳劅鍣�(杩欎釜鍗曡瘝鎷奸敊浜�,浣嗘槸閿欎簡灏遍敊浜嗗憲,灏辫繖鏍蜂簡)
+        /// </summary>
+        Sensor_Temperature = -1309,
+        /// <summary>
+        /// 婀垮害浼犳劅鍣�
+        /// </summary>
+        Sensor_Humidity = -1310,
+
+        //=========鈽呪槄缁х數鍣ㄧ被(2300-2499)鈽呪槄=========
+        /// <summary>
+        /// 缁х數鍣�
+        /// </summary>
+        Relay = -2300,
+        /// <summary>
+        /// 涓夎矾缁х數鍣� 闀滃儚id锛�2300
+        /// </summary>
+        Relay_ThreeLoad = 2300,
+        /// <summary>
+        /// 鏂规偊鏂伴灏忔ā鍧� 闀滃儚id锛�2310
+        /// </summary>
+        Relay_FangyueFreshAirModul = 2310,
+        /// <summary>
+        /// 鍥芥爣3璺�10A缁х數鍣ㄥ皬妯″潡 闀滃儚id锛�2301
+        /// </summary>
+        Relay_NationalThreeLoadTenA = 2301,
+        /// <summary>
+        /// 娆ф爣2璺�5A缁х數鍣ㄥ皬妯″潡 闀滃儚id锛�2315
+        /// </summary>
+        Relay_EuropeanTwoLoadFiveA = 2315,
+        /// <summary>
+        /// 7璺共鎺ョ偣杈撳叆杈撳嚭妯″潡 闀滃儚id锛�2320
+        /// </summary>
+        Relay_SevenLoadInOutPutDryContact = 2320,
+
+        //=========鈽呪槄璋冨厜鍣ㄧ被(2500-2799)鈽呪槄=========
+        /// <summary>
+        /// 璋冨厜鍣�
+        /// </summary>
+        DimmableLight = -2500,
+        /// <summary>
+        /// 1璺皟鍏夊櫒灏忔ā鍧�
+        /// </summary>
+        DimmableLight_OneLoad = 2500,
+
+        //=========鈽呪槄鏅鸿兘闂ㄩ攣绫�(2800-????)鈽呪槄=========
+        /// <summary>
+        /// 鏅鸿兘闂ㄩ攣
+        /// </summary>
+        IntelligentLocks = -2800,
+        /// <summary>
+        /// H06C
+        /// </summary>
+        IntelligentLocks_H06C = 2800,
+        /// <summary>
+        /// S-One Pro
+        /// </summary>
+        IntelligentLocks_Sone = 2802,
+        /// <summary>
+        /// AT-1TF
+        /// </summary>
+        IntelligentLocks_AT1TF = 2803,
+        /// <summary>
+        /// AT-1F
+        /// </summary>
+        IntelligentLocks_AT1F = 2804,
+        /// <summary>
+        /// AT-1T
+        /// </summary>
+        IntelligentLocks_AT1T = 2805,
+        /// <summary>
+        /// HAT-1B
+        /// </summary>
+        IntelligentLocks_HAT1B = 2806,
+        /// <summary>
+        /// HAT-1T
+        /// </summary>
+        IntelligentLocks_HAT1T = 2807,
+        /// <summary>
+        /// AT-FT
+        /// </summary>
+        IntelligentLocks_ATFT = 2808,
+
+        //=========鈽呪槄褰╃伅绫�(????-????)鈽呪槄=========
+        /// <summary>
+        /// 褰╃伅
+        /// </summary>
+        ColorLight = -10,
+        /// <summary>
+        /// 鑹叉俯鐏�(瀹冪殑闀滃儚ID鏈畾,鏆傚畾20000)
+        /// </summary>
+        ColorLight_Temperature = 20000,
+
+        //=========鈽呪槄绌鸿皟(3600-3899)鈽呪槄=========
+        /// <summary>
+        /// 绌鸿皟
+        /// </summary>
+        AirConditioner = -3600,
+        /// <summary>
+        /// zigbee绌鸿皟缃戝叧妯″潡
+        /// </summary>
+        AirConditioner_ZbGateway = 3600,
+
+        //=========鈽呪槄涓户鍣�(3900-3999)鈽呪槄=========
+        /// <summary>
+        /// 涓户鍣�
+        /// </summary>
+        Repeater = -3900,
+        /// <summary>
+        /// zigbee涓户鍣� 闀滃儚id锛�3900
+        /// </summary>
+        Repeater_Zigbee = 3900,
+
+        //=========鈽呪槄绌烘皵寮�鍏崇被(4100-????)鈽呪槄=========
+        /// <summary>
+        /// 鏅鸿兘绌哄紑
+        /// </summary>
+        AirSwitch = -4100,
+        /// <summary>
+        /// 鏅鸿兘绌哄紑 闀滃儚id锛�4100
+        /// </summary>
+        AirSwitch_CloudContr = 4100,
+
+        //=========鈽呪槄杞崲鍣ㄧ被(4200-4699)鈽呪槄=========
+        /// <summary>
+        /// 杞崲鍣�
+        /// </summary>
+        Converter = -4200,
+        /// <summary>
+        /// zigbee杞�485鍗忚杞崲鍣�
+        /// </summary>
+        Converter_Zb485 = 4200,
+        /// <summary>
+        /// zigbee杞琤uspro鍗忚杞崲鍣�
+        /// </summary>
+        Converter_ZbBuspro = 4201,
+
+        //=========鈽呪槄鏅捐。鏋剁被(5000-5199)鈽呪槄=========
+        /// <summary>
+        /// 鏅捐。鏋�
+        /// </summary>
+        Airer = 5000,
+
+        //=========鈽呪槄绌烘皵璐ㄩ噺浼犳劅鍣ㄧ被(5200-5399)鈽呪槄=========
+        /// <summary>
+        /// 绌烘皵璐ㄩ噺浼犳劅鍣�
+        /// </summary>
+        AirQualitySensor = 5200,
+
+        //=========鈽呪槄鍏朵粬绫�(????-????)鈽呪槄=========
+        /// <summary>
+        /// 骞叉帴鐐�(娉ㄦ剰,瀹冨睘浜庡叾浠栫被,涓嶆槸璁惧绫诲瀷)
+        /// </summary>
+        DryContact = -10000,
+        /// <summary>
+        /// 鐏厜(娉ㄦ剰,瀹冨睘浜庡叾浠栫被,涓嶆槸璁惧绫诲瀷)
+        /// </summary>
+        Light = -10001,
+        /// <summary>
+        /// 鎻掑骇(娉ㄦ剰,瀹冨睘浜庡叾浠栫被,涓嶆槸璁惧绫诲瀷)
+        /// </summary>
+        Socket1 = -10002,
+        /// <summary>
+        /// 寮�鍏�(娉ㄦ剰,瀹冨睘浜庡叾浠栫被,涓嶆槸璁惧绫诲瀷)
+        /// </summary>
+        Switch = -10003,
+    }
+
+    /// <summary>
+    /// <para>璁惧鎵�灞炴灇涓�,杩欎釜鍊兼槸鐬庡啓鐨�,娌′粈涔堢壒娈婃剰涔�</para>
+    /// </summary>
+    public enum DeviceBeloneType
+    {
+        /// <summary>
+        /// 鏈煡璁惧
+        /// </summary>
+        A鏈煡璁惧 = 0,
+        /// <summary>
+        /// 绐楀笜(100-199)
+        /// </summary>
+        A绐楀笜 = 100,
+        /// <summary>
+        /// 鎸夐敭闈㈡澘(200-1199)
+        /// </summary>
+        A鎸夐敭闈㈡澘 = 200,
+        /// <summary>
+        /// 浼犳劅鍣�(1200-2299)
+        /// </summary>
+        A浼犳劅鍣� = 1200,
+        /// <summary>
+        /// PM2.5绌烘皵璐ㄩ噺浼犳劅鍣�
+        /// </summary>
+        APM2鐐�5绌烘皵璐ㄩ噺浼犳劅鍣� = 1307,
+        /// <summary>
+        /// 缁х數鍣�(2300-2499)
+        /// </summary>
+        A缁х數鍣� = 2300,
+        /// <summary>
+        /// 鏂伴
+        /// </summary>
+        A鏂伴 = 2310,
+        /// <summary>
+        /// 璋冨厜鍣�(2500-2799)
+        /// </summary>
+        A璋冨厜鍣� = 2500,
+        /// <summary>
+        /// 鏅鸿兘闂ㄩ攣(2800-????)
+        /// </summary>
+        A鏅鸿兘闂ㄩ攣 = 2800,
+        /// <summary>
+        /// 绌鸿皟(3600-3899)
+        /// </summary>
+        A绌鸿皟 = 3600,
+        /// <summary>
+        /// 涓户鍣�(3900-3999)
+        /// </summary>
+        A涓户鍣� = 3900,
+        /// <summary>
+        /// 鏅鸿兘绌哄紑(4100-4199)
+        /// </summary>
+        A鏅鸿兘绌哄紑 = 4100,
+        /// <summary>
+        /// 杞崲鍣�(4200-4699)
+        /// </summary>
+        A杞崲鍣� = 4200,
+        /// <summary>
+        /// 鏅捐。鏋�(4200-4699)
+        /// </summary>
+        A鏅捐。鏋� = 5000,
+        /// <summary>
+        /// 绌烘皵璐ㄩ噺浼犳劅鍣�(5200-5399)
+        /// </summary>
+        A绌烘皵璐ㄩ噺 = 5200,
+        /// <summary>
+        /// 褰╃伅
+        /// </summary>
+        A褰╃伅 = 9,
+        /// <summary>
+        /// 娓╂箍搴︿紶鎰熷櫒
+        /// </summary>
+        A娓╂箍搴︿紶鎰熷櫒 = 10,
+        /// <summary>
+        /// 娓╁害浼犳劅鍣�
+        /// </summary>
+        A娓╁害浼犳劅鍣� = 11,
+        /// <summary>
+        /// 婀垮害浼犳劅鍣�
+        /// </summary>
+        A婀垮害浼犳劅鍣� = 12,
+        /// <summary>
+        /// 寮�鍏�
+        /// </summary>
+        A寮�鍏� = 13,
+        /// <summary>
+        /// 鎻掑骇
+        /// </summary>
+        A鎻掑骇 = 14,
+        /// <summary>
+        /// 鐏厜
+        /// </summary>
+        A鐏厜 = 15,
+        /// <summary>
+        /// 骞叉帴鐐�
+        /// </summary>
+        A骞叉帴鐐� = 16,
+    }
+
+    #endregion
+}

--
Gitblit v1.8.0