WJC
2019-10-31 d7ad5a3953a8cd001659092ebde204b881f94b9d
ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs
@@ -9,7 +9,7 @@
using System.Net;
using Newtonsoft.Json.Linq;
using MQTTnet.Core.Client;
//using MQTTnet;
using MQTTnet;
using Shared.Common;
using Shared.Phone.UserView;
@@ -98,12 +98,7 @@
            }
        }
        #region variable
        /// <summary>
        ///  远程是否被挤下线。默认远程没有被挤下线的
        /// </summary>
        public static bool IsRemoteBeingSqueezedOffline = false;
        #region variable
        /// <summary>
        /// 远程连接成功时的时间
        /// </summary>
@@ -226,7 +221,6 @@
        /// <para>第一个参数:如果为 DDevice/IsGetEpointInfo:有新设备加入zigbee网络反馈</para>设备请求APP获取升级数据
        /// <para>第一个参数:如果为 Device/DeviceJoinZbNet:获取新设备所有端点信息是否成功反馈</para>
        /// <para>第一个参数:如果为 DeviceRequestAcUpdateData: 设备请求空调发升级数据</para>
        /// "已经通知");//已经通知");
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public Action<string, object> ReportAction;
@@ -3110,7 +3104,7 @@
                        if (mqttClient == null)
                        {
                            //(2)创建Mqtt客户端
                            mqttClient = new MQTTnet.MqttClientFactory().CreateMqttClient();
                            mqttClient = new MqttClientFactory().CreateMqttClient();
                            //(3)当[连接Mqtt成功后]或者[Mqtt转发数据给网关成功后],处理接收到数据包响应时在mqttClient_ApplicationMessageReceived这个方法处理
                            mqttClient.ApplicationMessageReceived += (sender, e) =>
                            {
@@ -3210,7 +3204,7 @@
            {
                try
                {
                    if (remoteMqttIsConnecting)
                    if (remoteMqttIsConnecting || Shared.Common.Config.Instance.HomeId == "")
                    {
                        return;
                    }
@@ -3219,12 +3213,13 @@
                    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)
                    {
                        //(2)创建Mqtt客户端
                        RemoteMqttClient = new MQTTnet.MqttClientFactory().CreateMqttClient();
                        RemoteMqttClient = new MqttClientFactory().CreateMqttClient();
                        //(3)当[连接云端的Mqtt成功后]或者[以及后面App通过云端Mqtt转发数据给网关成功后],处理接收到云端数据包响应时在mqttServerClient_ApplicationMessageReceived这个方法处理
                        RemoteMqttClient.ApplicationMessageReceived += (sender, e) =>
                        {
@@ -3306,7 +3301,7 @@
                    //还有种情况是同一个ID 有多个设备用这个id连接(会导致中断)
                    string clientId = Shared.Common.Config.Instance.ConnectZigbeeMqttClientId;
                    string username = Shared.Common.Config.Instance.ConnectZigbeeMqttBrokerName;
                    string username = Shared.Common.Config.Instance.ConnectGuid;
                    string passwordRemote = Shared.Common.Config.Instance.ConnectZigbeeMqttBrokerPwd;
                    //(1)连接到云端的Mqtt客户端连接参数
                    var connectCloudMqttClientOptions = new MqttClientTcpOptions
@@ -3320,11 +3315,12 @@
                        KeepAlivePeriod = new TimeSpan(0, 5, 0),//设置心跳时间(最大值,2^16-1 = 65535秒 = 18小时。最小值可以为0,表示客户端不断开。一般设为几分钟,比如微信心跳周期为300秒。)
                        DefaultCommunicationTimeout = new TimeSpan(0, 0, 100),//设置超时时间
                    };
                    //远程通讯连接,连接云端服务器
                    if (ZigBee.Device.ZbGateway.IsRemoteBeingSqueezedOffline == false)
                    {
                        await RemoteMqttClient.ConnectAsync(connectCloudMqttClientOptions);
                    //远程通讯连接,连接云端服务器
                    if (RemoteMqttClient != null)
                    {
                        await RemoteMqttClient.ConnectAsync(connectCloudMqttClientOptions);
                    }
                }
                catch (Exception ex)
                {
@@ -3391,15 +3387,9 @@
        /// </summary>
        async System.Threading.Tasks.Task SendRemoteMsg(string topicName, byte[] message, MQTTnet.Core.Protocol.MqttQualityOfServiceLevel qosLevel = MQTTnet.Core.Protocol.MqttQualityOfServiceLevel.ExactlyOnce, bool retain = false)
        {
            #region MD5加密 token
            var result = System.Text.Encoding.UTF8.GetBytes(Shared.Common.Config.Instance.Password);
            var md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
            var output = md5.ComputeHash(result);
            var md5Password = BitConverter.ToString(output).Replace("-", "").ToUpper();
            #endregion
            //(1)生成[用户名:密码]
            var userNameAndPwdStr = string.Concat(Shared.Common.Config.Instance.Account, RemoteOperatorConsts.CAP_NUMBER, md5Password);
            var userNameAndPwdStr = string.Concat(Shared.Common.Config.Instance.Guid, RemoteOperatorConsts.CAP_NUMBER, Shared.Common.Config.Instance.MD5PWD);
            DebugPrintLog($"userNameAndPwdStr:{userNameAndPwdStr} ");
            //(2)将(1)转成Base64字符串,生成格式[Base64(用户名:密码)]
            var userNameAndPwdStrBaseSexFour = Convert.ToBase64String(ZigBee.Common.CommonInfo.EncodingUTF8.GetBytes(userNameAndPwdStr));
@@ -3407,16 +3397,17 @@
            //(3)将(2)继续生成格式[Base64(用户名:密码):Timestamp]
            var userNameAndPwdStrBaseSexFourAndTimestamp = string.Concat(userNameAndPwdStrBaseSexFour, RemoteOperatorConsts.CAP_NUMBER, CurrentTimeStamp.ToString());
            ///[Zigbee.Buspro]App/id(帐号Id)/Base64(DES[Base64(用户名:密码):Timestamp ]/网关唯一Id/转发给网关的主题/XX/XX
            //[Zigbee.Buspro]App/id(帐号Id)/Base64(DES[Base64(用户名:密码):Timestamp ]/网关唯一Id/转发给网关的主题/XX/XX
            //(4)生成上报主题,主题模式需要为  /ZigbeeApp/id(主子调试帐号Id)/Base64(DES[Base64(用户名:密码):Timestamp ]/网关唯一Id/topicName "000204022022"   GateWayId  000204022022
            var reportTopic = string.Format("/{0}/{1}/{2}/{3}/{4}", RemoteOperatorConsts.ZIGBEE_APP_STARTS_WITH, Shared.Common.Config.Instance.Account, userNameAndPwdStrBaseSexFourAndTimestamp, this.getGatewayBaseInfo?.gwID, topicName);
            var reportTopic = string.Format("/{0}/{1}/{2}/{3}/{4}", RemoteOperatorConsts.ZIGBEE_APP_STARTS_WITH, Shared.Common.Config.Instance.Guid, userNameAndPwdStrBaseSexFourAndTimestamp, this.getGatewayBaseInfo?.gwID, topicName);
            var aa = System.Text.Encoding.UTF8.GetString(message);
            //(5)使用你登录成功时8位key,进行DES加密你需要上报的数据
            string topicEncStr = reportTopic;
            //文件流不用加密
            topicEncStr = ZigBee.Common.SecuritySet.AesEncrypt(System.Text.Encoding.UTF8.GetBytes(topicEncStr), Shared.Common.Config.Instance.MqttKey);
            topicEncStr = topicEncStr.Replace("/", "[[$-MQTT_TILT_SYMBOL_REPLACE-$]]").Replace("+", "[[$-MQTT_PLUS_SYMBOL_REPLACE-$]]");
            message = System.Text.Encoding.UTF8.GetBytes(SecuritySet.AesEncrypt(message, Shared.Common.Config.Instance.MqttKey));
            var bb = System.Text.Encoding.UTF8.GetString(message);
            //(6)构建Mqtt需要发布的数据包,发布给云端的MqttBroker
            await RemoteMqttClient.PublishAsync(new MQTTnet.Core.MqttApplicationMessage(topicEncStr, message, qosLevel, retain));
@@ -3434,12 +3425,18 @@
        {
            try
            {
                if (Shared.Common.Config.Instance.HomeId == "")
                {
                    return;
                }
                if (IsRemote)
                {
                    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
                    await SendRemoteMsg(topic, message, qosLevel, retain);
#endif
                }
                else
                {
@@ -3525,7 +3522,6 @@
                    //云端中的当前连接被挤下线,需要通知app
                    //全局接收网关推送的的逻辑(为了执行速度,尽可能的别加耗时的操作)
                    message = "BeingSqueezedOffline";
                    ZigBee.Device.ZbGateway.IsRemoteBeingSqueezedOffline = true;
                    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;
@@ -3822,344 +3818,43 @@
                if (topic == gatewayID + "/" + "DeviceInComingRespon")
                {
                    //新设备上报,重新发获取所有的设备
                    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 = gwa.getGatewayBaseInfo.gwID };
                            dimmableLight.getNewDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<DimmableLight.NewDeviceInfoData>(jobject["Data"].ToString());
                            if (gwa.ReportAction != null)
                            {
                                DebugPrintLog("DeviceInComingRespon已经通知");
                                gwa.ReportAction("DeviceInComingRespon", dimmableLight.getNewDeviceInfo);
                            }
                            UpdateDeviceInfo(dimmableLight, "DeviceInComingRespon");
                            UpdateDeviceStatus(gwa);
                            break;
                        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 = gwa.getGatewayBaseInfo.gwID };
                            toggleLight.getNewDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<ToggleLight.NewDeviceInfoData>(jobject["Data"].ToString());
                            if (gwa.ReportAction != null)
                            {
                                DebugPrintLog("DeviceInComingRespon已经通知");
                                gwa.ReportAction("DeviceInComingRespon", toggleLight.getNewDeviceInfo);
                            }
                            UpdateDeviceInfo(toggleLight, "DeviceInComingRespon");
                            UpdateDeviceStatus(gwa);
                            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 = gwa.getGatewayBaseInfo.gwID };
                            airSwitch.getNewDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<AirSwitch.NewDeviceInfoData>(jobject["Data"].ToString());
                            if (gwa.ReportAction != null)
                            {
                                DebugPrintLog("DeviceInComingRespon已经通知");
                                gwa.ReportAction("DeviceInComingRespon", airSwitch.getNewDeviceInfo);
                            }
                            UpdateDeviceInfo(airSwitch, "DeviceInComingRespon");
                            UpdateDeviceStatus(gwa);
                            break;
                        case DeviceType.OnOffSwitch:
                            var panel = 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 = gwa.getGatewayBaseInfo.gwID };
                            panel.getNewDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.NewDeviceInfoData>(jobject["Data"].ToString());
                            if (gwa.ReportAction != null)
                            {
                                DebugPrintLog("DeviceInComingRespon已经通知");
                                gwa.ReportAction("DeviceInComingRespon", panel.getNewDeviceInfo);
                            }
                            UpdateDeviceInfo(panel, "DeviceInComingRespon");
                            UpdateDeviceStatus(gwa);
                            break;
                        case DeviceType.WindowCoveringDevice:
                            var curtain = 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 = gwa.getGatewayBaseInfo.gwID };
                            curtain.getNewDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<Rollershade.NewDeviceInfoData>(jobject["Data"].ToString());
                            if (gwa.ReportAction != null)
                            {
                                DebugPrintLog("DeviceInComingRespon已经通知");
                                gwa.ReportAction("DeviceInComingRespon", curtain.getNewDeviceInfo);
                            }
                            UpdateDeviceInfo(curtain, "DeviceInComingRespon");
                            UpdateDeviceStatus(gwa);
                            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 = gwa.getGatewayBaseInfo.gwID };
                            ias.getNewDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<IASZone.NewDeviceInfoData>(jobject["Data"].ToString());
                            if (gwa.ReportAction != null)
                            {
                                DebugPrintLog("DeviceInComingRespon已经通知");
                                gwa.ReportAction("DeviceInComingRespon", ias.getNewDeviceInfo);
                            }
                            UpdateDeviceInfo(ias, "DeviceInComingRespon");
                            UpdateDeviceStatus(gwa);
                            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 = gwa.getGatewayBaseInfo.gwID };
                            repeater.getNewDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<Repeater.NewDeviceInfoData>(jobject["Data"].ToString());
                            if (gwa.ReportAction != null)
                            {
                                DebugPrintLog("DeviceInComingRespon已经通知");
                                gwa.ReportAction("DeviceInComingRespon", repeater.getNewDeviceInfo);
                            }
                            UpdateDeviceInfo(repeater, "DeviceInComingRespon");
                            UpdateDeviceStatus(gwa);
                            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 = gwa.getGatewayBaseInfo.gwID };
                            ac.getNewDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<AC.NewDeviceInfoData>(jobject["Data"].ToString());
                            if (gwa.ReportAction != null)
                            {
                                DebugPrintLog("DeviceInComingRespon已经通知");
                                gwa.ReportAction("DeviceInComingRespon", ac.getNewDeviceInfo);
                            }
                            UpdateDeviceInfo(ac, "DeviceInComingRespon");
                            UpdateDeviceStatus(gwa);
                            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 = gwa.getGatewayBaseInfo.gwID };
                            transverter.getNewDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<Transverter.NewDeviceInfoData>(jobject["Data"].ToString());
                            if (gwa.ReportAction != null)
                            {
                                DebugPrintLog("DeviceInComingRespon已经通知");
                                gwa.ReportAction("DeviceInComingRespon", transverter.getNewDeviceInfo);
                            }
                            UpdateDeviceInfo(transverter, "DeviceInComingRespon");
                            UpdateDeviceStatus(gwa);
                            break;
                    }
                    var tempDevice = new CommonDevice() { 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 };
                    tempDevice.getNewDeviceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.NewDeviceInfoData>(jobject["Data"].ToString());
                    if (gwa.ReportAction != null)
                    {
                        DebugPrintLog("DeviceInComingRespon已经通知");
                        gwa.ReportAction("DeviceInComingRespon", tempDevice.getNewDeviceInfo);
                    }
                    UpdateDeviceInfo(tempDevice, "DeviceInComingRespon");
                    UpdateDeviceStatus(gwa);
                }
                #endregion
                #region 设备在线状态更新反馈
                else if (topic == gatewayID + "/" + "OnlineStatusChange_Respon")
                {
                    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 = gwa.getGatewayBaseInfo.gwID };
                            dimmableLight.IsOnline = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["IsOnline"].ToString());
                            if (gwa.ReportAction != null)
                            {
                                DebugPrintLog("OnlineStatusChange已经通知");
                                gwa.ReportAction("OnlineStatusChange", dimmableLight);
                            }
                            var lightDimmer = gwa.DeviceList.Find(obj => obj.DeviceID == dimmableLight.DeviceID && obj.DeviceAddr == dimmableLight.DeviceAddr);
                            if (lightDimmer == null)
                            {
                                gwa.DeviceList.Add(dimmableLight);
                                UpdateDeviceStatus(dimmableLight);
                                UpdateDeviceInfo(dimmableLight, "OnlineStatusChange");
                            }
                            else
                            {
                                if (dimmableLight.DeviceInfo != null)
                                {
                                    dimmableLight.DeviceInfo.IsOnline = dimmableLight.IsOnline;
                                }
                                UpdateDeviceInfo(dimmableLight, "OnlineStatusChange");
                                UpdateDeviceStatus(dimmableLight);
                            }
                            break;
                        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 = gwa.getGatewayBaseInfo.gwID };
                            toggleLight.IsOnline = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["IsOnline"].ToString());
                            if (gwa.ReportAction != null)
                            {
                                DebugPrintLog("OnlineStatusChange已经通知");
                                gwa.ReportAction("OnlineStatusChange", toggleLight);
                            }
                            var toggleInfo = gwa.DeviceList.Find(obj => obj.DeviceID == toggleLight.DeviceID && obj.DeviceAddr == toggleLight.DeviceAddr);
                            if (toggleInfo == null)
                            {
                                gwa.DeviceList.Add(toggleLight);
                                UpdateDeviceInfo(toggleLight, "OnlineStatusChange");
                                UpdateDeviceStatus(toggleLight);
                            }
                            else
                            {
                                if (toggleLight.DeviceInfo != null)
                                {
                                    toggleLight.DeviceInfo.IsOnline = toggleLight.IsOnline;
                                }
                                UpdateDeviceInfo(toggleLight, "OnlineStatusChange");
                                UpdateDeviceStatus(toggleLight);
                            }
                            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 = gwa.getGatewayBaseInfo.gwID };
                            airSwitch.IsOnline = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["IsOnline"].ToString());
                            if (gwa.ReportAction != null)
                            {
                                DebugPrintLog("OnlineStatusChange已经通知");
                                gwa.ReportAction("OnlineStatusChange", airSwitch);
                            }
                            var airSwitchInfo = gwa.DeviceList.Find(obj => obj.DeviceID == airSwitch.DeviceID && obj.DeviceAddr == airSwitch.DeviceAddr);
                            if (airSwitchInfo == null)
                            {
                                gwa.DeviceList.Add(airSwitch);
                                UpdateDeviceInfo(airSwitch, "OnlineStatusChange");
                                UpdateDeviceStatus(gwa);
                            }
                            else
                            {
                                if (airSwitchInfo.DeviceInfo != null)
                                {
                                    airSwitchInfo.DeviceInfo.IsOnline = airSwitchInfo.IsOnline;
                                }
                                UpdateDeviceInfo(airSwitchInfo, "OnlineStatusChange");
                                UpdateDeviceStatus(airSwitchInfo);
                            }
                            break;
                        case DeviceType.OnOffSwitch:
                            var panel = 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 = gwa.getGatewayBaseInfo.gwID };
                            panel.IsOnline = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["IsOnline"].ToString());
                            if (gwa.ReportAction != null)
                            {
                                DebugPrintLog("OnlineStatusChange已经通知");
                                gwa.ReportAction("OnlineStatusChange", panel);
                            }
                            var panelInfo = gwa.DeviceList.Find(obj => obj.DeviceID == panel.DeviceID && obj.DeviceAddr == panel.DeviceAddr);
                            if (panelInfo == null)
                            {
                                gwa.DeviceList.Add(panel);
                                UpdateDeviceInfo(panel, "OnlineStatusChange");
                                UpdateDeviceStatus(panel);
                            }
                            else
                            {
                                if (panelInfo.DeviceInfo != null)
                                {
                                    panelInfo.DeviceInfo.IsOnline = panelInfo.IsOnline;
                                }
                                UpdateDeviceInfo(panelInfo, "OnlineStatusChange");
                                UpdateDeviceStatus(panelInfo);
                            }
                            break;
                        case DeviceType.WindowCoveringDevice:
                            var curtain = 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 = gwa.getGatewayBaseInfo.gwID };
                            curtain.IsOnline = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["IsOnline"].ToString());
                            if (gwa.ReportAction != null)
                            {
                                DebugPrintLog("OnlineStatusChange已经通知");
                                gwa.ReportAction("OnlineStatusChange", curtain);
                            }
                            var curtainInfo = gwa.DeviceList.Find(obj => obj.DeviceID == curtain.DeviceID && obj.DeviceAddr == curtain.DeviceAddr);
                            if (curtainInfo == null)
                            {
                                gwa.DeviceList.Add(curtain);
                                UpdateDeviceInfo(curtain, "OnlineStatusChange");
                                UpdateDeviceStatus(gwa);
                            }
                            else
                            {
                                if (curtain.DeviceInfo != null)
                                {
                                    curtain.DeviceInfo.IsOnline = curtain.IsOnline;
                                }
                                UpdateDeviceStatus(curtain);
                                UpdateDeviceInfo(curtain, "OnlineStatusChange");
                            }
                            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 = gwa.getGatewayBaseInfo.gwID };
                            ias.IsOnline = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["IsOnline"].ToString());
                            if (gwa.ReportAction != null)
                            {
                                DebugPrintLog("OnlineStatusChange已经通知");
                                gwa.ReportAction("OnlineStatusChange", ias);
                            }
                            var iasInfo = gwa.DeviceList.Find(obj => obj.DeviceID == ias.DeviceID && obj.DeviceAddr == ias.DeviceAddr);
                            if (iasInfo == null)
                            {
                                gwa.DeviceList.Add(iasInfo);
                                UpdateDeviceInfo(iasInfo, "OnlineStatusChange");
                                UpdateDeviceStatus(gwa);
                            }
                            else
                            {
                                if (iasInfo.DeviceInfo != null)
                                {
                                    iasInfo.DeviceInfo.IsOnline = iasInfo.IsOnline;
                                }
                                UpdateDeviceInfo(iasInfo, "OnlineStatusChange");
                                UpdateDeviceStatus(iasInfo);
                            }
                            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 = gwa.getGatewayBaseInfo.gwID };
                            repeater.IsOnline = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["IsOnline"].ToString());
                            if (gwa.ReportAction != null)
                            {
                                DebugPrintLog("OnlineStatusChange已经通知");
                                gwa.ReportAction("OnlineStatusChange", repeater);
                            }
                            var repeaterInfo = gwa.DeviceList.Find(obj => obj.DeviceID == repeater.DeviceID && obj.DeviceAddr == repeater.DeviceAddr);
                            if (repeaterInfo == null)
                            {
                                gwa.DeviceList.Add(repeaterInfo);
                                UpdateDeviceInfo(repeaterInfo, "OnlineStatusChange");
                                UpdateDeviceStatus(gwa);
                            }
                            else
                            {
                                if (repeaterInfo.DeviceInfo != null)
                                {
                                    repeaterInfo.DeviceInfo.IsOnline = repeaterInfo.IsOnline;
                                }
                                UpdateDeviceInfo(repeaterInfo, "OnlineStatusChange");
                                UpdateDeviceStatus(repeaterInfo);
                            }
                            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 = gwa.getGatewayBaseInfo.gwID };
                            ac.IsOnline = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["IsOnline"].ToString());
                            if (gwa.ReportAction != null)
                            {
                                DebugPrintLog("OnlineStatusChange已经通知");
                                gwa.ReportAction("OnlineStatusChange", ac);
                            }
                            var acInfo = gwa.DeviceList.Find(obj => obj.DeviceID == ac.DeviceID && obj.DeviceAddr == ac.DeviceAddr);
                            if (acInfo == null)
                            {
                                gwa.DeviceList.Add(acInfo);
                                UpdateDeviceInfo(acInfo, "OnlineStatusChange");
                                UpdateDeviceStatus(gwa);
                            }
                            else
                            {
                                if (acInfo.DeviceInfo != null)
                                {
                                    acInfo.DeviceInfo.IsOnline = acInfo.IsOnline;
                                }
                                UpdateDeviceInfo(acInfo, "OnlineStatusChange");
                                UpdateDeviceStatus(acInfo);
                            }
                            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 = gwa.getGatewayBaseInfo.gwID };
                            transverter.IsOnline = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["IsOnline"].ToString());
                            if (gwa.ReportAction != null)
                            {
                                DebugPrintLog("OnlineStatusChange已经通知");
                                gwa.ReportAction("OnlineStatusChange", transverter);
                            }
                            var transverterInfo = gwa.DeviceList.Find(obj => obj.DeviceID == transverter.DeviceID && obj.DeviceAddr == transverter.DeviceAddr);
                            if (transverterInfo == null)
                            {
                                gwa.DeviceList.Add(transverterInfo);
                                UpdateDeviceInfo(transverterInfo, "OnlineStatusChange");
                                UpdateDeviceStatus(gwa);
                            }
                            else
                            {
                                if (transverterInfo.DeviceInfo != null)
                                {
                                    transverterInfo.DeviceInfo.IsOnline = transverterInfo.IsOnline;
                                }
                                UpdateDeviceInfo(transverterInfo, "OnlineStatusChange");
                                UpdateDeviceStatus(transverterInfo);
                            }
                            break;
                    var tempDevice = new CommonDevice() { 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 };
                    tempDevice.IsOnline = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["IsOnline"].ToString());
                    if (gwa.ReportAction != null)
                    {
                        DebugPrintLog("OnlineStatusChange已经通知");
                        gwa.ReportAction("OnlineStatusChange", tempDevice);
                    }
                    var infoTempDevice = gwa.DeviceList.Find(obj => obj.DeviceID == tempDevice.DeviceID && obj.DeviceAddr == tempDevice.DeviceAddr);
                    if (infoTempDevice == null)
                    {
                        gwa.DeviceList.Add(tempDevice);
                        UpdateDeviceStatus(tempDevice);
                        UpdateDeviceInfo(tempDevice, "OnlineStatusChange");
                    }
                    else
                    {
                        if (infoTempDevice.DeviceInfo != null)
                        {
                            infoTempDevice.DeviceInfo.IsOnline = infoTempDevice.IsOnline;
                        }
                        UpdateDeviceInfo(infoTempDevice, "OnlineStatusChange");
                        UpdateDeviceStatus(infoTempDevice);
                    }
                }
                #endregion
