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';
|
2013-12-15 04:18:36 +08:00
|
|
|
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
|
|
|
|
2013-12-16 02:52:09 +08:00
|
|
|
require('./basestar');
|
|
|
|
|
2013-12-16 15:08:34 +08:00
|
|
|
namespace('Cylon', function() {
|
2013-12-15 04:18:36 +08:00
|
|
|
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;
|
2013-12-15 04:12:18 +08:00
|
|
|
this.device = opts.device;
|
2013-12-16 11:28:12 +08:00
|
|
|
this.connection = this.device.connection;
|
2014-02-19 08:29:38 +08:00
|
|
|
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() {
|
2014-02-19 08:29:38 +08:00
|
|
|
return this.commandList;
|
2014-01-17 03:13:28 +08:00
|
|
|
};
|
|
|
|
|
2013-12-16 02:52:09 +08:00
|
|
|
Driver.prototype.start = function(callback) {
|
|
|
|
Logger.info("Driver " + this.name + " started");
|
|
|
|
callback(null);
|
|
|
|
this.device.emit('start');
|
|
|
|
return true;
|
2013-12-15 03:54:56 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2013-12-15 04:18:36 +08:00
|
|
|
})(Cylon.Basestar);
|
2013-11-12 00:28:37 +08:00
|
|
|
});
|
|
|
|
|
2013-10-25 05:25:42 +08:00
|
|
|
}).call(this);
|