xm
2020-04-16 6fa9d69da922c8049f5acfcbb9ce9fd26811024c
ZigbeeApp/Shared/Phone/ZigBee/Device/CommonDevice.cs
@@ -10,6 +10,11 @@
    {
        [Newtonsoft.Json.JsonIgnore]
        public DateTime LastDateTime = DateTime.MinValue;
        /// <summary>
        /// 是否已经读取了设备状态(此属性是给主页使用的)
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public bool HadReadDeviceStatu = false;
        /// <summary>
        /// 调试时打开打印信息,true:打印,false:不打印
@@ -18,6 +23,7 @@
        /// <param name="flage">If set to <c>true</c> flage.</param>
        public static void DebugPrintLog(string msg, bool flage = true)
        {
#if DEBUG
            if (flage == true)
            {
                if (msg.Contains("DeviceStatusReport") == false)
@@ -25,6 +31,7 @@
                    System.Console.WriteLine(msg + "  " + System.DateTime.Now.ToLongTimeString() + " " + System.DateTime.Now.Millisecond);
                }
            }
#endif
        }
        /// <summary>
@@ -167,6 +174,14 @@
            {
                return Newtonsoft.Json.JsonConvert.DeserializeObject<TemperatureSensor>(strDeviceByte);
            }
            else if (strDeviceType == ZigBee.Device.DeviceType.FreshAirHumiditySensor.ToString())
            {
                return Newtonsoft.Json.JsonConvert.DeserializeObject<HumiditySensor>(strDeviceByte);
            }
            else if (strDeviceType == ZigBee.Device.DeviceType.FreshAir.ToString())
            {
                return Newtonsoft.Json.JsonConvert.DeserializeObject<FreshAir>(strDeviceByte);
            }
            return null;
        }
@@ -223,10 +238,16 @@
                    //继电器
                    IconPath = "Device/RelayEpoint.png";
                }
                else if (this.Type == DeviceType.Thermostat)
                else if (this.Type == DeviceType.Thermostat || this.Type == DeviceType.FreshAir)
                {
                    //空调
                    //新风和空调图标相同
                    IconPath = "Device/AirConditionerEpoint.png";
                }
                else if (this.Type == DeviceType.FreshAirHumiditySensor)
                {
                    //湿度传感器
                    IconPath = "Device/SensorHumidity.png";
                }
                else if (this.Type == DeviceType.TemperatureSensor)
                {
@@ -246,7 +267,7 @@
                    //其他的图标有点特殊
                    string unSelectPic = string.Empty;
                    string selectPic = string.Empty;
                    Shared.Common.LocalDevice.Current.GetDeviceBeloneIcon(new List<CommonDevice> { this }, ref unSelectPic, ref selectPic);
                    Shared.Common.LocalDevice.Current.GetDeviceObjectIcon(new List<CommonDevice> { this }, ref unSelectPic, ref selectPic);
                    IconPath = unSelectPic;
                }
                Shared.Common.Global.WriteFileByBytesByHomeId(FilePath, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this)));
