From 404cdc88627f942df7944af04ee05b9d527752d6 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期一, 30 九月 2019 13:22:40 +0800
Subject: [PATCH] 合并了徐梅的按键面板绑定

---
 ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs |  988 +++++++++++++++++++++++++++++++--------------------------
 1 files changed, 542 insertions(+), 446 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs
old mode 100644
new mode 100755
index 42be53e..4ca338b
--- a/ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs
+++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs
@@ -46,8 +46,8 @@
         public bool IsMainGateWay
         {
             get
-            {
-                 return getGatewayBaseInfo != null && getGatewayBaseInfo.IsMainGateWay;
+            {
+                return getGatewayBaseInfo != null && getGatewayBaseInfo.IsMainGateWay;
             }
         }
 
@@ -98,7 +98,7 @@
             }
         }
 
-        #region variable
+        #region variable 
         /// <summary>
         /// 杩滅▼杩炴帴鎴愬姛鏃剁殑鏃堕棿
         /// </summary>
@@ -106,7 +106,7 @@
 
         /// <summary>
         /// 鍚屾鍒拌繙绋嬬殑褰撳墠鏃堕棿鎴�
-        /// </summary>
+        /// </summary>Re
         public static ulong CurrentTimeStamp
         {
             get
@@ -647,365 +647,365 @@
                         }
                         var deviceID = jobject.Value<int>("Device_ID");
                         switch ((DeviceType)(deviceID))
