From bba578c2f0acf2eca747edcb69426771e0cadd32 Mon Sep 17 00:00:00 2001
From: WJC <wjc@hdlchina.com.cn>
Date: 星期一, 23 三月 2020 18:20:50 +0800
Subject: [PATCH] 2020-03-23-3

---
 ZigbeeApp/Shared/Common/Device.cs |  152 ++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 146 insertions(+), 6 deletions(-)

diff --git a/ZigbeeApp/Shared/Common/Device.cs b/ZigbeeApp/Shared/Common/Device.cs
index cdc9c4d..e46a0f5 100755
--- a/ZigbeeApp/Shared/Common/Device.cs
+++ b/ZigbeeApp/Shared/Common/Device.cs
@@ -115,7 +115,7 @@
             {
                 CommonDevice device = null;
                 //鍙嶅簭鍒楀寲涓烘寚瀹氱殑绫伙紝涓嶇劧鏁版嵁浼氫涪澶辫�屽鑷存棤娉曞己杞�
-                try 
+                try
                 {
                     device = CommonDevice.CommonDeviceByFilePath(file);
                 }
@@ -271,7 +271,7 @@
                 //娣诲姞缂撳瓨
                 this.AddDeviceToMemory(ref device);
 
-                //绉婚櫎瀛樺湪鐨勮澶囧唴瀛� 
+                //绉婚櫎瀛樺湪鐨勮澶囧唴瀛�
                 string maikey = this.GetDeviceMainKeys(device);
                 if (dicExist.ContainsKey(maikey) == true)
                 {
@@ -475,9 +475,28 @@
                 //澶囦唤鏁版嵁
                 await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(device, GatewayBackupEnum.AMac鍚嶇О, newMacName);
                 //濡傛灉瀹冨彧鏈変竴涓洖璺�,鍒欐洿鏀圭鐐瑰悕瀛�
-                if (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == true && this.dicDeviceEpoint[device.DeviceAddr].Count == 1)
+                if (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == true)
                 {
-                    return await this.ReName(device, newMacName);
+                    //鍙湁涓�涓鐐�
+                    if (this.dicDeviceEpoint[device.DeviceAddr].Count == 1)
+                    {
+                        return await this.ReName(device, newMacName);
+                    }
+                    //濡傛灉瀹冩湁涓や釜绔偣鏃�,pir浼犳劅鍣ㄧ壒娈婂鐞�
+                    else if (this.dicDeviceEpoint[device.DeviceAddr].Count == 2)
+                    {
+                        var myType = this.GetMyDeviceEnumInfo(listDevice);
+                        if (myType.ConcreteType == DeviceConcreteType.Sensor_Pir)
+                        {
+                            foreach (var myDevice in listDevice)
+                            {
+                                if (myDevice.Type == DeviceType.IASZone)
+                                {
+                                    return await this.ReName(myDevice, newMacName);
+                                }
+                            }
+                        }
+                    }
                 }
             }
             return true;
@@ -1145,6 +1164,33 @@
         }
 
         /// <summary>
+        /// 璁剧疆璁惧銆愬浘鏍囥�戝埌鎸囧畾鐨勬帶浠�(娉ㄦ剰,姝ゅ嚱鏁拌缃殑閫夋嫨鐘舵�佺殑鍥剧墖鏄櫧鑹茬殑)
+        /// </summary>
+        /// <param name="btnIcon">鎺т欢瀵硅薄</param>
+        /// <param name="device">璁惧瀵硅薄</param>
+        /// <returns></returns>
+        public void SetDeviceIconToControl2(Button btnIcon, CommonDevice device)
+        {
+            if (device == null)
+            {
+                btnIcon.UnSelectedImagePath = "Device/ThirdPartyDevice.png";
+                return;
+            }
+            string unSelectFilePath = device.IconPath;
+            string selectFilePath = unSelectFilePath.Replace(".png", "Selected2.png");
+
+            //鑾峰彇璁惧銆愬浘鏍囥��
+            if (btnIcon.UnSelectedImagePath != unSelectFilePath)
+            {
+                btnIcon.UnSelectedImagePath = unSelectFilePath;
+            }
+            if (btnIcon.SelectedImagePath != selectFilePath)
+            {
+                btnIcon.SelectedImagePath = selectFilePath;
+            }
+        }
+
+        /// <summary>
         /// 鑾峰彇璁惧銆愬浘鏍囥��
         /// </summary>
         /// <param name="listdevice">璁惧瀵硅薄</param>
@@ -1397,6 +1443,9 @@
                 return null;
             }
             string modelKeys = device.ModelIdentifier;
+            //浜ゆ崲涓�涓嬫ā鍧桰D(楹︿箰鍏嬮偅杈圭殑浼犳劅鍣�)
+            this.ChangedDeviceModeId(ref modelKeys);
+
             if (this.dicDeviceModelIdEnum.ContainsKey(modelKeys) == false)
             {
                 //娌℃湁鍖归厤鍒版ā鍧桰D锛屽垯鐩存帴璧扮涓夋柟璁惧鐨勫垽鏂�
@@ -1814,6 +1863,80 @@
                 return null;
             }
             return HdlRoomLogic.Current.GetRoomById(this.dicDeviceRoomId[device.DeviceAddr]);