@@ -4177,198 +3872,24 @@
                            {
                                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 = gwa.getGatewayBaseInfo.gwID };
                                            toggleLight.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ToggleLight.RemoveDeviceResponseData>(jobject["Data"].ToString());
                                            if (toggleLight.removeDeviceResponseData == null)
                                            {
                                                return;
                                            }
                                            else
                                            {
                                                UpdateDeviceStatus(toggleLight);
                                                UpdateDeviceInfo(toggleLight, "RemoveDeviceRespon");
                                                if (toggleLight.removeDeviceResponseData.Result == 0)
                                                {
                                                    var infoToggleLight = gwa.DeviceList.Find((CommonDevice obj) => obj.DeviceID == toggleLight.DeviceID && obj.DeviceAddr == toggleLight.DeviceAddr && obj.DeviceEpoint == toggleLight.DeviceEpoint);
                                                    if (infoToggleLight != null)
                                                    {
                                                        gwa.DeviceList.Remove(infoToggleLight);
                                                    }
                                                }
                                            }
                                            break;
                                        case DeviceType.AirSwitch:
                                            var airSwitch = new AirSwitch() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID };
                                            airSwitch.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<AirSwitch.RemoveDeviceResponseData>(jobject["Data"].ToString());
                                            if (airSwitch.removeDeviceResponseData == null)
                                            {
                                                return;
                                            }
                                            else
                                            {
                                                UpdateDeviceStatus(airSwitch);
                                                UpdateDeviceInfo(airSwitch, "RemoveDeviceRespon");
                                                if (airSwitch.removeDeviceResponseData.Result == 0)
                                                {
                                                    var infoAirSwitch = gwa.DeviceList.Find((CommonDevice obj) => obj.DeviceID == airSwitch.DeviceID && obj.DeviceAddr == airSwitch.DeviceAddr && obj.DeviceEpoint == airSwitch.DeviceEpoint);
                                                    if (infoAirSwitch != null)
                                                    {
                                                        gwa.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 = gwa.getGatewayBaseInfo.gwID };
                                            panelObj.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.RemoveDeviceResponseData>(jobject["Data"].ToString());
                                            if (panelObj.removeDeviceResponseData == null)
                                            {
                                                return;
                                            }
                                            else
                                            {
                                                UpdateDeviceStatus(panelObj);
                                                UpdateDeviceInfo(panelObj, "RemoveDeviceRespon");
                                                if (panelObj.removeDeviceResponseData.Result == 0)
                                                {
                                                    var infoPanel = gwa.DeviceList.Find((CommonDevice obj) => obj.DeviceID == panelObj.DeviceID && obj.DeviceAddr == panelObj.DeviceAddr && obj.DeviceEpoint == panelObj.DeviceEpoint);
                                                    if (infoPanel != null)
                                                    {
                                                        gwa.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 = gwa.getGatewayBaseInfo.gwID };
                                            rollershade.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.RemoveDeviceResponseData>(jobject["Data"].ToString());
                                            if (rollershade.removeDeviceResponseData == null)
                                            {
                                                return;
                                            }
                                            else
                                            {
                                                UpdateDeviceStatus(rollershade);
                                                UpdateDeviceInfo(rollershade, "RemoveDeviceRespon");
                                                if (rollershade.removeDeviceResponseData.Result == 0)
                                                {
                                                    var infoRoller = gwa.DeviceList.Find((CommonDevice obj) => obj.DeviceID == rollershade.DeviceID && obj.DeviceAddr == rollershade.DeviceAddr && obj.DeviceEpoint == rollershade.DeviceEpoint);
                                                    if (infoRoller != null)
                                                    {
                                                        gwa.DeviceList.Remove(infoRoller);
                                                    }
                                                }
                                            }
                                            break;
                                        case DeviceType.IASZone:
                                            var ias = new IASZone() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID };
                                            ias.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<IASZone.RemoveDeviceResponseData>(jobject["Data"].ToString());
                                            if (ias.removeDeviceResponseData == null)
                                            {
                                                return;
                                            }
                                            else
                                            {
                                                UpdateDeviceStatus(ias);
                                                UpdateDeviceInfo(ias, "RemoveDeviceRespon");
                                                if (ias.removeDeviceResponseData.Result == 0)
                                                {
                                                    var info = gwa.DeviceList.Find((CommonDevice obj) => obj.DeviceID == ias.DeviceID && obj.DeviceAddr == ias.DeviceAddr && obj.DeviceEpoint == ias.DeviceEpoint);
                                                    if (info != null)
                                                    {
                                                        gwa.DeviceList.Remove(info);
                                                    }
                                                }
                                            }
                                            break;
                                        case DeviceType.DimmableLight:
                                            var dimmableLight = new DimmableLight() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID };
                                            dimmableLight.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<DimmableLight.RemoveDeviceResponseData>(jobject["Data"].ToString());
                                            if (dimmableLight.removeDeviceResponseData == null)
                                            {
                                                return;
                                            }
                                            else
                                            {
                                                UpdateDeviceStatus(dimmableLight);
                                                UpdateDeviceInfo(dimmableLight, "RemoveDeviceRespon");
                                                if (dimmableLight.removeDeviceResponseData.Result == 0)
                                                {
                                                    var info = gwa.DeviceList.Find((CommonDevice obj) => obj.DeviceID == dimmableLight.DeviceID && obj.DeviceAddr == dimmableLight.DeviceAddr && obj.DeviceEpoint == dimmableLight.DeviceEpoint);
                                                    if (info != null)
                                                    {
                                                        gwa.DeviceList.Remove(info);
                                                    }
                                                }
                                            }
                                            break;
                                        case DeviceType.Repeater:
                                            var repeater = new Repeater() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID };
                                            repeater.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<DimmableLight.RemoveDeviceResponseData>(jobject["Data"].ToString());
                                            if (repeater.removeDeviceResponseData == null)
                                            {
                                                return;
                                            }
                                            else
                                            {
                                                UpdateDeviceStatus(repeater);
                                                UpdateDeviceInfo(repeater, "RemoveDeviceRespon");
                                                if (repeater.removeDeviceResponseData.Result == 0)
                                                {
                                                    var info = gwa.DeviceList.Find((CommonDevice obj) => obj.DeviceID == repeater.DeviceID && obj.DeviceAddr == repeater.DeviceAddr && obj.DeviceEpoint == repeater.DeviceEpoint);
                                                    if (info != null)
                                                    {
                                                        gwa.DeviceList.Remove(info);
                                                    }
                                                }
                                            }
                                            break;
                                        case DeviceType.Thermostat:
                                            var ac = new AC() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID };
                                            ac.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<AC.RemoveDeviceResponseData>(jobject["Data"].ToString());
                                            if (ac.removeDeviceResponseData == null)
                                            {
                                                return;
                                            }
                                            else
                                            {
                                                UpdateDeviceStatus(ac);
                                                UpdateDeviceInfo(ac, "RemoveDeviceRespon");
                                                if (ac.removeDeviceResponseData.Result == 0)
                                                {
                                                    var info = gwa.DeviceList.Find((CommonDevice obj) => obj.DeviceID == ac.DeviceID && obj.DeviceAddr == ac.DeviceAddr && obj.DeviceEpoint == ac.DeviceEpoint);
                                                    if (info != null)
                                                    {
                                                        gwa.DeviceList.Remove(info);
                                                    }
                                                }
                                            }
                                            break;
                                        case DeviceType.Transverter:
                                            var transverter = new Transverter() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID };
                                            transverter.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<Transverter.RemoveDeviceResponseData>(jobject["Data"].ToString());
                                            if (transverter.removeDeviceResponseData == null)
                                            {
                                                return;
                                            }
                                            else
                                            {
                                                UpdateDeviceStatus(transverter);
                                                UpdateDeviceInfo(transverter, "RemoveDeviceRespon");
                                                if (transverter.removeDeviceResponseData.Result == 0)
                                                {
                                                    var info = gwa.DeviceList.Find((CommonDevice obj) => obj.DeviceID == transverter.DeviceID && obj.DeviceAddr == transverter.DeviceAddr && obj.DeviceEpoint == transverter.DeviceEpoint);
                                                    if (info != null)
                                                    {
                                                        gwa.DeviceList.Remove(info);
                                                    }
                                                }
                                            }
                                            break;
                                    var tempDevice = new CommonDevice() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gwa.getGatewayBaseInfo.gwID };
                                    tempDevice.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.RemoveDeviceResponseData>(jobject["Data"].ToString());
                                    if (tempDevice.removeDeviceResponseData == null)
                                    {
                                        return;
                                    }
                                    else
                                    {
                                        UpdateDeviceStatus(tempDevice);
                                        UpdateDeviceInfo(tempDevice, "RemoveDeviceRespon");
                                        if (tempDevice.removeDeviceResponseData.Result == 0)
                                        {
                                            var infoTempDevice = gwa.DeviceList.Find((CommonDevice obj) => obj.DeviceID == tempDevice.DeviceID && obj.DeviceAddr == tempDevice.DeviceAddr && obj.DeviceEpoint == tempDevice.DeviceEpoint);
                                            if (infoTempDevice != null)
                                            {
                                                gwa.DeviceList.Remove(infoTempDevice);
                                            }
                                        }
                                    }
                                }
                            }
