From c6b35c3138b944830b5336bf610f918154dd47c7 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期六, 12 十月 2019 15:45:10 +0800
Subject: [PATCH] 合并门锁,完成住宅管理

---
 ZigbeeApp/Shared/Common/Device.cs |  601 +++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 475 insertions(+), 126 deletions(-)

diff --git a/ZigbeeApp/Shared/Common/Device.cs b/ZigbeeApp/Shared/Common/Device.cs
index 7b123ae..8f0dc65 100755
--- a/ZigbeeApp/Shared/Common/Device.cs
+++ b/ZigbeeApp/Shared/Common/Device.cs
@@ -44,9 +44,13 @@
             get
             {
                 var list = new List<CommonDevice>();
-                foreach (var device in dicAllDevice.Values)
+                foreach (var listMac in this.dicDeviceSort.Values)
                 {
-                    list.Add(device);
+                    foreach (var strMac in listMac)
+                    {
+                        var listTemp = this.GetDevicesByMac(strMac);
+                        list.AddRange(listTemp);
+                    }
                 }
                 return list;
             }
@@ -81,13 +85,13 @@
         /// </summary>
         private Dictionary<string, HashSet<int>> dicDeviceEpoint = new Dictionary<string, HashSet<int>>();
         /// <summary>
+        /// 璁惧Mac椤哄簭
+        /// </summary>
+        private Dictionary<string, List<string>> dicDeviceSort = null;
+        /// <summary>
         /// 璁惧鏂囦欢鐨勫墠缂�鍚嶅瓧
         /// </summary>
         public const string deviceFirstName = "Device_";
-        /// <summary>
-        /// 閿�
-        /// </summary>
-        private object objLock = new object();
 
         #endregion
 
@@ -99,7 +103,7 @@
         public void ReFreshByLocal()
         {
             this.dicAllDevice.Clear();
-            this.dicDeviceEpoint.Clear();
+            this.dicDeviceEpoint.Clear();
 
             //鍒濆鍖朢鏂囦欢閲岄潰璁惧榛樿鍚嶅瓧鐨処D
             this.InitDeviceDefultNameIDList();
@@ -171,7 +175,9 @@
                 }
             }
             //鎴愬憳韬唤鐨勬椂鍊�,鍒犻櫎鎺夐潪娉曠殑缃戝叧鏂囦欢
-            this.DeleteGatewayFileByMemberModel();
+            this.DeleteGatewayFileByMemberModel();
+            //鍒濆鍖栬澶囬『搴�
+            this.InitDeviceSort();
         }
 
         /// <summary>
@@ -184,11 +190,15 @@
                 return;
             }
             var listId = new HashSet<string>();
-            foreach (var device in this.dicAllDevice.Values)
+
+            lock (dicAllDevice)
             {
-                if (listId.Contains(device.CurrentGateWayId) == false)
+                foreach (var device in this.dicAllDevice.Values)
                 {
-                    listId.Add(device.CurrentGateWayId);
+                    if (listId.Contains(device.CurrentGateWayId) == false)
+                    {
+                        listId.Add(device.CurrentGateWayId);
+                    }
                 }
             }
             var listGateway = HdlGatewayLogic.Current.GetAllLocalGateway();
