From 0e0584b87851c56745bf73b1a961b80613dd0721 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期二, 19 五月 2020 16:35:16 +0800
Subject: [PATCH] 2020-05-19-4

---
 ZigbeeApp/Shared/Common/Device.cs |  320 ++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 276 insertions(+), 44 deletions(-)

diff --git a/ZigbeeApp/Shared/Common/Device.cs b/ZigbeeApp/Shared/Common/Device.cs
index fa6b160..8426b1a 100755
--- a/ZigbeeApp/Shared/Common/Device.cs
+++ b/ZigbeeApp/Shared/Common/Device.cs
@@ -292,9 +292,9 @@
                     //鍦ㄧ鐐瑰悕瀛楃殑鍚庨潰闄勫姞銆愬洖璺�戝瓧鏍�
                     dName += "(" + device.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + ")";
 
-                    HdlThreadLogic.Current.RunThread(async () =>
+                    HdlThreadLogic.Current.RunThread(() =>
                     {
-                        await this.ReName(device, dName, ShowErrorMode.NO);
+                        this.ReName(device, dName, ShowErrorMode.NO);
                     });
                 }
             }
@@ -431,7 +431,7 @@
         /// <param name="device">璁惧瀵硅薄</param>
         /// <param name="newName">鏂板悕瀛�</param>
         /// <param name="mode">鏄惁鏄剧ず閿欒</param>
-        public async Task<bool> ReName(CommonDevice device, string newName, ShowErrorMode mode = ShowErrorMode.YES)
+        public bool ReName(CommonDevice device, string newName, ShowErrorMode mode = ShowErrorMode.YES)
         {
             //鍏堝埆绠¢偅涔堝锛屾洿鏀瑰悕瀛楀悗锛屽埛鏂拌澶囩紦瀛�
             this.SetEpointName(device, newName);
@@ -441,6 +441,8 @@
             //濡傛灉浣忓畢涓鸿櫄鎷熶綇瀹�
             if (Common.Config.Instance.Home.IsVirtually == true)
             {
+                //淇敼璁惧鍚嶅瓧鐨勮瘽,涓婚〉闇�瑕侀噸鏂板埛鏂�
+                Phone.UserView.UserPage.Instance.RefreshForm = true;
                 return true;
             }
 
@@ -448,7 +450,7 @@
             //鎴愬憳鍙兘淇敼鑷繁鏈湴鐨勫悕瀛�
             if (UserCenterResourse.UserInfo.AuthorityNo != 3)
             {
-                var result = await device.RenameDeviceNameAsync(device.DeviceAddr, device.DeviceEpoint, newName);
+                var result = this.RenameDeviceNameAsync(device, newName);
                 if (result == null || result.deviceRenameData == null || result.deviceRenameData.Result == 1)
                 {
                     //璁惧鍚嶇О淇敼澶辫触
@@ -462,9 +464,9 @@
                     }
                     return false;
                 }
-                //澶囦唤鏁版嵁
-                await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(device, GatewayBackupEnum.A绔偣鍚嶇О, newName);
             }
+            //淇敼璁惧鍚嶅瓧鐨勮瘽,涓婚〉闇�瑕侀噸鏂板埛鏂�
+            Phone.UserView.UserPage.Instance.RefreshForm = true;
             return true;
         }
 
@@ -474,7 +476,7 @@
         /// <param name="listDevice">璁惧瀵硅薄</param>
         /// <param name="newMacName">鏂板悕瀛�</param>
         /// <param name="mode">鏄惁鏄剧ず閿欒</param>
