From 2ed75b8b337048e5d75e6d9ec8307633134f02fd Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期四, 10 十月 2019 11:33:04 +0800
Subject: [PATCH] 个人中心添加楼层和创建房间,实装二级验证

---
 ZigbeeApp/Shared/Common/Device.cs |   76 +++++++++++++++++++++++++++++++++++--
 1 files changed, 71 insertions(+), 5 deletions(-)

diff --git a/ZigbeeApp/Shared/Common/Device.cs b/ZigbeeApp/Shared/Common/Device.cs
index 3453f98..7b123ae 100755
--- a/ZigbeeApp/Shared/Common/Device.cs
+++ b/ZigbeeApp/Shared/Common/Device.cs
@@ -279,11 +279,10 @@
                         dName += "(" + device.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + ")";
                     }
 
-                    new System.Threading.Thread(async () =>
-                    { 
+                    HdlThreadLogic.Current.RunThread(async () =>
+                    {
                         await this.ReName(device, dName, ShowErrorMode.NO);
-                    })
-                    { IsBackground = true }.Start();
+                    });
                 }
             }
 
@@ -996,6 +995,11 @@
                     return;
                 }
                 imageFilePath = "RealDevice/" + arry[0] + ".png";
+                //濡傛灉瀹冭嚜宸辩殑鍏遍�氬浘鐗囪繕鏄笉瀛樺湪鐨勮瘽,鍒欑洿鎺ヤ娇鐢ㄦ墍鏈夎澶囩殑鍏遍�氬浘鐗�
+                if (string.IsNullOrEmpty(IO.FileUtils.GetImageFilePath(imageFilePath)) == true)
+                {
+                    imageFilePath = "RealDevice/CommonDevice.png";
+                }
             }
             btnIcon.UnSelectedImagePath = imageFilePath;
         }
@@ -1319,13 +1323,57 @@
                 info.BeloneType = DeviceBeloneType.A鏅鸿兘闂ㄩ攣;
                 info.ConcreteType = DeviceConcreteType.IntelligentLocks;
             }
-            //2鍖呭惈浼犳劅鍣ㄧ殑璇�,褰撲紶鎰熷櫒澶勭悊
+            //12鍖呭惈浼犳劅鍣ㄧ殑璇�,褰撲紶鎰熷櫒澶勭悊
             else if (dicType.ContainsKey(DeviceType.IASZone) == true)
             {
                 //璁剧疆浼犳劅鍣ㄥ叿浣撶殑绫诲瀷
                 info.BeloneType = DeviceBeloneType.A浼犳劅鍣�;
                 this.SetSensorDeviceSpecificType(ref info, listdevice);
             }
+            //13鍖呭惈娓╁害浼犳劅鍣ㄧ殑璇�
+            else if (dicType.ContainsKey(DeviceType.TemperatureSensor) == true)
+            {
+                bool temperatrue = false;
+                bool humidity = false;
+                foreach (var device in listdevice)
+                {
+                    if (device is TemperatureSensor)
+                    {
+                        //娓╁害浼犳劅鍣�
+                        if (((TemperatureSensor)device).SensorDiv == 1)
+                        {
+                            temperatrue = true;
+                        }
+                        //婀垮害浼犳劅鍣�
+                        else if(((TemperatureSensor)device).SensorDiv == 2)
+                        {
+                            humidity = true;
+                        }
+                    }
+                }
+                if (temperatrue == true && humidity == true)
+                {
+                    //璁剧疆浼犳劅鍣ㄥ叿浣撶殑绫诲瀷
+                    info.BeloneType = DeviceBeloneType.A娓╂箍搴︿紶鎰熷櫒;
+                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId10;
+                    info.ConcreteType = DeviceConcreteType.Sensor_TemperatrueHumidity;
+                }
+                else if (temperatrue == true && humidity == false)
+                {
+                    //璁剧疆浼犳劅鍣ㄥ叿浣撶殑绫诲瀷
+                    info.BeloneType = DeviceBeloneType.A娓╁害浼犳劅鍣�;
+                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId11;
+                    info.ConcreteType = DeviceConcreteType.Sensor_Temperatrue;
+                }
+                else if (temperatrue == false && humidity == true)
+                {
+                    //璁剧疆浼犳劅鍣ㄥ叿浣撶殑绫诲瀷
+                    info.BeloneType = DeviceBeloneType.A婀垮害浼犳劅鍣�;
+                    info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId12;
+                    info.ConcreteType = DeviceConcreteType.Sensor_Humidity;
+                }
+            }
+
             int value = (int)info.BeloneType;
             if (dicDeviceDefultNameID.ContainsKey("uDeviceBelongId" + value) == true)
             {
@@ -1809,6 +1857,23 @@
             mainDevice.OutClusterList.AddRange(device.DeviceInfo.OutClusterList);
             mainDevice.AttributeStatus.Clear();
             mainDevice.AttributeStatus.AddRange(device.DeviceInfo.AttributeStatus);
+            
+            //濡傛灉鏄俯搴︿紶鎰熷櫒
+            if (mainDevice is TemperatureSensor)
+            {
+                //杈撳嚭鏃� 1026:娓╁害浼犳劅鍣� 1029:婀垮害浼犳劅鍣�
+                foreach (var data in mainDevice.OutClusterList)
+                {
+                    if (data.OutCluster == 1029)
+                    {
+                        ((TemperatureSensor)mainDevice).SensorDiv = 2;
+                    }
+                    else if (data.OutCluster == 1026)
+                    {
+                        ((TemperatureSensor)mainDevice).SensorDiv = 1;
+                    }
+                }
+            }
         }
 
         /// <summary>
@@ -1831,6 +1896,7 @@
             else if (deviceType == DeviceType.Repeater) { device = new Repeater(); }
             else if (deviceType == DeviceType.Thermostat) { device = new AC(); }
             else if (deviceType == DeviceType.DoorLock) { device = new DoorLock(); }
+            else if (deviceType == DeviceType.TemperatureSensor) { device = new TemperatureSensor(); }
             else if (deviceType == DeviceType.OtaDevice || deviceType == DeviceType.OtaPanelDevice) { device = new OTADevice(); }
             else { return null; }
 

--
Gitblit v1.8.0