$.root_ = $('body');
$.left_panel = $('#left-panel');

/**
 * 设备能力,通道号等获取
 */
function getDeviceCap() {
    var deviceCap = [];
    $.ajax({
        type: "get",
        url: config.baseUrl + '/System/DeviceCap',
        dataType: 'XML',
        async: false,
        timeout: 15000,
        beforeSend: function(xhr) {
            xhr.setRequestHeader("If-Modified-Since", "0");
        },
        success: function(xmlDoc) {
            // 先要判断是否是多目设备是的话走多通道的能力逻辑否则原先是啥就是啥
            if ($(xmlDoc).find("MultiChannelCap").eq(0).text()) {
                config.isSupportMultiChannel = JSON.parse($(xmlDoc).find("MultiChannelCap").eq(0).text().toLowerCase());
            } else {
                config.isSupportMultiChannel = false;
            }
            // var isSupportMultiChannel=true;
            if (config.isSupportMultiChannel == true) { //表示此时是多通道设备能力存在多个通道
                var Capscounts = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").size(); //表示此时有几个节点通道
                for (var o = 0; o < Capscounts; o++) {
                    var deviceCaps = {};
                    deviceCaps.StreamCount = $(xmlDoc).find("StreamCount").eq(0).text(); //支持的码流个数
                    deviceCaps.StreamCount = deviceCaps.StreamCount || 2;
                    deviceCaps.LPRSpeed=$(xmlDoc).find('Device').eq(0).find('FunctionList').eq(0).find('LPR').eq(0).find('Speed').eq(0).find('Support').eq(0).text();
                    deviceCaps.LPRSpeedMin=$(xmlDoc).find('Device').eq(0).find('FunctionList').eq(0).find('LPR').eq(0).find('Speed').eq(0).find('Min').eq(0).text();
                    deviceCaps.LPRSpeedMax=$(xmlDoc).find('Device').eq(0).find('FunctionList').eq(0).find('LPR').eq(0).find('Speed').eq(0).find('Max').eq(0).text();
                    deviceCaps.DevieceSIPPort = $(xmlDoc).find("DeviceSIPPort").eq(0).text().toLowerCase(); //设备SIP端口
                    deviceCaps.FourGsupport = $(xmlDoc).find("_4G").eq(0).text(); //支持4G
                    deviceCaps.CarDetect = $(xmlDoc).find("CarDetect").find("Support").text().toLowerCase(); //叠加人形
                    deviceCaps.Human = $(xmlDoc).find("AIOverlay").find("Human").text().toLowerCase(); //叠加人形
                    deviceCaps.Face = $(xmlDoc).find("AIOverlay").find("Face").text().toLowerCase(); //叠加人脸
                    deviceCaps.PolygonRegion = $(xmlDoc).find("AIOverlay").find("PolygonRegion").text().toLowerCase(); //叠加布防
                    deviceCaps.TraverseLine = $(xmlDoc).find("AIOverlay").find("TraverseLine").text().toLowerCase(); //叠加绊线
                    deviceCaps.Car = $(xmlDoc).find("AIOverlay").find("Car").text().toLowerCase(); //叠加绊线
                    deviceCaps.allOverlying = $(xmlDoc).find("AIOverlay").find("AllStreamUnity").text().toLowerCase(); //控制整个主子码流的叠加
                    deviceCaps.isSupportPolygonRegion = $(xmlDoc).find("DetectRegion").find("PolygonRegion").find("Support").text().toLowerCase(); //是否支持多边行(因为会和nvr冲突所以不能用此字段代表智能警戒能力)
                    deviceCaps.AudioAlarmType = $(xmlDoc).find("AudioAlarmType").eq(0);
                    deviceCaps.ydzcAudioAlarmType = $(xmlDoc).find("MotionAlarmType").eq(0); //移动侦测
                    deviceCaps.bjsrAudioAlarmType = $(xmlDoc).find("AudioAlarmIn").eq(0); //报警输入
                    deviceCaps.AudioAlarmVoiceType = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find("AudioAlarmIn").eq(0).find('AudioType').eq(0); //报警输入生意类型
                    deviceCaps.CarAudioAlarmType = $(xmlDoc).find("CarAudioAlarmType").eq(0);
                    // deviceCap.FaceSnapshot = $(xmlDoc).find('Device').eq(0).find("FaceFunction").eq(0).find("FaceSnapshot").eq(0).text(); //抓拍
                    deviceCaps.FaceSnapshot = $(xmlDoc).find('Device').eq(0).find("FunctionListAboutChannel").eq(0).find('ChannelList').eq(0).find('Channel').eq(o).find("FaceSnap").eq(0).text(); //抓拍
                    deviceCaps.maskDetectSupport = $(xmlDoc).find('Device').eq(0).find("FunctionListAboutChannel").eq(0).find('ChannelList').eq(0).find('Channel').eq(o).find("MaskDetect").eq(0).find('support').eq(0).find('Support').eq(0).text().toLowerCase();
                    // deviceCap.IsFaceReco = $(xmlDoc).find('FaceFunction').eq(0).find('FaceReco').text().toLowerCase(); //识别
                    deviceCaps.IsFaceReco = $(xmlDoc).find('Device').eq(0).find("FunctionListAboutChannel").eq(0).find('ChannelList').eq(0).find('Channel').eq(o).find("FaceReco").eq(0).text(); //识别
                    //新脸库配置与人员管理，填1表示T5AI现在的配置界面
                    deviceCaps.FaceLibConfig = $(xmlDoc).find('Device').eq(0).find("FunctionListAboutChannel").eq(0).find('ChannelList').eq(0).find('Channel').eq(o).find("FaceLibConfig").eq(0).text();

                    deviceCaps.IsFaceLibConfig = $(xmlDoc).find('FaceFunction').eq(0).find('FaceLibConfig').text().toLowerCase(); //t5ai新加脸库能力，，有这个能力代表不支持入库
                    //灯光报警联动
                    deviceCaps.LightAlarm = $(xmlDoc).find('Device').eq(0).find("LightAlarm").eq(0).find("Support").eq(0).text();
                    //声音报警
                    deviceCaps.AudioAlarm = $(xmlDoc).find('Device').eq(0).find("AudioAlarm").eq(0).text();
                    //wifi
                    deviceCaps.wifiEnable = $(xmlDoc).find('WIFI').text().toLowerCase(); //是否支持wifi
                    //SD
                    deviceCaps.diskEnable = $(xmlDoc).find('SD').text().toLowerCase(); //是否支持SD卡//磁盘信息与录像配置
                    deviceCaps.PlaybackSpeed = $(xmlDoc).find('PlaybackSpeed').eq(0).find('Support').text().toLowerCase();
                    deviceCaps.Max = parseInt($(xmlDoc).find('PlaybackSpeed').eq(0).find('Max').text().toLowerCase());
                    //宽动态能力
                    deviceCaps.wdrClose = $(xmlDoc).find('Device').eq(0).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find("WDR").eq(0).find("Close").eq(0).text();
                    // 人脸检测
                    deviceCaps.FacedetectIn = $(xmlDoc).find('FaceFunction').eq(0).find("FaceSnapConfig").eq(0).text();
                    // 脸库管理
                    deviceCaps.FaceKuoutIn = $(xmlDoc).find('FaceFunction').eq(0).find("FaceLibConfig").eq(0).text();
                    //email联动
                    deviceCaps.Email = $(xmlDoc).find('Device').eq(0).find("FunctionList").eq(0).find("Email").eq(0).text();
                    //Ftp联动
                    deviceCaps.Ftp = $(xmlDoc).find('Device').eq(0).find("FunctionList").eq(0).find("FTP").eq(0).text();
                    //去雾
                    deviceCaps.Defrog = $(xmlDoc).find('Device').eq(0).find("FunctionList").eq(0).find("Defrog").eq(0).find('Support').text();
                    deviceCaps.isSupportComplexd = $(xmlDoc).find("RejectEmptyPassword").find("Complex").text().toLowerCase();
                    deviceCaps.isSupportEmptyPassword = $(xmlDoc).find("RejectEmptyPassword").find("Support").text().toLowerCase();
                    //新增抗闪强度
                    deviceCaps.PowerLineFrequency = $(xmlDoc).find('Device').eq(0).find('FunctionList').eq(0).find('PowerLineFrequencyStrength').eq(0).find('Support').text();
                    //抗闪模式
                    deviceCaps.AntiFlicker = $(xmlDoc).find('Device').eq(0).find('FunctionList').eq(0).find('AntiFlickerMode').eq(0).find('Support').text();
                    //图像模式
                    deviceCaps.imageMode = $(xmlDoc).find('Device').eq(0).find('FunctionListAboutChannel').eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find('ImageMode ').attr("enable");
                    deviceCaps.normalMode = $(xmlDoc).find('Device').eq(0).find('FunctionListAboutChannel').eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find('Normal').text();
                    deviceCaps.faceMode = $(xmlDoc).find('Device').eq(0).find('FunctionListAboutChannel').eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find('FaceNoExposure').text();
                    deviceCaps.licenseMode = $(xmlDoc).find('Device').eq(0).find('FunctionListAboutChannel').eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find('LicensePlate').text();

                    //osd配置
                    //是否支持多行osd
                    deviceCaps.osdTag = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find("multi_osd").text();
                    //是否叠加osd的附加信息
                    deviceCaps.osdShowd = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find("OverlayCodecParam").eq(0).find("Support").text();
                    //老能力 osd1支持多少行
                    deviceCaps.osdline = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find("mosd_line_every_osd").text();
                    //每行osd1每行支持长度
                    deviceCap.osdchar = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find("mosd_char_count_every_line").text();
                    // osd2 新增的能力
                    deviceCaps.osd2support = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find("mosd_cntv2").eq(0).find("Support").text(); //是否支持新的osd能力协议
                    deviceCaps.osd2maxcnt = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find("mosd_cntv2").eq(0).find("max_cnt").text(); //是否支持osd2，max_cnt为1表示只取到osd1，不显示osd2
                    if (deviceCaps.osd2support == 'true') {
                        //支持osd1 总共支持多少行
                        deviceCaps.osdline = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find("osd1").eq(0).find("max_line").text();
                        //osd1 单行支持最大字符个数
                        deviceCaps.osdchar = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find("osd1").eq(0).find("max_line_char").text();
                        //支持osd1 总字符长度
                        deviceCaps.osd1linechar = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find("osd1").eq(0).find("max_char").text()
                            //osd2
                            //osd2总长度
                        deviceCaps.odTwo = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find("osd2").eq(0).find("max_char").text();
                        //osd2单行长度
                        deviceCaps.odTwol = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find("osd2").eq(0).find("max_line_char").text();
                        //osd2支持多少行
                        deviceCaps.osdTwoline = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find("osd2").eq(0).find("max_line").text();
                    }
                    deviceCaps.G711u = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find("AudioCodec").eq(0).find("G711u").eq(0).text();
                    deviceCaps.G711a = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find("AudioCodec").eq(0).find("G711a").eq(0).text();
                    deviceCaps.AAC = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find("AudioCodec").eq(0).find("AAC").eq(0).text();
                    deviceCaps.G726 = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find("AudioCodec").eq(0).find("G726").eq(0).text();
                    //移动侦测
                    deviceCaps.isMotion = $(xmlDoc).find('Motion').eq(0).find("Support").text();
                    deviceCaps.isMotionTow = $(xmlDoc).find('FunctionListAboutChannel').eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find('Motion').eq(0).text();
                    //隐私遮盖
                    deviceCaps.isPrivacyZone = $(xmlDoc).find('PrivacyZone').eq(0).find("Support").text();
                    //是否支持邮箱 FTP GB28181
                    deviceCaps.IsSupportEmail = $(xmlDoc).find('Email').eq(0).text();
                    deviceCaps.IsSupportFTP = $(xmlDoc).find('FTP').eq(0).text();
                    deviceCaps.IsSupportGB28181 = $(xmlDoc).find('Protocol').eq(0).find("GB28181").find("Support").text();
                    deviceCaps.IsSupportThirdParty = $(xmlDoc).find('Protocol').eq(0).find("ThirdParty").eq(0).find("Support").eq(0).text(); //是否支持第三方协议
                    deviceCaps.HKProtocol = $(xmlDoc).find('Protocol').eq(0).find("ThirdParty").find("HK").find("Support").text(); ///没有此项表示支持HK协议 // true表示支持HK协议,false表示不支持
                    deviceCaps.OnvifProtocol = $(xmlDoc).find('Protocol').eq(0).find("ThirdParty").find("Onvif").find("Support").text(); ///没有此项表示支持 // true表示支持,false表示不支持
                    deviceCaps.AuthConfig = $(xmlDoc).find('Protocol').eq(0).find("ThirdParty").find("Onvif").find("AuthConfig").text(); ///没有此项表示支持 // true表示支持,false表示不支持
                    deviceCaps.isSupportLightCapability = $(xmlDoc).find('Device').eq(0).find('LightCapability').eq(0).find('Support').text(); //是否支持新灯板能力
                    //非新灯板下的能力
                    deviceCaps.colorMode = $(xmlDoc).find('Device').eq(0).find('FunctionListAboutChannel').eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find('ColorNight').text();
                    deviceCaps.intelligentMode = $(xmlDoc).find('Device').eq(0).find('FunctionListAboutChannel').eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find('IntelligentNight').text();
                    deviceCaps.variableInfrared = $(xmlDoc).find('Device').eq(0).find('FunctionListAboutChannel').eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find('VariableInfrared').text();
                    deviceCaps.variableWhite = $(xmlDoc).find('Device').eq(0).find('FunctionListAboutChannel').eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find('VariableWhite').text();
                    deviceCaps.NormalInfrared = $(xmlDoc).find('Device').eq(0).find('FunctionListAboutChannel').eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find('NormalInfrared').text();
                    deviceCaps.normalWhite = $(xmlDoc).find('Device').eq(0).find('FunctionListAboutChannel').eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find('NormalWhite').text(); //普通红外
                    deviceCaps.AlarmInCount = $(xmlDoc).find('Device').eq(0).find('AlarmInCount').text(); //报警输入个数
                    deviceCaps.cruiseEnable = $(xmlDoc).find('Device').eq(0).find('FunctionListAboutChannel').eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find('PTZ_Advance_Cruise').text();
                    //移动侦测联动如下：：：：
                    //移动侦测联动 灯光报警
                    deviceCaps.motionLight = $(xmlDoc).find('Device').eq(0).find('FunctionListAboutChannel').eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find('MotionLinkageFunction').eq(0).find('Light').text();
                    //移动侦测联动 推送
                    deviceCaps.motionPush = $(xmlDoc).find('Device').eq(0).find('FunctionListAboutChannel').eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find('MotionLinkageFunction').eq(0).find('Push').text();
                    //移动侦测联动 声音报警
                    deviceCaps.motionAudio = $(xmlDoc).find('Device').eq(0).find('FunctionListAboutChannel').eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find('MotionLinkageFunction').eq(0).find('Audio').text();
                    //移动侦测联动 FTP
                    deviceCaps.motionFtp = $(xmlDoc).find('Device').eq(0).find('FunctionListAboutChannel').eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find('MotionLinkageFunction').eq(0).find('FTP').text();
                    //移动侦测联动 报警输出
                    deviceCaps.motionAlarmOut = $(xmlDoc).find('Device').eq(0).find('FunctionListAboutChannel').eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find('MotionLinkageFunction').eq(0).find('AlarmOut').text();
                    //移动侦测联动 邮件
                    deviceCaps.motionEmail = $(xmlDoc).find('Device').eq(0).find('FunctionListAboutChannel').eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find('MotionLinkageFunction').eq(0).find('Email').text();
                    // deviceCap.motionSD = $(xmlDoc).find('Device').eq(0).find('MotionLinkageFunction').eq(0).find('SD').text();
                    //配置项目 ddns
                    deviceCaps.ddns = $(xmlDoc).find('Device').eq(0).find("FunctionList").eq(0).find('WebUI').eq(0).find('Network').eq(0).find('DDNS').eq(0).text();
                    //侧边栏 人形检测
                    deviceCaps.HumanShape = $(xmlDoc).find('Device').eq(0).find("HumanShape").eq(0).find("Support").text().toLowerCase();
                    deviceCaps.HumanShapeTow = $(xmlDoc).find('Device').eq(0).find('FunctionListAboutChannel').eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find("SmartEvent").eq(0).find("PeopleDetect").text().toLowerCase();
                    deviceCaps.cloudUpgrade = $(xmlDoc).find('Device').eq(0).find("cloud_upgrade").eq(0).text().toLowerCase();
                    //StorageCapacity为false时 隐藏sd卡容量信息
                    deviceCaps.StorageCapacity = $(xmlDoc).find('Device').eq(0).find("AppUI").eq(0).find('StorageCapacity').text().toLowerCase();
                    // 是否支持车牌抓拍
                    deviceCaps.carSupport = $(xmlDoc).find('Device').eq(0).find("LPR").eq(0).find('Support').text().toLowerCase();

                    // 自适应IP
                    deviceCaps.AutoIP = $(xmlDoc).find("AutoIP").eq(0).text();
                    // 主动注册
                    deviceCaps.ActiveResgist = $(xmlDoc).find('Device').eq(0).find("CenterServer").eq(0).find('AutoRegister').text().toLowerCase();
                    // 报警联动
                    deviceCaps.AlarmLinkage = $(xmlDoc).eq(0).find('FunctionListAboutChannel').eq(0).find("ChannelList").eq(0).find("Channel").eq(o).find("FaceRecognition").eq(0).find('AlarmLinkage').eq(0).find('support').text().toLowerCase();
                    // HTTP
                    deviceCaps.HttpContrl = $(xmlDoc).find("HTTPPush").text().toLowerCase();
                    // MQTT
                    deviceCaps.MqttContrl = $(xmlDoc).find("MQTT").text().toLowerCase();
                    // 定时抓图
                    deviceCaps.TimeSnapshot = $(xmlDoc).find("TimeSnapshot").text().toLowerCase();
                    // 是否支持miaoyue地锁车位配置
                    deviceCaps.lockConfig = $(xmlDoc).find("CarPark").find("Support").text().toLowerCase();
                    // miaoyue车位个数
                    deviceCaps.lockNumber = $(xmlDoc).find("CarPark").find("Number").text();
                    // 调试信息
                    deviceCaps.debug = $(xmlDoc).find("CarPark").find("Debug").text().toLowerCase();
                    // 车形框
                    deviceCaps.carFrame = $(xmlDoc).find("CarPark").find("Car").text().toLowerCase();
                    // 车牌框
                    deviceCaps.cartPlateframe = $(xmlDoc).find("CarPark").find("LicensePlate").text().toLowerCase();
                    // 布防框
                    deviceCaps.defenseFrame = $(xmlDoc).find("CarPark").find("DetectArea").text().toLowerCase();
                    // 自定义语音
                    deviceCaps.enableG711U = $(xmlDoc).find("VoiceCustomAttr").find("G711U").find("Support").text().toLowerCase();
                    deviceCaps.MaxSample = $(xmlDoc).find("VoiceCustomAttr").find("G711U").find("MaxSample").text();
                    deviceCaps.MinSample = $(xmlDoc).find("VoiceCustomAttr").find("G711U").find("MinSample").text();
                    config.Sample=deviceCaps.MinSample;
                    deviceCaps.MaxLength = $(xmlDoc).find("VoiceCustomAttr").find("G711U").find("MaxLength").text();
                    config.maxTotal=deviceCaps.MaxLength*1024;
                    // 是否推送人脸特征
                    deviceCaps.FaceFeaturesPush =$(xmlDoc).find("FunctionListAboutChannel").find("FaceFeaturesPush").eq(0).text();
                    // 是否支持有线
                    deviceCaps.WiredNetwork = $(xmlDoc).find("WiredNetwork").eq(0).text();
                    // 是否支持灯光页面
                    deviceCaps.isSupportLightpage = $(xmlDoc).find('Device').eq(0).find('LightCapability').eq(0).find('HideLightPage').text();
                    deviceCaps.FourGnumber = $(xmlDoc).find("_4GConfig").eq(0).find("CardNumber").text(); //支持4G卡的数量
                    // 推送间隔是否支持1-9秒
                    deviceCaps.allowonetonine =$(xmlDoc).find('Device').eq(0).find("LPR").eq(0).find('PushInterval').text();
                    deviceCap.push(deviceCaps);
                }
            } else {
                var deviceCaps = {};
                deviceCaps.StreamCount = $(xmlDoc).find("StreamCount").eq(0).text(); //支持的码流个数
                deviceCaps.StreamCount = deviceCaps.StreamCount || 2;
                deviceCaps.LPRSpeed=$(xmlDoc).find('Device').eq(0).find('FunctionList').eq(0).find('LPR').eq(0).find('Speed').eq(0).find('Support').eq(0).text();
                deviceCaps.LPRSpeedMin=$(xmlDoc).find('Device').eq(0).find('FunctionList').eq(0).find('LPR').eq(0).find('Speed').eq(0).find('Min').eq(0).text();
                deviceCaps.LPRSpeedMax=$(xmlDoc).find('Device').eq(0).find('FunctionList').eq(0).find('LPR').eq(0).find('Speed').eq(0).find('Max').eq(0).text();
                deviceCaps.FourGsupport = $(xmlDoc).find("_4G").eq(0).text(); //支持4G
                deviceCaps.DevieceSIPPort = $(xmlDoc).find("DeviceSIPPort").eq(0).text().toLowerCase(); //设备SIP端口
                deviceCaps.CarDetect = $(xmlDoc).find("CarDetect").find("Support").text().toLowerCase(); //叠加人形
                deviceCaps.Human = $(xmlDoc).find("AIOverlay").find("Human").text().toLowerCase(); //叠加人形
                deviceCaps.Face = $(xmlDoc).find("AIOverlay").find("Face").text().toLowerCase(); //叠加人脸
                deviceCaps.PolygonRegion = $(xmlDoc).find("AIOverlay").find("PolygonRegion").text().toLowerCase(); //叠加布防
                deviceCaps.TraverseLine = $(xmlDoc).find("AIOverlay").find("TraverseLine").text().toLowerCase(); //叠加绊线
                deviceCaps.Car = $(xmlDoc).find("AIOverlay").find("Car").text().toLowerCase(); //叠加绊线
                deviceCaps.allOverlying = $(xmlDoc).find("AIOverlay").find("AllStreamUnity").text().toLowerCase(); //控制整个主子码流的叠加
                deviceCaps.isSupportPolygonRegion = $(xmlDoc).find("DetectRegion").find("PolygonRegion").find("Support").text().toLowerCase(); //是否支持多边行(因为会和nvr冲突所以不能用此字段代表智能警戒能力)
                deviceCaps.AudioAlarmType = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(0).find("AudioAlarmType").eq(0);
                deviceCaps.ydzcAudioAlarmType = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(0).find("MotionAlarmType").eq(0); //移动侦测
                deviceCaps.bjsrAudioAlarmType = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(0).find("AudioAlarmIn").eq(0); //报警输入
                deviceCaps.AudioAlarmVoiceType = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(0).find("AudioAlarmIn").eq(0).find('AudioType').eq(0); //报警输入
                deviceCaps.CarAudioAlarmType = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(0).find("CarAudioAlarmType").eq(0);
                // deviceCap.FaceSnapshot = $(xmlDoc).find('Device').eq(0).find("FaceFunction").eq(0).find("FaceSnapshot").eq(0).text(); //抓拍
                deviceCaps.FaceSnapshot = $(xmlDoc).find('Device').eq(0).find("FunctionListAboutChannel").eq(0).find('ChannelList').eq(0).find('Channel').eq(0).find("FaceSnap").eq(0).text(); //抓拍
                // deviceCap.IsFaceReco = $(xmlDoc).find('FaceFunction').eq(0).find('FaceReco').text().toLowerCase(); //识别
                deviceCaps.IsFaceReco = $(xmlDoc).find('Device').eq(0).find("FunctionListAboutChannel").eq(0).find('ChannelList').eq(0).find('Channel').eq(0).find("FaceReco").eq(0).text(); //识别
                deviceCaps.maskDetectSupport = $(xmlDoc).find('Device').eq(0).find("FunctionListAboutChannel").eq(0).find('ChannelList').eq(0).find('Channel').eq(0).find("MaskDetect").eq(0).find('Support').eq(0).text().toLowerCase(); //口罩
                //新脸库配置与人员管理，填1表示T5AI现在的配置界面
                deviceCaps.FaceLibConfig = $(xmlDoc).find('Device').eq(0).find("FunctionListAboutChannel").eq(0).find('ChannelList').eq(0).find('Channel').eq(0).find("FaceLibConfig").eq(0).text();

                deviceCaps.IsFaceLibConfig = $(xmlDoc).find('FaceFunction').eq(0).find('FaceLibConfig').text().toLowerCase(); //t5ai新加脸库能力，，有这个能力代表不支持入库
                //灯光报警联动
                deviceCaps.LightAlarm = $(xmlDoc).find('Device').eq(0).find("LightAlarm").eq(0).find("Support").eq(0).text();
                //声音报警
                deviceCaps.AudioAlarm = $(xmlDoc).find('Device').eq(0).find("AudioAlarm").eq(0).text();
                //wifi
                deviceCaps.wifiEnable = $(xmlDoc).find('WIFI').text().toLowerCase(); //是否支持wifi
                //SD
                deviceCaps.diskEnable = $(xmlDoc).find('SD').text().toLowerCase(); //是否支持SD卡//磁盘信息与录像配置
                deviceCaps.PlaybackSpeed = $(xmlDoc).find('PlaybackSpeed').eq(0).find('Support').text().toLowerCase();
                deviceCaps.Max = parseInt($(xmlDoc).find('PlaybackSpeed').eq(0).find('Max').text().toLowerCase());
                //宽动态能力
                deviceCaps.wdrClose = $(xmlDoc).find('Device').eq(0).find("WDR").eq(0).find("Close").eq(0).text();
                // 人脸检测
                deviceCaps.FacedetectIn = $(xmlDoc).find("FunctionListAboutChannel").find('FaceFunction').eq(0).find("FaceSnapConfig").eq(0).text();
                // 脸库管理
                deviceCaps.FaceKuoutIn = $(xmlDoc).find("FunctionListAboutChannel").find('FaceFunction').eq(0).find("FaceLibConfig").eq(0).text();
                //email联动
                deviceCaps.Email = $(xmlDoc).find('Device').eq(0).find("FunctionList").eq(0).find("Email").eq(0).text();
                //Ftp联动
                deviceCaps.Ftp = $(xmlDoc).find('Device').eq(0).find("FunctionList").eq(0).find("FTP").eq(0).text();
                //去雾
                deviceCaps.Defrog = $(xmlDoc).find('Device').eq(0).find("FunctionList").eq(0).find("Defrog").eq(0).find('Support').text();
                deviceCaps.isSupportComplexd = $(xmlDoc).find("RejectEmptyPassword").find("Complex").text().toLowerCase();
                deviceCaps.isSupportEmptyPassword = $(xmlDoc).find("RejectEmptyPassword").find("Support").text().toLowerCase();
                //新增抗闪强度
                deviceCaps.PowerLineFrequency = $(xmlDoc).find('Device').eq(0).find('FunctionList').eq(0).find('PowerLineFrequencyStrength').eq(0).find('Support').text();
                //抗闪模式
                deviceCaps.AntiFlicker = $(xmlDoc).find('Device').eq(0).find('FunctionList').eq(0).find('AntiFlickerMode').eq(0).find('Support').text();
                //图像模式
                deviceCaps.imageMode = $(xmlDoc).find('Device').eq(0).find('FunctionListAboutChannel').eq(0).find('ImageMode ').attr("enable");
                deviceCaps.normalMode = $(xmlDoc).find('Device').eq(0).find('FunctionListAboutChannel').eq(0).find('Normal').text();
                deviceCaps.faceMode = $(xmlDoc).find('Device').eq(0).find('FunctionListAboutChannel').eq(0).find('FaceNoExposure').text();
                deviceCaps.licenseMode = $(xmlDoc).find('Device').eq(0).find('FunctionListAboutChannel').eq(0).find('LicensePlate').text();

                //osd配置
                //是否支持多行osd
                deviceCaps.osdTag = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(0).find("multi_osd").text();
                //是否叠加osd的附加信息
                deviceCaps.osdShowd = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(0).find("OverlayCodecParam").eq(0).find("Support").text();
                //老能力 osd1支持多少行
                deviceCaps.osdline = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(0).find("mosd_line_every_osd").text();
                //每行osd1每行支持长度
                deviceCaps.osdchar = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(0).find("mosd_char_count_every_line").text();
                // osd2 新增的能力
                deviceCaps.osd2support = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(0).find("mosd_cntv2").eq(0).find("Support").text(); //是否支持新的osd能力协议
                deviceCaps.osd2maxcnt = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(0).find("mosd_cntv2").eq(0).find("max_cnt").text(); //是否支持osd2，max_cnt为1表示只取到osd1，不显示osd2
                if (deviceCaps.osd2support == 'true') {
                    //支持osd1 总共支持多少行
                    deviceCaps.osdline = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(0).find("osd1").eq(0).find("max_line").text();
                    //osd1 单行支持最大字符个数
                    deviceCaps.osdchar = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(0).find("osd1").eq(0).find("max_line_char").text();
                    //支持osd1 总字符长度
                    deviceCaps.osd1linechar = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(0).find("osd1").eq(0).find("max_char").text()
                        //osd2
                        //osd2总长度
                    deviceCaps.odTwo = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(0).find("osd2").eq(0).find("max_char").text();
                    //osd2单行长度
                    deviceCaps.odTwol = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(0).find("osd2").eq(0).find("max_line_char").text();
                    //osd2支持多少行
                    deviceCaps.osdTwoline = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(0).find("osd2").eq(0).find("max_line").text();
                }
                deviceCaps.G711u = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(0).find("AudioCodec").eq(0).find("G711u").eq(0).text();
                deviceCaps.G711a = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(0).find("AudioCodec").eq(0).find("G711a").eq(0).text();
                deviceCaps.AAC = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(0).find("AudioCodec").eq(0).find("AAC").eq(0).text();
                deviceCaps.G726 = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(0).find("AudioCodec").eq(0).find("G726").eq(0).text();
                //移动侦测
                deviceCaps.isMotion = $(xmlDoc).find('Motion').eq(0).find("Support").text();
                deviceCaps.isMotionTow = $(xmlDoc).find('FunctionListAboutChannel').eq(0).find('Motion').eq(0).text();
                //隐私遮盖
                deviceCaps.isPrivacyZone = $(xmlDoc).find('PrivacyZone').eq(0).find("Support").text();
                //是否支持邮箱 FTP GB28181
                deviceCaps.IsSupportEmail = $(xmlDoc).find('Email').eq(0).text();
                deviceCaps.IsSupportFTP = $(xmlDoc).find('FTP').eq(0).text();
                deviceCaps.IsSupportGB28181 = $(xmlDoc).find('Protocol').eq(0).find("GB28181").find("Support").text();
                deviceCaps.IsSupportThirdParty =$(xmlDoc).find('Protocol').eq(0).find("ThirdParty").eq(0).find("Support").eq(0).text(); //是否支持第三方协议
                deviceCaps.HKProtocol = $(xmlDoc).find('Protocol').eq(0).find("ThirdParty").find("HK").find("Support").text(); ///没有此项表示支持HK协议 // true表示支持HK协议,false表示不支持
                deviceCaps.OnvifProtocol = $(xmlDoc).find('Protocol').eq(0).find("ThirdParty").find("Onvif").find("Support").text(); ///没有此项表示支持 // true表示支持,false表示不支持
                deviceCaps.AuthConfig = $(xmlDoc).find('Protocol').eq(0).find("ThirdParty").find("Onvif").find("AuthConfig").text(); ///没有此项表示支持 // true表示支持,false表示不支持
                deviceCaps.isSupportLightCapability = $(xmlDoc).find('Device').eq(0).find('LightCapability').eq(0).find('Support').text(); //是否支持新灯板能力
                //非新灯板下的能力
                deviceCaps.colorMode = $(xmlDoc).find('Device').eq(0).find('FunctionListAboutChannel').eq(0).find('ColorNight').text();
                deviceCaps.intelligentMode = $(xmlDoc).find('Device').eq(0).find('FunctionListAboutChannel').eq(0).find('IntelligentNight').text();
                deviceCaps.variableInfrared = $(xmlDoc).find('Device').eq(0).find('FunctionListAboutChannel').eq(0).find('VariableInfrared').text();
                deviceCaps.variableWhite = $(xmlDoc).find('Device').eq(0).find('FunctionListAboutChannel').eq(0).find('VariableWhite').text();
                deviceCaps.NormalInfrared = $(xmlDoc).find('Device').eq(0).find('FunctionListAboutChannel').eq(0).find('NormalInfrared').text();
                deviceCaps.normalWhite = $(xmlDoc).find('Device').eq(0).find('FunctionListAboutChannel').eq(0).find('NormalWhite').text(); //普通红外
                deviceCaps.AlarmInCount = $(xmlDoc).find('Device').eq(0).find('AlarmInCount').text(); //报警输入个数
                deviceCaps.cruiseEnable = $(xmlDoc).find('PTZ_Advance_Cruise').text();
                //移动侦测联动如下：：：：
                //移动侦测联动 灯光报警
                deviceCaps.motionLight = $(xmlDoc).find('Device').eq(0).find('MotionLinkageFunction').eq(0).find('Light').text();
                //移动侦测联动 推送
                deviceCaps.motionPush = $(xmlDoc).find('Device').eq(0).find('MotionLinkageFunction').eq(0).find('Push').text();
                //移动侦测联动 声音报警
                deviceCaps.motionAudio = $(xmlDoc).find('Device').eq(0).find('MotionLinkageFunction').eq(0).find('Audio').text();
                //移动侦测联动 FTP
                deviceCaps.motionFtp = $(xmlDoc).find('Device').eq(0).find('MotionLinkageFunction').eq(0).find('FTP').text();
                //移动侦测联动 报警输出
                deviceCaps.motionAlarmOut = $(xmlDoc).find('Device').eq(0).find('MotionLinkageFunction').eq(0).find('AlarmOut').text();
                //移动侦测联动 邮件
                deviceCaps.motionEmail = $(xmlDoc).find('Device').eq(0).find('MotionLinkageFunction').eq(0).find('Email').text();
                // deviceCap.motionSD = $(xmlDoc).find('Device').eq(0).find('MotionLinkageFunction').eq(0).find('SD').text();
                //配置项目 ddns
                deviceCaps.ddns = $(xmlDoc).find('Device').eq(0).find("FunctionList").eq(0).find('WebUI').eq(0).find('Network').eq(0).find('DDNS').eq(0).text();
                //侧边栏 人形检测
                deviceCaps.HumanShape = $(xmlDoc).find('Device').eq(0).find("HumanShape").eq(0).find("Support").text().toLowerCase();
                deviceCaps.HumanShapeTow = $(xmlDoc).find('Device').eq(0).find("SmartEvent").eq(0).find("PeopleDetect").text().toLowerCase();
                deviceCaps.cloudUpgrade = $(xmlDoc).find('Device').eq(0).find("cloud_upgrade").eq(0).text().toLowerCase();
                //StorageCapacity为false时 隐藏sd卡容量信息
                deviceCaps.StorageCapacity = $(xmlDoc).find('Device').eq(0).find("AppUI").eq(0).find('StorageCapacity').text().toLowerCase();
                // 是否支持车牌抓拍
                deviceCaps.carSupport = $(xmlDoc).find('Device').eq(0).find("LPR").eq(0).find('Support').eq(0).text().toLowerCase();
                // 自适应IP
                deviceCaps.AutoIP = $(xmlDoc).find("AutoIP").eq(0).text();
                // 主动注册
                deviceCaps.ActiveResgist = $(xmlDoc).find('Device').eq(0).find("CenterServer").eq(0).find('AutoRegister').text().toLowerCase();
                // 报警联动
                deviceCaps.AlarmLinkage = $(xmlDoc).find("FaceRecognition").eq(0).find('AlarmLinkage').eq(0).find('support').text().toLowerCase();
                // HTTP
                deviceCaps.HttpContrl = $(xmlDoc).find("HTTPPush").text().toLowerCase();
                // MQTT
                deviceCaps.MqttContrl = $(xmlDoc).find("MQTT").text().toLowerCase();
                // 定时抓图
                deviceCaps.TimeSnapshot = $(xmlDoc).find("TimeSnapshot").text().toLowerCase();
                // 是否支持miaoyue地锁车位配置
                deviceCaps.lockConfig = $(xmlDoc).find("CarPark").find("Support").text().toLowerCase();
                // miaoyue车位个数
                deviceCaps.lockNumber = $(xmlDoc).find("CarPark").find("Number").text();
                // 调试信息
                deviceCaps.debug = $(xmlDoc).find("CarPark").find("Debug").text().toLowerCase();
                // 车形框
                deviceCaps.carFrame = $(xmlDoc).find("CarPark").find("Car").text().toLowerCase();
                // 车牌框
                deviceCaps.cartPlateframe = $(xmlDoc).find("CarPark").find("LicensePlate").text().toLowerCase();
                // 布防框
                deviceCaps.defenseFrame = $(xmlDoc).find("CarPark").find("DetectArea").text().toLowerCase();
                // 曝光时间是否支持设置
                deviceCaps.ExposureTime = $(xmlDoc).find("ExposureTime").find("Support").text().toLowerCase();
                // 曝光时间选项
                deviceCaps.ExposureTimeList = $(xmlDoc).find("ExposureTime").find("Option").text()
                    // 抠图类型
                deviceCaps.ImageCutoutType = $(xmlDoc).find('Device').eq(0).find("LPR").eq(0).find('ImageCutoutType').text().toLowerCase();
                // 不动不检
                deviceCaps.NoMotionNoDetection = $(xmlDoc).find('Device').eq(0).find("LPR").eq(0).find('NoMotionNoDetection').text().toLowerCase();
                // 识别车牌号
                deviceCaps.RecognitionNumber = $(xmlDoc).find('Device').eq(0).find("LPR").eq(0).find('RecognitionNumber').text().toLowerCase();
                // 支持特殊字符密码
                deviceCaps.PWDSpecialChars = $(xmlDoc).find('Device').eq(0).find("PWDSpecialChars").text().toLowerCase();
                // 设备不支持客流统计图
                deviceCaps.WebNosupportChart = $(xmlDoc).find('Device').eq(0).find("FunctionList").eq(0).find('WebUI').eq(0).find("NoPassengerFlowChart").text().toLowerCase();
                // 设备不支持车流统计图
                deviceCaps.WebNosupportTraChart = $(xmlDoc).find('Device').eq(0).find("FunctionList").eq(0).find('WebUI').eq(0).find("NoTrafficFlowChart").text().toLowerCase();
                // 修改配置时设备会保存并自动重新启动
                deviceCaps.ElectronicFenceFlag = $(xmlDoc).find('Device').find("FunctionList").find('ConfigReboot').find("ElectronicFence").text().toLowerCase(); //电子围栏
                deviceCaps.TraversePlaneFlag = $(xmlDoc).find('Device').find("FunctionList").find('ConfigReboot').find("TraversePlane").text().toLowerCase(); //越界检测
                deviceCaps.OffDutyFlag = $(xmlDoc).find('Device').find("FunctionList").find('ConfigReboot').find("OffDuty").text().toLowerCase(); //离岗检测
                deviceCaps.PassengerFlowFlag = $(xmlDoc).find('Device').find("FunctionList").find('ConfigReboot').find("PassengerFlow").text().toLowerCase(); //客流统计
                deviceCaps.ObjectTrackFlag = $(xmlDoc).find('Device').find("FunctionList").find('ConfigReboot').find("ObjectTrack").text().toLowerCase(); //智能跟踪
                deviceCaps.FaceSnapshotFlag = $(xmlDoc).find('Device').find("FunctionList").find('ConfigReboot').find("FaceSnapshot").text().toLowerCase(); //人脸抓拍
                deviceCaps.FaceRecoFlag = $(xmlDoc).find('Device').find("FunctionList").find('ConfigReboot').find("FaceReco").text().toLowerCase(); //人脸识别
                deviceCaps.LPRFlag = $(xmlDoc).find('Device').find("FunctionList").find('ConfigReboot').find("LPR").eq(0).text().toLowerCase(); //车牌抓拍
                deviceCaps.CarParkFlag = $(xmlDoc).find('Device').find("FunctionList").find('ConfigReboot').find("CarPark").text().toLowerCase(); //车位设置
                deviceCaps.TrafficFlowFlag = $(xmlDoc).find('Device').find("FunctionList").find('ConfigReboot').find("TrafficFlow").text().toLowerCase(); //车流统计
                deviceCaps.WDRFlag = $(xmlDoc).find('Device').find("FunctionList").find('ConfigReboot').find("WDR").text().toLowerCase(); //宽动态
                deviceCaps.VideoCodecFlag = $(xmlDoc).find('Device').find("FunctionList").find('ConfigReboot').find("VideoCodec").text().toLowerCase(); //视频编码配置
                deviceCaps.lateFlag = $(xmlDoc).find('Device').find("FunctionList").find('ConfigReboot').find("LPSurveillance").text().toLowerCase(); //车牌布控
                //NTP时间立即同步
                deviceCaps.NtpTimeSync = $(xmlDoc).find("NtpTimeSync").eq(0).text();
                // 是否支持车牌布控
                deviceCaps.lincenPlate = $(xmlDoc).find("LPSurveillance").find("Support").text().toLowerCase();
                // 点阵osd
                deviceCaps.osddoit = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(0).find("MatrixOSD").find('Support').text();
                deviceCaps.osddoitWidth = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(0).find("MatrixOSD").find('osd1').find('Resolution').find('MaxWidth').text(); //点阵宽
                deviceCaps.osddoitHeight = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(0).find("MatrixOSD").find('osd1').find('Resolution').find('MaxHeight').text(); //点阵高
                deviceCaps.osddoitWidth2 = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(0).find("MatrixOSD").find('osd2').find('Resolution').find('MaxWidth').text(); //点阵宽
                deviceCaps.osddoitHeight2 = $(xmlDoc).find("FunctionListAboutChannel").eq(0).find("ChannelList").eq(0).find("Channel").eq(0).find("MatrixOSD").find('osd2').find('Resolution').find('MaxHeight').text(); //点阵高
                // 自定义语音
                deviceCaps.enableG711U = $(xmlDoc).find('Device').find("FunctionList").find("VoiceCustomAttr").find("G711U").find("Support").text().toLowerCase();
                deviceCaps.MaxSample = $(xmlDoc).find('Device').find("FunctionList").find("VoiceCustomAttr").find("G711U").find("MaxSample").text();
                deviceCaps.MinSample = $(xmlDoc).find('Device').find("FunctionList").find("VoiceCustomAttr").find("G711U").find("MinSample").text();
                config.Sample=deviceCaps.MinSample;
                deviceCaps.MaxLength = $(xmlDoc).find('Device').find("FunctionList").find("VoiceCustomAttr").find("G711U").find("MaxLength").text();
                config.maxTotal=deviceCaps.MaxLength*1024;
                // 是否推送人脸特征
                deviceCaps.FaceFeaturesPush =$(xmlDoc).find("FunctionListAboutChannel").find("FaceFeaturesPush").eq(0).text();
                 // 是否支持有线
                 deviceCaps.WiredNetwork = $(xmlDoc).find("WiredNetwork").eq(0).text();
                // 是否支持灯光页面
                deviceCaps.isSupportLightpage = $(xmlDoc).find('Device').eq(0).find('LightCapability').eq(0).find('HideLightPage').text();
                deviceCaps.V2022 =$(xmlDoc).find("GB28181").find("V2022").eq(0).text();
                deviceCaps.FourGnumber = $(xmlDoc).find("_4GConfig").eq(0).find("CardNumber").text(); //支持4G卡的数量
                 // 推送间隔是否支持1-9秒
                deviceCaps.allowonetonine =$(xmlDoc).find('Device').eq(0).find("LPR").eq(0).find('PushInterval').text();
                deviceCap.push(deviceCaps);

            }
        },
        error: function(data) {}
    });
    return deviceCap
}