-        public async Task<bool> ReMacName(List<CommonDevice> listDevice, string newMacName, ShowErrorMode mode = ShowErrorMode.YES)
+        public bool ReMacName(List<CommonDevice> listDevice, string newMacName, ShowErrorMode mode = ShowErrorMode.YES)
         {
             if (listDevice.Count == 0)
             {
@@ -502,7 +504,7 @@
             if (UserCenterResourse.UserInfo.AuthorityNo != 3)
             {
                 //淇敼鐗╃悊鍚嶅瓧
-                var result = await device.RenameDeviceMacNameAsync(device.DeviceAddr, device.DeviceEpoint, newMacName);
+                var result = this.RenameDeviceMacNameAsync(device, newMacName);
                 if (result == null || result.renameDeviceMacNameData == null || result.renameDeviceMacNameData.Result != 0)
                 {
                     //璁惧鍚嶇О淇敼澶辫触
@@ -515,15 +517,13 @@
                     }
                     return false;
                 }
-                //澶囦唤鏁版嵁
-                await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(device, GatewayBackupEnum.AMac鍚嶇О, newMacName);
                 //濡傛灉瀹冨彧鏈変竴涓洖璺�,鍒欐洿鏀圭鐐瑰悕瀛�
                 if (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == true)
                 {
                     //鍙湁涓�涓鐐�
                     if (this.dicDeviceEpoint[device.DeviceAddr].Count == 1)
                     {
-                        return await this.ReName(device, newMacName);
+                        return this.ReName(device, newMacName);
                     }
                     //濡傛灉瀹冩湁涓や釜绔偣鏃�,pir浼犳劅鍣ㄧ壒娈婂鐞�
                     else if (this.dicDeviceEpoint[device.DeviceAddr].Count == 2)
@@ -535,7 +535,7 @@
                             {
                                 if (myDevice.Type == DeviceType.IASZone)
                                 {
-                                    return await this.ReName(myDevice, newMacName);
+                                    return this.ReName(myDevice, newMacName);
                                 }
                             }
                         }
@@ -543,6 +543,100 @@
                 }
             }
             return true;
