2013-10-24 10:51:40 +08:00
|
|
|
Cylon = require '..'
|
2013-10-24 09:40:00 +08:00
|
|
|
|
2013-10-25 03:53:20 +08:00
|
|
|
bots = [
|
|
|
|
{ port: '/dev/cu.Sphero-RGB', name: 'Huey' },
|
|
|
|
{ port: '/dev/cu.Sphero-GRB', name: 'Dewey' },
|
|
|
|
{ port: '/dev/cu.Sphero-BRG', name: 'Louie' }
|
|
|
|
]
|
|
|
|
|
|
|
|
SpheroRobot =
|
2013-10-24 09:40:00 +08:00
|
|
|
connection:
|
|
|
|
name: 'Sphero', adaptor: 'sphero'
|
|
|
|
|
2013-10-25 03:53:20 +08:00
|
|
|
work: (self) ->
|
|
|
|
console.log "Robot #{self.name} is now working!"
|
2013-10-24 09:40:00 +08:00
|
|
|
|
2013-10-25 03:53:20 +08:00
|
|
|
for bot in bots
|
|
|
|
robot = Object.create(SpheroRobot)
|
|
|
|
robot.connection.port = bot.port
|
|
|
|
robot.name = bot.name
|
2013-10-24 09:40:00 +08:00
|
|
|
|
2013-10-25 03:53:20 +08:00
|
|
|
Cylon.robot robot
|
2013-10-24 09:40:00 +08:00
|
|
|
|
|
|
|
Cylon.start()
|