陈嘉乐
2020-05-15 d5b9ff8bf8cc36f5b13c46b66682f5988d3a6f36
ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs
@@ -143,12 +143,6 @@
        public List<CommonDevice> DeviceList = new List<CommonDevice>();
        /// <summary>
        /// 所有网关中的设备列表
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public List<CommonDevice> AllGatewayDeviceList = new List<CommonDevice>();
        /// <summary>
        /// 网关中场景列表
        /// 一个场景中包含所有信息,包括场景设备信息
        /// </summary>
@@ -160,34 +154,6 @@
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public List<Scene.GetSceneDeviceListInfo> SceneDeviceList = new List<Scene.GetSceneDeviceListInfo>();
        /// <summary>
        /// 网关中逻辑列表
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public static List<Logic.GetLogicInfoResponseData> LogicList = new List<Logic.GetLogicInfoResponseData>();
        /// <summary>
        /// 网关中hdl私有按键绑定列表
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public List<HDLbutton> HdlButtonList = new List<HDLbutton>();
        //网关中新的设备列表
        [Newtonsoft.Json.JsonIgnore]
        public List<CommonDevice> ListNewDeviceInfoData = new List<CommonDevice>();
        /// <summary>
        /// 私有按键信息列表
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public System.Collections.Generic.Dictionary<string, HDLbutton> hdlButtonInfoList = new Dictionary<string, HDLbutton>();
        /// <summary>
        /// 传感器信息列表
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public System.Collections.Generic.Dictionary<string, Scene.TaskListInfo> sceneTaskInfoList = new Dictionary<string, Scene.TaskListInfo>();
        #region action variable
        /// <summary>
@@ -634,422 +600,6 @@
                return d;
            });
        }
        #endregion
        #region 获取已入网设备信息
        /// <summary>
        /// 获取网关设备信息(注意,这个接口会被去掉)
        /// </summary>
        public async System.Threading.Tasks.Task<List<CommonDevice>> GetGwDeviceList()
        {
            DeviceList.Clear();
            return await System.Threading.Tasks.Task.Run((Func<System.Threading.Tasks.Task<List<CommonDevice>>>)(async () =>
            {
                var dateTime = DateTime.Now;
                bool canBreak = false;
                Action<string, string> action = (topic, message) =>
                {
                    var gatewayID = topic.Split('/')[0];
                    var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
                    if (topic == gatewayID + "/" + "DeviceInfoRespon")
                    {
                        dateTime = DateTime.Now;
                        var totalNum = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(jobject["Data"]["TotalNum"].ToString());
                        if (totalNum == 0)
                        {
                            canBreak = true;
                            return;
                        }
                        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;
                        }
                    }
                    else if (topic == gatewayID + "/" + "DeviceInfoResponEnd")
                    {
                        canBreak = true;
                    }
                };
                Actions += action;
                DebugPrintLog("DeviceInfo Actions 启动" + "_" + System.DateTime.Now.ToString());
                try
                {
                    var jObject = new JObject { { "Cluster_ID", 0 }, { "Command", 93 } };
                    Send("GetDeviceInfo", jObject.ToString());
                }
                catch { }
                while (canBreak == false && (DateTime.Now - dateTime).TotalMilliseconds < 6000)
                {
                    await System.Threading.Tasks.Task.Delay(10);
                }
                Actions -= action;
                DebugPrintLog("DeviceInfo_Actions 退出" + System.DateTime.Now.ToString());
                return DeviceList;
            }));
        }
        #endregion
@@ -3054,22 +2604,6 @@
        public static readonly System.Collections.Generic.List<IStatus> StatusList = new System.Collections.Generic.List<IStatus>();
        /// <summary>
        /// 设备状态更新
        /// </summary>
        /// <param name="commonDevice">Common device.</param>
        public static void UpdateDeviceStatus(CommonDevice commonDevice)
        {
            if (commonDevice == null)
            {
                return;
            }
            for (int i = 0; i < StatusList.Count; i++)
            {
                StatusList[i].Changed(commonDevice);
            }
        }
        /// <summary>
        /// 设备信息变化
        /// <para>type:如果为 DeviceInComingRespon:设备新上报</para>
        /// <para>type:如果为 IASInfoReport:RemoveDeviceRespon</para>