+        }
+
+        ///<summary >
+        /// 淇敼璁惧mac鍚嶇О
+        /// <para>macName:璁惧鍚嶇О</para>
+        /// </summary>
+        private CommonDevice.RenameDeviceMacNameAllData RenameDeviceMacNameAsync(CommonDevice device, string macName)
+        {
+            //濡傛灉褰撳墠鏄櫄鎷熶綇瀹�
+            if (Common.Config.Instance.Home.IsVirtually == true)
+            {
+                return Phone.ModelData.DeviceModelDataLogic.Current.ReDeviceMacName(device, macName, "MacRename");
+            }
+
+            //鑾峰彇缂栬緫璁惧Mac鍚嶅瓧鐨勫懡浠ゅ瓧绗�
+            var sendData = this.GetReDeviceMacNameCommandText(device.DeviceAddr, device.DeviceEpoint, macName);
+            var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "MacRename", sendData, "MacRename_Respon");
+            if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
+            {
+                return null;
+            }
+            //鍔犵紦瀛�
+            Phone.ModelData.DeviceModelDataLogic.Current.ReDeviceMacName(device, macName, "MacRename");
+
+            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.ModelData.DeviceModelDataLogic.Current.ReDeviceEpointName(device, deviceName, "DeviceRename");
+            }
+            //鑾峰彇缂栬緫璁惧绔偣鍚嶅瓧鐨勫懡浠ゅ瓧绗�
+            var sendData = this.GetReDeviceEpointNameCommandText(device.DeviceAddr, device.DeviceEpoint, deviceName);
+            var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "DeviceRename", sendData, "DeviceRenameRespon");
+            if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
+            {
+                return null;
+            }
+            //鍔犵紦瀛�
+            Phone.ModelData.DeviceModelDataLogic.Current.ReDeviceEpointName(device, deviceName, "DeviceRename");
+
+            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>
@@ -628,6 +722,9 @@
         /// <param name="deleteRoom">鏄惁浠庢埧闂村垹闄�</param>
         public void DeleteMemmoryDevice(CommonDevice device, bool deleteRoom = true)
         {
+            //鍒犻櫎缂撳瓨璁惧鐨勮瘽,涓婚〉闇�瑕侀噸鏂板埛鏂�
+            Phone.UserView.UserPage.Instance.RefreshForm = true;
+
             if (deleteRoom == true)
             {
                 //浠庢埧闂翠腑鍒犻櫎
@@ -725,7 +822,7 @@
         /// <returns></returns>
         public bool DeviceIsCanFixedPosition(CommonDevice device)
         {
-            if (device.Type == DeviceType.DoorLock)
+            if (device.Type == DeviceType.DoorLock || device.Type == DeviceType.PMSensor)
             {
                 //闂ㄩ攣娌℃湁瀹氫綅鍔熻兘
                 return false;
@@ -1324,7 +1421,7 @@
         }
 
         /// <summary>
-        /// 璁剧疆銆愯澶囩被鍨嬨�戠殑鍥炬爣鍒版寚瀹氱殑鎺т欢
+        /// 璁剧疆銆愯澶囩被鍨嬨�戠殑鍥炬爣鍒版寚瀹氱殑鎺т欢(姝ゆ柟娉曚笉鑳界敤鍦ㄨ澶囧姛鑳界被鍨嬭彍鍗曠殑鍥炬爣)
         /// </summary>
         /// <param name="btnIcon">鎺т欢瀵硅薄</param>
         /// <param name="listdevice">璁惧瀵硅薄</param>
@@ -1346,7 +1443,7 @@
         }
 
         /// <summary>
-        /// 鑾峰彇銆愯澶囩被鍨嬨�戠殑鍥炬爣
+        /// 鑾峰彇銆愯澶囩被鍨嬨�戠殑鍥炬爣(姝ゆ柟娉曚笉鑳界敤鍦ㄨ澶囧姛鑳界被鍨嬭彍鍗曠殑鍥炬爣)
         /// </summary>
         /// <param name="listdevice">璁惧瀵硅薄</param>
         /// <param name="unSelectPath">鍥剧墖鍦板潃</param>
@@ -1362,13 +1459,42 @@
         }
 
         /// <summary>
-        /// 鑾峰彇銆愯澶囩被鍨嬨�戠殑鍥炬爣
+        /// 鑾峰彇銆愯澶囧姛鑳界被鍨嬨�戠殑鑿滃崟鍥炬爣
         /// </summary>
         /// <param name="specificType">鑷畾涔夎澶囩被鍨�</param>
         /// <param name="unSelectPath">鍥剧墖鍦板潃</param>
         /// <param name="selectPath">鍥剧墖鍦板潃</param>
         /// <returns></returns>
-        public void GetDeviceObjectIcon(DeviceConcreteType specificType, ref string unSelectPath, ref string selectPath)
+        public void GetDeviceFunctionTypeMenuIcon(DeviceConcreteType specificType, ref string unSelectPath, ref string selectPath)
+        {
+            //鏂伴灏忔ā鍧�
+            if (specificType == DeviceConcreteType.Relay_FangyueFreshAirModul)
+            {
+                unSelectPath = "Device/FreshAirEpoint.png";
+                selectPath = "Device/FreshAirEpointSelected.png";
+                return;
+            }
+            //PM2.5绌烘皵璐ㄩ噺浼犳劅鍣�
+            else if (specificType == DeviceConcreteType.Sensor_PMTwoPointFive)
+            {
+                unSelectPath = "Device/AirQualitySensorEpoint.png";
+                selectPath = "Device/AirQualitySensorEpointSelected.png";
+                return;
+            }
+            //涓婇潰闇�瑕佺壒娈婂鐞�
+
+            //鑾峰彇銆愯澶囩被鍨嬨�戠殑鍥炬爣
+            this.GetDeviceObjectIcon(specificType, 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);
@@ -1811,6 +1937,14 @@
                 info.ConcreteType = DeviceConcreteType.Relay_FangyueFreshAirModul;
                 info.ObjectTypeNameId = 60011;//鏂伴
             }
+            //15 PM2.5浼犳劅鍣ㄨ澶�
+            else if (dicType.ContainsKey(DeviceType.PMSensor) == true)
+            {
+                info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId1307;
+                info.BeloneType = DeviceBeloneType.APM2鐐�5绌烘皵璐ㄩ噺浼犳劅鍣�;
+                info.ConcreteType = DeviceConcreteType.Sensor_PMTwoPointFive;
+                info.ObjectTypeNameId = 60000;//浼犳劅鍣�
+            }
 
             int value = (int)info.BeloneType;
             if (dicDeviceAllNameID.ContainsKey("uDeviceBelongId" + value) == true)
@@ -1909,26 +2043,10 @@
         /// <param name="saveRoadDevice">濡傛灉鍙湁涓�涓洖璺�,鏄惁鎶婂洖璺殑鎴块棿涓�璧蜂慨鏀�</param>
         public void SaveRealDeviceRoomId(List<CommonDevice> listDevice, string roomId, bool saveRoadDevice = true)
         {
-            if (listDevice != null)
+            if (listDevice == null)
             {
-                if (roomId == string.Empty)
-                {
-                    //閫夋嫨鐨勬槸鏈垎閰�
-                    this.dicDeviceRoomId.Remove(listDevice[0].DeviceAddr);
-                }
-                else
-                {
-                    this.dicDeviceRoomId[listDevice[0].DeviceAddr] = roomId;
-                }
+                return;
             }
-
-            //淇濆瓨璁板綍
-            string fullName = UserCenterLogic.CombinePath(DirNameResourse.DeviceRoomIdFile);
-            UserCenterLogic.SaveFileContent(fullName, this.dicDeviceRoomId);
-
-            //娣诲姞鑷姩澶囦唤
-            HdlAutoBackupLogic.AddOrEditorFile(DirNameResourse.DeviceRoomIdFile);
-
             //濡傛灉璁惧鍙湁涓�涓洖璺紝濡傛灉鏀瑰彉浜嗙湡瀹炶澶囧尯鍩燂紝鍒欏畠鐨勫洖璺殑鍖哄煙涔熶竴璧锋敼浜�
             if (saveRoadDevice == true && listDevice != null && listDevice.Count == 1)
             {
@@ -1938,6 +2056,41 @@
                     return;
                 }
                 HdlRoomLogic.Current.ChangedRoom(listDevice[0], roomId, false);
+            }
+            bool save = false;
+            if (roomId == string.Empty)
+            {
+                //閫夋嫨鐨勬槸鏈垎閰�
+                this.dicDeviceRoomId.Remove(listDevice[0].DeviceAddr);
+                save = true;
+            }
+            else
+            {
+                if (this.dicDeviceRoomId.ContainsKey(listDevice[0].DeviceAddr) == false)
+                {
+                    this.dicDeviceRoomId[listDevice[0].DeviceAddr] = roomId;
+                    save = true;
+                }
+                else
+                {
+                    //2020.05.18杩藉姞:濡傛灉璁板綍鐨勬埧闂碔D鏄笉瀛樺湪鐨勮瘽,鍒欓噸鏂拌鐩�
+                    var room = HdlRoomLogic.Current.GetRoomById(this.dicDeviceRoomId[listDevice[0].DeviceAddr]);
+                    if (room == null)
+                    {
+                        this.dicDeviceRoomId[listDevice[0].DeviceAddr] = roomId;
+                        save = true;
+                    }
+                }
+            }
+
+            if (save == true)
+            {
+                //淇濆瓨璁板綍
+                string fullName = UserCenterLogic.CombinePath(DirNameResourse.DeviceRoomIdFile);
+                UserCenterLogic.SaveFileContent(fullName, this.dicDeviceRoomId);
+
+                //娣诲姞鑷姩澶囦唤
+                HdlAutoBackupLogic.AddOrEditorFile(DirNameResourse.DeviceRoomIdFile);
             }
         }
 
