Comparing version 1.2.2 to 1.2.3
105
can.js
@@ -28,7 +28,16 @@ /* Copyright Sebastian Haas <sebastian@sebastianhaas.info>. All rights reserved. | ||
// Exports | ||
/** | ||
* @method createRawChannel | ||
* @param channel {string} Channel name (e.g. vcan0) | ||
* @return {RawChannel} a new channel object or exception | ||
* @for exports | ||
*/ | ||
exports.createRawChannel = function(channel, timestamps) { return new can.RawChannel(channel, timestamps); } | ||
//----------------------------------------------------------------------------- | ||
// Signal-Object | ||
/** | ||
* The Signals modules provides an interface to access the values/signals | ||
* encoded in CAN messages. | ||
* @module Signals | ||
*/ | ||
@@ -39,4 +48,13 @@ var _signals = require('./build/Release/can_signals'); | ||
/** | ||
* The actual signal. | ||
* @class Signal | ||
*/ | ||
function Signal(desc) | ||
{ | ||
/** | ||
* Symbolic name | ||
* @attribute name | ||
* @final | ||
*/ | ||
this.name = desc['name']; | ||
@@ -55,2 +73,7 @@ | ||
/** | ||
* Current value | ||
* @attribute value | ||
* @final | ||
*/ | ||
this.value = desc['defaultValue']; | ||
@@ -63,3 +86,8 @@ if (!this.value) | ||
// Keep track of listeners who want to be notified if this signal changes | ||
/** | ||
* Keep track of listeners who want to be notified if this signal changes | ||
* @method onChange | ||
* @param listener JS callback to get notification | ||
* @for Signal | ||
*/ | ||
Signal.prototype.onChange = function(listener) { | ||
@@ -69,3 +97,10 @@ this.listeners.push(listener); | ||
// Someone wants to change signals' value | ||
/** | ||
* Set new value of this signal. Any local registered clients will | ||
* receive a notification. Please note, no CAN message is actually | ||
* send to the bus (@see DatabaseServer::send) | ||
* @method update | ||
* @param newValue {bool|double|integer} New value to set | ||
* @for Signal | ||
*/ | ||
Signal.prototype.update = function(newValue) { | ||
@@ -85,12 +120,41 @@ // Nothing changed | ||
//----------------------------------------------------------------------------- | ||
// Message-Object | ||
/** | ||
* Just a container to keep the Signals. | ||
* @class Message | ||
*/ | ||
function Message(desc) | ||
{ | ||
/** | ||
* CAN identifier | ||
* @attribute id | ||
* @final | ||
*/ | ||
this.id = desc.id; | ||
/** | ||
* Extended Frame Format used | ||
* @attribute ext | ||
* @final | ||
*/ | ||
this.ext = desc.ext; | ||
/** | ||
* Symbolic name | ||
* @attribute name | ||
* @final | ||
*/ | ||
this.name = desc.name; | ||
/** | ||
* Length in bytes of resulting CAN message | ||
* @attribute length | ||
* @final | ||
*/ | ||
this.length = desc.length; | ||
/** | ||
* Named array of signals within this message. Accessible via index and name. | ||
* @attribute {Signal} signals | ||
* @final | ||
*/ | ||
this.signals = []; | ||
@@ -105,6 +169,19 @@ | ||
//----------------------------------------------------------------------------- | ||
// DatabaseService | ||
/** | ||
* A DatabaseService is usually generated once per bus to collect signals | ||
* coded in the CAN messages according a DB description. | ||
* @class DatabaseService | ||
* @constructor DatabaseService | ||
* @param channel RAW channel | ||
* @param db_desc Set of rules to decode/encode signals (@parse_kcd.js) | ||
* @return a new DatabaseService | ||
* @for DatabaseService | ||
*/ | ||
function DatabaseService(channel, db_desc) { | ||
this.channel = channel; | ||
/** | ||
* Named array of known messages. Accessible via index and name. | ||
* @attribute {Message} messages | ||
*/ | ||
this.messages = []; | ||
@@ -121,5 +198,7 @@ | ||
// Subscribe to any incoming messages | ||
channel.addListener("onMessage", this.onMessage, this); | ||
} | ||
// Callback for incoming messages | ||
DatabaseService.prototype.onMessage = function (msg) { | ||
@@ -154,2 +233,9 @@ if (msg.rtr) | ||
/** | ||
* Construct a CAN message and encode all related signals according | ||
* the rules. Finally send the message to the bus. | ||
* @method send | ||
* @param msg_name Name of the message to generate | ||
* @for DatabaseService | ||
*/ | ||
DatabaseService.prototype.send = function (msg_name) { | ||
@@ -192,5 +278,10 @@ var m = this.messages[msg_name] | ||
// Exports | ||
/** | ||
* @method parseNetworkDescription | ||
* @param file {string} Path to KCD file to parse | ||
* @return DB description to be used in DatabaseService | ||
* @for exports | ||
*/ | ||
exports.parseNetworkDescription = kcd.parseKcdFile; | ||
exports.DatabaseService = DatabaseService; | ||
@@ -8,3 +8,3 @@ { | ||
"description": "A SocketCAN abstraction layer for NodeJS.", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"repository": { | ||
@@ -11,0 +11,0 @@ "type": "git", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
253641
47
2280
3
2