-                        {
-                            //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 = this.getGatewayBaseInfo?.gwID };
-                            //    dimmableLight.DeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<DimmableLight.DeviceInfoData>(jobject["Data"].ToString());
-                            //    if (dimmableLight.DeviceInfo == null)
-                            //    {
-                            //        return;
-                            //    }
-                            //    var light = DeviceList.Find(obj => obj.DeviceID == dimmableLight.DeviceID && obj.DeviceAddr == dimmableLight.DeviceAddr && obj.DeviceEpoint == dimmableLight.DeviceEpoint);
-                            //    if (light == null)
-                            //    {
-                            //        DeviceList.Add(dimmableLight);
-                            //        dimmableLight.DeviceName = dimmableLight.DeviceInfo.MacName;
-                            //        dimmableLight.DeviceEpointName = dimmableLight.DeviceInfo.DeviceName;
-                            //        dimmableLight.ImgVersion = dimmableLight.DeviceInfo.ImgVersion;
-                            //        dimmableLight.HwVersion = dimmableLight.DeviceInfo.HwVersion;
-                            //        dimmableLight.IsOnline = dimmableLight.DeviceInfo.IsOnline;
-                            //        dimmableLight.DriveCode = dimmableLight.DeviceInfo.DriveCode;
-                            //        dimmableLight.ImgTypeId = dimmableLight.DeviceInfo.ImgTypeId;
-                            //        dimmableLight.IasDeviceType = dimmableLight.DeviceInfo.DeviceType;
-                            //        dimmableLight.Profile = dimmableLight.DeviceInfo.Profile;
-                            //        dimmableLight.InClusterList = dimmableLight.DeviceInfo.InClusterList;
-                            //        dimmableLight.OutClusterList = dimmableLight.DeviceInfo.OutClusterList;
-                            //        dimmableLight.AttributeStatus = dimmableLight.DeviceInfo.AttributeStatus;
-                            //        //dimmableLight.Save();
-                            //    }
-                            //    else
-                            //    {
-                            //        light.DeviceInfo = dimmableLight.DeviceInfo;
-                            //        light.DeviceName = dimmableLight.DeviceInfo.MacName;
-                            //        light.DeviceEpointName = dimmableLight.DeviceInfo.DeviceName;
-                            //        light.ImgVersion = dimmableLight.DeviceInfo.ImgVersion;
-                            //        light.HwVersion = dimmableLight.DeviceInfo.HwVersion;
-                            //        light.IsOnline = dimmableLight.DeviceInfo.IsOnline;
-                            //        light.DriveCode = dimmableLight.DeviceInfo.DriveCode;
-                            //        light.ImgTypeId = dimmableLight.DeviceInfo.ImgTypeId;
-                            //        light.IasDeviceType = dimmableLight.DeviceInfo.DeviceType;
-                            //        light.Profile = dimmableLight.DeviceInfo.Profile;
-                            //        light.InClusterList = dimmableLight.DeviceInfo.InClusterList;
-                            //        light.OutClusterList = dimmableLight.DeviceInfo.OutClusterList;
-                            //        light.AttributeStatus = dimmableLight.DeviceInfo.AttributeStatus;
-                            //        //dimmableLight.ReSave();
-                            //    }
-                            //    DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
-
-                            //    break;
-                            //case DeviceType.OnOffSwitch:
-                            //    var panel = new Panel() { Time = jobject.Value<int>("Time"), DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = this.getGatewayBaseInfo?.gwID };
-                            //    panel.DeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.DeviceInfoData>(jobject["Data"].ToString());
-                            //    if (panel.DeviceInfo == null)
-                            //    {
-                            //        return;
-                            //    }
-                            //    var panelInfo = DeviceList.Find(obj => obj.DeviceID == panel.DeviceID && obj.DeviceAddr == panel.DeviceAddr && obj.DeviceEpoint == panel.DeviceEpoint);
-                            //    if (panelInfo == null)
-                            //    {
-                            //        DeviceList.Add(panel);
-                            //        panel.DeviceName = panel.DeviceInfo.MacName;
-                            //        panel.DeviceEpointName = panel.DeviceInfo.DeviceName;
-                            //        panel.ImgTypeId = panel.DeviceInfo.ImgTypeId;
-                            //        panel.ImgVersion = panel.DeviceInfo.ImgVersion;
-                            //        panel.HwVersion = panel.DeviceInfo.HwVersion;
-                            //        panel.IasDeviceType = panel.DeviceInfo.DeviceType;
-                            //        panel.IsOnline = panel.DeviceInfo.IsOnline;
-                            //        panel.DriveCode = panel.DeviceInfo.DriveCode;
-                            //        panel.Profile = panel.DeviceInfo.Profile;
-                            //        panel.InClusterList = panel.DeviceInfo.InClusterList;
-                            //        panel.OutClusterList = panel.DeviceInfo.OutClusterList;
-                            //        panel.AttributeStatus = panel.DeviceInfo.AttributeStatus;
-                            //        //panel.Save();
-                            //    }
-                            //    else
-                            //    {
-                            //        panelInfo.DeviceInfo = panel.DeviceInfo;
-                            //        panelInfo.DeviceName = panel.DeviceInfo.MacName;
-                            //        panelInfo.DeviceEpointName = panel.DeviceInfo.DeviceName;
-                            //        panelInfo.ImgVersion = panel.DeviceInfo.ImgVersion;
-                            //        panelInfo.HwVersion = panel.DeviceInfo.HwVersion;
-                            //        panelInfo.IsOnline = panel.DeviceInfo.IsOnline;
-                            //        panelInfo.DriveCode = panel.DeviceInfo.DriveCode;
-                            //        panelInfo.IasDeviceType = panel.DeviceInfo.DeviceType;
-                            //        panelInfo.Profile = panel.DeviceInfo.Profile;
-                            //        panelInfo.ImgTypeId = panel.DeviceInfo.ImgTypeId;
-                            //        panelInfo.InClusterList = panel.DeviceInfo.InClusterList;
-                            //        panelInfo.OutClusterList = panel.DeviceInfo.OutClusterList;
-                            //        panelInfo.AttributeStatus = panel.DeviceInfo.AttributeStatus;
-                            //        //panel.ReSave();
-                            //    }
-                            //    DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
-
-                            //    break;
-                            //case DeviceType.OnOffOutput:
-                            //    var toggleLight = new ToggleLight() { Time = jobject.Value<int>("Time"), DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = this.getGatewayBaseInfo?.gwID };
-                            //    toggleLight.DeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<ToggleLight.DeviceInfoData>(jobject["Data"].ToString());
-                            //    if (toggleLight.DeviceInfo == null)
-                            //    {
-                            //        return;
-                            //    }
-                            //    var toggleLightInfo = DeviceList.Find(obj => obj.DeviceID == toggleLight.DeviceID && obj.DeviceAddr == toggleLight.DeviceAddr && obj.DeviceEpoint == toggleLight.DeviceEpoint);
-                            //    if (toggleLightInfo == null)
-                            //    {
-                            //        DeviceList.Add(toggleLight);
-                            //        toggleLight.DeviceName = toggleLight.DeviceInfo.MacName;
-                            //        toggleLight.DeviceEpointName = toggleLight.DeviceInfo.DeviceName;
-                            //        toggleLight.ImgVersion = toggleLight.DeviceInfo.ImgVersion;
-                            //        toggleLight.HwVersion = toggleLight.DeviceInfo.HwVersion;
-                            //        toggleLight.IsOnline = toggleLight.DeviceInfo.IsOnline;
-                            //        toggleLight.DriveCode = toggleLight.DeviceInfo.DriveCode;
-                            //        toggleLight.IasDeviceType = toggleLight.DeviceInfo.DeviceType;
-                            //        toggleLight.Profile = toggleLight.DeviceInfo.Profile;
-                            //        toggleLight.ImgTypeId = toggleLight.DeviceInfo.ImgTypeId;
-                            //        toggleLight.InClusterList = toggleLight.DeviceInfo.InClusterList;
-                            //        toggleLight.OutClusterList = toggleLight.DeviceInfo.OutClusterList;
-                            //        toggleLight.AttributeStatus = toggleLight.DeviceInfo.AttributeStatus;
-                            //        //toggleLight.Save();
-                            //    }
-                            //    else
-                            //    {
-                            //        toggleLightInfo.DeviceName = toggleLight.DeviceInfo.MacName;
-                            //        toggleLightInfo.DeviceEpointName = toggleLight.DeviceInfo.DeviceName;
-                            //        toggleLightInfo.ImgVersion = toggleLight.DeviceInfo.ImgVersion;
-                            //        toggleLightInfo.HwVersion = toggleLight.DeviceInfo.HwVersion;
-                            //        toggleLightInfo.IsOnline = toggleLight.DeviceInfo.IsOnline;
-                            //        toggleLightInfo.DriveCode = toggleLight.DeviceInfo.DriveCode;
-                            //        toggleLightInfo.IasDeviceType = toggleLight.DeviceInfo.DeviceType;
-                            //        toggleLightInfo.Profile = toggleLight.DeviceInfo.Profile;
-                            //        toggleLightInfo.ImgTypeId = toggleLight.DeviceInfo.ImgTypeId;
-                            //        toggleLightInfo.InClusterList = toggleLight.DeviceInfo.InClusterList;
-                            //        toggleLightInfo.OutClusterList = toggleLight.DeviceInfo.OutClusterList;
-                            //        toggleLightInfo.AttributeStatus = toggleLight.DeviceInfo.AttributeStatus;
-                            //        toggleLightInfo.DeviceInfo = toggleLight.DeviceInfo;
-                            //        //toggleLightInfo.ReSave();
-                            //    }
-                            //    DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
-
-                            //    break;
-                            //case DeviceType.AirSwitch:
-                            //    var airSwitch = new AirSwitch() { Time = jobject.Value<int>("Time"), DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = this.getGatewayBaseInfo?.gwID };
-                            //    airSwitch.DeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<AirSwitch.DeviceInfoData>(jobject["Data"].ToString());
-                            //    if (airSwitch.DeviceInfo == null)
-                            //    {
-                            //        return;
-                            //    }
-                            //    var airSwitchInfo = DeviceList.Find(obj => obj.DeviceID == airSwitch.DeviceID && obj.DeviceAddr == airSwitch.DeviceAddr && obj.DeviceEpoint == airSwitch.DeviceEpoint);
-                            //    if (airSwitchInfo == null)
-                            //    {
-                            //        DeviceList.Add(airSwitch);
-                            //        airSwitch.DeviceName = airSwitch.DeviceInfo.MacName;
-                            //        airSwitch.DeviceEpointName = airSwitch.DeviceInfo.DeviceName;
-                            //        airSwitch.ImgVersion = airSwitch.DeviceInfo.ImgVersion;
-                            //        airSwitch.HwVersion = airSwitch.DeviceInfo.HwVersion;
-                            //        airSwitch.IsOnline = airSwitch.DeviceInfo.IsOnline;
-                            //        airSwitch.DriveCode = airSwitch.DeviceInfo.DriveCode;
-                            //        airSwitch.IasDeviceType = airSwitch.DeviceInfo.DeviceType;
-                            //        airSwitch.Profile = airSwitch.DeviceInfo.Profile;
-                            //        airSwitch.ImgTypeId = airSwitch.DeviceInfo.ImgTypeId;
-                            //        airSwitch.InClusterList = airSwitch.DeviceInfo.InClusterList;
-                            //        airSwitch.OutClusterList = airSwitch.DeviceInfo.OutClusterList;
-                            //        airSwitch.AttributeStatus = airSwitch.DeviceInfo.AttributeStatus;
-                            //        //airSwitch.Save();
-                            //    }
-                            //    else
-                            //    {
-                            //        airSwitchInfo.DeviceName = airSwitch.DeviceInfo.MacName;
-                            //        airSwitchInfo.DeviceEpointName = airSwitch.DeviceInfo.DeviceName;
-                            //        airSwitchInfo.ImgVersion = airSwitch.DeviceInfo.ImgVersion;
-                            //        airSwitchInfo.HwVersion = airSwitch.DeviceInfo.HwVersion;
-                            //        airSwitchInfo.IsOnline = airSwitch.DeviceInfo.IsOnline;
-                            //        airSwitchInfo.DriveCode = airSwitch.DeviceInfo.DriveCode;
-                            //        airSwitchInfo.IasDeviceType = airSwitch.DeviceInfo.DeviceType;
-                            //        airSwitchInfo.Profile = airSwitch.DeviceInfo.Profile;
-                            //        airSwitchInfo.ImgTypeId = airSwitch.DeviceInfo.ImgTypeId;
-                            //        airSwitchInfo.InClusterList = airSwitch.DeviceInfo.InClusterList;
-                            //        airSwitchInfo.OutClusterList = airSwitch.DeviceInfo.OutClusterList;
-                            //        airSwitchInfo.AttributeStatus = airSwitch.DeviceInfo.AttributeStatus;
-                            //        airSwitchInfo.DeviceInfo = airSwitch.DeviceInfo;
-                            //        // airSwitchInfo.ReSave();
-                            //    }
-                            //    DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
-
-                            //    break;
-                            //case DeviceType.WindowCoveringDevice:
-                            //    var windowCovering = new Rollershade() { DeviceID = jobject.Value<int>((object)"Device_ID"), DeviceAddr = jobject.Value<string>((object)"DeviceAddr"), DeviceEpoint = jobject.Value<int>((object)"Epoint"), DataID = jobject.Value<int>((object)"Data_ID"), CurrentGateWayId = this.getGatewayBaseInfo?.gwID };
-                            //    windowCovering.DeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<Rollershade.DeviceInfoData>(jobject["Data"].ToString());
-                            //    if (windowCovering.DeviceInfo == null)
-                            //    {
-                            //        return;
-                            //    }
-                            //    var wc = DeviceList.Find(obj => obj.DeviceID == windowCovering.DeviceID && obj.DeviceAddr == windowCovering.DeviceAddr && obj.DeviceEpoint == windowCovering.DeviceEpoint);
-                            //    if (wc == null)
-                            //    {
-                            //        DeviceList.Add(windowCovering);
-                            //        windowCovering.DeviceName = windowCovering.DeviceInfo.MacName;
-                            //        windowCovering.DeviceEpointName = windowCovering.DeviceInfo.DeviceName;
-                            //        windowCovering.ImgVersion = windowCovering.DeviceInfo.ImgVersion;
-                            //        windowCovering.HwVersion = windowCovering.DeviceInfo.HwVersion;
-                            //        windowCovering.IsOnline = windowCovering.DeviceInfo.IsOnline;
-                            //        windowCovering.DriveCode = windowCovering.DeviceInfo.DriveCode;
-                            //        windowCovering.IasDeviceType = windowCovering.DeviceInfo.DeviceType;
-                            //        windowCovering.Profile = windowCovering.DeviceInfo.Profile;
-                            //        windowCovering.ImgTypeId = windowCovering.DeviceInfo.ImgTypeId;
-                            //        windowCovering.InClusterList = windowCovering.DeviceInfo.InClusterList;
-                            //        windowCovering.OutClusterList = windowCovering.DeviceInfo.OutClusterList;
-                            //        windowCovering.AttributeStatus = windowCovering.DeviceInfo.AttributeStatus;
-                            //        //windowCovering.Save();
-                            //    }
-                            //    else
-                            //    {
-                            //        wc.DeviceName = windowCovering.DeviceInfo.MacName;
-                            //        wc.DeviceEpointName = windowCovering.DeviceInfo.DeviceName;
-                            //        wc.DeviceInfo = windowCovering.DeviceInfo;
-                            //        wc.ImgVersion = windowCovering.DeviceInfo.ImgVersion;
-                            //        wc.HwVersion = windowCovering.DeviceInfo.HwVersion;
-                            //        wc.IsOnline = windowCovering.DeviceInfo.IsOnline;
-                            //        wc.DriveCode = windowCovering.DeviceInfo.DriveCode;
-                            //        wc.IasDeviceType = windowCovering.DeviceInfo.DeviceType;
-                            //        wc.Profile = windowCovering.DeviceInfo.Profile;
-                            //        wc.ImgTypeId = windowCovering.DeviceInfo.ImgTypeId;
-                            //        wc.InClusterList = windowCovering.DeviceInfo.InClusterList;
-                            //        wc.OutClusterList = windowCovering.DeviceInfo.OutClusterList;
-                            //        wc.AttributeStatus = windowCovering.DeviceInfo.AttributeStatus;
-                            //        // wc.ReSave();
-                            //    }
-                            //    DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
-                            //    break;
-                            //case DeviceType.IASZone:
-                            //    var ias = new IASZone() { Time = jobject.Value<int>("Time"), DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = this.getGatewayBaseInfo?.gwID };
-                            //    ias.DeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<IASZone.DeviceInfoData>(jobject["Data"].ToString());
-                            //    if (ias.DeviceInfo == null)
-                            //    {
-                            //        return;
-                            //    }
-                            //    var infoIAS = DeviceList.Find(obj => obj.DeviceID == ias.DeviceID && obj.DeviceAddr == ias.DeviceAddr && obj.DeviceEpoint == ias.DeviceEpoint);
-                            //    if (infoIAS == null)
-                            //    {
-                            //        DeviceList.Add(ias);
-                            //        ias.DeviceName = ias.DeviceInfo.MacName;
-                            //        ias.DeviceEpointName = ias.DeviceInfo.DeviceName;
-                            //        ias.ImgVersion = ias.DeviceInfo.ImgVersion;
-                            //        ias.HwVersion = ias.DeviceInfo.HwVersion;
-                            //        ias.IsOnline = ias.DeviceInfo.IsOnline;
-                            //        ias.DriveCode = ias.DeviceInfo.DriveCode;
-                            //        ias.IasDeviceType = ias.DeviceInfo.DeviceType;
-                            //        ias.Profile = ias.DeviceInfo.Profile;
-                            //        ias.ImgTypeId = ias.DeviceInfo.ImgTypeId;
-                            //        ias.InClusterList = ias.DeviceInfo.InClusterList;
-                            //        ias.OutClusterList = ias.DeviceInfo.OutClusterList;
-                            //        ias.AttributeStatus = ias.DeviceInfo.AttributeStatus;
-                            //        //ias.Save();
-                            //    }
-                            //    else
-                            //    {
-                            //        infoIAS.DeviceName = ias.DeviceInfo.MacName;
-                            //        infoIAS.DeviceEpointName = ias.DeviceInfo.DeviceName;
-                            //        infoIAS.DeviceEpointName = ias.DeviceInfo.DeviceName;
-                            //        infoIAS.ImgVersion = ias.DeviceInfo.ImgVersion;
-                            //        infoIAS.HwVersion = ias.DeviceInfo.HwVersion;
-                            //        infoIAS.IsOnline = ias.DeviceInfo.IsOnline;
-                            //        infoIAS.DriveCode = ias.DeviceInfo.DriveCode;
-                            //        infoIAS.IasDeviceType = ias.DeviceInfo.DeviceType;
-                            //        infoIAS.Profile = ias.DeviceInfo.Profile;
-                            //        infoIAS.ImgTypeId = ias.DeviceInfo.ImgTypeId;
-                            //        infoIAS.InClusterList = ias.DeviceInfo.InClusterList;
-                            //        infoIAS.OutClusterList = ias.DeviceInfo.OutClusterList;
-                            //        infoIAS.AttributeStatus = ias.DeviceInfo.AttributeStatus;
-                            //        infoIAS.DeviceInfo = ias.DeviceInfo;
-                            //        //ias.ReSave();
-                            //    }
-                            //    DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
-                            //    break;
-                            //case DeviceType.OtaDevice:
-                            //case DeviceType.OtaPanelDevice:
-                                //var ota = new OTADevice() { Time = jobject.Value<int>("Time"), DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = this.getGatewayBaseInfo?.gwID };
-                                //ota.DeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<DeviceInfoData>(jobject["Data"].ToString());
-                                //if (ota.DeviceInfo == null)
-                                //{
-                                //    return;
-                                //}
-                                //var infoOta = DeviceList.Find(obj => obj.DeviceID == ota.DeviceID && obj.DeviceAddr == ota.DeviceAddr && obj.DeviceEpoint == ota.DeviceEpoint);
-                                //if (infoOta == null)
-                                //{
-                                //    DeviceList.Add(ota);
-                                //    ota.DeviceName = ota.DeviceInfo.MacName;
-                                //    ota.DeviceEpointName = ota.DeviceInfo.DeviceName;
-                                //    ota.ImgVersion = ota.DeviceInfo.ImgVersion;
-                                //    ota.HwVersion = ota.DeviceInfo.HwVersion;
-                                //    ota.IsOnline = ota.DeviceInfo.IsOnline;
-                                //    ota.DriveCode = ota.DeviceInfo.DriveCode;
-                                //    ota.IasDeviceType = ota.DeviceInfo.DeviceType;
-                                //    ota.Profile = ota.DeviceInfo.Profile;
-                                //    ota.ImgTypeId = ota.DeviceInfo.ImgTypeId;
-                                //    ota.InClusterList = ota.DeviceInfo.InClusterList;
-                                //    ota.OutClusterList = ota.DeviceInfo.OutClusterList;
-                                //    ota.AttributeStatus = ota.DeviceInfo.AttributeStatus;
-                                //    //ota.Save();
-                                //}
-                                //else
-                                //{
-                                //    infoOta.DeviceName = ota.DeviceInfo.MacName;
-                                //    infoOta.DeviceEpointName = ota.DeviceInfo.DeviceName;
-                                //    infoOta.DeviceEpointName = ota.DeviceInfo.DeviceName;
-                                //    infoOta.ImgVersion = ota.DeviceInfo.ImgVersion;
-                                //    infoOta.HwVersion = ota.DeviceInfo.HwVersion;
-                                //    infoOta.IsOnline = ota.DeviceInfo.IsOnline;
-                                //    infoOta.DriveCode = ota.DeviceInfo.DriveCode;
-                                //    infoOta.IasDeviceType = ota.DeviceInfo.DeviceType;
-                                //    infoOta.Profile = ota.DeviceInfo.Profile;
-                                //    infoOta.ImgTypeId = ota.DeviceInfo.ImgTypeId;
-                                //    infoOta.InClusterList = ota.DeviceInfo.InClusterList;
-                                //    infoOta.OutClusterList = ota.DeviceInfo.OutClusterList;
-                                //    infoOta.AttributeStatus = ota.DeviceInfo.AttributeStatus;
-                                //    infoOta.DeviceInfo = ota.DeviceInfo;
-                                //    //ota.ReSave();
-                                //}
-                                //DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
-                                //break;
-                                //case DeviceType.Thermostat:
-                                //var thermostat = new ThermostatObj() { 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 };
-                                //thermostat.DeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<ThermostatObj.DeviceInfoData>(jobject["Data"].ToString());
-                                //if (thermostat.DeviceInfo == null)
-                                //{
-                                //    return;
-                                //}
-                                //var ther = gateway.DeviceList.Find(obj => obj.DeviceID == thermostat.DeviceID && obj.DeviceAddr == thermostat.DeviceAddr && obj.DeviceEpoint == thermostat.DeviceEpoint);
-                                //if (ther == null)
-                                //{
-                                //    gateway.DeviceList.Add(thermostat);
-                                //    thermostat.DeviceName = thermostat.DeviceInfo.DeviceName;
-                                //    IO.LocalFileUtils.SaveDeviceInfo(thermostat, thermostat.DeviceEpoint.ToString());
-                                //}
-                                //else
-                                //{
-                                //    ther.DeviceName = thermostat.DeviceInfo.DeviceName;
-                                //    ther.DeviceInfo = thermostat.DeviceInfo;
-                                //    ZigBee.IO.LocalFileUtils.SaveDeviceInfo(ther, ther.DeviceEpoint.ToString());
-                                //}
-                                //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.getGatewayBaseInfo.gwID };
-                                //temperatureSensor.DeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<TemperatureSensor.DeviceInfoData>(jobject["Data"].ToString());
-                                //if (temperatureSensor.DeviceInfo == null)
-                                //{
-                                //    return;
-                                //}
-                                //var ts = gateway.DeviceList.Find(obj => obj.DeviceID == temperatureSensor.DeviceID && obj.DeviceAddr == temperatureSensor.DeviceAddr && obj.DeviceEpoint == temperatureSensor.DeviceEpoint);
-                                //if (ts == null)
-                                //{
-                                //    gateway.DeviceList.Add(temperatureSensor);
-                                //    temperatureSensor.DeviceName = temperatureSensor.DeviceInfo.DeviceName;
-                                //    IO.LocalFileUtils.SaveDeviceInfo(temperatureSensor, temperatureSensor.DeviceEpoint.ToString());
-                                //}
-                                //else
-                                //{
-                                //    ts.DeviceName = temperatureSensor.DeviceInfo.DeviceName;
-                                //    ts.DeviceInfo = temperatureSensor.DeviceInfo;
-                                //    IO.LocalFileUtils.SaveDeviceInfo(ts, ts.DeviceEpoint.ToString());
-                                //}
-                                //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 = this.getGatewayBaseInfo?.gwID };
+                            //    dimmableLight.DeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<DimmableLight.DeviceInfoData>(jobject["Data"].ToString());
+                            //    if (dimmableLight.DeviceInfo == null)
+                            //    {
+                            //        return;
+                            //    }
+                            //    var light = DeviceList.Find(obj => obj.DeviceID == dimmableLight.DeviceID && obj.DeviceAddr == dimmableLight.DeviceAddr && obj.DeviceEpoint == dimmableLight.DeviceEpoint);
+                            //    if (light == null)
+                            //    {
+                            //        DeviceList.Add(dimmableLight);
+                            //        dimmableLight.DeviceName = dimmableLight.DeviceInfo.MacName;
+                            //        dimmableLight.DeviceEpointName = dimmableLight.DeviceInfo.DeviceName;
+                            //        dimmableLight.ImgVersion = dimmableLight.DeviceInfo.ImgVersion;
+                            //        dimmableLight.HwVersion = dimmableLight.DeviceInfo.HwVersion;
+                            //        dimmableLight.IsOnline = dimmableLight.DeviceInfo.IsOnline;
+                            //        dimmableLight.DriveCode = dimmableLight.DeviceInfo.DriveCode;
+                            //        dimmableLight.ImgTypeId = dimmableLight.DeviceInfo.ImgTypeId;
+                            //        dimmableLight.IasDeviceType = dimmableLight.DeviceInfo.DeviceType;
+                            //        dimmableLight.Profile = dimmableLight.DeviceInfo.Profile;
+                            //        dimmableLight.InClusterList = dimmableLight.DeviceInfo.InClusterList;
+                            //        dimmableLight.OutClusterList = dimmableLight.DeviceInfo.OutClusterList;
+                            //        dimmableLight.AttributeStatus = dimmableLight.DeviceInfo.AttributeStatus;
+                            //        //dimmableLight.Save();
+                            //    }
+                            //    else
+                            //    {
+                            //        light.DeviceInfo = dimmableLight.DeviceInfo;
+                            //        light.DeviceName = dimmableLight.DeviceInfo.MacName;
+                            //        light.DeviceEpointName = dimmableLight.DeviceInfo.DeviceName;
+                            //        light.ImgVersion = dimmableLight.DeviceInfo.ImgVersion;
+                            //        light.HwVersion = dimmableLight.DeviceInfo.HwVersion;
+                            //        light.IsOnline = dimmableLight.DeviceInfo.IsOnline;
+                            //        light.DriveCode = dimmableLight.DeviceInfo.DriveCode;
+                            //        light.ImgTypeId = dimmableLight.DeviceInfo.ImgTypeId;
+                            //        light.IasDeviceType = dimmableLight.DeviceInfo.DeviceType;
+                            //        light.Profile = dimmableLight.DeviceInfo.Profile;
+                            //        light.InClusterList = dimmableLight.DeviceInfo.InClusterList;
+                            //        light.OutClusterList = dimmableLight.DeviceInfo.OutClusterList;
+                            //        light.AttributeStatus = dimmableLight.DeviceInfo.AttributeStatus;
+                            //        //dimmableLight.ReSave();
+                            //    }
+                            //    DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
+
+                            //    break;
+                            //case DeviceType.OnOffSwitch:
+                            //    var panel = new Panel() { Time = jobject.Value<int>("Time"), DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = this.getGatewayBaseInfo?.gwID };
+                            //    panel.DeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.DeviceInfoData>(jobject["Data"].ToString());
+                            //    if (panel.DeviceInfo == null)
+                            //    {
+                            //        return;
+                            //    }
+                            //    var panelInfo = DeviceList.Find(obj => obj.DeviceID == panel.DeviceID && obj.DeviceAddr == panel.DeviceAddr && obj.DeviceEpoint == panel.DeviceEpoint);
+                            //    if (panelInfo == null)
+                            //    {
+                            //        DeviceList.Add(panel);
+                            //        panel.DeviceName = panel.DeviceInfo.MacName;
+                            //        panel.DeviceEpointName = panel.DeviceInfo.DeviceName;
+                            //        panel.ImgTypeId = panel.DeviceInfo.ImgTypeId;
+                            //        panel.ImgVersion = panel.DeviceInfo.ImgVersion;
+                            //        panel.HwVersion = panel.DeviceInfo.HwVersion;
+                            //        panel.IasDeviceType = panel.DeviceInfo.DeviceType;
+                            //        panel.IsOnline = panel.DeviceInfo.IsOnline;
+                            //        panel.DriveCode = panel.DeviceInfo.DriveCode;
+                            //        panel.Profile = panel.DeviceInfo.Profile;
+                            //        panel.InClusterList = panel.DeviceInfo.InClusterList;
+                            //        panel.OutClusterList = panel.DeviceInfo.OutClusterList;
+                            //        panel.AttributeStatus = panel.DeviceInfo.AttributeStatus;
+                            //        //panel.Save();
+                            //    }
+                            //    else
+                            //    {
+                            //        panelInfo.DeviceInfo = panel.DeviceInfo;
+                            //        panelInfo.DeviceName = panel.DeviceInfo.MacName;
+                            //        panelInfo.DeviceEpointName = panel.DeviceInfo.DeviceName;
+                            //        panelInfo.ImgVersion = panel.DeviceInfo.ImgVersion;
+                            //        panelInfo.HwVersion = panel.DeviceInfo.HwVersion;
+                            //        panelInfo.IsOnline = panel.DeviceInfo.IsOnline;
+                            //        panelInfo.DriveCode = panel.DeviceInfo.DriveCode;
+                            //        panelInfo.IasDeviceType = panel.DeviceInfo.DeviceType;
+                            //        panelInfo.Profile = panel.DeviceInfo.Profile;
+                            //        panelInfo.ImgTypeId = panel.DeviceInfo.ImgTypeId;
+                            //        panelInfo.InClusterList = panel.DeviceInfo.InClusterList;
+                            //        panelInfo.OutClusterList = panel.DeviceInfo.OutClusterList;
+                            //        panelInfo.AttributeStatus = panel.DeviceInfo.AttributeStatus;
+                            //        //panel.ReSave();
+                            //    }
+                            //    DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
+
+                            //    break;
+                            //case DeviceType.OnOffOutput:
+                            //    var toggleLight = new ToggleLight() { Time = jobject.Value<int>("Time"), DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = this.getGatewayBaseInfo?.gwID };
+                            //    toggleLight.DeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<ToggleLight.DeviceInfoData>(jobject["Data"].ToString());
+                            //    if (toggleLight.DeviceInfo == null)
+                            //    {
+                            //        return;
+                            //    }
+                            //    var toggleLightInfo = DeviceList.Find(obj => obj.DeviceID == toggleLight.DeviceID && obj.DeviceAddr == toggleLight.DeviceAddr && obj.DeviceEpoint == toggleLight.DeviceEpoint);
+                            //    if (toggleLightInfo == null)
+                            //    {
+                            //        DeviceList.Add(toggleLight);
+                            //        toggleLight.DeviceName = toggleLight.DeviceInfo.MacName;
+                            //        toggleLight.DeviceEpointName = toggleLight.DeviceInfo.DeviceName;
+                            //        toggleLight.ImgVersion = toggleLight.DeviceInfo.ImgVersion;
+                            //        toggleLight.HwVersion = toggleLight.DeviceInfo.HwVersion;
+                            //        toggleLight.IsOnline = toggleLight.DeviceInfo.IsOnline;
+                            //        toggleLight.DriveCode = toggleLight.DeviceInfo.DriveCode;
+                            //        toggleLight.IasDeviceType = toggleLight.DeviceInfo.DeviceType;
+                            //        toggleLight.Profile = toggleLight.DeviceInfo.Profile;
+                            //        toggleLight.ImgTypeId = toggleLight.DeviceInfo.ImgTypeId;
+                            //        toggleLight.InClusterList = toggleLight.DeviceInfo.InClusterList;
+                            //        toggleLight.OutClusterList = toggleLight.DeviceInfo.OutClusterList;
+                            //        toggleLight.AttributeStatus = toggleLight.DeviceInfo.AttributeStatus;
+                            //        //toggleLight.Save();
+                            //    }
+                            //    else
+                            //    {
+                            //        toggleLightInfo.DeviceName = toggleLight.DeviceInfo.MacName;
+                            //        toggleLightInfo.DeviceEpointName = toggleLight.DeviceInfo.DeviceName;
+                            //        toggleLightInfo.ImgVersion = toggleLight.DeviceInfo.ImgVersion;
+                            //        toggleLightInfo.HwVersion = toggleLight.DeviceInfo.HwVersion;
+                            //        toggleLightInfo.IsOnline = toggleLight.DeviceInfo.IsOnline;
+                            //        toggleLightInfo.DriveCode = toggleLight.DeviceInfo.DriveCode;
+                            //        toggleLightInfo.IasDeviceType = toggleLight.DeviceInfo.DeviceType;
+                            //        toggleLightInfo.Profile = toggleLight.DeviceInfo.Profile;
+                            //        toggleLightInfo.ImgTypeId = toggleLight.DeviceInfo.ImgTypeId;
+                            //        toggleLightInfo.InClusterList = toggleLight.DeviceInfo.InClusterList;
+                            //        toggleLightInfo.OutClusterList = toggleLight.DeviceInfo.OutClusterList;
+                            //        toggleLightInfo.AttributeStatus = toggleLight.DeviceInfo.AttributeStatus;
+                            //        toggleLightInfo.DeviceInfo = toggleLight.DeviceInfo;
+                            //        //toggleLightInfo.ReSave();
+                            //    }
+                            //    DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
+
+                            //    break;
+                            //case DeviceType.AirSwitch:
+                            //    var airSwitch = new AirSwitch() { Time = jobject.Value<int>("Time"), DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = this.getGatewayBaseInfo?.gwID };
+                            //    airSwitch.DeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<AirSwitch.DeviceInfoData>(jobject["Data"].ToString());
+                            //    if (airSwitch.DeviceInfo == null)
+                            //    {
+                            //        return;
+                            //    }
+                            //    var airSwitchInfo = DeviceList.Find(obj => obj.DeviceID == airSwitch.DeviceID && obj.DeviceAddr == airSwitch.DeviceAddr && obj.DeviceEpoint == airSwitch.DeviceEpoint);
+                            //    if (airSwitchInfo == null)
+                            //    {
+                            //        DeviceList.Add(airSwitch);
+                            //        airSwitch.DeviceName = airSwitch.DeviceInfo.MacName;
+                            //        airSwitch.DeviceEpointName = airSwitch.DeviceInfo.DeviceName;
+                            //        airSwitch.ImgVersion = airSwitch.DeviceInfo.ImgVersion;
+                            //        airSwitch.HwVersion = airSwitch.DeviceInfo.HwVersion;
+                            //        airSwitch.IsOnline = airSwitch.DeviceInfo.IsOnline;
+                            //        airSwitch.DriveCode = airSwitch.DeviceInfo.DriveCode;
+                            //        airSwitch.IasDeviceType = airSwitch.DeviceInfo.DeviceType;
+                            //        airSwitch.Profile = airSwitch.DeviceInfo.Profile;
+                            //        airSwitch.ImgTypeId = airSwitch.DeviceInfo.ImgTypeId;
+                            //        airSwitch.InClusterList = airSwitch.DeviceInfo.InClusterList;
+                            //        airSwitch.OutClusterList = airSwitch.DeviceInfo.OutClusterList;
+                            //        airSwitch.AttributeStatus = airSwitch.DeviceInfo.AttributeStatus;
+                            //        //airSwitch.Save();
+                            //    }
+                            //    else
+                            //    {
+                            //        airSwitchInfo.DeviceName = airSwitch.DeviceInfo.MacName;
+                            //        airSwitchInfo.DeviceEpointName = airSwitch.DeviceInfo.DeviceName;
+                            //        airSwitchInfo.ImgVersion = airSwitch.DeviceInfo.ImgVersion;
+                            //        airSwitchInfo.HwVersion = airSwitch.DeviceInfo.HwVersion;
+                            //        airSwitchInfo.IsOnline = airSwitch.DeviceInfo.IsOnline;
+                            //        airSwitchInfo.DriveCode = airSwitch.DeviceInfo.DriveCode;
+                            //        airSwitchInfo.IasDeviceType = airSwitch.DeviceInfo.DeviceType;
+                            //        airSwitchInfo.Profile = airSwitch.DeviceInfo.Profile;
+                            //        airSwitchInfo.ImgTypeId = airSwitch.DeviceInfo.ImgTypeId;
+                            //        airSwitchInfo.InClusterList = airSwitch.DeviceInfo.InClusterList;
+                            //        airSwitchInfo.OutClusterList = airSwitch.DeviceInfo.OutClusterList;
+                            //        airSwitchInfo.AttributeStatus = airSwitch.DeviceInfo.AttributeStatus;
+                            //        airSwitchInfo.DeviceInfo = airSwitch.DeviceInfo;
+                            //        // airSwitchInfo.ReSave();
+                            //    }
+                            //    DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
+
+                            //    break;
+                            //case DeviceType.WindowCoveringDevice:
+                            //    var windowCovering = new Rollershade() { DeviceID = jobject.Value<int>((object)"Device_ID"), DeviceAddr = jobject.Value<string>((object)"DeviceAddr"), DeviceEpoint = jobject.Value<int>((object)"Epoint"), DataID = jobject.Value<int>((object)"Data_ID"), CurrentGateWayId = this.getGatewayBaseInfo?.gwID };
+                            //    windowCovering.DeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<Rollershade.DeviceInfoData>(jobject["Data"].ToString());
+                            //    if (windowCovering.DeviceInfo == null)
+                            //    {
+                            //        return;
+                            //    }
+                            //    var wc = DeviceList.Find(obj => obj.DeviceID == windowCovering.DeviceID && obj.DeviceAddr == windowCovering.DeviceAddr && obj.DeviceEpoint == windowCovering.DeviceEpoint);
+                            //    if (wc == null)
+                            //    {
+                            //        DeviceList.Add(windowCovering);
+                            //        windowCovering.DeviceName = windowCovering.DeviceInfo.MacName;
+                            //        windowCovering.DeviceEpointName = windowCovering.DeviceInfo.DeviceName;
+                            //        windowCovering.ImgVersion = windowCovering.DeviceInfo.ImgVersion;
+                            //        windowCovering.HwVersion = windowCovering.DeviceInfo.HwVersion;
+                            //        windowCovering.IsOnline = windowCovering.DeviceInfo.IsOnline;
+                            //        windowCovering.DriveCode = windowCovering.DeviceInfo.DriveCode;
+                            //        windowCovering.IasDeviceType = windowCovering.DeviceInfo.DeviceType;
+                            //        windowCovering.Profile = windowCovering.DeviceInfo.Profile;
+                            //        windowCovering.ImgTypeId = windowCovering.DeviceInfo.ImgTypeId;
+                            //        windowCovering.InClusterList = windowCovering.DeviceInfo.InClusterList;
+                            //        windowCovering.OutClusterList = windowCovering.DeviceInfo.OutClusterList;
+                            //        windowCovering.AttributeStatus = windowCovering.DeviceInfo.AttributeStatus;
+                            //        //windowCovering.Save();
+                            //    }
+                            //    else
+                            //    {
+                            //        wc.DeviceName = windowCovering.DeviceInfo.MacName;
+                            //        wc.DeviceEpointName = windowCovering.DeviceInfo.DeviceName;
+                            //        wc.DeviceInfo = windowCovering.DeviceInfo;
+                            //        wc.ImgVersion = windowCovering.DeviceInfo.ImgVersion;
+                            //        wc.HwVersion = windowCovering.DeviceInfo.HwVersion;
+                            //        wc.IsOnline = windowCovering.DeviceInfo.IsOnline;
+                            //        wc.DriveCode = windowCovering.DeviceInfo.DriveCode;
+                            //        wc.IasDeviceType = windowCovering.DeviceInfo.DeviceType;
+                            //        wc.Profile = windowCovering.DeviceInfo.Profile;
+                            //        wc.ImgTypeId = windowCovering.DeviceInfo.ImgTypeId;
+                            //        wc.InClusterList = windowCovering.DeviceInfo.InClusterList;
+                            //        wc.OutClusterList = windowCovering.DeviceInfo.OutClusterList;
+                            //        wc.AttributeStatus = windowCovering.DeviceInfo.AttributeStatus;
+                            //        // wc.ReSave();
+                            //    }
+                            //    DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
+                            //    break;
+                            //case DeviceType.IASZone:
+                            //    var ias = new IASZone() { Time = jobject.Value<int>("Time"), DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = this.getGatewayBaseInfo?.gwID };
+                            //    ias.DeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<IASZone.DeviceInfoData>(jobject["Data"].ToString());
+                            //    if (ias.DeviceInfo == null)
+                            //    {
+                            //        return;
+                            //    }
+                            //    var infoIAS = DeviceList.Find(obj => obj.DeviceID == ias.DeviceID && obj.DeviceAddr == ias.DeviceAddr && obj.DeviceEpoint == ias.DeviceEpoint);
+                            //    if (infoIAS == null)
+                            //    {
+                            //        DeviceList.Add(ias);
+                            //        ias.DeviceName = ias.DeviceInfo.MacName;
+                            //        ias.DeviceEpointName = ias.DeviceInfo.DeviceName;
+                            //        ias.ImgVersion = ias.DeviceInfo.ImgVersion;
+                            //        ias.HwVersion = ias.DeviceInfo.HwVersion;
+                            //        ias.IsOnline = ias.DeviceInfo.IsOnline;
+                            //        ias.DriveCode = ias.DeviceInfo.DriveCode;
+                            //        ias.IasDeviceType = ias.DeviceInfo.DeviceType;
+                            //        ias.Profile = ias.DeviceInfo.Profile;
+                            //        ias.ImgTypeId = ias.DeviceInfo.ImgTypeId;
+                            //        ias.InClusterList = ias.DeviceInfo.InClusterList;
+                            //        ias.OutClusterList = ias.DeviceInfo.OutClusterList;
+                            //        ias.AttributeStatus = ias.DeviceInfo.AttributeStatus;
+                            //        //ias.Save();
+                            //    }
+                            //    else
+                            //    {
+                            //        infoIAS.DeviceName = ias.DeviceInfo.MacName;
+                            //        infoIAS.DeviceEpointName = ias.DeviceInfo.DeviceName;
+                            //        infoIAS.DeviceEpointName = ias.DeviceInfo.DeviceName;
+                            //        infoIAS.ImgVersion = ias.DeviceInfo.ImgVersion;
+                            //        infoIAS.HwVersion = ias.DeviceInfo.HwVersion;
+                            //        infoIAS.IsOnline = ias.DeviceInfo.IsOnline;
+                            //        infoIAS.DriveCode = ias.DeviceInfo.DriveCode;
+                            //        infoIAS.IasDeviceType = ias.DeviceInfo.DeviceType;
+                            //        infoIAS.Profile = ias.DeviceInfo.Profile;
+                            //        infoIAS.ImgTypeId = ias.DeviceInfo.ImgTypeId;
+                            //        infoIAS.InClusterList = ias.DeviceInfo.InClusterList;
+                            //        infoIAS.OutClusterList = ias.DeviceInfo.OutClusterList;
+                            //        infoIAS.AttributeStatus = ias.DeviceInfo.AttributeStatus;
+                            //        infoIAS.DeviceInfo = ias.DeviceInfo;
+                            //        //ias.ReSave();
+                            //    }
+                            //    DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
+                            //    break;
+                            //case DeviceType.OtaDevice:
+                            //case DeviceType.OtaPanelDevice:
+                            //var ota = new OTADevice() { Time = jobject.Value<int>("Time"), DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = this.getGatewayBaseInfo?.gwID };
+                            //ota.DeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<DeviceInfoData>(jobject["Data"].ToString());
+                            //if (ota.DeviceInfo == null)
+                            //{
+                            //    return;
+                            //}
+                            //var infoOta = DeviceList.Find(obj => obj.DeviceID == ota.DeviceID && obj.DeviceAddr == ota.DeviceAddr && obj.DeviceEpoint == ota.DeviceEpoint);
+                            //if (infoOta == null)
+                            //{
+                            //    DeviceList.Add(ota);
+                            //    ota.DeviceName = ota.DeviceInfo.MacName;
+                            //    ota.DeviceEpointName = ota.DeviceInfo.DeviceName;
+                            //    ota.ImgVersion = ota.DeviceInfo.ImgVersion;
+                            //    ota.HwVersion = ota.DeviceInfo.HwVersion;
+                            //    ota.IsOnline = ota.DeviceInfo.IsOnline;
+                            //    ota.DriveCode = ota.DeviceInfo.DriveCode;
+                            //    ota.IasDeviceType = ota.DeviceInfo.DeviceType;
+                            //    ota.Profile = ota.DeviceInfo.Profile;
+                            //    ota.ImgTypeId = ota.DeviceInfo.ImgTypeId;
+                            //    ota.InClusterList = ota.DeviceInfo.InClusterList;
+                            //    ota.OutClusterList = ota.DeviceInfo.OutClusterList;
+                            //    ota.AttributeStatus = ota.DeviceInfo.AttributeStatus;
+                            //    //ota.Save();
+                            //}
+                            //else
+                            //{
+                            //    infoOta.DeviceName = ota.DeviceInfo.MacName;
+                            //    infoOta.DeviceEpointName = ota.DeviceInfo.DeviceName;
+                            //    infoOta.DeviceEpointName = ota.DeviceInfo.DeviceName;
+                            //    infoOta.ImgVersion = ota.DeviceInfo.ImgVersion;
+                            //    infoOta.HwVersion = ota.DeviceInfo.HwVersion;
+                            //    infoOta.IsOnline = ota.DeviceInfo.IsOnline;
+                            //    infoOta.DriveCode = ota.DeviceInfo.DriveCode;
+                            //    infoOta.IasDeviceType = ota.DeviceInfo.DeviceType;
+                            //    infoOta.Profile = ota.DeviceInfo.Profile;
+                            //    infoOta.ImgTypeId = ota.DeviceInfo.ImgTypeId;
+                            //    infoOta.InClusterList = ota.DeviceInfo.InClusterList;
+                            //    infoOta.OutClusterList = ota.DeviceInfo.OutClusterList;
+                            //    infoOta.AttributeStatus = ota.DeviceInfo.AttributeStatus;
+                            //    infoOta.DeviceInfo = ota.DeviceInfo;
+                            //    //ota.ReSave();
+                            //}
+                            //DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
+                            //break;
+                            //case DeviceType.Thermostat:
+                            //var thermostat = new ThermostatObj() { 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 };
+                            //thermostat.DeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<ThermostatObj.DeviceInfoData>(jobject["Data"].ToString());
+                            //if (thermostat.DeviceInfo == null)
+                            //{
+                            //    return;
+                            //}
+                            //var ther = gateway.DeviceList.Find(obj => obj.DeviceID == thermostat.DeviceID && obj.DeviceAddr == thermostat.DeviceAddr && obj.DeviceEpoint == thermostat.DeviceEpoint);
+                            //if (ther == null)
+                            //{
+                            //    gateway.DeviceList.Add(thermostat);
+                            //    thermostat.DeviceName = thermostat.DeviceInfo.DeviceName;
+                            //    IO.LocalFileUtils.SaveDeviceInfo(thermostat, thermostat.DeviceEpoint.ToString());
+                            //}
+                            //else
+                            //{
+                            //    ther.DeviceName = thermostat.DeviceInfo.DeviceName;
+                            //    ther.DeviceInfo = thermostat.DeviceInfo;
+                            //    ZigBee.IO.LocalFileUtils.SaveDeviceInfo(ther, ther.DeviceEpoint.ToString());
+                            //}
+                            //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.getGatewayBaseInfo.gwID };
+                            //temperatureSensor.DeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<TemperatureSensor.DeviceInfoData>(jobject["Data"].ToString());
+                            //if (temperatureSensor.DeviceInfo == null)
+                            //{
+                            //    return;
+                            //}
+                            //var ts = gateway.DeviceList.Find(obj => obj.DeviceID == temperatureSensor.DeviceID && obj.DeviceAddr == temperatureSensor.DeviceAddr && obj.DeviceEpoint == temperatureSensor.DeviceEpoint);
+                            //if (ts == null)
+                            //{
+                            //    gateway.DeviceList.Add(temperatureSensor);
+                            //    temperatureSensor.DeviceName = temperatureSensor.DeviceInfo.DeviceName;
+                            //    IO.LocalFileUtils.SaveDeviceInfo(temperatureSensor, temperatureSensor.DeviceEpoint.ToString());
+                            //}
+                            //else
+                            //{
+                            //    ts.DeviceName = temperatureSensor.DeviceInfo.DeviceName;
+                            //    ts.DeviceInfo = temperatureSensor.DeviceInfo;
+                            //    IO.LocalFileUtils.SaveDeviceInfo(ts, ts.DeviceEpoint.ToString());
+                            //}
+                            //break;
+
                         }
                     }
                     else if (topic == gatewayID + "/" + "DeviceInfoResponEnd")
