Refactor adaptor & driver to pure JS style

This commit is contained in:
deadprogram 2014-02-27 09:38:38 -08:00
parent 74efee0809
commit 8b88e5dc10
2 changed files with 60 additions and 76 deletions

View File

@ -2,52 +2,44 @@
* adaptor
* cylonjs.com
*
* Copyright (c) 2013 The Hybrid Group
* Copyright (c) 2013-2014 The Hybrid Group
* Licensed under the Apache 2.0 license.
*/
"use strict";
(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; };
require('./basestar');
var namespace = require('node-namespace');
namespace = require('node-namespace');
namespace("Cylon", function() {
this.Adaptor = (function(klass) {
subclass(Adaptor, klass);
require('./basestar');
namespace('Cylon', function() {
return this.Adaptor = (function(_super) {
__extends(Adaptor, _super);
function Adaptor(opts) {
if (opts == null) {
opts = {};
}
this.self = this;
this.name = opts.name;
this.connection = opts.connection;
this.commandList = [];
function Adaptor(opts) {
if (opts == null) {
opts = {};
}
this.self = this;
this.name = opts.name;
this.connection = opts.connection;
this.commandList = [];
}
Adaptor.prototype.commands = function() {
return this.commandList;
};
Adaptor.prototype.commands = function() {
return this.commandList;
};
Adaptor.prototype.connect = function(callback) {
Logger.info("Connecting to adaptor '" + this.name + "'...");
callback(null);
return this.connection.emit('connect');
};
Adaptor.prototype.connect = function(callback) {
Logger.info("Connecting to adaptor '" + this.name + "'...");
callback(null);
return this.connection.emit('connect');
};
Adaptor.prototype.disconnect = function() {
return Logger.info("Disconnecting from adaptor '" + this.name + "'...");
};
Adaptor.prototype.disconnect = function() {
return Logger.info("Disconnecting from adaptor '" + this.name + "'...");
};
return Adaptor;
return Adaptor;
})(Cylon.Basestar);
});
}).call(this);
})(Cylon.Basestar);
});

View File

@ -2,54 +2,46 @@
* driver
* cylonjs.com
*
* Copyright (c) 2013 The Hybrid Group
* Copyright (c) 2013-2014 The Hybrid Group
* Licensed under the Apache 2.0 license.
*/
'use strict';
(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; };
require('./basestar');
var namespace = require('node-namespace');
namespace = require('node-namespace');
namespace("Cylon", function() {
this.Driver = (function(klass) {
subclass(Driver, klass);
require('./basestar');
namespace('Cylon', function() {
return this.Driver = (function(_super) {
__extends(Driver, _super);
function Driver(opts) {
if (opts == null) {
opts = {};
}
this.self = this;
this.name = opts.name;
this.device = opts.device;
this.connection = this.device.connection;
this.commandList = [];
function Driver(opts) {
if (opts == null) {
opts = {};
}
this.self = this;
this.name = opts.name;
this.device = opts.device;
this.connection = this.device.connection;
this.commandList = [];
}
Driver.prototype.commands = function() {
return this.commandList;
};
Driver.prototype.commands = function() {
return this.commandList;
};
Driver.prototype.start = function(callback) {
Logger.info("Driver " + this.name + " started");
callback(null);
this.device.emit('start');
return true;
};
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");
};
Driver.prototype.stop = function() {
return Logger.info("Driver " + this.name + " stopped");
};
return Driver;
return Driver;
})(Cylon.Basestar);
});
}).call(this);
})(Cylon.Basestar);
});