node-red-contrib-mobius-flow-base 2.5.86-beta.102 → 2.5.86-beta.105
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.
|
@@ -237,45 +237,63 @@ module.exports = function (RED) {
|
|
|
237
237
|
*/
|
|
238
238
|
node.updateNodeStatus = function (mobiusNode) {
|
|
239
239
|
node.users[mobiusNode.id] = mobiusNode;
|
|
240
|
-
let newStatus = {
|
|
241
|
-
fill: 'green',
|
|
242
|
-
shape: 'dot',
|
|
243
|
-
text: 'Connected',
|
|
244
|
-
};
|
|
245
240
|
switch (node.users[mobiusNode.id].statusType) {
|
|
246
241
|
case 'timeSinceLastActive':
|
|
247
|
-
|
|
242
|
+
node.users[mobiusNode.id].status(
|
|
243
|
+
node.buildLastActiveTimeStatus(node.users[mobiusNode.id].lastActiveTime)
|
|
244
|
+
);
|
|
248
245
|
case 'lastUri':
|
|
249
246
|
const uri = node.users[mobiusNode.id].latestUri;
|
|
250
|
-
if (uri !== '') {
|
|
251
|
-
|
|
247
|
+
if (uri !== '' && uri !== undefined) {
|
|
248
|
+
node.users[mobiusNode.id].status({
|
|
252
249
|
fill: 'green',
|
|
253
250
|
shape: 'dot',
|
|
254
251
|
text: uri,
|
|
255
|
-
};
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
case 'lastValue':
|
|
255
|
+
const value = node.users[mobiusNode.id].latestValue;
|
|
256
|
+
if (value !== '' && value !== undefined) {
|
|
257
|
+
node.users[mobiusNode.id].status({
|
|
258
|
+
fill: 'green',
|
|
259
|
+
shape: 'dot',
|
|
260
|
+
text: value,
|
|
261
|
+
});
|
|
256
262
|
}
|
|
257
263
|
}
|
|
258
|
-
node.users[mobiusNode.id].status(newStatus);
|
|
259
264
|
};
|
|
260
265
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
266
|
+
// Information update functions to be used by node status
|
|
267
|
+
node.update = {
|
|
268
|
+
/**
|
|
269
|
+
* Update a given node's node last active time
|
|
270
|
+
* @param {Object} mobiusNode - The node whos last active time is to be updated
|
|
271
|
+
*/
|
|
272
|
+
lastActiveTime: (mobiusNode) => {
|
|
273
|
+
node.users[mobiusNode.id] = mobiusNode;
|
|
274
|
+
node.users[mobiusNode.id].lastActiveTime = Date.now();
|
|
275
|
+
node.updateNodeStatus(mobiusNode);
|
|
276
|
+
},
|
|
277
|
+
/**
|
|
278
|
+
* Update a given node's node latest URI record
|
|
279
|
+
* @param {Object} mobiusNode - The node whos last URI record is to be updated
|
|
280
|
+
* @param {string} uri - The latest uri to be sent by the node
|
|
281
|
+
*/
|
|
282
|
+
latestUri: (mobiusNode, uri) => {
|
|
283
|
+
node.users[mobiusNode.id] = mobiusNode;
|
|
284
|
+
node.users[mobiusNode.id].latestUri = uri;
|
|
285
|
+
node.updateNodeStatus(mobiusNode);
|
|
286
|
+
},
|
|
287
|
+
/**
|
|
288
|
+
* Update a given node's node latest URI record
|
|
289
|
+
* @param {Object} mobiusNode - The node whos last URI record is to be updated
|
|
290
|
+
* @param {number} value - The latest value to be sent by the node
|
|
291
|
+
*/
|
|
292
|
+
latestValue: (mobiusNode, value) => {
|
|
293
|
+
node.users[mobiusNode.id] = mobiusNode;
|
|
294
|
+
node.users[mobiusNode.id].latestValue = value;
|
|
295
|
+
node.updateNodeStatus(mobiusNode);
|
|
296
|
+
},
|
|
279
297
|
};
|
|
280
298
|
|
|
281
299
|
/**
|
|
@@ -54,8 +54,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
54
54
|
</div>
|
|
55
55
|
<hr>
|
|
56
56
|
<div class="form-row">
|
|
57
|
-
<label for="node-input-statusType" style="width:
|
|
58
|
-
<select type="text" id="node-input-statusType" style="display: inline-block; width:
|
|
57
|
+
<label for="node-input-statusType" style="width: 140px;"><i class="fa fa-bars"></i> Status Display</label>
|
|
58
|
+
<select type="text" id="node-input-statusType" style="display: inline-block; width: 282px; vertical-align: center;">
|
|
59
59
|
<option value="timeSinceLastActive">Show time since last active</option>
|
|
60
60
|
<option value="lastUri">Show last URI</option>
|
|
61
61
|
</select>
|
|
@@ -36,7 +36,6 @@ module.exports = function (RED) {
|
|
|
36
36
|
this.format = n.format;
|
|
37
37
|
this.include = n.include;
|
|
38
38
|
this.serviceConn = RED.nodes.getNode(n.connection);
|
|
39
|
-
this.latestUri = '';
|
|
40
39
|
this.statusType = n.statusType;
|
|
41
40
|
var node = this;
|
|
42
41
|
|
|
@@ -47,8 +46,8 @@ module.exports = function (RED) {
|
|
|
47
46
|
text: 'Disconnected',
|
|
48
47
|
});
|
|
49
48
|
node.serviceConn.subscribeToObjectCOV(node.object, this.id, (response) => {
|
|
50
|
-
node.serviceConn.
|
|
51
|
-
node.serviceConn.
|
|
49
|
+
node.serviceConn.update.latestUri(node, response.uri);
|
|
50
|
+
node.serviceConn.update.lastActiveTime(node);
|
|
52
51
|
let allResources = _.keyBy(
|
|
53
52
|
response.value.resources,
|
|
54
53
|
node.format === 'name' ? 'name' : 'rid'
|