@@ -1648,9 +1648,9 @@
         ///<para>Result2锛氭暟鎹В鏋愰敊璇�</para>
         ///<para>Result3锛氬彂閫佹暟鎹ぇ灏忚秴鍑洪檺鍒�</para>
         /// </summary>
-        public async System.Threading.Tasks.Task<Panel.PanelSwitchLevelInfo> ClientDataPassthroughBytesAsync(string deviceAddr, int devicePoint,long dataLength, byte[] passData)
+        public async System.Threading.Tasks.Task<Panel.PanelSwitchLevelInfo> ClientDataPassthroughBytesAsync(string deviceAddr, int devicePoint, long dataLength, byte[] passData)
         {
-           Panel.PanelSwitchLevelInfo result = null;
+            Panel.PanelSwitchLevelInfo result = null;
             if (Gateway == null)
             {
                 result = new Panel.PanelSwitchLevelInfo { errorMessageBase = "褰撳墠娌℃湁缃戝叧" };
@@ -1720,10 +1720,10 @@
                     sendDataBytes[1] = Convert.ToByte(devicePoint);
                     //璁惧mac鍦板潃锛屽皬绔粨鏋�,8涓猙ytes
                     //var addrAllBytes = new byte[8];
-                    int j=0;
+                    int j = 0;
                     for (int i = 14; i >= 0; i = i - 2)
                     {
-                        var curByte= deviceAddr.Substring(i, 2); //00 0d 6f ff fe 04 51 52
+                        var curByte = deviceAddr.Substring(i, 2); //00 0d 6f ff fe 04 51 52
 
                         sendDataBytes[2 + j] = Convert.ToByte(string.Format("0x{0}", curByte), 16);
                         j++;
@@ -2455,7 +2455,7 @@
                         var gateway = new ZbGateway() { DataID = jobject.Value<int>("Data_ID") };
                         var result = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["Result"].ToString());
                         dataRes = new SendFileResponseAllData { Result = result };
-                        if(result ==0)
+                        if (result == 0)
                         {
                             isRespond = true;
                         }
@@ -2476,7 +2476,7 @@
                         {
                             if (WaitReceiveDataTime < (DateTime.Now - dateTime).TotalMilliseconds)
                             {
-                                 return new SendFileResponseAllData { errorMessageBase = "鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; ;
+                                return new SendFileResponseAllData { errorMessageBase = "鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" }; ;
                             }
                             await System.Threading.Tasks.Task.Delay(10);
                         }
@@ -2513,7 +2513,8 @@
                     }
                 }
                 catch { }
-                finally{
+                finally
+                {
                     Actions -= action;
                 }
                 DebugPrintLog("Security/ChangeAdminPassword_Actions 閫�鍑�" + System.DateTime.Now.ToString());
@@ -2723,7 +2724,7 @@
                             if (tempData.Result == 0)
                             {
                                 ZbGateway.byteSource.Clear();
-                             }
+                            }
                             tempDa.Result = tempData.Result;
                             dataRes.setDownloadFileResponseData = tempDa;
                             DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
@@ -3085,11 +3086,11 @@
         /// <summary>
         /// 灞�鍩熺綉鐨凪QTT鏄惁姝e湪杩炴帴
         /// </summary>
-        object mqttIsConnecting=false.ToString();
+        object mqttIsConnecting = false.ToString();
 
         public async System.Threading.Tasks.Task StartLocalMqtt(string brokerName)
         {
-            await System.Threading.Tasks.Task.Factory.StartNew(async() =>
+            await System.Threading.Tasks.Task.Factory.StartNew(async () =>
             {
                 try
                 {
@@ -3121,29 +3122,29 @@
                                 DebugPrintLog($" 鏈湴杩炴帴鏂紑_缃戝叧IP:{brokerName}_缃戝叧鏄惁鍔�:{IsEncry}_{System.DateTime.Now.ToString()}");
 #endif
                             };
-                            mqttClient.Connected += async (sender, e) =>
-                             {
+                            mqttClient.Connected += async (sender, e) =>
+                            {
 #if DEBUG
-                                 DebugPrintLog($" 鏈湴杩炴帴鎴愬姛_缃戝叧IP:{brokerName}_缃戝叧鏄惁鍔�:{IsEncry}_褰撳墠瀵嗙爜:{Password}_{System.DateTime.Now.ToString()}");
+                                DebugPrintLog($" 鏈湴杩炴帴鎴愬姛_缃戝叧IP:{brokerName}_缃戝叧鏄惁鍔�:{IsEncry}_褰撳墠瀵嗙爜:{Password}_{System.DateTime.Now.ToString()}");
 #endif
-
-                                 //if (PubKey != null)
-                                 //{
-                                 //    var rsaString = ZigBee.Common.SecuritySet.RSAEncrypt(PubKey, Password);
-                                 //    var resultVerityfy = await SendAesKeyAsync(rsaString);
-                                 //    if (resultVerityfy == null)
-                                 //    {
-                                 //        resultVerityfy = await SendAesKeyAsync(rsaString);
-                                 //    }
-                                 //    if (resultVerityfy != null && resultVerityfy.Result == 0)
-                                 //    {
-                                 //        IsEncry = true;
-                                 //    }
-                                 //}
-                                 Shared.Common.LocalGateway.Current.CheckGatewayByConnectChanged(Shared.Phone.UserCenter.GatewayConnectMode.WIFI);
-                                 System.Console.WriteLine($"褰撳墠鏄綉鍏砏i-Fi鍦ㄩ�氳_{System.DateTime.Now.ToString()}");
-
-                             };
+
+                                if (PubKey != null)
+                                {
+                                    var rsaString = ZigBee.Common.SecuritySet.RSAEncrypt(PubKey, Password);
+                                    var resultVerityfy = await SendAesKeyAsync(rsaString);
+                                    if (resultVerityfy == null)
+                                    {
+                                        resultVerityfy = await SendAesKeyAsync(rsaString);
+                                    }
+                                    if (resultVerityfy != null && resultVerityfy.Result == 0)
+                                    {
+                                        IsEncry = true;
+                                    }
+                                }
+                                Shared.Phone.UserCenter.HdlGatewayLogic.Current.CheckGatewayByConnectChanged(Shared.Phone.UserCenter.GatewayConnectMode.WIFI);
+                                System.Console.WriteLine($"褰撳墠鏄綉鍏砏i-Fi鍦ㄩ�氳_{System.DateTime.Now.ToString()}");
+
+                            };
                         }
 
                         if (RemoteMqttClient != null && RemoteMqttClient.IsConnected == true)
@@ -3166,8 +3167,8 @@
                         CleanSession = true,// 璁剧疆鏄惁娓呯┖session,杩欓噷濡傛灉璁剧疆涓篺alse琛ㄧず鏈嶅姟鍣ㄤ細淇濈暀瀹㈡埛绔殑杩炴帴璁板綍锛岃繖閲岃缃负true琛ㄧず姣忔杩炴帴鍒版湇鍔″櫒閮戒互鏂扮殑韬唤杩炴帴
                         KeepAlivePeriod = new TimeSpan(0, 5, 0),//璁剧疆蹇冭烦鏃堕棿锛堟渶澶у�硷紝2^16-1 = 65535绉� = 18灏忔椂銆傛渶灏忓�煎彲浠ヤ负0锛岃〃绀哄鎴风涓嶆柇寮�銆備竴鑸涓哄嚑鍒嗛挓锛屾瘮濡傚井淇″績璺冲懆鏈熶负300绉掋�傦級
                         DefaultCommunicationTimeout = new TimeSpan(0, 0, 100),//璁剧疆瓒呮椂鏃堕棿
-                    };
-                   await mqttClient.ConnectAsync(connectCloudMqttClientOptions);
+                    };
+                    await mqttClient.ConnectAsync(connectCloudMqttClientOptions);
                 }
                 catch (Exception ex)
                 {
@@ -3204,7 +3205,7 @@
             {
                 try
                 {
-                    if (remoteMqttIsConnecting)
+                    if (remoteMqttIsConnecting || Shared.Common.Config.Instance.HomeId == "")
                     {
                         return;
                     }
@@ -3213,6 +3214,7 @@
                     var url = Shared.Common.Config.Instance.ZigbeeMqttBrokerLoadSubDomain;//.Replace("6688","6689");
                     if (string.IsNullOrEmpty(url) || !url.StartsWith("tcp://") || url.Split(':').Length != 3)
                     {
+                        remoteMqttIsConnecting = false;
                         return;
                     }
                     if (RemoteMqttClient == null)
@@ -3235,42 +3237,42 @@
 #endif
                         };
                         RemoteMqttClient.Connected += async (sender, e) =>
-                         {
+                        {
 #if DEBUG
-                             DebugPrintLog($"杩滅▼杩炴帴鎴愬姛_{System.DateTime.Now.ToString()}");
+                            DebugPrintLog($"杩滅▼杩炴帴鎴愬姛_{System.DateTime.Now.ToString()}");
 #endif
-                             Shared.Common.LocalGateway.Current.CheckGatewayByConnectChanged(Shared.Phone.UserCenter.GatewayConnectMode.Remote);
-                             //娌℃湁涓荤綉鍏虫椂涓诲姩璇诲彇锛岃幏鍙栦富缃戝叧淇℃伅
-                             var gateWayList = GateWayList.FindAll(obj => obj.getGatewayBaseInfo.HomeId == Shared.Common.Config.Instance.HomeId);
-                             if (gateWayList.Find(obj => obj.getGatewayBaseInfo.IsMainGateWay == true) == null)
-                             {
-                                 if (gateWayList.Count == 1)
-                                 {
-                                     gateWayList[0].getGatewayBaseInfo.IsMainGateWay = true;
-                                 }
-                                 else
-                                 {
-                                     for (int i = 0; i < gateWayList.Count; i++)
-                                     {
-                                         var gateWay = gateWayList[i];
-                                         var info = await gateWay.GetZbGwInfoAsync();
-                                         if (info == null || info.getGwData == null)
-                                         {
-                                             continue;
-                                         }
-                                         if (info.getGwData.IsDominant == 1)
-                                         {
-                                             gateWay.getGatewayBaseInfo.IsMainGateWay = true;
-                                             for (int j = i + 1; j < gateWayList.Count; j++)
-                                             {
-                                                 gateWayList[j].getGatewayBaseInfo.IsMainGateWay = false;
-                                             }
-                                             break;
-                                         }
-                                     }
-                                 }
-                             }
-                         };
+                            Shared.Phone.UserCenter.HdlGatewayLogic.Current.CheckGatewayByConnectChanged(Shared.Phone.UserCenter.GatewayConnectMode.Remote);
+                            //娌℃湁涓荤綉鍏虫椂涓诲姩璇诲彇锛岃幏鍙栦富缃戝叧淇℃伅
+                            var gateWayList = GateWayList.FindAll(obj => obj.getGatewayBaseInfo.HomeId == Shared.Common.Config.Instance.HomeId);
+                            if (gateWayList.Find(obj => obj.getGatewayBaseInfo.IsMainGateWay == true) == null)
+                            {
+                                if (gateWayList.Count == 1)
+                                {
+                                    gateWayList[0].getGatewayBaseInfo.IsMainGateWay = true;
+                                }
+                                else
+                                {
+                                    for (int i = 0; i < gateWayList.Count; i++)
+                                    {
+                                        var gateWay = gateWayList[i];
+                                        var info = await gateWay.GetZbGwInfoAsync();
+                                        if (info == null || info.getGwData == null)
+                                        {
+                                            continue;
+                                        }
+                                        if (info.getGwData.IsDominant == 1)
+                                        {
+                                            gateWay.getGatewayBaseInfo.IsMainGateWay = true;
+                                            for (int j = i + 1; j < gateWayList.Count; j++)
+                                            {
+                                                gateWayList[j].getGatewayBaseInfo.IsMainGateWay = false;
+                                            }
+                                            break;
+                                        }
+                                    }
+                                }
+                            }
+                        };
                     }
 
                     if (RemoteMqttClient.IsConnected)
@@ -3314,7 +3316,9 @@
                         KeepAlivePeriod = new TimeSpan(0, 5, 0),//璁剧疆蹇冭烦鏃堕棿锛堟渶澶у�硷紝2^16-1 = 65535绉� = 18灏忔椂銆傛渶灏忓�煎彲浠ヤ负0锛岃〃绀哄鎴风涓嶆柇寮�銆備竴鑸涓哄嚑鍒嗛挓锛屾瘮濡傚井淇″績璺冲懆鏈熶负300绉掋�傦級
                         DefaultCommunicationTimeout = new TimeSpan(0, 0, 100),//璁剧疆瓒呮椂鏃堕棿
                     };
+                    //杩滅▼閫氳杩炴帴锛岃繛鎺ヤ簯绔湇鍔″櫒 
                     await RemoteMqttClient.ConnectAsync(connectCloudMqttClientOptions);
+
                 }
                 catch (Exception ex)
                 {
@@ -3424,12 +3428,18 @@
         {
             try
             {
+                if (Shared.Common.Config.Instance.HomeId == "")
+                {
+                    return;
+                }
+
                 if (IsRemote)
                 {
-#if DEBUG
-                    DebugPrintLog($"杩滅▼ 鈥斺�斿彂閫佸埌缃戝叧鐨勪富棰�:{topic}_鍙戦�佸埌缃戝叧鐨勬暟鎹�:{System.Text.Encoding.UTF8.GetString(message)}_褰撳墠缃戝叧{CurrentGateWayId}_{System.DateTime.Now.ToString()}");
-#endif
+
                     await SendRemoteMsg(topic, message, qosLevel, retain);
+#if DEBUG
+                    DebugPrintLog($"杩滅▼ 鈥斺�斿彂閫佸埌缃戝叧鐨勪富棰�:{topic}_鍙戦�佸埌缃戝叧鐨勬暟鎹�:{System.Text.Encoding.UTF8.GetString(message)}_褰撳墠缃戝叧{CurrentGateWayId}_{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff")}");//{System.DateTime.Now.ToString()}");// DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff")
+#endif            
                 }
                 else
                 {
@@ -3478,7 +3488,8 @@
         /// <param name="retain"></param>
         public async System.Threading.Tasks.Task Send(string topic, string message, MQTTnet.Core.Protocol.MqttQualityOfServiceLevel qosLevel = MQTTnet.Core.Protocol.MqttQualityOfServiceLevel.ExactlyOnce, bool retain = false)
         {
-            if(string.IsNullOrEmpty(message)){
+            if (string.IsNullOrEmpty(message))
+            {
                 return;
             }
             await Send(topic, System.Text.Encoding.UTF8.GetBytes(message), qosLevel, retain);
@@ -3509,6 +3520,15 @@
                 {
                     message = System.Text.Encoding.UTF8.GetString(e.ApplicationMessage.Payload);
                 }
+                else if (topic == "BeingSqueezedOffline")
+                {
+                    //浜戠涓殑褰撳墠杩炴帴琚尋涓嬬嚎锛岄渶瑕侀�氱煡app
+                    //鍏ㄥ眬鎺ユ敹缃戝叧鎺ㄩ�佺殑鐨勯�昏緫(涓轰簡鎵ц閫熷害,灏藉彲鑳界殑鍒姞鑰楁椂鐨勬搷浣�)
+                    message = "BeingSqueezedOffline";
+                    Shared.Phone.UserCenter.HdlGatewayReceiveLogic.GatewayOverallMsgReceive("", topic, null);
+                    DebugPrintLog($"琚尋涓嬬嚎閫氱煡:{ topic}_杩滅▼杩斿洖鐨勬暟鎹甠{message}_{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff")}");//{System.DateTime.Now.ToString()}");// DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff")
+                    return;
+                }
                 //閲嶆柊鐧诲綍:甯愬彿鎴栬�呭叡浜繛鎺ヤ腑鐨刐瀛愬笎鍙峰垎甯冨紡Id$Share$鍒嗗竷寮忎綇瀹匢d=XXX灏氭湭鐧诲綍,璇烽噸鏂扮櫥褰曞悗鍐嶈繛鎺ュ悗鍐嶈繘琛屽彂甯冩搷浣�,濡傛灉鎮ㄥ綋鍓嶆槸鍒汉鍏变韩缁欎綘鐨勮繛鎺�,鍒欒閲嶆柊璇锋眰鑾峰彇杩炴帴淇℃伅涓�涓�,鍐嶅垵濮嬪寲杩炴帴鍐嶆鍙戝竷杩滅▼鎺у埗鍗冲彲!!
                 else if (topic == "AppNoLogin")
                 {
@@ -3526,7 +3546,7 @@
                     }
                 }
 #if DEBUG
-                DebugPrintLog($"杩滅▼杩斿洖鐨勪富棰�:{ topic}_杩滅▼杩斿洖鐨勬暟鎹甠{message}_{System.DateTime.Now.ToString()}");
+                DebugPrintLog($"杩滅▼杩斿洖鐨勪富棰�:{ topic}_杩滅▼杩斿洖鐨勬暟鎹甠{message}_{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff")}");//{System.DateTime.Now.ToString()}");// DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff")
 #endif
                 var cloudMqttResult = Newtonsoft.Json.JsonConvert.DeserializeObject<ZigBee.Common.CloudMqttResponsePack>(message);
                 if (cloudMqttResult != null)
