HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
2020-04-13 3793a9a38ac6c4c4111c2bba3a35a71c30601e82
ZigbeeApp/Shared/Phone/ZigBee/Device/CommonDevice.cs
@@ -174,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;
        }
@@ -230,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)
                {
@@ -1280,216 +1294,7 @@
                    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;
                        }
                        d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<ToggleLight.RenameDeviceMacNameData>(jobject["Data"].ToString()) };
                    }
                };
                Gateway.Actions += action;
@@ -1847,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--;
                            //    }
                            //}
                        }
                    }
                };
@@ -1970,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 设备属性状态上报
@@ -3368,37 +2669,6 @@
            public List<OTADeviceList> DeviceList = new List<OTADeviceList>();
        }
        #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 客户端向节点设备透传数据.