1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00

Tiny tidy up of RBE node

This commit is contained in:
dceejay 2015-02-14 17:56:29 +00:00
parent ba557b93c1
commit 7338a17991
4 changed files with 13 additions and 9 deletions

View File

@ -1,7 +1,8 @@
node-red-node-rbe node-red-node-rbe
================= =================
A <a href="http://nodered.org" target="_new">Node-RED</a> node that provides provides report-by-exception (RBE) and deadband capability. A <a href="http://nodered.org" target="_new">Node-RED</a> node that provides
provides report-by-exception (RBE) and deadband capability.
Install Install
------- -------
@ -14,15 +15,18 @@ Run the following command in the root directory of your Node-RED install
Usage Usage
----- -----
A simple node to provide report by exception (RBE) and deadband function - only passes on data if it has changed. A simple node to provide report by exception (RBE) and deadband function
- only passes on data if it has changed.
###RBE mode ###RBE mode
Outputs the **msg** if the **msg.payload** is different to the previous one. Works on numbers and strings. Useful for filtering out repeated messages of the same value. Saves bandwidth, etc... Outputs the **msg** if the **msg.payload** is different to the previous one.
Works on numbers and strings. Useful for filtering out repeated messages of the
same value. Saves bandwidth, etc...
###Deadband mode ###Deadband mode
In deadband mode the incoming payload should contain a parseable *number* and is In deadband mode the incoming payload should contain a parseable *number* and is
output only if greater than + or - the *band gap* away from the previous output. output only if greater than + or - the *band gap* away from the previous output.
Will accept numbers, or strings like "18.4 C" or "$500" Will accept numbers, or parseable strings like "18.4 C" or "$500"

View File

@ -1,6 +1,6 @@
{ {
"name" : "node-red-node-rbe", "name" : "node-red-node-rbe",
"version" : "0.0.1", "version" : "0.0.2",
"description" : "A Node-RED node that provides report-by-exception (RBE) and deadband capability.", "description" : "A Node-RED node that provides report-by-exception (RBE) and deadband capability.",
"dependencies" : { "dependencies" : {
}, },

View File

@ -34,9 +34,9 @@
<script type="text/x-red" data-help-name="rbe"> <script type="text/x-red" data-help-name="rbe">
<p>Report by Exception node - only passes on data if it has changed.</p> <p>Report by Exception node - only passes on data if it has changed.</p>
<p>In RBE mode this node only outputs the msg if the <b>msg.payload</b> is <p>In <b>RBE</b> mode this node only outputs the msg if the <b>msg.payload</b> is
different to the previous one. Works on numbers and strings.</p> different to the previous one. Works on numbers and strings.</p>
<p>In deadband mode the incoming payload should contain a parseable <i>number</i> and is <p>In <b>deadband</b> mode the incoming payload should contain a parseable <i>number</i> and is
output only if greater than + or - the <i>band gap</i> away from the previous output.</p> output only if greater than + or - the <i>band gap</i> away from the previous output.</p>
</script> </script>

View File

@ -33,8 +33,8 @@ module.exports = function(RED) {
} }
else { else {
var n = parseFloat(msg.payload); var n = parseFloat(msg.payload);
if (previous == null) { previous = n - node.gap; }
if (!isNaN(n)) { if (!isNaN(n)) {
if (previous == null) { previous = n - node.gap; }
if (Math.abs(n - previous) >= node.gap) { if (Math.abs(n - previous) >= node.gap) {
previous = n; previous = n;
node.send(msg); node.send(msg);