From 6fa9d69da922c8049f5acfcbb9ce9fd26811024c Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期四, 16 四月 2020 17:10:57 +0800
Subject: [PATCH] 请合并代码

---
 ZigbeeApp/Shared/Phone/ZigBee/Device/CommonDevice.cs | 1302 ++++++++---------------------------------------------------
 1 files changed, 177 insertions(+), 1,125 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/CommonDevice.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/CommonDevice.cs
index 3ae2a58..f73ef01 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;
 
@@ -11,6 +10,11 @@
     {
         [Newtonsoft.Json.JsonIgnore]
         public DateTime LastDateTime = DateTime.MinValue;
+        /// <summary>
+        /// 鏄惁宸茬粡璇诲彇浜嗚澶囩姸鎬�(姝ゅ睘鎬ф槸缁欎富椤典娇鐢ㄧ殑)
+        /// </summary>
+        [Newtonsoft.Json.JsonIgnore]
+        public bool HadReadDeviceStatu = false;
 
         /// <summary>
         /// 璋冭瘯鏃舵墦寮�鎵撳嵃淇℃伅锛宼rue:鎵撳嵃锛宖alse:涓嶆墦鍗�
@@ -19,13 +23,15 @@
         /// <param name="flage">If set to <c>true</c> flage.</param>
         public static void DebugPrintLog(string msg, bool flage = true)
         {
+#if DEBUG
             if (flage == true)
             {
-                //if (msg.Contains("DeviceStatusReport") == false)
-                //{
-                    System.Console.WriteLine(msg);
-                //}
+                if (msg.Contains("DeviceStatusReport") == false)
+                {
+                    System.Console.WriteLine(msg + "  " + System.DateTime.Now.ToLongTimeString() + " " + System.DateTime.Now.Millisecond);
+                }
             }
+#endif
         }
 
         /// <summary>
@@ -76,7 +82,7 @@
                     gateWay.getGatewayBaseInfo.gwID = CurrentGateWayId;
                     gateWay.getGatewayBaseInfo.HomeId = Shared.Common.Config.Instance.HomeId;
                     ZbGateway.GateWayList.Add(gateWay);
-                 }
+                }
 
                 return gateWay;
             }
@@ -110,13 +116,13 @@
                 return null;
             }
             return CommonDeviceByByteString(v[1], System.Text.Encoding.UTF8.GetString(Shared.Common.Global.ReadFileByHomeId(deviceFilePath)));
-        }
-
-        /// <summary>
-        /// 鐢辫澶囧瓧绗︿覆姣旂壒鎭㈠璁惧瀵硅薄
-        /// </summary>
-        /// <param name="strDeviceType">璁惧DeviceType鐨勫瓧绗︿覆绫诲瀷</param>
-        /// <param name="strDeviceByte">璁惧Json鏂囦欢杞负姣旂壒鍚庡啀杞负鐨勫瓧绗︿覆</param>
+        }
+
+        /// <summary>
+        /// 鐢辫澶囧瓧绗︿覆姣旂壒鎭㈠璁惧瀵硅薄
+        /// </summary>
+        /// <param name="strDeviceType">璁惧DeviceType鐨勫瓧绗︿覆绫诲瀷</param>
+        /// <param name="strDeviceByte">璁惧Json鏂囦欢杞负姣旂壒鍚庡啀杞负鐨勫瓧绗︿覆</param>
         /// <returns></returns>
         public static CommonDevice CommonDeviceByByteString(string strDeviceType, string strDeviceByte)
         {
@@ -160,6 +166,22 @@
             {
                 return Newtonsoft.Json.JsonConvert.DeserializeObject<Transverter>(strDeviceByte);
             }
+            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);
+            }
+            else if (strDeviceType == ZigBee.Device.DeviceType.FreshAirHumiditySensor.ToString())
+            {
+                return Newtonsoft.Json.JsonConvert.DeserializeObject<HumiditySensor>(strDeviceByte);
+            }
+            else if (strDeviceType == ZigBee.Device.DeviceType.FreshAir.ToString())
+            {
+                return Newtonsoft.Json.JsonConvert.DeserializeObject<FreshAir>(strDeviceByte);
+            }
             return null;
         }
 
@@ -180,8 +202,106 @@
         /// </summary>
         public void ReSave()
         {
-            //Console.WriteLine(FilePath);
+            if (IconPath == string.Empty)
+            {
+                //淇濆瓨璁惧鍥炬爣(杩欓噷浼氫繚瀛樹竴娆�,涓嬮潰灏变笉鐢ㄤ繚瀛樹簡)
+                this.SaveDeviceIcon();
+                return;
+            }
             Shared.Common.Global.WriteFileByBytesByHomeId(FilePath, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this)));
+        }
+
+        /// <summary>
+        /// 淇濆瓨璁惧鍥炬爣
+        /// </summary>
+        private void SaveDeviceIcon()
+        {
+            if (IconPath == string.Empty)
+            {
+                //骞叉帴鐐�
+                if (this.Type == DeviceType.OnOffSwitch)
+                {
+                    IconPath = "Device/DryContact.png";
+                }
+                else if (this.Type == DeviceType.ColorDimmableLight)
+                {
+                    //褰╃伅
+                    IconPath = "Device/ColorLight.png";
+                }
+                else if (this.Type == DeviceType.DimmableLight)
+                {
+                    //璋冨厜鍣�
+                    IconPath = "Device/Light.png";
+                }
+                else if (this.Type == DeviceType.OnOffOutput)
+                {
+                    //缁х數鍣�
+                    IconPath = "Device/RelayEpoint.png";
+                }
+                else if (this.Type == DeviceType.Thermostat || this.Type == DeviceType.FreshAir)
+                {
+                    //绌鸿皟
+                    //鏂伴鍜岀┖璋冨浘鏍囩浉鍚�
+                    IconPath = "Device/AirConditionerEpoint.png";
+                }
+                else if (this.Type == DeviceType.FreshAirHumiditySensor)
+                {
+                    //婀垮害浼犳劅鍣�
+                    IconPath = "Device/SensorHumidity.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)
+                {
+                    //鍏朵粬鐨勫浘鏍囨湁鐐圭壒娈�
+                    string unSelectPic = string.Empty;
+                    string selectPic = string.Empty;
+                    Shared.Common.LocalDevice.Current.GetDeviceObjectIcon(new List<CommonDevice> { this }, ref unSelectPic, ref selectPic);
+                    IconPath = unSelectPic;
+                }
+                Shared.Common.Global.WriteFileByBytesByHomeId(FilePath, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this)));
+            }
+        }
+
+        /// <summary>
+        /// 鏄惁鏄嚜瀹氫箟鍥剧墖
+        /// </summary>
+        public bool IsCustomizeImage = false;
+        /// <summary>
+        /// 璁惧鍥剧墖
+        /// </summary>
+        public string IconPath = string.Empty;
+        /// <summary>
+        /// 璁惧鍥剧墖--鍦ㄧ嚎鎴栬�呴�変腑鐘舵��
+        /// </summary>
+        /// <value>The online icon path.</value>
+        [Newtonsoft.Json.JsonIgnore]
+        public string OnlineIconPath
+        {
+            get
+            {
+                if (string.IsNullOrEmpty(IconPath))
+                {
+                    return string.Empty;
+                }
+                var pathArr = IconPath.Split('.');
+                if (pathArr == null || string.IsNullOrEmpty(pathArr[0]))
+                {
+                    return string.Empty;
+                }
+                return $"{pathArr[0]}Selected.png";
+            }
         }
 
         /// <summary>
@@ -192,7 +312,10 @@
         /// 褰撳墠璁惧绫诲瀷
         /// </summary>
         public DeviceType Type = DeviceType.UnKown;
-
+        /// <summary>
+        /// 璁惧鐨勫姛鑳界被鍨�(姝ょ被鍨嬬洰鍓嶅彧閽堝缁х數鍣ㄥ洖璺湁鏁�,榛樿鏈寚瀹�)
+        /// </summary>
+        public DeviceFunctionType DfunctionType = DeviceFunctionType.A鏈畾涔�;
         /// <summary>
         /// MAC鍦板潃
         /// </summary>
@@ -312,7 +435,7 @@
         /// <summary>
         /// 搴忓垪鍙�
         /// </summary>
-        public string SerialNumber = string.Empty; 
+        public string SerialNumber = string.Empty;
         /// <summary>
         /// 鎵�鏈夋寚瀹歝luster鏄惁閮藉凡缁忔垚鍔熺粦瀹氬崗璋冨櫒
         ///<para>0:鏈畬鍏ㄧ粦瀹�</para>