/**
 * Mac地址获取
 */
function getMacAddress() {
    var MacAddress;
    $.ajax({
        type: "get",
        url: config.baseUrl + '/Network/Interfaces',
        dataType: 'XML',
        timeout: 15000,
        async: false,
        beforeSend: function(xhr) {
            xhr.setRequestHeader("If-Modified-Since", "0");
        },
        success: function(data) {

            MacAddress = $(data).find('InterfaceList').find('Interface').eq(0).find('MacAddress').eq(0).text();
            if (!MacAddress) {
                MacAddress = $(data).find('InterfaceList').find('Interface').eq(1).find('MacAddress').eq(0).text();
            }

        },
        error: function(data) {}
    });
    return MacAddress;
}


/**
 * 网络端口号获取
 */
function getHTTPprot() {
    var Network = {};
    $.ajax({
        type: "get",
        url: config.baseUrl + '/Network/Port',
        dataType: 'XML',
        timeout: 15000,
        async: false,
        beforeSend: function(xhr) {
            xhr.setRequestHeader("If-Modified-Since", "0");
        },
        success: function(data) {
            Network.HTTPprot = $(data).find('Port').eq(0).find('HTTP').eq(0).text();
            Network.commandPort = $(data).find('Port').eq(0).find('Command').eq(0).text();
            Network.mediaPort = $(data).find('Port').eq(0).find('Media').eq(0).text();
            Network.rtspPort = $(data).find('Port').eq(0).find('RTP').eq(0).text();
        },
        error: function(data) {}
    });
    return Network;
}

