From d05083562044cc1eb7cdd6c0f4212480fa048b4b Mon Sep 17 00:00:00 2001 From: deadprogram Date: Sun, 20 Oct 2013 08:03:56 -0700 Subject: [PATCH] Init the connections and devices hashes --- src/robot.coffee | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) 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()