From e5f993f52e09eb46878baced83bb8492f147d41c Mon Sep 17 00:00:00 2001
From: WJC <wjc@hdlchina.com.cn>
Date: 星期一, 04 十一月 2019 17:58:40 +0800
Subject: [PATCH] 2019-11-04-1

---
 ZigbeeApp/Shared/Phone/ZigBee/Device/CommonDevice.cs |   88 +++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 82 insertions(+), 6 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/CommonDevice.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/CommonDevice.cs
index dd2f05e..0c25cf7 100755
--- a/ZigbeeApp/Shared/Phone/ZigBee/Device/CommonDevice.cs
+++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/CommonDevice.cs
@@ -1,6 +1,5 @@
 using System;
 using System.Collections.Generic;
-using System.Linq;
 using System.Text;
 using Newtonsoft.Json.Linq;
 
@@ -23,7 +22,7 @@
             {
                 //if (msg.Contains("DeviceStatusReport") == false)
                 //{
-                System.Console.WriteLine(msg);
+                System.Console.WriteLine(msg + "  " + System.DateTime.Now.ToLongTimeString() + " " + System.DateTime.Now.Millisecond);
                 //}
             }
         }
@@ -163,6 +162,10 @@
             else if (strDeviceType == ZigBee.Device.DeviceType.DoorLock.ToString())
             {
                 return Newtonsoft.Json.JsonConvert.DeserializeObject<DoorLock>(strDeviceByte);
+            }
+            else if (strDeviceType == ZigBee.Device.DeviceType.TemperatureSensor.ToString())
+            {
+                return Newtonsoft.Json.JsonConvert.DeserializeObject<TemperatureSensor>(strDeviceByte);
             }
             return null;
         }
@@ -208,12 +211,12 @@
                 else if (this.Type == DeviceType.ColorDimmableLight)
                 {
                     //褰╃伅
-                    IconPath = "Device/ColorDimmableLight.png";
+                    IconPath = "Device/ColorLight.png";
                 }
                 else if (this.Type == DeviceType.DimmableLight)
                 {
                     //璋冨厜鍣�
-                    IconPath = "Device/ColorDimmableLight.png";
+                    IconPath = "Device/Light.png";
                 }
                 else if (this.Type == DeviceType.OnOffOutput)
                 {
@@ -224,6 +227,19 @@
                 {
                     //绌鸿皟
                     IconPath = "Device/AirConditionerEpoint.png";
+                }
+                else if (this.Type == DeviceType.TemperatureSensor)
+                {
+                    if (((TemperatureSensor)this).SensorDiv == 1)
+                    {
+                        //娓╁害浼犳劅鍣�
+                        IconPath = "Device/SensorTemperature.png";
+                    }
+                    else if (((TemperatureSensor)this).SensorDiv == 2)
+                    {
+                        //婀垮害浼犳劅鍣�
+                        IconPath = "Device/SensorHumidity.png";
+                    }
                 }
                 else if (this.Type != DeviceType.UnKown)
                 {
@@ -276,9 +292,9 @@
         /// </summary>
         public DeviceType Type = DeviceType.UnKown;
         /// <summary>
-        /// 璁惧鐨勫姛鑳界被鍨�(姝ょ被鍨嬬洰鍓嶅彧閽堝缁х數鍣ㄥ洖璺湁鏁�,榛樿涓虹伅鍏�)
+        /// 璁惧鐨勫姛鑳界被鍨�(姝ょ被鍨嬬洰鍓嶅彧閽堝缁х數鍣ㄥ洖璺湁鏁�,榛樿鏈寚瀹�)
         /// </summary>
-        public DeviceFunctionType DfunctionType = DeviceFunctionType.A鐏厜;
+        public DeviceFunctionType DfunctionType = DeviceFunctionType.A鏈畾涔�;
         /// <summary>
         /// MAC鍦板潃
         /// </summary>
@@ -399,6 +415,10 @@
         /// 搴忓垪鍙�
         /// </summary>
         public string SerialNumber = string.Empty;
+        /// <summary>
+        /// 鏁翠釜璁惧鎵�灞炵殑鍖哄煙ID(鍥犱负璁惧涔熻兘澶熷垎閰嶅尯鍩熶簡)
+        /// </summary>
+        public string DeviceRoomId = string.Empty;
         /// <summary>
         /// 鎵�鏈夋寚瀹歝luster鏄惁閮藉凡缁忔垚鍔熺粦瀹氬崗璋冨櫒
         ///<para>0:鏈畬鍏ㄧ粦瀹�</para>
@@ -1306,6 +1326,24 @@
                                     }
                                 }
                                 break;
+                            case DeviceType.DoorLock:
+                                var doorLock = new DoorLock() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId };
+                                doorLock.renameDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<DoorLock.DeviceRenameResponseData>(jobject["Data"].ToString());
+                                if (doorLock.renameDeviceData == null)
+                                {
+                                    d = new DeviceRenameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
+                                }
+                                else
+                                {
+                                    d = new DeviceRenameAllData { deviceRenameData = doorLock.renameDeviceData };
+                                    System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
+                                    var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == doorLock.DeviceID && obj.DeviceAddr == doorLock.DeviceAddr && obj.DeviceEpoint == doorLock.DeviceEpoint);
+                                    if (info != null)
+                                    {
+                                        info.DeviceEpointName = doorLock.renameDeviceData.DeviceName;
+                                    }
+                                }
+                                break;
                         }
                     }
                 };
@@ -1597,6 +1635,25 @@
                                     if (info != null)
                                     {
                                         info.DeviceName = transverter.renameDeviceMacNameData.MacName;
+                                    }
+                                }
+                                break;
+                            case DeviceType.DoorLock:
+                                var doorLock = new DoorLock() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId };
+                                doorLock.renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<DoorLock.RenameDeviceMacNameData>(jobject["Data"].ToString());
+
+                                if (doorLock.renameDeviceMacNameData == null)
+                                {
+                                    d = new RenameDeviceMacNameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
+                                }
+                                else
+                                {
+                                    d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = doorLock.renameDeviceMacNameData };
+                                    System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}_鏀跺埌閫氱煡鍚庣殑鏁版嵁_{ d.renameDeviceMacNameData.ToString()}");
+                                    var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == doorLock.DeviceID && obj.DeviceAddr == doorLock.DeviceAddr && obj.DeviceEpoint == doorLock.DeviceEpoint);
+                                    if (info != null)
+                                    {
+                                        info.DeviceName = doorLock.renameDeviceMacNameData.MacName;
                                     }
                                 }
                                 break;
@@ -1960,6 +2017,25 @@
                                                     }
                                                 }
                                                 break;
+                                            case DeviceType.DoorLock:
+                                                var doorLock = new DoorLock() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
+                                                doorLock.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<DoorLock.RemoveDeviceResponseData>(jobject["Data"].ToString());
+                                                if (doorLock.removeDeviceResponseData == null)
+                                                {
+                                                    return;
+                                                }
+                                                else
+                                                {
+                                                    if (doorLock.removeDeviceResponseData.Result == 0)
+                                                    {
+                                                        var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == doorLock.DeviceID && obj.DeviceAddr == doorLock.DeviceAddr && obj.DeviceEpoint == doorLock.DeviceEpoint);
+                                                        if (info != null)
+                                                        {
+                                                            Gateway.DeviceList.Remove(info);
+                                                        }
+                                                    }
+                                                }
+                                                break;
                                         }
                                     }
                                 }

--
Gitblit v1.8.0