"use strict";(function(){var e=0;"use strict";var t=require("util");var o=require("events");var r=require("path");var n=require("./jsUtil");var l="Invalid input | Unknown command.";function i(){o.EventEmitter.call(this);if(false===this instanceof i){return new i}var e=this;e._abort=false}t.inherits(i,o.EventEmitter);i.prototype.setBasedInfo=function(e){var t=this;t.devMgr=e.devMgr;t.deviceName=e.deviceName;t.logPath=e.logPath;t.rollCmdPath=r.join(t.logPath,t.deviceName+"_diag_rollback")};i.prototype.rollback=function(e,t){var o=this;if(o._abort){return}var r=0;var i=e.backCmds;function a(e){setImmediate(function(){if(o._abort==true){console.log("stop rollback");return}o.devMgr.execCmd(o.deviceName,e,function(c,s){if(o._abort==true){console.log("stop rollback");return}if(c.search(l)!=-1){return t(new Error("failed"))}t(null,e,c,r+1,i.length);n.writeCmdWithTime(o.rollCmdPath,e,c);if(++r<i.length){a(i[r])}})})}if(r<i.length){a(i[r])}};i.prototype.abort=function(){var e=this;e._abort=true};module.exports=i;if(e){(function(){var e=require("./deviceLinkMgr");var t=new e;t.addDeviceLink({deviceName:"192.168.23.191",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 i;o.setBasedInfo({devMgr:t,deviceName:"192.168.23.191",logPath:"d:\\"});o.rollback({backCmds:["help","help","help","help","help","help","help","help","help","help","help","help","help","help"]},function(e,t,o,r,n){if(e!=null){return console.log("����ʧ��",e)}console.log("��ǰ���˵�"+r+"������");console.log("һ����"+n+"������");console.log("��ǰִ������:"+t);console.log("�豸��Ӧ����:"+o);if(r==n){console.log("���˽���: ���˳ɹ�")}});setTimeout(function(){o.abort()},1e3)});t.connectDeviceByDeviceName("192.168.23.191")})()}})();