@@ -217,7 +227,7 @@
         {
             //浠庣綉鍏宠幏鍙栧叏閮ㄧ殑璁惧
             List<CommonDevice> listDevice = new List<CommonDevice>();
-            List<CommonDevice> list = await this.GetDeviceListFromGateway(zbGateway, deviceComingAction);
+            List<CommonDevice> list = await this.GetDeviceListFromGateway(zbGateway, true, deviceComingAction);
 
             if (list == null)
             {
@@ -302,6 +312,16 @@
         /// <param name="device">璁惧瀵硅薄(杩欎釜涓滆タ鏈夊彲鑳戒細琚洿鏀�)</param>
         public void AddDeviceToMemory(ref CommonDevice device)
         {
+            if (dicDeviceSort.ContainsKey(device.CurrentGateWayId) == false)
+            {
+                dicDeviceSort[device.CurrentGateWayId] = new List<string>();
+            }
+            if (dicDeviceSort[device.CurrentGateWayId].Contains(device.DeviceAddr) == false)
+            {
+                //淇濆瓨椤哄簭
+                dicDeviceSort[device.CurrentGateWayId].Add(device.DeviceAddr);
+                UserCenterLogic.SaveFileContent(UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DeviceSortFile), dicDeviceSort);
+            }
             string mainKeys = this.GetDeviceMainKeys(device);
             //濡傛灉瀹冩槸鍗囩骇鐨勯《绔鐐�,鍒欎笉鑳借瀹冨姞鍏ュ埌缂撳瓨锛屼絾鏄彲浠ヨ浠栫敓鎴愭枃浠�
             if (device is OTADevice)
@@ -329,17 +349,20 @@
                 return;
             }
 
-            if (this.dicAllDevice.ContainsKey(mainKeys) == true)
+            lock (dicAllDevice)
             {
-                //浜ゆ崲灞炴��
-                var tempDevice = this.dicAllDevice[mainKeys];
-                //灏咲eviceInfo鐨勫睘鎬ц缃埌涓诲睘鎬т腑
-                this.SetDeviceInfoToMain(tempDevice, device);
-                device = tempDevice;
-            }
-            else
-            {
-                this.dicAllDevice[mainKeys] = device;
+                if (this.dicAllDevice.ContainsKey(mainKeys) == true)
+                {
+                    //浜ゆ崲灞炴��
+                    var tempDevice = this.dicAllDevice[mainKeys];
+                    //灏咲eviceInfo鐨勫睘鎬ц缃埌涓诲睘鎬т腑
+                    this.SetDeviceInfoToMain(tempDevice, device);
+                    device = tempDevice;
+                }
+                else
+                {
+                    this.dicAllDevice[mainKeys] = device;
+                }
             }
 
             //璁惧鍥炶矾鏀堕泦
@@ -456,16 +479,19 @@
         /// <param name="device"></param>
         private void BackupDeviceAfterReName(CommonDevice device)
         {
-            string mainKeys = this.GetDeviceMainKeys(device);
-            if (this.dicAllDevice.ContainsKey(mainKeys) == false)
+            lock (dicAllDevice)
             {
-                return;
-            }
-            this.dicAllDevice[mainKeys] = device;
-            device.ReSave();
+                string mainKeys = this.GetDeviceMainKeys(device);
+                if (this.dicAllDevice.ContainsKey(mainKeys) == false)
+                {
+                    return;
+                }
+                this.dicAllDevice[mainKeys] = device;
+                device.ReSave();
 
-            //娣诲姞鑷姩澶囦唤
-            HdlAutoBackupLogic.AddOrEditorFile(device.FilePath);
+                //娣诲姞鑷姩澶囦唤
+                HdlAutoBackupLogic.AddOrEditorFile(device.FilePath);
+            }
         }
 
         #endregion
@@ -495,6 +521,13 @@
                 this.ShowErrorMsg(msg);
                 return false;
             }
+            if (dicDeviceSort.ContainsKey(listdevice[0].CurrentGateWayId) == true &&
+                dicDeviceSort[listdevice[0].CurrentGateWayId].Contains(info.DeviceAddr) == true)
+            {
+                //淇濆瓨椤哄簭
+                dicDeviceSort[listdevice[0].CurrentGateWayId].Remove(info.DeviceAddr);
+                UserCenterLogic.SaveFileContent(UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DeviceSortFile), dicDeviceSort);
+            }
 
             //鍒犻櫎鏂囦欢
             foreach (CommonDevice device in listdevice)
