From 081ea8d273048fd03756718ac6fb48a3c09218e9 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期二, 29 十月 2019 13:10:00 +0800
Subject: [PATCH] Merge branch 'dev-tzy' into DEV_GXC

---
 ZigbeeApp/Shared/Common/Device.cs |   37 ++++++++++++++++++++++++++-----------
 1 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/ZigbeeApp/Shared/Common/Device.cs b/ZigbeeApp/Shared/Common/Device.cs
index 8f0dc65..15b7c71 100755
--- a/ZigbeeApp/Shared/Common/Device.cs
+++ b/ZigbeeApp/Shared/Common/Device.cs
@@ -85,7 +85,7 @@
         /// </summary>
         private Dictionary<string, HashSet<int>> dicDeviceEpoint = new Dictionary<string, HashSet<int>>();
         /// <summary>
-        /// 璁惧Mac椤哄簭
+        /// 璁惧Mac椤哄簭(閲岄潰鏄疢ac鍦板潃)
         /// </summary>
         private Dictionary<string, List<string>> dicDeviceSort = null;
         /// <summary>
@@ -223,11 +223,11 @@
         /// <param name="zbGateway">缃戝叧瀵硅薄</param>
         /// <param name="deviceComingAction">鎺ユ敹鍒拌澶囨椂鐨勪簨浠�,璁惧瀵硅薄涓簄ull鏃�,浠h〃鎺ユ敹瀹屾垚</param>
         /// <returns>涓�鐩磋繑鍥瀟rue</returns>
-        public async Task<bool> SetDeviceToMemmoryByGateway(ZbGateway zbGateway, Action<CommonDevice> deviceComingAction = null)
+        public bool SetDeviceToMemmoryByGateway(ZbGateway zbGateway, Action<CommonDevice> deviceComingAction = null)
         {
             //浠庣綉鍏宠幏鍙栧叏閮ㄧ殑璁惧
             List<CommonDevice> listDevice = new List<CommonDevice>();
-            List<CommonDevice> list = await this.GetDeviceListFromGateway(zbGateway, true, deviceComingAction);
+            List<CommonDevice> list = this.GetDeviceListFromGateway(zbGateway, true, deviceComingAction);
 
             if (list == null)
             {
@@ -1007,6 +1007,7 @@
             this.GetDeviceIcon(device, ref unSelectFilePath, ref selectFilePath);
 
             btnIcon.UnSelectedImagePath = unSelectFilePath;
+            btnIcon.SelectedImagePath = selectFilePath;
         }
 
         /// <summary>
@@ -1563,19 +1564,33 @@
         /// <returns></returns>
         public List<CommonDevice> SortDevice(List<CommonDevice> listDevice)
         {
-            var dic = new Dictionary<string, CommonDevice>();
+            var dic = new Dictionary<string, List<CommonDevice>>();
             for (int i = 0; i < listDevice.Count; i++)
             {
-                dic[(this.GetDeviceMainKeys(listDevice[i]))] = listDevice[i];
+                if (dic.ContainsKey(listDevice[i].DeviceAddr) == false)
+                {
+                    dic[listDevice[i].DeviceAddr] = new List<CommonDevice>();
+                }
+                dic[listDevice[i].DeviceAddr].Add(listDevice[i]);
             }
             var list = new List<CommonDevice>();
+            var listCheck = new HashSet<string>();
             foreach (var listSort in this.dicDeviceSort.Values)
             {
                 for (int i = 0; i < listSort.Count; i++)
                 {
-                    if (dic.ContainsKey(listSort[i]) == true)
+                    if (dic.ContainsKey(listSort[i]) == true && listCheck.Contains(listSort[i]) == false)
                     {
-                        list.Add(dic[listSort[i]]);
+                        listCheck.Add(listSort[i]);
+                        dic[listSort[i]].Sort((obj1, obj2) =>
+                        {
+                            if (obj1.DeviceEpoint > obj2.DeviceEpoint)
+                            {
+                                return 1;
+                            }
+                            return -1;
+                        });
+                        list.AddRange(dic[listSort[i]]);
                     }
                 }
             }
@@ -1692,7 +1707,7 @@
         /// <param name="deviceComingAction">鎺ユ敹鍒拌澶囨椂鐨勪簨浠�</param>
         /// <param name="mode">鏄惁鏄剧ず閿欒</param>
         /// <returns></returns>
-        public async Task<List<CommonDevice>> GetDeviceListFromGateway(ZbGateway zbGateway, bool ignoreTime, Action<CommonDevice> deviceComingAction = null, ShowErrorMode mode = ShowErrorMode.YES)
+        public List<CommonDevice> GetDeviceListFromGateway(ZbGateway zbGateway, bool ignoreTime, Action<CommonDevice> deviceComingAction = null, ShowErrorMode mode = ShowErrorMode.YES)
         {
             if (ignoreTime == false)
             {
@@ -1799,13 +1814,13 @@
             try
             {
                 var jObject = new Newtonsoft.Json.Linq.JObject { { "Cluster_ID", 0 }, { "Command", 93 } };
-                await realWay.Send("GetDeviceInfo", jObject.ToString());
+                realWay.Send("GetDeviceInfo", jObject.ToString());
             }
             catch { canBreak = true; }
 
             while (canBreak == false && TimeOut < 60)
             {
-                await Task.Delay(100);
+                System.Threading.Thread.Sleep(100);
                 TimeOut++;
             }
 
@@ -2060,7 +2075,7 @@
             this.dicDeviceModelIdEnum["H06C"] = "2800-2800";//鏅鸿兘闂ㄩ攣(H06C)
 
             //=========鈽呪槄绌鸿皟绫�(3600-3899)鈽呪槄=========
-            this.dicDeviceModelIdEnum["MAC/GW-ZB.431"] = "3600-3600";//zigbee绌鸿皟缃戝叧妯″潡
+            this.dicDeviceModelIdEnum["MAC/GW-ZB.10"] = "3600-3600";//zigbee绌鸿皟缃戝叧妯″潡
 
             //=========鈽呪槄涓户鍣ㄧ被(3900-3999)鈽呪槄=========
             this.dicDeviceModelIdEnum["MSR-ZB.10"] = "3900-3900"; //zigbee涓户鍣�

--
Gitblit v1.8.0