Refactor device/connection initialization methods
This commit is contained in:
parent
d9ef9046e9
commit
862a3702b7
29
lib/robot.js
29
lib/robot.js
|
@ -144,18 +144,18 @@ namespace("Cylon", function() {
|
|||
//
|
||||
// Returns initialized connections
|
||||
Robot.prototype.initConnections = function(connections) {
|
||||
var connection, _i, _len;
|
||||
Logger.info("Initializing connections...");
|
||||
if (connections == null) {
|
||||
return;
|
||||
}
|
||||
if (connections == null) { return; }
|
||||
|
||||
connections = [].concat(connections);
|
||||
for (_i = 0, _len = connections.length; _i < _len; _i++) {
|
||||
connection = connections[_i];
|
||||
|
||||
for (var i = 0; i < connections.length; i++) {
|
||||
var connection = connections[i];
|
||||
Logger.info("Initializing connection '" + connection.name + "'...");
|
||||
connection['robot'] = this;
|
||||
this.connections[connection.name] = new Cylon.Connection(connection);
|
||||
}
|
||||
|
||||
return this.connections;
|
||||
};
|
||||
|
||||
|
@ -165,20 +165,19 @@ namespace("Cylon", function() {
|
|||
//
|
||||
// Returns initialized devices
|
||||
Robot.prototype.initDevices = function(devices) {
|
||||
var device, _i, _len, _results;
|
||||
Logger.info("Initializing devices...");
|
||||
if (devices == null) {
|
||||
return;
|
||||
}
|
||||
if (devices == null) { return; }
|
||||
|
||||
devices = [].concat(devices);
|
||||
_results = [];
|
||||
for (_i = 0, _len = devices.length; _i < _len; _i++) {
|
||||
device = devices[_i];
|
||||
|
||||
for (var i = 0; i < devices.length; i++) {
|
||||
var device = devices[i];
|
||||
Logger.info("Initializing device '" + device.name + "'...");
|
||||
device['robot'] = this;
|
||||
_results.push(this.devices[device.name] = new Cylon.Device(device));
|
||||
this.devices[device.name] = new Cylon.Device(device);
|
||||
}
|
||||
return _results;
|
||||
|
||||
return this.devices;
|
||||
};
|
||||
|
||||
// Public: Starts the Robot working.
|
||||
|
|
Loading…
Reference in New Issue