+        }
+
+        #endregion
+
+        #region 鈻� 璁惧鎺掑簭___________________________
+
+        /// <summary>
+        /// 璁惧鎺掑簭
+        /// </summary>
+        /// <param name="i_listDevice">璇风‘淇濊繖涓笢瑗垮凡缁忔寜mac鍜岀鐐规帓搴忎簡</param>
+        /// <returns></returns>
+        public List<CommonDevice> SortDeviceByBelongType(List<CommonDevice> i_listDevice)
+        {
+            //鑾峰彇鎺掑簭瑙勫垯
+            var listRule = this.GetBelongTypeSortRule();
+            var dicDevice = new Dictionary<DeviceBeloneType, List<CommonDevice>>();
+            dicDevice[DeviceBeloneType.A鏈煡璁惧] = new List<CommonDevice>();
+
+            foreach (var device in i_listDevice)
+            {
+                //鑾峰彇鎵�灞炵被鍨�
+                var typeInfo = this.GetDeviceBelongEnumInfo(device);
+                if (listRule.Contains(typeInfo.BeloneType) == false)
+                {
+                    //涓嶅湪鎺掑簭鑼冨洿鍐�,閮戒涪鍦ㄦ渶鍚庨潰
+                    dicDevice[DeviceBeloneType.A鏈煡璁惧].Add(device);
+                    continue;
+                }
+                if (dicDevice.ContainsKey(typeInfo.BeloneType) == false)
+                {
+                    dicDevice[typeInfo.BeloneType] = new List<CommonDevice>();
+                }
+                dicDevice[typeInfo.BeloneType].Add(device);
+            }
+
+            var listSort = new List<CommonDevice>();
+            foreach (var myType in listRule)
+            {
+                //鏍规嵁瑙勫垯椤哄簭,娣诲姞璁惧
+                if (dicDevice.ContainsKey(myType) == false || dicDevice[myType].Count == 0)
+                {
+                    continue;
+                }
+                listSort.AddRange(dicDevice[myType]);
+            }
+
+            return listSort;
+        }
+
+        /// <summary>
+        /// 鑾峰彇璁惧鎵�灞炵被鍨嬬殑鐨勬帓搴忚鍒�
+        /// </summary>
+        /// <returns></returns>
+        public HashSet<DeviceBeloneType> GetBelongTypeSortRule()
+        {
+            //璋佸湪鍓嶉潰,璋佸氨浼樺厛鏄剧ず
+            var list = new HashSet<DeviceBeloneType>();
+            list.Add(DeviceBeloneType.A鐏厜);
+            list.Add(DeviceBeloneType.A褰╃伅);
+            list.Add(DeviceBeloneType.A寮�鍏�);
+            list.Add(DeviceBeloneType.A鎻掑骇);
+            list.Add(DeviceBeloneType.A璋冨厜鍣�);
+            list.Add(DeviceBeloneType.A绐楀笜);
+            list.Add(DeviceBeloneType.A绌鸿皟);
+            list.Add(DeviceBeloneType.A缁х數鍣�);
+            list.Add(DeviceBeloneType.A骞叉帴鐐�);
+            list.Add(DeviceBeloneType.A鏅鸿兘闂ㄩ攣);
+            list.Add(DeviceBeloneType.A鏅鸿兘绌哄紑);
+            list.Add(DeviceBeloneType.A浼犳劅鍣�);
+
+            //鍏朵粬鐨勭湅鐫�鍔炲憲,閮芥槸鎺掑湪鍚庨潰鐨�,閮藉綊涓鸿繖涓睘鎬�
+            list.Add(DeviceBeloneType.A鏈煡璁惧);
+
+            return list;
         }
 
         #endregion
@@ -2261,7 +2384,7 @@
             //1銆佸湪杩欓噷濉啓涓婃ā鍧桰D锛岀劧鍚庢槸 DeviceConcreteType 锛岀劧鍚庢槸 DeviceBeloneType
             //2銆佺劧鍚庡湪鏈�涓嬮潰鐨勩�愯嚜瀹氫箟璁惧绫诲瀷銆戞姌鍙犳爮閲屾坊鍔犮�愯澶囩殑鍏蜂綋绫诲瀷銆戯紝銆愯澶囩殑鎵�灞炵被鍨嬨��
             //3銆佷互璁惧鐨勫叿浣撶被鍨嬩负鍚嶅瓧(鍘绘帀銆�-銆�)娣诲姞璁惧鐨勩�愭墍灞炲浘鐗囥�戯紝銆愮湡瀹炵墿鐞嗗浘鐗囥�戙�傚洖璺浘鐗囬渶瑕佺壒娈婂鐞�
-            //4銆佹坊鍔燫鏂囦欢,娣诲姞Language鏂囦欢
+            //4銆佹坊鍔燫鏂囦欢(uDeviceModelId),娣诲姞Language鏂囦欢
             //5銆佸鏋滈渶瑕佸叡鏈夊浘鐗�,鍒欏湪杩欎釜鍑芥暟鐨勬渶搴曚笅娣诲姞
             //*********************************************************************
 
