"use strict";(function(){var e=0;"use strict";var t=require("util");var i=require("events");function s(e){i.EventEmitter.call(this);if(false===this instanceof s){return new s}this.setupDb(e)}t.inherits(s,i.EventEmitter);s.prototype.setupDb=function(e){var t=this;var i="CREATE TABLE IF NOT EXISTS vsu_master(deviceName VARCHAR(32),seriaNo VARCHAR(32),time DATETIME, masterNum INTEGER,PRIMARY KEY(deviceName, seriaNo));";var s="CREATE TABLE IF NOT EXISTS vsu_ap(deviceName VARCHAR(32),seriaNo VARCHAR(32),time DATETIME,apName VARCHAR(32), totalPorts INTEGER, upPorts INTEGER, PRIMARY KEY(deviceName, seriaNo));";var a="CREATE TABLE IF NOT EXISTS vsu_vsl(deviceName VARCHAR(32),seriaNo VARCHAR(32),time DATETIME,switchId INTEGER,totalVsls INTEGER,okVsls INTEGER, PRIMARY KEY(deviceName,seriaNo));";var o="CREATE TABLE IF NOT EXISTS vsu_route(deviceName VARCHAR(32), seriaNo VARCHAR(32),time DATETIME, totalRoutes INTEGER, upRoutes INTEGER,PRIMARY KEY(deviceName,seriaNo));";this.db=e;this.db.serialize(function(){t.db.run(i);t.db.run(s);t.db.run(a);t.db.run(o)})};s.prototype.replaceIntoVsuMaster=function(e,t){var i=this;i.db.run("REPLACE INTO vsu_master(deviceName, seriaNo, time, masterNum)"+"VALUES (?, ?, ?, ?);",[e.deviceName,e.seriaNo,e.time,e.masterNum],function(e){if(e){t(e)}else{t(null)}})};s.prototype.replaceIntoVsuAp=function(e,t){var i=this;i.db.run("REPLACE INTO vsu_ap(deviceName, seriaNo, time, apName, totalPorts, upPorts)"+"VALUES (?, ?, ?, ?, ?, ?);",[e.deviceName,e.seriaNo,e.time,e.apName,e.totalPorts,e.upPorts],function(e){if(e){t(e)}else{t(null)}})};s.prototype.replaceIntoVsuVsl=function(e,t){var i=this;i.db.run("REPLACE INTO vsu_vsl(deviceName, seriaNo, time, switchId, totalVsls, okVsls)"+"VALUES (?, ?, ?, ?, ?, ?);",[e.deviceName,e.seriaNo,e.time,e.switchId,e.totalVsls,e.okVsls],function(e){if(e){t(e)}else{t(null)}})};s.prototype.replaceIntoVsuRoute=function(e,t){var i=this;i.db.run("REPLACE INTO vsu_route(deviceName, seriaNo, time, totalRoutes, upRoutes)"+"VALUES (?, ?, ?, ?,?);",[e.deviceName,e.seriaNo,e.time,e.totalRoutes,e.upRoutes],function(e){if(e){t(e)}else{t(null)}})};s.prototype.queryVsuMaster=function(e,t){var i=this;this.db.all("SELECT * FROM vsu_master WHERE deviceName = ?;",[e.deviceName],function(e,i){t(e,i)})};s.prototype.queryVsuAp=function(e,t){this.db.all("SELECT * FROM vsu_ap WHERE deviceName = ?;",[e.deviceName],function(e,i){t(e,i)})};s.prototype.queryVsuVsl=function(e,t){this.db.all("SELECT * FROM vsu_vsl WHERE deviceName = ?;",[e.deviceName],function(e,i){t(e,i)})};s.prototype.queryVsuRoute=function(e,t){this.db.all("SELECT * FROM vsu_route WHERE deviceName = ?;",[e.deviceName],function(e,i){t(e,i)})};module.exports=s})();