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
25119c170f
Refer to correct element for proxying
2014-11-14 11:34:37 -08:00
Andrew Stewart
5ff743a4c5
Correct API inconsistency
2014-11-14 11:06:21 -08:00
Andrew Stewart
38bf5fdfed
Refer to Adaptor instances as 'Connection'
2014-11-14 10:56:45 -08:00
Andrew Stewart
39f9c8b637
Fix up API errors
2014-11-11 13:41:09 -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
4c539ab9d1
Better configuration for TDR test mode
2014-11-06 09:48:21 -08:00
Andrew Stewart
277d4a51ee
Correct API errors
2014-11-06 09:10:56 -08:00
Andrew Stewart
e0d3ffbe22
Bump version to "0.20.1"
2014-11-05 15:56:37 -08:00
Andrew Stewart
e9f73228f1
Move requires around to make Browserify cooperate
2014-11-05 15:24:50 -08:00
Andrew Stewart
c43978bea2
Add logging for module registration
2014-11-05 14:26:18 -08:00
Andrew Stewart
60e89c9671
If key supplied in hash, use it to find module in Registry
2014-11-05 10:04:45 -08:00
Andrew Stewart
966f8aa530
s/Repository/Registry/g
2014-10-31 14:14:02 -07:00
Andrew Stewart
d62673bc8a
Stop using extraParams
2014-10-31 13:50:22 -07: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
63e43cc553
Repository module added, not integrated yet
2014-10-29 15:25:35 -07:00
Andrew Stewart
0f59645fd7
Move Logger configuration into Cylon#config
2014-10-28 15:53:03 -07:00
Ron Evans
903f8a9518
Merge pull request #235 from hybridgroup/add/log-levels
...
Add log levels
2014-10-28 17:38:00 +00:00
Ron Evans
3ceb6cda85
Merge pull request #234 from hybridgroup/workMode
...
Work mode configuration
2014-10-28 17:37:24 +00:00
Andrew Stewart
a8b16a3469
Proxy all opts that aren't already used internally
2014-10-27 13:40:38 -07:00
Andrew Stewart
2cb2fc232d
Basic log level implementation
2014-10-27 08:59:36 -07:00
Andrew Stewart
d65742bb49
Generate code! It's what the cool kids are doing!
2014-10-24 14:54:56 -07:00
Andrew Stewart
f5de644af7
Not sure why these were classes to begin with
2014-10-24 14:02:03 -07:00
Andrew Stewart
3f9a7cf148
Fixup some Browserify errors, indicate support in README
2014-10-21 11:31:22 -07:00
Andrew Stewart
9be0f779ae
Update dependencies
2014-10-20 14:38:41 -07:00
Andrew Stewart
157fcec25e
Avoid creating functions inside loop, properly terminates now
2014-10-14 10:25:58 -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
e74675d65a
Small fixes to robot.js
2014-10-02 11:35:33 -07:00
Andrew Stewart
a4498d0281
Reduce duplication in Basestar event proxying code
2014-10-02 11:14:19 -07:00
Andrew Stewart
2c1c691cbc
Add new function proxying as utility function
2014-10-02 11:00:39 -07:00
Andrew Stewart
35c3a4b9e9
Proxy methods after #connect/#start
2014-10-01 18:11:36 -07:00
Andrew Stewart
d865bac72b
Add error triggering
2014-09-30 16:13:20 -07:00
Andrew Stewart
81dfda5732
Fixup specs
2014-09-30 12:22:00 -07:00
Andrew Stewart
8e0790ad9f
Default to manual mode, prevent multiple #starts
...
Additionally adds #halt/#disconnect to built-in loopback/ping
2014-09-30 12:17:02 -07:00
Andrew Stewart
f029438c19
Remove #Robot export, config option is now
2014-09-30 11:53:53 -07:00
Andrew Stewart
75c8d47676
Remove commands array from Adaptor base class
2014-09-29 15:41:13 -07:00
Andrew Stewart
77ecc2a82b
Automatically proxy methods from Adaptors to Connections
2014-09-29 15:25:51 -07:00
Andrew Stewart
de0a8fc0cb
Emit 'ready' event, not 'work', when working
2014-09-29 10:21:29 -07:00
Andrew Stewart
90cf0eed0a
Add direct Adaptor access inside Drivers
2014-09-23 11:57:35 -07:00
Andrew Stewart
6fa67f0e3b
Trigger test mode by checking NODE_ENV
...
Adds CYLON_TEST var for tests to make sure tests run properly
2014-09-22 15:05:45 -07:00
Andrew Stewart
299ade796b
Rename auto_start to 'auto'
2014-09-22 14:20:26 -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
1b549f2dbb
Remove Adaptor#_noop function
2014-09-22 09:53:10 -07:00
Andrew Stewart
333dc881ea
Move Cylon API config to the Cylon.configure block
2014-09-19 12:03:50 -07:00
Andrew Stewart
b7467e7a63
Fixup interval in driver
2014-09-18 12:03:41 -07:00
Andrew Stewart
e72ce5ceac
Add default interval in Driver class
2014-09-16 14:42:45 -07:00
Andrew Stewart
7560507f11
Switch to single Cylon#config function
2014-09-15 14:46:24 -07:00
Andrew Stewart
c182c1316e
Auto start by default, implement start of modes
2014-09-08 15:28:16 -07:00
Andrew Stewart
70bd524ebe
Explain auto_start better
2014-09-08 14:33:07 -07:00
Adrian Zankich
69f066e432
async the auto start
2014-09-08 14:30:23 -07:00
Andrew Stewart
3ec6c2717a
Switch to Logger.debug for default work, add test for #start return val
2014-09-08 14:14:11 -07:00
Andrew Stewart
f0d0e4b738
Correct tests for auto-start, allow for non-truthy values
2014-09-08 14:12:14 -07:00
Adrian Zankich
12ae17eeb2
Fix typo
2014-09-08 13:43:11 -07:00
Adrian Zankich
021c1756dc
Auto start by default
2014-09-08 13:41:59 -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
b48f5c3a57
Add no-op #connect and #start methods to built-ins
2014-09-08 09:31:16 -07:00
Andrew Stewart
cf643d9d70
Remove default Adaptor#connect and Driver#start methods
...
Child classes should always implement these themselves.
2014-09-08 09:27:18 -07:00
Andrew Stewart
14d8bbab00
Remove base Adaptor#disconnect and Driver#halt fns
...
Would be more useful to module developers to loudly error rather than silently
not work.
2014-09-05 09:55:57 -07:00
Andrew Stewart
9fe9700eef
Restructure Halt/Disconnect Structure
...
Moves disconnecting event handlers up a level so adaptors/drivers don't have to
worry about it.
Now, Adaptor/Driver subclasses should simply execute the provided callback to
dindicate they're done disconnecting, rather than calling the superclass method
as before.
2014-09-05 09:38:12 -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
d2b00c7d30
Attempt to stop drivers, then adaptors
2014-09-04 10:18:18 -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
11082b44a9
Remove extraneous Connection#halt method
2014-09-02 20:26:26 -07:00
Andrew Stewart
897668f3ab
Clean up DigitalPin class
2014-08-29 12:59:44 -07:00
Andrew Stewart
55f9445149
Remove #proxyTestStubs in favor of inline solution
2014-08-13 15:04:25 -07:00
Andrew Stewart
b312f6bb6b
Correctly proxy functions from driver to device
2014-08-12 18:33:20 -07:00
Andrew Stewart
ffc27f9942
Add ability to pass proxy
2014-08-12 10:07:17 -07:00
Andrew Stewart
6e9ceee6cf
Fixes to driver commands
2014-08-11 15:30:01 -07:00
Andrew Stewart
1f0b214c97
Add Driver#setupCommands method
2014-08-11 14:11:06 -07:00
Andrew Stewart
bad414be39
Correctly avoid labelling 'work' as a command
2014-08-07 14:00:30 -07:00
Andrew Stewart
7a481f6767
Correctly execute device commands
2014-08-07 13:56:06 -07:00
Andrew Stewart
e6c567a090
Add new command structure
2014-08-07 12:24:29 -07:00
Andrew Stewart
50f3ece923
Add basic error handling
2014-08-01 13:04:39 -07:00
Andrew Stewart
026d3777e6
Simplify coercion of Robot to JSON
2014-07-29 18:49:35 -07:00
Andrew Stewart
d0c29822ff
Correctly respond w/ 404 error
2014-07-28 10:01:16 -07:00
Andrew Stewart
029aca2e9e
Add 'details' subsection to Device/Connection
2014-07-25 16:11:45 -07:00
Ron Evans
8762820d0c
Merge pull request #213 from hybridgroup/refactor/threepio
...
Threepio Support
2014-07-19 01:08:19 +02:00
Andrew Stewart
715d9c89af
Emit 'ping' when Ping is told to #ping
...
sorry
2014-07-18 14:44:50 -07:00
Andrew Stewart
f5734b137e
Add MCP commands route, fix /robots route
2014-07-17 12:08:17 -07:00
Andrew Stewart
c97514689b
Only look for command params in POST bodies
2014-07-17 12:07:49 -07:00
Andrew Stewart
6b1d6e2653
WIP on Threepio changes
2014-07-15 12:45:32 -07:00
Andrew Stewart
4f66bdeb51
Namespace API routes under '/api'
2014-07-15 12:33:04 -07:00
Andrew Stewart
7394eefde2
WIP on commands + JSON serialization
2014-07-15 12:27:16 -07:00
Andrew Stewart
d7987f959e
Fix typo
2014-07-15 11:54:16 -07:00
Andrew Stewart
ace5f15a36
Refer to device connections by name in JSON format
2014-07-15 11:49:29 -07:00
Andrew Stewart
b4a68d1a37
Remove connection_id from Connection class
2014-07-15 11:43:43 -07:00
Adrian Zankich
0184efb4cd
Merge pull request #211 from hybridgroup/fix/require-connection
...
Require a connection if a robot has any devices
2014-07-14 07:57:20 -10:00
Andrew Stewart
c4d03428e8
Defer to Utils#fetch for getting ENV state
2014-07-12 11:00:34 -07:00
Andrew Stewart
ba295e9642
Slightly clean up Connection
2014-07-12 11:00:22 -07:00
Andrew Stewart
1c8e84cfb2
Clean up robot initialization
2014-07-12 10:48:57 -07:00
Andrew Stewart
4dd7e013ed
Require a connection if a robot has any devices
2014-07-11 10:46:22 -07:00
Andrew Stewart
ee366739d3
Misc. small refactors
2014-07-10 09:51:23 -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
1eabab6ec9
WIP: Change noop to use anonymous function and added tests.
2014-07-03 13:42:43 -05:00
Andrew Stewart
f0d8b0360b
Remove `self` references in favor of #bind
2014-07-03 09:35:24 -07:00
Edgar Silva
ed8d6faeee
Chance Adaptor#noop for Adaptor#_noop.
2014-07-02 20:06:40 -05:00
Edgar Silva
afa7fe7495
Adds noop function to base adaptor.
2014-07-02 19:42:39 -05:00
Edgar Silva
c4b10e66f4
Merge branch 'master' into servo-level-up
2014-07-02 17:05:15 -05:00
Andrew Stewart
5ce0d37640
Stop using #fetch here for now, it just breaks tests
2014-06-24 10:37:59 -07:00
Andrew Stewart
5974eb80cd
Just use arguments directly instead of array
2014-06-18 16:02:54 -07: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
5acfd4aed4
Remove Utils#bind in preference of built-in fn
...
We were re-implementing Function.prototype.bind, so let's just use that.
2014-06-17 19:35:07 -07:00
Andrew Stewart
6fa87fbf7c
Consolidate logstring generation into private fn
2014-06-17 19:18:12 -07:00
Andrew Stewart
e8520e3de2
Experiment with Utils.fetch in Driver class
2014-06-17 19:15:38 -07:00
Andrew Stewart
6f42b061b3
Add #fetch Utility function
...
The #fetch utility acts in (roughly) the same way as Ruby's Hash#fetch function.
This addition should hopefully make constructors more rigorous and help to
prevent a few classes of errors.
2014-06-17 16:02:54 -07:00
Andrew Stewart
af8cfbe333
Fix JSHint errors
2014-06-16 13:09:13 -07:00
Andrew Stewart
ca749fd03e
Fix an edge case and improve tests for API
2014-06-16 12:22:11 -07:00
Andrew Stewart
587efe2fee
Rename API variables for less confusion
...
api.express => the Express instance
api.server => the actual server (@express or a https.Server instance)
2014-06-16 08:44:52 -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
edgarsilva
0869909521
Updated fromScale util to return top or bottom of scale, updated specs to reflect new fromScale behavior.
2014-06-11 16:32:40 -05:00
Andrew Stewart
9e1ffad6f6
Add more tests for BasicLogger class
2014-06-10 19:05:41 -07:00
Andrew Stewart
9bbc7faf5e
Misc. JSHint-suggested cleanups in BasicLogger
2014-06-10 18:50:10 -07:00
Andrew Stewart
682bfc6536
Add missing semicolon to appease JSHint
2014-06-10 18:45:08 -07:00
Andrew Stewart
f797cf4c48
Misc. cleanup in Basestar
2014-06-10 18:44:40 -07:00
Andrew Stewart
9c60700c0f
Clean up declaration of default work block
2014-06-10 18:38:55 -07:00
Andrew Stewart
b66a1d3fee
Remove unused param for #start callback
2014-06-10 18:38:00 -07:00
Andrew Stewart
594c73dc60
Declare missingModuleError before it's used
2014-06-10 18:37:19 -07:00
Andrew Stewart
3b312def0d
Small cleanups in Device
2014-06-10 18:19:04 -07:00
Andrew Stewart
8d3c89076d
Allow easier extension in subclasses w/ prototypes
2014-06-10 14:18:35 -07:00
Andrew Stewart
1832e20e17
Expose commands as array, instead of function
...
For appropriate classes, #commands is now an array, instead of a function that
returns the same array.
2014-06-10 12:29:44 -07:00
Andrew Stewart
9406fddaad
Use same formatting for all log strings
2014-06-10 11:33:52 -07:00
Ron Evans
17c1d4609f
Merge pull request #198 from hybridgroup/refactor/robot
...
Robot Refactors
2014-06-10 13:52:00 -04:00
Andrew Stewart
0517942253
Remove the 'connect' and 'start' events
...
These events are being removed, as they're essentially useless in most cases, as
the events will already have been emitted before the work block is run to set up
handlers for them.
2014-06-10 09:20:23 -07:00
Andrew Stewart
3672a1b712
General cleanup of single-line statements
2014-06-09 14:02:06 -07:00
Andrew Stewart
dd553a55f2
Clean up #start to use Async.series
2014-06-09 13:55:44 -07:00
Andrew Stewart
4e43483e9d
Slightly refactor constructor
2014-06-09 13:41:46 -07:00
Andrew Stewart
dbde3d5b7d
Remove circular reference from Robot
2014-06-09 13:24:42 -07:00
edgarsilva
8c46aea525
Fix typo in IO utils.
2014-06-09 13:34:49 -05:00
Andrew Stewart
b1d7dd8186
Generate BasicLogger methods, rather than duplicating code
2014-06-06 17:09:22 -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
ebdeeccd12
Use implicit object conversion with #toJSON
...
JSON.stringify, if told to convert an object with a #toJSON method, will instead
stringify the result of the #toJSON method.
2014-06-06 14:15:43 -07:00
Andrew Stewart
af4bbd963b
Clean up API implementation using middleware
2014-06-06 13:52:55 -07: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
2b5e991ef3
Clean up some of the utility functions
2014-06-05 16:30:05 -07:00
Edgar Silva
a60f16b8ea
Fix typo in utils param name.
2014-06-05 14:47:48 -05: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
789347f6f8
Improve inline docs for Utils functions
2014-06-05 09:32:20 -07:00
Andrew Stewart
a5241e57b5
All work and no play makes Jack a dull boy
...
Robots can now take a break and have #play functions instead of #work.
Internally they're treated the same, but it's a fun easter egg!
Example:
Cylon.robot({
name: 'Jack',
connections: [],
devices: [],
play: function play(my) {
every((5).seconds(), function() {
console.log("All work and no play makes %s a dull boy.", my.name);
});
}
});
I sincerely apologize for the repeated reference to The Shining, blame
@deadprogram.
Closes #189 .
2014-06-04 16:33:20 -07:00
Andrew Stewart
9b352feeae
Move API command param parsing to middleware
2014-06-04 15:54:23 -07:00
Andrew Stewart
ac0a69e63f
Move API routes to their own file
2014-06-04 13:39:30 -07:00
Andrew Stewart
789ce02ad0
Organize server creation into new function
2014-06-04 13:21:15 -07:00
Andrew Stewart
a4cfc4b8ec
Improve authentication middleware mounting
2014-06-04 13:17:17 -07:00