@@ -559,6 +682,18 @@
             /// 椹卞姩浠g爜銆備负0鏃讹紝琛ㄧずzigbee鍗忚皟鍣ㄨ澶囥�傚叾浠栧�艰〃绀轰负铏氭嫙椹卞姩璁惧
             /// </summary>
             public int DriveCode;
+            /// <summary>
+            /// 鍘傚晢鍚嶇О
+            /// </summary>
+            public string ManufacturerName = string.Empty;
+            /// <summary>
+            /// 妯″潡ID
+            /// </summary>
+            public string ModelIdentifier = string.Empty;
+            /// <summary>
+            /// 濂藉儚鏄簭鍒楀彿
+            /// </summary>
+            public string ProductCode = string.Empty;
             /// <summary>
             /// 杈撳叆绨囧垪琛�
             /// </summary>
@@ -798,7 +933,7 @@
             /// 1:璺敱鍣ㄨ澶�
             /// <para>2:缁堢璁惧</para>
             /// </summary>
-            public int ZigbeeType; 
+            public int ZigbeeType;
         }
 
         /// <summary>
@@ -886,7 +1021,7 @@
             /// <summary>
             /// 璁惧鎵�鍦ㄧ綉鍏崇殑缃戝叧id
             /// </summary>
-            public int GwId;
+            public string GwId;
             /// <summary>
             /// 璁惧鍚�
             /// </summary>
@@ -931,7 +1066,7 @@
             /// <summary>
             /// 搴忓垪鍙�
             /// </summary>
-            public string SerialNumber = string.Empty; 
+            public string SerialNumber = string.Empty;
             /// <summary>
             /// 杈撳叆绨囧垪琛�
             /// </summary>
@@ -1035,180 +1170,8 @@
 
                     if (topic == gatewayID + "/" + "DeviceRenameRespon")
                     {
-                        var deviceID = jobject.Value<int>("Device_ID");
-                        switch ((DeviceType)(deviceID))
-                        {
-                            case DeviceType.OnOffOutput:
-                                var toggleLight = new ToggleLight() { 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 };
-                                toggleLight.renameDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<ToggleLight.DeviceRenameResponseData>(jobject["Data"].ToString());
-
-                                if (toggleLight.renameDeviceData == null)
-                                {
-                                    d = new DeviceRenameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
-                                }
-                                else
-                                {
-                                    d = new DeviceRenameAllData { deviceRenameData = toggleLight.renameDeviceData };
-                                    System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
-                                    var infoToggleLight = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == toggleLight.DeviceID && obj.DeviceAddr == toggleLight.DeviceAddr && obj.DeviceEpoint == toggleLight.DeviceEpoint);
-                                    if (infoToggleLight != null)
-                                    {
-                                        infoToggleLight.DeviceEpointName = toggleLight.renameDeviceData.DeviceName;
-                                    }
-                                }
-                                break;
-                            case DeviceType.AirSwitch:
-                                var airSwitch = new AirSwitch() { 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 };
-                                airSwitch.renameDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<AirSwitch.DeviceRenameResponseData>(jobject["Data"].ToString());
-
-                                if (airSwitch.renameDeviceData == null)
-                                {
-                                    d = new DeviceRenameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
-                                }
-                                else
-                                {
-                                    d = new DeviceRenameAllData { deviceRenameData = airSwitch.renameDeviceData };
-                                    System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
-                                    var infoAirSwitch = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == airSwitch.DeviceID && obj.DeviceAddr == airSwitch.DeviceAddr && obj.DeviceEpoint == airSwitch.DeviceEpoint);
-                                    if (infoAirSwitch != null)
-                                    {
-                                        infoAirSwitch.DeviceEpointName = airSwitch.renameDeviceData.DeviceName;
-                                        //infoAirSwitch.ReSave();
-                                    }
-                                }
-                                break;
-                            case DeviceType.OnOffSwitch:
-                                var panelObj = new Panel() { 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 };
-                                panelObj.renameDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.DeviceRenameResponseData>(jobject["Data"].ToString());
-                                if (panelObj.renameDeviceData == null)
-                                {
-                                    d = new DeviceRenameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
-                                }
-                                else
-                                {
-                                    d = new DeviceRenameAllData { deviceRenameData = panelObj.renameDeviceData };
-                                    System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
-                                    var infoPanel = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == panelObj.DeviceID && obj.DeviceAddr == panelObj.DeviceAddr && obj.DeviceEpoint == panelObj.DeviceEpoint);
-                                    if (infoPanel != null)
-                                    {
-                                        infoPanel.DeviceEpointName = panelObj.renameDeviceData.DeviceName;
-                                        //infoPanel.ReSave();
-                                    }
-                                }
-                                break;
-                            case DeviceType.WindowCoveringDevice:
-                                var windowCovering = new Rollershade() { 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 };
-                                windowCovering.renameDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<Rollershade.DeviceRenameResponseData>(jobject["Data"].ToString());
-                                if (windowCovering.renameDeviceData == null)
-                                {
-                                    d = new DeviceRenameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
-                                }
-                                else
-                                {
-                                    d = new DeviceRenameAllData { deviceRenameData = windowCovering.renameDeviceData };
-                                    System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{topic}");
-                                    var wc = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == windowCovering.DeviceID && obj.DeviceAddr == windowCovering.DeviceAddr && obj.DeviceEpoint == windowCovering.DeviceEpoint);
-                                    if (wc != null)
-                                    {
-                                        wc.DeviceEpointName = windowCovering.renameDeviceData.DeviceName;
-                                    }
-                                }
-
-                                break;
-                            case DeviceType.IASZone:
-                                var ias = new IASZone() { 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 };
-                                ias.renameDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<Rollershade.DeviceRenameResponseData>(jobject["Data"].ToString());
-                                if (ias.renameDeviceData == null)
-                                {
-                                    d = new DeviceRenameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
-                                }
-                                else
-                                {
-                                    d = new DeviceRenameAllData { deviceRenameData = ias.renameDeviceData };
-                                    System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{topic}");
-
-                                    var zone = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == ias.DeviceID && obj.DeviceAddr == ias.DeviceAddr && obj.DeviceEpoint == ias.DeviceEpoint);
-                                    if (zone != null)
-                                    {
-                                        zone.DeviceEpointName = ias.renameDeviceData.DeviceName;
-                                    }
-                                }
-                                break;
-                            case DeviceType.DimmableLight:
-                                var dimmableLight = new DimmableLight() { 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 };
-                                dimmableLight.renameDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<DimmableLight.DeviceRenameResponseData>(jobject["Data"].ToString());
-
-                                if (dimmableLight.renameDeviceData == null)
-                                {
-                                    d = new DeviceRenameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
-                                }
-                                else
-                                {
-                                    d = new DeviceRenameAllData { deviceRenameData = dimmableLight.renameDeviceData };
-                                    System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
-                                    var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == dimmableLight.DeviceID && obj.DeviceAddr == dimmableLight.DeviceAddr && obj.DeviceEpoint == dimmableLight.DeviceEpoint);
-                                    if (info != null)
-                                    {
-                                        info.DeviceEpointName = dimmableLight.renameDeviceData.DeviceName;
-                                    }
-                                }
-                                break;
-                            case DeviceType.Repeater:
-                                var repeater = new Repeater() { 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 };
-                                repeater.renameDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<Repeater.DeviceRenameResponseData>(jobject["Data"].ToString());
-
-                                if (repeater.renameDeviceData == null)
-                                {
-                                    d = new DeviceRenameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
-                                }
-                                else
-                                {
-                                    d = new DeviceRenameAllData { deviceRenameData = repeater.renameDeviceData };
-                                    System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
-                                    var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == repeater.DeviceID && obj.DeviceAddr == repeater.DeviceAddr && obj.DeviceEpoint == repeater.DeviceEpoint);
-                                    if (info != null)
-                                    {
-                                        info.DeviceEpointName = repeater.renameDeviceData.DeviceName;
-                                    }
-                                }
-                                break;
-                            case DeviceType.Thermostat:
-                                var ac = new AC() { 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 };
-                                ac.renameDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<AC.DeviceRenameResponseData>(jobject["Data"].ToString());
-                                if (ac.renameDeviceData == null)
-                                {
-                                    d = new DeviceRenameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
-                                }
-                                else
-                                {
-                                    d = new DeviceRenameAllData { deviceRenameData = ac.renameDeviceData };
-                                    System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
-                                    var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == ac.DeviceID && obj.DeviceAddr == ac.DeviceAddr && obj.DeviceEpoint == ac.DeviceEpoint);
-                                    if (info != null)
-                                    {
-                                        info.DeviceEpointName = ac.renameDeviceData.DeviceName;
-                                    }
-                                }
-                                break;
-                            case DeviceType.Transverter:
-                                var transverter = new Transverter() { 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 };
-                                transverter.renameDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<Transverter.DeviceRenameResponseData>(jobject["Data"].ToString());
-                                if (transverter.renameDeviceData == null)
-                                {
-                                    d = new DeviceRenameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
-                                }
-                                else
-                                {
-                                    d = new DeviceRenameAllData { deviceRenameData = transverter.renameDeviceData };
-                                    System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
-                                    var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == transverter.DeviceID && obj.DeviceAddr == transverter.DeviceAddr && obj.DeviceEpoint == transverter.DeviceEpoint);
-                                    if (info != null)
-                                    {
-                                        info.DeviceEpointName = transverter.renameDeviceData.DeviceName;
-                                    }
-                                }
-                                break;
-                        }
+                        var receiptData = Newtonsoft.Json.JsonConvert.DeserializeObject<DeviceRenameResponseData>(jobject["Data"].ToString());
+                        d = new DeviceRenameAllData { deviceRenameData = receiptData };
                     }
                 };
                 Gateway.Actions += action;