@@ -513,9 +546,12 @@
         {
             //鍒犻櫎缂撳瓨
             string mainKeys = this.GetDeviceMainKeys(device);
-            if (this.dicAllDevice.ContainsKey(mainKeys) == true)
+            lock (dicAllDevice)
             {
-                this.dicAllDevice.Remove(mainKeys);
+                if (this.dicAllDevice.ContainsKey(mainKeys) == true)
+                {
+                    this.dicAllDevice.Remove(mainKeys);
+                }
             }
 
             //鍒犻櫎璁惧鏂囦欢
@@ -645,13 +681,34 @@
         public List<CommonDevice> GetDeviceByGatewayID(string gwId)
         {
             List<CommonDevice> list = new List<CommonDevice>();
-            //鍚勭綉鍏崇殑鎵�鏈夎澶�
-            foreach (CommonDevice device in this.dicAllDevice.Values)
+            lock (dicAllDevice)
             {
-                if (gwId == device.CurrentGateWayId)
+                List<string> listSort = null;
+                if (dicDeviceSort.ContainsKey(gwId) == false)
                 {
-                    list.Add(device);
+                    dicDeviceSort[gwId] = new List<string>();
                 }
+                listSort = dicDeviceSort[gwId];
+
+                //鍚勭綉鍏崇殑鎵�鏈夎澶�
+                foreach (CommonDevice device in this.dicAllDevice.Values)
+                {
+                    if (gwId == device.CurrentGateWayId)
+                    {
+                        if (listSort.Contains(device.DeviceAddr) == false)
+                        {
+                            listSort.Add(device.DeviceAddr);
+                        }
+                    }
+                }
+                //鎺掑簭
+                foreach (var strMac in listSort)
+                {
+                    var listTemp = this.GetDevicesByMac(strMac);
+                    list.AddRange(listTemp);
+                }
+                //淇濆瓨椤哄簭
+                UserCenterLogic.SaveFileContent(UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DeviceSortFile), dicDeviceSort);
             }
 
             return list;
@@ -664,9 +721,12 @@
         /// <returns></returns>
         public CommonDevice GetDevice(string mainKeys)
         {
-            if (this.dicAllDevice.ContainsKey(mainKeys) == true)
+            lock (dicAllDevice)
             {
-                return this.dicAllDevice[mainKeys];
+                if (this.dicAllDevice.ContainsKey(mainKeys) == true)
+                {
+                    return this.dicAllDevice[mainKeys];
+                }
             }
             return null;
         }
@@ -1293,7 +1353,7 @@
             {
                 info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId9;
                 info.BeloneType = DeviceBeloneType.A褰╃伅;
-                info.ConcreteType = DeviceConcreteType.ColorDimmableLight;
+                info.ConcreteType = DeviceConcreteType.ColorLight;
             }
             //8绌鸿皟
             else if (dicType.ContainsKey(DeviceType.Thermostat) == true)
@@ -1454,94 +1514,72 @@
         #region 鈻� 璁惧鎺掑簭___________________________
 
         /// <summary>
+        /// 鍒濆鍖栬澶囬『搴�
+        /// </summary>
+        private void InitDeviceSort()
+        {
+            //璇诲彇璁惧椤哄簭
+            this.dicDeviceSort = new Dictionary<string, List<string>>();
+            string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DeviceSortFile);
+            var strData = UserCenterLogic.LoadFileContent(fullName);
+            if (strData != null)
+            {
+                this.dicDeviceSort = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, List<string>>>(strData);
+            }
+            foreach (var device in dicAllDevice.Values)
+            {
+                if (dicDeviceSort.ContainsKey(device.CurrentGateWayId) == false)
+                {
+                    dicDeviceSort[device.CurrentGateWayId] = new List<string>();
+                }
+                if (dicDeviceSort[device.CurrentGateWayId].Contains(device.DeviceAddr) == false)
+                {
+                    //鏂版坊鍔犵殑璁惧
+                    dicDeviceSort[device.CurrentGateWayId].Add(device.DeviceAddr);
+                }
+            }
+            foreach (var keys in dicDeviceSort.Keys)
+            {
+                var list = dicDeviceSort[keys];
+                for (int i = 0; i < list.Count; i++)
+                {
+                    if (this.dicDeviceEpoint.ContainsKey(list[i]) == false)
+                    {
+                        //杩欎釜涓滆タ鑾悕鐨勪笉瑙佷簡锛熷拰璁惧鍒楄〃鍖归厤涓嶄笂?
+                        list.RemoveAt(i);
+                        i--;
+                    }
+                }
+            }
+
+            //淇濆瓨椤哄簭
+            UserCenterLogic.SaveFileContent(fullName, dicDeviceEpoint);
+        }
+
+        /// <summary>
         /// 璁惧鎺掑簭
         /// </summary>
