node-red-contrib-mobius-flow-base 2.5.91 → 3.0.0-beta.12

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.
Files changed (39) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.md +16 -0
  2. package/.github/ISSUE_TEMPLATE/feature_request.md +16 -0
  3. package/.github/ISSUE_TEMPLATE/general.md +7 -0
  4. package/.github/workflows/build_publish.yml +80 -0
  5. package/README.md +4 -10
  6. package/dist/engine-api-calls.d.ts +18 -0
  7. package/dist/engine-api-calls.js +214 -0
  8. package/dist/engine-api-client.d.ts +7 -0
  9. package/dist/engine-api-client.js +92 -0
  10. package/dist/engine-websocket.d.ts +58 -0
  11. package/dist/engine-websocket.js +226 -0
  12. package/dist/node-red-ui-funcs.js +180 -0
  13. package/dist/nodes/common/mobsearch.js +576 -0
  14. package/dist/nodes/mobius-clear-resource.html +22 -3
  15. package/dist/nodes/mobius-clear-resource.js +17 -12
  16. package/dist/nodes/mobius-connection.html +30 -8
  17. package/dist/nodes/mobius-connection.js +194 -85
  18. package/dist/nodes/mobius-discover-object-list.html +185 -126
  19. package/dist/nodes/mobius-discover-object-list.js +24 -5
  20. package/dist/nodes/mobius-discover.js +7 -7
  21. package/dist/nodes/mobius-filter-by-rid-value.html +57 -41
  22. package/dist/nodes/mobius-filter-by-rid-value.js +38 -31
  23. package/dist/nodes/mobius-flow-inject.html +32 -2
  24. package/dist/nodes/mobius-get-multi-object.html +39 -5
  25. package/dist/nodes/mobius-get-multi-resource.html +36 -4
  26. package/dist/nodes/mobius-get-multi-resource.js +13 -12
  27. package/dist/nodes/mobius-get-object.html +25 -3
  28. package/dist/nodes/mobius-get-object.js +12 -9
  29. package/dist/nodes/mobius-get-resource.html +26 -3
  30. package/dist/nodes/mobius-get-resource.js +17 -12
  31. package/dist/nodes/mobius-object-cov.html +27 -3
  32. package/dist/nodes/mobius-object-cov.js +9 -6
  33. package/dist/nodes/mobius-resource-cov.html +23 -3
  34. package/dist/nodes/mobius-resource-cov.js +5 -5
  35. package/dist/nodes/mobius-set-multi-resource.html +24 -3
  36. package/dist/nodes/mobius-set-multi-resource.js +9 -11
  37. package/dist/nodes/mobius-set-resource.html +24 -3
  38. package/package.json +13 -7
  39. package/dist/nodes/node-red-ui-discover-devices.js +0 -103
@@ -63,72 +63,81 @@ POSSIBILITY OF SUCH DAMAGE.
63
63
  </script>
64
64
 
65
65
  <script type="text/javascript">