@@ -1223,7 +1186,7 @@
                     var jObject = new JObject { { "DeviceAddr", deviceAddr }, { "Epoint", deviceEpoint }, { "Cluster_ID", 0 }, { "Command", 96 } };
                     var data = new JObject { { "DeviceName", deviceName } };
                     jObject.Add("Data", data);
-                     Gateway?.Send(("DeviceRename"), jObject.ToString());
+                    Gateway?.Send(("DeviceRename"), jObject.ToString());
                 }
                 catch { }
 
@@ -1330,198 +1293,8 @@
 
                     if (topic == gatewayID + "/" + "MacRename_Respon")
                     {
-                        var deviceID = jobject.Value<int>("Device_ID");
-                        switch ((DeviceType)(deviceID))
-                        {
-                            case DeviceType.OnOffOutput:
-                                var toggleLight = new ToggleLight() { 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 };
-                                toggleLight.renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<ToggleLight.RenameDeviceMacNameData>(jobject["Data"].ToString());
-
-                                if (toggleLight.renameDeviceMacNameData == null)
-                                {
-                                    d = new RenameDeviceMacNameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
-                                }
-                                else
-                                {
-                                    d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = toggleLight.renameDeviceMacNameData };
-                                    System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
-                                    var infoToggleLight = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == toggleLight.DeviceID && obj.DeviceAddr == toggleLight.DeviceAddr && obj.DeviceEpoint == toggleLight.DeviceEpoint);
-                                    if (infoToggleLight != null)
-                                    {
-                                        infoToggleLight.DeviceName = toggleLight.renameDeviceMacNameData.MacName;
-                                     }
-                                }
-                                break;
-                            case DeviceType.AirSwitch:
-                                var airSwitch = new AirSwitch() { 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 };
-                                airSwitch.renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<AirSwitch.RenameDeviceMacNameData>(jobject["Data"].ToString());
-
-                                if (airSwitch.renameDeviceMacNameData == null)
-                                {
-                                    d = new RenameDeviceMacNameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
-                                }
-                                else
-                                {
-                                    d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = airSwitch.renameDeviceMacNameData };
-                                    System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
-                                    var infoAirSwitch = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == airSwitch.DeviceID && obj.DeviceAddr == airSwitch.DeviceAddr && obj.DeviceEpoint == airSwitch.DeviceEpoint);
-                                    if (infoAirSwitch != null)
-                                    {
-                                        infoAirSwitch.DeviceName = airSwitch.renameDeviceMacNameData.MacName;
-                                     }
-                                }
-                                break;
-                            case DeviceType.OnOffSwitch:
-                                var panelObj = new Panel() { 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 };
-                                panelObj.renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.RenameDeviceMacNameData>(jobject["Data"].ToString());
-                                if (panelObj.renameDeviceMacNameData == null)
-                                {
-                                    d = new RenameDeviceMacNameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
-                                }
-                                else
-                                {
-                                    d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = panelObj.renameDeviceMacNameData };
-                                    System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{topic}");
-                                    var infoPanel = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == panelObj.DeviceID && obj.DeviceAddr == panelObj.DeviceAddr && obj.DeviceEpoint == panelObj.DeviceEpoint);
-                                    if (infoPanel != null)
-                                    {
-                                        infoPanel.DeviceName = panelObj.renameDeviceMacNameData.MacName;
-                                     }
-                                }
-                                break;
-                            case DeviceType.WindowCoveringDevice:
-                                var windowCovering = new Rollershade() { 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 };
-                                windowCovering.renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<Rollershade.RenameDeviceMacNameData>(jobject["Data"].ToString());
-                                if (windowCovering.renameDeviceMacNameData == null)
-                                {
-                                    d = new RenameDeviceMacNameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
-                                }
-                                else
-                                {
-                                    d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = windowCovering.renameDeviceMacNameData };
-                                    System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}_鏀跺埌閫氱煡鍚庣殑鏁版嵁_{ d.renameDeviceMacNameData.ToString()}");
-                                    var wc = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == windowCovering.DeviceID && obj.DeviceAddr == windowCovering.DeviceAddr && obj.DeviceEpoint == windowCovering.DeviceEpoint);
-                                    if (wc != null)
-                                    {
-                                        wc.DeviceName = windowCovering.renameDeviceMacNameData.MacName;
-                                     }
-                                }
-                                break;
-                            case DeviceType.IASZone:
-                                var ias = new IASZone() { 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 };
-                                ias.renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<DimmableLight.RenameDeviceMacNameData>(jobject["Data"].ToString());
-
-                                if (ias.renameDeviceMacNameData == null)
-                                {
-                                    d = new RenameDeviceMacNameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
-                                }
-                                else
-                                {
-                                    d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = ias.renameDeviceMacNameData };
-                                    System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}_鏀跺埌閫氱煡鍚庣殑鏁版嵁_{ d.renameDeviceMacNameData.ToString()}");
-                                    var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == ias.DeviceID && obj.DeviceAddr == ias.DeviceAddr && obj.DeviceEpoint == ias.DeviceEpoint);
-                                    if (info != null)
-                                    {
-                                        info.DeviceName = ias.renameDeviceMacNameData.MacName;
-                                     }
-                                }
-                                break;
-                            case DeviceType.DimmableLight:
-                                var dimmableLight = new DimmableLight() { 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 };
-                                dimmableLight.renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<DimmableLight.RenameDeviceMacNameData>(jobject["Data"].ToString());
-
-                                if (dimmableLight.renameDeviceMacNameData == null)
-                                {
-                                    d = new RenameDeviceMacNameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
-                                }
-                                else
-                                {
-                                    d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = dimmableLight.renameDeviceMacNameData };
-                                    System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}_鏀跺埌閫氱煡鍚庣殑鏁版嵁_{ d.renameDeviceMacNameData.ToString()}");
-                                    var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == dimmableLight.DeviceID && obj.DeviceAddr == dimmableLight.DeviceAddr && obj.DeviceEpoint == dimmableLight.DeviceEpoint);
-                                    if (info != null)
-                                    {
-                                        info.DeviceName = dimmableLight.renameDeviceMacNameData.MacName;
-                                     }
-                                }
-                                break;
-                            case DeviceType.Repeater:
-                                var repeater = new DimmableLight() { 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 };
-                                repeater.renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<Repeater.RenameDeviceMacNameData>(jobject["Data"].ToString());
-
-                                if (repeater.renameDeviceMacNameData == null)
-                                {
-                                    d = new RenameDeviceMacNameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
-                                }
-                                else
-                                {
-                                    d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = repeater.renameDeviceMacNameData };
-                                    System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}_鏀跺埌閫氱煡鍚庣殑鏁版嵁_{ d.renameDeviceMacNameData.ToString()}");
-                                    var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == repeater.DeviceID && obj.DeviceAddr == repeater.DeviceAddr && obj.DeviceEpoint == repeater.DeviceEpoint);
-                                    if (info != null)
-                                    {
-                                        info.DeviceName = repeater.renameDeviceMacNameData.MacName;
-                                     }
-                                }
-                                break;
-                            case DeviceType.Thermostat:
-                                var ac = new AC() { 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 };
-                                ac.renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<AC.RenameDeviceMacNameData>(jobject["Data"].ToString());
-
-                                if (ac.renameDeviceMacNameData == null)
-                                {
-                                    d = new RenameDeviceMacNameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
-                                }
-                                else
-                                {
-                                    d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = ac.renameDeviceMacNameData };
-                                    System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}_鏀跺埌閫氱煡鍚庣殑鏁版嵁_{ d.renameDeviceMacNameData.ToString()}");
-                                    var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == ac.DeviceID && obj.DeviceAddr == ac.DeviceAddr && obj.DeviceEpoint == ac.DeviceEpoint);
-                                    if (info != null)
-                                    {
-                                        info.DeviceName = ac.renameDeviceMacNameData.MacName;
-                                    }
-                                }
-                                break;
-                            case DeviceType.Transverter:
-                                var transverter = new Transverter() { 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 };
-                                transverter.renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<Transverter.RenameDeviceMacNameData>(jobject["Data"].ToString());
-
-                                if (transverter.renameDeviceMacNameData == null)
-                                {
-                                    d = new RenameDeviceMacNameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
-                                }
-                                else
-                                {
-                                    d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = transverter.renameDeviceMacNameData };
-                                    System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}_鏀跺埌閫氱煡鍚庣殑鏁版嵁_{ d.renameDeviceMacNameData.ToString()}");
-                                    var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == transverter.DeviceID && obj.DeviceAddr == transverter.DeviceAddr && obj.DeviceEpoint == transverter.DeviceEpoint);
-                                    if (info != null)
-                                    {
-                                        info.DeviceName = transverter.renameDeviceMacNameData.MacName;
-                                    }
-                                }
-                                break;
-                                //case DeviceType.TemperatureSensor:
-                                //    var temperatureSensor = new TemperatureSensor() { 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 };
-                                //    temperatureSensor.renameDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<TemperatureSensor.DeviceRenameResponseData>(jobject["Data"].ToString());
-                                //    if (temperatureSensor.renameDeviceData == null)
-                                //    {
-                                //        d.errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�";
-                                //    }
-                                //    else
-                                //    {
-                                //        d.deviceRenameData = temperatureSensor.renameDeviceData;
-                                //    }
-                                //    var ts = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == temperatureSensor.DeviceID && obj.DeviceEpoint == temperatureSensor.DeviceEpoint && obj.DeviceEpoint == temperatureSensor.DeviceEpoint);
-                                //    if (ts == null)
-                                //    {
-                                //        ts.DeviceName = temperatureSensor.renameDeviceData.DeviceName;
-                                //        IO.LocalFileUtils.SaveDeviceInfo(ts, ts.DeviceEpoint.ToString());
-
-                                //    }
-                                //    break;
-                        }
+                        var deviceID = jobject.Value<int>("Device_ID");
+                        d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<ToggleLight.RenameDeviceMacNameData>(jobject["Data"].ToString()) };
                     }
                 };
                 Gateway.Actions += action;
