define(function(require, exports, module) {
    require('countdown');
	var global = require("../../js/global");
	var jGlobal = require("./oneUpgradeGlobal");
	var oneAcUpgrade = window.require("../../common/js/oneAcUpgrade");
	
	//当前页面变量
//	var upgradeTableLength = null;
	var oneAcUpgradeIns = null;
	var userClickRowArray = [];
	var binPath = [];		//[{type:"acBin", src:"", dst:""}, {type:"apBin", src:"1.bin", dst:""},  {type:"apBin", src:"2.bin", dst:""}, ……, {type:"midBin", src:"", dst:""}, ……]
	var isImport = false; 	//进入下一页面前判断用户是否已导入或下载了bin
	var showModalId = "#selectBinFor10x"; //现在可以不用判断,但这里延续之前的,避免过多的改动
	var curAcName = null;
	var isGotoNextPage = false; //是否已点击下一步

    var MIDBIN = "cloud-10x-mid-bin";   //存放云端下载的10.x ac和10.x ap的升级bin
    var ACBIN = "cloud-11x-ac-bin";		//存放云端下载的11.x ac的升级bin
    var APBIN = "cloud-11x-ap-bin";		//存放云端下载的11.x ap的升级bin
	
	function showUpgradeDeviceTable() {
		// console.error(jGlobal.oneUpgrade.multiDevRcmndVersion);
		var selectDevInfos = [];
		for (var key in jGlobal.oneUpgrade.multiDevRcmndVersion) {
			selectDevInfos.push(global.devicesIns.getDeviceInfoByDeviceName(key));
		}
//		console.error(selectDevInfos);
		
		jGlobal.oneUpgrade.upgradeDevInfos = [];
		for (var i = 0; i < selectDevInfos.length; i++) {
			var flag = false;
			for (var j = 0; j < jGlobal.oneUpgrade.upgradeDevInfos.length; j++) {				
				var tmpRecmndVersion = jGlobal.oneUpgrade.upgradeDevInfos[j].recmndVersion;
				if (tmpRecmndVersion != null && tmpRecmndVersion != '' && tmpRecmndVersion != '-') {
					if (jGlobal.oneUpgrade.multiDevRcmndVersion[selectDevInfos[i].deviceName].softwareVersion == tmpRecmndVersion) {
						flag = true;
						jGlobal.oneUpgrade.upgradeDevInfos[j].deviceName = "-";
						jGlobal.oneUpgrade.upgradeDevInfos[j].deviceNum++;
						jGlobal.oneUpgrade.upgradeDevInfos[j].deviceNames.push(selectDevInfos[i].deviceName);
						break;
					}
				}
			}
			if (flag == false) {
				var tmp_upgradeDevInfos = {};
				tmp_upgradeDevInfos.deviceNames = [];
				tmp_upgradeDevInfos.deviceNames.push(selectDevInfos[i].deviceName);

				tmp_upgradeDevInfos.deviceName = selectDevInfos[i].deviceName;
				tmp_upgradeDevInfos.deviceModel = selectDevInfos[i].deviceModel;
				tmp_upgradeDevInfos.hardVer = selectDevInfos[i].hardVer;
				tmp_upgradeDevInfos.softVer = selectDevInfos[i].softVer;
				tmp_upgradeDevInfos.recmndVersion = jGlobal.oneUpgrade.multiDevRcmndVersion[selectDevInfos[i].deviceName].softwareVersion;			
				tmp_upgradeDevInfos.deviceNum = 1;
				tmp_upgradeDevInfos.recmndVersionMsg = jGlobal.oneUpgrade.multiDevRcmndVersion[selectDevInfos[i].deviceName];
				jGlobal.oneUpgrade.upgradeDevInfos.push(tmp_upgradeDevInfos);
			}
		}
//		upgradeTableLength = jGlobal.oneUpgrade.upgradeDevInfos.length;
//		console.error(jGlobal.oneUpgrade.upgradeDevInfos);
		
		curAcName = jGlobal.oneUpgrade.upgradeDevInfos[0].deviceName;

		// 从云端获取推荐版本并显示在表格中
        var sessionId = global.userMgrIns.getUserInfo().sessionId;
        var selectAc = jGlobal.oneUpgrade.upgradeDevInfos;
        var params = [];
        for (var i = 0; i < selectAc.length; i++) {
            var tmp = {};
            tmp.deviceType = selectAc[i].deviceModel;
            tmp.hardwareVersion = selectAc[i].hardVer;
            if (jGlobal.oneUpgrade.isOperators) {
                tmp.versionType = "C";
            } else {
                tmp.versionType = "normal";
            }
            var softVer = selectAc[i].softVer;
            if (softVer.match(/mid/i) != null) {
                tmp.softwareVersion = "10.x";
            } else if (softVer.indexOf("10.") != -1) {
                tmp.softwareVersion = "10.x";
            } else if (softVer.indexOf("11.") != -1) {
                tmp.softwareVersion = "11.x";
            }
            params.push(tmp);
        }

        oneAcUpgradeIns = new oneAcUpgrade(global.devicesIns, false);
        oneAcUpgradeIns.getCloudRecommendInfo(sessionId, params, function(err, res) {
            console.log('AC的推荐版本的info.ini信息: ', res);

            // 有版本下载失败，err不为null
            if (err == null && res != null && res.info11ac != null) {
                selectAc[0].recommendVer = res.info11ac.versions[0].versionCode;
            }

            $('#table_acSelect').bootstrapTable('load', selectAc);
        });
	}

	function checkboxFormatter(value, row, index) {
	    if (row.softVer == row.recommendVer) {
            $("#acInfoDiv .noNeedUpgradeTip").text(' (当前AC版本与云端推荐版本一致，无需升级！) ');
            return {
                disabled : true
            }
        } else {
            $("#acInfoDiv .noNeedUpgradeTip").text('');
            return {
                disabled : false,
                checked : true
            };
        }
    }

    function apCheckboxFormatter(value, row, index) {
    	return {
            checked : true
        };
    }
	
	function recmndVersionShow(value, row, index) {
		if (row.recmndVersion == undefined) {
			return;
		}

	    if (row.recmndVersion == "下载完成" || row.recmndVersion == "文件已存在") {
	    	return '<span style="color:#0cc757;">' + row.recmndVersion + '</span>';
	    } else if (row.recmndVersion == "下载失败" || row.recmndVersion == "md5校验失败") {
	    	return '<span style="color:#f5224c;">' + row.recmndVersion + '</span>';
	    } else {
	    	return '<span>' + row.recmndVersion + '</span>';
	    }
	}
	
	function upgradeVerShow(value, row, index) {
		if (row.upgradeVer == undefined) {
			return;
		}

	    if (row.upgradeVer.indexOf('完成') != -1 || row.upgradeVer.indexOf('存在') != -1 || row.upgradeVer.indexOf('成功') != -1) {
	    	return '<span style="color:#0cc757;">' + row.upgradeVer + '</span>';
	    } else if (row.upgradeVer.indexOf('失败') != -1) {
	    	return '<span style="color:#f5224c;">' + row.upgradeVer + '</span>';
	    } else if (row.upgradeVer.indexOf('…') != -1) {
	    	return '<span>' + row.upgradeVer + '</span>';
	    }
	}
	
//	function operateForUpgradeTable() {
//	    return '<div>' +
//	                '<div class="table-btn select" style="float: right; width: 75px;">本地导入</div>' +
////	                '<div class="table-btn download" style="float: left; width: 75px; margin-left: 5px;">云端下载</div>' +
//	           '</div>';
//	}
	
	//导入ac的bin(只能单选)
	function importAcBin() {
		var import_acBin = $('#selectAcBin');
		import_acBin.unbind('change');
		import_acBin.change(function(evt) {
			//每次用户重新选择都需要删除原来的值
	    	var tmp_binPath = [];
	    	for (var i = 0; i < binPath.length; i++) {
	    		if (binPath[i].type != "acBin") {
	    			tmp_binPath.push(binPath[i]);
	    		}
	    	}
	    	binPath = [];
	    	binPath = tmp_binPath;
	    	
	    	//重新添加上本次选择的路径
	    	var path = $(this).val();
	    	var pathArr = path.split('\\');
	    	var fileName = pathArr[pathArr.length - 1];
	    	var tmp = {};
			tmp.type = "acBin";
			tmp.src = path;				
			tmp.dst = global.nwPath.resolve(global.jsUtil.getDataPath(), "upgradeInfo", global.nwPath.parse(path).name);
			binPath.push(tmp);
			$(showModalId + " #acImportText").val(fileName);
			
	        $(this).val("");
	    });
		import_acBin.trigger('click');
	}
	
	//导入ap的bin(可多选)
	function importApBin() {
		var import_apBin = $('#selectApBin');
		import_apBin.unbind('change');
		import_apBin.change(function(evt) {
			//每次用户重新选择都需要删除原来的值
	    	var tmp_binPath = [];
	    	for (var i = 0; i < binPath.length; i++) {
	    		if (binPath[i].type != "apBin") {
	    			tmp_binPath.push(binPath[i]);
	    		}
	    	}
	    	binPath = [];
	    	binPath = tmp_binPath;
	    	
//	    	//重新添加上本次选择的路径
	    	var path = $(this).val();
	    	var pathArr = path.split(';');
	    	var fileNameText = '';
	    	for (var i = 0; i < pathArr.length; i++) {
	    		fileNameText += global.nwPath.parse(pathArr[i]).base + ';';
	    		
	    		var tmp = {};
				tmp.type = "apBin";
				tmp.src = pathArr[i];
				tmp.dst = global.nwPath.resolve(global.jsUtil.getDataPath(), "upgradeInfo", global.nwPath.parse(pathArr[i]).name);
				binPath.push(tmp);
	    	}			
			$(showModalId + " #apImportText").val(fileNameText);
			
	        $(this).val("");
	    });
		import_apBin.trigger('click');
	}
	
	//导入中间版本的bin(只能单选)
	function importCenterBin() {
		var import_centerBin = $('#selectCenterBin');
		import_centerBin.unbind('change');
		import_centerBin.change(function(evt) {
			//每次用户重新选择都需要删除原来的值
	    	var tmp_binPath = [];
	    	for (var i = 0; i < binPath.length; i++) {
	    		if (binPath[i].type != "midBin") {
	    			tmp_binPath.push(binPath[i]);
	    		}
	    	}
	    	binPath = [];
	    	binPath = tmp_binPath;
	    	
	    	//重新添加上本次选择的路径
	    	var path = $(this).val();
	    	var pathArr = path.split('\\');
	    	var file_Name = pathArr[pathArr.length - 1];
	    	var tmp = {};
			tmp.type = "midBin";
			tmp.src = path;				
			tmp.dst = global.nwPath.resolve(global.jsUtil.getDataPath(), "upgradeInfo", global.nwPath.parse(path).name);
			binPath.push(tmp);
			$("#centerImportText").val(file_Name);
			
	        $(this).val("");
	    });
		import_centerBin.trigger('click');
	}
	
	function showUpgradeApInfo() {
		var apInfo = jGlobal.oneUpgrade.apInfo;
		var apArray = [];
		
		for (var i = 0; i < apInfo.length; i++) {
			var tmp = {};
			tmp.apDeviceModel = apInfo[i].name;
			tmp.apHardver = apInfo[i].hw_ver;
			tmp.apSoftver = apInfo[i].soft_ver;
			tmp.apDeviceNum = apInfo[i].num;
			if (apInfo[i].name != '') { //有时候会出现设备型号为空的情况...
				apArray.push(tmp);
			}
		}

        apGetCloudRecommendInfo(apArray);
	}
	
	function apGetCloudRecommendInfo(apArray) {
        // 从云端获取推荐版本并显示在表格中
        var sessionId = global.userMgrIns.getUserInfo().sessionId;
        var params = [];
        for (var i = 0; i < apArray.length; i++) {
            var tmp = {};
            tmp.deviceType = apArray[i].apDeviceModel;
            tmp.hardwareVersion = apArray[i].apHardver;
            if (jGlobal.oneUpgrade.isOperators) {
                tmp.versionType = "C";
            } else {
                tmp.versionType = "normal";
            }
            tmp.softwareVersion = apArray[i].apSoftver;
            params.push(tmp);
        }

        oneAcUpgradeIns = new oneAcUpgrade(global.devicesIns, false);
        oneAcUpgradeIns.getCloudRecommendInfo(sessionId, params, function(err, res) {
            console.log('AP的推荐版本的info.ini信息: ', res);

            // 有版本下载失败，err不为null
            if (err == null && res != null && res.info11ap != null) {
                var versions = res.info11ap.versions;
                for (var k = 0; k < apArray.length; k++) {
                    for (var i = 0; i < versions.length; i++) {
                        var deviceTypes = versions[i].deviceTypes;
                        for (var j = 0; j < deviceTypes.length; j++) {
                            var deviceType = deviceTypes[j];
                            if (apArray[k].apDeviceModel.toLocaleLowerCase() == deviceType.name.toLocaleLowerCase() && global.jsUtil.matchHwVer(apArray[k].apHardver, deviceType.hwVer)) {
                                apArray[k].apRecommendVer = versions[i].versionCode;

                                i = versions.length;
                                j = deviceTypes.length;
                            }
                        }
                    }
                }
            }

            $('#table_apSelect').bootstrapTable('load', apArray);
        });
    }
	
	function cancelUnzip() {
		oneAcUpgradeIns.cancelUnzipBinFile(); //这里这个instance与解压的instance是同一个实例
		
		$("#table_acSelect").bootstrapTable('updateRow', {
        	index: 0,
        	row: {
        		upgradeVer: "解压失败"
        	}
        });
		
		$("#dlg_unzip").modal('hide');
	}
	
	function getAndShowApInfo(devName) {
		var apCmdList = [];
		var _10xApList = [];
		var _11xApList = [];
		
		var apCmd1 = {name:'config', value: function() {}, args:''};
		apCmdList.push(apCmd1);
		var apCmd2 = {name:'no wlan diag enable', value: function() {}, args:''};
		apCmdList.push(apCmd2);
		var apCmd3 = {name:'wlan diag enable', value: function() {}, args:''};
		apCmdList.push(apCmd3);
		var apCmd4 = {name:'end', value: function() {}, args:''};
		apCmdList.push(apCmd4);
		
    	var apCmd5 = {name:'show ap-config product', value: function(res) { //11x ap的信息
    		_11xApList = parseApInfo(res, "11.x");
    	}, args:''};
    	apCmdList.push(apCmd5);
    	var apCmd6 = {name:'show ap-config rgos10-ap-list', value: function(res) { //10x ap的信息
    		_10xApList = parseApInfo(res, "10.x");
    		jGlobal.oneUpgrade.apInfo = _11xApList.concat(_10xApList);
    		console.error("所有的ap信息为: ", jGlobal.oneUpgrade.apInfo);
    		
    		$("#getApInfoModal").modal('hide');
    		setTimeout(function() {
    			showUpgradeApInfo();
    		}, 300);
    	}, args:''};
    	apCmdList.push(apCmd6);
    	global.devicesIns.execCmdList(devName, apCmdList);
	}
	
	//解析命令返回的ap信息并存储
	function parseApInfo(res, version) {		
		var resArr = res.split(/\r?\n/g);
		var apInfoStartIndex = 0;
		var apInfo = [];
		var apInfoFilter = [];
		
		for (var i = 1; i <= resArr.length - 2; i++) {
			if (resArr[i].match(/^-+\s+-+/) != null) {
				apInfoStartIndex = i + 1;	//从----- ----行起下一行到倒数第二行是当前上线ap的信息
				break;
			}
		}
		
		for (var i = apInfoStartIndex; i <= resArr.length - 2; i++) {
			var tmp_apInfo = {};
			var resField = resArr[i].split(/\s{2,}/g);
			tmp_apInfo.name = resField[0];
			tmp_apInfo.hw_ver = resField[1];
			tmp_apInfo.soft_ver = version;
			tmp_apInfo.num = resField[2];
			apInfo.push(tmp_apInfo);
		}
		
		//剔除数组中相同的项(这里好像并不会重复)	
		for (var i = 0; i < apInfo.length; i++) {
			var exist = false;
			for (var j = 0; j < apInfoFilter.length; j++) {
				if (apInfo[i].name == apInfoFilter[j].name && apInfo[i].hw_ver == apInfoFilter[j].hw_ver) {
					exist = true;
					break;
				}
			}
			if (exist == false) {
				apInfoFilter.push(apInfo[i]);
			}
		}
		
		return apInfoFilter;
	}
	
	function alertGotoNextPage() {
		alert(undefined, "是否开始升级？", function() {
			//进入升级页面
			var curElement = ".main_content", nextPageUrl = "./oneUpgrade/html/acUpgrading.html";
			global.enterPageCallback(curElement, nextPageUrl);
		}, true, function() {
			isGotoNextPage = false;
		});
	}
	
	function isOnlyChoose11xAp(selectAp) {
		var flag = true;
		for (var i = 0; i < selectAp.length; i++) {
			if (selectAp[i].apSoftver == '10.x') {
				flag = false;
				break;
			}
		}
		return flag;
	}

	// 为了和本地导入统一流程，云端下载完成后也构造一个binPath
	function formatBinPathAfterDownload() {
        var midBinPath = global.nwPath.join(global.jsUtil.getDataPath(), '/upgradeInfo/' + MIDBIN);
        var acBinPath = global.nwPath.join(global.jsUtil.getDataPath(), '/upgradeInfo/' + ACBIN);
        var apBinPath = global.nwPath.join(global.jsUtil.getDataPath(), '/upgradeInfo/' + APBIN);

        var midBinInfo = {};
        midBinInfo.dst = midBinPath;
        midBinInfo.src = MIDBIN;
        midBinInfo.type = "midBin";
        binPath.push(midBinInfo);

        var acBinInfo = {};
        acBinInfo.dst = acBinPath;
        acBinInfo.src = ACBIN;
        acBinInfo.type = "acBin";
        binPath.push(acBinInfo);

        var apBinInfo = {};
        apBinInfo.dst = apBinPath;
        apBinInfo.src = APBIN;
        apBinInfo.type = "apBin";
        binPath.push(apBinInfo);
    }
    
    function checkBeforeUpgrade() {
        // if (!isImport) {
        //     // alert(undefined, "还未成功下载或导入升级包，请先下载或导入！");
        //     alert(undefined, "还未下载升级包，请先下载！");
        //     return;
        // }
        console.log(binPath);

        // //通过本地导入的,检查是否导入了所有需要的升级包
        // var selectAc = $("#table_acSelect").bootstrapTable('getSelections');
        // var selectAp = $("#table_apSelect").bootstrapTable('getSelections');
        // var isImportAcBin = false;
        // var isImportApBin = false;
        // var isImportMidBin = false;
        // for (var i = 0; i < binPath.length; i++) {
        // 	if (binPath[i].type == "acBin") {
        // 		isImportAcBin = true;
        // 	} else if (binPath[i].type == "apBin") {
        // 		isImportApBin = true;
        // 	} else if (binPath[i].type == "midBin") {
        // 		isImportMidBin = true;
        // 	}
        // }
        // if (jGlobal.oneUpgrade.originAcVersion == "10.") { //AC是10x版本,只升级AC,需要中间版本和AC的最终版本
        // 	if (isImportAcBin == false || isImportMidBin == false) {
        // 		alert(undefined, "请导入AC中间版本和最终版本的升级包！");
        // 		return;
        // 	}
        // }
        // if (jGlobal.oneUpgrade.originAcVersion == "mid") { //AC是11x mid版本,只升级AC,需要AC的最终版本
        // 	if (isImportAcBin == false) {
        // 		alert(undefined, "请导入AC最终版本的升级包！");
        // 		return;
        // 	}
        // }
        // if (jGlobal.oneUpgrade.originAcVersion == "11.") { //AC是11x版本.
        // 	if (selectAc.length != 0 && selectAp.length == 0) { //只升级AC:需要AC的最终版本
        // 		if (isImportAcBin == false) {
        // 			alert(undefined, "请导入AC最终版本的升级包！");
        // 			return;
        // 		}
        //
        // 		jGlobal.oneUpgrade.onlyUpgradeAc = true;
        // 		jGlobal.oneUpgrade.onlyUpgradeAp = false;
        // 	} else if (selectAc.length == 0 && selectAp.length != 0) { //只升级AP:需要AP的中间版本和最终版本
        // 		var result = isOnlyChoose11xAp(selectAp);
        // 		if (result) {
        // 			if (isImportApBin == false) {
        // 				alert(undefined, "请导入AP最终版本的升级包！");
        // 				return;
        // 			}
        // 		} else {
        // 			if (isImportApBin == false || isImportMidBin == false) {
        // 				alert(undefined, "请导入AP的中间版本和最终版本的升级包！");
        // 				return;
        // 			}
        // 		}
        //
        // 		jGlobal.oneUpgrade.onlyUpgradeAc = false;
        // 		jGlobal.oneUpgrade.onlyUpgradeAp = true;
        // 	} else if (selectAc.length != 0 && selectAp.length != 0) { //同时升级AC和AP:需要中间版本和AC、AP的最终版本
        // 		var result = isOnlyChoose11xAp(selectAp);
        // 		if (result) {
        // 			if (isImportAcBin == false || isImportApBin == false) {
        // 				alert(undefined, "请导入AC的最终版本和AP最终版本的升级包！");
        // 				return;
        // 			}
        // 		} else {
        // 			if (isImportAcBin == false || isImportApBin == false || isImportMidBin == false) {
        // 				alert(undefined, "请导入中间版本、AC的最终版本和AP的最终版本的升级包！");
        // 				return;
        // 			}
        // 		}
        //
        // 		jGlobal.oneUpgrade.onlyUpgradeAc = false;
        // 		jGlobal.oneUpgrade.onlyUpgradeAp = false;
        // 	} else if (selectAc.length == 0 && selectAp.length == 0) {
        // 		alert(undefined, "请选择待升级的AC或AP！");
        // 		return;
        // 	}
        // }

        var selectAc = $("#table_acSelect").bootstrapTable('getSelections');
        var selectAp = $("#table_apSelect").bootstrapTable('getSelections');
        if (selectAc.length != 0 && selectAp.length == 0) {
            jGlobal.oneUpgrade.onlyUpgradeAc = true;
            jGlobal.oneUpgrade.onlyUpgradeAp = false;
        } else if (selectAc.length == 0 && selectAp.length != 0) {
            jGlobal.oneUpgrade.onlyUpgradeAc = false;
            jGlobal.oneUpgrade.onlyUpgradeAp = true;
        } else if (selectAc.length != 0 && selectAp.length != 0) {
            jGlobal.oneUpgrade.onlyUpgradeAc = false;
            jGlobal.oneUpgrade.onlyUpgradeAp = false;
        } else { // 现在的流程正常应该不会出现这种情况
            alert(undefined, "升级出现异常！未选择待升级的AC或AP！");
            return;
        }

        //保存下一个页面要用到的升级变量(结构参考oneUpgradeGlobal.js中的例子)
        jGlobal.oneUpgrade.upgradeAcFor11x = [];
        jGlobal.oneUpgrade.upgradeApFor11x = [];
        jGlobal.oneUpgrade.upgradeAcFor10x = [];
        jGlobal.oneUpgrade.upgradeApFor10x = [];
        var tmpUpgradeAcFor11x = {};
        var tmpUpgradeApFor11x = {};
        var tmpUpgradeAcFor10x = {};
        var tmpUpgradeApFor10x = {};
        tmpUpgradeApFor11x.unzipDir = [];
        tmpUpgradeApFor11x.apType = [];
        tmpUpgradeApFor10x.unzipDir = [];
        tmpUpgradeApFor10x.apType = [];

        tmpUpgradeAcFor11x.deviceName = curAcName;
        tmpUpgradeAcFor10x.deviceName = curAcName;
        tmpUpgradeApFor11x.deviceName = curAcName;
        tmpUpgradeApFor10x.deviceName = curAcName;
        for (var i = 0; i < binPath.length; i++) {
            var unzipDir = global.nwPath.parse(binPath[i].src).name;
            if (binPath[i].type == "acBin") {
                tmpUpgradeAcFor11x.unzipDir = unzipDir;
            } else if (binPath[i].type == "apBin") {
                tmpUpgradeApFor11x.unzipDir.push(unzipDir);
            } else if (binPath[i].type == "midBin") {
                tmpUpgradeAcFor10x.unzipDir = unzipDir;
                tmpUpgradeApFor10x.unzipDir.push(unzipDir);
            }
        }
        for (var i = 0 ; i < selectAp.length; i++) {
            var tmp = {};
            tmp.name = selectAp[i].apDeviceModel;
            tmp.hw_ver = selectAp[i].apHardver;
            tmp.cnt = parseInt(selectAp[i].apDeviceNum);
            tmpUpgradeApFor11x.apType.push(tmp);
            if (selectAp[i].apSoftver == "10.x") {
                tmpUpgradeApFor10x.apType.push(tmp);
            }
        }

        //对于11.x的ap参数,如果10.x和11.x的ap设备型号、硬件版本号相同,需要合并起来统计个数
        var filterUpgradeApFor11x = {};
        filterUpgradeApFor11x.deviceName = tmpUpgradeApFor11x.deviceName;
        filterUpgradeApFor11x.unzipDir = tmpUpgradeApFor11x.unzipDir;
        filterUpgradeApFor11x.apType = [];
        for (var i = 0; i < tmpUpgradeApFor11x.apType.length; i++) {
            var flag = false;
            var apType = tmpUpgradeApFor11x.apType[i];
            for (var j = 0; j < filterUpgradeApFor11x.apType.length; j++) {
                var filterApType = filterUpgradeApFor11x.apType[j];
                if (apType.hw_ver + apType.name == filterApType.hw_ver + filterApType.name) {
                    flag = true;
                    filterApType.cnt = parseInt(filterApType.cnt) + parseInt(apType.cnt);
                    break;
                }
            }
            if (!flag) {
                var tmp = {};
                tmp.name = apType.name;
                tmp.hw_ver = apType.hw_ver;
                tmp.cnt = apType.cnt;
                filterUpgradeApFor11x.apType.push(tmp);
            }
        }

        jGlobal.oneUpgrade.upgradeAcFor11x.push(tmpUpgradeAcFor11x);
        jGlobal.oneUpgrade.upgradeApFor11x.push(filterUpgradeApFor11x);
        jGlobal.oneUpgrade.upgradeAcFor10x.push(tmpUpgradeAcFor10x);
        jGlobal.oneUpgrade.upgradeApFor10x.push(tmpUpgradeApFor10x);

        console.log("待升级的11.xac参数： ", jGlobal.oneUpgrade.upgradeAcFor11x);
        console.log("待升级的11.xap参数： ", jGlobal.oneUpgrade.upgradeApFor11x);
        console.log("待升级的10.xac参数： ", jGlobal.oneUpgrade.upgradeAcFor10x);
        console.log("待升级的10.xap参数： ", jGlobal.oneUpgrade.upgradeApFor10x);

        /* 保存上传云端的数据 */
        // 升级前ac信息
        var acData = $("#table_acSelect").bootstrapTable('getData');
        var devInfo = global.devicesIns.getDeviceInfoByDeviceName(acData[0].deviceName);
        var preAcInfoTmp = {};
        preAcInfoTmp.deviceName = acData[0].deviceName;
        preAcInfoTmp.deviceModel = acData[0].deviceModel;
        preAcInfoTmp.hardVer = acData[0].hardVer;
        preAcInfoTmp.softVer = acData[0].softVer;
        preAcInfoTmp.deviceSn = devInfo.seriaNo;
        preAcInfoTmp.customer = devInfo.customer;
        preAcInfoTmp.subGroup = devInfo.subGroup;
        preAcInfoTmp.otherInfo = global.devicesIns.getStoreData(devInfo);
        jGlobal.oneUpgrade.uploadInfo.preAcInfo = [];
        jGlobal.oneUpgrade.uploadInfo.preAcInfo.push(preAcInfoTmp);

        //升级前ap信息
        jGlobal.oneUpgrade.uploadInfo.preApInfo = [];
        for (var i = 0; i < selectAp.length; i++) {
            var preApInfoTmp = {};
            preApInfoTmp.deviceModel = selectAp[i].apDeviceModel;
            preApInfoTmp.hardVer = selectAp[i].apHardver;
            preApInfoTmp.softVer = selectAp[i].apSoftver;
            preApInfoTmp.num = parseInt(selectAp[i].apDeviceNum);
            jGlobal.oneUpgrade.uploadInfo.preApInfo.push(preApInfoTmp);
        }

        /* 如果工具与设备的连接还未断开,则断开设备;否则直接进入升级页面 */
        if (jGlobal.oneUpgrade.multiDevConnectStatus[curAcName] == 'init' || jGlobal.oneUpgrade.multiDevConnectStatus[curAcName] == 'closing') {
            // alertGotoNextPage();

            //进入升级页面
            var curElement = ".main_content", nextPageUrl = "./oneUpgrade/html/acUpgrading.html";
            global.enterPageCallback(curElement, nextPageUrl);
        } else if (jGlobal.oneUpgrade.multiDevConnectStatus[curAcName] == 'connecting' || jGlobal.oneUpgrade.multiDevConnectStatus[curAcName] == 'connected') {
            isGotoNextPage = true;
            jGlobal.oneUpgrade.multiDevConnectStatus[curAcName] = jGlobal.changeDevStatus(curAcName, jGlobal.oneUpgrade.multiDevConnectStatus[curAcName], 'closing');
            global.devicesIns.closeDeviceLink(curAcName);
        }
    }
	
	function init() {
		initWindowEvent();
		initPageStatistic();
		initVariable();
		removeGlobalEvent();
		initDom();
		initTable();
		initEvent();
		resize();
		initGlobalEvent();
		
		function initWindowEvent() {
//			window.operateForUpgradeTable = operateForUpgradeTable;
			window.upgradeVerShow = upgradeVerShow;
			window.recmndVersionShow = recmndVersionShow;
            window.checkboxFormatter = checkboxFormatter;
            window.apCheckboxFormatter = apCheckboxFormatter;
//			window.operateEventsForUpgrade = {
//				'click .select': function (e, value, row, index) {
//			    	$(showModalId).modal('show');
//			    },
//			    'click .download': function (e, value, row, index) {
//			    	downloadVersionFromCloud(row, index);
//			    } 
//			};
			window.cancelUnzip = cancelUnzip;
		}
		function initPageStatistic() {
			statRecordEle("oneUpgrade#acSelectVersion");
		}
		function initVariable() {
//			upgradeTableLength = null;
			oneAcUpgradeIns = null;
			userClickRowArray = [];
			binPath = [];
			isImport = false;
			showModalId = "#selectBinFor10x";
			curAcName = null;
			isGotoNextPage = false;
			jGlobal.oneUpgrade.onlyUpgradeAc = false;
			jGlobal.oneUpgrade.onlyUpgradeAp = false;
		}
		function removeGlobalEvent() {
			global.devicesIns.removeAllListeners("deviceConnected");
			global.devicesIns.removeAllListeners("deviceError");
			global.devicesIns.removeAllListeners("deviceDisconnected");
			
//			global.oneUpgradeIns.reg();
		}
		function initTable() {
			//显示待升级的ac设备
			$('#table_acSelect').bootstrapTable({
		        data: []
		    });
			$("#table_acSelect").show();
			
			showUpgradeDeviceTable();
			
			//显示待升级的ap设备
			jGlobal.oneUpgrade.multiDevConnectStatus[curAcName] = "init";
			
			$('#table_apSelect').bootstrapTable({
		        data: []
		    });
			
			$(".fixed-table-body").addClass('custom-scroll');
			$("#table_apSelect").show();
			
			showUpgradeApInfo();
		}
		function initEvent() {
			$("#yesOperator").click(function() {
				jGlobal.oneUpgrade.isOperators = true;
				console.log("用户选择了mid是中间版本");
			});
			
			$("#noOperator").click(function() {
				jGlobal.oneUpgrade.isOperators = false;
				console.log("用户选择了mid不是中间版本");
			});
			
			$(".back").click(function() {
//				$(".main_content").load("./oneUpgrade/html/selectDevice.html");
				
				var curElement = ".main_content", nextPageUrl = "./oneUpgrade/html/oneUpgradeMenu.html";
				global.enterPageCallback(curElement, nextPageUrl);
			});
			
			$("#gotoUpgrade").click(function() {
			    $("#cloudDownload").trigger('click');
			});
			
			/* 本地导入 */
			$("#loaclImport").click(function() {
				$(showModalId).modal('show');
			});
			
			$(showModalId + " #acImport").click(function() {
				importAcBin();
			});
			
			$(showModalId + " #apImport").click(function() {
				importApBin();
			});
			
			$("#centerImport").click(function() {
				importCenterBin();
			});
			
			$(showModalId + " #importBin").click(function() {
				console.log("升级包的解压路径: ", binPath);

				//输入合法性判断
				var flag = true;
//				var selector = showModalId + " .binText";
//				$(selector).each(function() {
//					if ($(this).val() == '') {
//						flag = false;
//						alert(undefined, "还有未选择的升级包，请选择！");
//					}
//				});
				
				//解压文件
				if (flag == true && binPath.length > 0) {
					var unZipIndex = 0;
					var src = binPath[unZipIndex].src;
					var dst = binPath[unZipIndex].dst;
					var eachSize = []; //依次存储ac、ap、中间版本的bin文件大小
					var totalSize = 0; //存储所有包的总大小
					for (var i = 0; i < binPath.length; i++) {
			        	var tmpSize = global.jsUtil.getFileSize(binPath[i].src);			        	
			        	totalSize += tmpSize;
			        	eachSize.push(tmpSize);
			        }
					console.log("各bin文件大小： ", eachSize)
			        console.log("bin文件总大小： ", totalSize);
					
					$(showModalId).modal('hide');					
					
					setTimeout(function() {
						//解压进度条
						$("#unzip_progress").text('0%');
			            $("#unzip_progressBar").css('width', '0%');
			            $("#dlg_unzip").modal('show');
			            //表格显示
			            $("#table_acSelect").bootstrapTable('updateRow', {
			            	index: 0,
			            	row: {
			            		upgradeVer: "正在解压…"
			            	}
			            });
						
			            //解压文件
						oneAcUpgradeIns = new oneAcUpgrade(global.devicesIns, false);
						
						var record = 0;
						var unzipBinFileCallback = function (dataLen, fileLen, params) {
							var percent = Math.floor((dataLen / totalSize) * 100);							
							$("#unzip_progress").text((percent + record) + '%');
				            $("#unzip_progressBar").css('width', (percent + record) + '%');
				            
							if (dataLen == fileLen) { //表示解压完一个包
								record += percent;
							}
						}
						
						oneAcUpgradeIns.on("unzipBinFail", function (res) {
							$("#table_acSelect").bootstrapTable('updateRow', {
				            	index: 0,
				            	row: {
				            		upgradeVer: "解压失败"
				            	}
				            });
							
							$("#dlg_unzip").modal('hide');
							setTimeout(function() {
								alert(undefined, res.info);
							}, 300);
						});
						
						oneAcUpgradeIns.on("unzipBinSuccess", function (res) {
							unZipIndex++;
							if (unZipIndex < binPath.length) {
								src = binPath[unZipIndex].src;
								dst = binPath[unZipIndex].dst;
								
								oneAcUpgradeIns.unzipBinFile(src, dst, unzipBinFileCallback, binPath[unZipIndex].type);								
							} else {
								$("#dlg_unzip").modal('hide');
								$("#table_acSelect").bootstrapTable('updateRow', {
					            	index: 0,
					            	row: {
					            		upgradeVer: "导入完成"
					            	}
					            });
								setTimeout(function() {
									isImport = true;
									alert(undefined, "解压完成！您可以点击下一步开始升级。");
								}, 300);
							}
						});
						
						oneAcUpgradeIns.unzipBinFile(src, dst, unzipBinFileCallback, binPath[unZipIndex].type);
					}, 300);
				}
			});
			
			/* 云端下载 */
			$("#cloudDownload").click(function() {
				var selectAc = $("#table_acSelect").bootstrapTable('getSelections');
				var selectAp = $("#table_apSelect").bootstrapTable('getSelections');
				
				if (selectAc.length == 0 && selectAp.length == 0) {
					alert(undefined, "请先选择需要升级的AC和AP！");
					return;
				}
				
				binPath = [];
				oneAcUpgradeIns = new oneAcUpgrade(global.devicesIns, false);
				
				var sessionId = global.userMgrIns.getUserInfo().sessionId;
				var params = [];
				for (var i = 0; i < selectAc.length; i++) {
					var tmp = {};
					tmp.deviceType = selectAc[i].deviceModel;
					tmp.hardwareVersion = selectAc[i].hardVer;
					if (jGlobal.oneUpgrade.isOperators) {
						tmp.versionType = "C";
					} else {
						tmp.versionType = "normal";
					}						
					var softVer = selectAc[i].softVer;
					if (softVer.match(/mid/i) != null) {
						tmp.softwareVersion = "10.x";
					} else if (softVer.indexOf("10.") != -1) {
						tmp.softwareVersion = "10.x";
					} else if (softVer.indexOf("11.") != -1) {
						tmp.softwareVersion = "11.x";
					}
					params.push(tmp);
				}
				for (var i = 0; i < selectAp.length; i++) {
					var tmp = {};
					tmp.deviceType = selectAp[i].apDeviceModel;
					tmp.hardwareVersion = selectAp[i].apHardver;
					if (jGlobal.oneUpgrade.isOperators) {
						tmp.versionType = "C";
					} else {
						tmp.versionType = "normal";
					}						
					tmp.softwareVersion = selectAp[i].apSoftver;
					params.push(tmp);
				}

                // 初始化下载进度条显示
                $("#progress_download").text('0%');
                $("#progressBar_download").css('width', '0%');
                $("#dlg_downloadProgress").modal('show');

                // 表格显示
                /* $("#table_acSelect").bootstrapTable('updateRow', {
                    index: 0,
                    row: {
                        upgradeVer: "正在下载…"
                    }
                }); */

				oneAcUpgradeIns.batchDownloadBinFile(sessionId, params, function(err, res) {
					// 有版本下载失败，err不为null
				    if (err != null) {
                        $("#dlg_downloadProgress").modal('hide');
                        // $("#table_acSelect").bootstrapTable('updateRow', {
                        //     index: 0,
                        //     row: {
                        //         upgradeVer: '下载失败！您可以点击"云端下载"按钮重新下载'
                        //     }
                        // });
                        setTimeout(function () {
                            alert(undefined, '下载推荐版本出错，出错原因：' + err);
                        }, 300);
                        return;
                    }

                    if (res.code == 7) {
                        isImport = true;

                        $("#dlg_downloadProgress").modal('hide');
                        // $("#table_acSelect").bootstrapTable('updateRow', {
                        //     index: 0,
                        //     row: {
                        //         upgradeVer: "本地已存在推荐版本"
                        //     }
                        // });
                        setTimeout(function () {
                            // alert(undefined, '检测到本地已存在推荐版本。点击确定开始升级！', function () {
                            //     checkBeforeUpgrade();
                            // }, true, function () {});

                            formatBinPathAfterDownload();

                            // $("#selectBeforeUpgradeModal .modal-body").text("检测到本地已存在推荐版本。请选择升级的方式：");
                            // $("#selectBeforeUpgradeModal").modal('show');
                            
                            var upgradeMode = jGlobal.oneUpgrade.upgradeMode;
                            if (upgradeMode == 'immediate') {
								checkBeforeUpgrade();
                            } else if (upgradeMode == 'schedule') {
                            	$("#scheduleModal").modal('show');
                            }
                        }, 300);
					    return;
                    }

                    // 更新进度条
                    // $("#dlg_downloadProgress").modal('show');
                    if (res.code == -1) {
                        var percent = Math.floor((res.downloadLen / res.totalLen) * 100);
                        $("#progress_download").text(percent + '%');
                        $("#progressBar_download").css('width', percent + '%');
                    }

                    // 某一个文件下载完成
                    if (res.code == 2) {
                        console.log('下载完成: ', res.path);
                    }

                    // 全部下载完成
                    if (res.code == 0) {
                        isImport = true;

                        $("#progress_download").text('100%');
                        $("#progressBar_download").css('width', '100%');
                        $("#dlg_downloadProgress").modal('hide');
                        // $("#table_acSelect").bootstrapTable('updateRow', {
                        //     index: 0,
                        //     row: {
                        //         upgradeVer: "下载完成"
                        //     }
                        // });
                        setTimeout(function () {
                            // alert(undefined, '全部推荐版本都已下载完成。点击确定开始升级！', function () {
                            //     checkBeforeUpgrade();
                            // }, true, function () {});

                            formatBinPathAfterDownload();

                            // $("#selectBeforeUpgradeModal .modal-body").text("全部推荐版本都已下载完成。请选择升级的方式：");
                            // $("#selectBeforeUpgradeModal").modal('show');
                         	
                         	var upgradeMode = jGlobal.oneUpgrade.upgradeMode;
                            if (upgradeMode == 'immediate') {
								checkBeforeUpgrade();
                            } else if (upgradeMode == 'schedule') {
                            	$("#scheduleModal").modal('show');
                            }
                        }, 300);
                    }
				});
			});

            // // 取消升级
            // $("#selectBeforeUpgradeModal .btn-cancel").click(function () {
            //     $("#selectBeforeUpgradeModal").modal('hide');
            // });

			// 立即升级
            // $("#selectBeforeUpgradeModal .immediateUpgrade").click(function () {
            //     // $("#selectBeforeUpgradeModal").modal('hide');
            //     setTimeout(function () {
            //         checkBeforeUpgrade();
            //     }, 300);
            // });

            // 定时升级对话框
            $('#scheduleModal').on('show.bs.modal', function() {
                $("#hour").val("");
                $("#minite").val("");
                $("#scheduleModal #cancel").hide();
                $("#scheduleModal .close").show();
                $("#scheduleModal #confirm").show();
            });

            $("#scheduleModal #confirm").click(function() {
                //输入合法性检查
                var hour = $("#hour").val();
                var minite = $("#minite").val();

                if (hour == "" && minite == "") {
                    alert(undefined, '请输入重启时间！');
                    return;
                }
                if (hour != "") {
                    var ex = /^\d+$/;
                    if (!ex.test(hour)) {
                        alert(undefined, '请输入整数！');
                        return;
                    }
                }
                if (minite != "") {
                    var ex = /^\d+$/;
                    if (!ex.test(minite)) {
                        alert(undefined, '请输入整数！');
                        return;
                    }
                }
                if (hour < 0 || minite < 0 || minite > 59) {
                    alert(undefined, '输入不合法！请重新输入。');
                    return;
                }
                if (hour >= 24) {
                    alert(undefined, '定时不能超过24小时！');
                    return;
                }

                // 布局样式
                $("#scheduleModal .close").hide();
                $("#scheduleModal #confirm").hide();
                $("#scheduleModal #cancel").show();

                // 倒计时
                if (hour == "") hour = 0;
                if (minite == "") minite = 0;

                var now = new Date();
                var countTo = (hour * 60 * 60 * 1000) + (minite * 60 * 1000) + now.valueOf();

                $('.timer').countdown(countTo, function(event) {
                    var $this = $(this);
                    switch(event.type) {
                        case "seconds":
                        case "minutes":
                        case "hours":
                        case "daysLeft":
                            $this.find('span.' + event.type).html(event.value);
                            break;
                        case "finished":
                            $('#scheduleModal').modal('hide');
                            setTimeout(function () {
                                checkBeforeUpgrade();
                            }, 300);
                            break;
                    }
                });
            });

            $("#scheduleModal #cancel").click(function() {
                // 布局样式
                $("#scheduleModal #cancel").hide();
                $("#scheduleModal .close").show();
                $("#scheduleModal #confirm").show();

                // 没有提供取消接口，人为将定时器置为0
                $('.timer').countdown(0, function(event) {
                    var $this = $(this);
                    switch(event.type) {
                        case "seconds":
                        case "minutes":
                        case "hours":
                        case "daysLeft":
                            $this.find('span.' + event.type).html(event.value);
                            break;
                        case "finished":
                            break;
                    }
                });
            });
			
			/* 设备连接事件 */
			global.devicesIns.on("deviceConnected", function(devName) {
				if (jGlobal.oneUpgrade.multiDevConnectStatus[devName] != 'connecting') {
		    		return;
		    	} else {
		    		jGlobal.oneUpgrade.multiDevConnectStatus[devName] = jGlobal.changeDevStatus(devName, jGlobal.oneUpgrade.multiDevConnectStatus[devName], 'connected');
		    		
		    		//连接上ac设备,获取ap信息并刷新表格
		    		getAndShowApInfo(devName);
		    	}
			});
			
			global.devicesIns.on("deviceError", function(res) {
				if (jGlobal.oneUpgrade.multiDevConnectStatus[res.deviceName] == 'connecting') { //若当前设备处于connecting状态,说明该设备已尝试连接但无法连上,主动调用接口断开连接
					jGlobal.oneUpgrade.multiDevConnectStatus[res.deviceName] = jGlobal.changeDevStatus(res.deviceName, jGlobal.oneUpgrade.multiDevConnectStatus[res.deviceName], 'closing');
					global.devicesIns.closeDeviceLink(res.deviceName);					       	    	                    
		    		return;
				} else if (jGlobal.oneUpgrade.multiDevConnectStatus[res.deviceName] == 'connected') { //原则上不会处于该状态
					jGlobal.oneUpgrade.multiDevConnectStatus[res.deviceName] = jGlobal.changeDevStatus(res.deviceName, jGlobal.oneUpgrade.multiDevConnectStatus[res.deviceName], 'closing');
					global.devicesIns.closeDeviceLink(res.deviceName);					
					return;
				} else if (jGlobal.oneUpgrade.multiDevConnectStatus[res.deviceName] == 'closing' || jGlobal.oneUpgrade.multiDevConnectStatus[res.deviceName] == 'init') {
					return;
				}			
			});

			global.devicesIns.on("deviceDisconnected", function(devName) {
				if (jGlobal.oneUpgrade.multiDevConnectStatus[devName] == "connecting") { //原则上不会跑到, 连接不上或程序主动断开状态均已被置为closing
		            return;
		    	} else if (jGlobal.oneUpgrade.multiDevConnectStatus[devName] == "connected") { //原则上不会跑到。批量连接时，连接上设备后断开连接，状态置为closing
		    		return;
		    	} else if (jGlobal.oneUpgrade.multiDevConnectStatus[devName] == "closing") {
	    			jGlobal.oneUpgrade.multiDevConnectStatus[devName] = jGlobal.changeDevStatus(devName, jGlobal.oneUpgrade.multiDevConnectStatus[devName], 'init');
	    			
	    			//点击下一步后断开设备进入升级页面
	    			if (isGotoNextPage) {
	    				// alertGotoNextPage();

                        //进入升级页面
                        var curElement = ".main_content", nextPageUrl = "./oneUpgrade/html/acUpgrading.html";
                        global.enterPageCallback(curElement, nextPageUrl);
	    			}
		    	} else if (jGlobal.oneUpgrade.multiDevConnectStatus[devName] == "init") {
		    		return;
		    	}
			});
			
			//更新在线ap信息
			$("#refreshApInfo").click(function() {
				if (jGlobal.oneUpgrade.multiDevConnectStatus[curAcName] == "connecting" || jGlobal.oneUpgrade.multiDevConnectStatus[curAcName] == "closing") {
					return;
				}
				
				$("#getApInfoModal").modal('show');
				if (jGlobal.oneUpgrade.multiDevConnectStatus[curAcName] == "init") {
					jGlobal.oneUpgrade.multiDevConnectStatus[curAcName] = jGlobal.changeDevStatus(curAcName, jGlobal.oneUpgrade.multiDevConnectStatus[curAcName], 'connecting');
					global.devicesIns.connectDeviceByDeviceName(curAcName);
				}
				if (jGlobal.oneUpgrade.multiDevConnectStatus[curAcName] == "connected") {
					//连接上ac设备,获取ap信息并刷新表格
		    		getAndShowApInfo(curAcName);
				}
			});
		}
		function initDom() {
			$('#dlg_unzip').modal({
				backdrop: 'static',
				show: false,
                keyboard: false
			});
			$('#getApInfoModal').modal({
				backdrop: 'static',
				show: false,
                keyboard: false
			});
			$('#confirmModal').modal({
				backdrop: 'static',
				show: false,
                keyboard: false
			});
            $('#dlg_downloadProgress').modal({
                backdrop: 'static',
                show: false,
                keyboard: false
            });
            $("#selectBeforeUpgradeModal").modal({
                backdrop: 'static',
                show: false,
                keyboard: false
            });
            $("#scheduleModal").modal({
                backdrop: 'static',
                show: false,
                keyboard: false
            });
			
			if (jGlobal.oneUpgrade.originAcVersion == "mid") {
				$("#confirmModal").modal('show');
			}
			
//			if (jGlobal.oneUpgrade.originAcVersion == "10.") {				
//				showModalId = "#selectBinFor10x";
//			} else if (jGlobal.oneUpgrade.originAcVersion == "11.") {
//				showModalId = "#selectBinFor11x";
//			}
			
			if (jGlobal.oneUpgrade.apInfo.length == 0) {
				$("#apInfoDiv").hide();
			}
		}
		function resize() {
			var client_h = document.documentElement.clientHeight;
			var head_h = $(".main_menu").height();
			var body_h = client_h - head_h;
			
			$('#table_acSelect').bootstrapTable('resetView', {height : 80});
			$('#table_apSelect').bootstrapTable('resetView', {height : body_h - 275});
		}
		function initGlobalEvent() {
			global.exitPageCallback.exitFun = function () {
				// 移除注册事件
				removeGlobalEvent();
				
				// 离开该页面，断开设备
				console.log("无线升级离开选择版本页面设备的状态: ", jGlobal.oneUpgrade.multiDevConnectStatus[curAcName]);
				if (jGlobal.oneUpgrade.multiDevConnectStatus[curAcName] != "init") {
					global.devicesIns.closeDeviceLink(curAcName);
				}				
				return true;
			}
		}
	}
	exports.init = init;
});