@@ -3180,14 +2714,14 @@
                            {
                                if (localMqttClient.Options == null)
                                {
                                    var options = new MQTTnet.Client.Options.MqttClientOptionsBuilder().WithClientId(currentGuid.ToString())
                       .WithTcpServer(brokerName, 1883)
                       .WithKeepAlivePeriod(TimeSpan.FromSeconds(20))
                       .WithCleanSession()
                        //.WithCommunicationTimeout(TimeSpan.FromSeconds(10))
                       .WithCredentials("", "")
                       .Build();
                                    await localMqttClient.ConnectAsync(options, CancellationToken.None);
                                    var options = new MQTTnet.Client.Options.MqttClientOptionsBuilder()//MQTT连接参数填充
                                    .WithClientId(currentGuid.ToString())//客户端ID
                                    .WithTcpServer(brokerName, 1883)//TCP服务端  1883  ,即MQTT服务端
                                    .WithCredentials("", "")//"", "")//凭证  帐号 密码
                                    .WithCommunicationTimeout(new TimeSpan(0, 0, 60)) //重连超时时间,默认5s
                                    .WithKeepAlivePeriod(new TimeSpan(0, 0, 15)) //保持连接时间,默认5s,心跳包
                                    .Build();//
                                    await localMqttClient.ConnectAsync(options);
                                }
                                else
                                {
@@ -3359,23 +2893,19 @@
                        if (RemoteMqttClient.ApplicationMessageReceivedHandler == null)
                        {
                            RemoteMqttClient.UseApplicationMessageReceivedHandler((e) =>
                            {
                                if (!RemoteMqttClient.IsConnected || !IsRemote)
                                {
                                    if (e.ApplicationMessage.Topic != "/ZigbeeGateWayToClient/" + Config.Instance.ConnEmqClientId + "/Push/NotifySqueeze")
                                    {
                                        return;
                                    }
                                }
                                //如果当前使用的是内网模式
                                if (IsRemote == false)
                            {
                                //这里是特殊的主题
                                if (e.ApplicationMessage.Topic == "/ZigbeeGateWayToClient/" + Config.Instance.ConnEmqClientId + "/Push/NotifySqueeze"//踢人下线
                                   || e.ApplicationMessage.Topic == "/ZigbeeGateWayToClient/" + Config.Instance.Guid + "/Push/Deleted"//分享删除
                                   || e.ApplicationMessage.Topic == "/ZigbeeGateWayToClient/" + Config.Instance.Guid + "/Push/DeletedShareData"//分享删除
                                   || e.ApplicationMessage.Topic == "/ZigbeeGateWayToClient/" + Config.Instance.Guid + "/Push/Update"//成员权限变更
                                   || e.ApplicationMessage.Topic == "/ZigbeeGateWayToClient/" + Config.Instance.Home.Id + "_" + Config.Instance.Guid + "/PrimaryUserDelYou")//子账号被删除
                                {
                                    if (e.ApplicationMessage.Topic == "/ZigbeeGateWayToClient/" + Config.Instance.ConnEmqClientId + "/Push/NotifySqueeze"//踢人下线
                                      || e.ApplicationMessage.Topic == "/ZigbeeGateWayToClient/" + Config.Instance.Guid + "/Push/Deleted"//分享删除
                                      || e.ApplicationMessage.Topic == "/ZigbeeGateWayToClient/" + Config.Instance.Guid + "/Push/DeletedShareData")
                                    {
                                        mqttRemoteClient_MqttMsgPublishReceived(e);
                                    }
                                    mqttRemoteClient_MqttMsgPublishReceived(e);
                                    return;
                                }
                                if (!RemoteMqttClient.IsConnected || !IsRemote)
                                {
                                    return;
                                }
                                mqttRemoteClient_MqttMsgPublishReceived(e);
@@ -3404,6 +2934,10 @@
                                    await RemoteMqttClient.SubscribeAsync("/ZigbeeGateWayToClient/" + myGuid + "/Push/Deleted");
                                    //订阅一个分享数据已经变更的主题
                                    await RemoteMqttClient.SubscribeAsync("/ZigbeeGateWayToClient/" + myGuid + "/Push/DeletedShareData");
                                    //订阅一个子账号被删除的主题
                                    await RemoteMqttClient.SubscribeAsync("/ZigbeeGateWayToClient/" + Config.Instance.Home.Id + "_" + myGuid + "/PrimaryUserDelYou");
                                    //订阅一个成员权限已经变更的主题
                                    await RemoteMqttClient.SubscribeAsync("/ZigbeeGateWayToClient/" + myGuid + "/Push/Update");
                                }
                                //订阅一个挤下线的主题
                                await RemoteMqttClient.SubscribeAsync("/ZigbeeGateWayToClient/" + Config.Instance.ConnEmqClientId + "/Push/NotifySqueeze");
@@ -3495,6 +3029,9 @@
                                AllowRemoteCtrl = false;
                                return;
                            }
                            //虽然不知道对挤下线那一块有没有用,不过先这么弄
                            await System.Threading.Tasks.Task.Delay(1500);
                            var responseData = jobject["ResponseData"];
                            if (responseData != null)
                            {
@@ -4013,8 +3550,7 @@
                        DebugPrintLog("DeviceInComingRespon已经通知");
                        gwa.ReportAction("DeviceInComingRespon", tempDevice.getNewDeviceInfo);
                    }
                    UpdateDeviceInfo(tempDevice, "DeviceInComingRespon");
                    UpdateDeviceStatus(gwa);
                    UpdateDeviceInfo(tempDevice, "DeviceInComingRespon");
                }
                #endregion
                #region 设备在线状态更新反馈
@@ -4032,7 +3568,6 @@
                    if (infoTempDevice == null)
                    {
                        gwa.DeviceList.Add(tempDevice);
                        UpdateDeviceStatus(tempDevice);
                        UpdateDeviceInfo(tempDevice, "OnlineStatusChange");
                    }
                    else
@@ -4042,7 +3577,6 @@
                            infoTempDevice.DeviceInfo.IsOnline = infoTempDevice.IsOnline;
                        }
                        UpdateDeviceInfo(infoTempDevice, "OnlineStatusChange");
                        UpdateDeviceStatus(infoTempDevice);
                    }
                }
                #endregion