@@ -1536,7 +1309,7 @@
                     var jObject = new JObject { { "DeviceAddr", deviceAddr }, { "Epoint", deviceEpoint }, { "Cluster_ID", 0 }, { "Command", 100 } };
                     var data = new JObject { { "MacName", macName } };
                     jObject.Add("Data", data);
-                     Gateway?.Send(("MacRename"), jObject.ToString());
+                    Gateway?.Send(("MacRename"), jObject.ToString());
                 }
                 catch { }
 
@@ -1625,7 +1398,7 @@
             try
             {
                 var jObject = new JObject { { "DeviceAddr", deviceAddr }, { "Epoint", deviceEpoint }, { "Cluster_ID", 0 }, { "Command", 97 } };
-                 Gateway.Send("FactoryReset", jObject.ToString());
+                Gateway.Send("FactoryReset", jObject.ToString());
             }
             catch { }
 
@@ -1682,191 +1455,6 @@
                         {
                             d = new RemoveDeviceResponseAllData { removeDeviceResponseData = gatewayTemp.removeDeviceResponseData };
                             System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
-                            try
-                            {
-                                if (gatewayTemp.removeDeviceResponseData.Result == 0)
-                                {
-                                    foreach (var delD in gatewayTemp.removeDeviceResponseData.DeviceList)
-                                    {
-                                        var deviceID = delD.Device_ID;
-                                        switch ((DeviceType)(deviceID))
-                                        {
-                                            case DeviceType.OnOffOutput:
-                                                var toggleLight = new ToggleLight() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
-                                                toggleLight.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ToggleLight.RemoveDeviceResponseData>(jobject["Data"].ToString());
-                                                if (toggleLight.removeDeviceResponseData == null)
-                                                {
-                                                    return;
-                                                }
-                                                else
-                                                {
-                                                    if (toggleLight.removeDeviceResponseData.Result == 0)
-                                                    {
-                                                        var infoToggleLight = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == toggleLight.DeviceID && obj.DeviceAddr == toggleLight.DeviceAddr && obj.DeviceEpoint == toggleLight.DeviceEpoint);
-                                                        if (infoToggleLight != null)
-                                                        {
-                                                            Gateway.DeviceList.Remove(infoToggleLight);
-                                                        }
-                                                    }
-                                                }
-                                                break;
-                                            case DeviceType.AirSwitch:
-                                                var airSwitch = new AirSwitch() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
-                                                airSwitch.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<AirSwitch.RemoveDeviceResponseData>(jobject["Data"].ToString());
-                                                if (airSwitch.removeDeviceResponseData == null)
-                                                {
-                                                    return;
-                                                }
-                                                else
-                                                {
-                                                    if (airSwitch.removeDeviceResponseData.Result == 0)
-                                                    {
-                                                        var infoAirSwitch = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == airSwitch.DeviceID && obj.DeviceAddr == airSwitch.DeviceAddr && obj.DeviceEpoint == airSwitch.DeviceEpoint);
-                                                        if (infoAirSwitch != null)
-                                                        {
-                                                            Gateway.DeviceList.Remove(infoAirSwitch);
-                                                        }
-                                                    }
-                                                }
-                                                break;
-                                            case DeviceType.OnOffSwitch:
-                                                var panelObj = new Panel() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
-                                                panelObj.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.RemoveDeviceResponseData>(jobject["Data"].ToString());
-                                                if (panelObj.removeDeviceResponseData == null)
-                                                {
-                                                    return;
-                                                }
-                                                else
-                                                {
-                                                    if (panelObj.removeDeviceResponseData.Result == 0)
-                                                    {
-                                                        var infoPanel = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == panelObj.DeviceID && obj.DeviceAddr == panelObj.DeviceAddr && obj.DeviceEpoint == panelObj.DeviceEpoint);
-                                                        if (infoPanel != null)
-                                                        {
-                                                            Gateway.DeviceList.Remove(infoPanel);
-                                                        }
-                                                    }
-                                                }
-                                                break;
-                                            case DeviceType.WindowCoveringDevice:
-                                                var rollershade = new Rollershade() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
-                                                rollershade.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.RemoveDeviceResponseData>(jobject["Data"].ToString());
-                                                if (rollershade.removeDeviceResponseData == null)
-                                                {
-                                                    return;
-                                                }
-                                                else
-                                                {
-                                                    if (rollershade.removeDeviceResponseData.Result == 0)
-                                                    {
-                                                        var infoRoller = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == rollershade.DeviceID && obj.DeviceAddr == rollershade.DeviceAddr && obj.DeviceEpoint == rollershade.DeviceEpoint);
-                                                        if (infoRoller != null)
-                                                        {
-                                                            Gateway.DeviceList.Remove(infoRoller);
-                                                        }
-                                                    }
-                                                }
-                                                break;
-                                            case DeviceType.IASZone:
-                                                var ias = new IASZone() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
-                                                ias.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<IASZone.RemoveDeviceResponseData>(jobject["Data"].ToString());
-                                                if (ias.removeDeviceResponseData == null)
-                                                {
-                                                    return;
-                                                }
-                                                else
-                                                {
-                                                    if (ias.removeDeviceResponseData.Result == 0)
-                                                    {
-                                                        var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == ias.DeviceID && obj.DeviceAddr == ias.DeviceAddr && obj.DeviceEpoint == ias.DeviceEpoint);
-                                                        if (info != null)
-                                                        {
-                                                            Gateway.DeviceList.Remove(info);
-                                                        }
-                                                    }
-                                                }
-                                                break;
-                                            case DeviceType.DimmableLight:
-                                                var dimmableLight = new DimmableLight() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
-                                                dimmableLight.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<DimmableLight.RemoveDeviceResponseData>(jobject["Data"].ToString());
-                                                if (dimmableLight.removeDeviceResponseData == null)
-                                                {
-                                                    return;
-                                                }
-                                                else
-                                                {
-                                                    if (dimmableLight.removeDeviceResponseData.Result == 0)
-                                                    {
-                                                        var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == dimmableLight.DeviceID && obj.DeviceAddr == dimmableLight.DeviceAddr && obj.DeviceEpoint == dimmableLight.DeviceEpoint);
-                                                        if (info != null)
-                                                        {
-                                                            Gateway.DeviceList.Remove(info);
-                                                        }
-                                                    }
-                                                }
-                                                break;
-                                            case DeviceType.Repeater:
-                                                var repeater = new Repeater() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
-                                                repeater.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<Repeater.RemoveDeviceResponseData>(jobject["Data"].ToString());
-                                                if (repeater.removeDeviceResponseData == null)
-                                                {
-                                                    return;
-                                                }
-                                                else
-                                                {
-                                                    if (repeater.removeDeviceResponseData.Result == 0)
-                                                    {
-                                                        var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == repeater.DeviceID && obj.DeviceAddr == repeater.DeviceAddr && obj.DeviceEpoint == repeater.DeviceEpoint);
-                                                        if (info != null)
-                                                        {
-                                                            Gateway.DeviceList.Remove(info);
-                                                        }
-                                                    }
-                                                }
-                                                break;
-                                            case DeviceType.Thermostat:
-                                                var ac = new AC() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
-                                                ac.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<AC.RemoveDeviceResponseData>(jobject["Data"].ToString());
-                                                if (ac.removeDeviceResponseData == null)
-                                                {
-                                                    return;
-                                                }
-                                                else
-                                                {
-                                                    if (ac.removeDeviceResponseData.Result == 0)
-                                                    {
-                                                        var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == ac.DeviceID && obj.DeviceAddr == ac.DeviceAddr && obj.DeviceEpoint == ac.DeviceEpoint);
-                                                        if (info != null)
-                                                        {
-                                                            Gateway.DeviceList.Remove(info);
-                                                        }
-                                                    }
-                                                }
-                                                break;
-                                            case DeviceType.Transverter:
-                                                var transverter = new Transverter() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
-                                                transverter.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<Transverter.RemoveDeviceResponseData>(jobject["Data"].ToString());
-                                                if (transverter.removeDeviceResponseData == null)
-                                                {
-                                                    return;
-                                                }
-                                                else
-                                                {
-                                                    if (transverter.removeDeviceResponseData.Result == 0)
-                                                    {
-                                                        var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == transverter.DeviceID && obj.DeviceAddr == transverter.DeviceAddr && obj.DeviceEpoint == transverter.DeviceEpoint);
-                                                        if (info != null)
-                                                        {
-                                                            Gateway.DeviceList.Remove(info);
-                                                        }
-                                                    }
-                                                }
-                                                break;
-                                        }
-                                    }
-                                }
-                            }
-                            catch { }
                         }
                     }
                 };