-        /// <param name="listDevice">璁惧瀵硅薄</param>
+        /// <param name="listDevice">闇�瑕佹帓搴忕殑璁惧鍒楄〃</param>
         /// <returns></returns>
-        public List<CommonDevice> SortDeviceList(List<CommonDevice> listDevice)
+        public List<CommonDevice> SortDevice(List<CommonDevice> listDevice)
         {
-            List<CommonDevice> listSort = new List<CommonDevice>();
-            var list = this.SortDeviceListByRule(listDevice);
-            listSort.AddRange(list);
-
-            return listSort;
-        }
-
-        /// <summary>
-        /// 
-        /// </summary>
-        /// <param name="listDevice">璁惧瀵硅薄</param>
-        /// <returns></returns>
-        private List<CommonDevice> SortDeviceListByRule(List<CommonDevice> listDevice)
-        {
-            //璁惧鎺掑簭鐨勮鍒�(Keys锛氳澶囩被鍨�(DeviceType)  value锛氬瓨鏀捐澶囩殑瀹瑰櫒)
-            var dic = this.GetDeviceSortRule();
-            foreach (CommonDevice device in listDevice)
+            var dic = new Dictionary<string, CommonDevice>();
+            for (int i = 0; i < listDevice.Count; i++)
             {
-                if (device is IASZone)
+                dic[(this.GetDeviceMainKeys(listDevice[i]))] = listDevice[i];
+            }
+            var list = new List<CommonDevice>();
+            foreach (var listSort in this.dicDeviceSort.Values)
+            {
+                for (int i = 0; i < listSort.Count; i++)
                 {
-                    //浼犳劅鍣ㄦ湁寰堝绉�
-                    var strType = ((IASZone)device).DeviceInfo.DeviceType.ToString();
-                    if (dic.ContainsKey(strType) == false || dic[strType] == null)
+                    if (dic.ContainsKey(listSort[i]) == true)
                     {
-                        dic[strType] = new List<CommonDevice>();
+                        list.Add(dic[listSort[i]]);
                     }
-                    dic[strType].Add(device);
-                    continue;
-                }
-                string checkKeys = device.Type.ToString();
-                if (dic.ContainsKey(checkKeys) == false || dic[checkKeys] == null)
-                {
-                    dic[checkKeys] = new List<CommonDevice>();
-                }
-                dic[checkKeys].Add(device);
-            }
-
-            List<CommonDevice> lstSort = new List<CommonDevice>();
-            foreach (var list in dic.Values)
-            {
-                if (list != null && list.Count > 0)
-                {
-                    lstSort.AddRange(list);
                 }
             }
-            return lstSort;
-        }
-
-        /// <summary>
-        /// 鑾峰彇璁惧鎺掑簭鐨勮鍒�(Keys锛氳澶囩被鍨�(DeviceType)  value锛氬瓨鏀捐澶囩殑瀹瑰櫒)
-        /// </summary>
-        /// <returns></returns>
-        private Dictionary<string, List<CommonDevice>> GetDeviceSortRule()
-        {
-            var dic = new Dictionary<string, List<CommonDevice>>();
-            //鎺у埗闈㈡澘
-            dic[DeviceType.OnOffSwitch.ToString()] = null;
-            //鍗峰笜
-            dic[DeviceType.WindowCoveringDevice.ToString()] = null;
-            //璋冨厜鐏�
-            dic[DeviceType.ColorDimmableLight.ToString()] = null;
-            //缁х數鍣�
-            dic[DeviceType.OnOffOutput.ToString()] = null;
-            //绌烘皵寮�鍏�
-            dic[DeviceType.AirSwitch.ToString()] = null;
-            //闂ㄧ獥纾佷紶鎰熷櫒
-            dic["21"] = null;
-            dic["22"] = null;
-            //姘存蹈浼犳劅鍣�
-            dic["42"] = null;
-            //鐑熼浘浼犳劅鍣�
-            dic["40"] = null;
-            //绱ф�ユ寜閽�
-            dic["44"] = null;
-            //鐕冩皵浼犳劅鍣�
-            dic["43"] = null;
-            //杩愬姩浼犳劅鍣�
-            dic["13"] = null;
-            //閽ュ寵鎵�
-            dic["277"] = null;
-
-            return dic;
+            return list;
         }
 
         #endregion
@@ -1647,14 +1685,40 @@
         #region 鈻� 鑾峰彇璁惧鍒楄〃鐨勬帴鍙________________
 
         /// <summary>
-        /// 浠庣綉鍏抽噸鏂拌幏鍙栬澶囧垪琛�(鈽呪槄鈽呪槄鈽呪槄鈽呮帴鏀跺埌璁惧鏃剁殑浜嬩欢,璁惧瀵硅薄涓簄ull鏃�,浠h〃鎺ユ敹瀹屾垚鈽呪槄鈽呪槄鈽呪槄鈽�)
+        /// 浠庣綉鍏抽噸鏂拌幏鍙栬澶囧垪琛�(鈽呪槄鈽呪槄鈽呪槄鈽呮帴鏀跺埌璁惧鏃剁殑浜嬩欢鈽呪槄鈽呪槄鈽呪槄鈽�)
         /// </summary>
         /// <param name="zbGateway">缃戝叧瀵硅薄</param>
-        /// <param name="deviceComingAction">鎺ユ敹鍒拌澶囨椂鐨勪簨浠�,璁惧瀵硅薄涓簄ull鏃�,浠h〃鎺ユ敹瀹屾垚</param>
+        /// <param name="ignoreTime">鏄惁鏃犺鏃堕棿,true:姣忔璋冪敤閮藉幓缃戝叧鑾峰彇,false:3鍒嗛挓鍐呰繑鍥炵殑鏄湰鍦扮殑璁惧</param>
+        /// <param name="deviceComingAction">鎺ユ敹鍒拌澶囨椂鐨勪簨浠�</param>
         /// <param name="mode">鏄惁鏄剧ず閿欒</param>
         /// <returns></returns>
-        public async Task<List<CommonDevice>> GetDeviceListFromGateway(ZbGateway zbGateway, Action<CommonDevice> deviceComingAction = null, ShowErrorMode mode = ShowErrorMode.YES)
+        public async Task<List<CommonDevice>> GetDeviceListFromGateway(ZbGateway zbGateway, bool ignoreTime, Action<CommonDevice> deviceComingAction = null, ShowErrorMode mode = ShowErrorMode.YES)
         {
+            if (ignoreTime == false)
+            {
+                if ((DateTime.Now - zbGateway.LastDateTime).TotalMilliseconds < 3 * 60 * 1000)
+                {
+                    //涓嶆棤瑙嗘椂闂�,杩斿洖鏈湴璁惧鍒楄〃
+                    var listTemp = this.GetDeviceByGatewayID(HdlGatewayLogic.Current.GetGatewayId(zbGateway));
+                    if (deviceComingAction != null)
+                    {
+                        for (int i = 0; i < listTemp.Count; i++)
+                        {
+                            try
+                            {
+                                //鍥炶皟鍑芥暟
+                                deviceComingAction.Invoke(listTemp[i]);
+                            }
+                            //Log鍑哄姏
+                            catch (Exception ex) { HdlLogLogic.Current.WriteLog(ex); }
+                        }
+                    }
+                    deviceComingAction = null;
+                    return listTemp;
+                }
+            }
+            zbGateway.LastDateTime = DateTime.Now;
+
             //濡傛灉鍒囨崲鍒颁簡鍒殑鐣岄潰锛屽垯涓嶆樉绀洪敊璇俊鎭�
             string nowFormId = UserCenterResourse.NowActionFormID;
 
@@ -1711,8 +1775,13 @@
                         var device = this.NewDeviceObjectByDeviceId(deviceID, jobject, zbGateway);
                         if (device != null)
                         {
-                            //鍥炶皟鍑芥暟
-                            deviceComingAction?.Invoke(device);
+                            try
+                            {
+                                //鍥炶皟鍑芥暟
+                                deviceComingAction?.Invoke(device);
+                            }
+                            //Log鍑哄姏
+                            catch (Exception ex) { HdlLogLogic.Current.WriteLog(ex); }
 
                             listDevice.Add(device);
                         }
@@ -1769,8 +1838,7 @@
                 }
             }
 
