diff --git a/src/robot.coffee b/src/robot.coffee index 25da3df..2d09c76 100644 --- a/src/robot.coffee +++ b/src/robot.coffee @@ -12,21 +12,28 @@ Connection = source("connection") module.exports = class Robot constructor: (opts) -> + @_connections = {} + @_devices = {} @name = opts.name @connections = initConnections(opts.connection or opts.connections or {}) - @devices = initDevices(opts.device or opts.devices) + @devices = initDevices(opts.device or opts.devices or {}) @work = opts.work or -> (console.log "No work yet") initConnections = (connections) -> - console.log "Initialing connections..." + console.log "Initializing connections..." initConnection connection for connection in connections initConnection = (connection) -> - console.log "Initialing connection '" + connection.name + "'..." + console.log "Initializing connection '#{ connection.name }'..." @_connections[connection.name] = new Connection(connection) initDevices = (devices) -> - console.log "Initialing devices..." + console.log "Initializing devices..." + initDevice device for device in devices + + initDevice = (device) -> + console.log "Initializing device '#{ device.name }'..." + @_devices[device.name] = new Device(device) start: -> startConnections()