@@ -1890,7 +1478,7 @@
                     { "DeviceAddrList", deviceAddrList }
                         };
                         jObject.Add("Data", data);
-                         Gateway.Send(("RemoveDevice"), jObject.ToString());
+                        Gateway.Send(("RemoveDevice"), jObject.ToString());
                     }
                 }
                 catch { }
@@ -2064,16 +1652,6 @@
                         {
                             d = new RemoveGatewayDeviceListAllData { removeGatewayDeviceListData = gatewayTemp.removeGatewayDeviceListData };
                             System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
-
-                            //for (int listCount = 0; listCount < Gateway.AllGatewayDeviceList.Count; listCount++)
-                            //{
-                            //    var dev = Gateway.AllGatewayDeviceList[listCount];
-                            //    if (gatewayTemp.removeGatewayDeviceListData.GwId == dev.Gateway.CurrentGateWayId)
-                            //    {
-                            //        ZigBee.Device.ZbGateway.LogicList.RemoveAt(listCount);
-                            //        listCount--;
-                            //    }
-                            //}
                         }
                     }
                 };
@@ -2086,7 +1664,7 @@
                     var jObject = new JObject { { "Cluster_ID", 0 }, { "Command", 81 } };
                     var data = new JObject { { "GwId", gwId } };
                     jObject.Add("Data", data);
-                     Gateway.Send(("RemoveEqOfGw"), jObject.ToString());
+                    Gateway.Send(("RemoveEqOfGw"), jObject.ToString());
                 }
                 catch { }
 
@@ -2179,7 +1757,7 @@
                 var jObject = new JObject { { "DeviceAddr", deviceAddr }, { "Epoint", deviceEpoint }, { "Cluster_ID", 3 }, { "Command", 0 }, { "SendMode", 2 } };
                 var data = new JObject { { "Time", time } };
                 jObject.Add("Data", data);
-                 Gateway.Send(("Identify"), jObject.ToString());
+                Gateway.Send(("Identify"), jObject.ToString());
             }
             catch { }
 
@@ -2187,500 +1765,6 @@
             System.Console.WriteLine("Identify_Actions 閫�鍑�" + System.DateTime.Now.ToString());
 
         }
-        #endregion
-
-        #region 璁惧涓婃姤杩斿洖鏁版嵁锛岀綉鍏冲洖澶嶄俊鎭�
-        ///// <summary>
-        ///// 璁惧涓婃姤杩斿洖鏁版嵁锛岀綉鍏冲洖澶嶄俊鎭�
-        ///// </summary>
-        //public DeviceReportResponAllData deviceReportResponAllData;
-        ///// <summary>
-        ///// 缃戝叧鎭㈠鍑哄巶璁剧疆杩斿洖鏁版嵁
-        ///// </summary>
-        //[System.Serializable]
-        //public class DeviceReportResponAllData
-        //{
-        //    /// <summary>
-        //    /// 閿欒淇℃伅
-        //    /// </summary>
-        //    public string errorMessageBase;
-        //    /// <summary>
-        //    /// 缃戝叧淇℃伅閿欒鍙嶉
-        //    /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para>
-        //    /// </summary>
-        //    public ErrorResponData errorResponData;
-        //    ///<summary >
-        //    ///璁惧鏁版嵁
-        //    /// </summary>
-        //    public DeviceStatusReportData deviceStatusReportData;
-        //}
-
-        ///// <summary>
-        ///// 璇诲彇鎶ュ憡灞炴�ч厤缃�,寮傛鑾峰彇鏁版嵁
-        ///// </summary>
-        ///// <param name="clusterID">Cluster identifier.</param>
-        ///// <param name="attriButeId">Attri bute identifier.</param>
-        //public async System.Threading.Tasks.Task<DeviceReportResponAllData> ReadAttriAsync(Cluster_ID clusterID, AttriButeId attriButeId)
-        //{
-        //if (Gateway == null)
-        //{
-        //    return null;
-        //}
-        ////string result = null;
-
-        //return await System.Threading.Tasks.Task.Run(async () =>
-        //{
-        //var d = new DeviceReportResponAllData();
-        //Action<string, string> action = (topic, message) =>
-        //{
-        //var gatewayID = topic.Split('/')[0];
-        //var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
-
-        //if (topic == gatewayID + "/" + "Error_Respon")
-        //{
-        //    var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
-        //    var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString());
-
-        //    if (temp == null)
-        //    {
-        //        d.errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖";
-        //    }
-        //    else
-        //    {
-        //        d.errorResponData = temp;
-        //        d.errorMessageBase = ErrorMess(temp.Error);
-        //    }
-        //}
-
-        //if (topic == gatewayID + "/" + "DeviceStatusReport" + "/" + DeviceAddr + "/" + DeviceEpoint + "/" + (int)clusterID + "/" + (int)attriButeId)
-        //{
-        //var deviceID = jobject.Value<int>("Device_ID");
-        //var deviceAddr = jobject.Value<string>("DeviceAddr");
-        //var ep = jobject.Value<int>("Epoint");
-
-        //var device = Gateway.DeviceList.Find((obj) => obj.DeviceID == deviceID && obj.DeviceAddr == deviceAddr && obj.DeviceEpoint == ep);
-        //if (device == null)
-        //{
-        //    return;
-        //}
-
-        //switch ((DeviceType)(deviceID))
-        //{
-        // case DeviceType.ColorDimmableLight:
-        //    device.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<ColorDimmableLight.DeviceStatusReportData>(jobject["Data"].ToString());
-        //    if (device.DeviceStatusReport == null)
-        //    {
-        //        d.errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖";
-        //    }
-        //    else
-        //    {
-        //        d.deviceStatusReportData = device.DeviceStatusReport;
-        //        System.Console.WriteLine($"鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
-        //        var light = device as ColorDimmableLight;
-        //        if (device.DeviceStatusReport.CluterID == 8)
-        //        {
-        //            var attriButeList = device.DeviceStatusReport.AttriBute;
-        //            foreach (var attriBute1 in attriButeList)
-        //            {
-        //                light.Level = attriBute1.AttriButeData;
-        //            }
-        //            light.ReSave();
-        //            ZigBee.Device.ZbGateway.UpdateDeviceStatus(light);
-        //        }
-        //        else if (device.DeviceStatusReport.CluterID == 6)
-        //        {
-        //            var attriButeList = device.DeviceStatusReport.AttriBute;
-        //            foreach (var attriBute1 in attriButeList)
-        //            {
-        //                light.OnOffStatus = attriBute1.AttriButeData;
-
-        //                var key = light.DeviceAddr + "_" + light.DeviceEpoint;
-        //                Gateway.sceneTaskInfoList.Remove(key);
-        //                var st = new Scene.TaskListInfo()
-        //                {
-        //                    TaskType = 1,
-        //                    Data1 = attriBute1.AttriButeData,
-        //                    Data2 = 0,
-        //                };
-        //                Gateway.sceneTaskInfoList.Add(key, st);
-        //            }
-        //            light.ReSave();
-        //            ZigBee.Device.ZbGateway.UpdateDeviceStatus(light);
-        //        }
-        //        else if (device.DeviceStatusReport.CluterID == 768)
-        //        {
-        //            var attriButeList = device.DeviceStatusReport.AttriBute;
-        //            //foreach (var attriBute1 in attriButeList)
-        //            //{
-        //            //    if (attriBute1.AttriButeId == 0)
-        //            //    {
-        //            //        light.Hue = attriBute1.AttriButeData.ToString();
-        //            //    }
-        //            //    else if ((attriBute1.AttriButeId == 1))
-        //            //    {
-        //            //        light.Saturation = attriBute1.AttriButeData.ToString();
-
-        //            //    }
-        //            //    else if ((attriBute1.AttriButeId == 16394))
-        //            //    {
-        //            //        light.ColorCapabilities = attriBute1.AttriButeData.ToString();
-        //            //    }
-        //            //    else if ((attriBute1.AttriButeId == 16384))
-        //            //    {
-        //            //        light.EnhancedCurrentHue = attriBute1.AttriButeData.ToString();
-        //            //    }
-        //            //}
-        //            light.ReSave();
-        //            ZigBee.Device.ZbGateway.UpdateDeviceStatus(light);
-        //        }
-        //    }
-        //    break;
-        // case DeviceType.OnOffSwitch:
-        //    device.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.DeviceStatusReportData>(jobject["Data"].ToString());
-        //    if (device.DeviceStatusReport == null)
-        //    {
-        //        d.errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖";
-        //    }
-        //    else
-        //    {
-        //        d.deviceStatusReportData = device.DeviceStatusReport;
-        //        System.Console.WriteLine($"鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
-
-        //        var panelObj = device as Panel;
-        //        foreach (var common in Gateway.DeviceList)
-        //        {
-        //            if (common.DeviceAddr != panelObj.DeviceAddr || common.DeviceEpoint != panelObj.DeviceEpoint)
-        //            {
-        //                continue;
-        //            }
-        //            if (common.Type == DeviceType.OnOffSwitch)
-        //            {
-        //                if (device.DeviceStatusReport.CluterID == 6)
-        //                {
-        //                    var attriButeList = device.DeviceStatusReport.AttriBute;
-        //                    foreach (var attriBute1 in attriButeList)
-        //                    {
-        //                        panelObj.panelMode = attriBute1.AttriButeData;
-        //                    }
-
-        //                }
-        //            }
-        //            panelObj.ReSave();
-        //            ZigBee.Device.ZbGateway.UpdateDeviceStatus(panelObj);
-        //        }
-        //    }
-        //     break;
-        //case DeviceType.OnOffOutput:
-        //    device.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<ToggleLight.DeviceStatusReportData>(jobject["Data"].ToString());
-        //    //if (device.DeviceStatusReport != null)
-        //    //{
-        //    //    result = "鎴愬姛";
-        //    //}
-        //    if (device.DeviceStatusReport == null)
-        //    {
-        //        d.errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖";
-        //    }
-        //    else
-        //    {
-        //        d.deviceStatusReportData = device.DeviceStatusReport;
-        //        System.Console.WriteLine($"鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
-
-        //        var lighttoggle = device as ToggleLight;
-        //        foreach (var common in Gateway.DeviceList)
-        //        {
-        //            if (common.DeviceAddr != lighttoggle.DeviceAddr || common.DeviceEpoint != lighttoggle.DeviceEpoint)
-        //            {
-        //                continue;
-        //            }
-        //            if (common.Type == DeviceType.OnOffOutput)
-        //            {
-        //                if (device.DeviceStatusReport.CluterID == 6)
-        //                {
-        //                    var attriButeList = device.DeviceStatusReport.AttriBute;
-        //                    foreach (var attriBute1 in attriButeList)
-        //                    {
-        //                        lighttoggle.OnOffStatus = attriBute1.AttriButeData;
-        //                        System.Console.WriteLine("褰撳墠寮�鍏崇姸鎬�" + "_" + attriBute1.AttriButeData.ToString() + "_" + Gateway.getGatewayBaseInfo.gwID + "_" + System.DateTime.Now.ToString());
-        //                    }
-        //                }
-        //            }
-        //            lighttoggle.ReSave();
-        //            ZigBee.Device.ZbGateway.UpdateDeviceStatus(lighttoggle);
-        //        }
-        //    }
-        //      break;
-
-        //case DeviceType.WindowCoveringDevice:
-        //    device.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<Rollershade.DeviceStatusReportData>(jobject["Data"].ToString());
-        //    if (device.DeviceStatusReport == null)
-        //    {
-        //        d.errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖";
-        //    }
-        //    else
-        //    {
-        //        d.deviceStatusReportData = device.DeviceStatusReport;
-        //        System.Console.WriteLine($"鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
-        //        var curtain = device as Rollershade;
-        //        foreach (var common in Gateway.DeviceList)
-        //        {
-        //            if (common.DeviceAddr != curtain.DeviceAddr || common.DeviceEpoint != curtain.DeviceEpoint)
-        //            {
-        //                continue;
-        //            }
-        //            if (common.Type == DeviceType.WindowCoveringDevice)
-        //            {
-        //                if (device.DeviceStatusReport.CluterID == 258)
-        //                {
-        //                    foreach (var attriBute1 in curtain.DeviceStatusReport.AttriBute)
-        //                    {
-        //                        switch (attriBute1.AttributeId)
-        //                        {
-        //                            case 0:
-        //                                curtain.WcdType = attriBute1.AttriButeData;
-        //                                System.Console.WriteLine("褰撳墠绐楀笜鐨勭被鍨�" + "_" + curtain.WcdType.ToString() + "_" + Gateway.getGatewayBaseInfo.gwID + "_" + System.DateTime.Now.ToString());
-        //                                break;
-        //                            case 3:
-        //                                curtain.WcdCurrentPositionLift = attriBute1.AttriButeData;
-        //                                System.Console.WriteLine("绐楀笜褰撳墠楂樺害" + "_" + curtain.WcdCurrentPositionLift.ToString() + "_" + Gateway.getGatewayBaseInfo.gwID + "_" + System.DateTime.Now.ToString());
-        //                                break;
-        //                            case 8:
-        //                                curtain.WcdCurrentPositionLiftPercentage = attriBute1.AttriButeData;
-        //                                System.Console.WriteLine("褰撳墠绐楀笜鎵�鍦ㄧ殑杩涘害锛堢櫨鍒嗭級浣嶇疆" + "_" + curtain.WcdCurrentPositionLiftPercentage.ToString() + "_" + Gateway.getGatewayBaseInfo.gwID + "_" + System.DateTime.Now.ToString());
-        //                                break;
-        //                            case 16:
-        //                                curtain.WcdInstalledOpenLimitLift = attriBute1.AttriButeData;
-        //                                System.Console.WriteLine("绐楀笜鍏ㄥ紑鎵�鍦ㄧ殑浣嶇疆" + "_" + curtain.WcdInstalledOpenLimitLift.ToString() + "_" + Gateway.getGatewayBaseInfo.gwID + "_" + System.DateTime.Now.ToString());
-        //                                break;
-        //                            case 17:
-        //                                curtain.WcdInstalledClosedLimitLift = attriBute1.AttriButeData;
-        //                                System.Console.WriteLine("绐楀笜鍏ㄥ叧鎵�鍦ㄧ殑浣嶇疆" + "_" + curtain.WcdCurrentPositionLift.ToString() + "_" + Gateway.getGatewayBaseInfo.gwID + "_" + System.DateTime.Now.ToString());
-        //                                break;
-        //                            case 18:
-        //                                curtain.WcdInstalledOpenLimitTilt = attriBute1.AttriButeData;
-        //                                System.Console.WriteLine("绐楀笜鍏ㄥ紑鎵�鍦ㄧ殑瑙掑害" + "_" + curtain.WcdCurrentPositionLift.ToString() + "_" + Gateway.getGatewayBaseInfo.gwID + "_" + System.DateTime.Now.ToString());
-        //                                break;
-        //                            case 19:
-        //                                curtain.WcdInstalledClosedLimitTilt = attriBute1.AttriButeData;
-        //                                System.Console.WriteLine("绐楀笜鍏ㄥ叧鎵�鍦ㄧ殑瑙掑害" + "_" + curtain.WcdCurrentPositionLift.ToString() + "_" + Gateway.getGatewayBaseInfo.gwID + "_" + System.DateTime.Now.ToString());
-        //                                break;
-        //                            case 23:
-        //                                curtain.WcdCurrentMode = attriBute1.AttriButeData;
-        //                                System.Console.WriteLine("绐楀笜褰撳墠妯″紡" + "_" + curtain.WcdCurrentMode.ToString() + "_" + Gateway.getGatewayBaseInfo.gwID + "_" + System.DateTime.Now.ToString());
-        //                                break;
-        //                            default:
-        //                                break;
-        //                        }
-        //                    }
-        //                    curtain.ReSave();
-        //                    ZigBee.Device.ZbGateway.UpdateDeviceStatus(curtain);
-        //                }
-        //            }
-        //        }
-        //    }
-        //    break;
-        //case DeviceType.IASZone:
-        //device.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<IASZone.DeviceStatusReportData>(jobject["Data"].ToString());
-        //var ias = device as IASZone;
-        //foreach (var common in Gateway.DeviceList)
-        //{
-        //    if (common.DeviceAddr != ias.DeviceAddr || common.DeviceEpoint != ias.DeviceEpoint)
-        //    {
-        //        continue;
-        //    }
-        //    if (common.Type == DeviceType.IASZone)
-        //    {
-        //        ias.ReSave();
-        //        ZigBee.Device.ZbGateway.UpdateDeviceStatus(ias);
-        //    }
-        //}
-        //ias.ReSave();
-        //break;
-        //case DeviceType.Thermostat:
-        //device.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<ThermostatObj.DeviceStatusReportData>(jobject["Data"].ToString());
-        //var ther = device as ThermostatObj;
-        //if (ther.DeviceStatusReport.CluterID == 514)
-        //{
-        //    foreach (var attriBute1 in ther.DeviceStatusReport.AttriBute)
-        //    {
-        //        if (attriBute1.AttributeId == 0)
-        //        {
-        //            ther.CurentFanControlMode = attriBute1.AttriButeData;
-        //        }
-        //    }
-        //}
-
-        //if (ther.DeviceStatusReport.CluterID == 513)
-        //{
-        //    foreach (var attriBute1 in ther.DeviceStatusReport.AttriBute)
-        //    {
-        //        if (attriBute1.AttributeId == 0)
-        //        {
-        //            ther.LocalThermostat = attriBute1.AttriButeData / 100;
-        //        }
-        //        else if (attriBute1.AttributeId == 17)
-        //        {
-        //            ther.CurentCoolingSetpoint = attriBute1.AttriButeData / 100;
-        //        }
-        //        else if (attriBute1.AttributeId == 18)
-        //        {
-        //            ther.CurentHeatingSetpoint = attriBute1.AttriButeData / 100;
-        //        }
-        //        else if (attriBute1.AttributeId == 28)
-        //        {
-        //            ther.CurentSystemMode = attriBute1.AttriButeData;
-        //        }
-        //    }
-        //}
-
-        //ZigBee.Device.ZbGateway.UpdateDeviceStatus(ther);
-        //break;
-        //case DeviceType.TemperatureSensor:
-        //var sensor = new TemperatureSensor() { 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 };
-        //sensor.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<TemperatureSensor.DeviceStatusReportData>(jobject["Data"].ToString());
-        //ZigBee.Device.ZbGateway.UpdateDeviceStatus(sensor);
-
-        //if (sensor.DeviceStatusReport.CluterID == 1026)
-        //{
-        //    foreach (var attriBute1 in sensor.DeviceStatusReport.AttriBute)
-        //    {
-        //        if (attriBute1.AttributeId == 0)
-        //        {
-        //            sensor.CurentTemperature = attriBute1.AttriButeData;
-        //        }
-        //        else if (attriBute1.AttributeId == 1)
-        //        {
-        //            sensor.MaxTemperature = attriBute1.AttriButeData;
-        //        }
-        //        else if (attriBute1.AttributeId == 2)
-        //        {
-        //            sensor.MinTemperature = attriBute1.AttriButeData;
-        //        }
-        //        else if (attriBute1.AttributeId == 3)
-        //        {
-        //            sensor.TorleranceTemperature = attriBute1.AttriButeData;
-        //        }
-        //        IO.LocalFileUtils.SaveDeviceInfo(sensor, sensor.DeviceEpoint.ToString());
-        //    }
-        //}
-        //else if (sensor.DeviceStatusReport.CluterID == 1029)
-        //{
-        //    foreach (var attriBute1 in sensor.DeviceStatusReport.AttriBute)
-        //    {
-        //        if (attriBute1.AttributeId == 0)
-        //        {
-        //            sensor.CurentHumidity = attriBute1.AttriButeData;
-        //        }
-        //        else if (attriBute1.AttributeId == 1)
-        //        {
-        //            sensor.MaxHumidity = attriBute1.AttriButeData;
-        //        }
-        //        else if (attriBute1.AttributeId == 2)
-        //        {
-        //            sensor.MinHumidity = attriBute1.AttriButeData;
-        //        }
-        //        else if (attriBute1.AttributeId == 3)
-        //        {
-        //            sensor.ToleranceHumidity = attriBute1.AttriButeData;
-        //        }
-        //        IO.LocalFileUtils.SaveDeviceInfo(sensor, sensor.DeviceEpoint.ToString());
-        //    }
-        //}
-
-        //var sen = Gateway.SensorInfoList.Find(obj => obj.DeviceAddr == sensor.DeviceAddr && obj.DeviceEpoint == sensor.DeviceEpoint);
-        //if (sen == null)
-        //{
-        //    Gateway.SensorInfoList.Add(sensor);
-        //}
-        //else
-        //{
-        //    if (sensor.DeviceStatusReport.CluterID == 1026)
-        //    {
-        //        foreach (var attriBute1 in sensor.DeviceStatusReport.AttriBute)
-        //        {
-        //            if (attriBute1.AttributeId == 0)
-        //            {
-        //                sen.CurentTemperature = attriBute1.AttriButeData;
-        //            }
-        //            else if (attriBute1.AttributeId == 1)
-        //            {
-        //                sen.MaxTemperature = attriBute1.AttriButeData;
-        //            }
-        //            else if (attriBute1.AttributeId == 2)
-        //            {
-        //                sen.MinTemperature = attriBute1.AttriButeData;
-        //            }
-        //            else if (attriBute1.AttributeId == 3)
-        //            {
-        //                sen.TorleranceTemperature = attriBute1.AttriButeData;
-        //            }
-        //            IO.LocalFileUtils.SaveDeviceInfo(sensor, sensor.DeviceEpoint.ToString());
-        //        }
-        //    }
-        //    else if (sensor.DeviceStatusReport.CluterID == 1029)
-        //    {
-        //        foreach (var attriBute1 in sensor.DeviceStatusReport.AttriBute)
-        //        {
-        //            if (attriBute1.AttributeId == 0)
-        //            {
-        //                sen.CurentHumidity = attriBute1.AttriButeData;
-        //            }
-        //            else if (attriBute1.AttributeId == 1)
-        //            {
-        //                sen.MaxHumidity = attriBute1.AttriButeData;
-        //            }
-        //            else if (attriBute1.AttributeId == 2)
-        //            {
-        //                sen.MinHumidity = attriBute1.AttriButeData;
-        //            }
-        //            else if (attriBute1.AttributeId == 3)
-        //            {
-        //                sen.ToleranceHumidity = attriBute1.AttriButeData;
-        //            }
-        //            IO.LocalFileUtils.SaveDeviceInfo(sensor, sensor.DeviceEpoint.ToString());
-        //        }
-        //    }
-        //}
-        //break;
-        //                }
-        //            }
-        //        };
-
-        //        Gateway.Actions += action;
-
-        //        var JObject = new JObject {
-        //        { "DeviceAddr",DeviceAddr },
-        //        { "Epoint", DeviceEpoint },
-        //        { "Cluster_ID", (int)clusterID },
-        //        { "Command", 108 }
-        //    };
-        //        var attriBute = new JArray{
-        //          new JObject {
-        //            { "AttriButeId", (int)attriButeId}
-        //           }
-        //    };
-        //        var data = new JObject { { "AttriBute", attriBute } };
-        //        JObject.Add("Data", data);
-        //        Gateway?.Send(("GetDeviceStatus"), Common.SecuritySet.Encryption((JObject.ToString())));
-
-        //        var dateTime = DateTime.Now;
-        //        while ((DateTime.Now - dateTime).TotalMilliseconds < 5000)
-        //        {
-        //            await System.Threading.Tasks.Task.Delay(10);
-        //            if (d.deviceStatusReportData != null)
-        //            {
-        //                break;
-        //            }
-        //        }
-        //        if ((DateTime.Now - dateTime).TotalMilliseconds > 10000)
-        //        {
-        //            d.errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔";
-        //        }
-        //        Gateway.Actions -= action;
-        //        return d;
-
-        //    });
-
-        //}
         #endregion
 
         #region 璁惧灞炴�х姸鎬佷笂鎶�
@@ -2715,11 +1799,11 @@
                     { "AttriButeId", (int)attriButeId}
                    }
            };
-                   var data = new JObject { { "AttriBute", attriBute } };
-                   JObject.Add("Data", data);
+                    var data = new JObject { { "AttriBute", attriBute } };
+                    JObject.Add("Data", data);
                     Gateway?.Send(("GetDeviceStatus"), JObject.ToString());
-               }
-               catch { }
+                }
+                catch { }
 
                 // Gateway.Actions -= action;
                 System.Console.WriteLine("GetDeviceStatus_Actions 閫�鍑�" + System.DateTime.Now.ToString());
@@ -2831,7 +1915,7 @@
                     var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", clusterID }, { "Command", 120 } };
                     var data = new JObject { { "Undivided", setWritableValue.Undivided }, { "AttributeId", setWritableValue.AttributeId }, { "AttributeDataType", setWritableValue.AttributeDataType }, { "AttributeData", setWritableValue.AttributeData } };
                     jObject.Add("Data", data);
-                     gateway.Send("SetWritableValue", jObject.ToString());
+                    gateway.Send("SetWritableValue", jObject.ToString());
                 }
                 catch { }
 
@@ -2951,7 +2035,7 @@
             try
             {
                 var jobject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 6 }, { "Command", command }, { "SendMode", 2 } };