function enablePush() { //联动 触发推送
    var isPush = false;
    $.ajax({
        url: config.baseUrl + "/Network/P2PV2",
        type: "get",
        async: false,
        timeout: 15000,
        beforeSend: function(xhr) {
            xhr.setRequestHeader("If-Modified-Since", "0");
        },
        success: function(xmlDoc, textStatus, xhr) {
            var uid = $(xmlDoc).find('P2P').eq(0).find('UUID').eq(0).text();
            isPush = uid.indexOf("#") !== -1;
        },
        error: function(xhr, textStatus, errorThrown) {}
    });
    return isPush;
}


/**
 * 设备AI能力获取
 */
function getdeviceAiCap() {
    var deviceAiCap = [];
    $.ajax({
        type: "get",
        url: config.baseUrl + '/System/AICap',
        dataType: 'XML',
        timeout: 15000,
        async: false,
        beforeSend: function(xhr) {
            xhr.setRequestHeader("If-Modified-Since", "0");
        },
        success: function(xmlDoc) {
            if (config.isSupportMultiChannel) {
                var Capscounts = $(xmlDoc).find("AICap").eq(0).find("Channel").size(); //表示此时有几个节点通道
                for (var o = 0; o < Capscounts; o++) {
                    var deviceAiCaps = {};
                    //客流统计查询
                    deviceAiCaps.passengerFlow = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("SmartDetect").find("PassengerFlowStatisticsQuery").text().toLowerCase();
                    //电子围栏检测目标目标中的车型
                    deviceAiCaps.Electcar = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("SmartDetect").find("ElectronicFence").find('DetectTarget').find("car").text().toLowerCase();
                    //电子围栏目标检测目标目标中的人型
                    deviceAiCaps.Electhumn = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("SmartDetect").find("ElectronicFence").find('DetectTarget').find("human").text().toLowerCase();
                    // 电子围栏检测目标车和人
                    deviceAiCaps.Electhumnancar = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("SmartDetect").find("ElectronicFence").find('DetectTarget').find("humanAndCar").text().toLowerCase();
                    // 电子围栏非机动车
                    deviceAiCaps.nocarforV2 = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("SmartDetect").find("ElectronicFence").find('DetectTarget').find("NonMotorVehicle").text().toLowerCase();
                    // 电子围栏背景图推送
                    deviceAiCaps.elBackgroundImages = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("SmartDetect").find("ElectronicFence").find('BackgroundImage').find("Support").text().toLowerCase();
                    // 电子围栏显示警戒线
                    deviceAiCaps.Wroningfram = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("SmartDetect").find("ElectronicFence").find('OverlayArea').text();
                    // 电子围栏显示目标框
                    deviceAiCaps.TargetFrame = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("SmartDetect").find("ElectronicFence").find('OverlayObject').text();
                    // 越界侦测目标车型
                    deviceAiCaps.Travercar = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("SmartDetect").find("TraversePlane").find('DetectTarget').find("car").text().toLowerCase();
                    // 越界侦测目标人型
                    deviceAiCaps.Traverhumn = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("SmartDetect").find("TraversePlane").find('DetectTarget').find("human").text().toLowerCase();
                    // 越界侦测检测目标车和人
                    deviceAiCaps.Traverhumnancar = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("SmartDetect").find("TraversePlane").find('DetectTarget').find("humanAndCar").text().toLowerCase();
                    // 越界侦测背景图推送
                    deviceAiCaps.trBackgroundImages = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("SmartDetect").find("TraversePlane").find('BackgroundImage').find("Support").text().toLowerCase();
                    // 越界侦测显示警戒线
                    deviceAiCaps.trWroningfram = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("SmartDetect").find("TraversePlane").find('OverlayArea').text();
                    // 越界侦测显示目标框
                    deviceAiCaps.trTargetFrame = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("SmartDetect").find("TraversePlane").find('OverlayObject').text();
                    // 语音报警车型
                    deviceAiCaps.Carsupport = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("AudioAlarmType").find("ForCar").find("support").text().toLowerCase();
                    // 语音报警人形
                    deviceAiCaps.Peoplesupport = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("AudioAlarmType").find("ForHuman").find("support").text().toLowerCase();
                    //客流统计叠加
                    deviceAiCaps.PassengerFlowOverlay = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("SmartDetect").find("PassengerFlowStatisticsOverlay").text().toLowerCase();
                    deviceAiCaps.Electronsupport = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("SmartDetect").find("ElectronicFence").find('support').text().toLowerCase();
                    //越界侦测
                    deviceAiCaps.Traversesupport = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("SmartDetect").find("TraversePlane").find('support').text().toLowerCase();
                    //离岗侦测
                    deviceAiCaps.OffDetectsupport = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("SmartDetect").find("OffDutyDetect").find('support').text().toLowerCase();
                    // 离岗侦测显示警戒线
                    deviceAiCaps.offWroningfram = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("SmartDetect").find("OffDutyDetect").find('OverlayArea').text();
                    // 离岗侦测显示目标框
                    deviceAiCaps.offTargetFrame = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("SmartDetect").find("OffDutyDetect").find('OverlayObject').text();
                    // 离岗侦测背景图推送
                    deviceAiCaps.offBackgroundImages = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("SmartDetect").find("OffDutyDetect").find('BackgroundImage').find("Support").text().toLowerCase();
                    //客流统计
                    deviceAiCaps.PassengerFlowsupport = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("SmartDetect").find("PassengerFlowStatics").find('support').text().toLowerCase();
                    // 客流统计背景图推送
                    deviceAiCaps.PasBackgroundImages = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("SmartDetect").find("PassengerFlowStatics").find('BackgroundImage').find("Support").text().toLowerCase();
                    // 火焰检测
                    deviceAiCaps.Firedetectsupport = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("FireDetect").find('support').text().toLowerCase();
                    //电动车
                    deviceAiCaps.ElectricBikesupport = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("ElectricBike").find('support').text().toLowerCase();
                    // 火焰声音类型
                    deviceAiCaps.FiredetectAudioType = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("AudioAlarmType").find('ForFire').eq(0).find("AudioType").eq(0);
                    // 客流统计区域限制
                    deviceAiCaps.LeftTopX = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("SmartDetect").find("PassengerFlowStatics").find('MaxManagerRegion').find('LeftTopX').text();
                    deviceAiCaps.LeftTopY = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("SmartDetect").find("PassengerFlowStatics").find('MaxManagerRegion').find('LeftTopY').text();
                    deviceAiCaps.RightBottomX = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("SmartDetect").find("PassengerFlowStatics").find('MaxManagerRegion').find('RightBottomX').text();
                    deviceAiCaps.RightBottomY = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("SmartDetect").find("PassengerFlowStatics").find('MaxManagerRegion').find('RightBottomY').text();
                    //电子围栏声音类型
                    deviceAiCaps.electronVoicetype = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("AudioAlarmType").eq(0).find('ForElectronicFence').eq(0).find('support').eq(0).text();
                    deviceAiCaps.dzwlaudioVoicetype = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("AudioAlarmType").eq(0).find('ForElectronicFence').eq(0).find('AudioType').eq(0);
                    //电子围栏音量
                    deviceAiCaps.elevoicelume = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("AudioAlarmType").eq(0).find('ForElectronicFence').eq(0).find('AudioVolume').eq(0).text();
                    //越界侦测声音类型
                    deviceAiCaps.crossVoicetype = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("AudioAlarmType").eq(0).find('ForTraversePlane').eq(0).find('support').eq(0).text();
                    deviceAiCaps.yjzcaudioVoicetype = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("AudioAlarmType").eq(0).find('ForTraversePlane').eq(0).find('AudioType').eq(0);
                    //越界侦测音量
                    deviceAiCaps.crossvoicelume = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("AudioAlarmType").eq(0).find('ForTraversePlane').eq(0).find('AudioVolume').eq(0).text();
                    //离岗侦测声音类型
                    deviceAiCaps.offdutyVoicetype = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("AudioAlarmType").eq(0).find('ForOffDutyDetect').eq(0).find('support').eq(0).text();
                    deviceAiCaps.lgjcaudioVoicetype = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("AudioAlarmType").eq(0).find('ForOffDutyDetect').eq(0).find('AudioType').eq(0);
                    //越界侦测音量
                    deviceAiCaps.offvoicelume = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("AudioAlarmType").eq(0).find('ForOffDutyDetect').eq(0).find('AudioVolume').eq(0).text();
                    //视频遮挡生意类型
                    deviceAiCaps.spzdaudioisShow = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find('VideoShelter').eq(0).find('support').eq(0).text();
                    deviceAiCaps.spzdaudioVoicetype = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("AudioAlarmType").eq(0).find('ForVideoShelter').eq(0).find('AudioType').eq(0);
                    // 人脸检测声音类型
                    deviceAiCaps.forfaceVoicetype = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("AudioAlarmType").eq(0).find('ForFace').eq(0).find('AudioType').eq(0);
                    // 口罩检测声音类型
                    deviceAiCaps.formaskVoicetype = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("AudioAlarmType").eq(0).find('ForMask').eq(0).find('AudioType').eq(0);
                    // 口罩检测
                    deviceAiCaps.formaskSupport = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("AudioAlarmType").eq(0).find('ForMask').eq(0).find('support').eq(0);
                    // // 口罩检测tab
                    // deviceAiCaps.maskDetectSupport = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find('MaskDetect').eq(0).find('support').eq(0);
                    //客流统计声音类型
                    deviceAiCaps.flowpesupport = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("AudioAlarmType").eq(0).find('PassengerEnter').eq(0).find('support').eq(0).text().toLowerCase();
                    deviceAiCaps.flowenAudioType = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("AudioAlarmType").eq(0).find('PassengerEnter').eq(0).find('AudioType').eq(0);
                    // 电动车声音类型
                    deviceAiCaps.bikeSupport = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("AudioAlarmType").eq(0).find('ForElectricBike').eq(0).find('support').eq(0).text().toLowerCase();
                    deviceAiCaps.bikeAudioType = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("AudioAlarmType").eq(0).find('ForElectricBike').eq(0).find('AudioType').eq(0);
                    //客流音量
                    deviceAiCaps.flowvoicelume = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("AudioAlarmType").eq(0).find('PassengerEnter').eq(0).find('AudioVolume').eq(0).text();
                    deviceAiCaps.flowlesupport = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("AudioAlarmType").eq(0).find('PassengerLeave').eq(0).find('Support').eq(0).text().toLowerCase();
                    deviceAiCaps.flowleAudioType = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("AudioAlarmType").eq(0).find('PassengerLeave').eq(0).find('AudioType').eq(0);
                    //算法仓库
                    deviceAiCaps.isSupportAlgorithmWarehouse = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("AlgorithmWarehouse").eq(0).find("support").eq(0).text().toLowerCase();
                    //人脸抓拍
                    deviceAiCaps.algorithmFaceSnap = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("AlgorithmWarehouse").eq(0).find('FaceSnap').eq(0).find('support').eq(0);
                    //人脸音量
                    deviceAiCaps.facevoicelume = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("AudioAlarmType").eq(0).find('ForFace').eq(0).find('AudioVolume').eq(0).text();
                    //口罩音量
                    deviceAiCaps.maskvoicelume = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("AudioAlarmType").eq(0).find('ForMask').eq(0).find('AudioVolume').eq(0).text();
                    //声音报警控制
                    deviceAiCaps.ControlModeText = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("AudioAlarmType").eq(0).find('ControlMode').eq(0).text();

                    //人脸识别
                    deviceAiCaps.algorithmFaceReco = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("AlgorithmWarehouse").eq(0).find('FaceReco').eq(0).find('support').eq(0);
                    // 智能跟踪
                    deviceAiCaps.IntelligentTracksuport = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("SmartDetect").find("ObjectTrack").find('support').text().toLowerCase();
                    // 智能跟踪目标人形车型
                    deviceAiCaps.IntelligentTrackdectecCar = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("SmartDetect").find("ObjectTrack").find("DetectTarget").find("car").eq(0).text().toLowerCase();
                    deviceAiCaps.IntelligentTrackdectecHuman = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("SmartDetect").find("ObjectTrack").find("DetectTarget").find("human").eq(0).text().toLowerCase();
                    //声音报警次数和时间能力
                    deviceAiCaps.timeandtimes = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("AudioAlarmType").eq(0).find('ControlMode').eq(0).text();
                    //声音报警能力接口能力
                    deviceAiCaps.voiceAlarmint = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("AudioAlarm").eq(0).find("AudioAlarmType").eq(0).find('ReuseControlMode').eq(0).text().toLowerCase();
                    // 车牌声音类型
                    deviceAiCaps.forcarpaiVoicetype = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("AudioAlarmType").eq(0).find('ForLPR').eq(0).find('AudioType').eq(0);
                    deviceAiCaps.forcarpaiShow = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("AudioAlarmType").eq(0).find('ForLPR').eq(0).find('support').text().toLowerCase();
                    deviceAiCaps.Audiovolumex = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("ForFaceReco").eq(0).find('AudioVolume').eq(0).text().toLowerCase();
                    deviceAiCaps.AudioType = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("ForFaceReco").eq(0).find('AudioType').eq(0);
                    deviceAiCaps.PassengerFlowsupportV2 = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("SmartDetect").find("PassengerFlowStaticsV2").find('support').text().toLowerCase();
                    // 电子围栏V2能力
                    deviceAiCaps.foreletriceV2 = $(xmlDoc).find("AICap").eq(0).find("Channel").eq(o).find("SmartDetect").find("ElectronicFence").find('Version').text();
                    deviceAiCap.push(deviceAiCaps);
                }
            } else {
                var deviceAiCaps = {};
                //客流统计查询
                deviceAiCaps.passengerFlow = $(xmlDoc).find("SmartDetect").find("PassengerFlowStatisticsQuery").text().toLowerCase();
                //电子围栏检测目标目标中的车型
                deviceAiCaps.Electcar = $(xmlDoc).find("SmartDetect").find("ElectronicFence").find('DetectTarget').find("car").text().toLowerCase();
                //电子围栏目标检测目标目标中的人型
                deviceAiCaps.Electhumn = $(xmlDoc).find("SmartDetect").find("ElectronicFence").find('DetectTarget').find("human").text().toLowerCase();
                // 电子围栏检测目标车和人
                deviceAiCaps.Electhumnancar = $(xmlDoc).find("SmartDetect").find("ElectronicFence").find('DetectTarget').find("humanAndCar").text().toLowerCase();
                // 电子围栏非机动车
                deviceAiCaps.nocarforV2 = $(xmlDoc).find("SmartDetect").find("ElectronicFence").find('DetectTarget').find("NonMotorVehicle").text().toLowerCase();
                // 电子围栏背景图推送
                deviceAiCaps.elBackgroundImages = $(xmlDoc).find("SmartDetect").find("ElectronicFence").find('BackgroundImage').find("Support").text().toLowerCase();
                // 电子围栏显示警戒线
                deviceAiCaps.Wroningfram = $(xmlDoc).find("SmartDetect").find("ElectronicFence").find('OverlayArea').text();
                // 电子围栏显示目标框
                deviceAiCaps.TargetFrame = $(xmlDoc).find("SmartDetect").find("ElectronicFence").find('OverlayObject').text();
                // 越界侦测目标车型
                deviceAiCaps.Travercar = $(xmlDoc).find("SmartDetect").find("TraversePlane").find('DetectTarget').find("car").text().toLowerCase();
                // 越界侦测目标人型
                deviceAiCaps.Traverhumn = $(xmlDoc).find("SmartDetect").find("TraversePlane").find('DetectTarget').find("human").text().toLowerCase();
                // 越界侦测检测目标车和人
                deviceAiCaps.Traverhumnancar = $(xmlDoc).find("SmartDetect").find("TraversePlane").find('DetectTarget').find("humanAndCar").text().toLowerCase();
                // 越界侦测背景图推送
                deviceAiCaps.trBackgroundImages = $(xmlDoc).find("SmartDetect").find("TraversePlane").find('BackgroundImage').find("Support").text().toLowerCase();
                // 越界侦测显示警戒线
                deviceAiCaps.trWroningfram = $(xmlDoc).find("SmartDetect").find("TraversePlane").find('OverlayArea').text();
                // 越界侦测显示目标框
                deviceAiCaps.trTargetFrame = $(xmlDoc).find("SmartDetect").find("TraversePlane").find('OverlayObject').text();
                // 语音报警车型
                deviceAiCaps.Carsupport = $(xmlDoc).find("AudioAlarmType").find("ForCar").find("support").text().toLowerCase();
                // 语音报警人形
                deviceAiCaps.Peoplesupport = $(xmlDoc).find("AudioAlarmType").find("ForHuman").find("support").text().toLowerCase();
                //客流统计叠加
                deviceAiCaps.PassengerFlowOverlay = $(xmlDoc).find("SmartDetect").find("PassengerFlowStatisticsOverlay").text().toLowerCase();
                deviceAiCaps.Electronsupport =$(xmlDoc).find("SmartDetect").find("ElectronicFence").find('support').text().toLowerCase();
                //越界侦测
                deviceAiCaps.Traversesupport = $(xmlDoc).find("SmartDetect").find("TraversePlane").find('support').text().toLowerCase();
                //离岗侦测
                deviceAiCaps.OffDetectsupport = $(xmlDoc).find("SmartDetect").find("OffDutyDetect").find('support').text().toLowerCase();
                // 离岗侦测显示警戒线
                deviceAiCaps.offWroningfram = $(xmlDoc).find("SmartDetect").find("OffDutyDetect").find('OverlayArea').text();
                // 离岗侦测显示目标框
                deviceAiCaps.offTargetFrame = $(xmlDoc).find("SmartDetect").find("OffDutyDetect").find('OverlayObject').text();
                // 离岗侦测背景图推送
                deviceAiCaps.offBackgroundImages = $(xmlDoc).find("SmartDetect").find("OffDutyDetect").find('BackgroundImage').find("Support").text().toLowerCase();
                //客流统计
                deviceAiCaps.PassengerFlowsupport = $(xmlDoc).find("SmartDetect").find("PassengerFlowStatics").find('support').text().toLowerCase();
                // 客流统计背景图推送
                deviceAiCaps.PasBackgroundImages = $(xmlDoc).find("SmartDetect").find("PassengerFlowStatics").find('BackgroundImage').find("Support").text().toLowerCase();
                // 火焰检测
                deviceAiCaps.Firedetectsupport = $(xmlDoc).find("FireDetect").find('support').text().toLowerCase();
                //电动车
                deviceAiCaps.ElectricBikesupport = $(xmlDoc).find("ElectricBike").find('support').text().toLowerCase();
                // 火焰声音类型
                deviceAiCaps.FiredetectAudioType = $(xmlDoc).find("AudioAlarmType").find('ForFire').eq(0).find("AudioType").eq(0);
                // 客流统计区域限制
                deviceAiCaps.LeftTopX = $(xmlDoc).find("SmartDetect").find("PassengerFlowStatics").find('MaxManagerRegion').find('LeftTopX').text();
                deviceAiCaps.LeftTopY = $(xmlDoc).find("SmartDetect").find("PassengerFlowStatics").find('MaxManagerRegion').find('LeftTopY').text();
                deviceAiCaps.RightBottomX = $(xmlDoc).find("SmartDetect").find("PassengerFlowStatics").find('MaxManagerRegion').find('RightBottomX').text();
                deviceAiCaps.RightBottomY = $(xmlDoc).find("SmartDetect").find("PassengerFlowStatics").find('MaxManagerRegion').find('RightBottomY').text();
                //电子围栏声音类型
                deviceAiCaps.electronVoicetype = $(xmlDoc).find("AudioAlarmType").eq(0).find('ForElectronicFence').eq(0).find('support').eq(0).text();
                deviceAiCaps.dzwlaudioVoicetype = $(xmlDoc).find("AudioAlarmType").eq(0).find('ForElectronicFence').eq(0).find('AudioType').eq(0);
                //电子围栏音量
                deviceAiCaps.elevoicelume = $(xmlDoc).find("AudioAlarmType").eq(0).find('ForElectronicFence').eq(0).find('AudioVolume').eq(0).text();
                //越界侦测声音类型
                deviceAiCaps.crossVoicetype = $(xmlDoc).find("AudioAlarmType").eq(0).find('ForTraversePlane').eq(0).find('support').eq(0).text();
                deviceAiCaps.yjzcaudioVoicetype = $(xmlDoc).find("AudioAlarmType").eq(0).find('ForTraversePlane').eq(0).find('AudioType').eq(0);
                //越界侦测音量
                deviceAiCaps.crossvoicelume = $(xmlDoc).find("AudioAlarmType").eq(0).find('ForTraversePlane').eq(0).find('AudioVolume').eq(0).text();
                //离岗侦测声音类型
                deviceAiCaps.offdutyVoicetype = $(xmlDoc).find("AudioAlarmType").eq(0).find('ForOffDutyDetect').eq(0).find('support').eq(0).text();
                deviceAiCaps.lgjcaudioVoicetype = $(xmlDoc).find("AudioAlarmType").eq(0).find('ForOffDutyDetect').eq(0).find('AudioType').eq(0);
                //越界侦测音量
                deviceAiCaps.offvoicelume = $(xmlDoc).find("AudioAlarmType").eq(0).find('ForOffDutyDetect').eq(0).find('AudioVolume').eq(0).text();
                // 电动车声音类型
                deviceAiCaps.bikeSupport = $(xmlDoc).find("AudioAlarmType").eq(0).find('ForElectricBike').eq(0).find('support').eq(0).text().toLowerCase();
                deviceAiCaps.bikeAudioType = $(xmlDoc).find("AudioAlarmType").eq(0).find('ForElectricBike').eq(0).find('AudioType').eq(0);
                //煤气罐生意类型
                deviceAiCaps.ForGasContainerShow = $(xmlDoc).find("GasContainer").eq(0).find('support').eq(0).text();
                deviceAiCaps.ForGasContainerVoicetype = $(xmlDoc).find("AudioAlarmType").eq(0).find('ForGasContainer').eq(0).find('AudioType').eq(0);
                //视频遮挡生意类型
                deviceAiCaps.spzdaudioisShow = $(xmlDoc).find("Channel").eq(0).find('VideoShelter').eq(0).find('support').eq(0).text();
                deviceAiCaps.spzdaudioVoicetype = $(xmlDoc).find("AudioAlarmType").eq(0).find('ForVideoShelter').eq(0).find('AudioType').eq(0);
                // 人脸检测声音类型
                deviceAiCaps.forfaceVoicetype = $(xmlDoc).find("AudioAlarmType").eq(0).find('ForFace').eq(0).find('AudioType').eq(0);
                // 口罩检测声音类型
                deviceAiCaps.formaskVoicetype = $(xmlDoc).find("AudioAlarmType").eq(0).find('ForMask').eq(0).find('AudioType').eq(0);
                // 口罩检测
                deviceAiCaps.formaskSupport = $(xmlDoc).find("AudioAlarmType").eq(0).find('ForMask').eq(0).find('support').eq(0);
                //客流统计声音类型
                deviceAiCaps.flowpesupport = $(xmlDoc).find("AudioAlarmType").eq(0).find('PassengerEnter').eq(0).find('support').eq(0).text().toLowerCase();
                deviceAiCaps.flowenAudioType = $(xmlDoc).find("AudioAlarmType").eq(0).find('PassengerEnter').eq(0).find('AudioType').eq(0);
                //客流音量
                deviceAiCaps.flowvoicelume = $(xmlDoc).find("AudioAlarmType").eq(0).find('PassengerEnter').eq(0).find('AudioVolume').eq(0).text();
                deviceAiCaps.flowlesupport = $(xmlDoc).find("AudioAlarmType").eq(0).find('PassengerLeave').eq(0).find('Support').eq(0).text().toLowerCase();
                deviceAiCaps.flowleAudioType = $(xmlDoc).find("AudioAlarmType").eq(0).find('PassengerLeave').eq(0).find('AudioType').eq(0);
                //算法仓库
                deviceAiCaps.isSupportAlgorithmWarehouse = $(xmlDoc).find("AlgorithmWarehouse").eq(0).find("support").eq(0).text().toLowerCase();
                //人脸抓拍
                deviceAiCaps.algorithmFaceSnap = $(xmlDoc).find("AlgorithmWarehouse").eq(0).find('FaceSnap').eq(0).find('support').eq(0);
                //人脸音量
                deviceAiCaps.facevoicelume = $(xmlDoc).find("AudioAlarmType").eq(0).find('ForFace').eq(0).find('AudioVolume').eq(0).text();
                //口罩音量
                deviceAiCaps.maskvoicelume = $(xmlDoc).find("AudioAlarmType").eq(0).find('ForMask').eq(0).find('AudioVolume').eq(0).text();
                //声音报警控制
                deviceAiCaps.ControlModeText = $(xmlDoc).find("AudioAlarmType").eq(0).find('ControlMode').eq(0).text();

                //人脸识别
                deviceAiCaps.algorithmFaceReco = $(xmlDoc).find("AlgorithmWarehouse").eq(0).find('FaceReco').eq(0).find('support').eq(0);
                // 智能跟踪
                deviceAiCaps.IntelligentTracksuport =$(xmlDoc).find("SmartDetect").find("ObjectTrack").find('support').text().toLowerCase();
                // 智能跟踪目标人形车型
                deviceAiCaps.IntelligentTrackdectecCar = $(xmlDoc).find("SmartDetect").find("ObjectTrack").find("DetectTarget").find("car").eq(0).text().toLowerCase();
                deviceAiCaps.IntelligentTrackdectecHuman = $(xmlDoc).find("SmartDetect").find("ObjectTrack").find("DetectTarget").find("human").eq(0).text().toLowerCase();
                //声音报警次数和时间能力
                deviceAiCaps.timeandtimes = $(xmlDoc).find("AudioAlarmType").eq(0).find('ControlMode').eq(0).text();
                //声音报警能力接口能力
                deviceAiCaps.voiceAlarmint = $(xmlDoc).find("AudioAlarm").eq(0).find("AudioAlarmType").eq(0).find('ReuseControlMode').eq(0).text().toLowerCase();
                // 车牌声音类型
                deviceAiCaps.forcarpaiVoicetype = $(xmlDoc).find("AudioAlarmType").eq(0).find('ForLPR').eq(0).find('AudioType').eq(0);
                deviceAiCaps.forcarpaiShow = $(xmlDoc).find("AudioAlarmType").eq(0).find('ForLPR').eq(0).find('support').text().toLowerCase();
                deviceAiCaps.Audiovolumex = $(xmlDoc).find("ForFaceReco").eq(0).find('AudioVolume').eq(0).text().toLowerCase();
                deviceAiCaps.AudioType = $(xmlDoc).find("ForFaceReco").eq(0).find('AudioType').eq(0);
                // 车流统计能力
                deviceAiCaps.trafficFlowsupport = $(xmlDoc).find("SmartDetect").find("TrafficFlowStatistics").find('support').text().toLowerCase();
                //车流统计声音类型
                deviceAiCaps.trapesupport = $(xmlDoc).find("AudioAlarmType").eq(0).find('ForTrafficFlowEnter').eq(0).find('support').eq(0).text().toLowerCase();
                deviceAiCaps.traenAudioType = $(xmlDoc).find("AudioAlarmType").eq(0).find('ForTrafficFlowEnter').eq(0).find('AudioType').eq(0);
                //车流音量
                deviceAiCaps.travoicelume = $(xmlDoc).find("AudioAlarmType").eq(0).find('ForTrafficFlowEnter').eq(0).find('AudioVolume').eq(0).text();
                deviceAiCaps.tralesupport = $(xmlDoc).find("AudioAlarmType").eq(0).find('ForTrafficFlowLeave').eq(0).find('Support').eq(0).text().toLowerCase();
                deviceAiCaps.traleAudioType = $(xmlDoc).find("AudioAlarmType").eq(0).find('ForTrafficFlowLeave').eq(0).find('AudioType').eq(0);
                deviceAiCaps.PassengerFlowsupportV2 = $(xmlDoc).find("SmartDetect").find("PassengerFlowStaticsV2").find('support').text().toLowerCase();
                // 电子围栏V2能力
                deviceAiCaps.foreletriceV2 = $(xmlDoc).find("SmartDetect").find("ElectronicFence").find('Version').text();
                deviceAiCap.push(deviceAiCaps);
            }

        },
        error: function(data) {
            deviceAiCap.push({});
        }
    });
    return deviceAiCap
}

