node-red-contrib-mobius-flow-base 2.5.86-beta.77 → 2.5.86-beta.80
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/mobius-clear-resource.html +3 -23
- package/dist/nodes/mobius-clear-resource.js +8 -21
- package/dist/nodes/mobius-connection.js +45 -91
- package/dist/nodes/mobius-discover-object-list.html +3 -36
- package/dist/nodes/mobius-discover-object-list.js +53 -71
- package/dist/nodes/mobius-flow-inject.html +2 -34
- package/dist/nodes/mobius-flow-inject.js +9 -23
- package/dist/nodes/mobius-get-multi-object.html +7 -40
- package/dist/nodes/mobius-get-multi-object.js +9 -17
- package/dist/nodes/mobius-get-multi-resource.html +7 -38
- package/dist/nodes/mobius-get-multi-resource.js +11 -19
- package/dist/nodes/mobius-get-object.html +5 -26
- package/dist/nodes/mobius-get-object.js +10 -21
- package/dist/nodes/mobius-get-resource.html +3 -25
- package/dist/nodes/mobius-get-resource.js +8 -21
- package/dist/nodes/mobius-object-cov.html +5 -26
- package/dist/nodes/mobius-object-cov.js +3 -10
- package/dist/nodes/mobius-resource-cov.html +4 -25
- package/dist/nodes/mobius-resource-cov.js +5 -13
- package/dist/nodes/mobius-set-multi-resource.html +4 -25
- package/dist/nodes/mobius-set-multi-resource.js +12 -18
- package/dist/nodes/mobius-set-resource.html +3 -24
- package/dist/nodes/mobius-set-resource.js +13 -31
- package/dist/nodes/node-red-ui-discover-devices.js +6 -136
- package/package.json +1 -1
|
@@ -29,17 +29,10 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
29
29
|
<label for="node-input-connection"><i class="fa fa-globe"></i> MOBiUS</label>
|
|
30
30
|
<input type="text" id="node-input-connection">
|
|
31
31
|
</div>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
<div id="instance-row">
|
|
36
|
-
<div class="form-row" id="input-row">
|
|
37
|
-
<label for="node-input-resource"><i class="fa fa-tasks"></i> URI</label>
|
|
38
|
-
<input type="text" id="node-input-resource" style="width:61%;" placeholder="HID/SID/PID/INS/RID">
|
|
39
|
-
</div>
|
|
32
|
+
<div class="form-row">
|
|
33
|
+
<label for="node-input-resource"><i class="fa fa-tasks"></i> URI</label>
|
|
34
|
+
<input type="text" id="node-input-resource" placeholder="Resource URI (hid/sid/pid/ins/rid)">
|
|
40
35
|
</div>
|
|
41
|
-
<div id="mobsearch"></div>
|
|
42
|
-
|
|
43
36
|
<div class="form-row">
|
|
44
37
|
<label for="node-input-priority"><i class="fa fa-exclamation-triangle"></i> Priority</label>
|
|
45
38
|
<input type="text" id="node-input-priority" placeholder="Priotity to clear">
|
|
@@ -56,8 +49,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
56
49
|
</div>
|
|
57
50
|
</script>
|
|
58
51
|
|
|
59
|
-
<script src="common/mobsearch.js"></script>
|
|
60
|
-
|
|
61
52
|
<script type="text/javascript">
|
|
62
53
|
RED.nodes.registerType('mobius clear resource',{
|
|
63
54
|
category: 'mobius',
|
|
@@ -99,17 +90,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
99
90
|
labelStyle: function() {
|
|
100
91
|
return this.name ? "node_label_italic":"";
|
|
101
92
|
},
|
|
102
|
-
oneditprepare: function () {
|
|
103
|
-
var node = this;
|
|
104
|
-
let mobiusSrvc = $("#node-input-connection").val();
|
|
105
|
-
|
|
106
|
-
opts = {
|
|
107
|
-
htmlElementId: 'mobsearch',
|
|
108
|
-
uriFieldName: 'node-input-resource',
|
|
109
|
-
inputRowId: 'input-row',
|
|
110
|
-
};
|
|
111
|
-
initMobsearch.toRid(mobiusSrvc, opts);
|
|
112
|
-
},
|
|
113
93
|
oneditsave: function() {
|
|
114
94
|
if($("#node-input-detailedOutput").prop('checked')) {
|
|
115
95
|
this.outputs = 4;
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
'use strict';
|
|
29
29
|
|
|
30
30
|
module.exports = function (RED) {
|
|
31
|
-
function MobiusClearResourceNode(n) {
|
|
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,34 +65,29 @@ 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([
|
|
73
|
-
null,
|
|
74
|
-
null,
|
|
75
|
-
null,
|
|
76
|
-
{ topic: uri, payload: { error: true, response: err } },
|
|
77
|
-
]);
|
|
72
|
+
node.send([null, null, null, {topic: uri, payload: { error: true, response: err }}]);
|
|
78
73
|
}
|
|
79
74
|
} else {
|
|
80
75
|
node.status({
|
|
81
76
|
fill: 'green',
|
|
82
77
|
shape: 'dot',
|
|
83
|
-
text: JSON.stringify(response.value.pv)
|
|
78
|
+
text: JSON.stringify(response.value.pv)
|
|
84
79
|
});
|
|
85
80
|
if (node.detailedOutput === true) {
|
|
86
81
|
node.send([
|
|
87
82
|
{ topic: uri, payload: response.value.pv },
|
|
88
83
|
{ topic: uri, payload: { pv: response.value.pv, name: response.value.name } },
|
|
89
84
|
{ topic: uri, payload: response.value },
|
|
90
|
-
{ topic: uri, payload: { error: false, response: response } }
|
|
85
|
+
{ topic: uri, payload: { error: false, response: response } }
|
|
91
86
|
]);
|
|
92
87
|
} else {
|
|
93
88
|
node.send([
|
|
94
89
|
{ topic: uri, payload: response.value.pv },
|
|
95
|
-
{ topic: uri, payload: { pv: response.value.pv, name: response.value.name } }
|
|
90
|
+
{ topic: uri, payload: { pv: response.value.pv, name: response.value.name } }
|
|
96
91
|
]);
|
|
97
92
|
}
|
|
98
93
|
}
|
|
@@ -111,12 +106,4 @@ module.exports = function (RED) {
|
|
|
111
106
|
}
|
|
112
107
|
|
|
113
108
|
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
|
-
});
|
|
122
109
|
};
|
|
@@ -193,6 +193,42 @@ module.exports = function (RED) {
|
|
|
193
193
|
});
|
|
194
194
|
};
|
|
195
195
|
|
|
196
|
+
/**
|
|
197
|
+
* Update a given node's node status based on last active time
|
|
198
|
+
* @param {Object} mobiusNode - The node whos status is to be updated
|
|
199
|
+
*/
|
|
200
|
+
node.updateNodeStatus = function (mobiusNode) {
|
|
201
|
+
node.users[mobiusNode.id] = mobiusNode;
|
|
202
|
+
const timeSinceLastActive = Date.now() - node.users[mobiusNode.id].lastActiveTime;
|
|
203
|
+
let statusText = '';
|
|
204
|
+
let statusColour = 'green';
|
|
205
|
+
if (timeSinceLastActive < 15 * 60000) {
|
|
206
|
+
statusText = 'Active less than 15 minutes ago';
|
|
207
|
+
}
|
|
208
|
+
if (timeSinceLastActive >= 15 * 60000 && timeSinceLastActive < 3 * 60 * 60000) {
|
|
209
|
+
statusText = 'Active less than 3 hours ago';
|
|
210
|
+
}
|
|
211
|
+
if (timeSinceLastActive >= 3 * 60 * 60000 && timeSinceLastActive < 12 * 60 * 60000) {
|
|
212
|
+
statusText = 'Active less than 12 hours ago';
|
|
213
|
+
}
|
|
214
|
+
if (timeSinceLastActive >= 12 * 60 * 60000 && timeSinceLastActive < 24 * 60 * 60000) {
|
|
215
|
+
statusText = 'Active less than 24 hours ago';
|
|
216
|
+
}
|
|
217
|
+
if (timeSinceLastActive > 24 * 60 * 60000 && node.users[mobiusNode.id].lastActiveTime > 0) {
|
|
218
|
+
statusColour = 'grey';
|
|
219
|
+
statusText = 'Active more than 24 hours ago';
|
|
220
|
+
}
|
|
221
|
+
if (node.users[mobiusNode.id].lastActiveTime === 0) {
|
|
222
|
+
statusColour = 'grey';
|
|
223
|
+
statusText = 'Never Active';
|
|
224
|
+
}
|
|
225
|
+
node.users[mobiusNode.id].status({
|
|
226
|
+
fill: statusColour,
|
|
227
|
+
shape: 'dot',
|
|
228
|
+
text: statusText,
|
|
229
|
+
});
|
|
230
|
+
};
|
|
231
|
+
|
|
196
232
|
/**
|
|
197
233
|
* Register a new Mobius node with this config node
|
|
198
234
|
* @param {Object} mobiusNode - The new node to register
|
|
@@ -206,6 +242,14 @@ module.exports = function (RED) {
|
|
|
206
242
|
text: 'Connected',
|
|
207
243
|
});
|
|
208
244
|
}
|
|
245
|
+
node.users[mobiusNode.id].lastActiveTime = 0;
|
|
246
|
+
node.users[mobiusNode.id].on('send', () => {
|
|
247
|
+
node.users[mobiusNode.id].lastActiveTime = Date.now();
|
|
248
|
+
node.updateNodeStatus(mobiusNode);
|
|
249
|
+
});
|
|
250
|
+
node.users[mobiusNode.id].statusCheckLoop = setInterval(() => {
|
|
251
|
+
node.updateNodeStatus(mobiusNode);
|
|
252
|
+
}, 60000);
|
|
209
253
|
};
|
|
210
254
|
|
|
211
255
|
/**
|
|
@@ -214,6 +258,7 @@ module.exports = function (RED) {
|
|
|
214
258
|
* @param {Function} done - A callback to be run by the node after it has been deregistered
|
|
215
259
|
*/
|
|
216
260
|
node.deregister = function (mobiusNode, done) {
|
|
261
|
+
clearInterval(node.users[mobiusNode.id].statusCheckLoop);
|
|
217
262
|
delete node.users[mobiusNode.id];
|
|
218
263
|
if (node.service) {
|
|
219
264
|
try {
|
|
@@ -520,30 +565,6 @@ module.exports = function (RED) {
|
|
|
520
565
|
node.updateObjectInServiceConfig = function (hid, sid, pid, ins, config, callback) {
|
|
521
566
|
node.service.srvcAPI.updateObjectInServiceConfig(hid, sid, pid, ins, config, callback);
|
|
522
567
|
};
|
|
523
|
-
|
|
524
|
-
node.getNodeConfig = function (hid) {
|
|
525
|
-
return new Promise((resolve, reject) => {
|
|
526
|
-
node.service.srvcAPI.getNodeConfig(hid, (err, response) => {
|
|
527
|
-
if (!err) {
|
|
528
|
-
resolve(response);
|
|
529
|
-
} else {
|
|
530
|
-
reject(err);
|
|
531
|
-
}
|
|
532
|
-
});
|
|
533
|
-
});
|
|
534
|
-
};
|
|
535
|
-
|
|
536
|
-
node.getServiceConfigProm = function (hid, sid) {
|
|
537
|
-
return new Promise((resolve, reject) => {
|
|
538
|
-
node.service.srvcAPI.getServiceConfig(hid, sid, (err, response) => {
|
|
539
|
-
if (!err) {
|
|
540
|
-
resolve(response);
|
|
541
|
-
} else {
|
|
542
|
-
reject(err);
|
|
543
|
-
}
|
|
544
|
-
});
|
|
545
|
-
});
|
|
546
|
-
};
|
|
547
568
|
}
|
|
548
569
|
|
|
549
570
|
RED.nodes.registerType('mobius connection', MobiusConnectionNode);
|
|
@@ -604,71 +625,4 @@ module.exports = function (RED) {
|
|
|
604
625
|
}
|
|
605
626
|
}
|
|
606
627
|
);
|
|
607
|
-
|
|
608
|
-
// Register the endpoint for node-red mobius discovery in node-red node config pages
|
|
609
|
-
RED.httpAdmin.get('/mdiscover', RED.auth.needsPermission('serial.read'), function (req, res) {
|
|
610
|
-
let conn = RED.nodes.getNode(req.query.mobius);
|
|
611
|
-
let uri = req.query.uri;
|
|
612
|
-
if (conn === null || !conn.service.connected) {
|
|
613
|
-
RED.log.error('Discover services failed - could not to connect to MOBiUS hub.');
|
|
614
|
-
throw new Error('Discover services failed - could not to connect to MOBiUS hub.');
|
|
615
|
-
} else {
|
|
616
|
-
uiDeviceDiscovery
|
|
617
|
-
.discover(conn, uri)
|
|
618
|
-
.then((response) => {
|
|
619
|
-
res.json(response);
|
|
620
|
-
})
|
|
621
|
-
.catch((err) => {
|
|
622
|
-
throw err;
|
|
623
|
-
});
|
|
624
|
-
}
|
|
625
|
-
});
|
|
626
|
-
|
|
627
|
-
// Register the endpoint for node-red mobius discovery in node-red node config pages
|
|
628
|
-
RED.httpAdmin.get('/mgetservices', RED.auth.needsPermission('serial.read'), function (req, res) {
|
|
629
|
-
let conn = RED.nodes.getNode(req.query.mobius);
|
|
630
|
-
let hid = req.query.hid;
|
|
631
|
-
if (conn === null || !conn.service.connected) {
|
|
632
|
-
RED.log.error('Get services failed - could not to connect to MOBiUS hub.');
|
|
633
|
-
throw new Error('Get services failed - could not to connect to MOBiUS hub.');
|
|
634
|
-
} else {
|
|
635
|
-
uiDeviceDiscovery
|
|
636
|
-
.getServiceList(conn, hid)
|
|
637
|
-
.then((response) => {
|
|
638
|
-
res.json(response);
|
|
639
|
-
})
|
|
640
|
-
.catch((err) => {
|
|
641
|
-
RED.log.warn(`Get services failed - ${err}`);
|
|
642
|
-
});
|
|
643
|
-
}
|
|
644
|
-
});
|
|
645
|
-
|
|
646
|
-
RED.httpAdmin.get('/mgetobjects', RED.auth.needsPermission('serial.read'), function (req, res) {
|
|
647
|
-
let conn = RED.nodes.getNode(req.query.mobius);
|
|
648
|
-
let hid = req.query.hid;
|
|
649
|
-
let sid = req.query.sid;
|
|
650
|
-
if (conn === null || !conn.service.connected) {
|
|
651
|
-
RED.log.error('Get objects failed - could not to connect to MOBiUS hub.');
|
|
652
|
-
throw new Error('Get objects failed - could not to connect to MOBiUS hub.');
|
|
653
|
-
} else {
|
|
654
|
-
uiDeviceDiscovery
|
|
655
|
-
.getObjectList(conn, hid, sid)
|
|
656
|
-
.then((response) => {
|
|
657
|
-
res.json(response);
|
|
658
|
-
})
|
|
659
|
-
.catch((err) => {
|
|
660
|
-
RED.log.warn(`Get objects failed - ${err}`);
|
|
661
|
-
});
|
|
662
|
-
}
|
|
663
|
-
});
|
|
664
|
-
|
|
665
|
-
RED.httpAdmin.get('/mgethid', RED.auth.needsPermission('serial.read'), function (req, res) {
|
|
666
|
-
let conn = RED.nodes.getNode(req.query.mobius);
|
|
667
|
-
if (conn === null || !conn.service.connected) {
|
|
668
|
-
RED.log.error('Get hid failed - could not to connect to MOBiUS hub.');
|
|
669
|
-
throw new Error('Get hid failed - could not to connect to MOBiUS hub.');
|
|
670
|
-
} else {
|
|
671
|
-
res.json(conn.service.srvcAPI.status.hubId);
|
|
672
|
-
}
|
|
673
|
-
});
|
|
674
628
|
};
|
|
@@ -53,13 +53,10 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
53
53
|
<option value="array">Array of Items</option>
|
|
54
54
|
</select>
|
|
55
55
|
</div>
|
|
56
|
-
<div
|
|
56
|
+
<div class="form-row node-input-subs-container-row">
|
|
57
57
|
<label for="node-input-subs-container" style="width:105px;float:left;"><i class="fa fa-bars"></i> Discover</label>
|
|
58
58
|
<ol id="node-input-subs-container"></ol>
|
|
59
59
|
</div>
|
|
60
|
-
|
|
61
|
-
<div id="mobsearch"></div>
|
|
62
|
-
|
|
63
60
|
<div class="form-row">
|
|
64
61
|
<label for="node-input-useRIDValueFiltering" style="width:178px;float:left;"><i class="fa fa-filter"></i> Filter by Resource Value</label>
|
|
65
62
|
<input type="checkbox" id="node-input-useRIDValueFiltering" style="display: inline-block; width: auto; vertical-align: top;">
|
|
@@ -80,8 +77,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
80
77
|
</div>
|
|
81
78
|
</script>
|
|
82
79
|
|
|
83
|
-
<script src="common/mobsearch.js"></script>
|
|
84
|
-
|
|
85
80
|
<script type="text/javascript">
|
|
86
81
|
RED.nodes.registerType('mobius discover object list', {
|
|
87
82
|
category: 'mobius',
|
|
@@ -124,7 +119,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
124
119
|
},
|
|
125
120
|
oneditprepare: function () {
|
|
126
121
|
var node = this;
|
|
127
|
-
let mobiusSrvc = $("#node-input-connection").val();
|
|
128
122
|
|
|
129
123
|
/** Create the subs container and populate it */
|
|
130
124
|
$('#node-input-subs-container').css('min-height', '200px').css('min-width', '345px').editableList ({
|
|
@@ -143,12 +137,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
143
137
|
}
|
|
144
138
|
|
|
145
139
|
var row = $('<div>URI</div>').appendTo(container);
|
|
146
|
-
var uriField = $('<input/>',{class: "node-input-sub-uri", type: "text", style: "width:
|
|
147
|
-
|
|
148
|
-
// *** MOBSEARCH *** //
|
|
149
|
-
var searchField = $('<a class="searchbutton" style="vertical-align: middle"><i id="node-lookup-instance-icon" class="fa fa-search"></i></a>').appendTo(row);
|
|
150
|
-
// *** END MOBSEARCH *** //
|
|
151
|
-
|
|
140
|
+
var uriField = $('<input/>',{class: "node-input-sub-uri", type: "text", style: "width: 170px; margin-left: 5px; text-align: left;"}).appendTo(row);
|
|
152
141
|
var typeField = $('<select/>',{class: "node-input-sub-type", style: "width:auto; margin-left: 5px; text-align: center;"}).appendTo(row);
|
|
153
142
|
typeField.append($("<option></option>").val('include').text('Include'));
|
|
154
143
|
typeField.append($("<option></option>").val('exclude').text('Exclude'));
|
|
@@ -156,15 +145,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
156
145
|
// Populate the new stat
|
|
157
146
|
uriField.val(subscription.uri);
|
|
158
147
|
typeField.val(subscription.type);
|
|
159
|
-
|
|
160
|
-
// *** MOBSEARCH *** //
|
|
161
|
-
|
|
162
|
-
if (!node.subscriptions[i]) {
|
|
163
|
-
node.subscriptions[i] = {uri: '', type: 'include'}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
addMobsearchListButton(searchField, i, mobsearchOpts)
|
|
167
|
-
// *** END MOBSEARCH *** //
|
|
168
148
|
}
|
|
169
149
|
});
|
|
170
150
|
|
|
@@ -174,20 +154,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
174
154
|
if (!node.subscriptions) {
|
|
175
155
|
node.subscriptions = [subscription = {uri: '', type: 'include'}];
|
|
176
156
|
}
|
|
177
|
-
|
|
178
|
-
// *** MOBSEARCH *** //
|
|
179
|
-
|
|
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);
|
|
188
|
-
|
|
189
|
-
// *** END MOBSEARCH *** //
|
|
190
|
-
|
|
157
|
+
// Populate list with all saved filters
|
|
191
158
|
for (let i = 0; i < node.subscriptions.length; i++) {
|
|
192
159
|
let subscription = node.subscriptions[i];
|
|
193
160
|
$("#node-input-subs-container").editableList('addItem', subscription);
|
|
@@ -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,57 +54,54 @@ 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
|
-
|
|
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 {
|
|
60
|
+
node.discoverAllObjectURIs(msg).then((objectList) => {
|
|
61
|
+
if (node.sendType === 'individual') {
|
|
62
|
+
objectList.forEach((mobiusObject) => {
|
|
78
63
|
if (node.outputType === 'uris') {
|
|
79
|
-
const uris = [];
|
|
80
|
-
objectList.forEach((mobiusObject) => {
|
|
81
|
-
uris.push(mobiusObject.uri);
|
|
82
|
-
});
|
|
83
64
|
node.send({
|
|
84
|
-
topic:
|
|
85
|
-
payload:
|
|
65
|
+
topic: mobiusObject.uri,
|
|
66
|
+
payload: mobiusObject.uri
|
|
86
67
|
});
|
|
87
68
|
} else {
|
|
88
69
|
node.send({
|
|
89
|
-
topic:
|
|
90
|
-
payload:
|
|
70
|
+
topic: mobiusObject.uri,
|
|
71
|
+
payload: mobiusObject
|
|
91
72
|
});
|
|
92
|
-
}
|
|
93
|
-
}
|
|
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',
|
|
73
|
+
}
|
|
106
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
|
+
});
|
|
90
|
+
}
|
|
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'
|
|
107
103
|
});
|
|
104
|
+
});
|
|
108
105
|
if (done) {
|
|
109
106
|
done();
|
|
110
107
|
}
|
|
@@ -134,7 +131,7 @@ module.exports = function (RED) {
|
|
|
134
131
|
pids: pids,
|
|
135
132
|
rid: node.rid,
|
|
136
133
|
func: node.func,
|
|
137
|
-
limit: node.limit
|
|
134
|
+
limit: node.limit
|
|
138
135
|
};
|
|
139
136
|
} else {
|
|
140
137
|
discoverParams = {
|
|
@@ -142,21 +139,19 @@ module.exports = function (RED) {
|
|
|
142
139
|
pids: pids,
|
|
143
140
|
rid: '00',
|
|
144
141
|
func: 'return true;',
|
|
145
|
-
limit: 512
|
|
142
|
+
limit: 512
|
|
146
143
|
};
|
|
147
144
|
}
|
|
148
145
|
try {
|
|
149
146
|
let objects = await discover(node.serviceConn, discoverParams);
|
|
150
147
|
for (let lp = 0; lp < objects.value.length; lp++) {
|
|
151
|
-
objects.value[lp][
|
|
152
|
-
'uri'
|
|
153
|
-
] = `${serviceURI}/${objects.value[lp].pid}/${objects.value[lp].ins}`;
|
|
148
|
+
objects.value[lp]['uri'] = `${serviceURI}/${objects.value[lp].pid}/${objects.value[lp].ins}`;
|
|
154
149
|
objectList.push(objects.value[lp]);
|
|
155
150
|
}
|
|
156
151
|
} catch (err) {
|
|
157
152
|
node.warn(`Discover object failed for service (${serviceURI}) - ${err.message}`);
|
|
158
153
|
}
|
|
159
|
-
}
|
|
154
|
+
}
|
|
160
155
|
|
|
161
156
|
if (objectList.length === 0) {
|
|
162
157
|
throw new Error('No discovery data found');
|
|
@@ -181,28 +176,23 @@ module.exports = function (RED) {
|
|
|
181
176
|
let profiles = await discover(serviceConn, `${hid}/${sid}`);
|
|
182
177
|
let pids = [];
|
|
183
178
|
for (const pid of profiles.value) {
|
|
184
|
-
if (
|
|
185
|
-
isIncluded(`${hid}/${sid}/${pid}/#`, subscriptions) &&
|
|
186
|
-
!isExcluded(`${hid}/${sid}/${pid}/#`, subscriptions)
|
|
187
|
-
) {
|
|
179
|
+
if (isIncluded(`${hid}/${sid}/${pid}/#`, subscriptions) && !isExcluded(`${hid}/${sid}/${pid}/#`, subscriptions)) {
|
|
188
180
|
pids.push(pid);
|
|
189
|
-
}
|
|
181
|
+
}
|
|
190
182
|
}
|
|
191
183
|
if (pids.length > 0) {
|
|
192
184
|
discoveredProfiles.set(`${hid}/${sid}`, pids);
|
|
193
185
|
}
|
|
194
186
|
}
|
|
195
187
|
} else {
|
|
196
|
-
RED.log.warn(
|
|
197
|
-
`Failed to discover objects for service ${service.id.split('/')[1]} as it is offline.`
|
|
198
|
-
);
|
|
188
|
+
RED.log.warn(`Failed to discover objects for service ${service.id.split('/')[1]} as it is offline.`);
|
|
199
189
|
}
|
|
200
190
|
}
|
|
201
191
|
resolve(discoveredProfiles);
|
|
202
192
|
});
|
|
203
193
|
}
|
|
204
194
|
|
|
205
|
-
async function discover(serviceConn, params) {
|
|
195
|
+
async function discover (serviceConn, params) {
|
|
206
196
|
return new Promise((resolve, reject) => {
|
|
207
197
|
serviceConn.discover(params, (err, response) => {
|
|
208
198
|
if (err) {
|
|
@@ -212,7 +202,7 @@ module.exports = function (RED) {
|
|
|
212
202
|
}
|
|
213
203
|
});
|
|
214
204
|
});
|
|
215
|
-
}
|
|
205
|
+
};
|
|
216
206
|
|
|
217
207
|
function isIncluded(uri, subscriptions) {
|
|
218
208
|
let include = false;
|
|
@@ -226,7 +216,7 @@ module.exports = function (RED) {
|
|
|
226
216
|
return include;
|
|
227
217
|
}
|
|
228
218
|
|
|
229
|
-
function isExcluded(uri, subscriptions) {
|
|
219
|
+
function isExcluded (uri, subscriptions) {
|
|
230
220
|
let exclude = false;
|
|
231
221
|
for (const subscription of subscriptions) {
|
|
232
222
|
if (subscription.type === 'exclude' && validateSubscription(subscription.uri)) {
|
|
@@ -238,7 +228,7 @@ module.exports = function (RED) {
|
|
|
238
228
|
return exclude;
|
|
239
229
|
}
|
|
240
230
|
|
|
241
|
-
function validateSubscription(uri) {
|
|
231
|
+
function validateSubscription (uri) {
|
|
242
232
|
let parts = uri.split('/');
|
|
243
233
|
for (let lp = 0; lp < parts.length; lp++) {
|
|
244
234
|
if (parts[lp] === null || parts[lp] === '') {
|
|
@@ -254,11 +244,11 @@ module.exports = function (RED) {
|
|
|
254
244
|
return false;
|
|
255
245
|
}
|
|
256
246
|
|
|
257
|
-
function matchTopic(filter, topic) {
|
|
247
|
+
function matchTopic (filter, topic) {
|
|
258
248
|
const filterArray = filter.split('/');
|
|
259
249
|
const topicArray = topic.split('/');
|
|
260
250
|
const length = filterArray.length < topicArray.length ? filterArray.length : topicArray.length;
|
|
261
|
-
|
|
251
|
+
|
|
262
252
|
for (let i = 0; i < length; ++i) {
|
|
263
253
|
const left = filterArray[i];
|
|
264
254
|
const right = topicArray[i];
|
|
@@ -270,12 +260,4 @@ module.exports = function (RED) {
|
|
|
270
260
|
}
|
|
271
261
|
|
|
272
262
|
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
|
-
});
|
|
281
263
|
};
|
|
@@ -34,16 +34,12 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
34
34
|
<label for="node-input-connection"><i class="fa fa-globe"></i> MOBiUS</label>
|
|
35
35
|
<input type="text" id="node-input-connection">
|
|
36
36
|
</div>
|
|
37
|
-
<div
|
|
37
|
+
<div class="form-row node-input-subs-container-row">
|
|
38
38
|
<label for="node-input-subs-container"><i class="fa fa-bars"></i> Subscriptions</label>
|
|
39
39
|
<ol id="node-input-subs-container"></ol>
|
|
40
40
|
</div>
|
|
41
|
-
|
|
42
|
-
<div id="mobsearch"></div>
|
|
43
41
|
</script>
|
|
44
42
|
|
|
45
|
-
<script src="common/mobsearch.js"></script>
|
|
46
|
-
|
|
47
43
|
<script type="text/javascript">
|
|
48
44
|
RED.nodes.registerType('mobius flow inject', {
|
|
49
45
|
category: 'mobius',
|
|
@@ -71,7 +67,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
71
67
|
},
|
|
72
68
|
oneditprepare: function () {
|
|
73
69
|
var node = this;
|
|
74
|
-
let mobiusSrvc = $("#node-input-connection").val();
|
|
75
70
|
|
|
76
71
|
/** Create the subs container and populate it */
|
|
77
72
|
$('#node-input-subs-container').css('min-height', '300px').css('min-width', '450px').editableList ({
|
|
@@ -91,11 +86,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
91
86
|
|
|
92
87
|
var row = $('<div>URI</div>').appendTo(container);
|
|
93
88
|
var uriField = $('<input/>',{class: "node-input-sub-uri", type: "text", style: "width: 200px; margin-left: 5px; text-align: left;"}).appendTo(row);
|
|
94
|
-
|
|
95
|
-
// *** MOBSEARCH *** //
|
|
96
|
-
var searchField = $('<a class="searchbutton" style="vertical-align: middle"><i id="node-lookup-instance-icon" class="fa fa-search"></i></a>').appendTo(row);
|
|
97
|
-
// *** END MOBSEARCH *** //
|
|
98
|
-
|
|
99
89
|
var typeField = $('<select/>',{class: "node-input-sub-type", style: "width:auto; margin-left: 5px; text-align: center;"}).appendTo(row);
|
|
100
90
|
typeField.append($("<option></option>").val('include').text('Include'));
|
|
101
91
|
typeField.append($("<option></option>").val('exclude').text('Exclude'));
|
|
@@ -103,15 +93,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
103
93
|
// Populate the new stat
|
|
104
94
|
uriField.val(subscription.uri);
|
|
105
95
|
typeField.val(subscription.type);
|
|
106
|
-
|
|
107
|
-
// *** MOBSEARCH *** //
|
|
108
|
-
|
|
109
|
-
if (!node.subscriptions[i]) {
|
|
110
|
-
node.subscriptions[i] = {uri: '', type: 'include'}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
addMobsearchListButton(searchField, i, mobsearchOpts)
|
|
114
|
-
// *** END MOBSEARCH *** //
|
|
115
96
|
}
|
|
116
97
|
});
|
|
117
98
|
|
|
@@ -119,20 +100,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
119
100
|
if (!node.subscriptions) {
|
|
120
101
|
node.subscriptions = [subscription = {uri: '', type: 'include'}];
|
|
121
102
|
}
|
|
122
|
-
|
|
123
|
-
// *** MOBSEARCH *** //
|
|
124
|
-
|
|
125
|
-
mobsearchOpts = {
|
|
126
|
-
htmlElementId: 'mobsearch',
|
|
127
|
-
list: node.subscriptions,
|
|
128
|
-
containerRowName: 'node-input-subs-container-row',
|
|
129
|
-
containerName: 'node-input-subs-container',
|
|
130
|
-
containerSecondFieldName: 'node-input-sub-type',
|
|
131
|
-
};
|
|
132
|
-
initMobsearch.toIns_listed(mobiusSrvc, mobsearchOpts);
|
|
133
|
-
|
|
134
|
-
// *** END MOBSEARCH *** //
|
|
135
|
-
|
|
103
|
+
// Populate list with all saved filters
|
|
136
104
|
for (let i = 0; i < node.subscriptions.length; i++) {
|
|
137
105
|
let subscription = node.subscriptions[i];
|
|
138
106
|
$("#node-input-subs-container").editableList('addItem', subscription);
|