node-red-contrib-mobius-flow-base 2.5.86-beta.1 → 2.5.86-beta.101
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/icons/mobius-inject.png +0 -0
- package/dist/nodes/icons/mobius.png +0 -0
- package/dist/nodes/mobius-clear-resource.html +178 -0
- package/dist/nodes/mobius-clear-resource.js +109 -0
- package/dist/nodes/mobius-connection.html +68 -0
- package/dist/nodes/mobius-connection.js +675 -0
- package/dist/nodes/mobius-discover-object-list.html +272 -0
- package/dist/nodes/mobius-discover-object-list.js +263 -0
- package/dist/nodes/mobius-discover.html +139 -0
- package/dist/nodes/mobius-discover.js +100 -0
- package/dist/nodes/mobius-filter-by-rid-value.html +206 -0
- package/dist/nodes/mobius-filter-by-rid-value.js +123 -0
- package/dist/nodes/mobius-flow-inject.html +162 -0
- package/dist/nodes/mobius-flow-inject.js +124 -0
- package/dist/nodes/mobius-get-multi-object.html +176 -0
- package/dist/nodes/mobius-get-multi-object.js +127 -0
- package/dist/nodes/mobius-get-multi-resource.html +195 -0
- package/dist/nodes/mobius-get-multi-resource.js +140 -0
- package/dist/nodes/mobius-get-object.html +168 -0
- package/dist/nodes/mobius-get-object.js +102 -0
- package/dist/nodes/mobius-get-resource.html +169 -0
- package/dist/nodes/mobius-get-resource.js +101 -0
- package/dist/nodes/mobius-object-cov.html +171 -0
- package/dist/nodes/mobius-object-cov.js +83 -0
- package/dist/nodes/mobius-resource-cov.html +155 -0
- package/dist/nodes/mobius-resource-cov.js +77 -0
- package/dist/nodes/mobius-send-bcmd.html +93 -0
- package/dist/nodes/mobius-send-bcmd.js +61 -0
- package/dist/nodes/mobius-send-dcmd.html +130 -0
- package/dist/nodes/mobius-send-dcmd.js +80 -0
- package/dist/nodes/mobius-set-multi-resource.html +150 -0
- package/dist/nodes/mobius-set-multi-resource.js +104 -0
- package/dist/nodes/mobius-set-resource.html +180 -0
- package/dist/nodes/mobius-set-resource.js +145 -0
- package/dist/nodes/mobius-sub-bcmd.html +94 -0
- package/dist/nodes/mobius-sub-bcmd.js +64 -0
- package/dist/nodes/node-red-ui-discover-devices.js +103 -0
- package/dist/nodes/validateURI.js +51 -0
- package/package.json +1 -1
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Copyright (C) 2016, IAConnects Technology Limited
|
|
3
|
+
All Rights Reserved
|
|
4
|
+
|
|
5
|
+
ALL INFORMATION CONTAINED HEREIN IS, AND REMAINS
|
|
6
|
+
THE PROPERTY OF IACONNECTS TECHNOLOGY LIMITED AND ITS SUPPLIERS,
|
|
7
|
+
IF ANY. THE INTELLECTUAL AND TECHNICAL CONCEPTS CONTAINED
|
|
8
|
+
HEREIN ARE PROPRIETARY TO IACONNECTS TECHNOLOGY LIMITED
|
|
9
|
+
AND ITS SUPPLIERS AND ARE PROTECTED BY TRADE SECRET OR COPYRIGHT LAW.
|
|
10
|
+
DISSEMINATION OF THIS INFORMATION OR REPRODUCTION OF THIS MATERIAL
|
|
11
|
+
IS STRICTLY FORBIDDEN UNLESS PRIOR WRITTEN PERMISSION IS OBTAINED
|
|
12
|
+
FROM IACONNECTS TECHNOLOGY LIMITED.
|
|
13
|
+
|
|
14
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
15
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
16
|
+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
17
|
+
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
|
|
18
|
+
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
19
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
20
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
21
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
22
|
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
23
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
24
|
+
POSSIBILITY OF SUCH DAMAGE.
|
|
25
|
+
**/
|
|
26
|
+
|
|
27
|
+
/* jshint elision: true */
|
|
28
|
+
'use strict';
|
|
29
|
+
|
|
30
|
+
module.exports = function (RED) {
|
|
31
|
+
function MobiusDiscoverNode (n) {
|
|
32
|
+
RED.nodes.createNode(this, n);
|
|
33
|
+
this.serviceConn = RED.nodes.getNode(n.connection);
|
|
34
|
+
var node = this;
|
|
35
|
+
|
|
36
|
+
if (node.serviceConn) {
|
|
37
|
+
node.status({
|
|
38
|
+
fill: 'red',
|
|
39
|
+
shape: 'ring',
|
|
40
|
+
text: 'Disconnected'
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
node.on('input', function (msg) {
|
|
44
|
+
let path = '';
|
|
45
|
+
if (msg.hasOwnProperty('topic')) {
|
|
46
|
+
path = msg.topic;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (path === '') {
|
|
50
|
+
node.status({
|
|
51
|
+
fill: 'yellow',
|
|
52
|
+
shape: 'dot',
|
|
53
|
+
text: 'Error: Input message topic must contain a valid discovery URI'
|
|
54
|
+
});
|
|
55
|
+
} else {
|
|
56
|
+
node.status({
|
|
57
|
+
fill: 'green',
|
|
58
|
+
shape: 'ring',
|
|
59
|
+
text: 'Busy'
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
let parameters = {};
|
|
63
|
+
if (msg.payload.hasOwnProperty('rid') && msg.payload.hasOwnProperty('func')) {
|
|
64
|
+
parameters = msg.payload;
|
|
65
|
+
parameters['uri'] = path;
|
|
66
|
+
} else {
|
|
67
|
+
parameters['uri'] = path;
|
|
68
|
+
}
|
|
69
|
+
node.serviceConn.discover(parameters, (err, response) => {
|
|
70
|
+
if (err) {
|
|
71
|
+
node.status({
|
|
72
|
+
fill: 'yellow',
|
|
73
|
+
shape: 'dot',
|
|
74
|
+
text: 'Error: ' + JSON.stringify(err.code)
|
|
75
|
+
});
|
|
76
|
+
node.send({ topic: path, payload: { error: true, response: err } });
|
|
77
|
+
} else {
|
|
78
|
+
node.status({
|
|
79
|
+
fill: 'green',
|
|
80
|
+
shape: 'dot',
|
|
81
|
+
text: JSON.stringify(response.uri)
|
|
82
|
+
});
|
|
83
|
+
node.send({ topic: path, payload: { error: false, response: response } });
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
node.serviceConn.register(node);
|
|
90
|
+
|
|
91
|
+
node.on('close', function (done) {
|
|
92
|
+
node.serviceConn.deregister(node, done);
|
|
93
|
+
});
|
|
94
|
+
} else {
|
|
95
|
+
node.error(RED._('Mobius service not defined'));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
RED.nodes.registerType('mobius discover', MobiusDiscoverNode);
|
|
100
|
+
};
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Copyright (C) 2016, IAConnects Technology Limited
|
|
3
|
+
All Rights Reserved
|
|
4
|
+
|
|
5
|
+
ALL INFORMATION CONTAINED HEREIN IS, AND REMAINS
|
|
6
|
+
THE PROPERTY OF IACONNECTS TECHNOLOGY LIMITED AND ITS SUPPLIERS,
|
|
7
|
+
IF ANY. THE INTELLECTUAL AND TECHNICAL CONCEPTS CONTAINED
|
|
8
|
+
HEREIN ARE PROPRIETARY TO IACONNECTS TECHNOLOGY LIMITED
|
|
9
|
+
AND ITS SUPPLIERS AND ARE PROTECTED BY TRADE SECRET OR COPYRIGHT LAW.
|
|
10
|
+
DISSEMINATION OF THIS INFORMATION OR REPRODUCTION OF THIS MATERIAL
|
|
11
|
+
IS STRICTLY FORBIDDEN UNLESS PRIOR WRITTEN PERMISSION IS OBTAINED
|
|
12
|
+
FROM IACONNECTS TECHNOLOGY LIMITED.
|
|
13
|
+
|
|
14
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
15
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
16
|
+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
17
|
+
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
|
|
18
|
+
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
19
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
20
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
21
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
22
|
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
23
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
24
|
+
POSSIBILITY OF SUCH DAMAGE.
|
|
25
|
+
-->
|
|
26
|
+
|
|
27
|
+
<script type="text/x-red" data-template-name="mobius filter by rid value">
|
|
28
|
+
<div class="form-row">
|
|
29
|
+
<label for="node-input-connection"><i class="fa fa-globe"></i> MOBiUS</label>
|
|
30
|
+
<input type="text" id="node-input-connection">
|
|
31
|
+
</div>
|
|
32
|
+
<div class="form-row">
|
|
33
|
+
<label for="node-input-service"><i class="fa fa-tasks"></i> URI</label>
|
|
34
|
+
<input type="text" id="node-input-service" placeholder="Service URI (hid/sid)">
|
|
35
|
+
</div>
|
|
36
|
+
<div class="form-row">
|
|
37
|
+
<label for="node-input-pids"><i class="fa fa-tasks"></i> PIDs</label>
|
|
38
|
+
<input type="text" id="node-input-pids" placeholder="Array of PIDs ([pid, pid...])">
|
|
39
|
+
</div>
|
|
40
|
+
<div class="form-row">
|
|
41
|
+
<label for="node-input-rid"><i class="fa fa-tasks"></i> RID</label>
|
|
42
|
+
<input type="text" id="node-input-rid" placeholder="Resource to test">
|
|
43
|
+
</div>
|
|
44
|
+
<div class="form-row">
|
|
45
|
+
<label for="node-input-limit"><i class="fa fa-tasks"></i> Limit</label>
|
|
46
|
+
<input type="text" id="node-input-limit" placeholder="Maximum number of objects to return">
|
|
47
|
+
</div>
|
|
48
|
+
<div class="form-row">
|
|
49
|
+
<label for="node-input-func-editor" style="width:105px;float:left;"><i class="fa fa-tasks"></i> Function</label>
|
|
50
|
+
<div style="height: 150px; min-height:80px;" class="node-text-editor" id="node-input-func-editor"></div>
|
|
51
|
+
</div>
|
|
52
|
+
<div class="form-row">
|
|
53
|
+
<label> </label>
|
|
54
|
+
<input type="checkbox" id="node-input-detailedOutput" style="display: inline-block; width: auto; vertical-align: top;">
|
|
55
|
+
<label for="node-input-detailedOutput" style="width: 70%;"> Use detailed outputs</label>
|
|
56
|
+
<input type="hidden" id="node-input-outputs"/>
|
|
57
|
+
</div>
|
|
58
|
+
<hr>
|
|
59
|
+
<div class="form-row">
|
|
60
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
61
|
+
<input type="text" id="node-input-name" placeholder="Name">
|
|
62
|
+
</div>
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
<script type="text/javascript">
|
|
66
|
+
RED.nodes.registerType('mobius filter by rid value',{
|
|
67
|
+
category: 'mobius',
|
|
68
|
+
color:"#8abff5",
|
|
69
|
+
defaults: {
|
|
70
|
+
outputs: {value:1},
|
|
71
|
+
name: {value:""},
|
|
72
|
+
pids: {value: "[]"},
|
|
73
|
+
func: {value:""},
|
|
74
|
+
limit: {value:100, validate:RED.validators.number()},
|
|
75
|
+
rid: {value:"", validate:RED.validators.regex(/^[A-Fa-f0-9][A-Fa-f0-9]$/)},
|
|
76
|
+
detailedOutput: {value:false},
|
|
77
|
+
service: {value:"", validate:function(v) {
|
|
78
|
+
if(v === '') { return true; }
|
|
79
|
+
let parts = v.split('/');
|
|
80
|
+
for(let lp = 0; lp < parts.length; lp++) {
|
|
81
|
+
if(parts[lp] === null || parts[lp] === '') { return false;}
|
|
82
|
+
}
|
|
83
|
+
if(parts.length === 2) { return true; }
|
|
84
|
+
return false;
|
|
85
|
+
}},
|
|
86
|
+
connection: {type:"mobius connection", required:true}
|
|
87
|
+
},
|
|
88
|
+
inputs:1,
|
|
89
|
+
outputs:1,
|
|
90
|
+
outputLabels: function (index) {
|
|
91
|
+
if(index === 0) return ("Filtered object list");
|
|
92
|
+
if(index === 1) return ("Full MOBiUS response");
|
|
93
|
+
},
|
|
94
|
+
icon: "mobius.png",
|
|
95
|
+
align: "left",
|
|
96
|
+
paletteLabel: 'filter by rid value',
|
|
97
|
+
label: function() {
|
|
98
|
+
if(this.name) {
|
|
99
|
+
return this.name;
|
|
100
|
+
} else {
|
|
101
|
+
return this.service ? `Filter - ${this.service} by RID ${this.rid}` : "filter by rid value";
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
labelStyle: function() {
|
|
105
|
+
return this.name ? "node_label_italic":"";
|
|
106
|
+
},
|
|
107
|
+
oneditprepare: function() {
|
|
108
|
+
$("#node-input-pids").typedInput({
|
|
109
|
+
type:"json",
|
|
110
|
+
types:["json"]
|
|
111
|
+
});
|
|
112
|
+
this.editor = RED.editor.createEditor({
|
|
113
|
+
id: 'node-input-func-editor',
|
|
114
|
+
mode: 'ace/mode/javascript',
|
|
115
|
+
value: this.func
|
|
116
|
+
});
|
|
117
|
+
},
|
|
118
|
+
oneditsave: function() {
|
|
119
|
+
if($("#node-input-detailedOutput").prop('checked')) {
|
|
120
|
+
$("#node-input-outputs").val(2);
|
|
121
|
+
} else {
|
|
122
|
+
$("#node-input-outputs").val(1);
|
|
123
|
+
}
|
|
124
|
+
this.func = this.editor.getValue();
|
|
125
|
+
this.editor.destroy();
|
|
126
|
+
delete this.editor;
|
|
127
|
+
},
|
|
128
|
+
oneditcancel: function() {
|
|
129
|
+
this.editor.destroy();
|
|
130
|
+
delete this.editor;
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
</script>
|
|
134
|
+
|
|
135
|
+
<script type="text/x-red" data-help-name="mobius filter by rid value">
|
|
136
|
+
<p>Read a MOBiUS resource value.</p>
|
|
137
|
+
|
|
138
|
+
<h3>Configuration Page</h3>
|
|
139
|
+
<dl class="message-properties">
|
|
140
|
+
<dt>MOBiUS <span class="property-type">node</span></dt>
|
|
141
|
+
<dd>Shared MOBiUS connection for communication with the MOBiUS Hub.</dd>
|
|
142
|
+
<dt>URI <span class="property-type">string</span></dt>
|
|
143
|
+
<dd>The MOBiUS URI of the resource.</dd>
|
|
144
|
+
<dt>Use detailed outputs <span class="property-type">boolean</span></dt>
|
|
145
|
+
<dd>If checked the full resource is sent on output 3 and the full MOBiUS response is sent on output 4.</dd>
|
|
146
|
+
</dl>
|
|
147
|
+
|
|
148
|
+
<h3>Inputs</h3>
|
|
149
|
+
<ol class="node-ports">
|
|
150
|
+
<li>Input message to trigger reading a resource
|
|
151
|
+
<dl class="message-properties">
|
|
152
|
+
<dt class="optional">topic <span class="property-type">string</span></dt>
|
|
153
|
+
<dd>An optional property that overwrites the URI set in the node configuration page.
|
|
154
|
+
If the topic is not a valid URI it is ignored and the value set in the node configuration page is used.</dd>
|
|
155
|
+
</dl>
|
|
156
|
+
</li>
|
|
157
|
+
</ol>
|
|
158
|
+
|
|
159
|
+
<h3>Outputs</h3>
|
|
160
|
+
<ol class="node-ports">
|
|
161
|
+
<li>Output 1 (Present value)
|
|
162
|
+
<dl class="message-properties">
|
|
163
|
+
<dt>topic <span class="property-type">string</span></dt>
|
|
164
|
+
<dd>The full URI of the resource.</dd>
|
|
165
|
+
<dt>payload <span class="property-type">object</span></dt>
|
|
166
|
+
<dd>The resource's pv.</dd>
|
|
167
|
+
</dl>
|
|
168
|
+
</li>
|
|
169
|
+
<li>Output 2 (Present value and name of resource)
|
|
170
|
+
<dl class="message-properties">
|
|
171
|
+
<dt>topic <span class="property-type">string</span></dt>
|
|
172
|
+
<dd>The full URI of the resource.</dd>
|
|
173
|
+
<dt>payload.pv <span class="property-type">object</span></dt>
|
|
174
|
+
<dd>The resource's pv.</dd>
|
|
175
|
+
<dt>payload.name <span class="property-type">object</span></dt>
|
|
176
|
+
<dd>The resource's name.</dd>
|
|
177
|
+
</dl>
|
|
178
|
+
</li>
|
|
179
|
+
<li>Output 3 (The MOBiUS resource - optional)
|
|
180
|
+
<dl class="message-properties">
|
|
181
|
+
<dt>topic <span class="property-type">string</span></dt>
|
|
182
|
+
<dd>The full URI of the resource.</dd>
|
|
183
|
+
<dt>payload <span class="property-type">object</span></dt>
|
|
184
|
+
<dd>The resource.</dd>
|
|
185
|
+
</dl>
|
|
186
|
+
</li>
|
|
187
|
+
<li>Output 4 (Full MOBiUS response - optional)
|
|
188
|
+
<dl class="message-properties">
|
|
189
|
+
<dt>topic <span class="property-type">string</span></dt>
|
|
190
|
+
<dd>The full URI of the resource.</dd>
|
|
191
|
+
<dt>error <span class="property-type">boolean</span></dt>
|
|
192
|
+
<dd>True if an error occured, else false.</dd>
|
|
193
|
+
<dt>response <span class="property-type">object</span></dt>
|
|
194
|
+
<dd>The full MOBiUS response message.</dd>
|
|
195
|
+
</dl>
|
|
196
|
+
</li>
|
|
197
|
+
</ol>
|
|
198
|
+
|
|
199
|
+
<h3>Details</h3>
|
|
200
|
+
<p>Outputs 3 and 4 are only sent if <b>Use detailed outputs</b> is checked on the configuration page.</p>
|
|
201
|
+
<p>Outputs 1, 2 and 3 are only sent if no error occurs. The <b>error</b> property in output 4
|
|
202
|
+
can be used to determine if an error has occurred.</p>
|
|
203
|
+
|
|
204
|
+
<br>
|
|
205
|
+
<p align="center" style="color:#000080">iaconnects © 2017</p>
|
|
206
|
+
</script>
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Copyright (C) 2016, IAConnects Technology Limited
|
|
3
|
+
All Rights Reserved
|
|
4
|
+
|
|
5
|
+
ALL INFORMATION CONTAINED HEREIN IS, AND REMAINS
|
|
6
|
+
THE PROPERTY OF IACONNECTS TECHNOLOGY LIMITED AND ITS SUPPLIERS,
|
|
7
|
+
IF ANY. THE INTELLECTUAL AND TECHNICAL CONCEPTS CONTAINED
|
|
8
|
+
HEREIN ARE PROPRIETARY TO IACONNECTS TECHNOLOGY LIMITED
|
|
9
|
+
AND ITS SUPPLIERS AND ARE PROTECTED BY TRADE SECRET OR COPYRIGHT LAW.
|
|
10
|
+
DISSEMINATION OF THIS INFORMATION OR REPRODUCTION OF THIS MATERIAL
|
|
11
|
+
IS STRICTLY FORBIDDEN UNLESS PRIOR WRITTEN PERMISSION IS OBTAINED
|
|
12
|
+
FROM IACONNECTS TECHNOLOGY LIMITED.
|
|
13
|
+
|
|
14
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
15
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
16
|
+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
17
|
+
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
|
|
18
|
+
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
19
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
20
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
21
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
22
|
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
23
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
24
|
+
POSSIBILITY OF SUCH DAMAGE.
|
|
25
|
+
**/
|
|
26
|
+
|
|
27
|
+
// <input type="text" id="node-input-func" placeholder="Function used for filtering (return $PV === 0)">
|
|
28
|
+
|
|
29
|
+
/* jshint elision: true */
|
|
30
|
+
'use strict';
|
|
31
|
+
|
|
32
|
+
module.exports = function (RED) {
|
|
33
|
+
function MobiusFilterNode (n) {
|
|
34
|
+
RED.nodes.createNode(this, n);
|
|
35
|
+
this.detailedOutput = n.detailedOutput;
|
|
36
|
+
this.service = n.service;
|
|
37
|
+
this.pids = n.pids;
|
|
38
|
+
this.rid = n.rid;
|
|
39
|
+
this.limit = n.limit;
|
|
40
|
+
this.func = n.func;
|
|
41
|
+
this.serviceConn = RED.nodes.getNode(n.connection);
|
|
42
|
+
var node = this;
|
|
43
|
+
|
|
44
|
+
if (node.serviceConn) {
|
|
45
|
+
node.status({
|
|
46
|
+
fill: 'red',
|
|
47
|
+
shape: 'ring',
|
|
48
|
+
text: 'Disconnected'
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
node.on('input', function (msg) {
|
|
52
|
+
let uri = node.service;
|
|
53
|
+
let pids = JSON.parse(node.pids);
|
|
54
|
+
let rid = node.rid;
|
|
55
|
+
let limit = node.limit;
|
|
56
|
+
let func = node.func;
|
|
57
|
+
if (msg.hasOwnProperty('topic') && require('./validateURI')(msg.topic, 2)) {
|
|
58
|
+
uri = msg.topic;
|
|
59
|
+
}
|
|
60
|
+
if (msg.hasOwnProperty('payload')) {
|
|
61
|
+
if (msg.payload.hasOwnProperty('pids')) {
|
|
62
|
+
pids = msg.payload.pids;
|
|
63
|
+
}
|
|
64
|
+
if (msg.payload.hasOwnProperty('rid')) {
|
|
65
|
+
rid = msg.payload.rid;
|
|
66
|
+
}
|
|
67
|
+
if (msg.payload.hasOwnProperty('limit')) {
|
|
68
|
+
limit = msg.payload.limit;
|
|
69
|
+
}
|
|
70
|
+
if (msg.payload.hasOwnProperty('func')) {
|
|
71
|
+
func = msg.payload.func;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
node.status({
|
|
76
|
+
fill: 'green',
|
|
77
|
+
shape: 'ring',
|
|
78
|
+
text: 'Busy'
|
|
79
|
+
});
|
|
80
|
+
node.serviceConn.filterObjectsByRIDValue(uri, pids, rid, limit, func, (err, response) => {
|
|
81
|
+
if (err) {
|
|
82
|
+
node.status({
|
|
83
|
+
fill: 'yellow',
|
|
84
|
+
shape: 'dot',
|
|
85
|
+
text: 'Error: ' + JSON.stringify(err.code)
|
|
86
|
+
});
|
|
87
|
+
if (node.detailedOutput === true) {
|
|
88
|
+
node.send([null, {topic: uri, payload: { error: true, response: err }}]);
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
node.status({
|
|
92
|
+
fill: 'green',
|
|
93
|
+
shape: 'dot',
|
|
94
|
+
text: JSON.stringify(response.uri)
|
|
95
|
+
});
|
|
96
|
+
let uriList = [];
|
|
97
|
+
for (let lp = 0; lp < response.value.length; lp++) {
|
|
98
|
+
uriList.push(`${response.uri}/${response.value[lp].pid}/${response.value[lp].ins}`)
|
|
99
|
+
}
|
|
100
|
+
if (node.detailedOutput === true) {
|
|
101
|
+
node.send([
|
|
102
|
+
{ topic: uri, payload: uriList },
|
|
103
|
+
{ topic: uri, payload: { error: false, response: response } }
|
|
104
|
+
]);
|
|
105
|
+
} else {
|
|
106
|
+
node.send({ topic: uri, payload: uriList });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
node.serviceConn.register(node);
|
|
113
|
+
|
|
114
|
+
node.on('close', function (done) {
|
|
115
|
+
node.serviceConn.deregister(node, done);
|
|
116
|
+
});
|
|
117
|
+
} else {
|
|
118
|
+
node.error(RED._('Mobius service not defined'));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
RED.nodes.registerType('mobius filter by rid value', MobiusFilterNode);
|
|
123
|
+
};
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Copyright (C) 2016, IAConnects Technology Limited
|
|
3
|
+
All Rights Reserved
|
|
4
|
+
|
|
5
|
+
ALL INFORMATION CONTAINED HEREIN IS, AND REMAINS
|
|
6
|
+
THE PROPERTY OF IACONNECTS TECHNOLOGY LIMITED AND ITS SUPPLIERS,
|
|
7
|
+
IF ANY. THE INTELLECTUAL AND TECHNICAL CONCEPTS CONTAINED
|
|
8
|
+
HEREIN ARE PROPRIETARY TO IACONNECTS TECHNOLOGY LIMITED
|
|
9
|
+
AND ITS SUPPLIERS AND ARE PROTECTED BY TRADE SECRET OR COPYRIGHT LAW.
|
|
10
|
+
DISSEMINATION OF THIS INFORMATION OR REPRODUCTION OF THIS MATERIAL
|
|
11
|
+
IS STRICTLY FORBIDDEN UNLESS PRIOR WRITTEN PERMISSION IS OBTAINED
|
|
12
|
+
FROM IACONNECTS TECHNOLOGY LIMITED.
|
|
13
|
+
|
|
14
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
15
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
16
|
+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
17
|
+
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
|
|
18
|
+
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
19
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
20
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
21
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
22
|
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
23
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
24
|
+
POSSIBILITY OF SUCH DAMAGE.
|
|
25
|
+
-->
|
|
26
|
+
|
|
27
|
+
<script type="text/x-red" data-template-name="mobius flow inject">
|
|
28
|
+
<div class="form-row">
|
|
29
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
30
|
+
<input type="text" id="node-input-name" placeholder="Name">
|
|
31
|
+
</div>
|
|
32
|
+
<hr>
|
|
33
|
+
<div class="form-row">
|
|
34
|
+
<label for="node-input-connection"><i class="fa fa-globe"></i> MOBiUS</label>
|
|
35
|
+
<input type="text" id="node-input-connection">
|
|
36
|
+
</div>
|
|
37
|
+
<div class="form-row node-input-subs-container-row">
|
|
38
|
+
<label for="node-input-subs-container"><i class="fa fa-bars"></i> Subscriptions</label>
|
|
39
|
+
<ol id="node-input-subs-container"></ol>
|
|
40
|
+
</div>
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<script type="text/javascript">
|
|
44
|
+
RED.nodes.registerType('mobius flow inject', {
|
|
45
|
+
category: 'mobius',
|
|
46
|
+
defaults: {
|
|
47
|
+
name: {value:""},
|
|
48
|
+
subscriptions: {value:[{uri: '', type: 'include'}]},
|
|
49
|
+
connection: {type:"mobius connection", required:true}
|
|
50
|
+
},
|
|
51
|
+
color:"#55cef6",
|
|
52
|
+
inputs:0,
|
|
53
|
+
outputs:1,
|
|
54
|
+
outputLabels: ["MOBiUS flow object"],
|
|
55
|
+
icon: "mobius-inject.png",
|
|
56
|
+
align: "left",
|
|
57
|
+
paletteLabel: 'mobius flow inject',
|
|
58
|
+
label: function() {
|
|
59
|
+
if(this.name) {
|
|
60
|
+
return this.name;
|
|
61
|
+
} else {
|
|
62
|
+
return this.object ? `MOBiUSFlow - ${this.object}` : "mobius flow inject";
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
labelStyle: function() {
|
|
66
|
+
return this.name ? "node_label_italic":"";
|
|
67
|
+
},
|
|
68
|
+
oneditprepare: function () {
|
|
69
|
+
var node = this;
|
|
70
|
+
|
|
71
|
+
/** Create the subs container and populate it */
|
|
72
|
+
$('#node-input-subs-container').css('min-height', '300px').css('min-width', '450px').editableList ({
|
|
73
|
+
addButton: "add",
|
|
74
|
+
removable: true,
|
|
75
|
+
sortable: true,
|
|
76
|
+
addItem: function (container, i, subscription) {
|
|
77
|
+
container.css({
|
|
78
|
+
overflow: 'hidden',
|
|
79
|
+
whiteSpace: 'nowrap'
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// Add a default subscription if it does not exist
|
|
83
|
+
if (!subscription.hasOwnProperty("uri")) {
|
|
84
|
+
subscription = {uri: '', type: 'include'};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
var row = $('<div>URI</div>').appendTo(container);
|
|
88
|
+
var uriField = $('<input/>',{class: "node-input-sub-uri", type: "text", style: "width: 200px; margin-left: 5px; text-align: left;"}).appendTo(row);
|
|
89
|
+
var typeField = $('<select/>',{class: "node-input-sub-type", style: "width:auto; margin-left: 5px; text-align: center;"}).appendTo(row);
|
|
90
|
+
typeField.append($("<option></option>").val('include').text('Include'));
|
|
91
|
+
typeField.append($("<option></option>").val('exclude').text('Exclude'));
|
|
92
|
+
|
|
93
|
+
// Populate the new stat
|
|
94
|
+
uriField.val(subscription.uri);
|
|
95
|
+
typeField.val(subscription.type);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// If no stat exists, create a default one
|
|
100
|
+
if (!node.subscriptions) {
|
|
101
|
+
node.subscriptions = [subscription = {uri: '', type: 'include'}];
|
|
102
|
+
}
|
|
103
|
+
// Populate list with all saved filters
|
|
104
|
+
for (let i = 0; i < node.subscriptions.length; i++) {
|
|
105
|
+
let subscription = node.subscriptions[i];
|
|
106
|
+
$("#node-input-subs-container").editableList('addItem', subscription);
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
oneditresize(size) {
|
|
110
|
+
var rows = $("#dialog-form>div:not(.node-input-subs-container-row)");
|
|
111
|
+
var height = size.height;
|
|
112
|
+
for (var i=0; i<rows.size(); i++) {
|
|
113
|
+
height -= $(rows[i]).outerHeight(true);
|
|
114
|
+
}
|
|
115
|
+
var editorRow = $("#dialog-form>div.node-input-subs-container-row");
|
|
116
|
+
height -= 4 * ((parseInt(editorRow.css("marginTop"))+parseInt(editorRow.css("marginBottom"))));
|
|
117
|
+
|
|
118
|
+
$("#node-input-subs-container").editableList('height',height);
|
|
119
|
+
},
|
|
120
|
+
oneditsave: function() {
|
|
121
|
+
let subscriptions = $("#node-input-subs-container").editableList('items');
|
|
122
|
+
let node = this;
|
|
123
|
+
node.subscriptions= [];
|
|
124
|
+
subscriptions.each(function (i) {
|
|
125
|
+
var subscription = $(this);
|
|
126
|
+
let uri = subscription.find(".node-input-sub-uri").val();
|
|
127
|
+
let type = subscription.find(".node-input-sub-type").val();
|
|
128
|
+
node.subscriptions.push({uri: uri, type: type});
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
</script>
|
|
133
|
+
|
|
134
|
+
<script type="text/x-red" data-help-name="mobius flow inject">
|
|
135
|
+
<p>Start of a MOBiUSFlow by subscribing to MOBiUS object change of value messages.</p>
|
|
136
|
+
|
|
137
|
+
<h3>Configuration Page</h3>
|
|
138
|
+
<dl class="message-properties">
|
|
139
|
+
<dt>MOBiUS <span class="property-type">node</span></dt>
|
|
140
|
+
<dd>Shared MOBiUS connection for communication with the MOBiUS Hub.</dd>
|
|
141
|
+
<dt>URI <span class="property-type">string</span></dt>
|
|
142
|
+
<dd>The MOBiUS URI of the subscription. This may contain MQTT type wildcards.</dd>
|
|
143
|
+
</dl>
|
|
144
|
+
|
|
145
|
+
<h3>Outputs</h3>
|
|
146
|
+
<ol class="node-ports">
|
|
147
|
+
<li>MOBiUS Object COV in the correct format for a MOBiUS Flow
|
|
148
|
+
<dl class="message-properties">
|
|
149
|
+
<dt>topic <span class="property-type">string</span></dt>
|
|
150
|
+
<dd>The full URI of the object.</dd>
|
|
151
|
+
<dt>payload <span class="property-type">object</span></dt>
|
|
152
|
+
<dd>The object COV.</dd>
|
|
153
|
+
</dl>
|
|
154
|
+
</li>
|
|
155
|
+
</ol>
|
|
156
|
+
|
|
157
|
+
<h3>Details</h3>
|
|
158
|
+
<p>Use this node to to subscribe to MOBiUS object COVs to start a flow using the MOBiUS rules, conditioning and cloud output nodes.</p>
|
|
159
|
+
|
|
160
|
+
<br>
|
|
161
|
+
<p align="center" style="color:#000080">iaconnects © 2019</p>
|
|
162
|
+
</script>
|