From 23fb45dd846ed8b62304c408c6bbe64265d4ac8b Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期五, 20 十二月 2019 18:57:16 +0800
Subject: [PATCH] 代码合并

---
 ZigbeeApp/Shared/Common/Device.cs |  154 ++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 133 insertions(+), 21 deletions(-)

diff --git a/ZigbeeApp/Shared/Common/Device.cs b/ZigbeeApp/Shared/Common/Device.cs
index acbcb17..1a25f6f 100755
--- a/ZigbeeApp/Shared/Common/Device.cs
+++ b/ZigbeeApp/Shared/Common/Device.cs
@@ -725,11 +725,12 @@
         }
 
         /// <summary>
-        /// 鏍规嵁MAC鍦板潃,鑾峰彇鍏ㄩ儴鍥炶矾鐨勮澶囧璞�(宸茬粡鎺掑簭)
+        /// 鏍规嵁MAC鍦板潃,鑾峰彇鍏ㄩ儴鍥炶矾鐨勮澶囧璞�
         /// </summary>
         /// <param name="DeviceAddr">Mac鍦板潃</param>
+        /// <param name="sort">鏄惁鎺掑簭</param>
         /// <returns></returns>
-        public List<CommonDevice> GetDevicesByMac(string DeviceAddr)
+        public List<CommonDevice> GetDevicesByMac(string DeviceAddr, bool sort = true)
         {
             var list = new List<CommonDevice>();
             if (dicDeviceEpoint.ContainsKey(DeviceAddr) == false)
@@ -744,6 +745,11 @@
                     list.Add(device);
                 }
             }
+            if (sort == false)
+            {
+                return list;
+            }
+
             //鎺掑簭
             list.Sort((obj1, obj2) =>
             {
@@ -1216,7 +1222,7 @@
                 return info;
             }
             //鑾峰彇绗笁鏂硅澶囩殑銆愯澶囩被鍨嬨��
-            return this.GetNotHdlMyDeviceEnumInfo(listdevice);
+            return this.GetNotHdlMyDeviceEnumInfo(listdevice, false);
         }
 
         /// <summary>
@@ -1246,7 +1252,7 @@
             else
             {
                 //鑾峰彇绗笁鏂硅澶囩殑銆愯澶囩被鍨嬨��
-                var myDeviceType = this.GetNotHdlMyDeviceEnumInfo(listDevice);
+                var myDeviceType = this.GetNotHdlMyDeviceEnumInfo(listDevice, false);
                 strName = Language.StringByID(myDeviceType.ConcreteTextId);
             }
             if (ApendFalge == true && listDevice[0].DriveCode > 0)
@@ -1314,9 +1320,29 @@
         /// <summary>
         /// 鑾峰彇绗笁鏂硅澶囩殑銆愯澶囩被鍨嬨��
         /// </summary>
-        /// <param name="listdevice"></param>
+        /// <param name="device">璁惧鍥炶矾</param>
+        /// <param name="margeSensor">
+        /// <para>鏄惁灏嗘墍鏈夌被鍨嬬殑浼犳劅鍣ㄩ兘褰掍负銆愪紶鎰熷櫒銆�,</para> 
+        /// <para>false鐨勬椂鍊欙細銆怌oncreteType銆戝拰銆怌oncreteTextId銆戝彲鑳戒細鏈変笉鍚岀殑鍊�</para> 
+        /// <para>true鐨勬椂鍊欙細銆怌oncreteType銆戠粺涓�涓篠ensor,銆怌oncreteTextId銆戠粺涓�涓轰紶鎰熷櫒</para> 
+        /// </param>
         /// <returns></returns>