@@ -2285,6 +2408,7 @@
             this.dicDeviceModelIdEnum["MP8B/TILE-ZB.18"] = "242-200";//鏂规偊鍥涘紑鍏帶闈㈡澘
             this.dicDeviceModelIdEnum["MPFA/TILE-ZB.18"] = "250-200";//鏂规偊鏂伴闈㈡澘
             this.dicDeviceModelIdEnum["MPTE3/TILE-ZB.18"] = "253-200";//鏂规偊鐜闈㈡澘
+            this.dicDeviceModelIdEnum["MP2W/TILE-ZB.18"] = "256-200";//绐楀笜闈㈡澘
 
             //=========鈽呪槄PIR浼犳劅鍣ㄧ被(1200-1299)鈽呪槄=========
             this.dicDeviceModelIdEnum["MSPIR01-ZB.10"] = "1200-1200";//pir浼犳劅鍣�220
@@ -2299,12 +2423,14 @@
 
             //=========鈽呪槄缁х數鍣ㄧ被(2300-2499)鈽呪槄=========
             this.dicDeviceModelIdEnum["MPR0310-ZB.10"] = "2300-2300";//3璺户鐢靛櫒灏忔ā鍧�
+            this.dicDeviceModelIdEnum["MFA01-ZB1.0"] = "2310-2300";//鏂规偊鏂伴灏忔ā鍧�
 
             //=========鈽呪槄璋冨厜鍣ㄧ被(2500-2799)鈽呪槄=========
             this.dicDeviceModelIdEnum["MPD0101-ZB.10"] = "2500-2500";//1璺皟鍏夊櫒灏忔ā鍧�
 
             //=========鈽呪槄鏅鸿兘闂ㄩ攣绫�(2800-????)鈽呪槄=========
             this.dicDeviceModelIdEnum["H06C"] = "2800-2800";//鏅鸿兘闂ㄩ攣(H06C)
+            this.dicDeviceModelIdEnum["S-one"] = "2802-2800";//鏅鸿兘闂ㄩ攣(S-one)
 
             //=========鈽呪槄绌鸿皟绫�(3600-3899)鈽呪槄=========
             this.dicDeviceModelIdEnum["MAC/GW-ZB.10"] = "3600-3600";//zigbee绌鸿皟缃戝叧妯″潡
@@ -2340,6 +2466,8 @@
             this.dicPictrueShard["ButtonPanel_SimpleFour"] = "ButtonPanel_Four";//绠�绾�4鎸夐敭闈㈡澘 娌跨敤 4鎸夐敭鐨勫浘鏍�
             this.dicPictrueShard["ButtonPanel_SimpleThree"] = "ButtonPanel_Three";//绠�绾�3鎸夐敭闈㈡澘 娌跨敤 3鎸夐敭鐨勫浘鏍�
             this.dicPictrueShard["ButtonPanel_SimpleTwo"] = "ButtonPanel_Two";//绠�绾�2鎸夐敭闈㈡澘 娌跨敤 2鎸夐敭鐨勫浘鏍�
+            this.dicPictrueShard["IntelligentLocks_Sone"] = "IntelligentLocks_H06C";//S-one鐨勯棬閿佸浘鐗囨部鐢℉06C鐨勫浘鏍�
+
         }
 
         #endregion
@@ -2434,11 +2562,15 @@
         /// <summary>
         /// 鏂规偊鏂伴闈㈡澘 闀滃儚id锛�250
         /// </summary>
-        ButtonPanel_FangyueNewWind = 250,
+        ButtonPanel_FangyueFreshAir = 250,
         /// <summary>
         /// 鏂规偊鐜闈㈡澘 闀滃儚id锛�253
         /// </summary>
         ButtonPanel_FangyueEnvironment = 253,
+        /// <summary>
+        /// 绐楀笜闈㈡澘 闀滃儚id锛�256
+        /// </summary>
+        ButtonPanel_Curtain = 256,
 
         //=========鈽呪槄PIR浼犳劅鍣ㄧ被(1200-1299)鈽呪槄=========
         /// <summary>
@@ -2505,6 +2637,10 @@
         /// 涓夎矾缁х數鍣� 闀滃儚id锛�2300
         /// </summary>
         Relay_ThreeLoad = 2300,
+        /// <summary>
+        /// 鏂规偊鏂伴灏忔ā鍧� 闀滃儚id锛�2310
+        /// </summary>
+        Relay_FangyueFreshAirModul = 2310,
 
         //=========鈽呪槄璋冨厜鍣ㄧ被(2500-2799)鈽呪槄=========
         /// <summary>
@@ -2525,6 +2661,10 @@
         /// H06C
         /// </summary>
         IntelligentLocks_H06C = 2800,
+        /// <summary>
+        /// S-one
+        /// </summary>
+        IntelligentLocks_Sone = 2802,
 
         //=========鈽呪槄褰╃伅绫�(????-????)鈽呪槄=========
         /// <summary>

--
Gitblit v1.8.0