WIP on refactoring adaptor/driver base classes

This commit is contained in:
deadprogram 2013-12-15 10:52:09 -08:00
parent 4a058742c4
commit 4cb8742fc3
11 changed files with 40 additions and 22 deletions

4
dist/adaptor.js vendored
View File

@ -15,6 +15,8 @@
namespace = require('node-namespace');
require('./basestar');
namespace('Cylon.Adaptors', function() {
return this.Adaptor = (function(_super) {
__extends(Adaptor, _super);
@ -44,6 +46,4 @@
})(Cylon.Basestar);
});
module.exports = Cylon.Adaptors.Adaptor;
}).call(this);

4
dist/cylon.js vendored
View File

@ -19,6 +19,10 @@
require('./api');
require('./driver');
require('./adaptor');
Logger.setup();
Cylon = (function() {

11
dist/driver.js vendored
View File

@ -15,6 +15,8 @@
namespace = require('node-namespace');
require('./basestar');
namespace('Cylon.Drivers', function() {
return this.Driver = (function(_super) {
__extends(Driver, _super);
@ -25,8 +27,11 @@
this.device = opts.device;
}
Driver.prototype.start = function() {
return Logger.info("Driver " + this.name + " started");
Driver.prototype.start = function(callback) {
Logger.info("Driver " + this.name + " started");
callback(null);
this.device.emit('start');
return true;
};
Driver.prototype.stop = function() {
@ -42,6 +47,4 @@
})(Cylon.Basestar);
});
module.exports = Cylon.Drivers.Driver;
}).call(this);

View File

@ -29,13 +29,11 @@
};
namespace('Cylon.Adaptors', function() {
var _ref;
return this.Loopback = (function(_super) {
__extends(Loopback, _super);
function Loopback() {
_ref = Loopback.__super__.constructor.apply(this, arguments);
return _ref;
function Loopback(opts) {
Loopback.__super__.constructor.apply(this, arguments);
}
Loopback.prototype.commands = function() {
@ -44,7 +42,7 @@
return Loopback;
})(this.Adaptor);
})(Cylon.Adaptors.Adaptor);
});
}).call(this);

8
dist/test/ping.js vendored
View File

@ -29,13 +29,11 @@
};
namespace('Cylon.Drivers', function() {
var _ref;
return this.Ping = (function(_super) {
__extends(Ping, _super);
function Ping() {
_ref = Ping.__super__.constructor.apply(this, arguments);
return _ref;
function Ping(opts) {
Ping.__super__.constructor.apply(this, arguments);
}
Ping.prototype.commands = function() {
@ -48,7 +46,7 @@
return Ping;
})(this.Driver);
})(Cylon.Drivers.Driver);
});
}).call(this);

View File

@ -1,6 +1,6 @@
{
"name": "cylon",
"version": "0.7.0",
"version": "0.8.0",
"main": "dist/cylon.js",
"description": "A JavaScript robotics framework using Node.js",
"homepage": "http://cylonjs.com",

View File

@ -10,6 +10,8 @@
namespace = require 'node-namespace'
require './basestar'
namespace 'Cylon.Adaptors', ->
class @Adaptor extends Cylon.Basestar
constructor: (opts) ->
@ -28,4 +30,4 @@ namespace 'Cylon.Adaptors', ->
disconnect: ->
Logger.info "Disconnecting from adaptor '#{@name}'..."
module.exports = Cylon.Adaptors.Adaptor
#module.exports = Cylon.Adaptor

View File

@ -11,6 +11,8 @@
require './utils'
require './logger'
require './api'
require './driver'
require './adaptor'
Logger.setup()

View File

@ -10,6 +10,8 @@
namespace = require 'node-namespace'
require './basestar'
namespace 'Cylon.Drivers', ->
class @Driver extends Cylon.Basestar
constructor: (opts) ->
@ -17,8 +19,11 @@ namespace 'Cylon.Drivers', ->
@name = opts.name
@device = opts.device
start: ->
start: (callback) ->
Logger.info "Driver #{@name} started"
(callback)(null)
@device.emit 'start'
true
stop: ->
Logger.info "Driver #{@name} stopped"
@ -26,4 +31,4 @@ namespace 'Cylon.Drivers', ->
commands: ->
[]
module.exports = Cylon.Drivers.Driver
#module.exports = Cylon.Driver

View File

@ -15,6 +15,9 @@ module.exports =
new Cylon.Adaptors.Loopback(args...)
namespace 'Cylon.Adaptors', ->
class @Loopback extends @Adaptor
class @Loopback extends Cylon.Adaptors.Adaptor
constructor: (opts) ->
super
commands: ->
['ping']

View File

@ -15,7 +15,10 @@ module.exports =
new Cylon.Drivers.Ping(args...)
namespace 'Cylon.Drivers', ->
class @Ping extends @Driver
class @Ping extends Cylon.Drivers.Driver
constructor: (opts) ->
super
commands: ->
['ping']