@@ -4068,7 +3602,6 @@
                                    }
                                    else
                                    {
                                        UpdateDeviceStatus(tempDevice);
                                        UpdateDeviceInfo(tempDevice, "RemoveDeviceRespon");
                                        if (tempDevice.removeDeviceResponseData.Result == 0)
                                        {
@@ -4096,7 +3629,6 @@
                    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
@@ -4118,7 +3650,6 @@
                                DebugPrintLog("DoorLockProgrammingEventNotificationCommand已经通知");
                                gwa.ReportAction("DoorLockProgrammingEventNotificationCommand", doorLock);
                            }
                            UpdateDeviceStatus(doorLock);
                            UpdateDeviceInfo(doorLock, "DoorLockProgrammingEventNotificationCommand");
                            break;
                    }
@@ -4142,7 +3673,6 @@
                                DebugPrintLog("DoorLockProgrammingEventNotificationCommand已经通知");
                                gwa.ReportAction("DoorLockProgrammingEventNotificationCommand", doorLock);
                            }
                            UpdateDeviceStatus(doorLock);
                            UpdateDeviceInfo(doorLock, "DoorLockProgrammingEventNotificationCommand");
                            break;
                    }
@@ -4164,8 +3694,6 @@
                                //ias.Save();
                                gwa.ReportAction("IASInfoReport", ias.iASInfo);
                            }
                            UpdateDeviceStatus(ias);
                            UpdateDeviceInfo(ias, "IASInfoReport");
                            break;
                    }
@@ -4280,37 +3808,37 @@
                #region 逻辑被调用反馈
                else if (topic == gatewayID + "/" + "Logic/Execute_Respon")
                {
                    var logic = new Logic() { DataID = jobject.Value<int>("Data_ID"), GateWayId = gwa.getGatewayBaseInfo.gwID };
                    logic.logicExecuteRespo = Newtonsoft.Json.JsonConvert.DeserializeObject<Logic.ExecuteResponse>(jobject["Data"].ToString());
                    //var logic = new Logic() { DataID = jobject.Value<int>("Data_ID"), GateWayId = gwa.getGatewayBaseInfo.gwID };
                    //logic.logicExecuteRespo = Newtonsoft.Json.JsonConvert.DeserializeObject<Logic.ExecuteResponse>(jobject["Data"].ToString());
                    if (logic.logicExecuteRespo == null)
                    {
                        return;
                    }
                    //上报类型通知
                    if (gwa.ReportAction != null)
                    {
                        DebugPrintLog("LogicExecuteReport已经通知");
                        gwa.ReportAction("LogicExecuteReport", logic.logicExecuteRespo);
                    }
                    //if (logic.logicExecuteRespo == null)
                    //{
                    //    return;
                    //}
                    ////上报类型通知
                    //if (gwa.ReportAction != null)
                    //{
                    //    DebugPrintLog("LogicExecuteReport已经通知");
                    //    gwa.ReportAction("LogicExecuteReport", logic.logicExecuteRespo);
                    //}
                }
                #endregion
                #region 时间点条件推迟执行
                else if (topic == gatewayID + "/" + "Logic/TimingWillArrive")
                {
                    var logic = new Logic() { DataID = jobject.Value<int>("Data_ID"), GateWayId = gwa.getGatewayBaseInfo.gwID };
                    logic.timingWillArriveData = Newtonsoft.Json.JsonConvert.DeserializeObject<Logic.TimingWillArriveData>(jobject["Data"].ToString());
                    //var logic = new Logic() { DataID = jobject.Value<int>("Data_ID"), GateWayId = gwa.getGatewayBaseInfo.gwID };
                    //logic.timingWillArriveData = Newtonsoft.Json.JsonConvert.DeserializeObject<Logic.TimingWillArriveData>(jobject["Data"].ToString());
                    if (logic.timingWillArriveData == null)
                    {
                        return;
                    }
                    //上报类型通知
                    if (gwa.ReportAction != null)
                    {
                        DebugPrintLog("TimingWillArrive已经通知");
                        gwa.ReportAction("TimingWillArrive", logic.timingWillArriveData);
                    }
                    //if (logic.timingWillArriveData == null)
                    //{
                    //    return;
                    //}
                    ////上报类型通知
                    //if (gwa.ReportAction != null)
                    //{
                    //    DebugPrintLog("TimingWillArrive已经通知");
                    //    gwa.ReportAction("TimingWillArrive", logic.timingWillArriveData);
                    //}
                }
                #endregion
                #region 模式安防动作被最终激活时发送报警信息