From 7d4aa1ffee4a8bf46cefab7598202e1014174808 Mon Sep 17 00:00:00 2001 From: Andrew Stewart Date: Tue, 25 Nov 2014 16:01:31 -0800 Subject: [PATCH] Update examples for new syntax --- examples/api/api.js | 9 +++- examples/api/api.markdown | 8 +++- ...le_arduinos_multiple_skynet_connections.js | 4 +- ...multiple_arduinos_one_skynet_connection.js | 16 ++++--- examples/conway_sphero/conway_sphero.js | 9 +++- examples/conway_sphero/conway_sphero.markdown | 9 +++- .../conway_sphero/fluent-conway_sphero.js | 4 +- examples/crazyflie/crazyflie.js | 9 +++- examples/crazyflie/crazyflie.markdown | 10 ++--- examples/digispark_blink/blink.js | 9 +++- examples/digispark_blink/blink.markdown | 9 +++- examples/halt/halt.js | 9 +++- examples/hello/fluent-hello.js | 20 +++++++++ examples/hello/hello.js | 9 +++- examples/hello/hello.markdown | 9 +++- examples/hello/imperative_hello.js | 15 ------- examples/keyboard/keyboard.js | 9 +++- examples/keyboard/keyboard.markdown | 9 +++- examples/leap_arduino/leap_arduino.js | 4 +- examples/leap_arduino/leap_arduino.markdown | 4 +- examples/rapiro/rapiro_servo.js | 5 ++- examples/salesforce/salesforce.js | 23 +++++----- examples/salesforce/salesforce.markdown | 23 +++++----- examples/sf-sphero/sf-sphero.js | 33 +++++++++------ examples/sf-sphero/sf-sphero.markdown | 33 +++++++++------ examples/skynet/skynet-blink.js | 4 +- examples/skynet/skynet-blink.markdown | 4 +- examples/sphero-pebble-sf/sphero-pebble-sf.js | 41 +++++++++++------- .../sphero-pebble-sf.markdown | 42 ++++++++++++------- .../sphero_shakeometer/sphero_shakeometer.js | 9 +++- examples/travis/travis.js | 9 +++- examples/travis/travis.markdown | 8 +++- 32 files changed, 281 insertions(+), 137 deletions(-) create mode 100644 examples/hello/fluent-hello.js delete mode 100644 examples/hello/imperative_hello.js diff --git a/examples/api/api.js b/examples/api/api.js index 716eeba..e7b49dd 100644 --- a/examples/api/api.js +++ b/examples/api/api.js @@ -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() { diff --git a/examples/api/api.markdown b/examples/api/api.markdown index 3118e98..4204daa 100644 --- a/examples/api/api.markdown +++ b/examples/api/api.markdown @@ -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 diff --git a/examples/arduinos_and_skynet/multiple_arduinos_multiple_skynet_connections.js b/examples/arduinos_and_skynet/multiple_arduinos_multiple_skynet_connections.js index f81ecab..86c39a8 100644 --- a/examples/arduinos_and_skynet/multiple_arduinos_multiple_skynet_connections.js +++ b/examples/arduinos_and_skynet/multiple_arduinos_multiple_skynet_connections.js @@ -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) { diff --git a/examples/arduinos_and_skynet/multiple_arduinos_one_skynet_connection.js b/examples/arduinos_and_skynet/multiple_arduinos_one_skynet_connection.js index 87c4cbd..dbfba90 100644 --- a/examples/arduinos_and_skynet/multiple_arduinos_one_skynet_connection.js +++ b/examples/arduinos_and_skynet/multiple_arduinos_one_skynet_connection.js @@ -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) { diff --git a/examples/conway_sphero/conway_sphero.js b/examples/conway_sphero/conway_sphero.js index b38aa25..693a6b5 100644 --- a/examples/conway_sphero/conway_sphero.js +++ b/examples/conway_sphero/conway_sphero.js @@ -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(); diff --git a/examples/conway_sphero/conway_sphero.markdown b/examples/conway_sphero/conway_sphero.markdown index 45c0212..e12754b 100644 --- a/examples/conway_sphero/conway_sphero.markdown +++ b/examples/conway_sphero/conway_sphero.markdown @@ -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 diff --git a/examples/conway_sphero/fluent-conway_sphero.js b/examples/conway_sphero/fluent-conway_sphero.js index e2428d8..78bff33 100644 --- a/examples/conway_sphero/fluent-conway_sphero.js +++ b/examples/conway_sphero/fluent-conway_sphero.js @@ -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)); diff --git a/examples/crazyflie/crazyflie.js b/examples/crazyflie/crazyflie.js index d747c49..335f0ce 100644 --- a/examples/crazyflie/crazyflie.js +++ b/examples/crazyflie/crazyflie.js @@ -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() { diff --git a/examples/crazyflie/crazyflie.markdown b/examples/crazyflie/crazyflie.markdown index 73f05dd..67071cc 100644 --- a/examples/crazyflie/crazyflie.markdown +++ b/examples/crazyflie/crazyflie.markdown @@ -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. diff --git a/examples/digispark_blink/blink.js b/examples/digispark_blink/blink.js index c8687c3..2e86ff0 100644 --- a/examples/digispark_blink/blink.js +++ b/examples/digispark_blink/blink.js @@ -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); diff --git a/examples/digispark_blink/blink.markdown b/examples/digispark_blink/blink.markdown index a33be97..4e86741 100644 --- a/examples/digispark_blink/blink.markdown +++ b/examples/digispark_blink/blink.markdown @@ -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: diff --git a/examples/halt/halt.js b/examples/halt/halt.js index 43bff9a..886740c 100644 --- a/examples/halt/halt.js +++ b/examples/halt/halt.js @@ -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() { diff --git a/examples/hello/fluent-hello.js b/examples/hello/fluent-hello.js new file mode 100644 index 0000000..ef0337f --- /dev/null +++ b/examples/hello/fluent-hello.js @@ -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(); diff --git a/examples/hello/hello.js b/examples/hello/hello.js index a5e805f..9eed61c 100644 --- a/examples/hello/hello.js +++ b/examples/hello/hello.js @@ -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(){ diff --git a/examples/hello/hello.markdown b/examples/hello/hello.markdown index 325ad14..229d331 100644 --- a/examples/hello/hello.markdown +++ b/examples/hello/hello.markdown @@ -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. diff --git a/examples/hello/imperative_hello.js b/examples/hello/imperative_hello.js deleted file mode 100644 index 385ee14..0000000 --- a/examples/hello/imperative_hello.js +++ /dev/null @@ -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); diff --git a/examples/keyboard/keyboard.js b/examples/keyboard/keyboard.js index 45efcc8..74fe0eb 100644 --- a/examples/keyboard/keyboard.js +++ b/examples/keyboard/keyboard.js @@ -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) { diff --git a/examples/keyboard/keyboard.markdown b/examples/keyboard/keyboard.markdown index b3a25ef..f083238 100644 --- a/examples/keyboard/keyboard.markdown +++ b/examples/keyboard/keyboard.markdown @@ -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. diff --git a/examples/leap_arduino/leap_arduino.js b/examples/leap_arduino/leap_arduino.js index 93526a3..01f8a80 100644 --- a/examples/leap_arduino/leap_arduino.js +++ b/examples/leap_arduino/leap_arduino.js @@ -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) { diff --git a/examples/leap_arduino/leap_arduino.markdown b/examples/leap_arduino/leap_arduino.markdown index 42a8d29..0020df7 100644 --- a/examples/leap_arduino/leap_arduino.markdown +++ b/examples/leap_arduino/leap_arduino.markdown @@ -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: diff --git a/examples/rapiro/rapiro_servo.js b/examples/rapiro/rapiro_servo.js index 2942393..d5c2449 100644 --- a/examples/rapiro/rapiro_servo.js +++ b/examples/rapiro/rapiro_servo.js @@ -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 } } diff --git a/examples/salesforce/salesforce.js b/examples/salesforce/salesforce.js index 3964a7f..82e4fc2 100644 --- a/examples/salesforce/salesforce.js +++ b/examples/salesforce/salesforce.js @@ -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() { diff --git a/examples/salesforce/salesforce.markdown b/examples/salesforce/salesforce.markdown index bc91752..e03b90c 100644 --- a/examples/salesforce/salesforce.markdown +++ b/examples/salesforce/salesforce.markdown @@ -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: diff --git a/examples/sf-sphero/sf-sphero.js b/examples/sf-sphero/sf-sphero.js index 8d4e16b..a7dc7c1 100644 --- a/examples/sf-sphero/sf-sphero.js +++ b/examples/sf-sphero/sf-sphero.js @@ -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); diff --git a/examples/sf-sphero/sf-sphero.markdown b/examples/sf-sphero/sf-sphero.markdown index 32fabd3..7bb8228 100644 --- a/examples/sf-sphero/sf-sphero.markdown +++ b/examples/sf-sphero/sf-sphero.markdown @@ -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); diff --git a/examples/skynet/skynet-blink.js b/examples/skynet/skynet-blink.js index 37826c3..5079607 100644 --- a/examples/skynet/skynet-blink.js +++ b/examples/skynet/skynet-blink.js @@ -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"); diff --git a/examples/skynet/skynet-blink.markdown b/examples/skynet/skynet-blink.markdown index a5e3513..a9ed4a9 100644 --- a/examples/skynet/skynet-blink.markdown +++ b/examples/skynet/skynet-blink.markdown @@ -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: diff --git a/examples/sphero-pebble-sf/sphero-pebble-sf.js b/examples/sphero-pebble-sf/sphero-pebble-sf.js index f254691..c05e118 100644 --- a/examples/sphero-pebble-sf/sphero-pebble-sf.js +++ b/examples/sphero-pebble-sf/sphero-pebble-sf.js @@ -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, diff --git a/examples/sphero-pebble-sf/sphero-pebble-sf.markdown b/examples/sphero-pebble-sf/sphero-pebble-sf.markdown index 61debd3..9b7ac67 100644 --- a/examples/sphero-pebble-sf/sphero-pebble-sf.markdown +++ b/examples/sphero-pebble-sf/sphero-pebble-sf.markdown @@ -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, diff --git a/examples/sphero_shakeometer/sphero_shakeometer.js b/examples/sphero_shakeometer/sphero_shakeometer.js index d025af2..fc28316 100644 --- a/examples/sphero_shakeometer/sphero_shakeometer.js +++ b/examples/sphero_shakeometer/sphero_shakeometer.js @@ -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; diff --git a/examples/travis/travis.js b/examples/travis/travis.js index 1568335..cad9e96 100644 --- a/examples/travis/travis.js +++ b/examples/travis/travis.js @@ -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", diff --git a/examples/travis/travis.markdown b/examples/travis/travis.markdown index 6922a9c..a8951b4 100644 --- a/examples/travis/travis.markdown +++ b/examples/travis/travis.markdown @@ -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,