-            //鍥炶皟鍑芥暟(鎺ユ敹瀹屾垚)
-            deviceComingAction?.Invoke(null);
+            //鍥炶皟鍑芥暟(鎺ユ敹瀹屾垚)
             deviceComingAction = null;
 
             return listDevice;
@@ -1837,6 +1905,7 @@
             mainDevice.DriveCode = device.DeviceInfo.DriveCode;
             mainDevice.IasDeviceType = device.DeviceInfo.DeviceType;
             mainDevice.Profile = device.DeviceInfo.Profile;
+            mainDevice.Type = device.Type;
 
             //鍥轰欢鐗堟湰
             mainDevice.ImgVersion = device.DeviceInfo.ImgVersion;
@@ -1857,9 +1926,9 @@
             mainDevice.OutClusterList.AddRange(device.DeviceInfo.OutClusterList);
             mainDevice.AttributeStatus.Clear();
             mainDevice.AttributeStatus.AddRange(device.DeviceInfo.AttributeStatus);
-            
+
             //濡傛灉鏄俯搴︿紶鎰熷櫒
-            if (mainDevice is TemperatureSensor)
+            if (mainDevice.Type == DeviceType.TemperatureSensor)
             {
                 //杈撳嚭鏃� 1026:娓╁害浼犳劅鍣� 1029:婀垮害浼犳劅鍣�
                 foreach (var data in mainDevice.OutClusterList)
@@ -1872,6 +1941,24 @@
                     {
                         ((TemperatureSensor)mainDevice).SensorDiv = 1;
                     }
+                }
+            }
+            //濡傛灉鏄皟鍏夊櫒
+            else if (mainDevice.Type == DeviceType.DimmableLight )
+            {
+                mainDevice.DfunctionType = DeviceFunctionType.A鐏厜;
+                if (mainDevice.IsCustomizeImage == false)
+                {
+                    mainDevice.IconPath = "Device/Light.png";
+                }
+            }
+            //濡傛灉鏄僵鐏殑璇�
+            else if ( mainDevice.Type == DeviceType.ColorDimmableLight)
+            {
+                mainDevice.DfunctionType = DeviceFunctionType.A鐏厜;
+                if (mainDevice.IsCustomizeImage == false)
+                {
+                    mainDevice.IconPath = "Device/ColorLight.png";
                 }
             }
         }
@@ -1998,4 +2085,266 @@
 
         #endregion
     }