@@ -2007,6 +2160,25 @@
 
             //娣诲姞鑷姩澶囦唤
             HdlAutoBackupLogic.AddOrEditorFile(DirNameResourse.DeviceRoomIdFile);
+        }
+
+        /// <summary>
+        /// 鏍规嵁鎴块棿ID,绉婚櫎鎸囧畾鐨勭湡瀹炵墿鐞嗚澶囩殑鎵�灞炴埧闂磋褰�
+        /// </summary>
+        /// <param name="i_RoomId"></param>
+        public void DeleteRealDeviceByRoomId(string i_RoomId)
+        {
+            var listDeleteKey = new List<string>();
+            foreach (var deviceAddr in this.dicDeviceRoomId.Keys)
+            {
+                if (this.dicDeviceRoomId[deviceAddr] == i_RoomId
+                    && listDeleteKey.Contains(deviceAddr) == false)
+                {
+                    listDeleteKey.Add(deviceAddr);
+                }
+            }
+            //灏嗙湡瀹炵墿鐞嗚澶囦粠鎴块棿涓Щ闄�
+            this.DeleteRealDeviceFromRoom(listDeleteKey);
         }
 
         #endregion
@@ -2086,6 +2258,39 @@
 
         #endregion
 
+        #region 鈻� 鑾峰彇璁惧鍦ㄧ嚎鐘舵�佸垪琛╛______________
+
+        /// <summary>
+        /// 鑾峰彇璁惧鍦ㄧ嚎鐘舵�佸垪琛�(娉ㄦ剰,涓�涓澶囧彧杩斿洖涓�涓洖璺�)
+        /// </summary>
+        /// <param name="gwId">缃戝叧id</param>
+        /// <returns></returns>
+        public List<CommonDevice> GetDeviceOnlineList(string gwId)
+        {
+            var zbway = HdlGatewayLogic.Current.GetLocalGateway(gwId);
+            int statu = 0;
+            var listDevice = this.GetDeviceListFromGateway(zbway, ref statu, false, ShowErrorMode.NO);
+            if (statu == -1)
+            {
+                //褰撳嚭鐜板紓甯告椂,浣跨敤鍚庡鎿嶄綔,鐩存帴鑾峰彇鏈湴鐨勮澶囧垪琛�
+                listDevice = this.GetDeviceByGatewayID(gwId);
+            }
+
+            var listCheck = new HashSet<string>();
+            var listReturn = new List<CommonDevice>();
+            foreach (var device in listDevice)
+            {
+                if (listCheck.Contains(device.DeviceAddr) == false)
+                {
+                    listCheck.Add(device.DeviceAddr);
+                    listReturn.Add(device);
+                }
+            }
+            return listReturn;
+        }
+
+        #endregion
+
         #region 鈻� 涓�鑸柟娉昣__________________________
 
         /// <summary>
