define(function(require, exports, module) {
	var oneUpgrade = {};
	
	oneUpgrade.curPage = null; //记录左侧菜单当前点击的页面，返回的时候需要
	
//	oneUpgrade.upgradeDevInfos = [];

	oneUpgrade.multiDevConnectStatus = {}; 	   		//存储批量连接设备的名称及其对应的当前状态，init -> connecting -> connected -> upgrade -> restart -> closing -> init
	oneUpgrade.batchConnectFlag = false;  			//批量连接：标志位(批量连接时连上一台设备要要断开连接)
	oneUpgrade.connect_forcedCancelFlag = false;   	//批量连接：强制取消的标志位
	oneUpgrade.connectDevNum = 0; 			   		//批量连接：存储总的设备数
	oneUpgrade.connectDevNum_getInfo = 0;  	   		//批量连接：存储所有已获取到信息的设备数(设备从  已经尝试连接 -> 断开连接  整个过程才算获取到信息, connectDevNum_getInfo=devNum时所有设备都已尝试连接并均已断开)
	oneUpgrade.connectDevNum_disconnect = 0;     	//批量连接：存储点击强制取消时需要断开连接的设备数(调用连接接口加1, 收到disconnected减1)
	
	oneUpgrade.selectedDevice = [];

	oneUpgrade.curUpgradeTactic = undefined;		//当前升级策略(安全、快速、极速、单台)

	oneUpgrade.singleUpgradeOnce = true;			//单台升级时，用户一次点击多次单台设备进行升级，该变量为true时表示这些设备全部升级完成。下一次再点击单台升级，该变量重新置为false。
	oneUpgrade.singleUpgradeCount = 0;				//单台升级时，统计剩余多少台还未升级。singleUpgradeCount等于0表示单台升级全部完成。

	oneUpgrade.batchUpgradeDevList = [];			//存储批量升级的设备
	oneUpgrade.batchUpgradeCount = undefined; 		//统计批量升级的设备台数
	oneUpgrade.multiDevRcmndVersion = {};			//存储批量升级的设备名称及其对应的推荐版本信息
	oneUpgrade.multiDevUpgradeVersion = {};			//存储批量升级的设备名称及其所要升级的版本(包括：选择或下载)
	oneUpgrade.batchUpgradeResult = {};				//存储批量升级的设备名称及其对应的升级结果
	oneUpgrade.countSuccessUpgrade = 0;				//存储批量升级成功的设备数量
	oneUpgrade.countFailUpgrade = 0;				//存储批量升级失败的设备数量

	oneUpgrade.safeUpgradeIndex = undefined;		//安全升级：当前升级到第safeUpgradeIndex台

	oneUpgrade.fastUpgradeStep = 5;					//快速升级：用户确认完后一次升级5台 (正式发布时记得改回来@???)
	oneUpgrade.fastUpgradeIndex = oneUpgrade.fastUpgradeStep;
	oneUpgrade.fastUpgradeEnd = false;
	oneUpgrade.fastUpgradeFirstDev = true;			//快速升级：表示当前升级的是第一台设备，用于判断是否启动5台升级！

	oneUpgrade.speedUpgradeStep = 10; 				//极速升级(现在叫即刻升级)一次升级10台 (正式发布时记得改回来@???) ps:现在定时重启也用原先极速升级的变量
	oneUpgrade.speedUpgradeIndex = oneUpgrade.speedUpgradeStep - 1;
	oneUpgrade.speedUpgradeEnd = false;

	oneUpgrade.uploadId = undefined;
	oneUpgrade.upgradeStatistic = {};				//存储升级工具需要上传到云端的数据
	
	/* 无线升级新增全局变量 */
	oneUpgrade.apInfo = []; 						//存储当前跟ac连接的ap信息
	oneUpgrade.upgradeAcFor11x = [];				//存储待升级的11.x ac信息
	oneUpgrade.upgradeApFor11x = [];				//存储待升级的11.x ap信息
	oneUpgrade.upgradeAcFor10x = [];				//存储待升级的10.x ac信息
	oneUpgrade.upgradeApFor10x = [];				//存储待升级的10.x ap信息
	oneUpgrade.originAcVersion = null;				//存储升级前的ac版本(判断:10.或11.或mid,走不同的流程)
	oneUpgrade.isOperators = false;					//是否是运营商版本
	oneUpgrade.onlyUpgradeAc = false;				//ac版本为11x,只升级ac
	oneUpgrade.onlyUpgradeAp = false;				//ac版本为11x,只升级ap
	
	/* 热补丁升级新增全局变量 */
	oneUpgrade.multiDevVersion = [];			    //存储热补丁升级的设备名称及其升级所需的信息
	oneUpgrade.multiDevRcmndHotFix = {};			//存储设备名称及其对应的推荐补丁版本(结构类似下面)
    oneUpgrade.multiDevHotFix = {};					//存储本次所要升级的设备名称及补丁版本(结构:{"设备名1":[{"hotFixName":"x1.bin", "isUpgradeFrame":false, "isHotfix":true},{"hotFixName":"x1.bin", "isUpgradeFrame":false, "isHotfix":true}], "设备名2":[]})
    oneUpgrade.has11xBigBoxSwitch = false;  // 判断这些设备中，是否有11x箱式交换机存在，如果有的话，则需要云端推荐补丁
	oneUpgrade.uploadInfo = {};						//无线升级上传云端的信息

	/* 胖AP升级新增变量 */
    oneUpgrade.discoverResult = [];			    // 存储发现的所有胖AP
    oneUpgrade.recommndResult = [];			    // 存储所有胖AP的推荐版本信息

    // 一键升级中，定时升级、立即升级的标志
    oneUpgrade.upgradeMode = null;  // 立即升级：immediate；定时升级：schedule。


	/* 测试AC升级参数 */
//	var params = [];
//	var tmp_params = {};
//	tmp_params.deviceName = "192.168.23.193";
//	tmp_params.unzipDir = "RGOS11.1(5)B80P2_03182408_install";
//	params.push(tmp_params);
	
	/* 测试AP升级参数 */
//	var params = [];
//	var tmp_params = {};
//	tmp_params.deviceName = "192.168.201.109";
//	tmp_params.apType = [{"name":"AP320-I", "hw_ver":"1.00"}, {"name":"AP3220", "hw_ver":"1.1"}];
//	tmp_params.unzipDir = ["RGOS11.1(5)B81P2_install", "RGOS11.1(5)B81P2_install_test"];
//	params.push(tmp_params);
	
	/* 无线升级上传云端的信息示例 */
//	var uploadInfo = {};
//
//	uploadInfo.upgradeResult = '';        //升级结果。成功、失败或用户取消？
//	uploadInfo.upgradeFailReason = '';    //升级失败原因
//
//	uploadInfo.startTime = moment().format('YYYY-MM-DD HH:mm:ss'); //升级开始时间
//	uploadInfo.endTime = moment().format('YYYY-MM-DD HH:mm:ss');   //升级结束时间
//
//	uploadInfo.preAcInfo = [];            //升级前的ac信息。数组，但目前只会有一台。
//	var preAcInfoTmp = {};
//	preAcInfoTmp.deviceName = 'xxx';      //升级前ac名称
//	preAcInfoTmp.deviceModel = 'xxx';     //升级前ac型号
//	preAcInfoTmp.hardVer = 'xxx';         //升级前ac硬件版本
//	preAcInfoTmp.softVer = 'xxx';         //升级前ac软件版本
//	uploadInfo.preAcInfo.push(preAcInfoTmp);
//
//	uploadInfo.preApInfo = [];            //升级前的ap信息。数组。
//	for (var i = 0; i < 用户勾选的台数; i++) {
//		var preApInfoTmp = {};
//		preApInfoTmp.deviceModel = 'xxx'; //升级前ap型号
//		preApInfoTmp.hardVer = 'xxx';     //升级前ap硬件版本
//		preApInfoTmp.softVer = 'xxx';     //升级前ap软件版本
//		preApInfoTmp.num = x;             //整型。升级前ap个数。
//		uploadInfo.preApInfo.push(preApInfoTmp);
//	}
//
//	uploadInfo.aftAcInfo = [];            //升级后的ac信息。数组，但目前只会有一台。
//	var aftAcInfoTmp = {};
//	aftAcInfoTmp.deviceName = 'xxx';      //升级后ac名称
//	aftAcInfoTmp.deviceModel = 'xxx';     //升级后ac型号
//	aftAcInfoTmp.hardVer = 'xxx';         //升级后ac硬件版本
//	aftAcInfoTmp.softVer = 'xxx';         //升级后ac软件版本
//	uploadInfo.aftAcInfo.push(aftAcInfoTmp);
//
//	uploadInfo.aftApInfo = [];            //升级后的ap信息。数组。
//	for (var i = 0; i < 成功的台数; i++) {
//		var aftApInfoTmp = {};
//		aftApInfoTmp.deviceModel = 'xxx'; //升级后ap型号
//		aftApInfoTmp.hardVer = 'xxx';     //升级后ap硬件版本
//		aftApInfoTmp.softVer = 'xxx';     //升级后ap软件版本
//		aftApInfoTmp.num = x;             //整型。升级后ap个数。
//		uploadInfo.aftApInfo.push(aftApInfoTmp);
//	}
	
	//* XXX init -> connecting -> connected -> upgrade -> restart -> closing -> init
	oneUpgrade.curStatus = 'init';
	function changeDevStatus(devName, cur, next) {
	    console.log(devName + ' [curStatus] change from ' + cur + ' to ' + next);
	    return next;
	}
	
	exports.oneUpgrade = oneUpgrade;
	exports.changeDevStatus = changeDevStatus;
});