@@ -4385,70 +3906,10 @@
                    var tempEpoint = jobject.Value<int>("Epoint");
                    var dataId = jobject.Value<int>("Data_ID");
                    switch ((DeviceType)(deviceID))
                    {
                        case DeviceType.DimmableLight:
                            var light = new DimmableLight { DeviceID = deviceID, DeviceAddr = deviceAddr, DeviceEpoint = tempEpoint, DataID = dataId };
                            light.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<DimmableLight.DeviceStatusReportData>(jobject["Data"].ToString());
                            UpdateDeviceStatus(light);
                            UpdateDeviceInfo(light, "DeviceStatusReport");
                            break;
                        case DeviceType.OnOffSwitch:
                            var lightSwitch = new Panel { DeviceID = deviceID, DeviceAddr = deviceAddr, DeviceEpoint = tempEpoint, DataID = dataId };
                            lightSwitch.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.DeviceStatusReportData>(jobject["Data"].ToString());
                            UpdateDeviceStatus(lightSwitch);
                            UpdateDeviceInfo(lightSwitch, "DeviceStatusReport");
                            break;
                        case DeviceType.OnOffOutput:
                            var lighttoggle = new ToggleLight { DeviceID = deviceID, DeviceAddr = deviceAddr, DeviceEpoint = tempEpoint, DataID = dataId };
                            lighttoggle.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<ToggleLight.DeviceStatusReportData>(jobject["Data"].ToString());
                            UpdateDeviceStatus(lighttoggle);
                            UpdateDeviceInfo(lighttoggle, "DeviceStatusReport");
                            break;
                        case DeviceType.AirSwitch:
                            var airSwitch = new AirSwitch { DeviceID = deviceID, DeviceAddr = deviceAddr, DeviceEpoint = tempEpoint, DataID = dataId };
                            airSwitch.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<AirSwitch.DeviceStatusReportData>(jobject["Data"].ToString());
                            UpdateDeviceStatus(airSwitch);
                            UpdateDeviceInfo(airSwitch, "DeviceStatusReport");
                            break;
                        case DeviceType.WindowCoveringDevice:
                            var curtain = new Rollershade { DeviceID = deviceID, DeviceAddr = deviceAddr, DeviceEpoint = tempEpoint, DataID = dataId };
                            curtain.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<Rollershade.DeviceStatusReportData>(jobject["Data"].ToString());
                            UpdateDeviceStatus(curtain);
                            UpdateDeviceInfo(curtain, "DeviceStatusReport");
                            break;
                        case DeviceType.OtaDevice:
                        case DeviceType.OtaPanelDevice:
                            var ota = new OTADevice { DeviceID = deviceID, DeviceAddr = deviceAddr, DeviceEpoint = tempEpoint, DataID = dataId };
                            ota.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<OTADevice.DeviceStatusReportData>(jobject["Data"].ToString());
                            UpdateDeviceStatus(ota);
                            UpdateDeviceInfo(ota, "DeviceStatusReport");
                            break;
                        case DeviceType.IASZone:
                            var ias = new IASZone { DeviceID = deviceID, DeviceAddr = deviceAddr, DeviceEpoint = tempEpoint, DataID = dataId };
                            ias.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<IASZone.DeviceStatusReportData>(jobject["Data"].ToString());
                            UpdateDeviceStatus(ias);
                            UpdateDeviceInfo(ias, "DeviceStatusReport");
                            break;
                        case DeviceType.Repeater:
                            var repeater = new Repeater { DeviceID = deviceID, DeviceAddr = deviceAddr, DeviceEpoint = tempEpoint, DataID = dataId };
                            repeater.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<Repeater.DeviceStatusReportData>(jobject["Data"].ToString());
                            UpdateDeviceStatus(repeater);
                            UpdateDeviceInfo(repeater, "DeviceStatusReport");
                            break;
                        case DeviceType.Thermostat:
                            var ac = new AC { DeviceID = deviceID, DeviceAddr = deviceAddr, DeviceEpoint = tempEpoint, DataID = dataId };
                            ac.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<AC.DeviceStatusReportData>(jobject["Data"].ToString());
                            UpdateDeviceStatus(ac);
                            UpdateDeviceInfo(ac, "DeviceStatusReport");
                            break;
                        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());
                            UpdateDeviceStatus(transverter);
                            UpdateDeviceInfo(transverter, "DeviceStatusReport");
                            break;
                    }
                    var tempDevice = new CommonDevice { DeviceID = deviceID, DeviceAddr = deviceAddr, DeviceEpoint = tempEpoint, DataID = dataId };
                    tempDevice.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.DeviceStatusReportData>(jobject["Data"].ToString());
                    UpdateDeviceStatus(tempDevice);
                    UpdateDeviceInfo(tempDevice, "DeviceStatusReport");
                }
                #endregion
                #region IAS安防信息上报