@@ -3536,7 +3556,7 @@
                         RemoteTimeStamp = ulong.Parse(cloudMqttResult.CloudTimestamp);
                         LoginRemoteDateTime = System.DateTime.Now;
 #if DEBUG
-                        DebugPrintLog($"杩滅▼杩斿洖涓婚:{topic}_褰撳墠鏃堕棿鎴�:_+{CurrentTimeStamp} + _+ {System.DateTime.Now.ToString()}");
+                        DebugPrintLog($"杩滅▼杩斿洖涓婚:{topic}_褰撳墠鏃堕棿鎴�:_+{CurrentTimeStamp} + _+{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff")}");//{System.DateTime.Now.ToString()}");// DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff"   // {System.DateTime.Now.ToString()}");
 #endif
                         return;
                     }
@@ -3598,7 +3618,6 @@
             {
                 var topic = e.ApplicationMessage.Topic;
                 var message = System.Text.Encoding.UTF8.GetString(e.ApplicationMessage.Payload);
-               // DebugPrintLog($"缃戝叧杩斿洖鐨勪富棰橈紙绉樻枃锛�:{topic}_缃戝叧杩斿洖鐨勮礋杞斤紙绉樻枃锛�:{message}_{System.DateTime.Now.ToString()}");
 
                 if (IsEncry)
                 {
@@ -3645,12 +3664,13 @@
         {
             try
             {
-                if(string .IsNullOrEmpty(message))
+                if (string.IsNullOrEmpty(message))
                 {
-                    return;
+                    message = "{}";
                 }
                 var gatewayID = topic.Split('/')[0];//缃戝叧杩斿洖鐨勭綉鍏矷D
-                var reportStatus = topic.Split('/')[1];//涓婚涓鸿澶囦笂鎶ョ殑涓婚
+                var reportStatus = "";
+                reportStatus = topic.Split('/')[1];//涓婚涓鸿澶囦笂鎶ョ殑涓婚
                 string addr = "";//涓婃姤鐨勮澶嘺ddr
                 string epoint = "";//涓婃姤鐨勮澶噀point
                 string cluID = "";//涓婃姤鐨勮澶嘽luID
@@ -3677,6 +3697,14 @@
                 if (gwa.GwResDataAction != null)
                 {
                     gwa.GwResDataAction(topic, message);
+                    if (topic == $"{gatewayID}/DoorLock/DoorLockOperatingEventNotificationCommand")
+                    {
+                        Console.WriteLine($"111_DoorLockOperatingEventNotificationCommand:{message}");
+                    }
+                    if (topic == $"{gatewayID}/DoorLock/DoorLockProgrammingEventNotificationCommand")
+                    {
+                        Console.WriteLine($"111_DoorLockProgrammingEventNotificationCommand:{message}");
+                    }
                 }
                 gwa.CurrentGateWayId = gatewayID;
 
@@ -3700,6 +3728,9 @@
                     jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
                 }
 
+                //鍏ㄥ眬鎺ユ敹缃戝叧鎺ㄩ�佺殑鐨勯�昏緫(涓轰簡鎵ц閫熷害,灏藉彲鑳界殑鍒姞鑰楁椂鐨勬搷浣�)
+                Shared.Phone.UserCenter.HdlGatewayReceiveLogic.GatewayOverallMsgReceive(gatewayID, topic, jobject);
+
                 #region 浜戠閫氱煡
                 var cloudMqttResult = Newtonsoft.Json.JsonConvert.DeserializeObject<ZigBee.Common.CloudMqttResponsePack>(message);
                 if (cloudMqttResult != null)
@@ -3711,7 +3742,9 @@
                             {
                                 DebugPrintLog("AppNoLogin宸茬粡閫氱煡");
                                 gwa.CloudErrorAction("AppNoLogin", "鐧诲綍杩囨湡锛岃閲嶆柊鐧诲綍");
-                            }
+                            }
+                            //鍏ㄥ眬鎺ユ敹缃戝叧鎺ㄩ�佺殑鐨勯�昏緫(涓轰簡鎵ц閫熷害,灏藉彲鑳界殑鍒姞鑰楁椂鐨勬搷浣�)
+                            Shared.Phone.UserCenter.HdlGatewayReceiveLogic.GatewayOverallMsgReceive(gatewayID, "AppNoLogin", jobject);
                             break;
                         case "AppTimeOut":
                             if (gwa.CloudErrorAction != null)
@@ -3731,7 +3764,7 @@
                 }
                 #endregion
                 #region 杩滅▼,涓荤綉鍏充笂鎶ラ�氱煡
-                if(IsRemote)
+                if (IsRemote)
                 {
                     if (topic == gatewayID + "/" + "BeMainGw_Report")
                     {
@@ -3887,7 +3920,7 @@
                             UpdateDeviceInfo(ac, "DeviceInComingRespon");
                             UpdateDeviceStatus(gwa);
                             break;
-                        case DeviceType.Transverter :
+                        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 = gwa.getGatewayBaseInfo.gwID };
                             transverter.getNewDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<Transverter.NewDeviceInfoData>(jobject["Data"].ToString());
                             if (gwa.ReportAction != null)
@@ -3896,6 +3929,17 @@
                                 gwa.ReportAction("DeviceInComingRespon", transverter.getNewDeviceInfo);
                             }
                             UpdateDeviceInfo(transverter, "DeviceInComingRespon");
+                            UpdateDeviceStatus(gwa);
+                            break;
+                        case DeviceType.DoorLock:
+                            var doorLock = new DoorLock() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID };
+                            doorLock.getNewDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<DoorLock.NewDeviceInfoData>(jobject["Data"].ToString());
+                            if (gwa.ReportAction != null)
+                            {
+                                DebugPrintLog("DeviceInComingRespon宸茬粡閫氱煡");
+                                gwa.ReportAction("DeviceInComingRespon", doorLock.getNewDeviceInfo);
+                            }
+                            UpdateDeviceInfo(doorLock, "DeviceInComingRespon");
                             UpdateDeviceStatus(gwa);
                             break;
                     }