-        public DeviceEnumInfo GetNotHdlMyDeviceEnumInfo(List<CommonDevice> listdevice)
+        public DeviceEnumInfo GetNotHdlMyDeviceEnumInfo(CommonDevice device, bool margeSensor = true)
+        {
+            return this.GetNotHdlMyDeviceEnumInfo(new List<CommonDevice>() { device }, margeSensor);
+        }
+
+        /// <summary>
+        /// 鑾峰彇绗笁鏂硅澶囩殑銆愯澶囩被鍨嬨��(涓嶅缓璁娇鐢�)
+        /// </summary>
+        /// <param name="listdevice">Mac閮戒竴鏍风殑璁惧鍒楄〃</param>
+        /// <param name="margeSensor">
+        /// <para>鏄惁灏嗘墍鏈夌被鍨嬬殑浼犳劅鍣ㄩ兘褰掍负銆愪紶鎰熷櫒銆�,</para> 
+        /// <para>false鐨勬椂鍊欙細銆怌oncreteType銆戝拰銆怌oncreteTextId銆戝彲鑳戒細鏈変笉鍚岀殑鍊�</para> 
+        /// <para>true鐨勬椂鍊欙細銆怌oncreteType銆戠粺涓�涓篠ensor,銆怌oncreteTextId銆戠粺涓�涓轰紶鎰熷櫒</para> 
+        /// </param>
+        /// <returns></returns>
+        public DeviceEnumInfo GetNotHdlMyDeviceEnumInfo(List<CommonDevice> listdevice, bool margeSensor = true)
         {
             var dicType = new Dictionary<DeviceType, CommonDevice>();
             foreach (CommonDevice device in listdevice)
@@ -1331,9 +1357,18 @@
             //1鍖呭惈闈㈡澘鐨勮瘽,褰撻潰鏉垮鐞�
             if (dicType.ContainsKey(DeviceType.OnOffSwitch) == true)
             {
-                info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId200;
-                info.BeloneType = DeviceBeloneType.A鎸夐敭闈㈡澘;
-                info.ConcreteType = DeviceConcreteType.ButtonPanel;
+                if (listdevice.Count > 1)
+                {
+                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId200;
+                    info.BeloneType = DeviceBeloneType.A鎸夐敭闈㈡澘;
+                    info.ConcreteType = DeviceConcreteType.ButtonPanel;
+                }
+                else
+                {
+                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId16;
+                    info.BeloneType = DeviceBeloneType.A骞叉帴鐐�;
+                    info.ConcreteType = DeviceConcreteType.DryContact;
+                }
             }
             //3鍖呭惈绐楀笜鐨勮瘽,褰撶獥甯樺鐞�
             else if (dicType.ContainsKey(DeviceType.WindowCoveringDevice) == true)
@@ -1345,16 +1380,56 @@
             //4绌烘皵寮�鍏�
             else if (dicType.ContainsKey(DeviceType.AirSwitch) == true)
             {
+                //榛樿鍊�
                 info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId4100;
-                info.BeloneType = DeviceBeloneType.A绌烘皵寮�鍏�;
+                info.BeloneType = DeviceBeloneType.A鏅鸿兘绌哄紑;
                 info.ConcreteType = DeviceConcreteType.AirSwitch;
+
+                if (dicType[DeviceType.AirSwitch].DfunctionType == DeviceFunctionType.A寮�鍏�)
+                {
+                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId13;
+                    info.BeloneType = DeviceBeloneType.A寮�鍏�;
+                    info.ConcreteType = DeviceConcreteType.Switch;
+                }
+                else if (dicType[DeviceType.AirSwitch].DfunctionType == DeviceFunctionType.A鎻掑骇)
+                {
+                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId14;
+                    info.BeloneType = DeviceBeloneType.A鎻掑骇;
+                    info.ConcreteType = DeviceConcreteType.Socket1;
+                }
+                else if (dicType[DeviceType.AirSwitch].DfunctionType == DeviceFunctionType.A鐏厜)
+                {
+                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId15;
+                    info.BeloneType = DeviceBeloneType.A鐏厜;
+                    info.ConcreteType = DeviceConcreteType.Light;
+                }
             }
             //5缁х數鍣�
             else if (dicType.ContainsKey(DeviceType.OnOffOutput) == true)
             {
+                //榛樿鍊�
                 info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId2300;
                 info.BeloneType = DeviceBeloneType.A缁х數鍣�;
                 info.ConcreteType = DeviceConcreteType.Relay;
+
+                if (dicType[DeviceType.OnOffOutput].DfunctionType == DeviceFunctionType.A寮�鍏�)
+                {
+                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId13;
+                    info.BeloneType = DeviceBeloneType.A寮�鍏�;
+                    info.ConcreteType = DeviceConcreteType.Switch;
+                }
+                else if (dicType[DeviceType.OnOffOutput].DfunctionType == DeviceFunctionType.A鎻掑骇)
+                {
+                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId14;
+                    info.BeloneType = DeviceBeloneType.A鎻掑骇;
+                    info.ConcreteType = DeviceConcreteType.Socket1;
+                }
+                else if (dicType[DeviceType.OnOffOutput].DfunctionType == DeviceFunctionType.A鐏厜)
+                {
+                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId15;
+                    info.BeloneType = DeviceBeloneType.A鐏厜;
+                    info.ConcreteType = DeviceConcreteType.Light;
+                }
             }
             //6璋冨厜鍣�
             else if (dicType.ContainsKey(DeviceType.DimmableLight) == true)
@@ -1401,16 +1476,23 @@
             //12鍖呭惈浼犳劅鍣ㄧ殑璇�,褰撲紶鎰熷櫒澶勭悊
             else if (dicType.ContainsKey(DeviceType.IASZone) == true)
             {
-                //璁剧疆浼犳劅鍣ㄥ叿浣撶殑绫诲瀷
                 info.BeloneType = DeviceBeloneType.A浼犳劅鍣�;
-                this.SetSensorDeviceSpecificType(ref info, listdevice);
+                info.ConcreteType = DeviceConcreteType.Sensor;
+                info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId1200;
+                if (margeSensor == false)
+                {
+                    //璁剧疆浼犳劅鍣ㄥ叿浣撶殑绫诲瀷
+                    this.SetSensorDeviceSpecificType(ref info, listdevice);
+                }
             }
             //13鍖呭惈娓╁害浼犳劅鍣ㄧ殑璇�
             else if (dicType.ContainsKey(DeviceType.TemperatureSensor) == true)
             {
                 bool temperatrue = false;
                 bool humidity = false;
-                foreach (var device in listdevice)
+                //鑾峰彇鍏ㄩ儴鐨勫洖璺�
+                var listTemp = this.GetDevicesByMac(listdevice[0].DeviceAddr, false);
+                foreach (var device in listTemp)
                 {
                     if (device is TemperatureSensor)
                     {
@@ -1470,10 +1552,6 @@
         /// <param name="listdevice">璁惧瀵硅薄</param>
         private void SetSensorDeviceSpecificType(ref DeviceEnumInfo info, List<CommonDevice> listdevice)
         {
-            //榛樿鍚嶅瓧:浼犳劅鍣�
-            info.ConcreteType = DeviceConcreteType.Sensor;
-            info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId1200;
-
             //濡傛灉杩欎釜璁惧鎷ユ湁澶氫釜鍥炶矾鐨勮瘽,鎴戜篃涓嶇煡閬撴�庝箞鍛藉悕,鍙兘缁欎釜榛樿鍚嶅瓧
             if (listdevice.Count > 1)
             {
@@ -2314,7 +2392,7 @@
 
         //=========鈽呪槄绌烘皵寮�鍏崇被(4100-????)鈽呪槄=========
         /// <summary>
-        /// 鏅鸿兘绌烘皵寮�鍏�
+        /// 鏅鸿兘绌哄紑
         /// </summary>
         AirSwitch = -4100,
         /// <summary>
@@ -2335,6 +2413,24 @@
         /// zigbee杞琤uspro鍗忚杞崲鍣�
         /// </summary>
         Converter_ZbBuspro = 4201,
+
+        //=========鈽呪槄鍏朵粬绫�(????-????)鈽呪槄=========
+        /// <summary>
+        /// 骞叉帴鐐�
+        /// </summary>
+        DryContact = -10000,
+        /// <summary>
+        /// 鐏厜(娉ㄦ剰,瀹冭緭鍏ュ叾浠栫被,涓嶆槸璁惧绫诲瀷)
+        /// </summary>
+        Light = -10001,
+        /// <summary>
+        /// 鎻掑骇
+        /// </summary>
+        Socket1 = -10002,
+        /// <summary>
+        /// 寮�鍏�
+        /// </summary>
+        Switch = -10003,
     }
 
     /// <summary>
@@ -2380,9 +2476,9 @@
         /// </summary>
         A涓户鍣� = 3900,
         /// <summary>
-        /// 绌烘皵寮�鍏�(4100-4199)
+        /// 鏅鸿兘绌哄紑(4100-4199)
         /// </summary>
-        A绌烘皵寮�鍏� = 4100,
+        A鏅鸿兘绌哄紑 = 4100,
         /// <summary>
         /// 杞崲鍣�(4200-4699)
         /// </summary>
@@ -2402,7 +2498,23 @@
         /// <summary>
         /// 婀垮害浼犳劅鍣�
         /// </summary>
-        A婀垮害浼犳劅鍣� = 12
+        A婀垮害浼犳劅鍣� = 12,
+        /// <summary>
+        /// 寮�鍏�
+        /// </summary>
+        A寮�鍏� = 13,
+        /// <summary>
+        /// 鎻掑骇
+        /// </summary>
+        A鎻掑骇 = 14,
+        /// <summary>
+        /// 鐏厜
+        /// </summary>
+        A鐏厜 = 15,
+        /// <summary>
+        /// 骞叉帴鐐�
+        /// </summary>
+        A骞叉帴鐐� = 16
     }
 
     #endregion

--
Gitblit v1.8.0