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 '..'
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:
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)
huey.connection['port'] = '/dev/cu.Sphero-RGB'
huey.name = "Huey"
for bot in bots
robot = Object.create(SpheroRobot)
robot.connection.port = bot.port
robot.name = bot.name
dewey = Object.create(RobotInfo)
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.robot robot
Cylon.start()