+
+    #region 鈻� 鑷畾涔夎澶囩被鍨媉________________________
+
+    /// <summary>
+    /// <para>浠呴檺搴曞眰浣跨敤锛氳澶囩殑鍏蜂綋銆愯澶囩被鍨嬨��,鑷畾涔変笌妯″潡id鍏宠仈鐨勬灇涓�(鍊间负LocalDevice閲岄潰dicDeviceModelIdEnum鎵�鎸囧畾鐨勫��)</para>
+    /// <para>鍙橀噺鍚嶅彲浠ヤ綔涓恒�愯澶囩被鍨嬨�戝浘鐗�,杩欎釜鍊兼槸鐬庡啓鐨�,娌′粈涔堢壒娈婃剰涔�</para>
+    /// </summary>
+    public enum DeviceConcreteType
+    {
+        //瀹氫箟瑙勫垯锛氥�愯澶囩被鍨嬨�戝浘鐗囧悕瀛�=LocalDevice閲岄潰dicDeviceModelIdEnum鎵�鎸囧畾鐨勫��
+
+        /// <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,
+
+        //=========鈽呪槄PIR浼犳劅鍣ㄧ被(1200-1299)鈽呪槄=========
+        /// <summary>
+        /// 浼犳劅鍣�
+        /// </summary>
+        Sensor = -1200,
+        /// <summary>
+        /// pir浼犳劅鍣�220 闀滃儚id锛�1200
+        /// </summary>
+        Sensor_Pir = 1200,
+
+        //=========鈽呪槄瀹夐槻绫讳紶鎰熷櫒绫�(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_Motion = -1306,
+        /// <summary>
+        /// 閽ュ寵鎵�
+        /// </summary>
+        Sensor_Keyfob = -1307,
+        /// <summary>
+        /// 娓╂箍搴︿紶鎰熷櫒
+        /// </summary>
+        Sensor_TemperatrueHumidity = -1308,
+        /// <summary>
+        /// 娓╁害浼犳劅鍣�
+        /// </summary>
+        Sensor_Temperatrue = -1309,
+        /// <summary>
+        /// 婀垮害浼犳劅鍣�
+        /// </summary>
+        Sensor_Humidity = -1310,
+
+        //=========鈽呪槄缁х數鍣ㄧ被(2300-2499)鈽呪槄=========
+        /// <summary>
+        /// 缁х數鍣�
+        /// </summary>
+        Relay = -2300,
+        /// <summary>
+        /// 涓夎矾缁х數鍣� 闀滃儚id锛�2300
+        /// </summary>
+        Relay_ThreeLoad = 2300,
+
+        //=========鈽呪槄璋冨厜鍣ㄧ被(2500-2799)鈽呪槄=========
+        /// <summary>
+        /// 璋冨厜鍣�
+        /// </summary>
+        DimmableLight = -2500,
+        /// <summary>
+        /// 1璺皟鍏夊櫒灏忔ā鍧�
+        /// </summary>
+        DimmableLight_OneLoad = 2500,
+
+        //=========鈽呪槄鏅鸿兘闂ㄩ攣绫�(2800-????)鈽呪槄=========
+        /// <summary>
+        /// 鏅鸿兘闂ㄩ攣
+        /// </summary>
+        IntelligentLocks = -2800,
+        /// <summary>
+        /// H06C
+        /// </summary>
+        IntelligentLocks_H06C = 2800,
+
+        //=========鈽呪槄褰╃伅绫�(????-????)鈽呪槄=========
+        /// <summary>
+        /// 褰╃伅
+        /// </summary>
+        ColorLight = -10,
+
+        //=========鈽呪槄绌鸿皟(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,
+    }
+
+    /// <summary>
+    /// <para>浠呴檺搴曞眰浣跨敤锛氳澶囨墍灞炵殑銆愯澶囩绫汇��,鑷畾涔変笌妯″潡id鍏宠仈鐨勬灇涓�(鍊间负LocalDevice閲岄潰dicDeviceModelIdEnum鎵�鎸囧畾鐨勫��)</para>
+    /// <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>
+        /// 缁х數鍣�(2300-2499)
+        /// </summary>
+        A缁х數鍣� = 2300,
+        /// <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>
+        /// 褰╃伅
+        /// </summary>
+        A褰╃伅 = 9,
+        /// <summary>
+        /// 娓╂箍搴︿紶鎰熷櫒
+        /// </summary>
+        A娓╂箍搴︿紶鎰熷櫒 = 10,
+        /// <summary>
+        /// 娓╁害浼犳劅鍣�
+        /// </summary>
+        A娓╁害浼犳劅鍣� = 11,
+        /// <summary>
+        /// 婀垮害浼犳劅鍣�
+        /// </summary>
+        A婀垮害浼犳劅鍣� = 12
+    }
+
+    #endregion
 }

--
Gitblit v1.8.0