Update examples that previously used findRobot

This commit is contained in:
Andrew Stewart 2014-06-06 11:53:54 -07:00
parent 81fa260963
commit 5690d723fb
5 changed files with 26 additions and 36 deletions

View File

@ -28,16 +28,16 @@ skynet = {
console.log(data);
if (data.payload != null){
var robot,
bot,
robots = data.payload.robots;
for(var index in robots){
robot = robots[index];
console.log(robot);
my.master.findRobot(robot.name, function(err, bot){
if (robot.cmd == 'on')
bot.devices[robot.device].turnOn();
else
bot.devices[robot.device].turnOff();
});
bot = Cylon.robots[robot.name];
if (robot.cmd == 'on')
bot.devices[robot.device].turnOn();
else
bot.devices[robot.device].turnOff();
}
}
});

View File

@ -29,9 +29,8 @@ var SalesforceRobot = (function() {
msg += "Bucks: " + data.sobject.Bucks__c + ",";
msg += "SM_Id: " + data.sobject.Id;
console.log(msg);
me.master.findRobot(data.sobject.Sphero_Name__c, function(err, spheroBot) {
spheroBot.react(spheroBot.devices.sphero);
});
var spheroBot = Cylon.robots[data.sobject.Sphero_Name__c];
spheroBot.react(spheroBot.devices.sphero);
});
});
};
@ -70,9 +69,8 @@ var SpheroRobot = (function() {
spheroName: "" + me.name,
bucks: "" + (me.totalBucks++)
});
me.master.findRobot('salesforce', function(err, sf) {
sf.devices.salesforce.push('SpheroController', 'POST', data);
});
var sf = Cylon.robots['salesforce'];
sf.devices.salesforce.push('SpheroController', 'POST', data);
});
};

View File

@ -42,9 +42,8 @@ tell it what work we want to do:
msg += "Bucks: " + data.sobject.Bucks__c + ",";
msg += "SM_Id: " + data.sobject.Id;
console.log(msg);
me.master.findRobot(data.sobject.Sphero_Name__c, function(err, spheroBot) {
spheroBot.react(spheroBot.devices.sphero);
});
var spheroBot = Cylon.robots[data.sobject.Sphero_Name__c];
spheroBot.react(spheroBot.devices.sphero);
});
});
};
@ -83,9 +82,8 @@ tell it what work we want to do:
spheroName: "" + me.name,
bucks: "" + (me.totalBucks++)
});
me.master.findRobot('salesforce', function(err, sf) {
sf.devices.salesforce.push('SpheroController', 'POST', data);
});
var sf = Cylon.robots['salesforce'];
sf.devices.salesforce.push('SpheroController', 'POST', data);
});
};

View File

@ -57,9 +57,8 @@ var SalesforceRobot = (function() {
console.log(msg);
me.master.findRobot(name, function(err, spheroBot) {
spheroBot.react(spheroBot.devices.sphero);
});
var spheroBot = Cylon.robots[name];
spheroBot.react(spheroBot.devices.sphero);
me.spheroReport[name] = bucks;
toPebble = "";
@ -71,9 +70,8 @@ var SalesforceRobot = (function() {
toPebble += "" + key + ": $" + val + "\n";
}
me.master.findRobot('pebble', function(error, pebbleBot) {
pebbleBot.message(pebbleBot.devices.pebble, toPebble);
});
var pebbleBot = Cylon.robots['pebble'];
pebbleBot.message(pebbleBot.devices.pebble, toPebble);
});
});
};
@ -141,9 +139,8 @@ var SpheroRobot = (function() {
bucks: "" + (me.totalBucks++)
});
me.master.findRobot('salesforce', function(err, sf) {
sf.devices.salesforce.push("SpheroController", "POST", data);
});
var sf = Cylon.robots['salesforce'];
sf.devices.salesforce.push("SpheroController", "POST", data);
});
};

View File

@ -78,9 +78,8 @@ Tell it what work we want to do:
console.log(msg);
me.master.findRobot(name, function(err, spheroBot) {
spheroBot.react(spheroBot.devices.sphero);
});
var spheroBot = Cylon.robots[name];
spheroBot.react(spheroBot.devices.sphero);
me.spheroReport[name] = bucks;
toPebble = "";
@ -92,9 +91,8 @@ Tell it what work we want to do:
toPebble += "" + key + ": $" + val + "\n";
}
me.master.findRobot('pebble', function(error, pebbleBot) {
pebbleBot.message(pebbleBot.devices.pebble, toPebble);
});
var pebbleBot = Cylon.robots['pebble'];
pebbleBot.message(pebbleBot.devices.pebble, toPebble);
});
});
};
@ -166,9 +164,8 @@ Tell it what work we want to do:
bucks: "" + (me.totalBucks++)
});
me.master.findRobot('salesforce', function(err, sf) {
sf.devices.salesforce.push("SpheroController", "POST", data);
});
var sf = Cylon.robots['salesforce'];
sf.devices.salesforce.push("SpheroController", "POST", data);
});
};