From 2e74b8bdef4ee484b5903c7a51172cc98f5d0b8a Mon Sep 17 00:00:00 2001 From: deadprogram Date: Tue, 22 Oct 2013 13:30:16 -0700 Subject: [PATCH] Starting to build the object chain --- src/cylon.coffee | 3 ++- src/device.coffee | 2 ++ src/robot.coffee | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cylon.coffee b/src/cylon.coffee index e9166c4..28232f4 100644 --- a/src/cylon.coffee +++ b/src/cylon.coffee @@ -11,5 +11,6 @@ Robot = require("./robot") utils = require('./utils') -exports.robot = (opts) -> +exports.robot = (opts = {}) -> + opts.master = this new Robot(opts) diff --git a/src/device.coffee b/src/device.coffee index 5b2ccd7..f80d814 100644 --- a/src/device.coffee +++ b/src/device.coffee @@ -26,3 +26,5 @@ module.exports = class Device requireDriver: (driverName) -> console.log "dynamic load driver" + self = this + #new require("cylon-#{driverName}")(device: self) diff --git a/src/robot.coffee b/src/robot.coffee index 07b44a9..c3d5fa7 100644 --- a/src/robot.coffee +++ b/src/robot.coffee @@ -17,6 +17,7 @@ module.exports = class Robot constructor: (opts = {}) -> @name = opts.name or @constructor.randomName() + @master = opts.master @connections = initConnections(opts.connection or opts.connections or {}) @devices = initDevices(opts.device or opts.devices or {}) @work = opts.work or -> (console.log "No work yet")