@@ -2095,8 +2300,18 @@
         /// <returns></returns>
         public bool CheckDeviceIsOnline(CommonDevice i_device)
         {
-            //0:绂荤嚎 1:鍦ㄧ嚎 2:姝e湪鍒锋柊鐘舵�� 
-            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>
@@ -2326,8 +2541,14 @@
                                 if (listCheck.Contains(mainkeys) == false)
                                 {
                                     listDevice.Add(device);
-
                                     listCheck.Add(mainkeys);
+                                    //鍒锋柊涓�涓嬫湰鍦扮紦瀛�
+                                    var localDevice = this.GetDevice(mainkeys);
+                                    if (localDevice != null)
+                                    {
+                                        //鍒锋柊灞炴��
+                                        this.SetDeviceInfoToMain(localDevice, device);
+                                    }
                                 }
                             }
                         }
@@ -2454,6 +2675,7 @@
                 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;
@@ -2477,8 +2699,6 @@
             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)
@@ -2508,8 +2728,9 @@
             //濡傛灉鏄笁璺户鐢靛櫒鐨勫洖璺殑璇�,榛樿涓虹伅鍏�
             else if (mainDevice.Type == DeviceType.OnOffOutput)
             {
-                var myType = this.GetHdlMyDeviceEnumInfo(mainDevice);
-                if (myType != null && myType.ConcreteType == DeviceConcreteType.Relay_ThreeLoad)
+                //2020.05.13鍙樻洿:缁х數鍣ㄩ兘榛樿涓虹伅鍏�
+                //var myType = this.GetHdlMyDeviceEnumInfo(mainDevice);
+                //if (myType != null && myType.ConcreteType == DeviceConcreteType.Relay_ThreeLoad)
                 {
                     if (mainDevice.DfunctionType == DeviceFunctionType.A鏈畾涔�)
                     {
@@ -2567,6 +2788,7 @@
             else if (deviceType == DeviceType.FreshAir) { device = new FreshAir(); }
             else if (deviceType == DeviceType.DoorLock) { device = new DoorLock(); }
             else if (deviceType == DeviceType.TemperatureSensor) { device = new TemperatureSensor(); }
+            else if (deviceType == DeviceType.PMSensor) { device = new PMSensor(); }
             else if (deviceType == DeviceType.FreshAirHumiditySensor) { device = new HumiditySensor(); }
             else if (deviceType == DeviceType.OtaDevice || deviceType == DeviceType.OtaPanelDevice) { device = new OTADevice(); }
             else { return null; }
@@ -2585,11 +2807,9 @@
         public void SetNewDeviceMainKeys(CommonDevice device, Newtonsoft.Json.Linq.JObject jobject)
         {
             //璁剧疆璁惧涓婚敭绫�
-            device.Time = jobject.Value<int>("Time");
             device.DeviceID = jobject.Value<int>("Device_ID");
             device.DeviceAddr = jobject.Value<string>("DeviceAddr");
             device.DeviceEpoint = jobject.Value<int>("Epoint");
-            device.DataID = jobject.Value<int>("Data_ID");
         }
 
         #endregion
@@ -2672,6 +2892,9 @@
             this.dicDeviceModelIdEnum["MSW01/M-ZB.10"] = "1304-1200-60000";//姘存蹈浼犳劅鍣�
             this.dicDeviceModelIdEnum["MBU01/M-ZB.10"] = "1305-1200-60000";//绱ф�ユ寜閿�
             this.dicDeviceModelIdEnum["MGCD01/ZB.10"] = "1306-1200-60000";//鍚搁《鐕冩皵浼犳劅鍣�
+
+            //PM2.5绌烘皵璐ㄩ噺浼犳劅鍣� 銆愯璁惧灞炰簬绗笁鏂硅澶囷紝娌℃湁闀滃儚ID銆�
+            this.dicDeviceModelIdEnum["SZ_PM100"] = "1307-1200-60000";//PM2.5绌烘皵璐ㄩ噺浼犳劅鍣� 
 
             //=========鈽呪槄缁х數鍣ㄧ被(2300-2499)鈽呪槄=========
             this.dicDeviceModelIdEnum["MPR0310-ZB.10"] = "2300-2300-60001";//3璺户鐢靛櫒灏忔ā鍧�
@@ -2864,6 +3087,11 @@
         /// </summary>
         Sensor_CeilingGas = 1306,
         /// <summary>
+        /// PM2.5绌烘皵璐ㄩ噺浼犳劅鍣�
+        /// </summary>
+        Sensor_PMTwoPointFive = 1307,
+
+        /// <summary>
         /// 杩愬姩浼犳劅鍣�
         /// </summary>
         Sensor_Motion = -1306,
@@ -3014,6 +3242,10 @@
         /// </summary>
         A浼犳劅鍣� = 1200,
         /// <summary>
+        /// PM2.5绌烘皵璐ㄩ噺浼犳劅鍣�
+        /// </summary>
+        APM2鐐�5绌烘皵璐ㄩ噺浼犳劅鍣� = 1307,
+        /// <summary>
         /// 缁х數鍣�(2300-2499)
         /// </summary>
         A缁х數鍣� = 2300,

--
Gitblit v1.8.0