@@ -1149,198 +1170,8 @@
                    if (topic == gatewayID + "/" + "DeviceRenameRespon")
                    {
                        var deviceID = jobject.Value<int>("Device_ID");
                        switch ((DeviceType)(deviceID))
                        {
                            case DeviceType.OnOffOutput:
                                var toggleLight = new ToggleLight() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId };
                                toggleLight.renameDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<ToggleLight.DeviceRenameResponseData>(jobject["Data"].ToString());
                                if (toggleLight.renameDeviceData == null)
                                {
                                    d = new DeviceRenameAllData { errorMessageBase = "网关返回的数据为空" };
                                }
                                else
                                {
                                    d = new DeviceRenameAllData { deviceRenameData = toggleLight.renameDeviceData };
                                    System.Console.WriteLine($"UI收到通知后的主题_{ topic}");
                                    var infoToggleLight = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == toggleLight.DeviceID && obj.DeviceAddr == toggleLight.DeviceAddr && obj.DeviceEpoint == toggleLight.DeviceEpoint);
                                    if (infoToggleLight != null)
                                    {
                                        infoToggleLight.DeviceEpointName = toggleLight.renameDeviceData.DeviceName;
                                    }
                                }
                                break;
                            case DeviceType.AirSwitch:
                                var airSwitch = new AirSwitch() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId };
                                airSwitch.renameDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<AirSwitch.DeviceRenameResponseData>(jobject["Data"].ToString());
                                if (airSwitch.renameDeviceData == null)
                                {
                                    d = new DeviceRenameAllData { errorMessageBase = "网关返回的数据为空" };
                                }
                                else
                                {
                                    d = new DeviceRenameAllData { deviceRenameData = airSwitch.renameDeviceData };
                                    System.Console.WriteLine($"UI收到通知后的主题_{ topic}");
                                    var infoAirSwitch = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == airSwitch.DeviceID && obj.DeviceAddr == airSwitch.DeviceAddr && obj.DeviceEpoint == airSwitch.DeviceEpoint);
                                    if (infoAirSwitch != null)
                                    {
                                        infoAirSwitch.DeviceEpointName = airSwitch.renameDeviceData.DeviceName;
                                        //infoAirSwitch.ReSave();
                                    }
                                }
                                break;
                            case DeviceType.OnOffSwitch:
                                var panelObj = new Panel() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId };
                                panelObj.renameDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.DeviceRenameResponseData>(jobject["Data"].ToString());
                                if (panelObj.renameDeviceData == null)
                                {
                                    d = new DeviceRenameAllData { errorMessageBase = "网关返回的数据为空" };
                                }
                                else
                                {
                                    d = new DeviceRenameAllData { deviceRenameData = panelObj.renameDeviceData };
                                    System.Console.WriteLine($"UI收到通知后的主题_{ topic}");
                                    var infoPanel = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == panelObj.DeviceID && obj.DeviceAddr == panelObj.DeviceAddr && obj.DeviceEpoint == panelObj.DeviceEpoint);
                                    if (infoPanel != null)
                                    {
                                        infoPanel.DeviceEpointName = panelObj.renameDeviceData.DeviceName;
                                        //infoPanel.ReSave();
                                    }
                                }
                                break;
                            case DeviceType.WindowCoveringDevice:
                                var windowCovering = new Rollershade() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId };
                                windowCovering.renameDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<Rollershade.DeviceRenameResponseData>(jobject["Data"].ToString());
                                if (windowCovering.renameDeviceData == null)
                                {
                                    d = new DeviceRenameAllData { errorMessageBase = "网关返回的数据为空" };
                                }
                                else
                                {
                                    d = new DeviceRenameAllData { deviceRenameData = windowCovering.renameDeviceData };
                                    System.Console.WriteLine($"UI收到通知后的主题_{topic}");
                                    var wc = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == windowCovering.DeviceID && obj.DeviceAddr == windowCovering.DeviceAddr && obj.DeviceEpoint == windowCovering.DeviceEpoint);
                                    if (wc != null)
                                    {
                                        wc.DeviceEpointName = windowCovering.renameDeviceData.DeviceName;
                                    }
                                }
                                break;
                            case DeviceType.IASZone:
                                var ias = new IASZone() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId };
                                ias.renameDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<Rollershade.DeviceRenameResponseData>(jobject["Data"].ToString());
                                if (ias.renameDeviceData == null)
                                {
                                    d = new DeviceRenameAllData { errorMessageBase = "网关返回的数据为空" };
                                }
                                else
                                {
                                    d = new DeviceRenameAllData { deviceRenameData = ias.renameDeviceData };
                                    System.Console.WriteLine($"UI收到通知后的主题_{topic}");
                                    var zone = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == ias.DeviceID && obj.DeviceAddr == ias.DeviceAddr && obj.DeviceEpoint == ias.DeviceEpoint);
                                    if (zone != null)
                                    {
                                        zone.DeviceEpointName = ias.renameDeviceData.DeviceName;
                                    }
                                }
                                break;
                            case DeviceType.DimmableLight:
                                var dimmableLight = new DimmableLight() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId };
                                dimmableLight.renameDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<DimmableLight.DeviceRenameResponseData>(jobject["Data"].ToString());
                                if (dimmableLight.renameDeviceData == null)
                                {
                                    d = new DeviceRenameAllData { errorMessageBase = "网关返回的数据为空" };
                                }
                                else
                                {
                                    d = new DeviceRenameAllData { deviceRenameData = dimmableLight.renameDeviceData };
                                    System.Console.WriteLine($"UI收到通知后的主题_{ topic}");
                                    var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == dimmableLight.DeviceID && obj.DeviceAddr == dimmableLight.DeviceAddr && obj.DeviceEpoint == dimmableLight.DeviceEpoint);
                                    if (info != null)
                                    {
                                        info.DeviceEpointName = dimmableLight.renameDeviceData.DeviceName;
                                    }
                                }
                                break;
                            case DeviceType.Repeater:
                                var repeater = new Repeater() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId };
                                repeater.renameDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<Repeater.DeviceRenameResponseData>(jobject["Data"].ToString());
                                if (repeater.renameDeviceData == null)
                                {
                                    d = new DeviceRenameAllData { errorMessageBase = "网关返回的数据为空" };
                                }
                                else
                                {
                                    d = new DeviceRenameAllData { deviceRenameData = repeater.renameDeviceData };
                                    System.Console.WriteLine($"UI收到通知后的主题_{ topic}");
                                    var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == repeater.DeviceID && obj.DeviceAddr == repeater.DeviceAddr && obj.DeviceEpoint == repeater.DeviceEpoint);
                                    if (info != null)
                                    {
                                        info.DeviceEpointName = repeater.renameDeviceData.DeviceName;
                                    }
                                }
                                break;
                            case DeviceType.Thermostat:
                                var ac = new AC() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId };
                                ac.renameDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<AC.DeviceRenameResponseData>(jobject["Data"].ToString());
                                if (ac.renameDeviceData == null)
                                {
                                    d = new DeviceRenameAllData { errorMessageBase = "网关返回的数据为空" };
                                }
                                else
                                {
                                    d = new DeviceRenameAllData { deviceRenameData = ac.renameDeviceData };
                                    System.Console.WriteLine($"UI收到通知后的主题_{ topic}");
                                    var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == ac.DeviceID && obj.DeviceAddr == ac.DeviceAddr && obj.DeviceEpoint == ac.DeviceEpoint);
                                    if (info != null)
                                    {
                                        info.DeviceEpointName = ac.renameDeviceData.DeviceName;
                                    }
                                }
                                break;
                            case DeviceType.Transverter:
                                var transverter = new Transverter() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId };
                                transverter.renameDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<Transverter.DeviceRenameResponseData>(jobject["Data"].ToString());
                                if (transverter.renameDeviceData == null)
                                {
                                    d = new DeviceRenameAllData { errorMessageBase = "网关返回的数据为空" };
                                }
                                else
                                {
                                    d = new DeviceRenameAllData { deviceRenameData = transverter.renameDeviceData };
                                    System.Console.WriteLine($"UI收到通知后的主题_{ topic}");
                                    var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == transverter.DeviceID && obj.DeviceAddr == transverter.DeviceAddr && obj.DeviceEpoint == transverter.DeviceEpoint);
                                    if (info != null)
                                    {
                                        info.DeviceEpointName = transverter.renameDeviceData.DeviceName;
                                    }
                                }
                                break;
                            case DeviceType.DoorLock:
                                var doorLock = new DoorLock() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId };
                                doorLock.renameDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<DoorLock.DeviceRenameResponseData>(jobject["Data"].ToString());
                                if (doorLock.renameDeviceData == null)
                                {
                                    d = new DeviceRenameAllData { errorMessageBase = "网关返回的数据为空" };
                                }
                                else
                                {
                                    d = new DeviceRenameAllData { deviceRenameData = doorLock.renameDeviceData };
                                    System.Console.WriteLine($"UI收到通知后的主题_{ topic}");
                                    var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == doorLock.DeviceID && obj.DeviceAddr == doorLock.DeviceAddr && obj.DeviceEpoint == doorLock.DeviceEpoint);
                                    if (info != null)
                                    {
                                        info.DeviceEpointName = doorLock.renameDeviceData.DeviceName;
                                    }
                                }
                                break;
                        }
                        var receiptData = Newtonsoft.Json.JsonConvert.DeserializeObject<DeviceRenameResponseData>(jobject["Data"].ToString());
                        d = new DeviceRenameAllData { deviceRenameData = receiptData };
                    }
                };
                Gateway.Actions += action;
