From 66a9965c44ecc32a6696abca876ab9d1cd091584 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期五, 28 二月 2020 15:25:13 +0800
Subject: [PATCH] 2020.2.28

---
 ZigbeeApp/Shared/Phone/UserView/UserPage.cs |  120 ++++++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 84 insertions(+), 36 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserView/UserPage.cs b/ZigbeeApp/Shared/Phone/UserView/UserPage.cs
old mode 100755
new mode 100644
index 90511ff..1dd142f
--- a/ZigbeeApp/Shared/Phone/UserView/UserPage.cs
+++ b/ZigbeeApp/Shared/Phone/UserView/UserPage.cs
@@ -147,46 +147,38 @@
                                 var ac = (AC)myDevice;
                                 ac.DeviceStatusReport = common.DeviceStatusReport;
                                 var attriButeList = ac.DeviceStatusReport.AttriBute;
-                                foreach (var attList in attriButeList)
-                                {
+                                foreach (var attList in attriButeList)
+                                {
                                     //姝ゅ睘鎬ц〃鏄庡鍐呭綋鍓嶇殑娓╁害 * 100锛屽疄闄呮俯搴︿负鈥淟ocalTemperature / 100鈥濓紝鍗曚綅锛氣剝
                                     var curTemp = (attList.AttriButeData / 100 < ACControlBase.Temperature_High && attList.AttriButeData / 100 > ACControlBase.Temperature_Low) ? attList.AttriButeData / 100 : ACControlBase.Temperature_Default;
-                                    switch (attList.AttributeId)
-                                    {
-                                        case 0:
-                                            ac.currentLocalTemperature = curTemp;
-                                            ac.LastDateTime = DateTime.Now;
-                                            break;
-                                        case 17:
-                                            ac.currentCoolingSetpoint = curTemp;
-                                            ac.LastDateTime = DateTime.Now;
-                                            break;
-                                        case 18:
-                                            ac.currentHeatingSetpoint = curTemp;
-                                            ac.LastDateTime = DateTime.Now;
-                                            break;
-                                        case 4096:
-                                            ac.currentAutoSetpoint = curTemp;
-                                            ac.LastDateTime = DateTime.Now;
-                                            break;
-                                        case 28:
-                                            ac.currentSystemMode = attList.AttriButeData;
-                                            ac.LastDateTime = DateTime.Now;
-                                            break;
-                                        case 4099:
-                                            var value = Convert.ToString(attList.AttriButeData, 2).PadLeft(16, '0');
-                                            var modeStr = value.Substring(value.Length - 5, 5);
-                                            for (int j = 0; j < modeStr.Length; j++)
-                                            {
-                                                ac.listSupportMode[j] = Convert.ToInt32(modeStr[j]) == 49 ? 1 : 0;
-                                            }
+                                    switch (attList.AttributeId)
+                                    {
+                                        case 0:
+                                            ac.currentLocalTemperature = curTemp;
+                                            ac.LastDateTime = DateTime.Now;
+                                            break;
+                                        case 17:
+                                            ac.currentCoolingSetpoint = curTemp;
+                                            ac.LastDateTime = DateTime.Now;
+                                            break;
+                                        case 18:
+                                            ac.currentHeatingSetpoint = curTemp;
+                                            ac.LastDateTime = DateTime.Now;
+                                            break;
+                                        case 4096:
+                                            ac.currentAutoSetpoint = curTemp;
+                                            ac.LastDateTime = DateTime.Now;
+                                            break;
+                                        case 28:
+                                            ac.currentSystemMode = attList.AttriButeData;
+                                            ac.LastDateTime = DateTime.Now;
                                             break;
                                         case 4097:
                                             ac.CleanStatu = attList.AttriButeData == 42;
                                             break;
                                     }
                                 }
-                            }
+                            }
 
                             if (common.DeviceStatusReport.CluterID == 514)
                             {
@@ -196,7 +188,7 @@
                                 foreach (var attList in attriButeList)
                                 {
                                     switch (attList.AttributeId)
-                                    {
+                                    {
                                         case 0:
                                             ac.currentFanMode = attList.AttriButeData;
                                             ac.LastDateTime = DateTime.Now;
@@ -208,7 +200,7 @@
                                     }
                                 }
                             }
-
+
                             //褰揅luterID=3,灏辫瘉鏄庤璁惧鍦ㄧ嚎锛岀洿鎺ユ爣璁�
                             if (common.DeviceStatusReport.CluterID == 3)
                             {
@@ -247,6 +239,62 @@
                                 myDevice.IsOnline = 1;
                                 myDevice.LastDateTime = DateTime.Now;
                             }
+                            break;
+
+                        case DeviceType.TemperatureSensor:
+                            //娓╁害
+                            if (common.DeviceStatusReport.CluterID == 1026)
+                            {
+                                var tempera = (TemperatureSensor)myDevice;
+                                foreach (var data in common.DeviceStatusReport.AttriBute)
+                                {
+                                    if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue)
+                                    {
+                                        if (data.AttriButeData == 0)
+                                        {
+                                            tempera.Temperatrue = 0;
+                                        }
+                                        else if (data.AttriButeData > 32767)
+                                        {
+                                            //璐熸暟(鐗规畩澶勭悊)
+                                            string strValue = (data.AttriButeData - 65536).ToString();
+                                            //灏忔暟鐐归渶瑕佷竴浣�
+                                            strValue = strValue.Substring(0, strValue.Length - 1);
+                                            tempera.Temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
+                                        }
+                                        else
+                                        {
+                                            //灏忔暟鐐归渶瑕佷竴浣�
+                                            string strValue = data.AttriButeData.ToString();
+                                            strValue = strValue.Substring(0, strValue.Length - 1);
+                                            tempera.Temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
+                                        }
+                                    }
+                                }
+                            }
+                            //婀垮害
+                            if (common.DeviceStatusReport.CluterID == 1029)
+                            {
+                                var tempera = (TemperatureSensor)myDevice;
+                                foreach (var data in common.DeviceStatusReport.AttriBute)
+                                {
+                                    if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue)
+                                    {
+                                        if (data.AttriButeData == 0)
+                                        {
+                                            tempera.Humidity = 0;
+                                        }
+                                        else
+                                        {
+                                            //灏忔暟鐐归渶瑕佷竴浣�(婀垮害娌℃湁璐熸暟)
+                                            string strValue = data.AttriButeData.ToString();
+                                            strValue = strValue.Substring(0, strValue.Length - 1);
+                                            tempera.Humidity = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
+                                            tempera.LastDateTime = DateTime.Now;
+                                        }
+                                    }
+                                }
+                            }
                             break;
                     }
                 }
@@ -266,8 +314,8 @@
             {
                 try
                 {
-                    switch (myDevice.Type)
-                    {
+                    switch (myDevice.Type)
+                    {
                         case DeviceType.IASZone:
                             var iAS = (IASZone)myDevice;
                             iAS.iASInfo = (common as IASZone).iASInfo;

--
Gitblit v1.8.0