mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
redo delay node status messages to be interval based
This commit is contained in:
parent
c26852da77
commit
f12031ee9e
@ -68,10 +68,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-rate"><i class="fa fa-clock-o"></i> <span data-i18n="delay.rate"></span></label>
|
<label for="node-input-rate"><i class="fa fa-clock-o"></i> <span data-i18n="delay.rate"></span></label>
|
||||||
<input type="text" id="node-input-rate" placeholder="1" style="text-align:end; width:30px !important">
|
<input type="text" id="node-input-rate" placeholder="1" style="text-align:end; width:40px !important">
|
||||||
<label for="node-input-rateUnits"><span data-i18n="delay.msgper"></span></label>
|
<label for="node-input-rateUnits"><span data-i18n="delay.msgper"></span></label>
|
||||||
<input type="text" id="node-input-nbRateUnits" placeholder="1" style="text-align:end; width:30px !important">
|
<input type="text" id="node-input-nbRateUnits" placeholder="1" style="text-align:end; width:40px !important">
|
||||||
<select id="node-input-rateUnits" style="width:110px !important">
|
<select id="node-input-rateUnits" style="width:90px !important">
|
||||||
<option value="second" data-i18n="delay.label.units.second.singular"></option>
|
<option value="second" data-i18n="delay.label.units.second.singular"></option>
|
||||||
<option value="minute" data-i18n="delay.label.units.minute.singular"></option>
|
<option value="minute" data-i18n="delay.label.units.minute.singular"></option>
|
||||||
<option value="hour" data-i18n="delay.label.units.hour.singular"></option>
|
<option value="hour" data-i18n="delay.label.units.hour.singular"></option>
|
||||||
@ -89,9 +89,6 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="common.label.name"></span></label>
|
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="common.label.name"></span></label>
|
||||||
<input type="text" id="node-input-name" data-i18n="[placeholder]common.label.name">
|
<input type="text" id="node-input-name" data-i18n="[placeholder]common.label.name">
|
||||||
@ -114,7 +111,8 @@
|
|||||||
<p>When configured to delay messages, the delay interval can be a fixed value
|
<p>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.</p>
|
a random value within a range or dynamically set for each message.</p>
|
||||||
<p>When configured to rate limit messages, their delivery is spread across
|
<p>When configured to rate limit messages, their delivery is spread across
|
||||||
the configured time period. It can optionally discard intermediate messages as they arrive.</p>
|
the configured time period. The status shows the number of messages currently in the queue.
|
||||||
|
It can optionally discard intermediate messages as they arrive.</p>
|
||||||
</p>
|
</p>
|
||||||
<p>The rate limiting can be applied to all messages, or group them according to
|
<p>The rate limiting can be applied to all messages, or group them according to
|
||||||
their <code>msg.topic</code> value. When grouping, intermerdiate messages are
|
their <code>msg.topic</code> value. When grouping, intermerdiate messages are
|
||||||
|
@ -122,19 +122,15 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
else if (node.pauseType === "rate") {
|
else if (node.pauseType === "rate") {
|
||||||
var olddepth = 0;
|
var olddepth = 0;
|
||||||
|
node.busy = setInterval(function() {
|
||||||
|
if (node.buffer.length > 0) {
|
||||||
|
node.status({text:node.buffer.length});
|
||||||
|
}
|
||||||
|
},333);
|
||||||
node.on("input", function(msg) {
|
node.on("input", function(msg) {
|
||||||
if (!node.drop) {
|
if (!node.drop) {
|
||||||
if ( node.intervalID !== -1) {
|
if ( node.intervalID !== -1) {
|
||||||
node.buffer.push(msg);
|
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 {
|
else {
|
||||||
node.send(msg);
|
node.send(msg);
|
||||||
@ -173,6 +169,7 @@ module.exports = function(RED) {
|
|||||||
});
|
});
|
||||||
node.on("close", function() {
|
node.on("close", function() {
|
||||||
clearInterval(node.intervalID);
|
clearInterval(node.intervalID);
|
||||||
|
clearInterval(node.busy);
|
||||||
node.buffer = [];
|
node.buffer = [];
|
||||||
node.status({});
|
node.status({});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user