@@ -1462,217 +1293,8 @@
                    if (topic == gatewayID + "/" + "MacRename_Respon")
                    {
                        var deviceID = jobject.Value<int>("Device_ID");
                        switch ((DeviceType)(deviceID))
                        {
                            case DeviceType.OnOffOutput:
                                var toggleLight = new ToggleLight() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId };
                                toggleLight.renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<ToggleLight.RenameDeviceMacNameData>(jobject["Data"].ToString());
                                if (toggleLight.renameDeviceMacNameData == null)
                                {
                                    d = new RenameDeviceMacNameAllData { errorMessageBase = "网关返回的数据为空" };
                                }
                                else
                                {
                                    d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = toggleLight.renameDeviceMacNameData };
                                    System.Console.WriteLine($"UI收到通知后的主题_{ topic}");
                                    var infoToggleLight = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == toggleLight.DeviceID && obj.DeviceAddr == toggleLight.DeviceAddr && obj.DeviceEpoint == toggleLight.DeviceEpoint);
                                    if (infoToggleLight != null)
                                    {
                                        infoToggleLight.DeviceName = toggleLight.renameDeviceMacNameData.MacName;
                                    }
                                }
                                break;
                            case DeviceType.AirSwitch:
                                var airSwitch = new AirSwitch() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId };
                                airSwitch.renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<AirSwitch.RenameDeviceMacNameData>(jobject["Data"].ToString());
                                if (airSwitch.renameDeviceMacNameData == null)
                                {
                                    d = new RenameDeviceMacNameAllData { errorMessageBase = "网关返回的数据为空" };
                                }
                                else
                                {
                                    d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = airSwitch.renameDeviceMacNameData };
                                    System.Console.WriteLine($"UI收到通知后的主题_{ topic}");
                                    var infoAirSwitch = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == airSwitch.DeviceID && obj.DeviceAddr == airSwitch.DeviceAddr && obj.DeviceEpoint == airSwitch.DeviceEpoint);
                                    if (infoAirSwitch != null)
                                    {
                                        infoAirSwitch.DeviceName = airSwitch.renameDeviceMacNameData.MacName;
                                    }
                                }
                                break;
                            case DeviceType.OnOffSwitch:
                                var panelObj = new Panel() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId };
                                panelObj.renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.RenameDeviceMacNameData>(jobject["Data"].ToString());
                                if (panelObj.renameDeviceMacNameData == null)
                                {
                                    d = new RenameDeviceMacNameAllData { errorMessageBase = "网关返回的数据为空" };
                                }
                                else
                                {
                                    d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = panelObj.renameDeviceMacNameData };
                                    System.Console.WriteLine($"UI收到通知后的主题_{topic}");
                                    var infoPanel = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == panelObj.DeviceID && obj.DeviceAddr == panelObj.DeviceAddr && obj.DeviceEpoint == panelObj.DeviceEpoint);
                                    if (infoPanel != null)
                                    {
                                        infoPanel.DeviceName = panelObj.renameDeviceMacNameData.MacName;
                                    }
                                }
                                break;
                            case DeviceType.WindowCoveringDevice:
                                var windowCovering = new Rollershade() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId };
                                windowCovering.renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<Rollershade.RenameDeviceMacNameData>(jobject["Data"].ToString());
                                if (windowCovering.renameDeviceMacNameData == null)
                                {
                                    d = new RenameDeviceMacNameAllData { errorMessageBase = "网关返回的数据为空" };
                                }
                                else
                                {
                                    d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = windowCovering.renameDeviceMacNameData };
                                    System.Console.WriteLine($"UI收到通知后的主题_{ topic}_收到通知后的数据_{ d.renameDeviceMacNameData.ToString()}");
                                    var wc = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == windowCovering.DeviceID && obj.DeviceAddr == windowCovering.DeviceAddr && obj.DeviceEpoint == windowCovering.DeviceEpoint);
                                    if (wc != null)
                                    {
                                        wc.DeviceName = windowCovering.renameDeviceMacNameData.MacName;
                                    }
                                }
                                break;
                            case DeviceType.IASZone:
                                var ias = new IASZone() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId };
                                ias.renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<DimmableLight.RenameDeviceMacNameData>(jobject["Data"].ToString());
                                if (ias.renameDeviceMacNameData == null)
                                {
                                    d = new RenameDeviceMacNameAllData { errorMessageBase = "网关返回的数据为空" };
                                }
                                else
                                {
                                    d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = ias.renameDeviceMacNameData };
                                    System.Console.WriteLine($"UI收到通知后的主题_{ topic}_收到通知后的数据_{ d.renameDeviceMacNameData.ToString()}");
                                    var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == ias.DeviceID && obj.DeviceAddr == ias.DeviceAddr && obj.DeviceEpoint == ias.DeviceEpoint);
                                    if (info != null)
                                    {
                                        info.DeviceName = ias.renameDeviceMacNameData.MacName;
                                    }
                                }
                                break;
                            case DeviceType.DimmableLight:
                                var dimmableLight = new DimmableLight() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId };
                                dimmableLight.renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<DimmableLight.RenameDeviceMacNameData>(jobject["Data"].ToString());
                                if (dimmableLight.renameDeviceMacNameData == null)
                                {
                                    d = new RenameDeviceMacNameAllData { errorMessageBase = "网关返回的数据为空" };
                                }
                                else
                                {
                                    d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = dimmableLight.renameDeviceMacNameData };
                                    System.Console.WriteLine($"UI收到通知后的主题_{ topic}_收到通知后的数据_{ d.renameDeviceMacNameData.ToString()}");
                                    var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == dimmableLight.DeviceID && obj.DeviceAddr == dimmableLight.DeviceAddr && obj.DeviceEpoint == dimmableLight.DeviceEpoint);
                                    if (info != null)
                                    {
                                        info.DeviceName = dimmableLight.renameDeviceMacNameData.MacName;
                                    }
                                }
                                break;
                            case DeviceType.Repeater:
                                var repeater = new DimmableLight() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId };
                                repeater.renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<Repeater.RenameDeviceMacNameData>(jobject["Data"].ToString());
                                if (repeater.renameDeviceMacNameData == null)
                                {
                                    d = new RenameDeviceMacNameAllData { errorMessageBase = "网关返回的数据为空" };
                                }
                                else
                                {
                                    d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = repeater.renameDeviceMacNameData };
                                    System.Console.WriteLine($"UI收到通知后的主题_{ topic}_收到通知后的数据_{ d.renameDeviceMacNameData.ToString()}");
                                    var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == repeater.DeviceID && obj.DeviceAddr == repeater.DeviceAddr && obj.DeviceEpoint == repeater.DeviceEpoint);
                                    if (info != null)
                                    {
                                        info.DeviceName = repeater.renameDeviceMacNameData.MacName;
                                    }
                                }
                                break;
                            case DeviceType.Thermostat:
                                var ac = new AC() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId };
                                ac.renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<AC.RenameDeviceMacNameData>(jobject["Data"].ToString());
                                if (ac.renameDeviceMacNameData == null)
                                {
                                    d = new RenameDeviceMacNameAllData { errorMessageBase = "网关返回的数据为空" };
                                }
                                else
                                {
                                    d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = ac.renameDeviceMacNameData };
                                    System.Console.WriteLine($"UI收到通知后的主题_{ topic}_收到通知后的数据_{ d.renameDeviceMacNameData.ToString()}");
                                    var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == ac.DeviceID && obj.DeviceAddr == ac.DeviceAddr && obj.DeviceEpoint == ac.DeviceEpoint);
                                    if (info != null)
                                    {
                                        info.DeviceName = ac.renameDeviceMacNameData.MacName;
                                    }
                                }
                                break;
                            case DeviceType.Transverter:
                                var transverter = new Transverter() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId };
                                transverter.renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<Transverter.RenameDeviceMacNameData>(jobject["Data"].ToString());
                                if (transverter.renameDeviceMacNameData == null)
                                {
                                    d = new RenameDeviceMacNameAllData { errorMessageBase = "网关返回的数据为空" };
                                }
                                else
                                {
                                    d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = transverter.renameDeviceMacNameData };
                                    System.Console.WriteLine($"UI收到通知后的主题_{ topic}_收到通知后的数据_{ d.renameDeviceMacNameData.ToString()}");
                                    var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == transverter.DeviceID && obj.DeviceAddr == transverter.DeviceAddr && obj.DeviceEpoint == transverter.DeviceEpoint);
                                    if (info != null)
                                    {
                                        info.DeviceName = transverter.renameDeviceMacNameData.MacName;
                                    }
                                }
                                break;
                            case DeviceType.DoorLock:
                                var doorLock = new DoorLock() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId };
                                doorLock.renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<DoorLock.RenameDeviceMacNameData>(jobject["Data"].ToString());
                                if (doorLock.renameDeviceMacNameData == null)
                                {
                                    d = new RenameDeviceMacNameAllData { errorMessageBase = "网关返回的数据为空" };
                                }
                                else
                                {
                                    d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = doorLock.renameDeviceMacNameData };
                                    System.Console.WriteLine($"UI收到通知后的主题_{ topic}_收到通知后的数据_{ d.renameDeviceMacNameData.ToString()}");
                                    var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == doorLock.DeviceID && obj.DeviceAddr == doorLock.DeviceAddr && obj.DeviceEpoint == doorLock.DeviceEpoint);
                                    if (info != null)
                                    {
                                        info.DeviceName = doorLock.renameDeviceMacNameData.MacName;
                                    }
                                }
                                break;
                                //case DeviceType.TemperatureSensor:
                                //    var temperatureSensor = new TemperatureSensor() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId };
                                //    temperatureSensor.renameDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<TemperatureSensor.DeviceRenameResponseData>(jobject["Data"].ToString());
                                //    if (temperatureSensor.renameDeviceData == null)
                                //    {
                                //        d.errorMessageBase = "网关返回的数据为空";
                                //    }
                                //    else
                                //    {
                                //        d.deviceRenameData = temperatureSensor.renameDeviceData;
                                //    }
                                //    var ts = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == temperatureSensor.DeviceID && obj.DeviceEpoint == temperatureSensor.DeviceEpoint && obj.DeviceEpoint == temperatureSensor.DeviceEpoint);
                                //    if (ts == null)
                                //    {
                                //        ts.DeviceName = temperatureSensor.renameDeviceData.DeviceName;
                                //        IO.LocalFileUtils.SaveDeviceInfo(ts, ts.DeviceEpoint.ToString());
                                //    }
                                //    break;
                        }
                        var deviceID = jobject.Value<int>("Device_ID");
                        d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<ToggleLight.RenameDeviceMacNameData>(jobject["Data"].ToString()) };
                    }
                };
                Gateway.Actions += action;
