cylon/lib/driver.js

56 lines
1.4 KiB
JavaScript
Raw Normal View History

2013-10-25 05:25:42 +08:00
/*
* driver
* cylonjs.com
*
* Copyright (c) 2013 The Hybrid Group
* Licensed under the Apache 2.0 license.
*/
(function() {
'use strict';
var namespace,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
2013-10-25 05:25:42 +08:00
2013-11-12 00:28:37 +08:00
namespace = require('node-namespace');
2013-10-25 05:25:42 +08:00
require('./basestar');
namespace('Cylon', function() {
return this.Driver = (function(_super) {
__extends(Driver, _super);
2013-11-12 00:28:37 +08:00
function Driver(opts) {
2013-12-16 11:14:39 +08:00
if (opts == null) {
opts = {};
}
2013-11-12 00:28:37 +08:00
this.self = this;
this.name = opts.name;
this.device = opts.device;
this.connection = this.device.connection;
this.commandList = [];
2013-11-12 00:28:37 +08:00
}
2013-10-25 05:25:42 +08:00
2014-01-17 03:13:28 +08:00
Driver.prototype.commands = function() {
return this.commandList;
2014-01-17 03:13:28 +08:00
};
Driver.prototype.start = function(callback) {
Logger.info("Driver " + this.name + " started");
callback(null);
this.device.emit('start');
return true;
};
Driver.prototype.stop = function() {
return Logger.info("Driver " + this.name + " stopped");
2013-11-12 00:28:37 +08:00
};
2013-10-25 05:25:42 +08:00
2013-11-12 00:28:37 +08:00
return Driver;
})(Cylon.Basestar);
2013-11-12 00:28:37 +08:00
});
2013-10-25 05:25:42 +08:00
}).call(this);