From 2be70a32d2a8c517bd9868fb60913fcc843e66fe Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期三, 13 五月 2020 11:21:32 +0800
Subject: [PATCH] 上传代码

---
 ZigbeeApp/Shared/Common/Device.cs |  115 +++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 107 insertions(+), 8 deletions(-)

diff --git a/ZigbeeApp/Shared/Common/Device.cs b/ZigbeeApp/Shared/Common/Device.cs
index fa6b160..f7c3ede 100755
--- a/ZigbeeApp/Shared/Common/Device.cs
+++ b/ZigbeeApp/Shared/Common/Device.cs
@@ -441,6 +441,8 @@
             //濡傛灉浣忓畢涓鸿櫄鎷熶綇瀹�
             if (Common.Config.Instance.Home.IsVirtually == true)
             {
+                //淇敼璁惧鍚嶅瓧鐨勮瘽,涓婚〉闇�瑕侀噸鏂板埛鏂�
+                Phone.UserView.UserPage.Instance.RefreshForm = true;
                 return true;
             }
 
@@ -465,6 +467,8 @@
                 //澶囦唤鏁版嵁
                 await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(device, GatewayBackupEnum.A绔偣鍚嶇О, newName);
             }
+            //淇敼璁惧鍚嶅瓧鐨勮瘽,涓婚〉闇�瑕侀噸鏂板埛鏂�
+            Phone.UserView.UserPage.Instance.RefreshForm = true;
             return true;
         }
 
@@ -628,6 +632,9 @@
         /// <param name="deleteRoom">鏄惁浠庢埧闂村垹闄�</param>
         public void DeleteMemmoryDevice(CommonDevice device, bool deleteRoom = true)
         {
+            //鍒犻櫎缂撳瓨璁惧鐨勮瘽,涓婚〉闇�瑕侀噸鏂板埛鏂�
+            Phone.UserView.UserPage.Instance.RefreshForm = true;
+
             if (deleteRoom == true)
             {
                 //浠庢埧闂翠腑鍒犻櫎
@@ -1324,7 +1331,7 @@
         }
 
         /// <summary>
-        /// 璁剧疆銆愯澶囩被鍨嬨�戠殑鍥炬爣鍒版寚瀹氱殑鎺т欢
+        /// 璁剧疆銆愯澶囩被鍨嬨�戠殑鍥炬爣鍒版寚瀹氱殑鎺т欢(姝ゆ柟娉曚笉鑳界敤鍦ㄨ澶囧姛鑳界被鍨嬭彍鍗曠殑鍥炬爣)
         /// </summary>
         /// <param name="btnIcon">鎺т欢瀵硅薄</param>
         /// <param name="listdevice">璁惧瀵硅薄</param>
@@ -1346,7 +1353,7 @@
         }
 
         /// <summary>
-        /// 鑾峰彇銆愯澶囩被鍨嬨�戠殑鍥炬爣
+        /// 鑾峰彇銆愯澶囩被鍨嬨�戠殑鍥炬爣(姝ゆ柟娉曚笉鑳界敤鍦ㄨ澶囧姛鑳界被鍨嬭彍鍗曠殑鍥炬爣)
         /// </summary>
         /// <param name="listdevice">璁惧瀵硅薄</param>
         /// <param name="unSelectPath">鍥剧墖鍦板潃</param>
@@ -1362,13 +1369,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);
@@ -1405,6 +1441,7 @@
             unSelectPath = imageFilePath;
             selectPath = imageSelectFilePath;
         }
+
 
         #endregion
 
@@ -1811,6 +1848,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)
@@ -2082,6 +2127,50 @@
             list.Add(DeviceBeloneType.A鏈煡璁惧);
             
             return list;
+        }
+
+        #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 dicDevice = new Dictionary<string, CommonDevice>();
+            foreach (var device in listDevice)
+            {
+                if (dicDevice.ContainsKey(device.DeviceAddr) == false)
+                {
+                    dicDevice[device.DeviceAddr] = device;
+                    continue;
+                }
+                //璁惧鏄惁澶勪簬鍦ㄧ嚎鐘舵��
+                bool online = this.CheckDeviceIsOnline(device);
+                if (online == true)
+                {
+                    //濡傛灉璁惧鍥炶矾鍦ㄧ嚎,鍒欎紭鍏堜娇鐢ㄥ湪绾跨殑鍥炶矾,鍚庢潵鐨勭洿鎺ヨ鐩�
+                    dicDevice[device.DeviceAddr] = device;
+                }
+            }
+            var listReturn = new List<CommonDevice>();
+            foreach (var device in dicDevice.Values)
+            {
+                listReturn.Add(device);
+            }
+            return listReturn;
         }
 
         #endregion
@@ -2454,6 +2543,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 +2567,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)
@@ -2567,6 +2655,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 +2674,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 +2759,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 +2954,11 @@
         /// </summary>
         Sensor_CeilingGas = 1306,
         /// <summary>
+        /// PM2.5绌烘皵璐ㄩ噺浼犳劅鍣�
+        /// </summary>
+        Sensor_PMTwoPointFive = 1307,
+
+        /// <summary>
         /// 杩愬姩浼犳劅鍣�
         /// </summary>
         Sensor_Motion = -1306,
@@ -3014,6 +3109,10 @@
         /// </summary>
         A浼犳劅鍣� = 1200,
         /// <summary>
+        /// PM2.5绌烘皵璐ㄩ噺浼犳劅鍣�
+        /// </summary>
+        APM2鐐�5绌烘皵璐ㄩ噺浼犳劅鍣� = 1307,
+        /// <summary>
         /// 缁х數鍣�(2300-2499)
         /// </summary>
         A缁х數鍣� = 2300,

--
Gitblit v1.8.0