Commit Graph

126 Commits

Author SHA1 Message Date
deadprogram ed76890b8a Making connections dynamic as well 2015-09-07 10:51:34 -07:00
deadprogram 8921e902eb Add function to dynamically start devices 2015-09-07 08:34:01 -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 1726cdb5f1 Remove vestigial attributes on Robot 2015-06-26 08:17:30 -07:00
Andrew Stewart 8fbe9b9c4d Automate auto-binding of prototype methods 2015-06-25 12:33:13 -07:00
Edgar O Silva fd564f61f8 Merge pull request #296 from hybridgroup/remove/async
Remove dependency on 'async'
2015-06-24 13:30:43 -05:00
Andrew Stewart 0b48851885 Remove unnecessary comments at start of files 2015-06-22 09:16:43 -07:00
Andrew Stewart 0719fa203c Remove dependency on 'async'
This commit removes the last current dependency of Cylon, 'async'.

In it's place, simplified versions of the methods used have been added
so lib/utils/helpers.js.
2015-06-18 15:40:33 -07:00
Andrew Stewart f3efa83643 Correct issue with Robot halting 2015-06-18 14:56:39 -07:00
Andrew Stewart 4238385be4 Extract out Robot param validation into new file 2015-06-17 09:03:26 -07:00
Andrew Stewart 681e197ed9 Stop giving robots random names, use inc. counter 2015-06-09 11:50:50 -07:00
Andrew Stewart 68ab6ad441 Remove leftover comment 2015-06-09 07:08:46 -07:00
Andrew Stewart 6cccc41aff Begin JSDoc-ing core 2015-06-08 22:57:49 -07:00
Andrew Stewart 3f4140bd08 Add util to verify constructor calls use 'new' 2015-05-12 18:47:27 -07:00
Andrew Stewart 62cbae7cff Switch to ESLint for linting 2015-04-15 08:59:34 -07:00
Andrew Stewart cccb376679 Consistent top-of-file doc blocks 2015-04-15 08:59:12 -07:00
Andrew Stewart 9b04a4ed15 Add basic DSL error checks 2015-04-02 12:22:19 -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 6e3d7c6667 Add helpers to replace some lodash functionality
Not a 1:1, and probably much slower than Lodash's ultra-optimised
implementations, but we do enough I/O that it's not really relevant,
is it?
2015-02-23 08:38:12 -08:00
Andrew Stewart 618aa8212d Remove lodash 2015-02-20 11:15:34 -08:00
deadprogram 64a0d76af1 Extract deprecation warning into separate function 2015-01-22 19:25:45 -08:00
Andrew Stewart 147816b366 First crack at removing seperate Device/Connection initialization 2015-01-22 14:41:58 -08:00
Andrew Stewart d56f9bc53f Add better error checking for Robot#halt 2015-01-21 08:56:13 -08:00
Andrew Stewart 8272efe060 Robot log messages should contain the bot name 2015-01-20 19:29:40 -08:00
Andrew Stewart 5354102c2e If bad start detected, shut down the Robot 2015-01-20 19:18:52 -08:00
deadprogram 6ac3cad7c1 Extract even more of function to DRY up code 2015-01-17 21:35:40 -08:00
deadprogram 5cea07602a Extract function to DRY up code 2015-01-17 21:29:07 -08:00
deadprogram a7e8caf19d Extract robot var init into separate function 2015-01-17 15:48:45 -08:00
Andrew Stewart eccdde81a9 Update copyright years 2015-01-07 12:58:50 -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 6cbf2db122 Lodashify 2014-12-17 14:45:57 -08:00
Andrew Stewart ac6b09fe50 Clean up lib for JSHint 2014-12-15 11:15:29 -08:00
Andrew Stewart 9fe92967bb Make use of `thisArg` instead of #bind 2014-11-30 15:17:57 -08:00
Andrew Stewart 3eb1da8481 Simplify halt code in Robot slightly 2014-11-30 11:47:33 -08:00
Andrew Stewart 29583c0bd5 Add back debug logging for device/connection start 2014-11-28 14:42:26 -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 9047797c9f Deprecate 'connection' and 'device' Robot opts 2014-11-25 14:43:57 -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 38bf5fdfed Refer to Adaptor instances as 'Connection' 2014-11-14 10:56:45 -08:00
Andrew Stewart ce87a355f0 Modifications, fix test suite 2014-11-11 11:41:23 -08:00
Andrew Stewart e67ae19882 Remove Connection and Device classes
They are now functions that return instances of Adaptors and Drivers
respectively.
2014-11-10 16:06:10 -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 e9f73228f1 Move requires around to make Browserify cooperate 2014-11-05 15:24:50 -08:00