From 1f4cec0e3b571e7541f0c7f3a5ea302ed586d9fb Mon Sep 17 00:00:00 2001 From: WJC <wjc@hdlchina.com.cn> Date: 星期四, 24 十月 2019 16:47:06 +0800 Subject: [PATCH] 2019-10-24-5 --- ZigbeeApp/Shared/Common/Device.cs | 24 +++++++++++++++++++----- 1 files changed, 19 insertions(+), 5 deletions(-) diff --git a/ZigbeeApp/Shared/Common/Device.cs b/ZigbeeApp/Shared/Common/Device.cs index 8f0dc65..85ac646 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> @@ -1563,19 +1563,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]]); } } } -- Gitblit v1.8.0