2013-11-28 03:34:27 +08:00
|
|
|
# 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:
|
|
|
|
|
2014-03-27 08:06:26 +08:00
|
|
|
var Cylon = require('../..');
|
2013-11-28 03:34:27 +08:00
|
|
|
|
|
|
|
Now we can define our robot:
|
|
|
|
|
2014-03-27 08:06:26 +08:00
|
|
|
Cylon.robot({
|
2013-11-28 03:34:27 +08:00
|
|
|
|
|
|
|
For work, it's going to print a message to the console every second, and another
|
|
|
|
message after ten seconds have elapsed.
|
|
|
|
|
2014-03-27 08:06:26 +08:00
|
|
|
work: function() {
|
|
|
|
every((1).second(), function() {
|
2014-01-04 09:18:09 +08:00
|
|
|
console.log("Hello, human!")
|
2014-03-27 08:06:26 +08:00
|
|
|
});
|
2013-11-28 03:34:27 +08:00
|
|
|
|
2014-03-27 08:06:26 +08:00
|
|
|
after((10).seconds(), function() {
|
2014-01-04 09:18:09 +08:00
|
|
|
console.log "Impressive."
|
2014-03-27 08:06:26 +08:00
|
|
|
});
|
|
|
|
}
|
2013-11-28 03:34:27 +08:00
|
|
|
|
|
|
|
Simple as can be. Now that we're done, let's start the robot:
|
|
|
|
|
2014-03-27 08:06:26 +08:00
|
|
|
}).start();
|