"use strict";(function(){var e=0;"use strict";var t=require("util");var o=require("events");var n=require("path");var i=require("./jsUtil");var r="Invalid input | Unknown command.";function a(){o.EventEmitter.call(this);if(false===this instanceof a){return new a}var e=this;e._abort=false}t.inherits(a,o.EventEmitter);a.prototype.setBasedInfo=function(e){var t=this;t.devMgr=e.devMgr;t.deviceName=e.deviceName;t.logPath=e.logPath;t.fixCmdPath=n.join(t.logPath,t.deviceName+"_diag_fix")};a.prototype.fix=function(e,t){var o=this;if(o._abort){return}var n=0;var a=e.fixCmds;function l(e){setImmediate(function(){if(o._abort==true){console.log("stop fix");return}o.devMgr.execCmd(o.deviceName,e,function(c,s){if(o._abort==true){console.log("stop fix");return}if(c.search(r)!=-1){return t(new Error("failed"))}t(null,e,c,n+1,a.length);i.writeCmdWithTime(o.fixCmdPath,e,c);if(++n<a.length){l(a[n])}})})}if(n<a.length){l(a[n])}};a.prototype.abort=function(){var e=this;e._abort=true};module.exports=a;if(e){(function(){var e=require("./deviceLinkMgr");var t=new e;t.addDeviceLink({deviceName:"loma",protocal:"telnet",host:"192.168.23.191",port:23,username:"adm",password:"adm",enablePassword:"",containShell:true},function(e){console.log(e)});t.on("deviceConnected",function(e){var o=new a;o.setBasedInfo({devMgr:t,deviceName:"loma",logPath:"d:\\"});o.fix({fixCmds:["help","help","help","help","help","help","help","help","help","help","help","help","help","help"]},function(e,t,o,n,i){if(e!=null){return console.log("修复失败",e)}console.log("当前修复第"+n+"条命令");console.log("一共有"+i+"条命令");console.log("当前执行命令:"+t);console.log("设备响应内容:"+o);if(n==i){console.log("修复结束: 修复成功")}});setTimeout(function(){o.abort()},1e3)});t.connectDeviceByDeviceName("loma")})()}})();