From f12031ee9eec58c3c9f6241188f9e8a60530516e Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Wed, 14 Jun 2017 22:25:44 +0100 Subject: [PATCH] redo delay node status messages to be interval based --- nodes/core/core/89-delay.html | 26 ++++++++++++-------------- nodes/core/core/89-delay.js | 15 ++++++--------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/nodes/core/core/89-delay.html b/nodes/core/core/89-delay.html index d64207517..8b468d0ea 100644 --- a/nodes/core/core/89-delay.html +++ b/nodes/core/core/89-delay.html @@ -59,19 +59,19 @@
-
- - -
+
+ + +
- + - - +
- - -
@@ -114,7 +111,8 @@

When configured to delay messages, the delay interval can be a fixed value a random value within a range or dynamically set for each message.

When configured to rate limit messages, their delivery is spread across - the configured time period. It can optionally discard intermediate messages as they arrive.

+ the configured time period. The status shows the number of messages currently in the queue. + It can optionally discard intermediate messages as they arrive.

The rate limiting can be applied to all messages, or group them according to their msg.topic value. When grouping, intermerdiate messages are diff --git a/nodes/core/core/89-delay.js b/nodes/core/core/89-delay.js index 96928fc97..4abb39808 100644 --- a/nodes/core/core/89-delay.js +++ b/nodes/core/core/89-delay.js @@ -122,19 +122,15 @@ module.exports = function(RED) { } else if (node.pauseType === "rate") { var olddepth = 0; + node.busy = setInterval(function() { + if (node.buffer.length > 0) { + node.status({text:node.buffer.length}); + } + },333); node.on("input", function(msg) { if (!node.drop) { if ( node.intervalID !== -1) { node.buffer.push(msg); - if ((node.rate >= 200) && (node.buffer.length > 0)) { - node.status({text:node.buffer.length}); - } - else { - if (!olddepth) { - node.status({fill:"blue",shape:"dot"}); - olddepth = 1; - } - } } else { node.send(msg); @@ -173,6 +169,7 @@ module.exports = function(RED) { }); node.on("close", function() { clearInterval(node.intervalID); + clearInterval(node.busy); node.buffer = []; node.status({}); });