Default to manual mode, prevent multiple #starts

Additionally adds #halt/#disconnect to built-in loopback/ping
This commit is contained in:
Andrew Stewart 2014-09-30 12:15:46 -07:00
parent f029438c19
commit 8e0790ad9f
3 changed files with 16 additions and 1 deletions

View File

@ -120,7 +120,7 @@ var Robot = module.exports = function Robot(opts) {
this.commands = opts.commands;
}
var mode = Utils.fetch(Config, 'mode', 'auto');
var mode = Utils.fetch(Config, 'mode', 'manual');
if (mode === 'auto') {
// run on the next tick, to allow for 'work' event handlers to be set up
@ -235,6 +235,10 @@ Robot.prototype.initDevices = function(devices) {
//
// Returns the result of the work
Robot.prototype.start = function() {
if (this.running) {
return;
}
var begin = function(callback) {
Logger.info('Working.');
@ -255,6 +259,7 @@ Robot.prototype.start = function() {
Logger.fatal(err);
}
});
return this;
};
@ -329,6 +334,8 @@ Robot.prototype.halt = function(callback) {
Async.parallel(fns, callback);
}.bind(this));
this.running = false;
};
// Public: Initialize an adaptor and adds it to @robot.adaptors

View File

@ -23,4 +23,8 @@ Loopback.prototype.connect = function(callback) {
callback();
};
Loopback.prototype.disconnect = function(callback) {
callback();
};
Loopback.adaptor = function(opts) { return new Loopback(opts); };

View File

@ -30,6 +30,10 @@ Ping.prototype.start = function(callback) {
callback();
};
Ping.prototype.halt = function(callback) {
callback();
};
Ping.driver = function(opts) {
return new Ping(opts);
};