define(function(require, exports, module) {
	require('ztree');
	require('bootstrapTable');
	require('bootstrapTableCn');
	var modal = require("../../js/modal");
	var global = require("../../js/global");
	// 现在,收集与自动升级，共用一个tftp服务器
	//global.tftpServerIns.start({
	//       root: global.jsUtil.getDataRootPath(),
	//       host: "0.0.0.0",
	//       port: 69,
	//   });

	//   // ftp服务器启动
	//   global.ftpServiceIns.start({
	//       root: jsUtil.getDataRootPath(),
	//       port: 21
	//   });  

	// 这里初始化了所有的服务，以及预先建立了所有文件夹
    

	//设备管理页面的全局变量
	var showLoadFlag = true;
	var devNameToModify = "";
	var curDevInfo = []; //存储当前设备列表全部的设备信息。作用：1、编辑设备时直接查询该变量不再读数据库；2、添加设备时判断有无重名。
	var curSelectedNode = undefined;
	var curRightClickNode = undefined;
	var addFlag = 1; //1表示添加设备，0表示编辑设备
	//var guide = false;
	var STEP = 1; // 新手引导步骤顺序	
	var setting = {
		view: {
			showLine: false,
			showIcon: false,
			selectedMulti: false,
			dblClickExpand: false,
			autoCancelSelected: false,
			addDiyDom: addDiyDom
		},
		data: {
			simpleData: {
				enable: true
			}
		},
		callback: {
			beforeClick: beforeClick,
			onClick: onClick,
			beforeRightClick: beforeRightClick,
			onRightClick: onRightClick
		}
	};

	function addDiyDom(treeId, treeNode) {
		var spaceWidth = 10;
		var switchObj = $("#" + treeNode.tId + "_switch");
		var icoObj = $("#" + treeNode.tId + "_ico");
		switchObj.remove();
		icoObj.before(switchObj);
		var spaceStr = "<span style='display: inline-block;width:" + (spaceWidth * treeNode.level) + "px'></span>";
		switchObj.before(spaceStr);
	}

	function beforeClick(treeId, treeNode) {
		console.log(treeNode);
		if(treeNode.level == 0) {
			var zTree = $.fn.zTree.getZTreeObj("deviceAttrTree");
			zTree.expandNode(treeNode);
			return false;
		} else {
			var parentNode = treeNode;
			while(parentNode.level != 0) {
				parentNode = parentNode.getParentNode();
			}
			var parentObj = $("#" + parentNode.tId + "_a");
			if(!parentObj.hasClass('selectParentNode')) {
				$(".selectParentNode").removeClass('selectParentNode');
				parentObj.addClass('selectParentNode');
			}

			showDeviceGroupName(treeId, treeNode);
			return true;
		}
	}

	function onClick(event, treeId, treeNode, clickFlag) {
		curSelectedNode = treeNode;
		addDevInfoToTable(searchDeviceByGroupId(treeNode.id));
		return true;
	}

	function beforeRightClick(treeId, treeNode) { //beforeRightClick没有参数event, 无法获取到当前鼠标点击的位置
		return true;
	}

	function onRightClick(event, treeId, treeNode) {
		curRightClickNode = treeNode;
		$("#editNodeModal div.modal-dialog").css("left", event.clientX);
		$("#editNodeModal div.modal-dialog").css("top", event.clientY);
		$("#editNodeModal").modal('show');
		return true;
	}

	function showDeviceGroupName(treeId, treeNode) {
		var html = "";
		var title = "";
		var treeNodeName = [];
		var parentNode = treeNode;
		for(var i = 0; i <= treeNode.level; i++) {
			treeNodeName.push(parentNode.name);
			parentNode = parentNode.getParentNode();
		}
		for(var i = (treeNodeName.length - 1); i >= 0; i--) {
			if(i != 0) {
				html += treeNodeName[i] + '<span class="textSeparator"> / </span>';
				title += treeNodeName[i] + ' / ';
			} else {
				html += treeNodeName[i];
				title += treeNodeName[i];
			}
		}
		$("#deviceGroupName").html(html);
		$("#deviceGroupName").attr("title", title);
	}

	function getAndShowDevInfo() {
		function queryDevInfoCallback(error, result) {
			curDevInfo = result;
			if(error == null) {
				addDevInfoToTable(result);
			} else {
				alert(undefined, "读取设备数据失败！");
			}
		}
		global.devicesIns.getDeviceConfigInfoAll(queryDevInfoCallback);
	}

	function addDevInfoToTable(devInfo) {
		for(var i = 0; i < devInfo.length; ++i) {
			if(devInfo[i].protocal == "serial") {
				devInfo[i].conne_type = devInfo[i].protocal;
				devInfo[i].host_com = devInfo[i].comNum;
				devInfo[i].port = devInfo[i].baudrate;
			} else {
				devInfo[i].conne_type = devInfo[i].protocal;
				devInfo[i].host_com = devInfo[i].host;
				devInfo[i].port = devInfo[i].port;
			}

			if(devInfo[i].groupName === null || devInfo[i].groupName === undefined || devInfo[i].groupName === '') {
				devInfo[i].groupName = "未分组";
			}

			// 更新 curDevInfo
			for(var j = 0; j < curDevInfo.length; ++j) {
				if(curDevInfo[j].deviceName == devInfo[i].deviceName) {
					curDevInfo[j].groupName = devInfo[i].groupName;
					break;
				}
			}
		}

		$('#deiveManageTable').bootstrapTable('load', devInfo);
		return;
	}

	function operateStyle(value) {
		return '<div class="table-btn edit" style="width: 50px;">编辑</div>';
	}

	function searchDeviceByGroupId(selectGroupId) {

		var groupDevice = global.devicesIns.queryLinkInfoByGroupIdFromMem(selectGroupId);
		//		console.log("searchDeviceByGroupId start");
		//		for(var data in groupDevice)
		//		console.log(groupDevice[data].deviceName);
		//		console.log("searchDeviceByGroupId end");
		return groupDevice;
	}
	exports.searchDeviceByGroupId = searchDeviceByGroupId;

	function protocol_type_onchange(value) {
		if(value === "serial") {
			$("#telnet_para_group").hide();
			$("#serial_para_group").show();
			$("#band_rate").val("115200");
		} else if(value === "telnet") {
			$("#telnet_para_group").show();
			$("#serial_para_group").hide();
			$("#loca_port").val("23");
		} else if(value === "SSH") {
			$("#telnet_para_group").show();
			$("#serial_para_group").hide();
			$("#loca_port").val("22");
		}
	}

	function queryAllSubGroupsCbk(err, rows, select_id) {
		if(err != null) {
			alert(undefined, "查询分组信息失败！");
			return;
		}
		//    	console.log(rows);
		for(var i = 0; i < rows.length; i++) {
			var val = rows[i].groupId + ':' + rows[i].groupName;
			var text = rows[i].groupName;
			global.addOption(val, text, select_id);
		}
	}
	exports.queryAllSubGroupsCbk = queryAllSubGroupsCbk;

	function editDeviceClick(row, index) {
		if(curDevInfo === null) {
			return;
		}
		console.log(row);
		addFlag = 0;
		$("#loca_dev_name").attr("disabled",true);
        $("#group_name").show();
		$('#addDeviceModal').modal('show');
		for(var i = 0; i < curDevInfo.length; ++i) {
			if(curDevInfo[i].deviceName == row.deviceName) {
				$("#addDeviceModal .modal-title").text("修改设备");
				devNameToModify = curDevInfo[i].deviceName;
				setDevInfoToModify(curDevInfo[i]);
				break;
			}
		}
	}

	function setDevInfoToModify(row) {
		//添加串口
		var port_id = "port";
		$("#" + port_id).children().remove();

		function getComListCallback(data) {
			if(data.length === 0) {
				global.addOption("无", "无", port_id);
			} else {
				data = data.sort();
				for(var i = 0; i < data.length; ++i) {
					global.addOption(data[i], data[i], port_id);
				}
			}

			//	        $("#group_name").val(row.groupName);
			$("#loca_dev_name").val(row.deviceName);
			$("#protocol_type").val(row.protocal);
			protocol_type_onchange(row.protocal);

			if(row.username != "") {
				$("#loca_username").val(row.username);
			} else {
				$("#loca_username").val("");
			}
			if(row.password != "") {
				$("#loca_pwd").val(row.password);
			} else {
				$("#loca_pwd").val("");
			}
			if(row.enablePassword != "" && row.enablePassword != undefined) {
				$("#loca_enable_pwd").val(row.enablePassword);
			} else {
				$("#loca_enable_pwd").val("");
			}

			$("#code_option").val(row.encoding);
			if(row.encoding === "utf8") {
				$("#code_option").val(row.encoding.toUpperCase() + ",通用编码");
			} else if(row.encoding === "gb2312") {
				$("#code_option").val(row.encoding.toUpperCase() + ",中文编码");
			}

			if(row.protocal === "serial") {
				var serialNum = row.comNum;
				$("#band_rate").val(row.baudrate);
				var existFlag = 0;
				for(var i = 0; i < data.length; ++i) {
					if(serialNum === data[i]) {
						$("#port").val(serialNum);
						existFlag = 1;
						break;
					}
				}
				if(existFlag === 0) {
					alert(undefined, "当前设备不存在端口号:" + serialNum);
				}
			} else {
				$("#loca_ip_addr").val(row.host);
				$("#loca_port").val(row.port);
			}
		}
		global.deviceConfIns.getComList(getComListCallback);

		//查询分组，添加到select下，并显示当前分组
		var group_id = "group_name";
		$("#" + group_id).children().remove();

		function queryAllSubGroupsCbkCurPage(err, rows, select_id) {
			if(err != null) {
				alert(undefined, "查询分组信息失败！");
				return;
			}
			//        	console.log(rows);
			for(var i = 0; i < rows.length; i++) {
				var val = rows[i].groupId + ':' + rows[i].groupName;
				var text = rows[i].groupName;
				global.addOption(val, text, select_id);
			}

			// 显示当前分组
			//            var groupIds = [];
			//            $("#group_name option").each(function() {
			//            	groupIds.push($(this).val());
			//            });
			//            for (var i = 0; i < groupIds.length; i++) {
			//            	console.error(groupIds[i]);
			//            	if (groupIds[i].split(':')[0] == row.groupId) {
			//            		$("#group_name").val(groupIds[i]);
			//            		break;
			//            	}
			//            }
			for(var i = 0; i < rows.length; i++) {
				if(rows[i].groupId == row.groupId) {
					$("#group_name").val(rows[i].groupId + ':' + rows[i].groupName);
					break;
				}
			}
		}
		global.devicesIns.queryAllSubGroups(group_id, queryAllSubGroupsCbkCurPage);
	}

	function get_connect_param(addFlag) {
		var dev_name = $("#loca_dev_name").val();
		var conne_type = $("#protocol_type").val();
		var encoding = $("#code_option").val();
		var parameter = {
			deviceName: dev_name,
			protocal: conne_type,
			encoding: encoding.split(',')[0].toLowerCase() //* 外部传入按照 toUpperCase+中文说明 设置文字的
		};

		//	    console.error(addFlag);
		if(addFlag != null) {
			if(addFlag === 1) {
				parameter.groupId = curSelectedNode.id;
			} else if(addFlag === 0) {
				var groupId = $('#group_name').val();
				//		    	console.log(groupId);
				groupId = groupId.split(':')[0];
				parameter.groupId = groupId;
			}
		}

		var user_name = $("#loca_username").val();
		var pwd = $("#loca_pwd").val();
		parameter.username = user_name;
		parameter.password = pwd;

		if(conne_type === "serial") {
			var selected_com_num = $('#port option:selected').text();
			if(selected_com_num === "" || selected_com_num === "无") {
				alert(undefined, "请选择正确的端口号");
				return false;
			}
			var selected_band_rate = $('#band_rate option:selected').text();
			var enable_pwd = $("#loca_enable_pwd").val();

			parameter.comNum = selected_com_num;
			parameter.baudrate = selected_band_rate;
			parameter.enablePassword = enable_pwd;
		} else {
			var ip = $("#loca_ip_addr").val();
			if(!window.isIpOk(ip)) { //判断ip地址是否合法
				alert(undefined, "您输入IP格式不正确，必须是000.000.000.000格式");
				return false;
			}

			if(conne_type == "SSH") {
				if($("#loca_username").val() == "") { //* 用 user_name 或者 pwd 更合适些
					alert(undefined, "SSH连接时用户名不能为空！");
					return false;
				}
				if($("#loca_pwd").val() == "") {
					alert(undefined, "SSH连接时密码不能为空！");
					return false;
				}
			}

			var port = $("#loca_port").val();
			var enable_pwd = $("#loca_enable_pwd").val();

			parameter.host = ip;
			parameter.port = port;
			parameter.containShell = true;
			parameter.enablePassword = enable_pwd;

			//	        if (conne_type !== "http" && conne_type !== "https") {
			//	            parameter.enablePassword = enable_pwd;
			//	        }
		}
		return parameter;
	}
	exports.get_connect_param = get_connect_param;

	function queryAllGroupsCallback(err, rows) {
		//		console.log(err);
		//		console.log(rows);
		if(err != null) {
			alert(undefined, "查询客户分组信息出错！");
			return;
		}

		// 如果有客户，则不需要新手引导
        // XXX 先关闭新手引导
        console.log(rows.length);
        global.guide = false;
		//if(STEP == 1) {
		//	if(rows.length) {
		//		global.guide = false;
		//	}else{
		//		global.guide = true;
		//	}

		//	initGuide();
		//}

		var zNodes = [];
		for(var i = 0; i < rows.length; i++) {
			var tmp_zNodes = {};
			tmp_zNodes.id = rows[i].groupId;
			tmp_zNodes.pId = rows[i].parentId;
			tmp_zNodes.name = rows[i].groupName;
			if(rows[i].open == "true") {
				tmp_zNodes.open = true;
			}
			zNodes.push(tmp_zNodes);
		}
		var treeObj = $("#deviceAttrTree");
		$.fn.zTree.init(treeObj, setting, zNodes);

		//		// 更新树时需初始化变量
		//		curSelectedNode = undefined;
		//		curRightClickNode = undefined;
	}

	function initGuide() {
		//console.log(guide)

		if(global.guide && STEP === 1) {
			$('#red-point').css('display', 'block');
			$('#guide-panel').css('display', 'block');

			setTimeout(function() {
				$('#guide-panel').fadeOut('1000');
				$('#red-point').animate({
					top: '580px',
					left: '128px'
				}, 1000);
				STEP = 2;
			}, 2000);
		}
	}

	function init() {
		initWindowEvent();
		initPageStatistic();
		initVariable();
		initTree();
		initTable();
		initEvent();
		initDom();
		resize();
		initGlobalEvent();

		function initWindowEvent() {
			window.operateStyle = operateStyle;
			window.operateEvents = {
				'click .edit': function(e, value, row, index) {
					editDeviceClick(row, index);
				}
			};
			window.protocol_type_onchange = protocol_type_onchange;
		}

		function initPageStatistic() {
			window.statRecordEle("deviceManage#deviceManage");
		}

		function initVariable() {
			showLoadFlag = true;
			devNameToModify = "";
			curDevInfo = []; //存储当前设备列表全部的设备信息。作用：1、编辑设备时直接查询该变量不再读数据库；2、添加设备时判断有无重名。
			curSelectedNode = undefined;
			curRightClickNode = undefined;
			addFlag = 1; //1表示添加设备，0表示编辑设备
			setting = {
				view: {
					showLine: false,
					showIcon: false,
					selectedMulti: false,
					dblClickExpand: false,
					autoCancelSelected: false,
					addDiyDom: addDiyDom
				},
				data: {
					simpleData: {
						enable: true
					}
				},
				callback: {
					beforeClick: beforeClick,
					onClick: onClick,
					beforeRightClick: beforeRightClick,
					onRightClick: onRightClick
				}
			};
		}

		function initTree() {
			global.devicesIns.queryAllGroups(queryAllGroupsCallback);
		}

		function initTable() {
			$('#deiveManageTable').bootstrapTable({
				data: []
			});

			$(".fixed-table-body").addClass('custom-scroll');
			$("#deiveManageTable").show();

			getAndShowDevInfo();
		}

		function initEvent() {
			$('#addUserModal').on('show.bs.modal', function() {
				$("#userName").val("");
			});

			$('#addGroupModal').on('show.bs.modal', function() {
				$("#groupName").val("");
			});

			$("#addUserModal .btn-confirm").click(function() {

				var userName = $("#userName").val();
				if(userName == '' || userName == null) {
					return;
				}
				var params = {};
				params.groupName = userName;
				params.open = "true";
				global.devicesIns.InsertAndUpdateGroupIntoDb(params, InsertAndUpdateGroupIntoDbCbk);

				function InsertAndUpdateGroupIntoDbCbk(res) {
					if(res != null) {
						alert(undefined, "添加客户失败！");
						return;
					}
					global.devicesIns.queryAllGroups(queryAllGroupsCallback);
					//					var zTree = $.fn.zTree.getZTreeObj("deviceAttrTree");
					//					var newNode = {};
					//					newNode.name = userName;
					//					zTree.addNodes(null, newNode);
				}
			});

			$("#addGroupModal .btn-confirm").click(function() {
				//				console.log(curRightClickNode);
				var groupName = $("#groupName").val();
				if(groupName == '' || groupName == null) {
					return;
				}
				//				//如果当前选中的节点跟当前要新增子节点的节点是同一节点，去掉curSelectedNode样式
				//				if (curRightClickNode.name == $(".curSelectedNode span:last-child").text()) {
				//					$(".curSelectedNode").removeClass('curSelectedNode');
				//				}
				//				var zTree = $.fn.zTree.getZTreeObj("deviceAttrTree");
				//				var newNode = {name:"新增节点"};
				//				zTree.addNodes(curRightClickNode, newNode);
				var params = {};
				var userName = $("#groupName").val();
				params.groupName = userName;
				params.parentId = curRightClickNode.id;
				global.devicesIns.InsertAndUpdateGroupIntoDb(params, InsertAndUpdateGroupIntoDbCbk);

				function InsertAndUpdateGroupIntoDbCbk(res) {
					if(res != null) {
						alert(undefined, "添加客户失败！");
						return;
					}
					global.devicesIns.queryAllGroups(queryAllGroupsCallback);
				}
			});

			$('#addDevBtn').click(function() {
				if(curSelectedNode == undefined) {
					alert(undefined, '请选中某个分组后再在该分组上添加设备！\r\n如果没有任何分组，请点击“添加客户“按钮创建分组');
					return;
				}
				addFlag = 1;
				$("#addDeviceModal").modal('show');
				$("#addDeviceModal .modal-title").text("添加设备");
                $("#loca_dev_name").attr("disabled", false);
				$("#loca_dev_name").val("");
				$("#loca_ip_addr").val("");
				$("#loca_port").val("23");
				$("#loca_username").val("");
				$("#loca_pwd").val("");
				$("#loca_enable_pwd").val("");
				$("#protocol_type").val("telnet");
				$("#code_option").val("UTF8,通用编码");
				$("#group_name").hide();
				protocol_type_onchange("telnet");

				//添加串口
				var select_id = "port";
				$("#" + select_id).children().remove();

				function getComListCallback(data) {
					if(data.length === 0) {
						global.addOption("无", "无", select_id);
					} else {
						data = data.sort();
						for(var i = 0; i < data.length; ++i) {
							global.addOption(data[i], data[i], select_id);
						}
					}
				}
				global.deviceConfIns.getComList(getComListCallback);
			});

			$("#addDeviceModal .btn-confirm").click(function() {
				var dev_name = $("#loca_dev_name").val();
				if (dev_name === "") {
					alert(undefined, "请填写设备名称");
					return;
				} else {
					if (dev_name.length > 32) {
						alert(undefined, "设备名称长度不能超过32位！");
						return;
					}

					var pattern = new RegExp("[`~!@#$^&*()=|{}':;',\"\"\\[\\]<>/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？]");
					var valid = pattern.test(dev_name);
					if (valid) {
						alert(undefined, "设备名称只能包含：字母、数字、中文、点号、下划线或-");
						return;
					}
				}

				// //1.判断设备名是否为空且是否唯一，不唯一则提示 2.将数据插入到数据库 3.重新获取数据并显示在界面中
				// if (curDevInfo !== undefined) {
				// 	for (var i = 0; i < curDevInfo.length; ++i) {
				// 		if (dev_name !== devNameToModify && dev_name === curDevInfo[i].deviceName) {
				// 			alert(undefined, "设备名称已经存在，请重新输入");
				// 			return;
				// 		}
				// 	}
				// }

				var parameter = get_connect_param(addFlag);
				if (parameter === false) {
					return;
				}

				$("#addDeviceModal").modal('hide');

				if(addFlag === 1) { //添加的时候直接插入
					function insertDevinfoCallback(error, result) {
						if(error === null) { //插入正确
							addDevInfoToTable(searchDeviceByGroupId(curSelectedNode.id));
						} else {
							alert(undefined, "设备添加失败!失败原因: " + error.toString());
						}
					}
					global.devicesIns.addDeviceLink(parameter, insertDevinfoCallback);
				} else if(addFlag === 0) { //修改设备信息
					var dataToModify;
					for(var i = 0; i < curDevInfo.length; ++i) {
						if(devNameToModify === curDevInfo[i].deviceName) {
							dataToModify = curDevInfo[i];
							break;
						}
					}
					dataToModify.groupId = parameter.groupId;
					dataToModify.deviceName = parameter.deviceName;
					dataToModify.protocal = parameter.protocal;
					dataToModify.username = parameter.username;
					dataToModify.password = parameter.password;
					dataToModify.encoding = parameter.encoding;
					if(parameter.protocal === "serial") {
						dataToModify.comNum = parameter.comNum;
						dataToModify.baudrate = parameter.baudrate;
						dataToModify.enablePassword = parameter.enablePassword;
					} else {
						dataToModify.host = parameter.host;
						dataToModify.port = parameter.port;
						if(parameter.protocol != "http" && parameter.protocol != "https") {
							dataToModify.enablePassword = parameter.enablePassword;
						}
						dataToModify.containShell = true;
					}
					//			        console.log(parameter);
					//			        console.log(dataToModify);
					if(parameter.deviceName !== devNameToModify) { //修改了设备名，则先删除再插入
						//将设备名字传递给后台去删除数据，再重新获取数据并显示 todo
						function delOneDevCallback(error) {
							if(error !== null) {
								alert(undefined, "修改失败!");
							} else { //删除成功之后再插入
								function insertDevinfoCallback(error, result) {
									if(error === null) { //更新正确
										if(curSelectedNode != undefined) { //有选中节点			                        		
											addDevInfoToTable(searchDeviceByGroupId(curSelectedNode.id));
										} else { //没有选中节点
											//					                		console.error("设备设备设备设备");
											//			    							console.error(searchDeviceByGroupId(null));
											addDevInfoToTable(searchDeviceByGroupId(null));
										}
									} else {
										alert(undefined, "信息修改失败!");
									}
								}
								global.devicesIns.addDeviceLink(dataToModify, insertDevinfoCallback);
							}
						}
						//将设备名字传递给后台去改变状态这个字段，再重新获取数据并显示 
						//获取选中的设备参数
						var devNames = [];
						devNames.push(devNameToModify);
						global.devicesIns.deleteDeviceLinkByDeviceName(devNames, delOneDevCallback);
					} else {
						function updateDevinfoCallback(error, result) {
							if(error === null) { //更新正确
								if(curSelectedNode != undefined) { //有选中节点
									addDevInfoToTable(searchDeviceByGroupId(curSelectedNode.id));
								} else { //没有选中节点
									addDevInfoToTable(searchDeviceByGroupId(null));
								}
							} else {
								alert(undefined, "信息修改失败!");
							}
						}
						global.devicesIns.updateDeviceLink(dataToModify, updateDevinfoCallback);
					}
				}
			});

			$('#deleteDevBtn').click(function() {
				var deleteDev = $("#deiveManageTable").bootstrapTable('getSelections');
				if(deleteDev.length == 0) {
					alert(undefined, '请至少选择一台设备！');
					return;
				}

				alert(undefined, "确认要删除设备吗？", function() {
					//			        curStatus = changeDevStatus(curStatus, 'init'); //* XXX 这里假定后台删除的时候会自动断开连接，包括connecting和connected、closing对象

					//将设备名字传递给后台去删除数据，再重新获取数据并显示 todo
					function delDevCallback(error) {
						if(error === null) {
							if(curSelectedNode != undefined) {
								addDevInfoToTable(searchDeviceByGroupId(curSelectedNode.id));
							} else {
								addDevInfoToTable(searchDeviceByGroupId(null));
							}
						} else {
							alert(undefined, "删除失败!");
						}
					}
					var devNames = [];
					var devInfos = $("#deiveManageTable").bootstrapTable('getSelections');
					for(var i = 0; i < devInfos.length; ++i) {
						devNames.push(devInfos[i].deviceName);
					}
					global.devicesIns.deleteDeviceLinkByDeviceName(devNames, delDevCallback);
				}, true);
			});

			$('#editNodeModal .addNode').click(function() {
				if(curRightClickNode.level != 0) {
					alert(undefined, "只能在根节点下添加分组!");
					return;
				}
				$("#addGroupModal").modal('show');
			});

			$('#editNodeModal .deleteNode').click(function() {
				//				$("#editNodeModal").modal('hide');
				//				var zTree = $.fn.zTree.getZTreeObj("deviceAttrTree");
				//				zTree.removeNode(curRightClickNode);
				console.log(curRightClickNode);
				alert(undefined, "确定要删除该分组及其该分组下的所有设备吗？", function() {
					var group = {};
					group.groupId = curRightClickNode.id;
					global.devicesIns.deleteGroup(group, deleteGroupCbk);

					function deleteGroupCbk(err) {
						if(err != null) {
							alert(undefined, "删除分组失败！");
							return;
						}
						global.devicesIns.queryAllGroups(queryAllGroupsCallback);
						if(curSelectedNode == undefined) { //没有选中节点就删除
							//							console.error("节点节点节点");
							//							console.error(searchDeviceByGroupId(null));
							addDevInfoToTable(searchDeviceByGroupId(null));
						} else {
							if(curSelectedNode.id == curRightClickNode.id || curSelectedNode.pId == curRightClickNode.id) { //当前删除的节点包含当前选中的节点
								curSelectedNode = undefined;
								$("#deviceGroupName").html("");
								$("#deviceGroupName").attr("title", "");

								addDevInfoToTable(searchDeviceByGroupId(null));
							} else {
								addDevInfoToTable(searchDeviceByGroupId(curSelectedNode.id)); //可以不写，不会有问题。
							}
						}
					}
				}, true);
			});

			$("#batchImportModalBtn").click(function() {
				var selectConfFile = $('#selectConfFile');
				selectConfFile.unbind('change');
				selectConfFile.change(function(evt) {
					//			    	console.log($(this).val());
					showLoadFlag = true;
					$("#loadingConfModal").modal('show');

					function importDevicesCb(error, succ, fail) {
						//			        	console.log(error);
						//			        	console.log(succ);
						//			        	console.log(fail);

						if(error != null) {
							console.log('import error:', error);
							if(showLoadFlag) {
								$("#loadingConfModal").modal('hide');
								$("#loadConfFailModal").modal('show');
								setTimeout(function() {
									showLoadFlag = false;
									$("#loadConfFailModal").modal('hide');
								}, 1000);
							}
							return;
						}

						$("#loadingConfModal").modal('hide');
						initTree();
						initTable();
						$("#loadConfSuccessModal").modal('show');
						setTimeout(function() {
							$("#loadConfSuccessModal").modal('hide');
						}, 1000);
					}

					var filePath = $(this).val();
					//			        console.log(filePath);deleteDeviceLinkByDeviceNameOnlyLogic
					global.devicesIns.importDevices(filePath, importDevicesCb);

					$(this).val("");
				});
				selectConfFile.trigger('click');
            });

            // 同步所有可用设备信息到云端
            $('#syncBtn').click(function () {
                var util = window.require('util');
                $('#syncInfo').html('0/0/0');
                $('#syncDevModal').modal('show');
                console.log('syncer:', global.syncer);
                global.syncer.syncDevices(global.devicesIns, function (successCnt, failedCnt, totalCnt) {
                    $('#syncInfo').html(util.format('%d台有效/%d台无效/%d台待检', successCnt, failedCnt, totalCnt - successCnt - failedCnt));
                }, function (err, saveNum) {
                    console.log('syncer callback is called!!!');
                    $("#syncDevModal").modal('hide');
                    if (!err) {
                        alert(undefined, '完成!共上传' + saveNum + '台设备信息');
                    } else {
                        console.error('syncInfo error:', err);
                        alert(undefined, '上传失败,请稍后尝试');
                    }
                    
                });
            });


			//拓扑发现----------------------------------------------------------------------------------------------
			//UI界面操作--start--
			$("#deviceManage_deviceTopo_AddInfo").click(function() {
				var m_username = $("#deviceManage_deviceTopo_username").val();
				var m_password = $("#deviceManage_deviceTopo_pwd").val();
				var m_enabled = $("#deviceManage_deviceTopo_enable").val();
				if(m_username.length <= 0 && m_password.length <= 0 && m_enabled <= 0) {
					alert(undefined, "请输入用户名、密码、或特权码");
					return;
				}
				if(IsTopoDeviceInfoExist(m_username, m_password, m_enabled)) {
					alert(undefined, "已添加了相同的用户信息");
					return;
				}
				AddTopoDeviceInfoToTable(m_username, m_password, m_enabled);
			});
			var deviceManage_TopoAuthResultTable_tbody_RowIndex = 0;
			//添加行
			function AddTopoDeviceInfoToTable(username, password, enable) {
				deviceManage_TopoAuthResultTable_tbody_RowIndex++;
				var id = "deviceManage_TopoAuthResultTable_tbody_" + deviceManage_TopoAuthResultTable_tbody_RowIndex;
				var m_newRow = '<tr id="' + id + '">';
				m_newRow += '<td><input class="form-control self-form-control"  type="text" placeholder="用户名 (可选 若无可不填)" value="' + username + '"></td>';
				m_newRow += '<td><input class="form-control self-form-control" type="password" placeholder="密码 (可选 若无可不填)" value="' + password + '"></td>';
				m_newRow += '<td><input class="form-control self-form-control" type="password" placeholder="特权密码 (可选 若无可不填)" value="' + enable + '"></td>';
				m_newRow += '<td><input class="button_confirm" type="button" value="删除" onclick="DelTopoDeviceInfoTableRow(' + deviceManage_TopoAuthResultTable_tbody_RowIndex + ')"></td>';
				m_newRow += '</tr>';
				$('#deviceManage_TopoAuthResultTable tbody').append(m_newRow);
			}

			function IsTopoDeviceInfoExist(username, password, enable) {
				var m_tableData = GetTopoDeviceInfoTableData();
				for(var data in m_tableData) {
					if(m_tableData[data].username == username && m_tableData[data].password == password && m_tableData[data].enable == enable)
						return true;
				}
				return false;
			}

			function GetTopoDeviceInfoTableData() {
				var m_tableData = [];
				$("#deviceManage_TopoAuthResultTable tbody").find("tr").each(function() {
					var tdArr = $(this).children();
					var m_username = tdArr.eq(0).find('input').val();
					var m_password = tdArr.eq(1).find('input').val();
					var m_enable = tdArr.eq(2).find('input').val();
					m_tableData.push({
						username: m_username,
						password: m_password,
						enable: m_enable
					});
				});
				return m_tableData;
			}
			//UI界面操作--end----
			var m_topo_WaitForUnSelectCount = 0;
			var m_topo_StartDate;
			var m_topo_cmd = "show lldp neighbors detail";
			var m_topo_ipCmd = "show ip interface brief";
			var m_topoDeleteDeviceIp = [];
			var m_topoUserAuthData = [];
			var m_isTopoBreak = 0;
			var m_topoIntervalObject;
			var m_topo_discoveryTitle = "正在发现设备中";

			$("#btn_deviceTopoBtn").click(function() {
				$("#deviceManage_TopologyDiscoveryModal").hide();
				if(curSelectedNode == undefined) {
					alert(undefined, "请选择一个客户分组才可以设备发现");
					return false;
				}
				$("#deviceManage_TopologyDiscoveryModal").show();
				return true;
			});

			function InitTopoTime() {
				global.TopoToolIns.InitTopoTimeDate();
			}

			function IsTopoEnd() {
				return global.TopoToolIns.IsTopoTimeOut();
			}

			function WaitForTopoEnd() {
				InitTopoTime();
				m_topoIntervalObject = setInterval(WaitForTopoEndOperation, 2000)
			}

			function WaitForTopoEndOperation() {
				var m_currentTime = new Date();
				var m_currentTimeData = m_currentTime.getTime();
				var m_topoTimeData = m_topo_StartDate.getTime();
				var m_topoTimeDiff = m_currentTimeData - m_topoTimeData;
				var m_timeTips = m_topoTimeDiff > 60000 ? Math.round(m_topoTimeDiff / 6000) / 10 + "分" : Math.round(m_topoTimeDiff / 100) / 10 + "秒";
				var m_confirmTitle = "当前总发现设备:" + global.TopoToolIns.getTopoTotalIpCount() + "台,其中有效设备:" + global.TopoToolIns.topoValidTotalCount() + "台 用时" + m_timeTips;
				$("#deviceManage_TopoModal_SelectNum_log").html(m_confirmTitle);
				m_topo_WaitForUnSelectCount++;
				if(m_topo_WaitForUnSelectCount == 2) {
					m_topo_WaitForUnSelectCount = 0;
					if(m_topoDeleteDeviceIp.length > 0) {
						global.devicesIns.deleteDeviceLinkByDeviceName(m_topoDeleteDeviceIp, function(err) {
							addDevInfoToTable(searchDeviceByGroupId(curSelectedNode.id));
						});
						m_topoDeleteDeviceIp = [];
					}
					TopoUnSelectIpOperationAll();
				}
				if(IsTopoEnd()) {
					TopoAppendWriteLog(m_confirmTitle);
					EndTopoOperation();
				}
			}

			function EndTopoOperation() {
				clearInterval(m_topoIntervalObject);
				ResetTopoFormControl();
				AddTopoLog("全部设备发现完毕！");
				//刷新deviceManage页面
				addDevInfoToTable(searchDeviceByGroupId(curSelectedNode.id));
			}
			$("#deviceManage_TopoModalStart").click(function() {
				if($("#deviceManage_TopoModalStart").html() == m_topo_discoveryTitle) {
					if(confirm("正在设备发现中，确认要停止吗?")) {
						m_isTopoBreak = 1;
						clearInterval(m_topoIntervalObject);
						ResetTopoFormControl();
						AddTopoLog("用户停止设备发现");
					}
					return;
				}
				var m_startIp = $("#deviceManage_inputTopoStartIP").val();
				if(!global.TopoToolIns.IsIpv4(m_startIp)) {
					alert(undefined, "起始设备IP不是有效的IPV4格式");
					return;
				}
				m_isTopoBreak = 0;
				var m_topo_community = $("#deviceManage_inputTopo_community").val();
				var m_topo_commnutiy_port = $("#deviceManage_inputTopo_community_port").val();
				global.TopoToolIns.ClearTopoData();
				$("#deviceManage_TopoModalStart").html(m_topo_discoveryTitle);
				$("#deviceManage_TopoModalStartLoading").show();
				global.TopoToolIns.telnetInit(global.devicesIns, m_topo_cmd, telnetDeviceConnectedCallBack, deviceDisconnectedCallBack);
				global.TopoToolIns.initSetCommunity(m_topo_community, m_topo_commnutiy_port);
				m_topo_StartDate = new Date();
				TopoAppendWriteLog("start_Topo_IP", true);
				TopoAppendWriteValidIPLog("start_Topo_IP", true);
				m_topoUserAuthData = GetTopoDeviceInfoTableData();
				//TopoModalRouteStart(m_startIp);
				telnetStart(m_startIp);
				WaitForTopoEnd();
			});

			function telnetDeviceConnectedCallBack(deviceName, cmd, response) {
				global.TopoToolIns.ConsoleLog("cmd: " + cmd + " result: " + response);
				if(global.TopoToolIns.isSameDeviveIp(deviceName)) {
					DiviceDisconnectedDeleteOperation(deviceName);
					return;
				}
				var m_deviceObj = global.devicesIns.getDeviceInfoByDeviceName(deviceName);
				var m_devInfo = m_deviceObj != undefined && m_deviceObj.deviceModel != undefined ? m_deviceObj.deviceModel : "nodeviceModel";
				TopoAppendWriteValidIPLog(deviceName + " " + m_devInfo);
				telnetCmdsResultOperation(deviceName, response);
				global.devicesIns.execCmd(deviceName, m_topo_ipCmd, function(res, args) {
					global.TopoToolIns.telnetClose(global.devicesIns, deviceName);
					telnetDeviceConnectCmdIpCallBack(deviceName, m_topo_ipCmd, res);
				});
			}

			function telnetDeviceConnectCmdIpCallBack(ip, cmd, response) {
				if(response == undefined || response.length <= 0)
					return;
				var m_telnetDataResult = response.split("\r\n");
				for(var data in m_telnetDataResult) {
					var isUp = false;
					var m_validip;
					var m_datasplit = m_telnetDataResult[data].split(' ');
					if(m_datasplit.length <= 3)
						continue;
					for(var ips in m_datasplit) {
						var m_ipsdata = global.TopoToolIns.trimStr(m_datasplit[ips]);
						if(m_ipsdata.length <= 0)
							continue;
						var m_ip = m_ipsdata.split('/')[0];
						if(global.TopoToolIns.IsIpv4(m_ip))
							m_validip = m_ip;
						if(m_ip == "up")
							isUp = true;
					}
					if(isUp && m_validip) {
						global.TopoToolIns.AddTopoSameDeviceArray(m_validip);
					}
				}
			}

			function deviceDisconnectedCallBack(res, m_msg) {
				var m_config = global.devicesIns.getDeviceInfoByDeviceName(res);
				for(var i = 0; i < m_topoUserAuthData.length; i++) {
					if(m_config.username == m_topoUserAuthData[i].username) {
						if(i == m_topoUserAuthData.length - 1) {
							DiviceDisconnectedCoreOperation(res);
						} else {
							global.TopoToolIns.UpdatetelnetSet(global.devicesIns, curSelectedNode.id, res, m_topoUserAuthData[i + 1].username, m_topoUserAuthData[i + 1].password, m_topoUserAuthData[i + 1].enable, updateDevinfoCallback);

							function updateDevinfoCallback(error, result) {
								global.TopoToolIns.telnetConnect(global.devicesIns, res);
							}
						}
						return;
					}
				}
				DiviceDisconnectedCoreOperation(res);
			}

			function DiviceDisconnectedDeleteOperation(ip) {
				m_topoDeleteDeviceIp.push(ip);
			}

			function DiviceDisconnectedCoreOperation(ip) {
				DiviceDisconnectedDeleteOperation(ip);
				telnetCmdsResultOperation(ip, "");
			}

			function ResetTopoFormControl() {
				$("#deviceManage_TopoModalStart").html("开始设备发现");
				$("#deviceManage_TopoModalStartLoading").hide();
			}

			function TopoBreakOperation() {
				if(m_isTopoBreak) {
					AddTopoLog("用户停止设备发现！");
					console.log("用户停止设备发现");
					return true;
				}
				return false;
			}

			function AddTopoLog(log) {
				$("#deviceManage_TopoModal_log").html(log);
			}
			//拓扑功能-start
			//开始执行telnet指令
			function telnetStart(ip) {
				InitTopoTime();
				if(global.TopoToolIns.isSameDeviveIp(ip))
					return;
				AddTopoLog("正在执行" + ip + "的二层设备发现！");
				telnetSetAndConnect(ip);
			}

			function telnetSetAndConnect(ip) {
				InitTopoTime();
				global.TopoToolIns.ConsoleLog("start telnetSetAndConnect");
				if(global.TopoToolIns.isSameDeviveIp(ip))
					return;

				var m_username = m_topoUserAuthData[0] ? m_topoUserAuthData[0].username : "";
				var m_password = m_topoUserAuthData[0] ? m_topoUserAuthData[0].password : "";
				var m_enabled = m_topoUserAuthData[0] ? m_topoUserAuthData[0].enable : "";
				global.TopoToolIns.telnetSet(global.devicesIns, curSelectedNode.id, ip, m_username, m_password, m_enabled, function(error, result) {});
				global.TopoToolIns.telnetConnect(global.devicesIns, ip);
			}
			//Telnet命令执行结果解析（注意多个邻居的情况也即多个IP及对应的MAC）
			function telnetCmdsResultOperation(ip, result) {
				InitTopoTime();
				var m_telnetData = [];
				if(result.length > 0) {
					var m_telnetDataResult = result.split("\r\n");
					var m_ip = "";
					var m_mac = "";
					var m_name = "";
					for(var data in m_telnetDataResult) {
						var m_datasplit = m_telnetDataResult[data].split(":");
						var m_keyname = global.TopoToolIns.trimStr(m_datasplit[0]);
						if(m_keyname == "Management address") {
							m_ip = getTelnetDataResult(m_datasplit);
							if(global.TopoToolIns.IsIpv4(m_ip)) {
								//TopoAppendWriteExtLog("AddTwoLayerIP-->"+ip+"=>"+m_ip);
								global.TopoToolIns.AddArrayDataFromTwoLayer(ip, m_ip, TopoModalDelSuccessCallBack);
							}
						}
						if(m_keyname == "System name") {
							m_name = getTelnetDataResult(m_datasplit);
						}
						if(m_keyname == "Chassis ID") {
							m_mac = getTelnetDataResult(m_datasplit);
						}
						if(m_ip != "" && m_mac != "" && m_name != "") {
							m_telnetData.push({
								"ip": m_ip,
								"mac": m_mac,
								"name": m_name
							});
							m_ip = "";
							m_mac = "";
							m_name = "";
						}
					}
				}
				global.TopoToolIns.telnetAddData(ip, m_telnetData);
				if(m_telnetData.length > 0) {
					addDevInfoToTable(searchDeviceByGroupId(curSelectedNode.id));
				}
				global.TopoToolIns.ConsoleLog(ip + " 二层设备发现已遍历完毕");
				AddTopoLog(ip + "的二层设备发现执行完毕！");
			}

			function getTelnetDataResult(data) {
				if(data && data.length > 1)
					return global.TopoToolIns.trimStr(data[1]);
				return "";
			}

			function TopoModalStart(ip, oid) {
				InitTopoTime();
				var m_firstCommunity = global.TopoToolIns.getFirstCommunity();
				var m_snmp = global.TopoToolIns.initTopoInfo(ip, m_firstCommunity);
				global.TopoToolIns.getTopoNext(m_snmp, ip, oid, oid, TopoModalSuccessCallBack, TopoModalFailedCallBack, TopoModalEndCallBack);
			}

			function TopoModalRouteStart(ip) {
				InitTopoTime();
				if(global.TopoToolIns.IsTopoSelectedIp(ip))
					return;
				global.TopoToolIns.SetCurrentIpSelectedData(ip);
				if(global.TopoToolIns.isSameDeviveIp(ip))
					return;
				var oid = ["1.3.6.1.2.1.4.21.1.7"];
				global.TopoToolIns.ConsoleLog("正在执行" + ip + "的三层设备发现！");
				AddTopoLog("正在执行" + ip + "的三层设备发现！");
				TopoModalStart(ip, oid);
			}

			function TopoModalFailedCallBack(ip, errorMsg) {
				InitTopoTime();
				//TopoAppendWriteExtLog(ip+" "+errorMsg);
			}

			function TopoModalSuccessCallBack(ip, startOid, oid, value) {
				InitTopoTime();
				var m_data = [];
				m_data.push({
					"key": oid,
					"value": value
				});
				//TopoAppendWriteExtLog("topoSnmp---->"+ip+ " key:"+oid+"==>"+value);
				global.TopoToolIns.AddArrayData(ip, m_data, TopoModalDelSuccessCallBack, TopoModalShowIPMacInfo);
			}

			function TopoModalDelSuccessCallBack(ip) {
				global.devicesIns.deleteDeviceLinkByDeviceName(ip.split(";"), function(error) {});
			}

			function TopoModalShowIPMacInfo(ip, mac) {
				//TopoAppendWriteExtLog(ip+" "+mac);
			}

			function TopoModalEndCallBack(snmpSession, ip, startOid, oid, value, isError) {
				InitTopoTime();
				global.TopoToolIns.ConsoleLog("TopoModalEndCallBack:" + startOid + " isError:" + isError);
				if(isError) {
					global.TopoToolIns.ConsoleLog("Topo Error Next Ip Send");
					TopoModalEndCallBackCoreOperation(ip);
					return;
				}
				if(startOid.toString() == "1.3.6.1.2.1.4.21.1.7") { //对应的IP
					var m_oid2 = ["1.3.6.1.2.1.4.22.1.2"]; //IP对应的MAC
					global.TopoToolIns.getTopoNext(snmpSession, ip, m_oid2, m_oid2, TopoModalSuccessCallBack, TopoModalFailedCallBack, TopoModalEndCallBack);
				}
				if(startOid.toString() == "1.3.6.1.2.1.4.22.1.2") { //IP对应的MAC
					global.TopoToolIns.ConsoleLog("------>startOid:" + startOid);
					//snmpSession.close();
					TopoModalEndCallBackCoreOperation(ip);
				}
			}

			function TopoModalEndCallBackCoreOperation(ip) {
				global.TopoToolIns.ConsoleLog("InitTopoTime");
				InitTopoTime();
				global.TopoToolIns.ConsoleLog("telnetStart");
				if(ip != undefined && ip != "")
					telnetStart(ip);
			}

			function TopoUnSelectIpOperationAll() {
				//当前设备测试完毕 整理数据,并开始下一个设备的数据获取
				var m_unselectIp = global.TopoToolIns.GetUnSelectedIp();
				if(m_unselectIp == undefined || m_unselectIp.length <= 0) {
					global.TopoToolIns.ConsoleLog("所有的拓扑发现已完成");
					return;
				}
				for(var unip in m_unselectIp) {
					if(TopoBreakOperation())
						return;
					topoThreadsleep(100);
					global.TopoToolIns.ConsoleLog("--->NextIP:" + m_unselectIp[unip]);
					TopoAppendWriteLog(m_unselectIp[unip]);
					//TopoModalRouteStart(m_unselectIp[unip]);
					telnetStart(m_unselectIp[unip]);
				}
			}

			function TopoAppendWriteLog(content, isInit) {
				TopoAppendWriteLogCoreOperation(content, "C://TopoSelectedIP_log.txt", isInit);
			}

			function TopoAppendWriteValidIPLog(ip, isInit) {
				TopoAppendWriteLogCoreOperation(ip, "C://TopoSelectedValidIP_log.txt", isInit);
				if(isInit)
					TopoAppendWriteExtLog(ip, isInit);
			}

			function TopoAppendWriteExtLog(content, isInit) {
				TopoAppendWriteLogCoreOperation(content, "C://TopoWriteExt_log.txt", isInit);
			}

			function TopoAppendWriteLogCoreOperation(content, filepath, isInit) {
				return; //正式运行时屏蔽掉
				//var m_date=new Date();
				//var m_content=m_date.toLocaleDateString() + " "+ m_date.toLocaleTimeString()+" "+content+"\r\n";
				var m_content = content + "\r\n";
				if(isInit)
					global.fs.writeFile(filepath, m_content);
				else
					global.fs.appendFile(filepath, m_content);
			}

			function topoThreadsleep(numberMillis) {
				var now = new Date();
				var exitTime = now.getTime() + numberMillis;
				while(true) {
					now = new Date();
					if(now.getTime() > exitTime)
						return;
				}
			}

			//拓扑功能-end-----------------------------------------------------------------------------
		}

		function initDom() {
			$('#addUserModal').modal({
				backdrop: 'static',
				show: false
			});
			$('#addDeviceModal').modal({
				backdrop: 'static',
				show: false
			});
			$('#loadingConfModal').modal({
				backdrop: 'static',
				show: false
			});

			//			//查询分组，并添加到select下
			//			var group_id = "group_name";
			//	     	$("#" + group_id).children().remove();
			//		    global.devicesIns.queryAllSubGroups(group_id, queryAllSubGroupsCbk);

			//添加下载模板路径
			var path = global.jsUtil.getRootPath() + '/db/device_import.xlsx';
			$("#downloadConfBtn").attr('href', path);
		}

		function resize() {
			var client_h = document.documentElement.clientHeight;
			var head_h = $(".main_menu").height();
			var body_h = client_h - head_h;

			$('#deiveManageTable').bootstrapTable('resetView', {
				height: body_h - 5
			});
		}

		function initGlobalEvent() {
			global.exitPageCallback.exitFun = function() {
				return true;
			}
		}
	}
	exports.init = init;

	//exports.guide = guide;

	//	function addTestData() {
	//		$('#deiveManageTable').bootstrapTable({
	//	        data: curDevInfo
	//	    });
	//		
	//		$(".fixed-table-body").addClass('custom-scroll');
	//		$("#deiveManageTable").show();
	//		$('#deiveManageTable').bootstrapTable('showLoading');
	//		$('#deiveManageTable').bootstrapTable('resetView', {height:550});
	//		
	//		var tmp_curDevInfo = {};
	//		for (var i = 0; i < 15; i++) {
	//			tmp_curDevInfo.deviceName = "192.168.23.191";
	//			tmp_curDevInfo.deviceModel = "S2910C-24GT2XS-P-E";
	//			tmp_curDevInfo.ipAddress = "192.168.23.191";
	//			tmp_curDevInfo.softVersion = "S2910_RGOS 11.4(1)B1P1, Release(03142218)";
	//			curDevInfo.push(tmp_curDevInfo);
	//		}
	//		$('#deiveManageTable').bootstrapTable('hideLoading');
	//		$('#deiveManageTable').bootstrapTable('load', curDevInfo);
	//	}
});