Skip to content

Commit cfb7c5f

Browse files
committed
doc: update metering example and README
1 parent eaa5aa4 commit cfb7c5f

File tree

4 files changed

+30
-173
lines changed

4 files changed

+30
-173
lines changed

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,16 @@ client.on('error', (e) => {
3333
await client.connect()
3434

3535
// If you want to listen to stream updates - you can do it like this:
36-
client.on('streamUpdate', (path, value) => {
36+
client.on('streamUpdate', (internalNodePath, value) => {
3737
console.log('Stream Update:', {
38-
path: path,
38+
path: internalNodePath,
3939
value: value,
4040
})
41+
// You can get the internal node path, the internal path can be different from the path you requested,
42+
// depending on wheter you request a numbered node or via the description
43+
// the client has a client.getInternalNodePath(node) that you can request and use as reference when subsribing to a node
4144
})
45+
4246
// Get Root info
4347
const req = await client.getDirectory(client.tree)
4448
await req.response
@@ -95,6 +99,12 @@ client
9599
console.log(update)
96100
})
97101
)
102+
client.on('streamUpdate', (internalNodePath, value) => {
103+
console.log('Stream Update:', {
104+
path: internalNodePath,
105+
value: value,
106+
})
107+
})
98108
```
99109

100110
### Setting New Value

examples/mc2_1_fader_mock.js renamed to examples/lawo_mc2_fader_metering_example.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
1-
//process.env.DEBUG = 'emberplus-connection:*'
1+
// Setting the environment variable DEBUG=emberplus-connection:*
2+
// will show debug information from the emberplus-connection module
3+
4+
process.env.DEBUG = 'emberplus-connection:*'
5+
// Note: it's also possible to only log parts of the module by using a subset of the debug name,
6+
// 'emberplus-connection:S101Client' // for the S101Client class
7+
// 'emberplus-connection:S101Codec' // for the S101Codec class
8+
// 'emberplus-connection:StreamManager' // for the StreamManager class
9+
210
const { EmberClient } = require('../dist/index')
311

412
//-------------------------------------------------------------------------
513
// Client
6-
// log output from mc2_1_fader_mock.js
14+
// log output from lawo_mc2_fader_metering_mock.js
715
// ------------------------------------------------------------------------
816

917
const client = new EmberClient('192.168.1.67', 9000)
18+
let node1InternalNodePath = ''
1019

1120
client.on('disconnected', () => {
1221
console.error('Client Lost Ember connection')
@@ -35,6 +44,7 @@ client.on('connected', () => {
3544
throw new Error(' Could not find node 1')
3645
}
3746
console.log('Found node:', node1)
47+
node1InternalNodePath = client.getInternalNodePath(node1)
3848

3949
// Subscribe to changes
4050
client.subscribe(node1, (node1) => {
@@ -46,15 +56,18 @@ client.on('connected', () => {
4656
console.error(' Error:', error)
4757
})
4858
})
49-
client.on('streamUpdate', (path, value) => {
59+
client.on('streamUpdate', (internalNodePath, value) => {
60+
if (internalNodePath !== node1InternalNodePath) {
61+
return
62+
}
5063
console.log('Stream Update:', {
51-
path: path,
64+
path: internalNodePath,
5265
value: value,
5366
})
5467
})
5568

5669
console.log('-----------------------------------------------------------------------------')
57-
console.log('log output from mc2_1_fader_mock.js')
70+
console.log('log output from mc2_fader_metering_example.js')
5871
console.log('Connecting to Client...')
5972
client.connect().catch((error) => {
6073
console.error('Client 2 Error when connecting:', error)

examples/mc2_mock.js

Lines changed: 0 additions & 106 deletions
This file was deleted.

examples/r3lay_pacthbay_mock.js

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)