Commit Graph

54 Commits

Author SHA1 Message Date
Andrew Stewart ac6b09fe50 Clean up lib for JSHint 2014-12-15 11:15:29 -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 668acf1e18 Add support for specifying API configuration to Cylon#api 2014-11-14 13:05:16 -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 c43978bea2 Add logging for module registration 2014-11-05 14:26:18 -08:00
Andrew Stewart 0f59645fd7 Move Logger configuration into Cylon#config 2014-10-28 15:53:03 -07:00
Adrian Zankich b80ad6e167 start the robots in parallel 2014-10-04 00:56:08 -07:00
Adrian Zankich d4ed3117f3 enable async or sync work modes 2014-10-03 23:07:07 -07:00
Andrew Stewart f029438c19 Remove #Robot export, config option is now 2014-09-30 11:53:53 -07:00
Andrew Stewart 83bf4e3d14 Merge branch 'dev' into add/imperative-work
* dev:
  Remove Adaptor#_noop function
  Move Cylon API config to the Cylon.configure block
  Fixup interval in driver
  Add all new platforms to README
  Add default interval in Driver class
  Switch to single Cylon#config function

Conflicts:
	test/specs/cylon.spec.js
2014-09-22 11:37:56 -07:00
Andrew Stewart 333dc881ea Move Cylon API config to the Cylon.configure block 2014-09-19 12:03:50 -07:00
Andrew Stewart 7560507f11 Switch to single Cylon#config function 2014-09-15 14:46:24 -07:00
Andrew Stewart f1544e5a8f Add support for work to be triggered via an event 2014-09-08 12:57:56 -07:00
Andrew Stewart 179c486c80 Address namespace collisions for robots, devices, and connections 2014-09-04 14:51:44 -07:00
Andrew Stewart 48497b7b0e Default to no-op callbacks for #halt methods 2014-09-04 11:22:00 -07:00
Andrew Stewart 8f20ccbcf3 Default #halt timeout is 3s, now user configurable 2014-09-03 15:39:54 -07:00
Andrew Stewart 3b7c96e81e Add user configuration for Cylon internals 2014-09-03 15:08:48 -07:00
Andrew Stewart 7394eefde2 WIP on commands + JSON serialization 2014-07-15 12:27:16 -07:00
Andrew Stewart ca2bf7e5a9 Merge branch 'dev' into servo-level-up
* dev:
  Remove `self` references in favor of #bind
  Stop using #fetch here for now, it just breaks tests
  Just use arguments directly instead of array
  Remove Utils#bind in preference of built-in fn
  Consolidate logstring generation into private fn
  Experiment with Utils.fetch in Driver class
  Add #fetch Utility function
  Fix JSHint errors
  Fix an edge case and improve tests for API
2014-07-03 11:52:02 -07:00
Edgar Silva c4b10e66f4 Merge branch 'master' into servo-level-up 2014-07-02 17:05:15 -05:00
Andrew Stewart a9b874a917 Merge branch 'master' into dev
* master:
  Bump version to 0.15.1
  Only require the API/Express when using it
2014-06-18 15:19:53 -07:00
Andrew Stewart 856619e902 Only require the API/Express when using it
Fixes an issue with the Tessel, which cannot load Express.
2014-06-18 14:44:46 -07:00
Andrew Stewart af8cfbe333 Fix JSHint errors 2014-06-16 13:09:13 -07:00
Andrew Stewart 6de922f2fc Make halting on SIGINT async
This change gives adaptors/drivers more flexibility in halting. Additionally,
now, by default, all Adaptors/Drivers will remove all their event listeners
before halting, which should prevent some additional commands from being sent to
the adaptor during shutdown.
2014-06-12 15:31:49 -07:00
Ron Evans 3717c4dc31 Merge pull request #195 from hybridgroup/refactor/robots-collection
Refactor Robots collection
2014-06-06 18:36:19 -04:00
Andrew Stewart 81fa260963 Store robots in an dict, rather than array
Also removes the find{Robot,RobotConnection,RobotDevice} methods. Additionally,
stops passing the Master through to the Robot constructor, we can just
require('./cylon') if we need to access anything in there.
2014-06-06 11:36:22 -07:00
Andrew Stewart f91dd7d5c3 Refactor Utils (mostly) out of global namespace
This commit reframes the Utils module to be more self-contained, and now only
the Number prototype methods and the every/after/constantly methods are exposed
globally.