@@ -1833,210 +1455,6 @@
                        {
                            d = new RemoveDeviceResponseAllData { removeDeviceResponseData = gatewayTemp.removeDeviceResponseData };
                            System.Console.WriteLine($"UI收到通知后的主题_{ topic}");
                            try
                            {
                                if (gatewayTemp.removeDeviceResponseData.Result == 0)
                                {
                                    foreach (var delD in gatewayTemp.removeDeviceResponseData.DeviceList)
                                    {
                                        var deviceID = delD.Device_ID;
                                        switch ((DeviceType)(deviceID))
                                        {
                                            case DeviceType.OnOffOutput:
                                                var toggleLight = new ToggleLight() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
                                                toggleLight.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ToggleLight.RemoveDeviceResponseData>(jobject["Data"].ToString());
                                                if (toggleLight.removeDeviceResponseData == null)
                                                {
                                                    return;
                                                }
                                                else
                                                {
                                                    if (toggleLight.removeDeviceResponseData.Result == 0)
                                                    {
                                                        var infoToggleLight = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == toggleLight.DeviceID && obj.DeviceAddr == toggleLight.DeviceAddr && obj.DeviceEpoint == toggleLight.DeviceEpoint);
                                                        if (infoToggleLight != null)
                                                        {
                                                            Gateway.DeviceList.Remove(infoToggleLight);
                                                        }
                                                    }
                                                }
                                                break;
                                            case DeviceType.AirSwitch:
                                                var airSwitch = new AirSwitch() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
                                                airSwitch.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<AirSwitch.RemoveDeviceResponseData>(jobject["Data"].ToString());
                                                if (airSwitch.removeDeviceResponseData == null)
                                                {
                                                    return;
                                                }
                                                else
                                                {
                                                    if (airSwitch.removeDeviceResponseData.Result == 0)
                                                    {
                                                        var infoAirSwitch = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == airSwitch.DeviceID && obj.DeviceAddr == airSwitch.DeviceAddr && obj.DeviceEpoint == airSwitch.DeviceEpoint);
                                                        if (infoAirSwitch != null)
                                                        {
                                                            Gateway.DeviceList.Remove(infoAirSwitch);
                                                        }
                                                    }
                                                }
                                                break;
                                            case DeviceType.OnOffSwitch:
                                                var panelObj = new Panel() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
                                                panelObj.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.RemoveDeviceResponseData>(jobject["Data"].ToString());
                                                if (panelObj.removeDeviceResponseData == null)
                                                {
                                                    return;
                                                }
                                                else
                                                {
                                                    if (panelObj.removeDeviceResponseData.Result == 0)
                                                    {
                                                        var infoPanel = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == panelObj.DeviceID && obj.DeviceAddr == panelObj.DeviceAddr && obj.DeviceEpoint == panelObj.DeviceEpoint);
                                                        if (infoPanel != null)
                                                        {
                                                            Gateway.DeviceList.Remove(infoPanel);
                                                        }
                                                    }
                                                }
                                                break;
                                            case DeviceType.WindowCoveringDevice:
                                                var rollershade = new Rollershade() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
                                                rollershade.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.RemoveDeviceResponseData>(jobject["Data"].ToString());
                                                if (rollershade.removeDeviceResponseData == null)
                                                {
                                                    return;
                                                }
                                                else
                                                {
                                                    if (rollershade.removeDeviceResponseData.Result == 0)
                                                    {
                                                        var infoRoller = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == rollershade.DeviceID && obj.DeviceAddr == rollershade.DeviceAddr && obj.DeviceEpoint == rollershade.DeviceEpoint);
                                                        if (infoRoller != null)
                                                        {
                                                            Gateway.DeviceList.Remove(infoRoller);
                                                        }
                                                    }
                                                }
                                                break;
                                            case DeviceType.IASZone:
                                                var ias = new IASZone() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
                                                ias.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<IASZone.RemoveDeviceResponseData>(jobject["Data"].ToString());
                                                if (ias.removeDeviceResponseData == null)
                                                {
                                                    return;
                                                }
                                                else
                                                {
                                                    if (ias.removeDeviceResponseData.Result == 0)
                                                    {
                                                        var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == ias.DeviceID && obj.DeviceAddr == ias.DeviceAddr && obj.DeviceEpoint == ias.DeviceEpoint);
                                                        if (info != null)
                                                        {
                                                            Gateway.DeviceList.Remove(info);
                                                        }
                                                    }
                                                }
                                                break;
                                            case DeviceType.DimmableLight:
                                                var dimmableLight = new DimmableLight() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
                                                dimmableLight.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<DimmableLight.RemoveDeviceResponseData>(jobject["Data"].ToString());
                                                if (dimmableLight.removeDeviceResponseData == null)
                                                {
                                                    return;
                                                }
                                                else
                                                {
                                                    if (dimmableLight.removeDeviceResponseData.Result == 0)
                                                    {
                                                        var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == dimmableLight.DeviceID && obj.DeviceAddr == dimmableLight.DeviceAddr && obj.DeviceEpoint == dimmableLight.DeviceEpoint);
                                                        if (info != null)
                                                        {
                                                            Gateway.DeviceList.Remove(info);
                                                        }
                                                    }
                                                }
                                                break;
                                            case DeviceType.Repeater:
                                                var repeater = new Repeater() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
                                                repeater.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<Repeater.RemoveDeviceResponseData>(jobject["Data"].ToString());
                                                if (repeater.removeDeviceResponseData == null)
                                                {
                                                    return;
                                                }
                                                else
                                                {
                                                    if (repeater.removeDeviceResponseData.Result == 0)
                                                    {
                                                        var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == repeater.DeviceID && obj.DeviceAddr == repeater.DeviceAddr && obj.DeviceEpoint == repeater.DeviceEpoint);
                                                        if (info != null)
                                                        {
                                                            Gateway.DeviceList.Remove(info);
                                                        }
                                                    }
                                                }
                                                break;
                                            case DeviceType.Thermostat:
                                                var ac = new AC() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
                                                ac.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<AC.RemoveDeviceResponseData>(jobject["Data"].ToString());
                                                if (ac.removeDeviceResponseData == null)
                                                {
                                                    return;
                                                }
                                                else
                                                {
                                                    if (ac.removeDeviceResponseData.Result == 0)
                                                    {
                                                        var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == ac.DeviceID && obj.DeviceAddr == ac.DeviceAddr && obj.DeviceEpoint == ac.DeviceEpoint);
                                                        if (info != null)
                                                        {
                                                            Gateway.DeviceList.Remove(info);
                                                        }
                                                    }
                                                }
                                                break;
                                            case DeviceType.Transverter:
                                                var transverter = new Transverter() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
                                                transverter.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<Transverter.RemoveDeviceResponseData>(jobject["Data"].ToString());
                                                if (transverter.removeDeviceResponseData == null)
                                                {
                                                    return;
                                                }
                                                else
                                                {
                                                    if (transverter.removeDeviceResponseData.Result == 0)
                                                    {
                                                        var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == transverter.DeviceID && obj.DeviceAddr == transverter.DeviceAddr && obj.DeviceEpoint == transverter.DeviceEpoint);
                                                        if (info != null)
                                                        {
                                                            Gateway.DeviceList.Remove(info);
                                                        }
                                                    }
                                                }
                                                break;
                                            case DeviceType.DoorLock:
                                                var doorLock = new DoorLock() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
                                                doorLock.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<DoorLock.RemoveDeviceResponseData>(jobject["Data"].ToString());
                                                if (doorLock.removeDeviceResponseData == null)
                                                {
                                                    return;
                                                }
                                                else
                                                {
                                                    if (doorLock.removeDeviceResponseData.Result == 0)
                                                    {
                                                        var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == doorLock.DeviceID && obj.DeviceAddr == doorLock.DeviceAddr && obj.DeviceEpoint == doorLock.DeviceEpoint);
                                                        if (info != null)
                                                        {
                                                            Gateway.DeviceList.Remove(info);
                                                        }
                                                    }
                                                }
                                                break;
                                        }
                                    }
                                }
                            }
                            catch { }
                        }
                    }
                };
