node-red-contrib-mobius-flow-base 2.5.86-beta.67 → 2.5.86-beta.70
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.
- package/dist/nodes/common/mobsearch.js +115 -27
- package/dist/nodes/mobius-clear-resource.html +8 -273
- package/dist/nodes/mobius-clear-resource.js +21 -8
- package/dist/nodes/mobius-discover-object-list.html +12 -248
- package/dist/nodes/mobius-discover-object-list.js +71 -53
- package/dist/nodes/mobius-flow-inject.html +12 -248
- package/dist/nodes/mobius-flow-inject.js +23 -9
- package/dist/nodes/mobius-get-multi-object.html +12 -248
- package/dist/nodes/mobius-get-multi-object.js +17 -9
- package/dist/nodes/mobius-get-resource.html +0 -5
- package/dist/nodes/mobius-object-cov.html +8 -238
- package/dist/nodes/mobius-object-cov.js +8 -0
- package/dist/nodes/mobius-resource-cov.html +8 -273
- package/dist/nodes/mobius-resource-cov.js +13 -5
- package/dist/nodes/mobius-set-multi-resource.html +8 -238
- package/dist/nodes/mobius-set-multi-resource.js +8 -0
- package/dist/nodes/mobius-set-resource.html +9 -273
- package/dist/nodes/mobius-set-resource.js +31 -13
- package/package.json +1 -1
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
'use strict';
|
|
29
29
|
|
|
30
30
|
module.exports = function (RED) {
|
|
31
|
-
function MobiusClearResourceNode
|
|
31
|
+
function MobiusClearResourceNode(n) {
|
|
32
32
|
RED.nodes.createNode(this, n);
|
|
33
33
|
this.detailedOutput = n.detailedOutput;
|
|
34
34
|
this.resource = n.resource;
|
|
@@ -40,7 +40,7 @@ module.exports = function (RED) {
|
|
|
40
40
|
node.status({
|
|
41
41
|
fill: 'red',
|
|
42
42
|
shape: 'ring',
|
|
43
|
-
text: 'Disconnected'
|
|
43
|
+
text: 'Disconnected',
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
node.on('input', function (msg) {
|
|
@@ -57,7 +57,7 @@ module.exports = function (RED) {
|
|
|
57
57
|
node.status({
|
|
58
58
|
fill: 'green',
|
|
59
59
|
shape: 'ring',
|
|
60
|
-
text: 'Busy'
|
|
60
|
+
text: 'Busy',
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
node.serviceConn.clearResourcePriority(uri, pri, (err, response) => {
|
|
@@ -65,29 +65,34 @@ module.exports = function (RED) {
|
|
|
65
65
|
node.status({
|
|
66
66
|
fill: 'yellow',
|
|
67
67
|
shape: 'dot',
|
|
68
|
-
text: 'Error: ' + JSON.stringify(err.code)
|
|
68
|
+
text: 'Error: ' + JSON.stringify(err.code),
|
|
69
69
|
});
|
|
70
70
|
node.error('Mobius error clearing resource priority ' + JSON.stringify(err));
|
|
71
71
|
if (node.detailedOutput === true) {
|
|
72
|
-
node.send([
|
|
72
|
+
node.send([
|
|
73
|
+
null,
|
|
74
|
+
null,
|
|
75
|
+
null,
|
|
76
|
+
{ topic: uri, payload: { error: true, response: err } },
|
|
77
|
+
]);
|
|
73
78
|
}
|
|
74
79
|
} else {
|
|
75
80
|
node.status({
|
|
76
81
|
fill: 'green',
|
|
77
82
|
shape: 'dot',
|
|
78
|
-
text: JSON.stringify(response.value.pv)
|
|
83
|
+
text: JSON.stringify(response.value.pv),
|
|
79
84
|
});
|
|
80
85
|
if (node.detailedOutput === true) {
|
|
81
86
|
node.send([
|
|
82
87
|
{ topic: uri, payload: response.value.pv },
|
|
83
88
|
{ topic: uri, payload: { pv: response.value.pv, name: response.value.name } },
|
|
84
89
|
{ topic: uri, payload: response.value },
|
|
85
|
-
{ topic: uri, payload: { error: false, response: response } }
|
|
90
|
+
{ topic: uri, payload: { error: false, response: response } },
|
|
86
91
|
]);
|
|
87
92
|
} else {
|
|
88
93
|
node.send([
|
|
89
94
|
{ topic: uri, payload: response.value.pv },
|
|
90
|
-
{ topic: uri, payload: { pv: response.value.pv, name: response.value.name } }
|
|
95
|
+
{ topic: uri, payload: { pv: response.value.pv, name: response.value.name } },
|
|
91
96
|
]);
|
|
92
97
|
}
|
|
93
98
|
}
|
|
@@ -106,4 +111,12 @@ module.exports = function (RED) {
|
|
|
106
111
|
}
|
|
107
112
|
|
|
108
113
|
RED.nodes.registerType('mobius clear resource', MobiusClearResourceNode);
|
|
114
|
+
|
|
115
|
+
RED.httpAdmin.get('/common/*', function (req, res) {
|
|
116
|
+
var options = {
|
|
117
|
+
root: __dirname + '/common/',
|
|
118
|
+
dotfiles: 'deny',
|
|
119
|
+
};
|
|
120
|
+
res.sendFile(req.params[0], options);
|
|
121
|
+
});
|
|
109
122
|
};
|
|
@@ -58,23 +58,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
58
58
|
<ol id="node-input-subs-container"></ol>
|
|
59
59
|
</div>
|
|
60
60
|
|
|
61
|
-
<div id="
|
|
62
|
-
<div class="form-row">
|
|
63
|
-
<label for="instance-search-sid"><i class="fa fa-search"></i> Search</label>
|
|
64
|
-
<input type="text" id="instance-search-hid" style="width:15%;" placeholder="HID">
|
|
65
|
-
<input type="text" id="instance-search-sid" style="width:10%;" placeholder="SID">
|
|
66
|
-
<input type="text" id="instance-search-pid" style="width:10%;" placeholder="PID">
|
|
67
|
-
<input type="text" id="instance-search-ins" style="width:10%;" placeholder="INS">
|
|
68
|
-
<a id="node-search-return" class="searchbutton" style="vertical-align: middle"><i id="node-search-return-icon" class="fa fa-arrow-left"></i></a>
|
|
69
|
-
<a id="node-search-accept" class="searchbutton" style="vertical-align: middle"><i id="node-search-accept-icon" class="fa fa-check"></i></a>
|
|
70
|
-
</div>
|
|
71
|
-
</div>
|
|
72
|
-
<div id="wildcard-alert-row" class="form-row hidden" style="color:#555555" align="center">
|
|
73
|
-
<p>Please note: The selection of wildcard '+'
|
|
74
|
-
means a search for a specific instance or resource
|
|
75
|
-
cannot be performed. As such, enter the
|
|
76
|
-
INS manually.</p>
|
|
77
|
-
</div>
|
|
61
|
+
<div id="mobsearch"></div>
|
|
78
62
|
|
|
79
63
|
<div class="form-row">
|
|
80
64
|
<label for="node-input-useRIDValueFiltering" style="width:178px;float:left;"><i class="fa fa-filter"></i> Filter by Resource Value</label>
|
|
@@ -96,6 +80,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
96
80
|
</div>
|
|
97
81
|
</script>
|
|
98
82
|
|
|
83
|
+
<script src="common/mobsearch.js"></script>
|
|
84
|
+
|
|
99
85
|
<script type="text/javascript">
|
|
100
86
|
RED.nodes.registerType('mobius discover object list', {
|
|
101
87
|
category: 'mobius',
|
|
@@ -140,214 +126,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
140
126
|
var node = this;
|
|
141
127
|
let mobiusSrvc = $("#node-input-connection").val();
|
|
142
128
|
|
|
143
|
-
// *** MOBSEARCH *** //
|
|
144
|
-
|
|
145
|
-
$("#instance-search-row").hide();
|
|
146
|
-
$("#wildcard-alert-row").hide();
|
|
147
|
-
$("#node-search-return").addClass('disabled');
|
|
148
|
-
$.getJSON(`mgethid?mobius=${mobiusSrvc}`, function (response) {
|
|
149
|
-
$("#instance-search-hid").val(response);
|
|
150
|
-
})
|
|
151
|
-
|
|
152
|
-
let globalSubscriptionIndex = 0;
|
|
153
|
-
|
|
154
|
-
let searchObject = {
|
|
155
|
-
hid: '',
|
|
156
|
-
sid: '',
|
|
157
|
-
pid: '',
|
|
158
|
-
ins: '',
|
|
159
|
-
objects: []
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
//Function to search for INSs
|
|
163
|
-
function insSearch (objects, pid) {
|
|
164
|
-
let inss = ['#'];
|
|
165
|
-
for (let i = 0; i < objects.length; i++) {
|
|
166
|
-
if (objects[i].pid === pid) {
|
|
167
|
-
const name = objects[i].resources[1].pv;
|
|
168
|
-
if (name === '') {
|
|
169
|
-
inss.push(objects[i].ins);
|
|
170
|
-
} else {
|
|
171
|
-
inss.push(`${objects[i].ins} - ${name}`);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
$("#instance-search-ins").autocomplete({
|
|
176
|
-
source: inss,
|
|
177
|
-
minLength: 0,
|
|
178
|
-
close: function (event, ui) {
|
|
179
|
-
acceptCheck();
|
|
180
|
-
$("#instance-search-ins").autocomplete('destroy');
|
|
181
|
-
if ($("#instance-search-ins").val().length > 4) {
|
|
182
|
-
$("#instance-search-ins").val($("#instance-search-ins").val().substring(0, 4))
|
|
183
|
-
}
|
|
184
|
-
searchObject.ins = $("#instance-search-ins").val();
|
|
185
|
-
}
|
|
186
|
-
}).autocomplete('search', '');
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
//Function to search for PIDs
|
|
190
|
-
function pidsSearch(objects) {
|
|
191
|
-
searchObject.objects = objects;
|
|
192
|
-
let pids = ['#', '+'];
|
|
193
|
-
for (let i = 0; i < objects.length; i++) {
|
|
194
|
-
pids.push(`${objects[i].pid} - ${objects[i].profileName}`);
|
|
195
|
-
}
|
|
196
|
-
pids = [...new Set(pids)];
|
|
197
|
-
$("#instance-search-pid").autocomplete({
|
|
198
|
-
source: pids,
|
|
199
|
-
minLength: 0,
|
|
200
|
-
close: function (event, ui) {
|
|
201
|
-
acceptCheck();
|
|
202
|
-
$("#instance-search-pid").autocomplete('destroy');
|
|
203
|
-
if ($("#instance-search-pid").val().length > 4) {
|
|
204
|
-
$("#instance-search-pid").val($("#instance-search-pid").val().substring(0, 4))
|
|
205
|
-
}
|
|
206
|
-
searchObject.pid = $("#instance-search-pid").val();
|
|
207
|
-
}
|
|
208
|
-
}).autocomplete('search', '');
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
//Function to search for SIDs, and then fetch child objects based on selection
|
|
212
|
-
function serviceSearch(response) {
|
|
213
|
-
let services = ['#', '+'];
|
|
214
|
-
for (let i = 0; i < response.length; i++) {
|
|
215
|
-
if (response[i].sid !== '009') {
|
|
216
|
-
services.push(`${response[i].sid} - ${response[i].name}`);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
$("#instance-search-sid").autocomplete({
|
|
220
|
-
source: services,
|
|
221
|
-
minLength: 0,
|
|
222
|
-
close: function (event, ui) {
|
|
223
|
-
acceptCheck();
|
|
224
|
-
$("#instance-search-sid").autocomplete('destroy');
|
|
225
|
-
if ($("#instance-search-sid").val().length > 3) {
|
|
226
|
-
$("#instance-search-sid").val($("#instance-search-sid").val().substring(0, 3))
|
|
227
|
-
}
|
|
228
|
-
searchObject.sid = $("#instance-search-sid").val();
|
|
229
|
-
if (searchObject.sid === '+') {
|
|
230
|
-
for (let i = 2; i < services.length; i++) {
|
|
231
|
-
$.getJSON(`mgetobjects?mobius=${mobiusSrvc}&hid=${searchObject.hid}&sid=${services[i].substring(0, 3)}`, (objects) => {
|
|
232
|
-
searchObject.objects = searchObject.objects.concat(objects);
|
|
233
|
-
})
|
|
234
|
-
}
|
|
235
|
-
} else {
|
|
236
|
-
$.getJSON(`mgetobjects?mobius=${mobiusSrvc}&hid=${searchObject.hid}&sid=${searchObject.sid}`, (objects) => {
|
|
237
|
-
searchObject.objects = objects;
|
|
238
|
-
})
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}).autocomplete('search', '');
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
//Start a new search
|
|
245
|
-
function startSearch() {
|
|
246
|
-
$("#wildcard-alert-row").hide();
|
|
247
|
-
$("#instance-search-sid").val('');
|
|
248
|
-
$("#instance-search-pid").val('');
|
|
249
|
-
$("#instance-search-ins").val('');
|
|
250
|
-
searchObject.hid = $("#instance-search-hid").val()
|
|
251
|
-
searchObject.sid = '';
|
|
252
|
-
searchObject.pid = '';
|
|
253
|
-
searchObject.ins = '';
|
|
254
|
-
searchObject.objects = [];
|
|
255
|
-
if (/((^([0-9A-F]){6}$)|^$)/.test(searchObject.hid)) {
|
|
256
|
-
$.getJSON(`mgetservices?mobius=${mobiusSrvc}&hid=${searchObject.hid}`, serviceSearch)
|
|
257
|
-
.fail((err) => {
|
|
258
|
-
console.log('Some kind of html failure message on service discovery');
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
//Finish a search
|
|
264
|
-
function finishSearch() {
|
|
265
|
-
$("#wildcard-alert-row").hide();
|
|
266
|
-
let uri = `${searchObject.hid}/${searchObject.sid}/${searchObject.pid}/${searchObject.ins}`
|
|
267
|
-
if (uri.includes('#')) {
|
|
268
|
-
uri = uri.substring(0,uri.indexOf('#') + 1)
|
|
269
|
-
}
|
|
270
|
-
node.subscriptions[globalSubscriptionIndex].uri = uri;
|
|
271
|
-
updateList()
|
|
272
|
-
$("#node-search-accept").css('color', '#CCCCCC');
|
|
273
|
-
readyToAccept = false;
|
|
274
|
-
$("#node-search-return").addClass('disabled');
|
|
275
|
-
$("#node-search-accept").addClass('disabled');
|
|
276
|
-
$("#instance-search-row").hide();
|
|
277
|
-
$('#node-input-subs-container-row').show();
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
//Function to update if accept button is grade out and functions based on conditions of fields
|
|
281
|
-
function acceptCheck() {
|
|
282
|
-
if (($("#instance-search-hid").val() !== '' && $("#instance-search-sid").val() !== '' && $("#instance-search-pid").val() !== '' && $("#instance-search-ins").val() !== '') ||
|
|
283
|
-
$("#instance-search-sid").val() === '#' || $("#instance-search-pid").val() === '#' || $("#instance-search-ins").val() === '#') {
|
|
284
|
-
$("#node-search-accept").css('color', '#555555');
|
|
285
|
-
readyToAccept = true;
|
|
286
|
-
} else {
|
|
287
|
-
$("#node-search-accept").css('color', '#CCCCCC');
|
|
288
|
-
readyToAccept = false;
|
|
289
|
-
}
|
|
290
|
-
if ($("#instance-search-sid").val() !== '+' && $("#instance-search-pid").val() !== '+') {
|
|
291
|
-
$("#wildcard-alert-row").hide();
|
|
292
|
-
} else {
|
|
293
|
-
$("#wildcard-alert-row").show();
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
$("#instance-search-sid").click(function () { //SID field clicked
|
|
298
|
-
$("#instance-search-pid").val('')
|
|
299
|
-
$("#instance-search-ins").val('')
|
|
300
|
-
searchObject.pid = '';
|
|
301
|
-
searchObject.ins = '';
|
|
302
|
-
searchObject.objects = [];
|
|
303
|
-
startSearch();
|
|
304
|
-
})
|
|
305
|
-
$("#instance-search-pid").click(function () { //PID field clicked
|
|
306
|
-
$("#instance-search-ins").val('')
|
|
307
|
-
searchObject.ins = '';
|
|
308
|
-
if (searchObject.sid !== '') {
|
|
309
|
-
pidsSearch(searchObject.objects);
|
|
310
|
-
}
|
|
311
|
-
})
|
|
312
|
-
$("#instance-search-ins").click(function () { //INS field clicked
|
|
313
|
-
if (searchObject.pid !== '' && searchObject.pid !== '+' && searchObject.sid !== '+') {
|
|
314
|
-
insSearch(searchObject.objects, searchObject.pid);
|
|
315
|
-
}
|
|
316
|
-
})
|
|
317
|
-
$("#node-search-return").click(function () { //Return/Back button clicked
|
|
318
|
-
$("#node-search-return").addClass('disabled');
|
|
319
|
-
$("#node-search-accept").addClass('disabled');
|
|
320
|
-
$("#instance-search-row").hide();
|
|
321
|
-
$('#node-input-subs-container-row').show();
|
|
322
|
-
});
|
|
323
|
-
$("#node-search-accept").click(function () { //Accept button clicked
|
|
324
|
-
if (readyToAccept) {
|
|
325
|
-
finishSearch();
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
|
|
329
|
-
// Respond to search field changes
|
|
330
|
-
$("#instance-search-hid").change(function () {
|
|
331
|
-
acceptCheck();
|
|
332
|
-
$("#instance-search-sid").val('');
|
|
333
|
-
$("#instance-search-pid").val('');
|
|
334
|
-
$("#instance-search-ins").val('');
|
|
335
|
-
});
|
|
336
|
-
$("#instance-search-sid").change(function () {
|
|
337
|
-
searchObject.sid = $("#instance-search-sid").val()
|
|
338
|
-
acceptCheck();
|
|
339
|
-
});
|
|
340
|
-
$("#instance-search-pid").change(function () {
|
|
341
|
-
searchObject.pid = $("#instance-search-pid").val()
|
|
342
|
-
acceptCheck();
|
|
343
|
-
});
|
|
344
|
-
$("#instance-search-ins").change(function () {
|
|
345
|
-
searchObject.ins = $("#instance-search-ins").val()
|
|
346
|
-
acceptCheck();
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
// *** END MOBSEARCH *** //
|
|
350
|
-
|
|
351
129
|
/** Create the subs container and populate it */
|
|
352
130
|
$('#node-input-subs-container').css('min-height', '200px').css('min-width', '345px').editableList ({
|
|
353
131
|
addButton: "add uri",
|
|
@@ -385,17 +163,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
385
163
|
node.subscriptions[i] = {uri: '', type: 'include'}
|
|
386
164
|
}
|
|
387
165
|
|
|
388
|
-
searchField
|
|
389
|
-
globalSubscriptionIndex = i;
|
|
390
|
-
$('#node-input-subs-container-row').hide();
|
|
391
|
-
$("#instance-search-sid").val('');
|
|
392
|
-
$("#instance-search-pid").val('');
|
|
393
|
-
$("#instance-search-ins").val('');
|
|
394
|
-
$("#node-search-return").removeClass('disabled');
|
|
395
|
-
$("#node-search-accept").removeClass('disabled');
|
|
396
|
-
$("#instance-search-row").show();
|
|
397
|
-
|
|
398
|
-
});
|
|
166
|
+
addMobsearchListButton(searchField, i, mobsearchOpts)
|
|
399
167
|
// *** END MOBSEARCH *** //
|
|
400
168
|
}
|
|
401
169
|
});
|
|
@@ -409,18 +177,14 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
409
177
|
|
|
410
178
|
// *** MOBSEARCH *** //
|
|
411
179
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
let subscription = node.subscriptions[i];
|
|
421
|
-
$("#node-input-subs-container").editableList('addItem', subscription);
|
|
422
|
-
}
|
|
423
|
-
}
|
|
180
|
+
mobsearchOpts = {
|
|
181
|
+
htmlElementId: 'mobsearch',
|
|
182
|
+
list: node.subscriptions,
|
|
183
|
+
containerRowName: 'node-input-subs-container-row',
|
|
184
|
+
containerName: 'node-input-subs-container',
|
|
185
|
+
containerSecondFieldName: 'node-input-sub-type',
|
|
186
|
+
};
|
|
187
|
+
initMobsearch.toIns_listed(mobiusSrvc, mobsearchOpts);
|
|
424
188
|
|
|
425
189
|
// *** END MOBSEARCH *** //
|
|
426
190
|
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
'use strict';
|
|
29
29
|
|
|
30
30
|
module.exports = function (RED) {
|
|
31
|
-
function MobiusFlowNode
|
|
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
|
|
61
|
-
|
|
62
|
-
|
|
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:
|
|
66
|
-
payload:
|
|
84
|
+
topic: msg.topic,
|
|
85
|
+
payload: uris,
|
|
67
86
|
});
|
|
68
87
|
} else {
|
|
69
88
|
node.send({
|
|
70
|
-
topic:
|
|
71
|
-
payload:
|
|
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
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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,7 +134,7 @@ 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 = {
|
|
@@ -139,19 +142,21 @@ module.exports = function (RED) {
|
|
|
139
142
|
pids: pids,
|
|
140
143
|
rid: '00',
|
|
141
144
|
func: 'return true;',
|
|
142
|
-
limit: 512
|
|
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][
|
|
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 (
|
|
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(
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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];
|
|
@@ -260,4 +270,12 @@ module.exports = function (RED) {
|
|
|
260
270
|
}
|
|
261
271
|
|
|
262
272
|
RED.nodes.registerType('mobius discover object list', MobiusFlowNode);
|
|
273
|
+
|
|
274
|
+
RED.httpAdmin.get('/common/*', function (req, res) {
|
|
275
|
+
var options = {
|
|
276
|
+
root: __dirname + '/common/',
|
|
277
|
+
dotfiles: 'deny',
|
|
278
|
+
};
|
|
279
|
+
res.sendFile(req.params[0], options);
|
|
280
|
+
});
|
|
263
281
|
};
|