66
- RED.nodes.registerType('mobius filter by rid value',{
66
+ RED.nodes.registerType('mobius filter by rid value', {
67
67
  category: 'mobius',
68
- color:"#8abff5",
68
+ color: '#8abff5',
69
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}
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: {
78
+ value: '',
79
+ validate: function (v) {
80
+ if (v === '') {
81
+ return true;
82
+ }
83
+ let parts = v.split('/');
84
+ for (let lp = 0; lp < parts.length; lp++) {
85
+ if (parts[lp] === null || parts[lp] === '') {
86
+ return false;
87
+ }
88
+ }
89
+ if (parts.length === 2) {
90
+ return true;
91
+ }
92
+ return false;
93
+ },
94
+ },
95
+ connection: { type: 'mobius connection', required: true },
87
96
  },
88
- inputs:1,
89
- outputs:1,
97
+ inputs: 1,
98
+ outputs: 1,
90
99
  outputLabels: function (index) {
91
- if(index === 0) return ("Filtered object list");
92
- if(index === 1) return ("Full MOBiUS response");
100
+ if (index === 0) return 'Filtered object list';
101
+ if (index === 1) return 'Full MOBiUS response';
93
102
  },
94
- icon: "mobius.png",
95
- align: "left",
103
+ icon: 'mobius.png',
104
+ align: 'left',
96
105
  paletteLabel: 'filter by rid value',
97
- label: function() {
98
- if(this.name) {
106
+ label: function () {
107
+ if (this.name) {
99
108
  return this.name;
100
109
  } else {
101
- return this.service ? `Filter - ${this.service} by RID ${this.rid}` : "filter by rid value";
110
+ return this.service ? `Filter - ${this.service} by RID ${this.rid}` : 'filter by rid value';
102
111
  }
103
112
  },
104
- labelStyle: function() {
105
- return this.name ? "node_label_italic":"";
113
+ labelStyle: function () {
114
+ return this.name ? 'node_label_italic' : '';
106
115
  },
107
- oneditprepare: function() {
108
- $("#node-input-pids").typedInput({
109
- type:"json",
110
- types:["json"]
116
+ oneditprepare: function () {
117
+ $('#node-input-pids').typedInput({
118
+ type: 'json',
119
+ types: ['json'],
111
120
  });
112
121
  this.editor = RED.editor.createEditor({
113
122
  id: 'node-input-func-editor',
114
123
  mode: 'ace/mode/javascript',
115
- value: this.func
124
+ value: this.func,
116
125
  });
117
126
  },
118
- oneditsave: function() {
119
- if($("#node-input-detailedOutput").prop('checked')) {
120
- $("#node-input-outputs").val(2);
127
+ oneditsave: function () {
128
+ if ($('#node-input-detailedOutput').prop('checked')) {
129
+ $('#node-input-outputs').val(2);
121
130
  } else {
122
- $("#node-input-outputs").val(1);
131
+ $('#node-input-outputs').val(1);
123
132
  }
124
133
  this.func = this.editor.getValue();
125
134
  this.editor.destroy();
126
135
  delete this.editor;
127
136
  },
128
- oneditcancel: function() {
137
+ oneditcancel: function () {
129
138
  this.editor.destroy();
130
139
  delete this.editor;
131
- }
140
+ },
132
141
  });
133
142
  </script>
134
143
 
@@ -197,6 +206,13 @@ POSSIBILITY OF SUCH DAMAGE.
197
206
  </ol>
198
207
 
199
208
  <h3>Details</h3>
209
+ <p>
210
+ The <code>Function</code> configuration property is string containing the JavaScript function used to test the resource value. The function must return <b>true</b> or <b>false</b>.
211
+ A few examples are shown below (The name v is used to represent the resource values in the following example. You can use any identifier of your choice):</br>
212
+ <code>(v) => { return v === 5; }</code><br>
213
+ <code>function test (v) { return v > 10 && v < 100; }</code><br>
214
+ <code>(v) => { return v.includes('test-string'); }</code>
215
+ </p>
200
216
  <p>Outputs 3 and 4 are only sent if <b>Use detailed outputs</b> is checked on the configuration page.</p>
201
217
  <p>Outputs 1, 2 and 3 are only sent if no error occurs. The <b>error</b> property in output 4
202
218
  can be used to determine if an error has occurred.</p>
@@ -24,13 +24,13 @@
24
24
  POSSIBILITY OF SUCH DAMAGE.
25
25
  **/
26
26
 
27
- // <input type="text" id="node-input-func" placeholder="Function used for filtering (return $PV === 0)">
27
+ // <input type="text" id="node-input-func" placeholder="Function used for filtering (return $PV === 0)">
28
28
 
29
29
  /* jshint elision: true */
30
30
  'use strict';
31
31
 
32
32
  module.exports = function (RED) {
33
- function MobiusFilterNode (n) {
33
+ function MobiusFilterNode(n) {
34
34
  RED.nodes.createNode(this, n);
35
35
  this.detailedOutput = n.detailedOutput;
36
36
  this.service = n.service;
@@ -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.on('input', function (msg) {
@@ -75,38 +75,45 @@ module.exports = function (RED) {
75
75
  node.status({
76
76
  fill: 'green',
77
77
  shape: 'ring',
78
- text: 'Busy'
78
+ text: 'Busy',
79
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
- ]);
80
+ node.serviceConn.filterObjectsByRIDValue(
81
+ uri,
82
+ pids,
83
+ rid,
84
+ limit,
85
+ eval('(' + func + ')'),
86
+ (err, response) => {
87
+ if (err) {
88
+ node.status({
89
+ fill: 'yellow',
90
+ shape: 'dot',
91
+ text: 'Error: ' + JSON.stringify(err.code),
92
+ });
93
+ if (node.detailedOutput === true) {
94
+ node.send([null, { topic: uri, payload: { error: true, response: err } }]);
95
+ }
105
96
  } else {
106
- node.send({ topic: uri, payload: uriList });
97
+ node.status({
98
+ fill: 'green',
99
+ shape: 'dot',
100
+ text: JSON.stringify(response.uri),
101
+ });
102
+ let uriList = [];
103
+ for (let lp = 0; lp < response.value.length; lp++) {
104
+ uriList.push(`${response.uri}/${response.value[lp].pid}/${response.value[lp].ins}`);
105
+ }
106
+ if (node.detailedOutput === true) {
107
+ node.send([
108
+ { topic: uri, payload: uriList },
109
+ { topic: uri, payload: { error: false, response: response } },
110
+ ]);
111
+ } else {
112
+ node.send({ topic: uri, payload: uriList });
113
+ }
107
114
  }
108
115
  }
109
- });
116
+ );
110
117
  });
111
118
 
112
119
  node.serviceConn.register(node);
@@ -34,10 +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 class="form-row node-input-subs-container-row">
37
+ <div id="node-input-subs-container-row" 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>
41
43
  </script>
42
44
 
43
45
  <script type="text/javascript">
@@ -67,7 +69,7 @@ POSSIBILITY OF SUCH DAMAGE.
67
69
  },
68
70
  oneditprepare: function () {
69
71
  var node = this;
70
-
72
+ let mobiusSrvc = $("#node-input-connection").val();
71
73
  /** Create the subs container and populate it */
72
74
  $('#node-input-subs-container').css('min-height', '300px').css('min-width', '450px').editableList ({
73
75
  addButton: "add",
@@ -86,6 +88,11 @@ POSSIBILITY OF SUCH DAMAGE.
86
88
 
87
89
  var row = $('<div>URI</div>').appendTo(container);
88
90
  var uriField = $('<input/>',{class: "node-input-sub-uri", type: "text", style: "width: 200px; margin-left: 5px; text-align: left;"}).appendTo(row);
91
+
92
+ // *** MOBSEARCH *** //
93
+ var searchField = $('<a class="searchbutton" style="margin-left: 5px; vertical-align: middle"><i id="node-lookup-instance-icon" class="fa fa-search"></i></a>').appendTo(row);
94
+ // *** END MOBSEARCH *** //
95
+
89
96
  var typeField = $('<select/>',{class: "node-input-sub-type", style: "width:auto; margin-left: 5px; text-align: center;"}).appendTo(row);
90
97
  typeField.append($("<option></option>").val('include').text('Include'));
91
98
  typeField.append($("<option></option>").val('exclude').text('Exclude'));
@@ -93,6 +100,15 @@ POSSIBILITY OF SUCH DAMAGE.
93
100
  // Populate the new stat
94
101
  uriField.val(subscription.uri);
95
102
  typeField.val(subscription.type);
103
+
104
+ // *** MOBSEARCH *** //
105
+
106
+ if (!node.subscriptions[i]) {
107
+ node.subscriptions[i] = {uri: '', type: 'include'}
108
+ }
109
+
110
+ addMobsearchListButton(searchField, i, mobsearchOpts)
111
+ // *** END MOBSEARCH *** //
96
112
  }
97
113
  });
98
114
 
@@ -100,6 +116,20 @@ POSSIBILITY OF SUCH DAMAGE.
100
116
  if (!node.subscriptions) {
101
117
  node.subscriptions = [subscription = {uri: '', type: 'include'}];
102
118
  }
119
+
120
+ // *** MOBSEARCH *** //
121
+
122
+ mobsearchOpts = {
123
+ htmlElementId: 'mobsearch',
124
+ list: node.subscriptions,
125
+ containerRowName: 'node-input-subs-container-row',
126
+ containerName: 'node-input-subs-container',
127
+ containerSecondFieldName: 'node-input-sub-type',
128
+ };
129
+ initMobsearch.toIns_listed(mobiusSrvc, mobsearchOpts);
130
+
131
+ // *** END MOBSEARCH *** //
132
+
103
133
  // Populate list with all saved filters
104
134
  for (let i = 0; i < node.subscriptions.length; i++) {
105
135
  let subscription = node.subscriptions[i];
@@ -34,12 +34,16 @@ 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 class="form-row node-input-mobjects-container-row">
37
+ <div id="node-input-mobjects-container-row" 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>
41
43
  </script>
42
44
 
45
+ <script src="common/mobsearch.js"></script>
46
+
43
47
  <script type="text/javascript">
44
48
  RED.nodes.registerType('mobius get multi-object', {
45
49
  category: 'mobius',
@@ -67,11 +71,12 @@ POSSIBILITY OF SUCH DAMAGE.
67
71
  },
68
72
  oneditprepare: function () {
69
73
  var node = this;
74
+ let mobiusSrvc = $("#node-input-connection").val();
70
75
 
71
76
  /** Resize a object when it has changed */
72
77
  function resizeObject (mobject) {
73
78
  let newWidth = mobject.width();
74
- mobject.find(".node-input-mobject-comment").width(newWidth - 270);
79
+ mobject.find(".node-input-mobject-comment").width(newWidth - 300);
75
80
  }
76
81
 
77
82
  /** Create the objects container and populate it */
@@ -92,21 +97,50 @@ POSSIBILITY OF SUCH DAMAGE.
92
97
 
93
98
  var row = $('<div>URI</div>').appendTo(container);
94
99
  var uriField = $('<input/>',{class: "node-input-mobject-uri", type: "text", style: "width: 200px; margin-left: 5px; text-align: left;"}).appendTo(row);
100
+
101
+ // *** MOBSEARCH *** //
102
+ var searchField = $('<a class="searchbutton" style="margin-left: 5px; vertical-align: middle"><i id="node-lookup-instance-icon" class="fa fa-search"></i></a>').appendTo(row);
103
+ // *** END MOBSEARCH *** //
104
+
95
105
  row.append('&nbsp;&nbsp;-&nbsp;');
96
- var commentField = $('<input/>',{class: "node-input-mobject-comment", type: "text", style: "margin-left: 5px; text-align: left;"}).appendTo(row);
106
+ var commentField = $('<input/>',{class: "node-input-mobject-comment", type: "text", style: "width: 35%; margin-left: 5px; text-align: left;"}).appendTo(row);
97
107
 
98
108
  // Populate the new stat
99
109
  uriField.val(mobject.uri);
100
110
  commentField.val(mobject.comment);
101
- resizeObject(container);
111
+ // resizeObject(container);
112
+
113
+ // *** MOBSEARCH *** //
114
+
115
+ if (!node.mobjects[i]) {
116
+ node.mobjects[i] = {uri: '', comment: ''}
117
+ }
118
+
119
+ addMobsearchListButton(searchField, i, mobsearchOpts)
120
+ // *** END MOBSEARCH *** //
121
+
102
122
  },
103
- resizeItem: resizeObject
123
+ // resizeItem: resizeObject
104
124
  });
105
125
 
106
126
  // If no mobjects exists, create a default one
107
127
  if (!node.mobjects) {
108
128
  node.mobjects = [mobject = {uri: '', comment: ''}];
109
129
  }
130
+
131
+ // *** MOBSEARCH *** //
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
144
  // Populate list with all saved filters
111
145
  for (let i = 0; i < node.mobjects.length; i++) {
112
146
  let mobject = node.mobjects[i];
@@ -41,12 +41,16 @@ POSSIBILITY OF SUCH DAMAGE.
41
41
  <option value="object">Object - Resource PVs, URIs and Names</option>
42
42
  </select>
43
43
  </div>
44
- <div class="form-row node-input-resources-container-row">
44
+ <div id="node-input-resources-container-row" 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>
48
50
  </script>
49
51
 
52
+ <script src="common/mobsearch.js"></script>
53
+
50
54
  <script type="text/javascript">
51
55
  RED.nodes.registerType('mobius get multi-resource', {
52
56
  category: 'mobius',
@@ -75,6 +79,7 @@ POSSIBILITY OF SUCH DAMAGE.
75
79
  },
76
80
  oneditprepare: function () {
77
81
  var node = this;
82
+ let mobiusSrvc = $("#node-input-connection").val();
78
83
 
79
84
  /** Resize a resource when it has changed */
80
85
  function resizeResource (resource) {
@@ -100,21 +105,48 @@ POSSIBILITY OF SUCH DAMAGE.
100
105
 
101
106
  var row = $('<div>URI</div>').appendTo(container);
102
107
  var uriField = $('<input/>',{class: "node-input-resource-uri", type: "text", style: "width: 200px; margin-left: 5px; text-align: left;"}).appendTo(row);
108
+
109
+ // *** MOBSEARCH *** //
110
+ var searchField = $('<a class="searchbutton" style="margin-left: 5px; vertical-align: middle"><i id="node-lookup-instance-icon" class="fa fa-search"></i></a>').appendTo(row);
111
+ // *** END MOBSEARCH *** //
112
+
103
113
  row.append('&nbsp;&nbsp;-&nbsp;');
104
- var commentField = $('<input/>',{class: "node-input-resource-comment", type: "text", style: "margin-left: 5px; text-align: left;"}).appendTo(row);
114
+ var commentField = $('<input/>',{class: "node-input-resource-comment", type: "text", style: "width: 35%; margin-left: 5px; text-align: left;"}).appendTo(row);
105
115
 
106
116
  // Populate the new stat
107
117
  uriField.val(resource.uri);
108
118
  commentField.val(resource.comment);
109
- resizeResource(container);
119
+ //resizeResource(container);
120
+
121
+ // *** MOBSEARCH *** //
122
+ if (!node.resources[i]) {
123
+ node.resources[i] = {uri: '', comment: ''}
124
+ }
125
+ addMobsearchListButton(searchField, i, mobsearchOpts)
126
+ // *** END MOBSEARCH *** //
127
+
110
128
  },
111
- resizeItem: resizeResource
129
+ // resizeItem: resizeResource
112
130
  });
113
131
 
114
132
  // If no stat exists, create a default one
115
133
  if (!node.resources) {
116
134
  node.resources = [resource = {uri: '', comment: ''}];
117
135
  }
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
150
  // Populate list with all saved filters
119
151
  for (let i = 0; i < node.resources.length; i++) {
120
152
  let resource = node.resources[i];
@@ -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();
@@ -69,26 +69,27 @@ module.exports = function (RED) {
69
69
  }
70
70
  Promise.all(promiseChain)
71
71
  .then((values) => {
72
+ console.log(values);
72
73
  node.status({
73
74
  fill: 'green',
74
75
  shape: 'dot',
75
- text: 'Done'
76
+ text: 'Done',
76
77
  });
77
78
  if (node.sendFormat === 'array') {
78
- node.send({topic: msg.topic, payload: values});
79
+ node.send({ topic: msg.topic, payload: values });
79
80
  } else {
80
81
  let payload = values.reduce((obj, item) => {
81
82
  obj[item.uri] = { pv: item.pv, name: item.name };
82
83
  return obj;
83
84
  }, {});
84
- node.send({topic: msg.topic, payload: payload});
85
+ node.send({ topic: msg.topic, payload: payload });
85
86
  }
86
87
  })
87
88
  .catch((err) => {
88
89
  node.status({
89
90
  fill: 'yellow',
90
91
  shape: 'dot',
91
- text: 'Error: ' + JSON.stringify(err.code)
92
+ text: 'Error: ' + JSON.stringify(err.code),
92
93
  });
93
94
  node.error('Mobius error reading resource ' + JSON.stringify(err));
94
95
  })
@@ -107,7 +108,7 @@ module.exports = function (RED) {
107
108
  }
108
109
  }
109
110
 
110
- function validateResourceURI (uri) {
111
+ function validateResourceURI(uri) {
111
112
  let parts = uri.split('/');
112
113
  for (let lp = 0; lp < parts.length; lp++) {
113
114
  if (parts[lp] === null || parts[lp] === '') {
@@ -120,16 +121,16 @@ module.exports = function (RED) {
120
121
  return false;
121
122
  }
122
123
 
123
- function readResource (node, uri) {
124
+ function readResource(node, uri) {
124
125
  return new Promise((resolve, reject) => {
125
126
  node.serviceConn.readResource(uri, (err, response) => {
126
127
  if (err) {
127
128
  reject(err);
128
129
  } else {
129
130
  if (node.sendFormat === 'array') {
130
- resolve(response.value.pv);
131
+ resolve(response.data.pv);
131
132
  } else {
132
- resolve({uri: uri, pv: response.value.pv, name: response.value.name});
133
+ resolve({ uri: uri, pv: response.data.pv, name: response.data.name });
133
134
  }
134
135
  }
135
136
  });
@@ -29,10 +29,18 @@ 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
- <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)">
32
+
33
+ <hr>
34
+
35
+ <div id="instance-row">
36
+ <div class="form-row" id="input-row">
37
+ <label for="node-input-mobject"><i class="fa fa-tasks"></i> URI</label>
38
+ <input type="text" id="node-input-mobject" style="width:61%;" placeholder="Object URI (hid/sid/pid/ins)">
39
+ </div>
35
40
  </div>
41
+
42
+ <div id="mobsearch"></div>
43
+
36
44
  <div class="form-row">
37
45
  <label for="node-input-format"><i class="fa fa-bars"></i> Format</label>
38
46
  <select type="text" id="node-input-format" style="display: inline-block; width: auto; vertical-align: center;">
@@ -40,6 +48,7 @@ POSSIBILITY OF SUCH DAMAGE.
40
48
  <option value="rid">By RID</option>
41
49
  </select>
42
50
  </div>
51
+
43
52
  <div class="form-row">
44
53
  <label>&nbsp;</label>
45
54
  <input type="checkbox" id="node-input-detailedOutput" style="display: inline-block; width: auto; vertical-align: top;">
@@ -52,6 +61,8 @@ POSSIBILITY OF SUCH DAMAGE.
52
61
  </div>
53
62
  </script>
54
63
 
64
+ <script src="common/mobsearch.js"></script>
65
+
55
66
  <script type="text/javascript">
56
67
  RED.nodes.registerType('mobius get object',{
57
68
  category: 'mobius',
@@ -92,6 +103,17 @@ POSSIBILITY OF SUCH DAMAGE.
92
103
  labelStyle: function() {
93
104
  return this.name ? "node_label_italic":"";
94
105
  },
106
+ oneditprepare: function () {
107
+ var node = this;
108
+ let mobiusSrvc = $("#node-input-connection").val();
109
+
110
+ opts = {
111
+ htmlElementId: 'mobsearch',
112
+ uriFieldName: 'node-input-mobject',
113
+ inputRowId: 'input-row',
114
+ };
115
+ initMobsearch.toIns(mobiusSrvc, opts);
116
+ },
95
117
  oneditsave: function() {
96
118
  if($("#node-input-detailedOutput").prop('checked')) {
97
119
  this.outputs = 3;