"use strict";(function(){"use strict";var e=require("util");var t=require("events");var i=1;function r(e){t.EventEmitter.call(this);if(false===this instanceof r){return new r}this.setupDb(e)}e.inherits(r,t.EventEmitter);r.prototype.setupDb=function(e){var t=this;var i="CREATE TABLE IF NOT EXISTS vsu_warn(id INTEGER PRIMARY KEY AUTOINCREMENT, time DATETIME, deviceName VARCHAR(32), seriaNo VARCHAR(32), errorType VARCHAR(50), desc VARCHAR(200));";this.db=e;this.db.serialize(function(){t.db.run(i)})};r.prototype.insertIntoVsuWarn=function(e,t){self.db.run("INSERT INTO vsu_devices(deviceName, seriaNo, time, errorType, desc)"+"VALUES (?, ?, ?, ?, ?);",[e.deviceName,e.seriaNo,e.time,e.errorType,e.desc],function(e){if(e){t(e)}else{t(null)}})};r.prototype.queryVsuWarn=function(e,t){this.db.all("SELECT * FROM vsu_warn WHERE deviceName = ?;",[e.deviceName],function(e,i){t(e,i)})};module.exports=r})();