Skip to content

Commit

Permalink
Merge pull request #96 from fh1ch/docs/function-docs-improve
Browse files Browse the repository at this point in the history
Docs/function docs improve
  • Loading branch information
fh1ch committed Apr 2, 2018
2 parents 4777725 + 4ed6d06 commit 2f98d3b
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 30 deletions.
60 changes: 31 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,35 +28,37 @@ The BACNET standard defines a wide variety of services as part of it's
specification. While Node BACstack tries to be as complete as possible,
following services are already supported at this point in time:

| Service | Execute | Handle |
|--------------------------------|:-------:|:------:|
| Who Is / I Am | yes | yes¹ |
| Who Has / I Have | yes¹ | yes¹ |
| Time Sync | yes | yes¹ |
| UTC Time Sync | yes | yes¹ |
| Read Property | yes | yes¹ |
| Read Property Multiple | yes | yes¹ |
| Read Range | yes¹ | yes¹ |
| Write Property | yes | yes¹ |
| Write Property Multiple | yes | yes¹ |
| Add List Element | yes¹ | yes¹ |
| Remove List Element | yes¹ | yes¹ |
| Create Object | yes¹ | yes¹ |
| Delete Object | yes¹ | yes¹ |
| Subscribe COV | yes¹ | yes¹ |
| Subscribe Property | yes¹ | yes¹ |
| Atomic Read File | yes¹ | yes¹ |
| Atomic Write File | yes¹ | yes¹ |
| Reinitialize Device | yes | yes¹ |
| Device Communication Control | yes | yes¹ |
| Get Alarm Summary | yes¹ | yes¹ |
| Get Event Information | yes¹ | yes¹ |
| Get Enrollment Summary | yes¹ | yes¹ |
| Acknowledge Alarm | yes¹ | yes¹ |
| Confirmed Event Notification | yes¹ | yes¹ |
| Unconfirmed Event Notification | yes¹ | yes¹ |
| Unconfirmed Private Transfer | yes¹ | yes¹ |
| Confirmed Private Transfer | yes¹ | yes¹ |
| Service | Execute | Handle |
|--------------------------------|:--------------------------------------------------------------------------------------:|:-----------------------------------------------------------------------------:|
| Who Is | [yes](https://fh1ch.github.io/node-bacstack/bacstack.html#.whoIs) | [yes](https://fh1ch.github.io/node-bacstack/bacstack.html#.event:whoIs) |
| I Am | yes¹ | [yes](https://fh1ch.github.io/node-bacstack/bacstack.html#.event:iAm) |
| Who Has | yes¹ | yes¹ |
| I Have | yes¹ | yes¹ |
| Time Sync | [yes](https://fh1ch.github.io/node-bacstack/bacstack.html#.timeSync) | [yes](https://fh1ch.github.io/node-bacstack/bacstack.html#.event:timeSync) |
| UTC Time Sync | [yes](https://fh1ch.github.io/node-bacstack/bacstack.html#.timeSyncUTC) | [yes](https://fh1ch.github.io/node-bacstack/bacstack.html#.event:timeSyncUTC) |
| Read Property | [yes](https://fh1ch.github.io/node-bacstack/bacstack.html#.readProperty) | yes¹ |
| Read Property Multiple | [yes](https://fh1ch.github.io/node-bacstack/bacstack.html#.readPropertyMultiple) | yes¹ |
| Read Range | yes¹ | yes¹ |
| Write Property | [yes](https://fh1ch.github.io/node-bacstack/bacstack.html#.writeProperty) | yes¹ |
| Write Property Multiple | [yes](https://fh1ch.github.io/node-bacstack/bacstack.html#.writePropertyMultiple) | yes¹ |
| Add List Element | yes¹ | yes¹ |
| Remove List Element | yes¹ | yes¹ |
| Create Object | yes¹ | yes¹ |
| Delete Object | yes¹ | yes¹ |
| Subscribe COV | yes¹ | yes¹ |
| Subscribe Property | yes¹ | yes¹ |
| Atomic Read File | yes¹ | yes¹ |
| Atomic Write File | yes¹ | yes¹ |
| Reinitialize Device | [yes](https://fh1ch.github.io/node-bacstack/bacstack.html#.reinitializeDevice) | yes¹ |
| Device Communication Control | [yes](https://fh1ch.github.io/node-bacstack/bacstack.html#.deviceCommunicationControl) | yes¹ |
| Get Alarm Summary | yes¹ | yes¹ |
| Get Event Information | yes¹ | yes¹ |
| Get Enrollment Summary | yes¹ | yes¹ |
| Acknowledge Alarm | yes¹ | yes¹ |
| Confirmed Event Notification | yes¹ | yes¹ |
| Unconfirmed Event Notification | yes¹ | yes¹ |
| Unconfirmed Private Transfer | yes¹ | yes¹ |
| Confirmed Private Transfer | yes¹ | yes¹ |

¹ Support implemented as Beta (untested, undocumented, breaking interface)

Expand Down
49 changes: 48 additions & 1 deletion lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ class Client extends EventEmitter {
if (!result) return debug('Received invalid iAm message');

/**
* The iAm event represents the response to a whoIs request to detect all devices in a BACNET network.
* @event bacstack.iAm
* @param {object} device - An object representing the detected device.
* @param {string} device.address - The IP address of the detected device.
Expand All @@ -290,6 +291,22 @@ class Client extends EventEmitter {
} else if (service === baEnum.UnconfirmedServices.SERVICE_UNCONFIRMED_WHO_IS) {
result = baServices.decodeWhoIsBroadcast(buffer, offset, length);
if (!result) return debug('Received invalid WhoIs message');

/**
* The whoIs event represents the request for an IAm reponse to detect all devices in a BACNET network.
* @event bacstack.whoIs
* @param {object} request - An object representing the received request.
* @param {string} request.address - The IP address of the device sending the request.
* @param {number=} request.lowLimit - The lower limit of the BACNET device-id.
* @param {number=} request.highLimit - The higher limit of the BACNET device-id.
* @example
* const bacnet = require('bacstack');
* const client = new bacnet();
*
* client.on('whoIs', (request) => {
* console.log('address: ', device.address, ' - lowLimit: ', device.lowLimit, ' - highLimit: ', device.highLimit);
* });
*/
this.emit('whoIs', {address: address, lowLimit: result.lowLimit, highLimit: result.highLimit});
} else if (service === baEnum.UnconfirmedServices.SERVICE_UNCONFIRMED_WHO_HAS) {
result = baServices.decodeWhoHasBroadcast(buffer, offset, length);
Expand All @@ -302,10 +319,40 @@ class Client extends EventEmitter {
} else if (service === baEnum.UnconfirmedServices.SERVICE_UNCONFIRMED_TIME_SYNCHRONIZATION) {
result = baServices.decodeTimeSync(buffer, offset, length);
if (!result) return debug('Received invalid TimeSync message');

/**
* The timeSync event represents the request to synchronize the local time to the received time.
* @event bacstack.timeSync
* @param {object} request - An object representing the received request.
* @param {string} request.address - The IP address of the device sending the request.
* @param {date} request.dateTime - The time to be synchronized to.
* @example
* const bacnet = require('bacstack');
* const client = new bacnet();
*
* client.on('timeSync', (request) => {
* console.log('address: ', device.address, ' - dateTime: ', device.dateTime);
* });
*/
this.emit('timeSync', {address: address, dateTime: result.dateTime});
} else if (service === baEnum.UnconfirmedServices.SERVICE_UNCONFIRMED_UTC_TIME_SYNCHRONIZATION) {
result = baServices.decodeTimeSync(buffer, offset, length);
if (!result) return debug('Received invalid TimeSyncUTC message');

/**
* The timeSyncUTC event represents the request to synchronize the local time to the received UTC time.
* @event bacstack.timeSyncUTC
* @param {object} request - An object representing the received request.
* @param {string} request.address - The IP address of the device sending the request.
* @param {date} request.dateTime - The time to be synchronized to.
* @example
* const bacnet = require('bacstack');
* const client = new bacnet();
*
* client.on('timeSyncUTC', (request) => {
* console.log('address: ', device.address, ' - dateTime: ', device.dateTime);
* });
*/
this.emit('timeSyncUTC', {address: address, dateTime: result.dateTime});
} else if (service === baEnum.UnconfirmedServices.SERVICE_UNCONFIRMED_EVENT_NOTIFICATION) {
result = baServices.decodeEventNotifyData(buffer, offset, length);
Expand Down Expand Up @@ -408,7 +455,7 @@ class Client extends EventEmitter {

/**
* @event bacstack.error
* @param {error} err - The IP address of the detected device.
* @param {error} err - The error object thrown by the underlying transport layer.
* @example
* const bacnet = require('bacstack');
* const client = new bacnet();
Expand Down

0 comments on commit 2f98d3b

Please sign in to comment.