Init the connections and devices hashes
This commit is contained in:
parent
54f657e76a
commit
d050835620
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue