node-red-contrib-mobius-flow-base 2.5.86-beta.74 → 2.5.86-beta.78
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 +44 -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 +4 -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 +2 -2
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
const _ = require('lodash');
|
|
31
31
|
|
|
32
32
|
module.exports = function (RED) {
|
|
33
|
-
function MobiusFlowNode(n) {
|
|
33
|
+
function MobiusFlowNode (n) {
|
|
34
34
|
RED.nodes.createNode(this, n);
|
|
35
35
|
this.subscriptions = n.subscriptions;
|
|
36
36
|
this.serviceConn = RED.nodes.getNode(n.connection);
|
|
@@ -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
|
for (const subscription of node.subscriptions) {
|
|
@@ -61,7 +61,7 @@ module.exports = function (RED) {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
function validateSubscription(uri) {
|
|
64
|
+
function validateSubscription (uri) {
|
|
65
65
|
let parts = uri.split('/');
|
|
66
66
|
for (let lp = 0; lp < parts.length; lp++) {
|
|
67
67
|
if (parts[lp] === null || parts[lp] === '') {
|
|
@@ -83,24 +83,18 @@ module.exports = function (RED) {
|
|
|
83
83
|
* @param {string} messageTopic - The topic in an actual message
|
|
84
84
|
* @return {boolean} - True if the topics match, else false
|
|
85
85
|
*/
|
|
86
|
-
function matchTopic(topic, messageTopic) {
|
|
86
|
+
function matchTopic (topic, messageTopic) {
|
|
87
87
|
if (topic === '#') {
|
|
88
88
|
return true;
|
|
89
89
|
}
|
|
90
90
|
// eslint-disable-next-line no-useless-escape
|
|
91
|
-
var regex = new RegExp(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
.replace(/([\[\]\?\(\)\\\\$\^\*\.|])/g, '\\$1')
|
|
95
|
-
// eslint-disable-next-line no-useless-escape
|
|
96
|
-
.replace(/\+/g, '[^/]+')
|
|
97
|
-
.replace(/\/#$/, '(/.*)?') +
|
|
98
|
-
'$'
|
|
99
|
-
);
|
|
91
|
+
var regex = new RegExp('^' + topic.replace(/([\[\]\?\(\)\\\\$\^\*\.|])/g, '\\$1')
|
|
92
|
+
// eslint-disable-next-line no-useless-escape
|
|
93
|
+
.replace(/\+/g, '[^/]+').replace(/\/#$/, '(\/.*)?') + '$');
|
|
100
94
|
return regex.test(messageTopic);
|
|
101
95
|
}
|
|
102
96
|
|
|
103
|
-
function handleSubscription(node, response) {
|
|
97
|
+
function handleSubscription (node, response) {
|
|
104
98
|
for (const subscription of node.subscriptions) {
|
|
105
99
|
if (subscription.type === 'exclude') {
|
|
106
100
|
if (matchTopic(subscription.uri, response.uri)) {
|
|
@@ -112,7 +106,7 @@ module.exports = function (RED) {
|
|
|
112
106
|
node.status({
|
|
113
107
|
fill: 'green',
|
|
114
108
|
shape: 'dot',
|
|
115
|
-
text: JSON.stringify(response.uri)
|
|
109
|
+
text: JSON.stringify(response.uri)
|
|
116
110
|
});
|
|
117
111
|
let outObject = response.value;
|
|
118
112
|
try {
|
|
@@ -127,12 +121,4 @@ module.exports = function (RED) {
|
|
|
127
121
|
}
|
|
128
122
|
|
|
129
123
|
RED.nodes.registerType('mobius flow inject', MobiusFlowNode);
|
|
130
|
-
|
|
131
|
-
RED.httpAdmin.get('/common/*', function (req, res) {
|
|
132
|
-
var options = {
|
|
133
|
-
root: __dirname + '/common/',
|
|
134
|
-
dotfiles: 'deny',
|
|
135
|
-
};
|
|
136
|
-
res.sendFile(req.params[0], options);
|
|
137
|
-
});
|
|
138
124
|
};
|
|
@@ -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-mobjects-container-row">
|
|
38
38
|
<label for="node-input-mobjects-container"><i class="fa fa-bars"></i> Objects</label>
|
|
39
39
|
<ol id="node-input-mobjects-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 get multi-object', {
|
|
49
45
|
category: 'mobius',
|
|
@@ -78,8 +74,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
78
74
|
mobject.find(".node-input-mobject-comment").width(newWidth - 270);
|
|
79
75
|
}
|
|
80
76
|
|
|
81
|
-
let mobiusSrvc = $("#node-input-connection").val();
|
|
82
|
-
|
|
83
77
|
/** Create the objects container and populate it */
|
|
84
78
|
$('#node-input-mobjects-container').css('min-height', '300px').css('min-width', '450px').editableList ({
|
|
85
79
|
addButton: "add",
|
|
@@ -97,29 +91,14 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
97
91
|
}
|
|
98
92
|
|
|
99
93
|
var row = $('<div>URI</div>').appendTo(container);
|
|
100
|
-
var uriField = $('<input/>',{class: "node-input-mobject-uri", type: "text", style: "width:
|
|
101
|
-
|
|
102
|
-
// *** MOBSEARCH *** //
|
|
103
|
-
var searchField = $('<a class="searchbutton" style="vertical-align: middle"><i id="node-lookup-instance-icon" class="fa fa-search"></i></a>').appendTo(row);
|
|
104
|
-
// *** END MOBSEARCH *** //
|
|
105
|
-
|
|
94
|
+
var uriField = $('<input/>',{class: "node-input-mobject-uri", type: "text", style: "width: 200px; margin-left: 5px; text-align: left;"}).appendTo(row);
|
|
106
95
|
row.append(' - ');
|
|
107
|
-
|
|
108
|
-
var commentField = $('<input/>',{class: "node-input-mobject-comment", type: "text", style: "width: 120px; margin-left: 5px; text-align: left;"}).appendTo(row);
|
|
96
|
+
var commentField = $('<input/>',{class: "node-input-mobject-comment", type: "text", style: "margin-left: 5px; text-align: left;"}).appendTo(row);
|
|
109
97
|
|
|
110
98
|
// Populate the new stat
|
|
111
99
|
uriField.val(mobject.uri);
|
|
112
100
|
commentField.val(mobject.comment);
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
// *** MOBSEARCH *** //
|
|
116
|
-
|
|
117
|
-
if (!node.mobjects[i]) {
|
|
118
|
-
node.mobjects[i] = {uri: '', comment: ''}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
addMobsearchListButton(searchField, i, mobsearchOpts)
|
|
122
|
-
// *** END MOBSEARCH *** //
|
|
101
|
+
resizeObject(container);
|
|
123
102
|
},
|
|
124
103
|
resizeItem: resizeObject
|
|
125
104
|
});
|
|
@@ -128,31 +107,19 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
128
107
|
if (!node.mobjects) {
|
|
129
108
|
node.mobjects = [mobject = {uri: '', comment: ''}];
|
|
130
109
|
}
|
|
131
|
-
//
|
|
132
|
-
|
|
133
|
-
mobsearchOpts = {
|
|
134
|
-
htmlElementId: 'mobsearch',
|
|
135
|
-
list: node.mobjects,
|
|
136
|
-
containerRowName: 'node-input-mobjects-container-row',
|
|
137
|
-
containerName: 'node-input-mobjects-container',
|
|
138
|
-
containerSecondFieldName: 'node-input-mobject-comment',
|
|
139
|
-
};
|
|
140
|
-
initMobsearch.toIns_listed(mobiusSrvc, mobsearchOpts);
|
|
141
|
-
|
|
142
|
-
// *** END MOBSEARCH *** //
|
|
143
|
-
|
|
110
|
+
// Populate list with all saved filters
|
|
144
111
|
for (let i = 0; i < node.mobjects.length; i++) {
|
|
145
112
|
let mobject = node.mobjects[i];
|
|
146
113
|
$("#node-input-mobjects-container").editableList('addItem', mobject);
|
|
147
114
|
}
|
|
148
115
|
},
|
|
149
116
|
oneditresize(size) {
|
|
150
|
-
var rows = $("#dialog-form>div:not(.node-input-mobjects-container)");
|
|
117
|
+
var rows = $("#dialog-form>div:not(.node-input-mobjects-container-row)");
|
|
151
118
|
var height = size.height;
|
|
152
119
|
for (var i=0; i<rows.size(); i++) {
|
|
153
120
|
height -= $(rows[i]).outerHeight(true);
|
|
154
121
|
}
|
|
155
|
-
var editorRow = $("#dialog-form>div.node-input-mobjects-container");
|
|
122
|
+
var editorRow = $("#dialog-form>div.node-input-mobjects-container-row");
|
|
156
123
|
height -= 4 * ((parseInt(editorRow.css("marginTop"))+parseInt(editorRow.css("marginBottom"))));
|
|
157
124
|
|
|
158
125
|
$("#node-input-mobjects-container").editableList('height',height);
|
|
@@ -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.mobjects = n.mobjects;
|
|
34
34
|
this.serviceConn = RED.nodes.getNode(n.connection);
|
|
@@ -38,7 +38,7 @@ module.exports = function (RED) {
|
|
|
38
38
|
node.status({
|
|
39
39
|
fill: 'red',
|
|
40
40
|
shape: 'ring',
|
|
41
|
-
text: 'Disconnected'
|
|
41
|
+
text: 'Disconnected'
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
node.serviceConn.register(node);
|
|
@@ -47,7 +47,7 @@ module.exports = function (RED) {
|
|
|
47
47
|
node.status({
|
|
48
48
|
fill: 'green',
|
|
49
49
|
shape: 'ring',
|
|
50
|
-
text: 'Busy'
|
|
50
|
+
text: 'Busy'
|
|
51
51
|
});
|
|
52
52
|
|
|
53
53
|
for (const mobject of node.mobjects) {
|
|
@@ -55,7 +55,7 @@ module.exports = function (RED) {
|
|
|
55
55
|
node.status({
|
|
56
56
|
fill: 'yellow',
|
|
57
57
|
shape: 'dot',
|
|
58
|
-
text: 'URIs not Valid'
|
|
58
|
+
text: 'URIs not Valid'
|
|
59
59
|
});
|
|
60
60
|
if (done) {
|
|
61
61
|
return done();
|
|
@@ -71,15 +71,15 @@ module.exports = function (RED) {
|
|
|
71
71
|
node.status({
|
|
72
72
|
fill: 'green',
|
|
73
73
|
shape: 'dot',
|
|
74
|
-
text: 'Done'
|
|
74
|
+
text: 'Done'
|
|
75
75
|
});
|
|
76
|
-
node.send({
|
|
76
|
+
node.send({topic: msg.topic, payload: values});
|
|
77
77
|
})
|
|
78
78
|
.catch((err) => {
|
|
79
79
|
node.status({
|
|
80
80
|
fill: 'yellow',
|
|
81
81
|
shape: 'dot',
|
|
82
|
-
text: 'Error: ' + JSON.stringify(err.code)
|
|
82
|
+
text: 'Error: ' + JSON.stringify(err.code)
|
|
83
83
|
});
|
|
84
84
|
node.error('Mobius error reading object ' + JSON.stringify(err));
|
|
85
85
|
})
|
|
@@ -98,7 +98,7 @@ module.exports = function (RED) {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
function validateResourceURI(uri) {
|
|
101
|
+
function validateResourceURI (uri) {
|
|
102
102
|
let parts = uri.split('/');
|
|
103
103
|
for (let lp = 0; lp < parts.length; lp++) {
|
|
104
104
|
if (parts[lp] === null || parts[lp] === '') {
|
|
@@ -111,7 +111,7 @@ module.exports = function (RED) {
|
|
|
111
111
|
return false;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
function readObject(node, uri) {
|
|
114
|
+
function readObject (node, uri) {
|
|
115
115
|
return new Promise((resolve, reject) => {
|
|
116
116
|
node.serviceConn.readObject(uri, (err, response) => {
|
|
117
117
|
if (err) {
|
|
@@ -124,12 +124,4 @@ module.exports = function (RED) {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
RED.nodes.registerType('mobius get multi-object', MobiusFlowNode);
|
|
127
|
-
|
|
128
|
-
RED.httpAdmin.get('/common/*', function (req, res) {
|
|
129
|
-
var options = {
|
|
130
|
-
root: __dirname + '/common/',
|
|
131
|
-
dotfiles: 'deny',
|
|
132
|
-
};
|
|
133
|
-
res.sendFile(req.params[0], options);
|
|
134
|
-
});
|
|
135
127
|
};
|
|
@@ -41,16 +41,12 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
41
41
|
<option value="object">Object - Resource PVs, URIs and Names</option>
|
|
42
42
|
</select>
|
|
43
43
|
</div>
|
|
44
|
-
<div
|
|
44
|
+
<div class="form-row node-input-resources-container-row">
|
|
45
45
|
<label for="node-input-resources-container"><i class="fa fa-bars"></i> Resources</label>
|
|
46
46
|
<ol id="node-input-resources-container"></ol>
|
|
47
47
|
</div>
|
|
48
|
-
|
|
49
|
-
<div id="mobsearch"></div>
|
|
50
48
|
</script>
|
|
51
49
|
|
|
52
|
-
<script src="common/mobsearch.js"></script>
|
|
53
|
-
|
|
54
50
|
<script type="text/javascript">
|
|
55
51
|
RED.nodes.registerType('mobius get multi-resource', {
|
|
56
52
|
category: 'mobius',
|
|
@@ -86,8 +82,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
86
82
|
resource.find(".node-input-resource-comment").width(newWidth - 270);
|
|
87
83
|
}
|
|
88
84
|
|
|
89
|
-
let mobiusSrvc = $("#node-input-connection").val();
|
|
90
|
-
|
|
91
85
|
/** Create the subs container and populate it */
|
|
92
86
|
$('#node-input-resources-container').css('min-height', '300px').css('min-width', '450px').editableList ({
|
|
93
87
|
addButton: "add",
|
|
@@ -105,26 +99,14 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
105
99
|
}
|
|
106
100
|
|
|
107
101
|
var row = $('<div>URI</div>').appendTo(container);
|
|
108
|
-
var uriField = $('<input/>',{class: "node-input-resource-uri", type: "text", style: "width:
|
|
109
|
-
|
|
110
|
-
// *** MOBSEARCH *** //
|
|
111
|
-
var searchField = $('<a class="searchbutton" style="vertical-align: middle"><i id="node-lookup-instance-icon" class="fa fa-search"></i></a>').appendTo(row);
|
|
112
|
-
// *** END MOBSEARCH *** //
|
|
113
|
-
|
|
102
|
+
var uriField = $('<input/>',{class: "node-input-resource-uri", type: "text", style: "width: 200px; margin-left: 5px; text-align: left;"}).appendTo(row);
|
|
114
103
|
row.append(' - ');
|
|
115
|
-
var commentField = $('<input/>',{class: "node-input-resource-comment", type: "text", style: "
|
|
104
|
+
var commentField = $('<input/>',{class: "node-input-resource-comment", type: "text", style: "margin-left: 5px; text-align: left;"}).appendTo(row);
|
|
116
105
|
|
|
117
106
|
// Populate the new stat
|
|
118
107
|
uriField.val(resource.uri);
|
|
119
108
|
commentField.val(resource.comment);
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
// *** MOBSEARCH *** //
|
|
123
|
-
if (!node.resources[i]) {
|
|
124
|
-
node.resources[i] = {uri: '', comment: ''}
|
|
125
|
-
}
|
|
126
|
-
addMobsearchListButton(searchField, i, mobsearchOpts)
|
|
127
|
-
// *** END MOBSEARCH *** //
|
|
109
|
+
resizeResource(container);
|
|
128
110
|
},
|
|
129
111
|
resizeItem: resizeResource
|
|
130
112
|
});
|
|
@@ -133,32 +115,19 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
133
115
|
if (!node.resources) {
|
|
134
116
|
node.resources = [resource = {uri: '', comment: ''}];
|
|
135
117
|
}
|
|
136
|
-
|
|
137
|
-
// *** MOBSEARCH *** //
|
|
138
|
-
|
|
139
|
-
mobsearchOpts = {
|
|
140
|
-
htmlElementId: 'mobsearch',
|
|
141
|
-
list: node.resources,
|
|
142
|
-
containerRowName: 'node-input-resources-container-row',
|
|
143
|
-
containerName: 'node-input-resources-container',
|
|
144
|
-
containerSecondFieldName: 'node-input-resources-comment',
|
|
145
|
-
};
|
|
146
|
-
initMobsearch.toRid_listed(mobiusSrvc, mobsearchOpts);
|
|
147
|
-
|
|
148
|
-
// *** END MOBSEARCH *** //
|
|
149
|
-
|
|
118
|
+
// Populate list with all saved filters
|
|
150
119
|
for (let i = 0; i < node.resources.length; i++) {
|
|
151
120
|
let resource = node.resources[i];
|
|
152
121
|
$("#node-input-resources-container").editableList('addItem', resource);
|
|
153
122
|
}
|
|
154
123
|
},
|
|
155
124
|
oneditresize(size) {
|
|
156
|
-
var rows = $("#dialog-form>div:not(.node-input-resources-container)");
|
|
125
|
+
var rows = $("#dialog-form>div:not(.node-input-resources-container-row)");
|
|
157
126
|
var height = size.height;
|
|
158
127
|
for (var i=0; i<rows.size(); i++) {
|
|
159
128
|
height -= $(rows[i]).outerHeight(true);
|
|
160
129
|
}
|
|
161
|
-
var editorRow = $("#dialog-form>div.node-input-resources-container");
|
|
130
|
+
var editorRow = $("#dialog-form>div.node-input-resources-container-row");
|
|
162
131
|
height -= 4 * ((parseInt(editorRow.css("marginTop"))+parseInt(editorRow.css("marginBottom"))));
|
|
163
132
|
|
|
164
133
|
$("#node-input-resources-container").editableList('height',height);
|
|
@@ -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.resources = n.resources;
|
|
34
34
|
this.sendFormat = n.send;
|
|
@@ -39,7 +39,7 @@ module.exports = function (RED) {
|
|
|
39
39
|
node.status({
|
|
40
40
|
fill: 'red',
|
|
41
41
|
shape: 'ring',
|
|
42
|
-
text: 'Disconnected'
|
|
42
|
+
text: 'Disconnected'
|
|
43
43
|
});
|
|
44
44
|
|
|
45
45
|
node.serviceConn.register(node);
|
|
@@ -48,7 +48,7 @@ module.exports = function (RED) {
|
|
|
48
48
|
node.status({
|
|
49
49
|
fill: 'green',
|
|
50
50
|
shape: 'ring',
|
|
51
|
-
text: 'Busy'
|
|
51
|
+
text: 'Busy'
|
|
52
52
|
});
|
|
53
53
|
|
|
54
54
|
for (const resource of node.resources) {
|
|
@@ -56,7 +56,7 @@ module.exports = function (RED) {
|
|
|
56
56
|
node.status({
|
|
57
57
|
fill: 'yellow',
|
|
58
58
|
shape: 'dot',
|
|
59
|
-
text: 'URIs not Valid'
|
|
59
|
+
text: 'URIs not Valid'
|
|
60
60
|
});
|
|
61
61
|
if (done) {
|
|
62
62
|
return done();
|
|
@@ -72,23 +72,23 @@ module.exports = function (RED) {
|
|
|
72
72
|
node.status({
|
|
73
73
|
fill: 'green',
|
|
74
74
|
shape: 'dot',
|
|
75
|
-
text: 'Done'
|
|
75
|
+
text: 'Done'
|
|
76
76
|
});
|
|
77
77
|
if (node.sendFormat === 'array') {
|
|
78
|
-
node.send({
|
|
78
|
+
node.send({topic: msg.topic, payload: values});
|
|
79
79
|
} else {
|
|
80
80
|
let payload = values.reduce((obj, item) => {
|
|
81
81
|
obj[item.uri] = { pv: item.pv, name: item.name };
|
|
82
82
|
return obj;
|
|
83
83
|
}, {});
|
|
84
|
-
node.send({
|
|
84
|
+
node.send({topic: msg.topic, payload: payload});
|
|
85
85
|
}
|
|
86
86
|
})
|
|
87
87
|
.catch((err) => {
|
|
88
88
|
node.status({
|
|
89
89
|
fill: 'yellow',
|
|
90
90
|
shape: 'dot',
|
|
91
|
-
text: 'Error: ' + JSON.stringify(err.code)
|
|
91
|
+
text: 'Error: ' + JSON.stringify(err.code)
|
|
92
92
|
});
|
|
93
93
|
node.error('Mobius error reading resource ' + JSON.stringify(err));
|
|
94
94
|
})
|
|
@@ -107,7 +107,7 @@ module.exports = function (RED) {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
function validateResourceURI(uri) {
|
|
110
|
+
function validateResourceURI (uri) {
|
|
111
111
|
let parts = uri.split('/');
|
|
112
112
|
for (let lp = 0; lp < parts.length; lp++) {
|
|
113
113
|
if (parts[lp] === null || parts[lp] === '') {
|
|
@@ -120,7 +120,7 @@ module.exports = function (RED) {
|
|
|
120
120
|
return false;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
function readResource(node, uri) {
|
|
123
|
+
function readResource (node, uri) {
|
|
124
124
|
return new Promise((resolve, reject) => {
|
|
125
125
|
node.serviceConn.readResource(uri, (err, response) => {
|
|
126
126
|
if (err) {
|
|
@@ -129,7 +129,7 @@ module.exports = function (RED) {
|
|
|
129
129
|
if (node.sendFormat === 'array') {
|
|
130
130
|
resolve(response.value.pv);
|
|
131
131
|
} else {
|
|
132
|
-
resolve({
|
|
132
|
+
resolve({uri: uri, pv: response.value.pv, name: response.value.name});
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
});
|
|
@@ -137,12 +137,4 @@ module.exports = function (RED) {
|
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
RED.nodes.registerType('mobius get multi-resource', MobiusFlowNode);
|
|
140
|
-
|
|
141
|
-
RED.httpAdmin.get('/common/*', function (req, res) {
|
|
142
|
-
var options = {
|
|
143
|
-
root: __dirname + '/common/',
|
|
144
|
-
dotfiles: 'deny',
|
|
145
|
-
};
|
|
146
|
-
res.sendFile(req.params[0], options);
|
|
147
|
-
});
|
|
148
140
|
};
|
|
@@ -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 class="form-row" id="input-row">
|
|
36
|
-
<label for="node-input-instance"><i class="fa fa-tasks"></i> URI</label>
|
|
37
|
-
<input type="text" id="node-input-instance" style="width:61%;" placeholder="HID/SID/PID/INS (optional name)">
|
|
38
|
-
</div>
|
|
32
|
+
<div class="form-row">
|
|
33
|
+
<label for="node-input-mobject"><i class="fa fa-tasks"></i> URI</label>
|
|
34
|
+
<input type="text" id="node-input-mobject" placeholder="Object URI (hid/sid/pid/ins)">
|
|
39
35
|
</div>
|
|
40
|
-
|
|
41
|
-
<div id="mobsearch"></div>
|
|
42
|
-
|
|
43
36
|
<div class="form-row">
|
|
44
37
|
<label for="node-input-format"><i class="fa fa-bars"></i> Format</label>
|
|
45
38
|
<select type="text" id="node-input-format" style="display: inline-block; width: auto; vertical-align: center;">
|
|
@@ -59,8 +52,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
59
52
|
</div>
|
|
60
53
|
</script>
|
|
61
54
|
|
|
62
|
-
<script src="common/mobsearch.js"></script>
|
|
63
|
-
|
|
64
55
|
<script type="text/javascript">
|
|
65
56
|
RED.nodes.registerType('mobius get object',{
|
|
66
57
|
category: 'mobius',
|
|
@@ -69,7 +60,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
69
60
|
name: {value: ""},
|
|
70
61
|
detailedOutput: {value:false},
|
|
71
62
|
format: {value: "name", required: true},
|
|
72
|
-
|
|
63
|
+
mobject: {value: "", validate:function(v) {
|
|
73
64
|
if(v === '') { return true; }
|
|
74
65
|
let parts = v.split('/');
|
|
75
66
|
for(let lp = 0; lp < parts.length; lp++) {
|
|
@@ -95,24 +86,12 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
95
86
|
if(this.name) {
|
|
96
87
|
return this.name;
|
|
97
88
|
} else {
|
|
98
|
-
return this.
|
|
89
|
+
return this.mobject ? `Get - ${this.mobject}` : "get object";
|
|
99
90
|
}
|
|
100
91
|
},
|
|
101
92
|
labelStyle: function() {
|
|
102
93
|
return this.name ? "node_label_italic":"";
|
|
103
94
|
},
|
|
104
|
-
oneditprepare: function () {
|
|
105
|
-
|
|
106
|
-
var node = this;
|
|
107
|
-
let mobiusSrvc = $("#node-input-connection").val();
|
|
108
|
-
|
|
109
|
-
opts = {
|
|
110
|
-
htmlElementId: 'mobsearch',
|
|
111
|
-
uriFieldName: 'node-input-instance ',
|
|
112
|
-
inputRowId: 'input-row',
|
|
113
|
-
};
|
|
114
|
-
initMobsearch.toIns(mobiusSrvc, opts);
|
|
115
|
-
},
|
|
116
95
|
oneditsave: function() {
|
|
117
96
|
if($("#node-input-detailedOutput").prop('checked')) {
|
|
118
97
|
this.outputs = 3;
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
const _ = require('lodash');
|
|
31
31
|
|
|
32
32
|
module.exports = function (RED) {
|
|
33
|
-
function MobiusGetObjectNode(n) {
|
|
33
|
+
function MobiusGetObjectNode (n) {
|
|
34
34
|
RED.nodes.createNode(this, n);
|
|
35
35
|
this.detailedOutput = n.detailedOutput;
|
|
36
36
|
this.format = n.format;
|
|
37
|
-
this.
|
|
37
|
+
this.mobject = n.mobject;
|
|
38
38
|
this.serviceConn = RED.nodes.getNode(n.connection);
|
|
39
39
|
var node = this;
|
|
40
40
|
|
|
@@ -42,11 +42,11 @@ module.exports = function (RED) {
|
|
|
42
42
|
node.status({
|
|
43
43
|
fill: 'red',
|
|
44
44
|
shape: 'ring',
|
|
45
|
-
text: 'Disconnected'
|
|
45
|
+
text: 'Disconnected'
|
|
46
46
|
});
|
|
47
47
|
|
|
48
48
|
node.on('input', function (msg) {
|
|
49
|
-
let uri = node.
|
|
49
|
+
let uri = node.mobject;
|
|
50
50
|
if (msg.hasOwnProperty('topic') && require('./validateURI')(msg.topic, 4)) {
|
|
51
51
|
uri = msg.topic;
|
|
52
52
|
}
|
|
@@ -54,35 +54,32 @@ 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
|
node.serviceConn.readObject(uri, (err, response) => {
|
|
60
60
|
if (err) {
|
|
61
61
|
node.status({
|
|
62
62
|
fill: 'yellow',
|
|
63
63
|
shape: 'dot',
|
|
64
|
-
text: 'Error: ' + JSON.stringify(err.code)
|
|
64
|
+
text: 'Error: ' + JSON.stringify(err.code)
|
|
65
65
|
});
|
|
66
66
|
node.error('Mobius error reading object ' + JSON.stringify(err));
|
|
67
67
|
if (node.detailedOutput === true) {
|
|
68
|
-
node.send([null, null, {
|
|
68
|
+
node.send([null, null, {topic: uri, payload: { error: true, response: err }}]);
|
|
69
69
|
}
|
|
70
70
|
} else {
|
|
71
71
|
node.status({
|
|
72
72
|
fill: 'green',
|
|
73
73
|
shape: 'dot',
|
|
74
|
-
text: JSON.stringify(response.uri)
|
|
74
|
+
text: JSON.stringify(response.uri)
|
|
75
75
|
});
|
|
76
76
|
|
|
77
|
-
let allResources = _.keyBy(
|
|
78
|
-
response.value.resources,
|
|
79
|
-
node.format === 'name' ? 'name' : 'rid'
|
|
80
|
-
);
|
|
77
|
+
let allResources = _.keyBy(response.value.resources, node.format === 'name' ? 'name' : 'rid');
|
|
81
78
|
if (node.detailedOutput === true) {
|
|
82
79
|
node.send([
|
|
83
80
|
{ topic: uri, payload: allResources },
|
|
84
81
|
{ topic: uri, payload: response.value },
|
|
85
|
-
{ topic: uri, payload: { error: false, response: response } }
|
|
82
|
+
{ topic: uri, payload: { error: false, response: response } }
|
|
86
83
|
]);
|
|
87
84
|
} else {
|
|
88
85
|
node.send({ topic: uri, payload: allResources });
|
|
@@ -102,12 +99,4 @@ module.exports = function (RED) {
|
|
|
102
99
|
}
|
|
103
100
|
|
|
104
101
|
RED.nodes.registerType('mobius get object', MobiusGetObjectNode);
|
|
105
|
-
|
|
106
|
-
RED.httpAdmin.get('/common/*', function (req, res) {
|
|
107
|
-
var options = {
|
|
108
|
-
root: __dirname + '/common/',
|
|
109
|
-
dotfiles: 'deny',
|
|
110
|
-
};
|
|
111
|
-
res.sendFile(req.params[0], options);
|
|
112
|
-
});
|
|
113
102
|
};
|
|
@@ -29,18 +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
|
-
|
|
42
|
-
<div id="mobsearch"></div>
|
|
43
|
-
|
|
44
36
|
<div class="form-row">
|
|
45
37
|
<label> </label>
|
|
46
38
|
<input type="checkbox" id="node-input-detailedOutput" style="display: inline-block; width: auto; vertical-align: top;">
|
|
@@ -53,8 +45,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
53
45
|
</div>
|
|
54
46
|
</script>
|
|
55
47
|
|
|
56
|
-
<script src="common/mobsearch.js"></script>
|
|
57
|
-
|
|
58
48
|
<script type="text/javascript">
|
|
59
49
|
RED.nodes.registerType('mobius get resource',{
|
|
60
50
|
category: 'mobius',
|
|
@@ -95,18 +85,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
95
85
|
labelStyle: function() {
|
|
96
86
|
return this.name ? "node_label_italic":"";
|
|
97
87
|
},
|
|
98
|
-
oneditprepare: function () {
|
|
99
|
-
var node = this;
|
|
100
|
-
let mobiusSrvc = $("#node-input-connection").val();
|
|
101
|
-
|
|
102
|
-
opts = {
|
|
103
|
-
htmlElementId: 'mobsearch',
|
|
104
|
-
uriFieldName: 'node-input-resource',
|
|
105
|
-
inputRowId: 'input-row',
|
|
106
|
-
};
|
|
107
|
-
initMobsearch.toRid(mobiusSrvc, opts);
|
|
108
|
-
|
|
109
|
-
},
|
|
110
88
|
oneditsave: function() {
|
|
111
89
|
if($("#node-input-detailedOutput").prop('checked')) {
|
|
112
90
|
this.outputs = 4;
|