node-red-contrib-mobius-flow-base 2.5.87-beta.1 → 2.5.88

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -68,7 +68,6 @@ module.exports = function (RED) {
68
68
  this.service.srvcAPI.removeAllListeners('obcov');
69
69
  this.service.srvcAPI.removeAllListeners('bcmd');
70
70
  this.service.srvcAPI.on('cov', (response) => {
71
- console.log('*************************** Resource COV detected');
72
71
  this.handleCOVEvents(response);
73
72
  });
74
73
  this.service.srvcAPI.on('obcov', (response) => {
@@ -28,7 +28,7 @@
28
28
  'use strict';
29
29
 
30
30
  module.exports = function (RED) {
31
- function MobiusFlowNode (n) {
31
+ function MobiusFlowNode(n) {
32
32
  RED.nodes.createNode(this, n);
33
33
  this.subscriptions = n.subscriptions;
34
34
  this.sendType = n.send;
@@ -45,7 +45,7 @@ module.exports = function (RED) {
45
45
  node.status({
46
46
  fill: 'red',
47
47
  shape: 'ring',
48
- text: 'Disconnected'
48
+ text: 'Disconnected',
49
49
  });
50
50
 
51
51
  node.serviceConn.register(node);
@@ -54,54 +54,57 @@ module.exports = function (RED) {
54
54
  node.status({
55
55
  fill: 'green',
56
56
  shape: 'ring',
57
- text: 'Busy'
57
+ text: 'Busy',
58
58
  });
59
59
 
60
- node.discoverAllObjectURIs(msg).then((objectList) => {
61
- if (node.sendType === 'individual') {
62
- objectList.forEach((mobiusObject) => {
60
+ node
61
+ .discoverAllObjectURIs(msg)
62
+ .then((objectList) => {
63
+ if (node.sendType === 'individual') {
64
+ objectList.forEach((mobiusObject) => {
65
+ if (node.outputType === 'uris') {
66
+ node.send({
67
+ topic: mobiusObject.uri,
68
+ payload: mobiusObject.uri,
69
+ });
70
+ } else {
71
+ node.send({
72
+ topic: mobiusObject.uri,
73
+ payload: mobiusObject,
74
+ });
75
+ }
76
+ });
77
+ } else {
63
78
  if (node.outputType === 'uris') {
79
+ const uris = [];
80
+ objectList.forEach((mobiusObject) => {
81
+ uris.push(mobiusObject.uri);
82
+ });
64
83
  node.send({
65
- topic: mobiusObject.uri,
66
- payload: mobiusObject.uri
84
+ topic: msg.topic,
85
+ payload: uris,
67
86
  });
68
87
  } else {
69
88
  node.send({
70
- topic: mobiusObject.uri,
71
- payload: mobiusObject
89
+ topic: msg.topic,
90
+ payload: objectList,
72
91
  });
73
- }
74
- });
75
- } else {
76
- if (node.outputType === 'uris') {
77
- const uris = [];
78
- objectList.forEach((mobiusObject) => {
79
- uris.push(mobiusObject.uri);
80
- });
81
- node.send({
82
- topic: msg.topic,
83
- payload: uris
84
- });
85
- } else {
86
- node.send({
87
- topic: msg.topic,
88
- payload: objectList
89
- });
92
+ }
90
93
  }
91
- }
92
-
93
- node.status({
94
- fill: 'green',
95
- shape: 'dot',
96
- text: 'Done'
97
- });
98
- }).catch(() => {
99
- node.status({
100
- fill: 'yellow',
101
- shape: 'dot',
102
- text: 'Failed discovery'
94
+
95
+ node.status({
96
+ fill: 'green',
97
+ shape: 'dot',
98
+ text: 'Done',
99
+ });
100
+ })
101
+ .catch(() => {
102
+ node.status({
103
+ fill: 'yellow',
104
+ shape: 'dot',
105
+ text: 'Failed discovery',
106
+ });
103
107
  });
104
- });
105
108
  if (done) {
106
109
  done();
107
110
  }
@@ -131,27 +134,29 @@ module.exports = function (RED) {
131
134
  pids: pids,
132
135
  rid: node.rid,
133
136
  func: node.func,
134
- limit: node.limit
137
+ limit: node.limit,
135
138
  };
136
139
  } else {
137
140
  discoverParams = {
138
141
  uri: serviceURI,
139
- pids: pids,
140
- rid: '00',
141
- func: 'return true;',
142
- limit: 512
142
+ // pids: pids,
143
+ // rid: '00',
144
+ // func: 'return true;',
145
+ // limit: 512
143
146
  };
144
147
  }
145
148
  try {
146
149
  let objects = await discover(node.serviceConn, discoverParams);
147
150
  for (let lp = 0; lp < objects.value.length; lp++) {
148
- objects.value[lp]['uri'] = `${serviceURI}/${objects.value[lp].pid}/${objects.value[lp].ins}`;
151
+ objects.value[lp][
152
+ 'uri'
153
+ ] = `${serviceURI}/${objects.value[lp].pid}/${objects.value[lp].ins}`;
149
154
  objectList.push(objects.value[lp]);
150
155
  }
151
156
  } catch (err) {
152
157
  node.warn(`Discover object failed for service (${serviceURI}) - ${err.message}`);
153
158
  }
154
- }
159
+ }
155
160
 
156
161
  if (objectList.length === 0) {
157
162
  throw new Error('No discovery data found');
@@ -176,23 +181,28 @@ module.exports = function (RED) {
176
181
  let profiles = await discover(serviceConn, `${hid}/${sid}`);
177
182
  let pids = [];
178
183
  for (const pid of profiles.value) {
179
- if (isIncluded(`${hid}/${sid}/${pid}/#`, subscriptions) && !isExcluded(`${hid}/${sid}/${pid}/#`, subscriptions)) {
184
+ if (
185
+ isIncluded(`${hid}/${sid}/${pid}/#`, subscriptions) &&
186
+ !isExcluded(`${hid}/${sid}/${pid}/#`, subscriptions)
187
+ ) {
180
188
  pids.push(pid);
181
- }
189
+ }
182
190
  }
183
191
  if (pids.length > 0) {
184
192
  discoveredProfiles.set(`${hid}/${sid}`, pids);
185
193
  }
186
194
  }
187
195
  } else {
188
- RED.log.warn(`Failed to discover objects for service ${service.id.split('/')[1]} as it is offline.`);
196
+ RED.log.warn(
197
+ `Failed to discover objects for service ${service.id.split('/')[1]} as it is offline.`
198
+ );
189
199
  }
190
200
  }
191
201
  resolve(discoveredProfiles);
192
202
  });
193
203
  }
194
204
 
195
- async function discover (serviceConn, params) {
205
+ async function discover(serviceConn, params) {
196
206
  return new Promise((resolve, reject) => {
197
207
  serviceConn.discover(params, (err, response) => {
198
208
  if (err) {
@@ -202,7 +212,7 @@ module.exports = function (RED) {
202
212
  }
203
213
  });
204
214
  });
205
- };
215
+ }
206
216
 
207
217
  function isIncluded(uri, subscriptions) {
208
218
  let include = false;
@@ -216,7 +226,7 @@ module.exports = function (RED) {
216
226
  return include;
217
227
  }
218
228
 
219
- function isExcluded (uri, subscriptions) {
229
+ function isExcluded(uri, subscriptions) {
220
230
  let exclude = false;
221
231
  for (const subscription of subscriptions) {
222
232
  if (subscription.type === 'exclude' && validateSubscription(subscription.uri)) {
@@ -228,7 +238,7 @@ module.exports = function (RED) {
228
238
  return exclude;
229
239
  }
230
240
 
231
- function validateSubscription (uri) {
241
+ function validateSubscription(uri) {
232
242
  let parts = uri.split('/');
233
243
  for (let lp = 0; lp < parts.length; lp++) {
234
244
  if (parts[lp] === null || parts[lp] === '') {
@@ -244,11 +254,11 @@ module.exports = function (RED) {
244
254
  return false;
245
255
  }
246
256
 
247
- function matchTopic (filter, topic) {
257
+ function matchTopic(filter, topic) {
248
258
  const filterArray = filter.split('/');
249
259
  const topicArray = topic.split('/');
250
260
  const length = filterArray.length < topicArray.length ? filterArray.length : topicArray.length;
251
-
261
+
252
262
  for (let i = 0; i < length; ++i) {
253
263
  const left = filterArray[i];
254
264
  const right = topicArray[i];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-mobius-flow-base",
3
- "version": "2.5.87-beta.1",
3
+ "version": "2.5.88",
4
4
  "description": "Node-RED base nodes for Mobius Flow",
5
5
  "main": "index.js",
6
6
  "types": "dist/index.d.ts",