// 生成唯一标识符的函数
function generateUniqueId() {
    return Date.now().toString(36) + Math.random().toString(36).substr(2);
}
function loadVoiceURL(url, id,assistCommand) {
    if (url.trim() == '/') {
        return;
    }
    var uniqueId = generateUniqueId();
    var prefix = "customSound-"+uniqueId+"-";
    $.ajax({
        type: "GET",
        url: url,
        dataType: 'html',
        cache: config.pageCache,

        success: function(data) {
            id.html(data.replace(/\$\{prefix\}/g, prefix)).delay(50).animate({opacity: '1.0'}, 100, function() {
                // 动画完成后调用 initCustomSound 方法
                initCustomSound(prefix,assistCommand);
            });
            id.show();
            loadProperties(sessionStorage.getItem("language"));
        },
        error: function(xhr, ajaxOptions, thrownError) {
        },
        async: false
    });
}

/**
 * 设备信息获取
 */
function getDeviceInfo() {
    var deviceInfo = {};
    $.ajax({
        type: "get",
        url: config.baseUrl + '/System/DeviceInfo',
        dataType: 'XML',
        timeout: 15000,
        async: false,
        beforeSend: function(xhr) {
            xhr.setRequestHeader("If-Modified-Since", "0");
        },
        success: function(xmlDoc) {
            if (URL_Request("isp2p") != "p2p" && URL_Request("isp2p") != "p6s") { //非vms
                var deviceNameReult = $(xmlDoc).find('DeviceInfo').eq(0).find('DeviceTypeName').eq(0).text();
                if (deviceNameReult.charAt(0) == "N") {
                    deviceInfo.DeviceName = "NVR";
                } else if (deviceNameReult.substr(0, 3) == "AHB") {
                    deviceInfo.DeviceName = "HVR";
                } else {
                    deviceInfo.DeviceName = "IPC";
                }
            } else {
                deviceInfo.DeviceName = window.deviceType;
            }
            deviceInfo.AlarmOutputChannels = $(xmlDoc).find('DeviceInfo').eq(0).find('AlarmOutputChannels').eq(0).text();
            deviceInfo.DeviceTypeName = $(xmlDoc).find('DeviceInfo').eq(0).find('DeviceTypeName').eq(0).text();
            deviceInfo.TwoWayAudio = $(xmlDoc).find('DeviceInfo').eq(0).find('TwoWayAudio').eq(0).text();
            deviceInfo.AlarmInputChannels = $(xmlDoc).find('DeviceInfo').eq(0).find('AlarmInputChannels').eq(0).text();
            deviceInfo.DeviceTypeName = $(xmlDoc).find('DeviceInfo').eq(0).find('DeviceTypeName').eq(0).text();
            deviceInfo.SerialNum = $(xmlDoc).find('DeviceInfo').eq(0).find('SerialNum').eq(0).text();
            deviceInfo.SoftWareVersion = $(xmlDoc).find('DeviceInfo').eq(0).find('SoftWareVersion').eq(0).text();
            deviceInfo.VideoInputChannels = $(xmlDoc).find('DeviceInfo').eq(0).find('VideoInputChannels').eq(0).text();
            deviceInfo.AudioChannels = $(xmlDoc).find('DeviceInfo').eq(0).find('AudioChannels').eq(0).text();
            deviceInfo.TwoWayAudi = $(xmlDoc).find('DeviceInfo').eq(0).find('TwoWayAudio').eq(0).text();
            deviceInfo.VideoInputChannels = parseInt($(xmlDoc).find('VideoInputChannels').eq(0).text()); //语言输出
            deviceInfo.AudioChannels = parseInt($(xmlDoc).find('AudioChannels').eq(0).text()); //视频
            // RTMP
            deviceInfo.rtmp = $(xmlDoc).find('DeviceInfo').eq(0).find('RTMP').eq(0).find('ActiveStatus').text();
            deviceInfo.AFBoardVersion = $(xmlDoc).find('DeviceInfo').eq(0).find('AFBoardVersion').text();
        },
        error: function(data) {}
    });
    return deviceInfo
}


/**
 * 设备状态分辨率获取
 */