@@ -2234,16 +1652,6 @@
                        {
                            d = new RemoveGatewayDeviceListAllData { removeGatewayDeviceListData = gatewayTemp.removeGatewayDeviceListData };
                            System.Console.WriteLine($"UI收到通知后的主题_{ topic}");
                            //for (int listCount = 0; listCount < Gateway.AllGatewayDeviceList.Count; listCount++)
                            //{
                            //    var dev = Gateway.AllGatewayDeviceList[listCount];
                            //    if (gatewayTemp.removeGatewayDeviceListData.GwId == dev.Gateway.CurrentGateWayId)
                            //    {
                            //        ZigBee.Device.ZbGateway.LogicList.RemoveAt(listCount);
                            //        listCount--;
                            //    }
                            //}
                        }
                    }
                };
@@ -2357,500 +1765,6 @@
            System.Console.WriteLine("Identify_Actions 退出" + System.DateTime.Now.ToString());
        }
        #endregion
        #region 设备上报返回数据,网关回复信息
        ///// <summary>
        ///// 设备上报返回数据,网关回复信息
        ///// </summary>
        //public DeviceReportResponAllData deviceReportResponAllData;
        ///// <summary>
        ///// 网关恢复出厂设置返回数据
        ///// </summary>
        //[System.Serializable]
        //public class DeviceReportResponAllData
        //{
        //    /// <summary>
        //    /// 错误信息
        //    /// </summary>
        //    public string errorMessageBase;
        //    /// <summary>
        //    /// 网关信息错误反馈
        //    /// <para>当网关接收到客户端信息后,出现以下异常情况将反馈错误。</para>
        //    /// </summary>
        //    public ErrorResponData errorResponData;
        //    ///<summary >
        //    ///设备数据
        //    /// </summary>
        //    public DeviceStatusReportData deviceStatusReportData;
        //}
        ///// <summary>
        ///// 读取报告属性配置,异步获取数据
        ///// </summary>
        ///// <param name="clusterID">Cluster identifier.</param>
        ///// <param name="attriButeId">Attri bute identifier.</param>
        //public async System.Threading.Tasks.Task<DeviceReportResponAllData> ReadAttriAsync(Cluster_ID clusterID, AttriButeId attriButeId)
        //{
        //if (Gateway == null)
        //{
        //    return null;
        //}
        ////string result = null;
        //return await System.Threading.Tasks.Task.Run(async () =>
        //{
        //var d = new DeviceReportResponAllData();
        //Action<string, string> action = (topic, message) =>
        //{
        //var gatewayID = topic.Split('/')[0];
        //var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
        //if (topic == gatewayID + "/" + "Error_Respon")
        //{
        //    var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
        //    var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString());
        //    if (temp == null)
        //    {
        //        d.errorMessageBase = "网关错误回复,且数据是空";
        //    }
        //    else
        //    {
        //        d.errorResponData = temp;
        //        d.errorMessageBase = ErrorMess(temp.Error);
        //    }
        //}
        //if (topic == gatewayID + "/" + "DeviceStatusReport" + "/" + DeviceAddr + "/" + DeviceEpoint + "/" + (int)clusterID + "/" + (int)attriButeId)
        //{
        //var deviceID = jobject.Value<int>("Device_ID");
        //var deviceAddr = jobject.Value<string>("DeviceAddr");
        //var ep = jobject.Value<int>("Epoint");
        //var device = Gateway.DeviceList.Find((obj) => obj.DeviceID == deviceID && obj.DeviceAddr == deviceAddr && obj.DeviceEpoint == ep);
        //if (device == null)
        //{
        //    return;
        //}
        //switch ((DeviceType)(deviceID))
        //{
        // case DeviceType.ColorDimmableLight:
        //    device.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<ColorDimmableLight.DeviceStatusReportData>(jobject["Data"].ToString());
        //    if (device.DeviceStatusReport == null)
        //    {
        //        d.errorMessageBase = "网关错误回复,且数据是空";
        //    }
        //    else
        //    {
        //        d.deviceStatusReportData = device.DeviceStatusReport;
        //        System.Console.WriteLine($"收到通知后的主题_{ topic}");
        //        var light = device as ColorDimmableLight;
        //        if (device.DeviceStatusReport.CluterID == 8)
        //        {
        //            var attriButeList = device.DeviceStatusReport.AttriBute;
        //            foreach (var attriBute1 in attriButeList)
        //            {
        //                light.Level = attriBute1.AttriButeData;
        //            }
        //            light.ReSave();
        //            ZigBee.Device.ZbGateway.UpdateDeviceStatus(light);
        //        }
        //        else if (device.DeviceStatusReport.CluterID == 6)
        //        {
        //            var attriButeList = device.DeviceStatusReport.AttriBute;
        //            foreach (var attriBute1 in attriButeList)
        //            {
        //                light.OnOffStatus = attriBute1.AttriButeData;
        //                var key = light.DeviceAddr + "_" + light.DeviceEpoint;
        //                Gateway.sceneTaskInfoList.Remove(key);
        //                var st = new Scene.TaskListInfo()
        //                {
        //                    TaskType = 1,
        //                    Data1 = attriBute1.AttriButeData,
        //                    Data2 = 0,
        //                };
        //                Gateway.sceneTaskInfoList.Add(key, st);
        //            }
        //            light.ReSave();
        //            ZigBee.Device.ZbGateway.UpdateDeviceStatus(light);
        //        }
        //        else if (device.DeviceStatusReport.CluterID == 768)
        //        {
        //            var attriButeList = device.DeviceStatusReport.AttriBute;
        //            //foreach (var attriBute1 in attriButeList)
        //            //{
        //            //    if (attriBute1.AttriButeId == 0)
        //            //    {
        //            //        light.Hue = attriBute1.AttriButeData.ToString();
        //            //    }
        //            //    else if ((attriBute1.AttriButeId == 1))
        //            //    {
        //            //        light.Saturation = attriBute1.AttriButeData.ToString();
        //            //    }
        //            //    else if ((attriBute1.AttriButeId == 16394))
        //            //    {
        //            //        light.ColorCapabilities = attriBute1.AttriButeData.ToString();
        //            //    }
        //            //    else if ((attriBute1.AttriButeId == 16384))
        //            //    {
        //            //        light.EnhancedCurrentHue = attriBute1.AttriButeData.ToString();
        //            //    }
        //            //}
        //            light.ReSave();
        //            ZigBee.Device.ZbGateway.UpdateDeviceStatus(light);
        //        }
        //    }
        //    break;
        // case DeviceType.OnOffSwitch:
        //    device.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.DeviceStatusReportData>(jobject["Data"].ToString());
        //    if (device.DeviceStatusReport == null)
        //    {
        //        d.errorMessageBase = "网关错误回复,且数据是空";
        //    }
        //    else
        //    {
        //        d.deviceStatusReportData = device.DeviceStatusReport;
        //        System.Console.WriteLine($"收到通知后的主题_{ topic}");
        //        var panelObj = device as Panel;
        //        foreach (var common in Gateway.DeviceList)
        //        {
        //            if (common.DeviceAddr != panelObj.DeviceAddr || common.DeviceEpoint != panelObj.DeviceEpoint)
        //            {
        //                continue;
        //            }
        //            if (common.Type == DeviceType.OnOffSwitch)
        //            {
        //                if (device.DeviceStatusReport.CluterID == 6)
        //                {
        //                    var attriButeList = device.DeviceStatusReport.AttriBute;
        //                    foreach (var attriBute1 in attriButeList)
        //                    {
        //                        panelObj.panelMode = attriBute1.AttriButeData;
        //                    }
        //                }
        //            }
        //            panelObj.ReSave();
        //            ZigBee.Device.ZbGateway.UpdateDeviceStatus(panelObj);
        //        }
        //    }
        //     break;
        //case DeviceType.OnOffOutput:
        //    device.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<ToggleLight.DeviceStatusReportData>(jobject["Data"].ToString());
        //    //if (device.DeviceStatusReport != null)
        //    //{
        //    //    result = "成功";
        //    //}
        //    if (device.DeviceStatusReport == null)
        //    {
        //        d.errorMessageBase = "网关错误回复,且数据是空";
        //    }
        //    else
        //    {
        //        d.deviceStatusReportData = device.DeviceStatusReport;
        //        System.Console.WriteLine($"收到通知后的主题_{ topic}");
        //        var lighttoggle = device as ToggleLight;
        //        foreach (var common in Gateway.DeviceList)
        //        {
        //            if (common.DeviceAddr != lighttoggle.DeviceAddr || common.DeviceEpoint != lighttoggle.DeviceEpoint)
        //            {
        //                continue;
        //            }
        //            if (common.Type == DeviceType.OnOffOutput)
        //            {
        //                if (device.DeviceStatusReport.CluterID == 6)
        //                {
        //                    var attriButeList = device.DeviceStatusReport.AttriBute;
        //                    foreach (var attriBute1 in attriButeList)
        //                    {
        //                        lighttoggle.OnOffStatus = attriBute1.AttriButeData;
        //                        System.Console.WriteLine("当前开关状态" + "_" + attriBute1.AttriButeData.ToString() + "_" + Gateway.getGatewayBaseInfo.gwID + "_" + System.DateTime.Now.ToString());
        //                    }
        //                }
        //            }
        //            lighttoggle.ReSave();
        //            ZigBee.Device.ZbGateway.UpdateDeviceStatus(lighttoggle);
        //        }
        //    }
        //      break;
        //case DeviceType.WindowCoveringDevice:
        //    device.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<Rollershade.DeviceStatusReportData>(jobject["Data"].ToString());
        //    if (device.DeviceStatusReport == null)
        //    {
        //        d.errorMessageBase = "网关错误回复,且数据是空";
        //    }
        //    else
        //    {
        //        d.deviceStatusReportData = device.DeviceStatusReport;
        //        System.Console.WriteLine($"收到通知后的主题_{ topic}");
        //        var curtain = device as Rollershade;
        //        foreach (var common in Gateway.DeviceList)
        //        {
        //            if (common.DeviceAddr != curtain.DeviceAddr || common.DeviceEpoint != curtain.DeviceEpoint)
        //            {
        //                continue;
        //            }
        //            if (common.Type == DeviceType.WindowCoveringDevice)
        //            {
        //                if (device.DeviceStatusReport.CluterID == 258)
        //                {
        //                    foreach (var attriBute1 in curtain.DeviceStatusReport.AttriBute)
        //                    {
        //                        switch (attriBute1.AttributeId)
        //                        {
        //                            case 0:
        //                                curtain.WcdType = attriBute1.AttriButeData;
        //                                System.Console.WriteLine("当前窗帘的类型" + "_" + curtain.WcdType.ToString() + "_" + Gateway.getGatewayBaseInfo.gwID + "_" + System.DateTime.Now.ToString());
        //                                break;
        //                            case 3:
        //                                curtain.WcdCurrentPositionLift = attriBute1.AttriButeData;
        //                                System.Console.WriteLine("窗帘当前高度" + "_" + curtain.WcdCurrentPositionLift.ToString() + "_" + Gateway.getGatewayBaseInfo.gwID + "_" + System.DateTime.Now.ToString());
        //                                break;
        //                            case 8:
        //                                curtain.WcdCurrentPositionLiftPercentage = attriBute1.AttriButeData;
        //                                System.Console.WriteLine("当前窗帘所在的进度(百分)位置" + "_" + curtain.WcdCurrentPositionLiftPercentage.ToString() + "_" + Gateway.getGatewayBaseInfo.gwID + "_" + System.DateTime.Now.ToString());
        //                                break;
        //                            case 16:
        //                                curtain.WcdInstalledOpenLimitLift = attriBute1.AttriButeData;
        //                                System.Console.WriteLine("窗帘全开所在的位置" + "_" + curtain.WcdInstalledOpenLimitLift.ToString() + "_" + Gateway.getGatewayBaseInfo.gwID + "_" + System.DateTime.Now.ToString());
        //                                break;
        //                            case 17:
        //                                curtain.WcdInstalledClosedLimitLift = attriBute1.AttriButeData;
        //                                System.Console.WriteLine("窗帘全关所在的位置" + "_" + curtain.WcdCurrentPositionLift.ToString() + "_" + Gateway.getGatewayBaseInfo.gwID + "_" + System.DateTime.Now.ToString());
        //                                break;
        //                            case 18:
        //                                curtain.WcdInstalledOpenLimitTilt = attriBute1.AttriButeData;
        //                                System.Console.WriteLine("窗帘全开所在的角度" + "_" + curtain.WcdCurrentPositionLift.ToString() + "_" + Gateway.getGatewayBaseInfo.gwID + "_" + System.DateTime.Now.ToString());
        //                                break;
        //                            case 19:
        //                                curtain.WcdInstalledClosedLimitTilt = attriBute1.AttriButeData;
        //                                System.Console.WriteLine("窗帘全关所在的角度" + "_" + curtain.WcdCurrentPositionLift.ToString() + "_" + Gateway.getGatewayBaseInfo.gwID + "_" + System.DateTime.Now.ToString());
        //                                break;
        //                            case 23:
        //                                curtain.WcdCurrentMode = attriBute1.AttriButeData;
        //                                System.Console.WriteLine("窗帘当前模式" + "_" + curtain.WcdCurrentMode.ToString() + "_" + Gateway.getGatewayBaseInfo.gwID + "_" + System.DateTime.Now.ToString());
        //                                break;
        //                            default:
        //                                break;
        //                        }
        //                    }
        //                    curtain.ReSave();
        //                    ZigBee.Device.ZbGateway.UpdateDeviceStatus(curtain);
        //                }
        //            }
        //        }
        //    }
        //    break;
        //case DeviceType.IASZone:
        //device.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<IASZone.DeviceStatusReportData>(jobject["Data"].ToString());
        //var ias = device as IASZone;
        //foreach (var common in Gateway.DeviceList)
        //{
        //    if (common.DeviceAddr != ias.DeviceAddr || common.DeviceEpoint != ias.DeviceEpoint)
        //    {
        //        continue;
        //    }
        //    if (common.Type == DeviceType.IASZone)
        //    {
        //        ias.ReSave();
        //        ZigBee.Device.ZbGateway.UpdateDeviceStatus(ias);
        //    }
        //}
        //ias.ReSave();
        //break;
        //case DeviceType.Thermostat:
        //device.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<ThermostatObj.DeviceStatusReportData>(jobject["Data"].ToString());
        //var ther = device as ThermostatObj;
        //if (ther.DeviceStatusReport.CluterID == 514)
        //{
        //    foreach (var attriBute1 in ther.DeviceStatusReport.AttriBute)
        //    {
        //        if (attriBute1.AttributeId == 0)
        //        {
        //            ther.CurentFanControlMode = attriBute1.AttriButeData;
        //        }
        //    }
        //}
        //if (ther.DeviceStatusReport.CluterID == 513)
        //{
        //    foreach (var attriBute1 in ther.DeviceStatusReport.AttriBute)
        //    {
        //        if (attriBute1.AttributeId == 0)
        //        {
        //            ther.LocalThermostat = attriBute1.AttriButeData / 100;
        //        }
        //        else if (attriBute1.AttributeId == 17)
        //        {
        //            ther.CurentCoolingSetpoint = attriBute1.AttriButeData / 100;
        //        }
        //        else if (attriBute1.AttributeId == 18)
        //        {
        //            ther.CurentHeatingSetpoint = attriBute1.AttriButeData / 100;
        //        }
        //        else if (attriBute1.AttributeId == 28)
        //        {
        //            ther.CurentSystemMode = attriBute1.AttriButeData;
        //        }
        //    }
        //}
        //ZigBee.Device.ZbGateway.UpdateDeviceStatus(ther);
        //break;
        //case DeviceType.TemperatureSensor:
        //var sensor = new TemperatureSensor() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId };
        //sensor.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<TemperatureSensor.DeviceStatusReportData>(jobject["Data"].ToString());
        //ZigBee.Device.ZbGateway.UpdateDeviceStatus(sensor);
        //if (sensor.DeviceStatusReport.CluterID == 1026)
        //{
        //    foreach (var attriBute1 in sensor.DeviceStatusReport.AttriBute)
        //    {
        //        if (attriBute1.AttributeId == 0)
        //        {
        //            sensor.CurentTemperature = attriBute1.AttriButeData;
        //        }
        //        else if (attriBute1.AttributeId == 1)
        //        {
        //            sensor.MaxTemperature = attriBute1.AttriButeData;
        //        }
        //        else if (attriBute1.AttributeId == 2)
        //        {
        //            sensor.MinTemperature = attriBute1.AttriButeData;
        //        }
        //        else if (attriBute1.AttributeId == 3)
        //        {
        //            sensor.TorleranceTemperature = attriBute1.AttriButeData;
        //        }
        //        IO.LocalFileUtils.SaveDeviceInfo(sensor, sensor.DeviceEpoint.ToString());
        //    }
        //}
        //else if (sensor.DeviceStatusReport.CluterID == 1029)
        //{
        //    foreach (var attriBute1 in sensor.DeviceStatusReport.AttriBute)
        //    {
        //        if (attriBute1.AttributeId == 0)
        //        {
        //            sensor.CurentHumidity = attriBute1.AttriButeData;
        //        }
        //        else if (attriBute1.AttributeId == 1)
        //        {
        //            sensor.MaxHumidity = attriBute1.AttriButeData;
        //        }
        //        else if (attriBute1.AttributeId == 2)
        //        {
        //            sensor.MinHumidity = attriBute1.AttriButeData;
        //        }
        //        else if (attriBute1.AttributeId == 3)
        //        {
        //            sensor.ToleranceHumidity = attriBute1.AttriButeData;
        //        }
        //        IO.LocalFileUtils.SaveDeviceInfo(sensor, sensor.DeviceEpoint.ToString());
        //    }
        //}
        //var sen = Gateway.SensorInfoList.Find(obj => obj.DeviceAddr == sensor.DeviceAddr && obj.DeviceEpoint == sensor.DeviceEpoint);
        //if (sen == null)
        //{
        //    Gateway.SensorInfoList.Add(sensor);
        //}
        //else
        //{
        //    if (sensor.DeviceStatusReport.CluterID == 1026)
        //    {
        //        foreach (var attriBute1 in sensor.DeviceStatusReport.AttriBute)
        //        {
        //            if (attriBute1.AttributeId == 0)
        //            {
        //                sen.CurentTemperature = attriBute1.AttriButeData;
        //            }
        //            else if (attriBute1.AttributeId == 1)
        //            {
        //                sen.MaxTemperature = attriBute1.AttriButeData;
        //            }
        //            else if (attriBute1.AttributeId == 2)
        //            {
        //                sen.MinTemperature = attriBute1.AttriButeData;
        //            }
        //            else if (attriBute1.AttributeId == 3)
        //            {
        //                sen.TorleranceTemperature = attriBute1.AttriButeData;
        //            }
        //            IO.LocalFileUtils.SaveDeviceInfo(sensor, sensor.DeviceEpoint.ToString());
        //        }
        //    }
        //    else if (sensor.DeviceStatusReport.CluterID == 1029)
        //    {
        //        foreach (var attriBute1 in sensor.DeviceStatusReport.AttriBute)
        //        {
        //            if (attriBute1.AttributeId == 0)
        //            {
        //                sen.CurentHumidity = attriBute1.AttriButeData;
        //            }
        //            else if (attriBute1.AttributeId == 1)
        //            {
        //                sen.MaxHumidity = attriBute1.AttriButeData;
        //            }
        //            else if (attriBute1.AttributeId == 2)
        //            {
        //                sen.MinHumidity = attriBute1.AttriButeData;
        //            }
        //            else if (attriBute1.AttributeId == 3)
        //            {
        //                sen.ToleranceHumidity = attriBute1.AttriButeData;
        //            }
        //            IO.LocalFileUtils.SaveDeviceInfo(sensor, sensor.DeviceEpoint.ToString());
        //        }
        //    }
        //}
        //break;
        //                }
        //            }
        //        };
        //        Gateway.Actions += action;
        //        var JObject = new JObject {
        //        { "DeviceAddr",DeviceAddr },
        //        { "Epoint", DeviceEpoint },
        //        { "Cluster_ID", (int)clusterID },
        //        { "Command", 108 }
        //    };
        //        var attriBute = new JArray{
        //          new JObject {
        //            { "AttriButeId", (int)attriButeId}
        //           }
        //    };
        //        var data = new JObject { { "AttriBute", attriBute } };
        //        JObject.Add("Data", data);
        //        Gateway?.Send(("GetDeviceStatus"), Common.SecuritySet.Encryption((JObject.ToString())));
        //        var dateTime = DateTime.Now;
        //        while ((DateTime.Now - dateTime).TotalMilliseconds < 5000)
        //        {
        //            await System.Threading.Tasks.Task.Delay(10);
        //            if (d.deviceStatusReportData != null)
        //            {
        //                break;
        //            }
        //        }
        //        if ((DateTime.Now - dateTime).TotalMilliseconds > 10000)
        //        {
        //            d.errorMessageBase = " 回复超时,请重新操作";
        //        }
        //        Gateway.Actions -= action;
        //        return d;
        //    });
        //}
        #endregion
        #region 设备属性状态上报
