Add better error checking for Robot#halt

This commit is contained in:
Andrew Stewart 2015-01-21 08:56:13 -08:00
parent 754af3b4db
commit d56f9bc53f
2 changed files with 15 additions and 3 deletions

View File

@ -394,12 +394,22 @@ Robot.prototype.startDevices = function(callback) {
Robot.prototype.halt = function(callback) {
callback = callback || function() {};
if (!this.isRunning) {
return callback();
}
var devices = _.map(this.devices, "halt");
var connections = _.map(this.connections, "disconnect");
Async.parallel(devices, function() {
Async.parallel(connections, callback);
});
try {
Async.parallel(devices, function() {
Async.parallel(connections, callback);
});
} catch (e) {
var msg = "An error occured while attempting to safely halt the robot";
this.log("error", msg);
this.log("error", e.message);
}
this.running = false;
};

View File

@ -550,6 +550,8 @@ describe("Robot", function() {
}
});
bot.isRunning = true;
device = bot.devices.ping;
connection = bot.connections.loopback;