function getBitrate() {
    var bitrate = {};
    $.ajax({
        type: "get",
        url: config.baseUrl + '/System/DeviceStatus',
        dataType: 'XML',
        timeout: 15000,
        async: false,
        beforeSend: function(xhr) {
            xhr.setRequestHeader("If-Modified-Since", "0");
        },
        success: function(xmlDoc) {
            bitrate.MainBitrate = $(xmlDoc).find('DeviceStatusList').find('DeviceStatus').eq(0).find('MainStreamVideoBitrate').eq(0).text();
            bitrate.FirstBitrate = $(xmlDoc).find('DeviceStatusList').find('DeviceStatus').eq(0).find('FirstSubStreamVideoBitrate').eq(0).text();
            bitrate.SecondBitrate = $(xmlDoc).find('DeviceStatusList').find('DeviceStatus').eq(0).find('SecondSubStreamVideoBitrate').eq(0).text();
        },
        error: function(data) {}
    });
    return bitrate
}

/**********************************
 功能: 登陆
 ***********************************/
function Login() {
    config.isSupportUserAuthV2 = false;
    var nonce = generateNonce();
    var created = generateTimestamp();
    // 计算密码摘要
    var passwordDigest = calculatePasswordDigest(nonce, created, config.password);
    if (!passwordDigest) {
        console.log('生成密码摘要失败');
        return false;
    }
    var cyDate = '<Security>' +
                 '<Username>' + config.user + '</Username>' +
                 '<Password>' + passwordDigest + '</Password>' +
                 '<Nonce>' + nonce + '</Nonce>' +
                 '<Created>' + created + '</Created>' +
                 '</Security>';
    console.log('发送的XML:', cyDate);
    $.ajax({
        url: config.baseUrl + "/Security/UserAuthV2",
        type: "PUT",
        timeout: 15000,
        async: false,
        data: cyDate,
        beforeSend: function(xhr) {
            xhr.setRequestHeader("If-Modified-Since", "0");
        },
        success: function(xmlDoc, textStatus, xhr) {
            config.isSupportUserAuthV2 = true;
            var statusflg = $(xmlDoc).find('ResponseStatus').eq(0).find('statusCode').eq(0).text();
            if (0 == statusflg) { //成功登陆
                var responedtoken = xhr.getResponseHeader('Token');
                if ((responedtoken != "") && (responedtoken != null) && (responedtoken != "null") && (typeof(responedtoken) != "undefined")) {
                    window.localStorage.setItem('Token', responedtoken);
                }
                loginLoad();
            } else if (statusflg == "-25") {
                $.optionBootoast($.i18n.prop("i18n-default-msg12"), 'danger')
                return false;
            } else if (-17 == statusflg) { //密码出错
                $.optionBootoast($.i18n.prop("i18n-default-msg13"), 'danger')
                return false;
            } else if (-45 == statusflg) { //nvr会返回-45
                $.optionBootoast($.i18n.prop("i18n-link-statu10"), 'danger')
                config.deviceCap = getDeviceCap(); //设备能力
                if (window.deviceType == "NVR") {
                    config.deviceCapV2 = getDeviceCapV2(); //设备能力
                }
                // 此时判断密码是否为弱密 弱密码阻止表单提交
                if (config.deviceCap[number].isSupportComplexd == "true") { //支持强密码
                    var testpwd = /^(?=.*?[A-Z])(?=.*?[0-9])[0-9a-zA-Z]{8,16}$/g;
                    var pwds = testpwd.test($('#passwd').val());
                    if (!pwds) {
                        $("#usernamed").val($("#username").val());
                        if (config.deviceCap[number].PWDSpecialChars == "true") {
                            $("#ruomiTip").text($.i18n.prop('i18n-default-msg33'));
                        }
                        $('#ruomibox').show();
                        $('#userbox').hide();
                        if (config.deviceCap[number].isSupportEmptyPassword == 'true') { //拒绝空密码
                            $("#cancelruomi").hide();
                            $("#confruomi").css('width', '264px');
                        }
                    }
                }
                return false;
            } else if ("401" != xhr.status) { //其它异常
                if ("timeout" == textStatus) { //连接超时
                    $.optionBootoast($.i18n.prop("i18n-default-msg14"), 'danger')
                } else { //网络异常
                    $.optionBootoast($.i18n.prop("i18n-default-msg15"), 'danger')
                }
                return false;
            }
        },
        error: function(xhr, textStatus, errorThrown) {
            config.isSupportUserAuthV2 = false;
            userAuths();
            return false;
        }
    });
}
function userAuths(){
    var cyDate = 'Username=' + config.user + '&Password=' + config.password;
    $.ajax({
        url: config.baseUrl + "/Security/UserAuth",
        type: "PUT",
        timeout: 15000,
        async: false,
        data: cyDate,
        beforeSend: function(xhr) {
            xhr.setRequestHeader("If-Modified-Since", "0");
        },
        success: function(xmlDoc, textStatus, xhr) {
            var statusflg = $(xmlDoc).find('ResponseStatus').eq(0).find('statusCode').eq(0).text();
            if (0 == statusflg) { //成功登陆
                loginLoad();
            } else if (statusflg == "-25") {
                $.optionBootoast($.i18n.prop("i18n-default-msg12"), 'danger');
                return false;
            } else if ("-17" == statusflg) { //密码出错
                if (URL_Request("isp2p") == "p6s") { //这里这么做是因为语言文件此时没有加载，导致无法正确翻译
                    $.optionBootoast("Login failed with incorrect password", 'danger');
                    return false;
                } else {
                    $.optionBootoast($.i18n.prop("i18n-default-msg13"), 'danger');
                    return false;
                }
            } else if ("401" != xhr.status) { //其它异常
                if ("timeout" == textStatus) { //连接超时
                    $.optionBootoast($.i18n.prop("i18n-default-msg14"), 'danger')
                } else { //网络异常
                    $.optionBootoast($.i18n.prop("i18n-default-msg15"), 'danger')
                }
                return false;
            }
        },
        error: function(xhr, textStatus, errorThrown) {
            $.optionBootoast($.i18n.prop("i18n-default-msg13"), 'danger');
            return false;
        }
    });
}
// 生成随机 Nonce (16字节)
function generateNonce() {
    var randomBytes = new Uint8Array(16);
    if (window.crypto && window.crypto.getRandomValues) {
        window.crypto.getRandomValues(randomBytes);
    } else {
        for (var i = 0; i < 16; i++) {
            randomBytes[i] = Math.floor(Math.random() * 256);
        }
    }

    var randomStr = '';
    for (var i = 0; i < randomBytes.length; i++) {
        randomStr += String.fromCharCode(randomBytes[i]);
    }

    return btoa(randomStr);
}

// 生成 ISO 格式的时间戳
function generateTimestamp() {
    return new Date().toISOString();
}

// 使用 crypto-js 计算密码摘要
function calculatePasswordDigest(nonce, created, password) {
    try {
        // 2. 拼接数据：Nonce + Created + Password
        var dataToHash = nonce + created + password;
        console.log(password,'password');
        console.log(nonce,'nonce');
        console.log(created,'created');

        // 3. 使用 crypto-js 计算 SHA1
        var sha1Hash = CryptoJS.SHA1(dataToHash);
        console.log(sha1Hash,'sha1Hashsha1Hashsha1Hashsha1Hash');
        // 4. 转换为 Base64
        return CryptoJS.enc.Base64.stringify(sha1Hash);

    } catch (error) {
        console.error('计算密码摘要错误:', error);
        return null;
    }
}
function loginLoad() {
    $.ajax({
        url: config.baseUrl + "/Network/Port",
        type: "GET",
        async: false,
        username: config.user,
        password: config.password,
        timeout: 15000,
        beforeSend: function(xhr) {
            xhr.setRequestHeader("If-Modified-Since", "0");
        },
        success: function(xmlDoc, textStatus, xhr) {
            //仅仅针对vms
            var m_cyUserPwdValue = Base64.encode(config.user + ":" + config.password);
            $.cookie('userInfo', m_cyUserPwdValue);
            // config.MacAddress = getMacAddress(); //mac地址
            // config.Network = getHTTPprot(); //网络端口号
            config.Network.HTTPprot = $(xmlDoc).find('Port').eq(0).find('HTTP').eq(0).text();
            config.Network.commandPort = $(xmlDoc).find('Port').eq(0).find('Command').eq(0).text();
            config.Network.mediaPort = $(xmlDoc).find('Port').eq(0).find('Media').eq(0).text();
            config.Network.rtspPort = $(xmlDoc).find('Port').eq(0).find('RTP').eq(0).text();
            config.deviceCap = getDeviceCap(); //设备能力
            config.deviceAiCap = getdeviceAiCap(); //ai能力
            config.deviceInfo = getDeviceInfo(); //设备信息获取
            // config.bitrate = getBitrate(); //设备状态分辨率获取
            config.playMode = getplayMode(); //播放模式数组获取

        },
        error: function(xhr, textStatus, errorThrown) {
            if ("401" != xhr.status) {
                if ("timeout" == textStatus) { //连接超时
                    $.optionBootoast($.i18n.prop("i18n-default-msg14"), 'danger')
                } else { //网络异常
                    $.optionBootoast($.i18n.prop("i18n-default-msg15"), 'danger')
                }
            } else {
                $.optionBootoast($.i18n.prop("i18n-default-msg13"), 'danger')
            }
            return false; //阻止表单提交
        }
    });
}

/**
 * easyvideo返回码翻译
 * @param code
 */
function easyerrortranslation(code) {
    var tiptitle = "";
    if (code == 1000) {
        tiptitle = $.i18n.prop('i18n-parametererror');
    } else if (code == 1001) {
        tiptitle = $.i18n.prop('i18n-unsupportedOperations');
    } else if (code == 1002) {
        tiptitle = $.i18n.prop('i18n-outmemory');
    } else if (code == 1003) {
        tiptitle = $.i18n.prop('i18n-Invalidparameter');
    } else if (code == 1004) {
        tiptitle = $.i18n.prop('i18n-servernotinitialized');
    } else if (code == 1005) {
        tiptitle = $.i18n.prop('i18n-internalerror');
    } else if (code == 1006) {
        tiptitle = $.i18n.prop('i18n-unrealized');
    } else if (code == 1007) {
        tiptitle = $.i18n.prop('i18n-Networkerror');
    } else if (code == 1008) {
        tiptitle = $.i18n.prop('i18n-Serverbusy');
    } else if (code == 1009) {
        tiptitle = $.i18n.prop('i18n-Callsequenceerror');
    } else if (code == 1011) {
        tiptitle = $.i18n.prop('i18n-diskspace');
    } else if (code == 1012) {
        tiptitle = $.i18n.prop('i18n-Equipmentbusy');
    } else if (code == 1013) {
        tiptitle = $.i18n.prop('i18n-Unknownerror');
    } else if (code == 1014) {
        tiptitle = $.i18n.prop('i18n-Connectiontimeout');
    } else if (code == 1015) {
        tiptitle = $.i18n.prop('i18n-Denyaccess');
    } else if (code == 1017) {
        tiptitle = $.i18n.prop('i18n-cancelfile');
    } else if (code == 2000) {
        tiptitle = $.i18n.prop('i18n-Unsupportedbrowser');
    } else if (code == 2001) {
        tiptitle = $.i18n.prop('i18n-notwindow');
    } else if (code == 2002) {
        tiptitle = $.i18n.prop('i18n-Hardwareacceleration');
    } else if (code == 3000) {
        tiptitle = $.i18n.prop('i18n-connectionfailure');
    } else if (code == 3001) {
        tiptitle = $.i18n.prop('i18n-userpasswordincorrect');
    } else if (code == 3002) {
        tiptitle = $.i18n.prop('i18n-Connectiontimeout');
    } else if (code == 3003) {
        tiptitle = $.i18n.prop('i18n-Weakpassworderro');
    } else if (code == 3004) {
        tiptitle = $.i18n.prop('i18n-InvalidDID');
    } else if (code == 3005) {
        tiptitle = $.i18n.prop('i18n-maxline');
    } else if (code == 3006) {
        tiptitle = $.i18n.prop('i18n-filefail');
    } else if (code == 3007) {
        tiptitle = $.i18n.prop('i18n-loginfail');
    } else if (code == 4000) {
        tiptitle = $.i18n.prop('i18n-rembacknolx');
    }else if (code == 1019) {//文字转语音错误
        tiptitle = $.i18n.prop('i18n-voice-inputMsg');
    }
    bootoast({
        message: tiptitle,
        type: 'danger',
        position: 'bottom-center',
        timeout: true,
        animationDuration: 3000,
        dismissable: true
    });
}

/**
 * 脸库返回信息状态码提示
 */
function statuscode(code) {
    var title = "";
    if (-1 == code) {
        title = $.i18n.prop('i18n-facecode1');
    }
    if (-2 == code) {
        title = $.i18n.prop('i18n-facecode2');
    }
    if (-3 == code) {
        title = $.i18n.prop('i18n-facecode3');
    }
    if (-5 == code) {
        title = $.i18n.prop('i18n-facecode4');
    }
    if (-6 == code) {
        title = $.i18n.prop('i18n-facecode5');
    }
    if (-7 == code) {
        title = $.i18n.prop('i18n-facecode6');
    }
    if (-8 == code) {
        title = $.i18n.prop('i18n-facecode7');
    }
    if (-9 == code) {
        title = $.i18n.prop('i18n-facecode8');
    }
    if (-10 == code) {
        title = $.i18n.prop('i18n-facecode9');
    }
    if (-11 == code) {
        title = $.i18n.prop('i18n-facecode10');
    }
    if (-12 == code) {
        title = $.i18n.prop('i18n-facecode11');
    }
    if (-13 == code) {
        title = $.i18n.prop('i18n-facecode12');
    }
    if (0x1001 == code) {
        title = $.i18n.prop('i18n-facecode13');
    }
    if (0x1002 == code) {
        title = $.i18n.prop('i18n-facecode14');
    }
    if (0x1003 == code) {
        title = $.i18n.prop('i18n-facecode15');
    }
    if (0x1004 == code) {
        title = $.i18n.prop('i18n-facecode16');
    }
    if (0x1005 == code) {
        title = $.i18n.prop('i18n-facecode17');
    }
    if (0x1006 == code) {
        title = $.i18n.prop('i18n-facecode18');
    }
    if (0x1007 == code) {
        title = $.i18n.prop('i18n-facecode19');
    }
    if (0x1008 == code) {
        title = $.i18n.prop('i18n-facecode20');
    }
    if (0x1009 == code) {
        title = $.i18n.prop('i18n-facecode21');
    }
    if (0x100A == code) {
        title = $.i18n.prop('i18n-facecode22');
    }
    if (0x100B == code) {
        title = $.i18n.prop('i18n-facecode23');
    }
    if (0x100C == code) {
        title = $.i18n.prop('i18n-facecode24');
    }
    if (0x100D == code) {
        title = $.i18n.prop('i18n-facecode25');
    }
    if (0x100E == code) {
        title = $.i18n.prop('i18n-facecode26');
    }
    if (0x100F == code) {
        title = $.i18n.prop('i18n-facecode27');
    }
    if (0x1064 == code) {
        title = $.i18n.prop('i18n-facecode28');
    }
    if (0x1065 == code) {
        title = $.i18n.prop('i18n-facecode29');
    }
    if (0x1066 == code) {
        title = $.i18n.prop('i18n-facecode30');
    }
    if (0x1067 == code) {
        title = $.i18n.prop('i18n-facecode31');
    }
    if (0x1068 == code) {
        title = $.i18n.prop('i18n-facecode32');
    }
    if (0x1069 == code) {
        title = $.i18n.prop('i18n-facecode33');
    }
    if (0x106a == code) {
        title = $.i18n.prop('i18n-facecode34');
    }
    if (0x106b == code) {
        title = $.i18n.prop('i18n-facecode35');
    }
    if (0x106c == code) {
        title = $.i18n.prop('i18n-facecode36');
    }
    if (0x106d == code) {
        title = $.i18n.prop('i18n-facecode37');
    }
    bootoast({
        message: title,
        type: 'danger',
        position: 'bottom-center',
        timeout: true,
        animationDuration: 3000,
        dismissable: true
    });

}

function URL_Request(strName) {
    var strHref = document.location.toString();
    var intPos = strHref.indexOf("?");
    var strRight = strHref.substr(intPos + 1);
    var arrTmp = strRight.split("&");
    for (var i = 0; i < arrTmp.length; i++) {
        var dIntPos = arrTmp[i].indexOf("=");
        var paraName = arrTmp[i].substr(0, dIntPos);
        var paraData = arrTmp[i].substr(dIntPos + 1);
        if (paraName.toUpperCase() == strName.toUpperCase()) {
            return paraData;
        }
    }
    return "";
}


/*************************************************
 Function:        createxmlDoc
 Description:    创建xml DOM对象
 Input:            无
 Output:            无
 return:            无
 *************************************************/
function createxmlDoc() {
    var xmlDoc;
    var aVersions = ["MSXML2.DOMDocument", "MSXML2.DOMDocument.5.0", "MSXML2.DOMDocument.4.0", "MSXML2.DOMDocument.3.0", "Microsoft.XmlDom"];

    for (var i = 0; i < aVersions.length; i++) {
        try {
            xmlDoc = new ActiveXObject(aVersions[i]);
            break;
        } catch (oError) {
            xmlDoc = document.implementation.createDocument("", "", null);
            break;
        }
    }
    xmlDoc.async = "false";
    return xmlDoc;

}
/*************************************************
 Function:        parseXmlFromStr
 Description:    从xml字符串中解析xml
 Input:            szXml xml字符串
 Output:            无
 return:            xml文档
 *************************************************/
// 是否ie
function isIElANCE() {
    if (!!window.ActiveXObject || "ActiveXObject" in window) {
        return true;
    } else {
        return false;
    }
}

function parseXmlFromStr(szXml) {
    if (null == szXml || '' == szXml) {
        return null;
    }
    var xmlDoc = new createxmlDoc();
    if (!isIElANCE()) {
        var oParser = new DOMParser();
        xmlDoc = oParser.parseFromString(szXml, "text/xml");
    } else {
        xmlDoc.loadXML(szXml);
    }
    return xmlDoc;

}



//将base64转换为Blob
function dataURLtoBlob(dataurl) {
    var arr = dataurl.split(','),
        mime = arr[0].match(/:(.*?);/)[1],
        bstr = atob(arr[1]),
        // bstr = Base64.decode(arr[1]),
        n = bstr.length,
        u8arr = new Uint8Array(n);
    while (n--) {
        u8arr[n] = bstr.charCodeAt(n);
    }
    return new Blob([u8arr], {
        type: mime
    });
}

//将blob转换为file
function blobToFile(theBlob, fileName) {
    theBlob.lastModifiedDate = new Date();
    theBlob.name = fileName;
    return theBlob;
}


/*************************************************
 Function:        Base64
 Description:    Base64加密解密
 Input:            无
 Output:            无
 return:            无
 *************************************************/
