Commit Graph

30 Commits

Author SHA1 Message Date
deadprogram aca4ebce70 Use dot notation for tests
Signed-off-by: deadprogram <ron@hybridgroup.com>
2016-03-27 18:38:07 -07:00
deadprogram f6be3b1ae3 Adds back robot-scoped connections by name, and the tests to prove it.
Signed-off-by: deadprogram <ron@hybridgroup.com>
2016-03-27 18:28:14 -07:00
deadprogram 4ec19961f8 Devices will only be started up once, and can be added dynamically 2015-09-01 18:12:39 -07:00
Ron Evans bea67b2e5e Merge pull request #305 from hybridgroup/refactor/logger
Simplify logger
2015-08-31 21:19:22 -07:00
Andrew Stewart 67f0386bb5 prevent callback(err) from messing with shutdown 2015-07-21 10:31:52 -07:00
Andrew Stewart 843e0a3217 Simplify logger
This commit adds a simplified logging system, with two primary methods:

- `Logger#log(String) :: void` (for normal logging)
- `Logger#debug(String) :: void` (for debug logging)

This helps dramatically simplify logging infrastructure, as well as
enabling simpler toggling of log modes.

The configuration values for the Logger have also been updated:

- `logger :: Function` - function to log output to (both normal + debug)
- `silent :: Boolean` - whether to log default normal messages or not (`--silent` flag)
- `debug  :: Boolean` - whether or not to log debug output (`--debug` flag)

Additionally, the following CLI flags are supported re: logging:

- `--silent` disables normal logging (will override all other settings)
- `--debug` enables debug logging

Deprecation notices have been added for old log methods, with first-run
messages to this effect.

This change should have negligible impact on end-users, with minor
inconvenience for library developers, as they need to switch their
logging function calls over.

Logging configuration is still possible via both
`Cylon.Config.update(Object)`, and directly calling
`Cylon.Logger.setup(Object)`.
2015-07-13 14:05:12 -07:00
Andrew Stewart ceac0df8dd Consolidate Robot initialization to a single fn
Additionally, extracts validation of connections being present out to
the validator logic.
2015-06-26 10:31:23 -07:00
Andrew Stewart f3efa83643 Correct issue with Robot halting 2015-06-18 14:56:39 -07:00
Andrew Stewart 681e197ed9 Stop giving robots random names, use inc. counter 2015-06-09 11:50:50 -07:00
Andrew Stewart 8adacef282 s/source/lib for loading files for specs 2015-06-09 07:21:03 -07:00
Andrew Stewart 62cbae7cff Switch to ESLint for linting 2015-04-15 08:59:34 -07:00
Andrew Stewart a17c70a18b Bind passed function to Robot by default 2015-03-17 14:22:14 -07:00
Andrew Stewart cb492c0747 Remove deprecated Connection / Device syntaxes
Removes deprecation warnings + support for single-object + array
syntaxes.

The array syntax will likely continue to work due to the `_.each`
abstraction, but since we don't use it anywhere, the requisite specs
have been removed.
2015-03-04 09:27:33 -08:00
Andrew Stewart d56f9bc53f Add better error checking for Robot#halt 2015-01-21 08:56:13 -08:00
Andrew Stewart 754af3b4db Add test for Robot#log 2015-01-20 19:38:48 -08:00
Andrew Stewart 8065644b4e Add support for nested device details inside conn
e.g.
    connections: {
      loopback: {
        adaptor: "loopback",
        devices: {
          ping: { driver: "ping", pin: 1 }
        }
      }
    }

In the event of a name collision between the `devices` hash and a nested
device, the nested device will 'win'.
2015-01-07 10:21:51 -08:00
Andrew Stewart cf0d24f785 Add API event publication
This update gives Cylon support for the latest changes to the CPPP-IO
spec.
2015-01-05 12:20:53 -08:00
Andrew Stewart c9e16fe8c2 Use _.result to get commands from options. 2014-12-17 15:07:03 -08:00
Andrew Stewart 36d1505c2f Add specs for new #connections/#devices behaviour 2014-12-15 13:17:04 -08:00
Andrew Stewart e2bec78de7 Clean up specs for JSHint 2014-12-15 09:37:52 -08:00
Andrew Stewart 7f761c7268 WIP on cleaning up specs 2014-12-14 15:24:49 -08:00
Andrew Stewart 83153664f5 Remove deprecated syntax from robot spec 2014-11-26 09:42:09 -08:00
Andrew Stewart ca8e22f1e2 Fluent #device/#connection update
Now pass name, then object of details

    #device({ name: 'ping', driver: 'ping' });
    // vs
    #device('ping', { driver: 'ping' });
2014-11-26 09:33:19 -08:00
Andrew Stewart 15c9b96333 Extract out Connection/Device initialization
Simple extraction out of Connection/Device initialization code inside
Robot.

This yields an interesting boon, however - this is now a valid Cylon
program:

    var Cylon = require('cylon');

    Cylon
      .robot()
      .connection({ name: 'loopback', adaptor: 'loopback' })
      .device({ name: 'ping', driver: 'ping' })
      .on('ready', function(bot) {
        console.log("Bot working!");

        every(1000, function() {
          console.log(bot.ping.ping());
        })
      });

    Cylon.start();

For those that prefer imperative programs with Cylon, this is a nice
syntax addition.
2014-11-20 08:43:08 -08:00
Andrew Stewart ce87a355f0 Modifications, fix test suite 2014-11-11 11:41:23 -08:00
Andrew Stewart f1b982fedd Support providing connections/devices as an object
Before:

  connections: [
    { name: 'loopback', adaptor: 'loopback', port: 13 }
  ],

Now:

  connections: {
    loopback: { adaptor: 'loopback', port: 13 }
  }

Array syntax still works, but has been marked as deprecated.
2014-11-10 10:52:55 -08:00
Andrew Stewart 1c922f02c1 Address bugs w/ connections 2014-10-31 13:48:05 -07:00
Andrew Stewart 44075a1a30 Hook Repository class up, change-up module loading
Cylon modules were previously styled something like this:

    module.exports = {
      adaptor: function(args) {
        return new Adaptor(args);
      },

      register: function(robot) {
        Cylon.Logger.debug("Registering Firmata adaptor for " + robot.name);
        robot.registerAdaptor('cylon-firmata', 'firmata');

        GPIO.register(robot);
        I2C.register(robot);
      }
    };

Now, they should be something more like this:

    module.exports = {
      adaptors: ['firmata'],
      dependencies: ['cylon-gpio', 'cylon-i2c'],

      adaptor: function(args) {
        return new Adaptor(args);
      },
    };
2014-10-30 13:29:06 -07:00
Andrew Stewart a8b16a3469 Proxy all opts that aren't already used internally 2014-10-27 13:40:38 -07:00
Andrew Stewart bd95f9eb3c Reorganize tests, under 'spec' directory now 2014-10-20 14:55:25 -07:00