cylon/examples/hello/hello.markdown

41 lines
966 B
Markdown
Raw Normal View History

# Hello
For this exceedingly simple example, we're going to define a robot that has no
devices, no connections, and just demonstrates the tools for performing work on
an interval, and after a timeout.
Let's start by importing Cylon:
var Cylon = require('../..');
Now we can define our robot:
Cylon.robot({
2014-11-26 06:39:24 +08:00
name: 'test',
2014-11-26 08:01:31 +08:00
connections: {
loopback: { adaptor: 'loopback' }
},
devices: {
ping: { driver: 'ping' }
},
For work, it's going to print a message to the console every second, and another
2014-11-26 06:39:24 +08:00
message after five seconds have elapsed.
2014-11-26 06:39:24 +08:00
work: function(my) {
every((1).seconds(), function(){
console.log("Hello, human!")
2014-11-26 06:39:24 +08:00
console.log(my.ping.ping());
});
2014-11-26 06:39:24 +08:00
after((5).seconds(), function(){
2014-08-01 07:45:18 +08:00
console.log("I've been at your command for 5 seconds now.")
});
}
Simple as can be. Now that we're done, let's start the robot:
}).start();