"use strict";(function(){var e=0;var n=1;"use strict";var i=require("util");var t=require("events");var c=require("./deviceLinkMgr");var r=require("node-schedule");var o="";var v=1e3*20;function d(){t.EventEmitter.call(this);if(false===this instanceof d){return new d}this.deviceLinkMgrInst=new c;this.warnItems=[];o=this;if(n)setTimeout(function(){m(o)},1e3*5);s(o)}i.inherits(d,t.EventEmitter);function s(e){e.deviceLinkMgrInst.on("deviceConnected",function(n){g(e,n)});e.deviceLinkMgrInst.on("deviceDisconnected",function(n){e.emit("deviceDisconnected",n)});e.deviceLinkMgrInst.on("deviceError",function(n){e.emit("deviceError",n)});e.deviceLinkMgrInst.on("complete_end",function(n){e.emit("complete_end",n);e.deviceLinkMgrInst.closeDeviceLink(n)});e.deviceLinkMgrInst.on("device_update",function(n){e.emit("device_update",n)});e.deviceLinkMgrInst.on("device_add",function(n){e.emit("device_add",n)});e.deviceLinkMgrInst.on("device_delete",function(n){e.emit("device_delete",n)});e.deviceLinkMgrInst.on("admin_delete",function(n){e.emit("admin_delete",n)});e.deviceLinkMgrInst.on("admin_add",function(n){e.emit("admin_add",n)})}function u(e,n){var i=n.getDeviceInst();i.getDeviceIntfInfo(e,n)}function a(e,n){var i=n.getDeviceInst();i.getCpuInfo(e,n)}function f(e,n){var i=n.getDeviceInst();i.getUptimeInfo(e,n)}function g(e,n){var i=e.deviceLinkMgrInst.getDeviceLinkInstByName(n);if(i!=null){u(n,i);a(n,i);f(n,i)}}function m(e){var i=e.deviceLinkMgrInst.getDeviceConfigInfoFromMem("管理中");for(var t=0;t<i.length;t++){e.deviceLinkMgrInst.connectDeviceByDeviceName(i[t].deviceName)}if(n)setTimeout(function(){m(e)},1e3*300)}d.prototype.insertDevice=function(e,n){var i=this;i.deviceLinkMgrInst.addDeviceLink(e,n)};d.prototype.queryAllDevices=function(e){var n=this;n.deviceLinkMgrInst.getDeviceConfigInfoAll(e)};d.prototype.deleteDevices=function(e,n){var i=this;i.deviceLinkMgrInst.deleteDeviceLinkByDeviceName(e,n)};d.prototype.updateByDeviceName=function(e,n){var i=this;i.deviceLinkMgrInst.updateDeviceLink(e,n)};function I(e,n){e.deviceLinkMgrInst.connectDeviceByDeviceName(n.deviceName)}d.prototype.getDataImediately=function(e,n){var i=this;I(i,e)};d.prototype.addDevicesForAdmin=function(e,n){var i=this;i.deviceLinkMgrInst.addDevicesForAdmin(e,n)};d.prototype.runScheduleTask=function(){var e=new r.RecurrenceRule;e.dayOfWeek=[0,new r.Range(1,6)];e.hour=9;e.minute=0;e.second=0;r.scheduleJob(e,function(){m()});var n=new r.RecurrenceRule;n.dayOfWeek=[0,new r.Range(1,6)];n.hour=15;n.minute=0;n.second=0;r.scheduleJob(n,function(){m()})};d.prototype.deleteDevicesForAdmin=function(e,n){var i=this;i.deviceLinkMgrInst.deleteDevicesForAdmin(e,n)};d.prototype.getDbInstance=function(){var e=this;return e.deviceLinkMgrInst.getDbInstance()};module.exports=d})();