Update examples for new syntax
This commit is contained in:
parent
9047797c9f
commit
7d4aa1ffee
|
@ -16,8 +16,13 @@ Object.keys(bots).forEach(function(name) {
|
|||
Cylon.robot({
|
||||
name: name,
|
||||
|
||||
connection: { name: 'sphero', adaptor: 'sphero', port: port },
|
||||
device: { name: 'sphero', driver: 'sphero' },
|
||||
connections: {
|
||||
sphero: { adaptor: 'sphero', port: port }
|
||||
},
|
||||
|
||||
devices: {
|
||||
sphero: { driver: 'sphero' }
|
||||
},
|
||||
|
||||
work: function(my) {
|
||||
every((1).seconds(), function() {
|
||||
|
|
|
@ -39,12 +39,16 @@ Now we can define the basic robot both of our Sphero robots will be based on.
|
|||
Both robots will be connecting to Spheros, and so using the cylon-sphero
|
||||
adaptor:
|
||||
|
||||
connection: { name: 'sphero', adaptor: 'sphero', port: port },
|
||||
connections: {
|
||||
sphero: { adaptor: 'sphero', port: port }
|
||||
},
|
||||
|
||||
And both will be connecting to the same kind of device (you guessed it,
|
||||
a Sphero).
|
||||
|
||||
device: { name: 'sphero', driver: 'sphero' },
|
||||
devices: {
|
||||
sphero: { driver: 'sphero' }
|
||||
},
|
||||
|
||||
Both robots will be performing the same kind of work as well. Every second,
|
||||
they'll print their name to the console, set themselves to a random color, and
|
||||
|
|
|
@ -21,7 +21,9 @@ bots.forEach(function(bot) {
|
|||
skynet: { adaptor: "skynet", uuid: bot.uuid, token: bot.port }
|
||||
},
|
||||
|
||||
device: { name: "led13", driver: "led", pin: 13, connection: "arduino" },
|
||||
devices: {
|
||||
led13: { driver: "led", pin: 13, connection: "arduino" }
|
||||
},
|
||||
|
||||
work: function(my) {
|
||||
my.skynet.on('message', function(data) {
|
||||
|
|
|
@ -23,11 +23,12 @@ var arduinos = [
|
|||
Cylon.robot({
|
||||
name: "SkynetBot",
|
||||
|
||||
connection: {
|
||||
name: 'skynet',
|
||||
adaptor: 'skynet',
|
||||
uuid: "96630051-a3dc-11e3-8442-5bf31d98c912",
|
||||
token: "2s67o7ek98pycik98f43reqr90t6s9k9"
|
||||
connections: {
|
||||
skynet: {
|
||||
adaptor: 'skynet',
|
||||
uuid: "96630051-a3dc-11e3-8442-5bf31d98c912",
|
||||
token: "2s67o7ek98pycik98f43reqr90t6s9k9"
|
||||
}
|
||||
},
|
||||
|
||||
handler: function(data) {
|
||||
|
@ -59,7 +60,10 @@ arduinos.forEach(function(bot) {
|
|||
Cylon.robot({
|
||||
name: bot.name,
|
||||
|
||||
connection: { name: 'arduino', adaptor: 'firmata', port: bot.port },
|
||||
connections: {
|
||||
arduino: { adaptor: 'firmata', port: bot.port }
|
||||
},
|
||||
|
||||
devices: bot.devices,
|
||||
|
||||
work: function(my) {
|
||||
|
|
|
@ -16,8 +16,13 @@ Object.keys(bots).forEach(function(name) {
|
|||
Cylon.robot({
|
||||
name: name,
|
||||
|
||||
connection: { name: 'sphero', adaptor: 'sphero', port: port },
|
||||
device: { name: 'sphero', driver: 'sphero' },
|
||||
connections: {
|
||||
sphero: { adaptor: 'sphero', port: port }
|
||||
},
|
||||
|
||||
devices: {
|
||||
sphero: { driver: 'sphero' }
|
||||
},
|
||||
|
||||
work: function(my) {
|
||||
my.born();
|
||||
|
|
|
@ -59,8 +59,13 @@ device (you guessed it, a Sphero).
|
|||
Cylon.robot({
|
||||
name: name,
|
||||
|
||||
connection: { name: 'sphero', adaptor: 'sphero', port: port },
|
||||
device: { name: 'sphero', driver: 'sphero' },
|
||||
connections: {
|
||||
sphero: { adaptor: 'sphero', port: port }
|
||||
},
|
||||
|
||||
devices: {
|
||||
sphero: { driver: 'sphero' }
|
||||
},
|
||||
|
||||
Now that the pieces are there, we can set up our robot's work. It starts by
|
||||
being "born", then moves every three seconds if it's alive, celebrates it's
|
||||
|
|
|
@ -15,8 +15,8 @@ Object.keys(bots).forEach(function(name) {
|
|||
|
||||
var robot = Cylon.robot({ name: name, });
|
||||
|
||||
robot.connection({ name: 'sphero', adaptor: 'sphero', port: port });
|
||||
robot.device({ name: 'sphero', driver: 'sphero' });
|
||||
robot.connection('sphero', { adaptor: 'sphero', port: port });
|
||||
robot.device('sphero', { driver: 'sphero' });
|
||||
|
||||
robot.move = function() {
|
||||
robot.sphero.roll(60, Math.floor(Math.random() * 360));
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
var Cylon = require('../..');
|
||||
|
||||
Cylon.robot({
|
||||
connection: { name: 'crazyflie', adaptor: 'crazyflie', port: "radio://1/10/250KPS" },
|
||||
device: { name: 'drone', driver: 'crazyflie' },
|
||||
connections: {
|
||||
crazyflie: { adaptor: 'crazyflie', port: "radio://1/10/250KPS" }
|
||||
},
|
||||
|
||||
devices: {
|
||||
drone: { driver: 'crazyflie' }
|
||||
}
|
||||
|
||||
work: function(my) {
|
||||
my.drone.on('start', function() {
|
||||
|
|
|
@ -15,13 +15,13 @@ Now that we've got that set up, we can start defining our robot:
|
|||
We'll be using one connection and one device for this robot, both using the
|
||||
crazyflie adaptor. We'll be connecting to the Crazyflie using the CrazyRadio.
|
||||
|
||||
connection: {
|
||||
name: 'crazyflie',
|
||||
adaptor: 'crazyflie',
|
||||
port: "radio://1/10/250KPS"
|
||||
connections: {
|
||||
crazyflie: { adaptor: 'crazyflie', port: "radio://1/10/250KPS" }
|
||||
},
|
||||
|
||||
device: { name: 'drone', driver: 'crazyflie' }
|
||||
devices: {
|
||||
drone: { driver: 'crazyflie' }
|
||||
}
|
||||
|
||||
With the parts in place, we can start defining our robot's work.
|
||||
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
var Cylon = require('../..');
|
||||
|
||||
Cylon.robot({
|
||||
connection: { name: 'digispark', adaptor: 'digispark' },
|
||||
device: { name: 'led', driver: 'led', pin: 1 },
|
||||
connections: {
|
||||
digispark: { adaptor: 'digispark' }
|
||||
},
|
||||
|
||||
devices: {
|
||||
led: { driver: 'led', pin: 1 }
|
||||
},
|
||||
|
||||
work: function(my) {
|
||||
every((1).second(), my.led.toggle);
|
||||
|
|
|
@ -10,8 +10,13 @@ Now that we have Cylon imported, we can start defining our robot
|
|||
|
||||
Let's define the connections and devices:
|
||||
|
||||
connection: { name: 'digispark', adaptor: 'digispark' },
|
||||
device: { name: 'led', driver: 'led', pin: 1 },
|
||||
connections: {
|
||||
digispark: { adaptor: 'digispark' }
|
||||
},
|
||||
|
||||
devices: {
|
||||
led: { driver: 'led', pin: 1 }
|
||||
},
|
||||
|
||||
Now that Cylon knows about the necessary hardware we're going to be using, we'll
|
||||
tell it what work we want to do:
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
var Cylon = require('../..');
|
||||
|
||||
Cylon.robot({
|
||||
connection: { name: 'loopback', adaptor: 'loopback' },
|
||||
device: { name: 'ping', driver: 'ping' },
|
||||
connections: {
|
||||
loopback: { adaptor: 'loopback' }
|
||||
},
|
||||
|
||||
devices: {
|
||||
ping: { driver: 'ping' }
|
||||
},
|
||||
|
||||
work: function(my) {
|
||||
after((1).second(), function() {
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
var Cylon = require('../..');
|
||||
|
||||
Cylon.api();
|
||||
|
||||
Cylon
|
||||
.robot({ name: 'test' })
|
||||
.connection('loopback', { adaptor: 'loopback' })
|
||||
.device('ping', { driver: 'ping' })
|
||||
.on('ready', function(bot) {
|
||||
setInterval(function() {
|
||||
console.log("Hello, human!")
|
||||
console.log(bot.ping.ping());
|
||||
}, 1000);
|
||||
|
||||
setTimeout(function() {
|
||||
console.log("I've been at your command for 5 seconds now.")
|
||||
}, 5000);
|
||||
});
|
||||
|
||||
Cylon.start();
|
|
@ -5,8 +5,13 @@ Cylon.api();
|
|||
Cylon.robot({
|
||||
name: 'test',
|
||||
|
||||
connection: { name: 'loopback', adaptor: 'loopback' },
|
||||
device: { name: 'ping', driver: 'ping' },
|
||||
connections: {
|
||||
loopback: { adaptor: 'loopback' }
|
||||
},
|
||||
|
||||
devices: {
|
||||
ping: { driver: 'ping' }
|
||||
},
|
||||
|
||||
work: function(my) {
|
||||
every((1).seconds(), function(){
|
||||
|
|
|
@ -13,8 +13,13 @@ Now we can define our robot:
|
|||
Cylon.robot({
|
||||
name: 'test',
|
||||
|
||||
connection: { name: 'loopback', adaptor: 'loopback' },
|
||||
device: { name: 'ping', driver: 'ping' },
|
||||
connections: {
|
||||
loopback: { adaptor: 'loopback' }
|
||||
},
|
||||
|
||||
devices: {
|
||||
ping: { driver: 'ping' }
|
||||
},
|
||||
|
||||
For work, it's going to print a message to the console every second, and another
|
||||
message after five seconds have elapsed.
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
var Cylon = require('cylon');
|
||||
|
||||
var robot = new Cylon.Robot({
|
||||
connection: { name: 'loopback', adaptor: 'loopback' },
|
||||
device: { name: 'ping', driver: 'ping' },
|
||||
});
|
||||
|
||||
setInterval(function() {
|
||||
console.log("Hello, human!")
|
||||
console.log(robot.ping.ping());
|
||||
}, 1000);
|
||||
|
||||
setTimeout(function() {
|
||||
console.log("I've been at your command for 5 seconds now.")
|
||||
}, 5000);
|
|
@ -1,8 +1,13 @@
|
|||
var Cylon = require('../..');
|
||||
|
||||
Cylon.robot({
|
||||
connection: { name: 'keyboard', adaptor: 'keyboard' },
|
||||
device: { name: 'keyboard', driver: 'keyboard' },
|
||||
connections: {
|
||||
keyboard: { adaptor: 'keyboard' }
|
||||
},
|
||||
|
||||
devices: {
|
||||
keyboard: { driver: 'keyboard' }
|
||||
},
|
||||
|
||||
work: function(my) {
|
||||
my.keyboard.on('a', function(key) {
|
||||
|
|
|
@ -13,8 +13,13 @@ With that done, let's define our robot:
|
|||
|
||||
It will have a single connection and device, both to the keyboard.
|
||||
|
||||
connection: { name: 'keyboard', adaptor: 'keyboard' },
|
||||
device: { name: 'keyboard', driver: 'keyboard' },
|
||||
connections: {
|
||||
keyboard: { adaptor: 'keyboard' }
|
||||
},
|
||||
|
||||
devices: {
|
||||
keyboard: { driver: 'keyboard' }
|
||||
},
|
||||
|
||||
When we tell this robot to work, it's going to listen to the 'a' key on the
|
||||
keyboard and let us know when it's been pressed.
|
||||
|
|
|
@ -6,7 +6,9 @@ Cylon.robot({
|
|||
arduino: { adaptor: 'firmata', port: '/dev/ttyACM0' }
|
||||
},
|
||||
|
||||
devices: { name: 'led', driver: 'led', pin: 13, connection: 'arduino' },
|
||||
devices: {
|
||||
led: { driver: 'led', pin: 13, connection: 'arduino' }
|
||||
},
|
||||
|
||||
work: function(my) {
|
||||
my.leapmotion.on('frame', function(frame) {
|
||||
|
|
|
@ -15,7 +15,9 @@ Let's define the connections and devices:
|
|||
arduino: { adaptor: 'firmata', port: '/dev/ttyACM0' }
|
||||
},
|
||||
|
||||
device: { name: 'led', driver: 'led', pin: 13, connection: 'arduino' },
|
||||
devices: {
|
||||
led: { driver: 'led', pin: 13, connection: 'arduino' }
|
||||
},
|
||||
|
||||
Now that Cylon knows about the necessary hardware we're going to be using, we'll
|
||||
tell it what work we want to do:
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
var Cylon = require('../..');
|
||||
|
||||
Cylon.robot({
|
||||
connection: { name: 'arduino', adaptor: 'firmata', port: '/dev/ttyUSB0' },
|
||||
connections: {
|
||||
arduino: { adaptor: 'firmata', port: '/dev/ttyUSB0' }
|
||||
},
|
||||
|
||||
devices: {
|
||||
led: { driver: 'led', pin: 17 },
|
||||
servo: { driver: 'servo', pin: 2, range: { min: 30, max: 150 } }
|
||||
|
|
|
@ -1,19 +1,22 @@
|
|||
var Cylon = require('../..');
|
||||
|
||||
Cylon.robot({
|
||||
connection: {
|
||||
name: 'sfcon',
|
||||
adaptor: 'force',
|
||||
sfuser: process.env.SF_USERNAME,
|
||||
sfpass: process.env.SF_SECURITY_TOKEN,
|
||||
orgCreds: {
|
||||
clientId: process.env.SF_CLIENT_ID,
|
||||
clientSecret: process.env.SF_CLIENT_SECRET,
|
||||
redirectUri: 'http://localhost:3000/oauth/_callback'
|
||||
connections: {
|
||||
sfcon: {
|
||||
adaptor: 'force',
|
||||
sfuser: process.env.SF_USERNAME,
|
||||
sfpass: process.env.SF_SECURITY_TOKEN,
|
||||
orgCreds: {
|
||||
clientId: process.env.SF_CLIENT_ID,
|
||||
clientSecret: process.env.SF_CLIENT_SECRET,
|
||||
redirectUri: 'http://localhost:3000/oauth/_callback'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
device: { name: 'salesforce', driver: 'force' },
|
||||
devices: {
|
||||
salesforce: { driver: 'force' }
|
||||
},
|
||||
|
||||
work: function(my) {
|
||||
my.salesforce.on('start', function() {
|
||||
|
|
|
@ -10,19 +10,22 @@ Now that we have Cylon imported, we can start defining our robot
|
|||
|
||||
Let's define the connections and devices:
|
||||
|
||||
connection: {
|
||||
name: 'sfcon',
|
||||
adaptor: 'force',
|
||||
sfuser: process.env.SF_USERNAME,
|
||||
sfpass: process.env.SF_SECURITY_TOKEN,
|
||||
orgCreds: {
|
||||
clientId: process.env.SF_CLIENT_ID,
|
||||
clientSecret: process.env.SF_CLIENT_SECRET,
|
||||
redirectUri: 'http://localhost:3000/oauth/_callback'
|
||||
connections: {
|
||||
sfcon: {
|
||||
adaptor: 'force',
|
||||
sfuser: process.env.SF_USERNAME,
|
||||
sfpass: process.env.SF_SECURITY_TOKEN,
|
||||
orgCreds: {
|
||||
clientId: process.env.SF_CLIENT_ID,
|
||||
clientSecret: process.env.SF_CLIENT_SECRET,
|
||||
redirectUri: 'http://localhost:3000/oauth/_callback'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
device: { name: 'salesforce', driver: 'force' },
|
||||
devices: {
|
||||
salesforce: { driver: 'force' }
|
||||
},
|
||||
|
||||
Now that Cylon knows about the necessary hardware we're going to be using, we'll
|
||||
tell it what work we want to do:
|
||||
|
|
|
@ -3,19 +3,22 @@ var Cylon = require('../..');
|
|||
Cylon.robot({
|
||||
name: 'salesforce',
|
||||
|
||||
connection: {
|
||||
name: 'sfcon',
|
||||
adaptor: 'force',
|
||||
sfuser: process.env.SF_USERNAME,
|
||||
sfpass: process.env.SF_SECURITY_TOKEN,
|
||||
orgCreds: {
|
||||
clientId: process.env.SF_CLIENT_ID,
|
||||
clientSecret: process.env.SF_CLIENT_SECRET,
|
||||
redirectUri: 'http://localhost:3000/oauth/_callback'
|
||||
connections: {
|
||||
sfcon: {
|
||||
adaptor: 'force',
|
||||
sfuser: process.env.SF_USERNAME,
|
||||
sfpass: process.env.SF_SECURITY_TOKEN,
|
||||
orgCreds: {
|
||||
clientId: process.env.SF_CLIENT_ID,
|
||||
clientSecret: process.env.SF_CLIENT_SECRET,
|
||||
redirectUri: 'http://localhost:3000/oauth/_callback'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
device: { name: 'salesforce', driver: 'force' },
|
||||
devices: {
|
||||
salesforce: { driver: 'force' }
|
||||
},
|
||||
|
||||
work: function(my) {
|
||||
my.salesforce.on('start', function() {
|
||||
|
@ -35,8 +38,14 @@ Cylon.robot({
|
|||
|
||||
Cylon.robot({
|
||||
name: 'ROY',
|
||||
connection: { name: 'sphero', adaptor: 'sphero' },
|
||||
device: { name: 'sphero', driver: 'sphero' },
|
||||
|
||||
connections: {
|
||||
sphero: { adaptor: 'sphero' }
|
||||
},
|
||||
|
||||
devices: {
|
||||
sphero: { driver: 'sphero' }
|
||||
},
|
||||
|
||||
react: function() {
|
||||
this.sphero.setRGB(0x00FF00);
|
||||
|
|
|
@ -9,19 +9,22 @@ With that done, let's define the Robot we'll use to communicate with Salesforce:
|
|||
Cylon.robot({
|
||||
name: 'salesforce',
|
||||
|
||||
connection: {
|
||||
name: 'sfcon',
|
||||
adaptor: 'force',
|
||||
sfuser: process.env.SF_USERNAME,
|
||||
sfpass: process.env.SF_SECURITY_TOKEN,
|
||||
orgCreds: {
|
||||
clientId: process.env.SF_CLIENT_ID,
|
||||
clientSecret: process.env.SF_CLIENT_SECRET,
|
||||
redirectUri: 'http://localhost:3000/oauth/_callback'
|
||||
connections: {
|
||||
sfcon: {
|
||||
adaptor: 'force',
|
||||
sfuser: process.env.SF_USERNAME,
|
||||
sfpass: process.env.SF_SECURITY_TOKEN,
|
||||
orgCreds: {
|
||||
clientId: process.env.SF_CLIENT_ID,
|
||||
clientSecret: process.env.SF_CLIENT_SECRET,
|
||||
redirectUri: 'http://localhost:3000/oauth/_callback'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
device: { name: 'salesforce', driver: 'force' },
|
||||
devices: {
|
||||
salesforce: { driver: 'force' }
|
||||
},
|
||||
|
||||
work: function(my) {
|
||||
my.salesforce.on('start', function() {
|
||||
|
@ -43,8 +46,14 @@ Next up, the shape our Sphero Robot will take:
|
|||
|
||||
Cylon.robot({
|
||||
name: 'ROY',
|
||||
connection: { name: 'sphero', adaptor: 'sphero' },
|
||||
device: { name: 'sphero', driver: 'sphero' },
|
||||
|
||||
connections: {
|
||||
sphero: { adaptor: 'sphero' }
|
||||
},
|
||||
|
||||
devices: {
|
||||
sphero: { driver: 'sphero' }
|
||||
},
|
||||
|
||||
react: function() {
|
||||
this.sphero.setRGB(0x00FF00);
|
||||
|
|
|
@ -11,7 +11,9 @@ Cylon.robot({
|
|||
}
|
||||
},
|
||||
|
||||
device: { name: 'led13', driver: 'led', pin: 13, connection: 'arduino' },
|
||||
devices: {
|
||||
led13: { driver: 'led', pin: 13, connection: 'arduino' }
|
||||
},
|
||||
|
||||
work: function(my) {
|
||||
console.log("Skynet is listening");
|
||||
|
|
|
@ -20,7 +20,9 @@ Let's define the connections and devices:
|
|||
}
|
||||
},
|
||||
|
||||
device: { name: 'led13', driver: 'led', pin: 13, connection: 'arduino' },
|
||||
devices: {
|
||||
led13: { driver: 'led', pin: 13, connection: 'arduino' }
|
||||
},
|
||||
|
||||
Now that Cylon knows about the necessary hardware we're going to be using, we'll
|
||||
tell it what work we want to do:
|
||||
|
|
|
@ -5,8 +5,13 @@ Cylon.api({ host: '0.0.0.0', port: '8080' });
|
|||
Cylon.robot({
|
||||
name: 'pebble',
|
||||
|
||||
connection: { name: 'pebble', adaptor: 'pebble' },
|
||||
device: { name: 'pebble', driver: 'pebble' },
|
||||
connections: {
|
||||
pebble: { adaptor: 'pebble' }
|
||||
},
|
||||
|
||||
devices: {
|
||||
pebble: { driver: 'pebble' }
|
||||
},
|
||||
|
||||
message: function(msg) {
|
||||
this.message_queue().push(msg);
|
||||
|
@ -20,19 +25,22 @@ Cylon.robot({
|
|||
Cylon.robot({
|
||||
name: 'salesforce',
|
||||
|
||||
connection: {
|
||||
name: 'sfcon',
|
||||
adaptor: 'force',
|
||||
sfuser: process.env.SF_USERNAME,
|
||||
sfpass: process.env.SF_SECURITY_TOKEN,
|
||||
orgCreds: {
|
||||
clientId: process.env.SF_CLIENT_ID,
|
||||
clientSecret: process.env.SF_CLIENT_SECRET,
|
||||
redirectUri: 'http://localhost:3000/oauth/_callback'
|
||||
connections: {
|
||||
sfcon: {
|
||||
adaptor: 'force',
|
||||
sfuser: process.env.SF_USERNAME,
|
||||
sfpass: process.env.SF_SECURITY_TOKEN,
|
||||
orgCreds: {
|
||||
clientId: process.env.SF_CLIENT_ID,
|
||||
clientSecret: process.env.SF_CLIENT_SECRET,
|
||||
redirectUri: 'http://localhost:3000/oauth/_callback'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
device: { name: 'salesforce', driver: 'force' },
|
||||
devices: {
|
||||
salesforce: { driver: 'force' }
|
||||
},
|
||||
|
||||
spheroReport: {},
|
||||
|
||||
|
@ -76,8 +84,13 @@ bots.forEach(function(bot) {
|
|||
Cylon.robot({
|
||||
name: bot.name,
|
||||
|
||||
connection: { name: 'sphero', adaptor: 'sphero', port: bot.port },
|
||||
device: { name: 'sphero', driver: 'sphero' },
|
||||
connections: {
|
||||
sphero: { adaptor: 'sphero', port: bot.port }
|
||||
},
|
||||
|
||||
devices: {
|
||||
sphero: { driver: 'sphero' }
|
||||
},
|
||||
|
||||
totalBucks: 1,
|
||||
payingPower: true,
|
||||
|
|
|
@ -9,7 +9,6 @@ Next up, we'll configure the API Cylon will serve, telling it to serve on port
|
|||
|
||||
Cylon.api({ host: '0.0.0.0', port: '8080' });
|
||||
|
||||
|
||||
Now that we have Cylon imported, we can start defining our Pebble robot:
|
||||
|
||||
Cylon.robot({
|
||||
|
@ -17,8 +16,13 @@ Now that we have Cylon imported, we can start defining our Pebble robot:
|
|||
|
||||
Let's define the connections and devices:
|
||||
|
||||
connection: { name: 'pebble', adaptor: 'pebble' },
|
||||
device: { name: 'pebble', driver: 'pebble' },
|
||||
connections: {
|
||||
pebble: { adaptor: 'pebble' }
|
||||
},
|
||||
|
||||
devices: {
|
||||
pebble: { driver: 'pebble' }
|
||||
},
|
||||
|
||||
Now that Cylon knows about the necessary hardware we're going to be using, we'll
|
||||
tell it what work we want to do:
|
||||
|
@ -39,19 +43,22 @@ Next, let's define our SalesForce robot:
|
|||
|
||||
Let's define the connections and devices:
|
||||
|
||||
connection: {
|
||||
name: 'sfcon',
|
||||
adaptor: 'force',
|
||||
sfuser: process.env.SF_USERNAME,
|
||||
sfpass: process.env.SF_SECURITY_TOKEN,
|
||||
orgCreds: {
|
||||
clientId: process.env.SF_CLIENT_ID,
|
||||
clientSecret: process.env.SF_CLIENT_SECRET,
|
||||
redirectUri: 'http://localhost:3000/oauth/_callback'
|
||||
connections: {
|
||||
sfcon: {
|
||||
adaptor: 'force',
|
||||
sfuser: process.env.SF_USERNAME,
|
||||
sfpass: process.env.SF_SECURITY_TOKEN,
|
||||
orgCreds: {
|
||||
clientId: process.env.SF_CLIENT_ID,
|
||||
clientSecret: process.env.SF_CLIENT_SECRET,
|
||||
redirectUri: 'http://localhost:3000/oauth/_callback'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
device: { name: 'salesforce', driver: 'force' },
|
||||
devices: {
|
||||
salesforce: { driver: 'force' }
|
||||
},
|
||||
|
||||
Tell it what work we want to do:
|
||||
|
||||
|
@ -99,8 +106,13 @@ Now, Let's define our Sphero robots:
|
|||
Cylon.robot({
|
||||
name: bot.name,
|
||||
|
||||
connection: { name: 'sphero', adaptor: 'sphero', port: bot.port },
|
||||
device: { name: 'sphero', driver: 'sphero' },
|
||||
connections: {
|
||||
sphero: { adaptor: 'sphero', port: bot.port }
|
||||
},
|
||||
|
||||
devices: {
|
||||
sphero: { driver: 'sphero' }
|
||||
},
|
||||
|
||||
totalBucks: 1,
|
||||
payingPower: true,
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
var Cylon = require('cylon');
|
||||
|
||||
Cylon.robot({
|
||||
connection: { name: 'sphero', adaptor: 'sphero', port: '/dev/tty.Sphero-YBW-RN-SPP' },
|
||||
device: { name: 'sphero', driver: 'sphero' },
|
||||
connections: {
|
||||
sphero: { adaptor: 'sphero', port: '/dev/tty.Sphero-YBW-RN-SPP' }
|
||||
},
|
||||
|
||||
devices: {
|
||||
sphero: { driver: 'sphero' }
|
||||
},
|
||||
|
||||
work: function(my) {
|
||||
var max = 0;
|
||||
|
|
|
@ -4,8 +4,13 @@ var Cylon = require('../..'),
|
|||
var travis = new Travis({version: '2.0.0'});
|
||||
|
||||
Cylon.robot({
|
||||
connection: { name: 'sphero', adaptor: 'sphero', port: '/dev/rfcomm0' },
|
||||
device: {name: 'sphero', driver: 'sphero' },
|
||||
connections: {
|
||||
sphero: { adaptor: 'sphero', port: '/dev/rfcomm0' }
|
||||
},
|
||||
|
||||
devices: {
|
||||
sphero: { driver: 'sphero' }
|
||||
},
|
||||
|
||||
work: function(my) {
|
||||
var user = "hybridgroup",
|
||||
|
|
|
@ -41,13 +41,17 @@ We use a connection to tell Cylon what port it can use to communicate with our
|
|||
Sphero, along with what adaptor it should require (`cylon-sphero`) to connect to
|
||||
it. We give it a name to make it easier to reference later on.
|
||||
|
||||
connection: { name: 'sphero', adaptor: 'sphero', port: '/dev/rfcomm0' },
|
||||
connections: {
|
||||
sphero: { adaptor: 'sphero', port: '/dev/rfcomm0' ;n
|
||||
},
|
||||
|
||||
Devices are set up in a similar fashion, but allow us to directly issue commands
|
||||
to the sphero. These are added to the robot's namespace directly to make them
|
||||
easy to access.
|
||||
|
||||
device: {name: 'sphero', driver: 'sphero' },
|
||||
devices: {
|
||||
sphero: { driver: 'sphero' }
|
||||
},
|
||||
|
||||
Now that we've told our robot what hardware it has access to, we can start
|
||||
telling it what it should do. The work function passes along one argument,
|
||||
|
|
Loading…
Reference in New Issue