I'm unsure about whether these methods can be more scoped such that people can
turn them off if they want, but that's potentially something to look into in the
future.

This commit also updates most of the other source files in Cylon, requiring the
Utils module rather than assuming the methods are in the global namespace.

A similar batch of commits will need to be made for all other Cylon modules to
make sure they don't explode when they can't find #subclass or something like
that.

To make the previously-global methods available, both in submodules and for
people looking for them, all the utility functions are exported in Cylon.Utils.
2014-06-05 12:17:29 -07:00
Andrew Stewart 6bc1e9d944 Move configuration to API class 2014-06-04 11:51:07 -07:00
edgarsilva 62d4ef620e Fix typos in new sero IO util. 2014-06-02 18:02:02 -05:00
Edgar Silva 293594355c WIP on sero utils 2014-06-02 15:45:42 -05:00
Andrew Stewart c22ef95239 Remove Logger from global namespace 2014-05-13 19:44:40 -07:00
Andrew Stewart 43a9351921 Convert Cylon.Master to a plain JS object
Acts exactly the same with much, much less code complexity.

This also introduces a pattern for providing core modules to external libraries.

Whereas previously Cylon modules were able to rely on Cylon.Adaptor or
Cylon.Driver being present in the namespace (due to being required in
./lib/cylon), they will now need to require Cylon first, like this:

    var Cylon = require('cylon');

    var Driver = Cylon.Driver,
        Adaptor = Cylon.Adaptor,
        DigitalPin = Cylon.IO.DigitalPin;
2014-05-13 19:20:54 -07:00
Andrew Stewart a3974f38b7 Remove node-namespace from API 2014-05-07 15:19:23 -07:00
Javier Cervantes 394691a8f2 Refactoring api optional ssl logic 2014-04-24 11:18:20 -05:00
Javier Cervantes 956e757e8e Updating ssl configuration keys and tests 2014-04-24 10:14:02 -05:00
Javier Cervantes 40b3db1dce Changing how ssl is configured
Expected configuration:

{
  ssl: {
    key: "/path/to/key",
    cert: "/path/to/cert"
  }
}

If ssl is false, use plain HTTP. If it's an empty object (the default)
use our self-signed certs. If it's set up like above, use the provided
certs.
2014-04-23 17:56:42 -05:00
Javier Cervantes cc3dac9442 Adding optional ssl param in API
By default http is used for api, but you can pass a param to use ssl.

This is the same behaviour that we have currently in robot.
2014-04-23 17:02:25 -05:00
Andrew Stewart e66c1145d5 Simplify Master#api 2014-04-21 16:36:47 -07:00
edgarsilva 283b05b08a Fixes bug with robot not halting, which caused connections, adaptors and devices to not disconnect. 2014-04-21 17:46:02 -05:00
Andrew Stewart d8152852a0 Correctly kill process 2014-04-14 15:11:07 -07:00
Andrew Stewart 9e781a2ea1 Add basic tests for API server and routes 2014-04-11 12:33:32 -07:00
Andrew Stewart 4b409f7777 Add CORS param for API config 2014-04-08 10:58:58 -07:00
Andrew Stewart 89a5bbae2f Support passing auth hash to API server 2014-04-03 15:49:13 -07:00
Andrew Stewart 29b7db0de8 Add support for manually specifying cert/key files 2014-04-03 15:03:21 -07:00
Andrew Stewart f9537d9af8 Rename #stop to #halt to avoid potential conflicts 2014-03-11 10:44:11 -07:00
Andrew Stewart a1b230c62d Added specs for Cylon#findRobotConnection 2014-03-09 19:06:06 -07:00
Andrew Stewart 691547a97f Add specs for Cylon#findRobotDevice 2014-03-09 18:56:42 -07:00
Andrew Stewart c0c4ce6958 Small changes to appease JSHint 2014-03-07 23:33:59 -08:00
Andrew Stewart 9c5d1c3496 Refactor API configuration method 2014-03-04 16:18:51 -08:00
Andrew Stewart 5120c35f7c Provide backing variables instead of functions 2014-03-04 16:10:49 -08:00