@@ -4134,6 +4178,31 @@
                                 UpdateDeviceStatus(transverterInfo);
                             }
                             break;
+                        case DeviceType.DoorLock:
+                            var doorLock = new DoorLock() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID };
+                            doorLock.IsOnline = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["IsOnline"].ToString());
+                            if (gwa.ReportAction != null)
+                            {
+                                DebugPrintLog("OnlineStatusChange宸茬粡閫氱煡");
+                                gwa.ReportAction("OnlineStatusChange", doorLock);
+                            }
+                            var doorLockInfo = gwa.DeviceList.Find(obj => obj.DeviceID == doorLock.DeviceID && obj.DeviceAddr == doorLock.DeviceAddr);
+                            if (doorLockInfo == null)
+                            {
+                                gwa.DeviceList.Add(doorLockInfo);
+                                UpdateDeviceInfo(doorLockInfo, "OnlineStatusChange");
+                                UpdateDeviceStatus(gwa);
+                            }
+                            else
+                            {
+                                if (doorLockInfo.DeviceInfo != null)
+                                {
+                                    doorLockInfo.DeviceInfo.IsOnline = doorLockInfo.IsOnline;
+                                }
+                                UpdateDeviceInfo(doorLockInfo, "OnlineStatusChange");
+                                UpdateDeviceStatus(doorLockInfo);
+                            }
+                            break;
                     }
                 }
                 #endregion
@@ -4343,6 +4412,27 @@
                                                 }
                                             }
                                             break;
+                                        case DeviceType.DoorLock:
+                                            var doorLock = new DoorLock() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID };
+                                            doorLock.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<DoorLock.RemoveDeviceResponseData>(jobject["Data"].ToString());
+                                            if (doorLock.removeDeviceResponseData == null)
+                                            {
+                                                return;
+                                            }
+                                            else
+                                            {
+                                                UpdateDeviceStatus(doorLock);
+                                                UpdateDeviceInfo(doorLock, "RemoveDeviceRespon");
+                                                if (doorLock.removeDeviceResponseData.Result == 0)
+                                                {
+                                                    var info = gwa.DeviceList.Find((CommonDevice obj) => obj.DeviceID == doorLock.DeviceID && obj.DeviceAddr == doorLock.DeviceAddr && obj.DeviceEpoint == doorLock.DeviceEpoint);
+                                                    if (info != null)
+                                                    {
+                                                        gwa.DeviceList.Remove(info);
+                                                    }
+                                                }
+                                            }
+                                            break;
                                     }
                                 }
                             }
@@ -4416,12 +4506,18 @@
                             UpdateDeviceStatus(ac);
                             UpdateDeviceInfo(ac, "DeviceStatusReport");
                             break;
-                        case DeviceType.Transverter :
+                        case DeviceType.Transverter:
                             var transverter = new Transverter { DeviceID = deviceID, DeviceAddr = deviceAddr, DeviceEpoint = tempEpoint, DataID = dataId };
-                            transverter.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<AC.DeviceStatusReportData>(jobject["Data"].ToString());
+                            transverter.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<Transverter.DeviceStatusReportData>(jobject["Data"].ToString());
                             UpdateDeviceStatus(transverter);
                             UpdateDeviceInfo(transverter, "DeviceStatusReport");
                             break;
+                        case DeviceType.DoorLock:
+                            var doorLock = new DoorLock { DeviceID = deviceID, DeviceAddr = deviceAddr, DeviceEpoint = tempEpoint, DataID = dataId };
+                            doorLock.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<DoorLock.DeviceStatusReportData>(jobject["Data"].ToString());
+                            UpdateDeviceStatus(doorLock);
+                            UpdateDeviceInfo(doorLock, "DeviceStatusReport");
+                            break;
                     }
                 }
                 #endregion

--
Gitblit v1.8.0