Ruff 1.6.0 Documentation
Table of Contents
Ruff Driver#
The ruff-driver
module provides you a facility for Ruff driver developers to build their device driver.
Usage#
var driver = require('ruff-driver');
Configuring driver.json
#
driver.json
is the configuration file that describes the information that related to the driver,
and what interfaces the device requires and exports.
{
"models": [...],
"inputs": {
"...": {
"type": ...,
"args": {
...
}
}
}
}
Please refer to interface documentations for more detailed configurations:
Defining Device#
'use strict';
var driver = require('ruff-driver');
module.exports = driver({
attach: function (inputs) {
// ...
}
});
Options#
attach(inputs, context[, callback])
#
A function with three or less parameters that intializes the device instance.
- inputs: A map of assigned interfaces according to
driver.json
. - context: Context of this instance to attach.
- id: ID of the device.
- model: Model of the device.
- args: A map of device arguments.
- callback: If the third parameter presents, the callback for asyncrhonous attaching.
detach([callback])
#
Optional. A function that disposes the device instance.
- callback: If presents, the callback for asynchronous detaching.
getInterface(name, options[, callback])
#
Optional. A function to get interface instance if any, this should be required if driver.json
has outputs
configured.
- name: The name of interface requested.
- options: Options (defined by
args
indriver.json
) to initiate the interface. - callback: If presents, the callback for asyncrhonous attaching.
exports
#
Optional. An object with properties or methods to be copied to the prototype of device.
traits
#
Optional. An array of traits to be applied.