-                 Gateway?.Send(("DeviceControl"), jobject.ToString());
+                Gateway?.Send(("DeviceControl"), jobject.ToString());
                 System.Console.WriteLine("SwitchControl_鍙戦�佹暟鎹�" + "_" + jobject.ToString() + "_" + System.DateTime.Now.ToString());
 
             }
@@ -3026,7 +2110,7 @@
                 try
                 {
                     var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", clusterID }, { "Command", 301 } };
-                     gateway.Send("Cluster/OwnAttributes", jObject.ToString());
+                    gateway.Send("Cluster/OwnAttributes", jObject.ToString());
                 }
                 catch { }
 
@@ -3283,7 +2367,7 @@
                     var jObject = new JObject { { "Cluster_ID", 25 }, { "Command", 30 } };
                     var data = new JObject { { "OTAImageName", oTAImageName }, { "OTAImagePath", "/tmp" } };
                     jObject.Add("Data", data);
-                     gateway.Send(("OTA/SetImage"), jObject.ToString());
+                    gateway.Send(("OTA/SetImage"), jObject.ToString());
                 }
                 catch
                 { }
@@ -3457,7 +2541,7 @@
                         }
                         var data = new JObject { { "DeviceList", deviceList } };
                         jObject.Add("Data", data);
-                         gateway.Send(("OTA/StartUpdate"), jObject.ToString());
+                        gateway.Send(("OTA/StartUpdate"), jObject.ToString());
                     }
                 }
                 catch
@@ -3587,37 +2671,6 @@
 
         #endregion
 
-        #region 鍚敤鎴栧叧闂妭鐐硅澶囬�忎紶鏁版嵁涓婁紶鎺ュ彛
-        /// <summary>
-        /// 鑺傜偣璁惧閫忎紶鏁版嵁鍒板鎴风
-        /// <para>缃戝叧绋嬪簭榛樿鏄叧闂�忎紶鏁版嵁涓婁紶鐨勶紝鍙互閫氳繃浠ヤ笅鎸囦护寮�鍚�忎紶鏁版嵁涓婁紶銆傞�忎紶鏁版嵁涓婁紶寮�鍚悗锛岄噸鍚綉鍏崇▼搴忛�忎紶鏁版嵁涓婁紶灏嗚繕鍘熸垚鍏抽棴鐘舵��</para>
-        /// <para>isOn 0锛氬叧闂�忎紶鏁版嵁涓婁紶</para>
-        /// <para>isOn 1锛氬紑鍚�忎紶鏁版嵁涓婁紶</para>
-        /// </summary>
-        public void OpenPassthroughControl(ZigBee.Device.ZbGateway gateway, int isOn = 1)
-        {
-            if (Gateway == null)
-            {
-                return;
-            }
-            Action<string, string> action = (topic, message) => { };
-            Gateway.Actions += action;
-            System.Console.WriteLine("OnZbDataPassthrough_Actions 鍚姩" + "_" + System.DateTime.Now.ToString());
-
-            try
-            {
-                var jObject = new JObject { { "Cluster_ID", 64513 }, { "Command", 1 } };
-                var data = new JObject { { "IsOn", isOn } };
-                jObject.Add("Data", data);
-                gateway.Send(("OnZbDataPassthrough"), jObject.ToString());
-            }
-            catch { }
-
-            Gateway.Actions -= action;
-            System.Console.WriteLine("OnZbDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString());
-        }
-        #endregion
-
         #region 瀹㈡埛绔悜鑺傜偣璁惧閫忎紶鏁版嵁.
         /// <summary>
         /// 瀹㈡埛绔悜鑺傜偣璁惧閫忎紶鏁版嵁
@@ -3671,7 +2724,6 @@
 
                 try
                 {
-                    OpenPassthroughControl(gateway);
                     var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
                     var data = new JObject { { "PassData", passData } };
                     jObject.Add("Data", data);
@@ -3837,7 +2889,7 @@
                         { "FileName", imageName }
                      };
                     jObject.Add("Data", data);
-                     gateway.Send("DownloadFile", jObject.ToString());
+                    gateway.Send("DownloadFile", jObject.ToString());
                 }
                 catch
                 {
@@ -4003,7 +3055,7 @@
                 try
                 {
                     var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", deviceEpoint }, { "Cluster_ID", 25 }, { "Command", 5 } };
-                     gateway.Send("OTA/KillUpdate", jObject.ToString());
+                    gateway.Send("OTA/KillUpdate", jObject.ToString());
                 }
                 catch
                 { }
@@ -4098,12 +3150,12 @@
             /// <summary>
             ///鍝嶅簲鎿嶄綔鐮侊紙0-ffff锛�
             /// </summary>
-            public int command=-1;
+            public string command;
             /// <summary>
             /// 鐘舵�佸��
             /// <para>0--鎴愬姛 1--澶辫触 ff--鏃犳晥</para>
             /// </summary>
-            public int status=-1;
+            public int status = -1;
         }
         #endregion
     }

--
Gitblit v1.8.0