@@ -3757,37 +2671,6 @@
        #endregion
        #region 启用或关闭节点设备透传数据上传接口
        /// <summary>
        /// 节点设备透传数据到客户端
        /// <para>网关程序默认是关闭透传数据上传的,可以通过以下指令开启透传数据上传。透传数据上传开启后,重启网关程序透传数据上传将还原成关闭状态</para>
        /// <para>isOn 0:关闭透传数据上传</para>
        /// <para>isOn 1:开启透传数据上传</para>
        /// </summary>
        //public void OpenPassthroughControl(ZigBee.Device.ZbGateway gateway, int isOn = 1)
        //{
        //    if (Gateway == null)
        //    {
        //        return;
        //    }
        //    Action<string, string> action = (topic, message) => { };
        //    Gateway.Actions += action;
        //    System.Console.WriteLine("OnZbDataPassthrough_Actions 启动" + "_" + System.DateTime.Now.ToString());
        //    try
        //    {
        //        var jObject = new JObject { { "Cluster_ID", 64513 }, { "Command", 1 } };
        //        var data = new JObject { { "IsOn", isOn } };
        //        jObject.Add("Data", data);
        //        gateway.Send(("OnZbDataPassthrough"), jObject.ToString());
        //    }
        //    catch { }
        //    Gateway.Actions -= action;
        //    System.Console.WriteLine("OnZbDataPassthrough_Actions 退出" + System.DateTime.Now.ToString());
        //}
        #endregion
        #region 客户端向节点设备透传数据.
        /// <summary>
        /// 客户端向节点设备透传数据
@@ -4267,7 +3150,7 @@
            /// <summary>
            ///响应操作码(0-ffff)
            /// </summary>
            public int command = -1;
            public string command;
            /// <summary>
            /// 状态值
            /// <para>0--成功 1--失败 ff--无效</para>