var Base64 = {

    // private property
    _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",

    // public method for encoding
    encode: function(input) {
        var output = "";
        var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
        var i = 0;

        input = Base64._utf8_encode(input);

        while (i < input.length) {

            chr1 = input.charCodeAt(i++);
            chr2 = input.charCodeAt(i++);
            chr3 = input.charCodeAt(i++);

            enc1 = chr1 >> 2;
            enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
            enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
            enc4 = chr3 & 63;

            if (isNaN(chr2)) {
                enc3 = enc4 = 64;
            } else if (isNaN(chr3)) {
                enc4 = 64;
            }

            output = output + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);

        }

        return output;
    },

    // public method for decoding
    decode: function(input) {
        var output = "";
        var chr1, chr2, chr3;
        var enc1, enc2, enc3, enc4;
        var i = 0;

        input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

        while (i < input.length) {

            enc1 = this._keyStr.indexOf(input.charAt(i++));
            enc2 = this._keyStr.indexOf(input.charAt(i++));
            enc3 = this._keyStr.indexOf(input.charAt(i++));
            enc4 = this._keyStr.indexOf(input.charAt(i++));

            chr1 = (enc1 << 2) | (enc2 >> 4);
            chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
            chr3 = ((enc3 & 3) << 6) | enc4;

            output = output + String.fromCharCode(chr1);

            if (enc3 != 64) {
                output = output + String.fromCharCode(chr2);
            }
            if (enc4 != 64) {
                output = output + String.fromCharCode(chr3);
            }

        }

        output = Base64._utf8_decode(output);

        return output;

    },

    // private method for UTF-8 encoding
    _utf8_encode: function(string) {
        string = string.replace(/\r\n/g, "\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            } else if ((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            } else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
    },

    // private method for UTF-8 decoding
    _utf8_decode: function(utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;

        while (i < utftext.length) {

            c = utftext.charCodeAt(i);

            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            } else if ((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i + 1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            } else {
                c2 = utftext.charCodeAt(i + 1);
                c3 = utftext.charCodeAt(i + 2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }

        }

        return string;
    }
};



/**
 * 获取播放模式
 */

function getplayMode() {
    var playModeList = [];
    $.ajax({
        url: 'custom/playMode.json',
        dataType: 'json',
        async: false,
        success: function(data) {
            if (data.playList.length == 0) { //如果客户不小心把全部的播放模式都删除了，，默认JPEG
                playModeList = ["MJPEG"];
            } else {
                playModeList = data.playList;
            }
        },
        error: function(data) {}
    });
    return playModeList
}

/**
 * 目标浏览器判断
 * @returns {boolean}
 */
function getBrowserType() {
    var ua = navigator.userAgent.toLocaleLowerCase();
    var isopera = ua.match(/opera/) != null || ua.match(/opr/) != null;
    var isEdge = ua.match(/edg/) != null;
    var isFirefox = ua.match(/firefox/) != null;
    var isSafari = ua.match(/safari/) != null && ua.match(/chrome/) == null;
    var isChrome = ua.match(/chrome/) != null;
    var isUC = ua.match(/ubrowser/) != null;
    var isQQ = ua.match(/tencenttraveler/) != null || ua.match(/qqbrowse/) != null;
    var issogou = ua.match(/metasr/) != null;
    var is360 = check360() && ua.match(/chrome/) != null;

    if (isopera || isEdge || isFirefox || isSafari || isChrome || isUC || isQQ || is360 || issogou) {
        return true;
    } else {
        return false;
    }
}

function check360() {
    var result = false;
    for (var key in navigator.plugins) {
        if (navigator.plugins[key].filename == "internal-nacl-plugin ") {
            return !result;
        }
    }
    return result;
}


/**
 * 插件下载
 *正式服:http://erp-cn.p6sai.com:8090---新http://utilerp.p6sai.com:8090
 * 測試服:http://139.9.6.140:8090
 */

function downloweasyvideo() {
    $.ajax({
        url: "http://utilerp.p6sai.com:8090/UtilERP/device/web/last-pack?boardId=" + "FFFF" + '&deviceType=' + "FFF7" + '&customer=' + "C009" + '&versionId=' + "V001",
        type: "GET",
        // async: false,
        dataType: 'jsonp', //同源策略
        jsonp: "callbackName", //指定参数名称
        jsonpCallback: "showData", //指定回调函数名称
        timeout: 5000,
        success: function(result) {},
        error: function(jqXHR, textStatus) {
            bootoast({
                message: $.i18n.prop('i18n-Downloadtimeout'),
                type: 'danger',
                position: 'top-center',
                timeout: true,
                animationDuration: 3000,
                dismissable: true
            });
        },
    })
}

function showData(data) {
    if (data.code == '200') {
        if (data.data.url) {
            location.href = data.data.url
        } else {
            bootoast({
                message: $.i18n.prop('i18n-noeasyvideofile'),
                type: 'danger',
                position: 'top-center',
                timeout: true,
                animationDuration: 3000,
                dismissable: true
            });
        }
    } else {
        bootoast({
            message: $.i18n.prop('i18n-Downloadfaileasy'),
            type: 'danger',
            position: 'top-center',
            timeout: true,
            animationDuration: 3000,
            dismissable: true
        });
    }
}

/**
 * 载入视频流
 * @param szPluginType  播放模式
 * @param vType 用来区分是否是预览框还是回放框，1是，2否
 * @param param 是否需要重复创建 ""空为不需要重复创建直接初始化实时流  cerate--重复创建
 * @param settings 是否是配置页面，true--是，false--不是
 * @param dzwl  判断当前是否需要播放是osd还是图像还是智能等等 2-osd  3-图像 4隐私 5移动 6电子围栏，，，，，，
 * @param paramdata
 * @param num 通道
 */

function getVideoPlugin(szPluginType, vType, param, settings, dzwl, paramdata, opentype, num) {
    InitBrowseFrameInfo(JSON.parse(sessionStorage.getItem('mousePos')));
    var g_bIsIE = !(/(msie\s|trident.*rv:)([\w.]+)/.exec(navigator.userAgent.toLowerCase()) == null);
    if (!g_bIsIE || config.forceEV) //如果是非IE的情况
    {
        if ("MJPEG" == szPluginType) {
            $("#downlodeasyvideo").hide();
            $("#playcz").hide();
            onloadMy(num);
            if (sessionStorage.getItem('connectionfail') != "2") {
                if (typeof Playervideo !== 'undefined' && typeof Playervideo === 'function') {
                    self.playervideo = new Playervideo();
                    self.playervideo.intervaleasy = setInterval(self.playervideo.connection, 2000);
                } else {
                    // 函数未定义
                    // console.log('Playervideo函数不存在');
                }
            }
        } else if ("WebPlayer" == szPluginType) {
            $("#downlodeasyvideo").hide();
            $("#playcz").hide();
            initwebvideo();
            if (sessionStorage.getItem('connectionfail') != "2") {
                if (typeof Playervideo !== 'undefined' && typeof Playervideo === 'function') {
                    self.playervideo = new Playervideo();
                    self.playervideo.intervaleasy = setInterval(self.playervideo.connection, 2000);
                } else {
                    // 函数未定义
                    // console.log('Playervideo函数不存在');
                }
            }
        } else if ("EasyVideo" == szPluginType) {
            $("#downloadeasyplay").hide();
            $("#downlodeasyvideo").hide();
            $("#playcz").show();
            if (vType == 1) { //开启实时流
                initwebeasy(param, settings, dzwl, paramdata, opentype, num);
            }
        }
    } else {
        if ("ActiveX" == szPluginType) {
            $("#axdiv").html("<object id='previewocx' name='previewocx' width='100%' height='100%' classid='CLSID:d276963c-7c62-41a0-88b7-79e818ffb28b'  codebase='VideoClientControl.exe#version=" + config.iePlugVersion + "'  standby='控件加载中...'></object>");
            if (vType == 1) {
                InitPrivatePreviewEvent(num);
            }
        } else if ("MJPEG" == szPluginType) {
            onloadMy(num);
        }
    }
}


function initwebeasy(param, settings, dzwl, paramdata, opentype, num) {
    var pt = GetAbsoluteLocationEx($("#axdiv")[0]);
    console.log(pt,"最终输出的坐标");
    var ua = navigator.userAgent.toLocaleLowerCase();
    var adjustPos = true;
    if (ua.match(/firefox/) != null || URL_Request("isp2p") == "p6s" || URL_Request("isp2p") == "p2p") { //火狐特殊处理
        adjustPos = false
    } else {
        adjustPos = true
    }
    var obj = {};
    obj.Fountion = "live";
    obj.LiveCtrl = {};
    obj.LiveCtrl.Preview = {};
    obj.LiveCtrl.type = 1;
    obj.LiveCtrl.uniqueId = parseInt(sessionStorage.getItem('uniqueId'), 10);
    if (config.isSupportMultiChannel == true) { //这里也要区分多目设备
        obj.LiveCtrl.channel = num;
    } else {
        obj.LiveCtrl.channel = 0;
    }
    obj.LiveCtrl.settings = settings; //settings是否是配置页面，true，是，false否
    obj.LiveCtrl.Preview.browser = getBrowsername();
    obj.LiveCtrl.Preview.title = document.getElementsByTagName("title")[0].text;
    if (pt) {
        obj.LiveCtrl.Preview.x = parseInt(pt.Left, 10);
        obj.LiveCtrl.Preview.y = parseInt(pt.Top, 10);
    }
    if (pt) {
        obj.LiveCtrl.Preview.w = parseInt(pt.Width, 10);
        obj.LiveCtrl.Preview.h = parseInt(pt.Height, 10);
    }
    obj.LiveCtrl.Preview.adjustPos = adjustPos;
    if (settings||sessionStorage.getItem("stream") == "codestream1") { //非主页面预览使用子码流
        obj.LiveCtrl.Preview.streamType = 2;
    } else {
        obj.LiveCtrl.Preview.streamType = 1;
    }
    obj.LiveCtrl.Preview.open = true;
    if (param == "cerate" || config.devicelose) { //走这一步的时候必须是easyvideo模式，devicelose这个状态也是针对它的，不判断刷新之后找不到资源会无法创建
        self.playervideo.reconcreatedev(obj, "", "", "", dzwl, paramdata,opentype);//加上opentype参数表示刷新之后开流
    } else {
        if (self.playervideo) {
            self.playervideo.live(obj, dzwl, paramdata, opentype);
        } else {
            self.playervideo = new Playervideo();
            self.playervideo.reconcreatedev(obj, "", "", "", dzwl, paramdata,opentype);
        }
    }
}

function initwebvideo() {
    if (sessionStorage.getItem("stream") == "miancodestream") {
        self.player = new Player("main");
    } else if (sessionStorage.getItem("stream") == "codestream1") {
        self.player = new Player("sub1");
    } else {
        self.player = new Player("sub2");
    }
}


/**
 * 页面可见性监听
 * @param cb
 */

function registerVisibilityEvent(cb) {
    var hidden = "hidden";
    // console.log('页面可见性监听调用');
    // Standards:
    if (hidden in document) { //当前环境下浏览器对应的页面可见性事件，并注册相应的事件监听器
        document.addEventListener("visibilitychange", onchange);
    } else if ((hidden = "mozHidden") in document) {
        document.addEventListener("mozvisibilitychange", onchange);
    } else if ((hidden = "webkitHidden") in document) {
        document.addEventListener("webkitvisibilitychange", onchange);
    } else if ((hidden = "msHidden") in document) {
        document.addEventListener("msvisibilitychange", onchange);
    } else if ("onfocusin" in document) {
        // IE 9 and lower.
        document.onfocusin = document.onfocusout = onchange;
    } else {
        // All others.
        window.onpageshow = window.onpagehide = window.onfocus = window.onblur = onchange;
    }

    function onchange(evt) {
        // console.log('页面可见性监听开始');
        var v = true;
        var h = false;
        var evtMap = {
            focus: v,
            focusin: v,
            pageshow: v,
            blur: h,
            focusout: h,
            pagehide: h
        };

        evt = evt || window.event;
        var visible = v;
        if (evt.type in evtMap) {
            visible = evtMap[evt.type];
        } else {
            visible = this[hidden] ? h : v;
        }
        cb(visible); //设置 visible 变量为 true 或 false，表示页面当前的可见性状态。最后调用回调函数 cb，将当前可见性状态传递给它。
    }

    // set the initial state (but only if browser supports the Page Visibility API)
    if (document[hidden] !== undefined) {
        onchange({
            type: document[hidden] ? "blur" : "focus"
        });
    }
}



function GetDevicePixelRatio() {
    return window.devicePixelRatio || window.screen.deviceXDPI / window.screen.logicalXDPI;
}

function GetPageOffset() {
    //document.documentElement.scrollLeft 与 window.pageYOffset是一个意思 这里是做兼容
    //都代表网页滚动偏移量。
    var bGetPos = window.pageXOffset !== undefined;
    var bStandard = (document.compatMode || "") === "CSS1Compat";
    var posX = bGetPos ? window.pageXOffset : bStandard ? document.documentElement.scrollLeft :
        document.body.scrollLeft;
    var posY = bGetPos ? window.pageYOffset : bStandard ? document.documentElement.scrollTop :
        document.body.scrollTop;
    return {
        "x": posX,
        "y": posY
    };
}

/**
 * 获取当前easyvideo的播放窗口
 * @param ele
 * @returns {*}
 * @constructor
 */
function GetAbsoluteLocationEx(ele) {
    if (ele == null) {
        return null;
    }
    var u = GetDevicePixelRatio();
    // var u = 1;
    var offsetT = ele.offsetTop;//相对于最近祖先元素的距离如果没有祖先则现对于html
    var offsetL = ele.offsetLeft;

    while (ele = ele.offsetParent) {
        if (ele.style.position == "absolute" || ele.style.position == "relative" ||
            ele.style.overflow != "visible" &&
            ele.style.overflow != "") {
            break;
        }
        offsetT += ele.offsetTop;
        offsetL += ele.offsetLeft;
        offsetT -= ele.scrollTop;
        offsetL -= ele.scrollLeft;
    }
    var a = GetPageOffset();
    var q = $("#axdiv")[0].getBoundingClientRect();
    var t = {
        Left: q.left > 0 ? q.left : 0,
        Top: q.top > 0 ? q.top : 0,
        Width: q.width,
        Height: q.height
    };
    if (q.left < 0) {
        t.Width += q.left;
        t.Width = Math.max(1, t.Width);
    }
    if (q.top < 0) {
        t.Height += q.top;
        t.Height = Math.max(1, t.Height);
    }
    if ((q.height + offsetT) > (window.innerHeight + a.y)){
        t.Height -= ((q.height + offsetT) - (window.innerHeight + a.y));
        t.Height = Math.max(1, t.Height);
    }

    if ((q.width + offsetL) > (window.innerWidth + a.x)){
        t.Width -= ((q.width + offsetL) - (window.innerWidth + a.x));
        t.Width = Math.max(1, t.Width);
    }
    t.Left *= u;
    t.Top *= u;
    t.Width *= u;
    t.Height *= u;
    // //暂时解决浏览器窗口缩放后报参数错误
    // if (t.Width < 0) {
    //     return;
    // }
    var ua = navigator.userAgent.toLocaleLowerCase();
    // console.log(t.Top,"9999999990");
    if (ua.match(/firefox/) != null) { //火狐特殊处理
        t.Top += config.BrowseMenuH;
    }
    // console.log(config.BrowseMenuH,"66666666666");
    // console.log(t.Top,"88888888");
    t.Left = Math.round(t.Left);
    t.Top = Math.round(t.Top);
    t.Width = Math.round(t.Width);
    t.Height = Math.round(t.Height);

    t.Left = Math.max(1, t.Left);
    t.Top = Math.max(1, t.Top);
    t.Width = Math.max(1, t.Width);
    t.Height = Math.max(1, t.Height);
    return t;
}


function InitBrowseFrameInfo(event) {
    // console.log(event,"传递进来的原始坐标");
    var obj={}
    if(JSON.stringify(event)==JSON.stringify(obj)){//为了解决火狐刷新之后坐标原始值丢失的问题特此处理
        event=JSON.parse(localStorage.getItem('mousePos'));
    }
    var u = GetDevicePixelRatio();
    // var u =1;
    var browseT = window.screenY || window.screenTop;
    var browseW = window.screenX || window.screenLeft;

    var BrowseW = 0;
    var BrowseH = 0;



    if (browseT < 0) {
        browseT = 0
    }
    var ua = navigator.userAgent.toLocaleLowerCase();
    if (ua.match(/firefox/) != null) { //火狐特殊处理
        browseT = parseInt(browseT * u);
        browseW = parseInt(browseW * u);
        BrowseH = parseInt(event.screenY * sessionStorage.getItem('dpiRadio')) - parseInt(event.clientY * u) - browseT;
        BrowseW = parseInt(event.screenX * sessionStorage.getItem('dpiRadio')) - parseInt(event.clientX * u) - browseW;
    }
    // console.log(BrowseH,"计算之后的坐标");
    // else{
    //     BrowseH = parseInt(event.screenY) - parseInt(event.clientY * u);
    //     BrowseW = parseInt(event.screenX) - parseInt(event.clientX * u);
    // }
    if (Math.abs(BrowseW) > parseInt(4 * u) || Math.abs(BrowseH) > parseInt(4 * u)) {
        config.BrowseMenuH = BrowseH;
        config.BrowseMenuW = BrowseW;
    }
}

$("#content").click(function(event) {
    // var event = arguments.callee.caller.arguments[0] || window.event;
    var event = event || window.event;
    if (!event && window.event) {
        event = window.event;
    }
    var mousePos = {};
    mousePos.clientX = event.clientX;
    mousePos.clientY = event.clientY;
    mousePos.screenX = event.screenX;
    mousePos.screenY = event.screenY;
    sessionStorage.setItem('mousePos', JSON.stringify(mousePos));
});

//判断浏览器 登录后复制
function getBrowsername() {
    var ua = navigator.userAgent.toLocaleLowerCase();
    if (ua.match(/firefox/) != null) {
        return "firefox.exe";
    } else if (ua.match(/ubrowser/) != null) {
        return "UCBrowser.exe";
    } else if (ua.match(/opera/) != null || ua.match(/opr/) != null) {
        return "opera.exe";
    } else if (ua.match(/edg/) != null) {
        return "msedge.exe";
    } else if (ua.match(/metasr/) != null) {
        return "SogouExplorer.exe";
    } else if (ua.match(/tencenttraveler/) != null || ua.match(/qqbrowse/) != null) {
        return "QQBrowser.exe";
    } else if (ua.match(/chrome/) != null) {
        if (checkChromeFor360()) {
            return "360se.exe";
        } else {
            return "chrome.exe";
        }
    } else if (ua.match(/safari/) != null && ua.match(/chrome/) == null) {
        return "SafariSetup.exe";
    }

}


// 检测极速内核下的360浏览器
function checkChromeFor360() {
    var uas = navigator.userAgent.split(' '),
        result = false;
    // 排除ua自带标志的双核浏览器, 余下chrome,chromium及360浏览器
    if (uas[uas.length - 1].indexOf('Safari') == -1) {
        return result;
    }
    for (var key in navigator.plugins) {
        // np-mswmp.dll文件在chromium及chrome未查询到
        if (navigator.plugins[key].filename == 'np-mswmp.dll') {
            return !result;
        }
    }
    return result;
}

/**
 * 画面比例方法
 * @param W 宽的比例
 * @param H 高的比例
 *
 */
function screenMode(W, H) { //4 3
    var axdivParentH, axdivW, axdivH;
    if ((W == 4 && H == 3) || (W == 16 && H == 9)) {

        axdivParentH = $(".play").height();
        //高度固定，算宽度
        axdivW = axdivParentH / H * W;
        //宽度固定，算高度
        axdivH = axdivParentH;
    } else {
        axdivW = "100%";
        //宽度固定，算高度
        axdivH = "100%";
    }
    if (sessionStorage.getItem("playstyle") == "WebPlayer") {
        $("#playCanvas").height(axdivH);
        $("#playCanvas").width(axdivW);
    } else {
        // $("#axdiv").height(axdivH); 这个注释是因为高度要相对父元素百分比 不能为居然值 不然会导致流的高度有问题
        $("#axdiv").width(axdivW);
        if (sessionStorage.getItem("playstyle") == "EasyVideo") {
            preWindowfollowing(false);
        }
    }


}



function enventwesoket(ml) {
    this.downloaderenventWorker = null;
    this.stream = ml;
    this.url = 'ws://' + location.hostname + ":" + config.m_HttpPort + "/WebSocket/Connect";
    this.fun = "event";
    this.initDownloaderenventWorker();
}

function useAdaptImage(width, height, containerWidth, containerHeight, widthFirst, keepAspectRatio) {
    const aspectRatio = width / height;
    let finalWidth = 0,
        finalHeight = 0;

    if (widthFirst) {
        finalWidth = width;
        if (width > containerWidth) {
            finalWidth = containerWidth;
        }
        if (keepAspectRatio) {
            finalHeight = finalWidth / aspectRatio;
            if (finalHeight > containerHeight) {
                finalHeight = containerHeight;
            }
        } else {
            finalHeight = height;
            if (height > containerHeight) {
                finalHeight = containerHeight;
            }
        }
    } else {
        finalHeight = height;
        if (height > containerHeight) {
            finalHeight = containerHeight;
        }

        if (keepAspectRatio) {
            finalWidth = finalHeight * aspectRatio;
            if (finalWidth > containerWidth) {
                finalWidth = containerWidth;
            }
        } else {
            finalWidth = width;
            if (width > containerWidth) {
                finalWidth = containerWidth;
            }
        }
    }
    return {
        width: finalWidth,
        height: finalHeight,
    };

}


/**
 * websoket线程
 */

enventwesoket.prototype.initDownloaderenventWorker = function() {
    var self = this;
    this.downloaderenventWorker = new Worker('js/components/downloaderenvent.js');
    if (this.downloaderenventWorker) {
        var obj = {};
        obj.auth = {};
        obj.auth.user = config.user;
        obj.auth.mode = "0";
        obj.auth.time = new Date().getTime().toString();
        obj.auth.pass = hex_md5(config.password + obj.auth.time);

        obj.req = {};
        obj.req.fun = this.fun;
        obj.req.ctrl = "open";
        obj.req.ch = "1";
        obj.req.stream = this.stream;
        this.downloaderenventWorker.postMessage({
            t: kGetwasmReqenvent,
            url: this.url,
            msg: obj,
            type: ""
        });
    }
    this.downloaderenventWorker.onmessage = function(evt) {
        var objData = evt.data;
        switch (objData.t) {
            case kGetwasmRspenvent:
                self.onmessageWS(objData.i);
                break;
        }
    };
};




enventwesoket.prototype.onmessageWS = function(envent) {
    if (envent.code == 200) {
        var data = JSON.parse(envent.data);
        if (data.cmd == "event") {
            if (data.body.type == "videoShade") { //视频遮挡事件
                if (data.body.param3 == 4) { //结束事件
                    $("#spzd").remove();
                } else {
                    if (!document.getElementById("spzd")) {
                        $("<img src='img/enventicon/spzd.png' id='spzd'>").appendTo("#eventnotice");
                    }
                    // $("#spzd").show();
                    var index = config.enventList.map(function(a) {
                        return a.type;
                    }).indexOf("videoShade");
                    var obj = {};
                    obj.type = "videoShade";
                    obj.time = Math.round(Date.parse(new Date()) / 1000).toString();
                    if (index == -1) { //无则添加
                        config.enventList.push(obj);
                    } else { //有则替换
                        config.enventList.splice(index, 1, obj);
                    }
                }

            } else if (data.body.type == "leavePost") { //离岗侦测事件
                if (data.body.param3 == 4) { //结束事件
                    $("#ligang").remove();
                } else {
                    if (!document.getElementById("ligang")) {
                        $("<img src='img/enventicon/ligang.png' id='ligang'>").appendTo("#eventnotice");
                    }

                    // $("#ligang").show();
                    var index = config.enventList.map(function(a) {
                        return a.type;
                    }).indexOf("leavePost");
                    var obj1 = {};
                    obj1.type = "leavePost";
                    obj1.time = Math.round(Date.parse(new Date()) / 1000).toString();
                    if (index == -1) { //无则添加
                        config.enventList.push(obj1);
                    } else { //有则替换
                        config.enventList.splice(index, 1, obj1);
                    }
                }

            } else if (data.body.type == "outOfBound") { //越界事件
                if (data.body.param3 == 4) { //结束事件
                    $("#yuejie").remove();
                } else {
                    if (!document.getElementById("yuejie")) {
                        $("<img src='img/enventicon/yuejie.png' id='yuejie'>").appendTo("#eventnotice");
                    }

                    // $("#yuejie").show();
                    var index = config.enventList.map(function(a) {
                        return a.type;
                    }).indexOf("outOfBound");
                    var obj2 = {};
                    obj2.type = "outOfBound";
                    obj2.time = Math.round(Date.parse(new Date()) / 1000).toString();
                    if (index == -1) { //无则添加
                        config.enventList.push(obj2);
                    } else { //有则替换
                        config.enventList.splice(index, 1, obj2);
                    }
                }

            } else if (data.body.type == "fenceDetectAlarm"||data.body.type == "fenceDetectAlarmV2") { //电子围栏
                if (data.body.param3 == 4) { //结束事件
                    $("#quyu").remove();
                } else {
                    if (!document.getElementById("quyu")) {
                        $("<img src='img/enventicon/quyu.png' id='quyu'>").appendTo("#eventnotice");
                    }

                    // $("#quyu").show();
                    var index = config.enventList.map(function(a) {
                        return a.type;
                    }).indexOf(data.body.type);
                    var obj3 = {};
                    obj3.type = data.body.type;
                    obj3.time = Math.round(Date.parse(new Date()) / 1000).toString();
                    if (index == -1) { //无则添加
                        config.enventList.push(obj3);
                    } else { //有则替换
                        config.enventList.splice(index, 1, obj3);
                    }
                }

            } else if (data.body.type == "motionDetection") { //移动侦测
                if (data.body.param3 == 4) { //结束事件
                    $("#yidon").remove();
                } else {
                    if (!document.getElementById("yidon")) {
                        $("<img src='img/enventicon/yidon.png' id='yidon'>").appendTo("#eventnotice");
                    }

                    // $("#yidon").show();
                    var index = config.enventList.map(function(a) {
                        return a.type;
                    }).indexOf("motionDetection");
                    var obj4 = {};
                    obj4.type = "motionDetection";
                    obj4.time = Math.round(Date.parse(new Date()) / 1000).toString();
                    if (index == -1) { //无则添加
                        config.enventList.push(obj4);
                    } else { //有则替换
                        config.enventList.splice(index, 1, obj4);
                    }
                }

            } else if (data.body.type == "faceCaptured") { //只支持人脸抓拍事件

            } else if (data.body.type == "faceRecognition") { //只支持人脸识别事件


            } else if (data.body.type == "faceRecognitionV4" || data.body.type == "strangeFace" || data.body.type == "faceComparison" || data.body.type == "faceComparisonAll") { //既支持人脸抓怕也支持人脸识别
                if (config.stopjs || config.enableelectron) { //暂停接收不再接收人脸事件或者识别按钮没开启
                    return;
                }
                if (data.body.msg.dwType == 0) { //0只显示抓拍 1识别与抓拍
                    $("#face_Analysis").hide();
                }
                var checkImage = data.body.msg.HasFaceMatchInfoV2;
                if (checkImage == "0") {
                    var snapImagePath = "img/face/bdtg.png"; //识别图
                } else {
                    var pictureData = data.body.msg.faceMatchInfoV3.faceMatchImage.picture;
                    // 检查是否有逗号分隔符和逗号后的实际数据
                    if (pictureData && pictureData.includes(',') && pictureData.split(',')[1]) {
                        snapImagePath = pictureData;
                    } else {
                        snapImagePath = "img/face/bdtg.png";
                    }
                }
                var MatchCount = data.body.msg.faceMatchInfoV3.match;
                var caputImagePath = data.body.msg.faceCaptureInfoV3.faceCaptureImage.picture; //抓拍图
                var otherface_property = {};
                otherface_property.path = data.body.msg.BackgroundInfo.HasBackground; //背景图标识
                if (MatchCount != 0) {
                    var pictureData = data.body.msg.faceMatchInfoV3.faceMatchImage.picture;
                    // 检查是否有逗号分隔符和逗号后的实际数据
                    if (pictureData && pictureData.includes(',') && pictureData.split(',')[1]) {
                        snapImagePath = pictureData;
                    } else {
                        snapImagePath = "img/face/bdtg.png";
                    }
                    otherface_property.snapImagePath = snapImagePath
                } else {
                    otherface_property.snapImagePath = "img/face/bdtg.png"
                }
                otherface_property.caputImagePath = data.body.msg.faceCaptureInfoV3.faceCaptureImage.picture;
                otherface_property.chancel = data.body.param2; //通道名
                otherface_property.time = new Date(parseInt(data.body.msg.timeSec) * 1000 + new Date()
                    .getTimezoneOffset() * 60000).Format('yyyy-MM-dd hh:mm:ss');
                otherface_property.match = data.body.msg.faceMatchInfoV3.match; //匹配度
                otherface_property.faceLibName = data.body.msg.faceMatchInfoV3.faceLibName; //脸库名称
                otherface_property.serial = data.body.msg.faceMatchInfoV3.serial; //匹配序号
                otherface_property.faceLibID = data.body.msg.faceMatchInfoV3.libID; //脸库ID
                otherface_property.faceID = data.body.msg.faceMatchInfoV3.FaceID; //人脸ID
                otherface_property.faceName = data.body.msg.faceMatchInfoV3.faceName; //人脸名称
                otherface_property.MatchCount = data.body.msg.faceMatchInfoV3.match; //比对通过不通过标志
                while (config.peopleface_detect_list.length == 50) {
                    config.peopleface_detect_list.shift(); //当等于100的时候数组清空
                    if(config.IsPushFaceFeatures==="true"){
                        $(".oneCaput").last().remove();
                    }else{
                        $(".zppeople").last().remove();
                    }
                }
                config.peopleface_detect_list.push(otherface_property);

                while (config.face_detect_list.length == 50) {
                    config.face_detect_list.shift(); //删除数组的第一个元素
                    $(".onepeopleFaceReco").last().remove(); //删除li的最后一个元素
                }
                config.face_detect_list.push(otherface_property);
                 var peopleInfo=data.body.msg.faceCaptureInfoV3.faceFeature;
                 console.log(peopleInfo);
                if (MatchCount != 0) { //比对通过
                    var facename = data.body.msg.faceMatchInfoV3.faceLibName;
                    if(config.IsPushFaceFeatures==="true"){
                        $("#face_Feature").prepend("" +
                            "<div class='oneCaput'>" +
                            "<div class='zppeople' style='background-image:url(" + caputImagePath + ");background-size: 100% 100%;'>" +
                            "</div>"+
                            "<div class='peopleInfo'>" +
                            "<div>" + $.i18n.prop('i18n-sex') +":"+ formatsex(peopleInfo.sex)  + "</div>" +
                            "<div>" + $.i18n.prop('i18n-age') +":"+ peopleInfo.age + "</div>" +
                            "<div>" +$.i18n.prop('i18n-hat') +":"+ formathat(peopleInfo.hat) + "</div>" +
                            "<div>" +$.i18n.prop('i18n-glasses') +":"+ formatglasses(peopleInfo.glasses) + "</div>" +
                            "<div>" + $.i18n.prop('i18n-mask') +":"+formatmask(peopleInfo.mask) + "</div>" +
                            "</div>" +
                            "</div>");
                    }else{
                        $("#face_Feature").prepend("<div class='zppeople'  style='background-image:url(" + caputImagePath + ");background-size: 100% 100%;'></div>");
                    }
                    $("#face_Analysis").prepend(
                        "<div class='onepeopleFaceReco'>" +
                        "<div class='peopleparent'>" +
                        "<div class='sbpeople'><img src='" + caputImagePath + "' style='width: 100%;height: 100%'></div>" +
                        "<div class='sbpeople'><img src='" + snapImagePath + "' class='" + (checkImage == "0" ? "" : "snapImageimg") + "'></div></div>" +
                        "<div class='name'>" + data.body.msg.faceMatchInfoV3.faceName + "</div>" +
                        "<div class='facegroup'><img src='img/face/facegroup.png'><span class='timeandgrouptitle'>" + facename + "</span><span class='bdresult'>" + (data.body.msg.faceMatchInfoV3.match).toFixed(2) + "%" + "</span></div>" +
                        "<div class='time'><img src='img/face/time.png'><span class='timeandgrouptitle'>" + new Date(parseInt(data.body.msg.timeSec) * 1000 + new Date().getTimezoneOffset() * 60000).Format('yyyy-MM-dd hh:mm:ss') + "</span></div>" +
                        "</div>");
                } else { //比对不通过
                    if(config.IsPushFaceFeatures==="true"){
                        $("#face_Feature").prepend("" +
                            "<div class='oneCaput'>" +
                            "<div class='zppeople' style='background-image:url(" + caputImagePath + ");background-size: 100% 100%;'>" +
                            "</div>"+
                            "<div class='peopleInfo'>" +
                            "<div>" + $.i18n.prop('i18n-sex') +":"+ formatsex(peopleInfo.sex)  + "</div>" +
                            "<div>" + $.i18n.prop('i18n-age') +":"+ peopleInfo.age + "</div>" +
                            "<div>" +$.i18n.prop('i18n-hat') +":"+ formathat(peopleInfo.hat) + "</div>" +
                            "<div>" +$.i18n.prop('i18n-glasses') +":"+ formatglasses(peopleInfo.glasses) + "</div>" +
                            "<div>" + $.i18n.prop('i18n-mask') +":"+formatmask(peopleInfo.mask) + "</div>" +
                            "</div>" +
                            "</div>");

                    }else{
                        $("#face_Feature").prepend("<div class='zppeople'  style='background-image:url(" + caputImagePath + ");background-size: 100% 100%;'></div>");
                    }
                    $("#face_Analysis").prepend(
                        "<div class='onepeopleFaceReco'>" +
                        "<div class='peopleparent'>" +
                        "<div class='sbpeople'><img src='" + caputImagePath + "' style='width: 100%;height: 100%'></div>" +
                        "<div class='sbpeople'><img src='" + snapImagePath + "'  class='" + (checkImage == "0" ? "" : "snapImageimg") + "'></div></div>" +
                        "<div class='bdnottg'>" + $.i18n.prop('i18n-noPass-thecomparison') + "</div>" +
                        "<div class='time'><img src='img/face/time.png'><span class='timeandgrouptitle'>" + new Date(parseInt(data.body.msg.timeSec) * 1000 + new Date().getTimezoneOffset() * 60000).Format('yyyy-MM-dd hh:mm:ss') + "</span></div>" +
                        "</div>");

                }
            } else if (data.body.type == "breathMask") { //口罩事件
            } else if (data.body.type == "CarLicenseCapture") { //车牌事件
                var carobj = {};
                var CaptureImage = null;
                var NumberS = null;
                var CarLicenseAttriColor = null;
                var AttriClass = null;
                var timesnmp = 0;
                if (data.body.msg.HasCaptureInfo == 1) { //表示当前有抓拍图
                    carobj.CaptureImage = data.body.msg.CaptureInfo.CarLicenseImage.picture;
                    CaptureImage = data.body.msg.CaptureInfo.CarLicenseImage.picture;
                    NumberS = data.body.msg.CaptureInfo.AttriInfo.Number;
                    AttriClass = changecarlioce(data.body.msg.CaptureInfo.AttriInfo.AttriClass);
                    CarLicenseAttriColor = changeValue(data.body.msg.CaptureInfo.AttriInfo.CarLicenseAttriColor);
                    timesnmp = $.dateFormat((data.body.msg.TimeSec - 28800) * 1000)
                } else { //表示当前没有抓拍图
                    carobj.CaptureImage = null;
                    CaptureImage = "";
                    NumberS = "";
                    AttriClass = "";
                    CarLicenseAttriColor = "";
                    timesnmp = "";
                }
                carobj.CarLicenseAttriColor = data.body.msg.CaptureInfo.AttriInfo.CarLicenseAttriColor;
                carobj.Number = data.body.msg.CaptureInfo.AttriInfo.Number;
                carobj.AttriClass = data.body.msg.CaptureInfo.AttriInfo.AttriClass;
                while (config.car_detect_list.length == 50) {
                    config.car_detect_list.shift(); //当等于100的时候数组清空
                    $(".carDinfo").last().remove();
                }
                config.car_detect_list.push(carobj);
                $("#face_Feature").prepend(
                    "<div style='display: flex;align-items: center' class='carDinfo'>" +
                    "<div class='czppeople' style='background-image:url(" + CaptureImage + ");background-size: 100% 100%;'>" +
                    "</div>"+
                    "<div class='carinfo'>" +
                    "<div>"  + $.i18n.prop("i18n-time") + ":" + timesnmp + "</div>" +
                    "<div>" + $.i18n.prop("i18n-carrnumber") + ": " + NumberS + "</div>" +
                    "<div>" + $.i18n.prop("i18n-carrtype") + ": " + AttriClass + "</div>" +
                    "<div>" + $.i18n.prop("i18n-carrcolor") + ": " + CarLicenseAttriColor +  "</div>" +
                    "</div>" +
                    "</div>");
            } else if (data.body.type == "CarLicenseSurveillance") { //布控事件
                var carobj = {};
                var CaptureImage = null;
                var NumberS = null;
                var CarLicenseAttriColor = null;
                var AttriClass = null;
                var timesnmp = 0;
                var licensePlateNumStatus = changeLicensePlateNumStatus(data.body.msg.LicensePlateNumStatus);
                if (data.body.msg.HasCaptureInfo == 1) { //表示当前有抓拍图
                    carobj.CaptureImage = data.body.msg.CaptureInfo.CarLicenseImage.picture;
                    CaptureImage = data.body.msg.CaptureInfo.CarLicenseImage.picture;
                    NumberS = data.body.msg.CaptureInfo.AttriInfo.Number;
                    AttriClass = changecarlioce(data.body.msg.CaptureInfo.AttriInfo.AttriClass);
                    CarLicenseAttriColor = changeValue(data.body.msg.CaptureInfo.AttriInfo.CarLicenseAttriColor);
                    timesnmp = $.dateFormat((data.body.msg.TimeSec - 28800) * 1000)
                } else { //表示当前没有抓拍图
                    carobj.CaptureImage = null;
                    CaptureImage = "";
                    NumberS = "";
                    AttriClass = "";
                    CarLicenseAttriColor = "";
                    timesnmp = "";
                }
                carobj.CarLicenseAttriColor = data.body.msg.CaptureInfo.AttriInfo.CarLicenseAttriColor;
                carobj.Number = data.body.msg.CaptureInfo.AttriInfo.Number;
                carobj.AttriClass = data.body.msg.CaptureInfo.AttriInfo.AttriClass;
                while (config.car_detect_list.length == 50) {
                    config.car_detect_list.shift(); //当等于100的时候数组清空
                    $(".carDinfo").last().remove();
                    $(".oneCar").last().remove();
                }
                config.car_detect_list.push(carobj);
                $("#face_Feature").prepend(
                    "<div style='display: flex;align-items: center' class='carDinfo'>" +
                    "<div class='czppeople' style='background-image:url(" + CaptureImage + ");background-size: 100% 100%;'>" +
                    "</div>"+
                    "<div class='carinfo'>" +
                    "<div>"  + $.i18n.prop("i18n-time") + ":" + timesnmp + "</div>" +
                    "<div>" + $.i18n.prop("i18n-carrnumber") + ": " + NumberS + "</div>" +
                    "<div>" + $.i18n.prop("i18n-carrtype") + ": " + AttriClass + "</div>" +
                    "<div>" + $.i18n.prop("i18n-carrcolor") + ": " + CarLicenseAttriColor +  "</div>" +
                    "</div>" +
                    "</div>");
                $("#face_Analysis").prepend("<div class='oneCar'>" +
                    "<div class='sbimgandinfo'>" +
                    "<div class='czsbppeople' style='background-image:url(" + CaptureImage + ");" +
                    "background-size: 100% auto;" +
                    "background-repeat: no-repeat;" +
                    "background-position: center center'>" +
                    "</div>" +
                    "<div class='cartype'>" + licensePlateNumStatus + "</div>" +
                    "</div>" +
                    "<div class='carinfo'><div>" + $.i18n.prop("i18n-time") + ":" + timesnmp + "</div>" +
                    "<div style='margin-top:10px'>" + $.i18n.prop("i18n-carrnumber") + ": " + NumberS + "</div>" +
                    "<div style='margin-top:10px'>" + $.i18n.prop("i18n-carrtype") + ": " + AttriClass + "</div>" +
                    "<div style='margin-top:10px'>" + $.i18n.prop("i18n-carrcolor") + ": " + CarLicenseAttriColor + "</div>" +
                    "</div></div>");
            }
        }

    }
};

function formatsex(sex) {
    var str = ""
    switch (sex) {
        case "female":
            str = $.i18n.prop("i18n-female")
            break;
        case "male":
            str = $.i18n.prop("i18n-male")
            break;
        case "unknown":
            str =  $.i18n.prop("i18n-unknown")
            break;
        default:
            str = $.i18n.prop("i18n-unknown");
            break;
    }
    return str
}
function formatglasses(glasses) {
    var str = ""
    switch (glasses) {
        case "true":
            str = $.i18n.prop("i18n-haveglasses")
            break;
        case "false":
            str = $.i18n.prop("i18n-noglasses")
            break;
        case "unknown":
            str =  $.i18n.prop("i18n-unknown")
            break;
        default:
            str = $.i18n.prop("i18n-unknown");
            break;
    }
    return str
}

function formatmask(mask) {
    var str = ""
    switch (mask) {
        case "true":
            str = $.i18n.prop("i18n-havemask")
            break;
        case "false":
            str = $.i18n.prop("i18n-nomask")
            break;
        case "unknown":
            str =  $.i18n.prop("i18n-unknown")
            break;
        default:
            str = $.i18n.prop("i18n-unknown");
            break;
    }
    return str
}

function formathat(hat) {
    var str = ""
    switch (hat) {
        case "true":
            str = $.i18n.prop("i18n-havehat")
            break;
        case "false":
            str = $.i18n.prop("i18n-nohat")
            break;
        case "unknown":
            str =  $.i18n.prop("i18n-unknown")
            break;
        default:
            str = $.i18n.prop("i18n-unknown");
            break;
    }
    return str
}
// 数据转换表示颜色表示类型
function changeValue(data) {
    var str = ""
    switch (data) {
        case 1:
            str = $.i18n.prop("i18n-color-1")
            break;
        case 2:
            str = $.i18n.prop("i18n-color-2")
            break;
        case 3:
            str = $.i18n.prop("i18n-color-3")
            break;
        case 4:
            str = $.i18n.prop("i18n-color-4")
            break;
        case 5:
            str = $.i18n.prop("i18n-color-5")
            break;
        case 6:
            str = $.i18n.prop("i18n-color-6")
            break;
        case 7:
            str = $.i18n.prop("i18n-color-7")
            break;
        case 8:
            str = $.i18n.prop("i18n-color-8")
            break;
        default:
            str = "";
            break;
    }
    return str
}

function changecarlioce(data) {
    var str = ""
    switch (data) {
        case 1:
            str = $.i18n.prop("i18n-cartype-1")
            break;
        case 2:
            str = $.i18n.prop("i18n-cartype-2")
            break;
        case 3:
            str = $.i18n.prop("i18n-cartype-3")
            break;
        case 4:
            str = $.i18n.prop("i18n-cartype-4")
            break;
        case 5:
            str = $.i18n.prop("i18n-cartype-5")
            break;
        case 6:
            str = $.i18n.prop("i18n-cartype-6")
            break;
        default:
            break;
    }
    return str
}

function changeLicensePlateNumStatus(data) {
    var str = "";
    switch (data) {
        case 0:
            str = $.i18n.prop("i18n-Unknown-license");
            break;
        case 1:
            str = $.i18n.prop("i18n-look-license");
            break;
        case 2:
            str = $.i18n.prop("i18n-Nongreen-license");
            break;
        case 3:
            str = $.i18n.prop("i18n-Yellow-license");
            break;
        case 4:
            str = $.i18n.prop("i18n-no-license");
            break;
        default:
            break;
    }
    return str
}
/**
 * xml字符串转换xml对象数据
 * @param {Object} xmlStr
 */
function xmlStr2XmlObj(xmlStr) {
    var xmlObj = {};
    if (document.all) {
        var xmlDom = new ActiveXObject("Microsoft.XMLDOM");
        xmlDom.loadXML(xmlStr);
        xmlObj = xmlDom;
    } else {
        xmlObj = new DOMParser().parseFromString(xmlStr, "text/xml");
    }
    return xmlObj;
}

/**
 * 快速入库
 * @param param
 */

function funquck(param) {
    var options = {};
    options.extData = param.caputImagePath;
    options.dataId = $("#facezhupairule").select2("val"); //脸库id
    CustomOpenModal.openDialogByData("addPeopleModal", "ipc/pages/events/addpeople.html?m=" + Math.random(), "", "添加", 1040, options);
}

/**********************************
 功能: 计算字符串的长度
 参数: szString: 输入的字符串
 ***********************************/
function JudgeTextLength(szString) {
    var iLength = 0;
    for (var i = 0; i < szString.length; i++) {
        if (szString.charCodeAt(i) > 255) {
            iLength += 2;
        } else {
            iLength += 1;
        }
    }
    return iLength
}


// 组织一周的布防时间
function group(array, subGroupLength) {
    var index = 0;
    var newArray = [];
    while (index < array.length) {
        newArray.push(array.slice(index, index += subGroupLength));
    }
    var a = newArray[0];
    newArray.push(a);
    newArray.shift();
    return newArray;
}

// 取出所有为1的时间的下标
function changetimeFool(arr) {
    var lastArr = []
    for (var i = 0; i < arr.length; i++) {
        var checkArr = []
        for (var o = 0; o < arr[i].length; o++) {
            if (arr[i][o] == "1") {
                checkArr.push(o + 1)
            }
        }
        lastArr.push(checkArr)
    }
    var realt = []
    for (var q = 0; q < lastArr.length; q++) {
        realt.push(arrange(lastArr[q]))
    }
    var lastRealt = []
    for (var j = 0; j < timeSlot(realt).length; j++) {
        lastRealt.push(timeSlot(realt)[j])
    }
    // lastRealt.push(timeSlot(realt))
    return lastRealt;
}
// 转换成连续的数组方法
function arrange(arr) {
    var result = [],
        temp = [];
    arr.sort(function(source, dest) {
        return source - dest;
    }).concat(Infinity).reduce(function(source, dest) {
        temp.push(source);
        if (dest - source > 1) {
            result.push(temp);
            temp = [];
        }
        return dest;
    });
    return result;
};
// 彻底转换为符合条件的时间段
function timeSlot(t) {
    var arr = []
    for (var a = 0; a < t.length; a++) {
        var k = t[a]
        var bigArr = [];
        for (var i = 0; i < k.length; i++) {
            var q = k[i]
            var obj = {};
            if (q[0] > 10) {
                obj.sTime = q[0] - 1 + ':00:00'
            } else if (q[0] == 1) {
                obj.sTime = '00' + ':00:00'
            } else {
                obj.sTime = '0' + (q[0] - 1) + ':00:00'
            }
            if (q[q.length - 1] > 9 && q[q.length - 1] != 23) {
                obj.eTime = q[q.length - 1] + ':00:00'
            } else if (q[q.length - 1] == 23) {
                obj.eTime = (q[q.length - 1]) + ':00:00'
            } else {
                obj.eTime = '0' + q[q.length - 1] + ':00:00'
            }
            bigArr.push(obj)
        }
        arr.push(bigArr)
    }
    return arr;
}
//将每一天的选中时间段转换为00和11
function takeZero(data) {
    var arr = []
    for (var r = 0; r < data.length; r++) {
        var v = data[r]
        var arr2 = []
        for (var p = 0; p < v.length; p++) {
            var k = v[p]
            var newArr = []
            if (k.sTime.split(':')[0] == k.eTime.split(':')[0]) {
                newArr.push(Number(k.sTime.split(':')[0]))
                newArr.push(Number(k.sTime.split(':')[0]) + 1)
            } else {
                if (Number(k.sTime.split(':')[1]) > 29) {
                    newArr.push(Number(k.sTime.split(':')[0]) + 1)
                } else {
                    newArr.push(Number(k.sTime.split(':')[0]))
                }
                if (Number(k.eTime.split(':')[1]) > 29) {
                    newArr.push(Number(k.eTime.split(':')[0]) + 1)
                } else {
                    newArr.push(Number(k.eTime.split(':')[0]))
                }
            }
            arr2.push(newArr)
        }
        arr.push(arr2)
    }
    var timeContent = []
    for (var m = 0; m < arr.length; m++) {
        var p = arr[m]
        var ctext = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24']
        for (var x = 0; x < p.length; x++) {
            var j = p[x]
            for (var i = 0; i < 24; i++) {
                if (ctext[i] > j[0] && ctext[i] < j[1]) {
                    ctext.splice(i, 1, "tt")
                } else if (ctext[i] > j[0] && ctext[i] == j[1]) {
                    ctext.splice(i, 1, "tt")
                }
            }
        }
        for (var r = 0; r < ctext.length; r++) {
            if (ctext[r] == 'tt') {
                ctext[r] = '11'
            } else {
                ctext[r] = '00'
            }
        }
        timeContent.push(ctext.join(""))
    }
    return timeContent
}

function needReboot(value) {
    var obj = {};
    var xml = '<DeviceCapInfo><DeviceCapability>' + value + '</DeviceCapability></DeviceCapInfo>'
    $.ajax({
        url: window.config.baseUrl + "/AI/DeviceNeedReboot",
        type: "POST",
        async: false,
        data: xml,
        dataType: "XML",
        timeout: 15000,
        beforeSend: function(xhr) {
            xhr.setRequestHeader("If-Modified-Since", "0");
        },
        complete: function(xmlDoc, textStatus, xhr) {
            if (sessionStorage.getItem("xystyle") == "p2p") {
                xmlDoc = atob(xmlDoc.responseJSON[0].attach.response);
                obj.isReBoot = $(xmlDoc).find('IsNeedReboot').eq(0).text();
                if (['0', '1', '2', '3'].indexOf($(xmlDoc).find('Supplementary').eq(0).text()) != -1) {
                    obj.isUpplementary = $(xmlDoc).find('Supplementary').eq(0).text();
                }
                return;
            }
            obj.isReBoot = $(xmlDoc.responseXML).find('IsNeedReboot').eq(0).text();
            if (['0', '1', '2', '3'].indexOf($(xmlDoc.responseXML).find('Supplementary').eq(0).text()) != -1) {
                obj.isUpplementary = $(xmlDoc.responseXML).find('Supplementary').eq(0).text();
            }
        },
        error: function(xhr, textStatus, errorThrown) {
            obj.isReBoot = 'true'
        }
    });
    return obj;
}
/**
 * 声音类型下拉根据能力渲染
 * @param {string} eleId - 元素id
 * @param {string} dev - 能力
 */
function soundType(eleId, dev) {
    var sylx = ['custom', 'alarm', 'dog', 'warning area', 'monitoring area', 'welcome', 'Deep Water Warning', 'Private territory', 'danger zone', 'Valuable objects', 'High Warning', 'Private Parking', 'ThankYou', 'MindPersonalBelongings', 'CatchThief', 'Help', 'Classification', 'RecyclableWaste', 'HouseholdFoodWaste', 'HazardousWaste', 'ClassificationAll', 'ResidualWaste'];
    $('#' + eleId).empty();
    var dzwlVoicetype = $(dev);
    var st = $.i18n.prop("i18n-str_voice_type").split(",")
    for (var i = 0; i < 12; i++) {
        if (dzwlVoicetype.find("Custom").text() == "true" && sylx[i] == "custom") {
            $("<option value='" + sylx[i] + "'>" + st[i] + "</option>").appendTo('#' + eleId);
        } else if (dzwlVoicetype.find("Alarm").text() == "true" && sylx[i] == "alarm") {
            $("<option value='" + sylx[i] + "'>" + st[i] + "</option>").appendTo('#' + eleId);
        } else if (dzwlVoicetype.find("dog").text() == "true" && sylx[i] == "dog") {
            $("<option value='" + sylx[i] + "'>" + st[i] + "</option>").appendTo('#' + eleId);
        } else if (dzwlVoicetype.find("warning").text() == "true" && sylx[i] == "warning area") {
            $("<option value='" + sylx[i] + "'>" + st[i] + "</option>").appendTo('#' + eleId);
        } else if (dzwlVoicetype.find("monitoring").text() == "true" && sylx[i] == "monitoring area") {
            $("<option value='" + sylx[i] + "'>" + st[i] + "</option>").appendTo('#' + eleId);
        } else if (dzwlVoicetype.find("welcome").text() == "true" && sylx[i] == "welcome") {
            $("<option value='" + sylx[i] + "'>" + st[i] + "</option>").appendTo('#' + eleId);
        } else if (dzwlVoicetype.find("DeepWater").text() == "true" && sylx[i] == "Deep Water Warning") {
            $("<option value='" + sylx[i] + "'>" + st[i] + "</option>").appendTo('#' + eleId);
        } else if (dzwlVoicetype.find("PrivateTerritory").text() == "true" && sylx[i] == "Private territory") {
            $("<option value='" + sylx[i] + "'>" + st[i] + "</option>").appendTo('#' + eleId);
        } else if (dzwlVoicetype.find("DangerZone").text() == "true" && sylx[i] == "danger zone") {
            $("<option value='" + sylx[i] + "'>" + st[i] + "</option>").appendTo('#' + eleId);
        } else if (dzwlVoicetype.find("ValuableObjects").text() == "true" && sylx[i] == "Valuable objects") {
            $("<option value='" + sylx[i] + "'>" + st[i] + "</option>").appendTo('#' + eleId);
        } else if (dzwlVoicetype.find("HighWarning").text() == "true" && sylx[i] == "High Warning") {
            $("<option value='" + sylx[i] + "'>" + st[i] + "</option>").appendTo('#' + eleId);
        } else if (dzwlVoicetype.find("PrivateParking").text() == "true" && sylx[i] == "Private Parking") {
            $("<option value='" + sylx[i] + "'>" + st[i] + "</option>").appendTo('#' + eleId);
        }
    }
    if (dzwlVoicetype.find("VideoShelter").text() == "true") { //遮挡
        $("<option value='VideoShelter'>" + $.i18n.prop("i18n-Occlusion-alarm") + "</option>").appendTo('#' + eleId);
    }
    if ($('#' + eleId).children().length == 0) { //这里是为了适配app，没有能力的时候直接给默认的三个声音类型
        $("<option value='" + sylx[0] + "'>" + st[0] + "</option>").appendTo('#' + eleId);
        $("<option value='" + sylx[1] + "'>" + st[1] + "</option>").appendTo('#' + eleId);
        $("<option value='" + sylx[2] + "'>" + st[2] + "</option>").appendTo('#' + eleId);
    }
}

// 自定义函数，将字符串编码为 iso-8859-1 字节数组
function encodeToISO88591(str) {
    if (typeof TextEncoder !== 'undefined') {
        // 现代浏览器使用 TextEncoder
        const encoder = new TextEncoder('iso-8859-1');
        return encoder.encode(str);
    } else {
        // IE 浏览器使用兼容方案
        const bytes = [];
        for (let i = 0; i < str.length; i++) {
            const charCode = str.charCodeAt(i);
            if (charCode < 256) {
                bytes.push(charCode);
            } else {
                // iso-8859-1 只支持 0 - 255 的字符编码，超出部分用 0x3F（?）替代
                bytes.push(0x3F);
            }
        }
        return new Uint8Array(bytes);
    }
}
/**
 * 试听按钮下发
 * @param {string} type - 试听类型
 * @param {string} xml - xml片段
 */
function tryListen(type, valueXml) {
    voiceXmldoc = '<?xml version="1.0" encoding="UTF-8" ?>' +
        "<AudioAlarmConfig><ChannelID>1</ChannelID>" +
        "<PeopleAudio></PeopleAudio><CarAudio></CarAudio>" +
        "<FireAudioType></FireAudioType><AudioOutputDelay></AudioOutputDelay>" +
        "<AudioVolume></AudioVolume>" +
        "<TryListenType>" + type + "</TryListenType>" +
        "<AlarmInExAudioType></AlarmInExAudioType>" +
        "<VideoShelterAudioType></VideoShelterAudioType>" +
        "<MotionAudioType></MotionAudioType>" + valueXml + "</AudioAlarmConfig>";
    var cyURL = window.config.baseUrl + "/System/1/TryListenSelectedAlarmAudioV1";
    $.ajax({
        type: "PUT",
        url: cyURL,
        processData: false,
        data: voiceXmldoc,
        beforeSend: function(xhr) {
            xhr.setRequestHeader("If-Modified-Since", "0");
        },
        complete: function(xhr, textStatus) {
            SaveState(xhr,1);
        }
    });
}


function getDeviceConfigFile() {
    console.log(config.baseUrl);
    var urlReq = '/System/DeviceConfigFile?FileType=9';
    $.ajax({
        type: "get",
        url: urlReq,
        async: false,
        success: function(result) {
            console.log("uuuuuu");
            console.log(result);
            var lines = result.split("\n");
            var message = {};
            for (var i = 0; i < lines.length; i++) {
                var line = lines[i].split("=");
                if (line.length === 2) {
                    var key = line[0].trim();
                    var value = line[1].trim();
                    message[key] = value;
                }
            }
            console.log(message);
            return message;
        },
        error: function(data) {}
    });
}

function  set3dPos(record){
    var cyXml = "<?xml version='1.0' encoding='UTF-8' ?>" +
        "<Device3DPositioningCfg>" +
        "<Operator>" + record.type + "</Operator>" +
        "<_3DPositionCoord>" +
        "<PointLeftTop>" +
        "<PosX>" + record.topLeft.x  + "</PosX>"+
        "<PosY>" + record.topLeft.y + "</PosY>"+
        "</PointLeftTop>" +
        "<PointRightTop>" +
        "<PosX>" + record.topRight.x + "</PosX>"+
        "<PosY>" + record.topRight.y + "</PosY>"+
        "</PointRightTop>" +
        "<PointRightBottom>" +
        "<PosX>" + record.bottomLeft.x + "</PosX>"+
        "<PosY>" + record.bottomLeft.y + "</PosY>"+
        "</PointRightBottom>" +
        "<PointLeftBottom>" +
        "<PosX>" + record.bottomRight.x + "</PosX>"+
        "<PosY>" + record.bottomRight.y + "</PosY>"+
        "</PointLeftBottom>" +
        "<PointCenter>" +
        "<PosX>" + record.centerPoint.x + "</PosX>"+
        "<PosY>" + record.centerPoint.y + "</PosY>"+
        "</PointCenter>" +
        "</_3DPositionCoord>" +
        "</Device3DPositioningCfg>";

    var cyURL = config.baseUrl + "/System/Device3DPositioningCfg";
    $.ajax({
        type: "PUT",
        url: cyURL,
        async: false,
        processData: false,
        data: cyXml,
        beforeSend: function(xhr) {
            xhr.setRequestHeader("If-Modified-Since", "0");
        },
        complete: function(xhr, textStatus) {
            SaveState(xhr);
        }
    });
}
