Rewritten 'Master' example

This commit is contained in:
Andrew Stewart 2013-10-24 12:53:20 -07:00
parent 0ac38c735a
commit 3310dee260
1 changed files with 14 additions and 16 deletions

View File

@ -1,25 +1,23 @@
Cylon = require '..' Cylon = require '..'
RobotInfo = bots = [
{ port: '/dev/cu.Sphero-RGB', name: 'Huey' },
{ port: '/dev/cu.Sphero-GRB', name: 'Dewey' },
{ port: '/dev/cu.Sphero-BRG', name: 'Louie' }
]
SpheroRobot =
connection: connection:
name: 'Sphero', adaptor: 'sphero' name: 'Sphero', adaptor: 'sphero'
work: -> every 2.seconds(), -> Logger.info "Required cylon-sphero adaptor!" work: (self) ->
console.log "Robot #{self.name} is now working!"
huey = Object.create(RobotInfo) for bot in bots
huey.connection['port'] = '/dev/cu.Sphero-RGB' robot = Object.create(SpheroRobot)
huey.name = "Huey" robot.connection.port = bot.port
robot.name = bot.name
dewey = Object.create(RobotInfo) Cylon.robot robot
dewey.connection['port'] = '/dev/cu.Sphero-GRB'
dewey.name = "Dewey"
louie = Object.create(RobotInfo)
louie.connection['port'] = '/dev/cu.Sphero-BRG'
louie.name = "Louie"
Cylon.robot(huey)
Cylon.robot(dewey)
Cylon.robot(louie)
Cylon.start() Cylon.start()