Просмотр исходного кода

Added Interrupt Flow node

master
Massimo 5 лет назад
Родитель
Сommit
8b43d6607b
5 измененных файлов: 134 добавлений и 8 удалений
  1. +5
    -0
      CHANGELOG.md
  2. +10
    -6
      README.md
  3. +58
    -0
      boolean-logic-ultimate/InterruptFlowUltimate.html
  4. +57
    -0
      boolean-logic-ultimate/InterruptFlowUltimate.js
  5. +4
    -2
      package.json

+ 5
- 0
CHANGELOG.md Просмотреть файл

@@ -1,4 +1,9 @@
# node-red-contrib-boolean-logic-ultimate

<p>
<b>Version 1.0.9</b><br/>
- Added "Interrupt Flow" node. Whenever the node receives a payload = false from a specific topic, it stops output messages to the flow. As soon it receives payload = true from this topic, the output messages start to flow out again.</br>
</p>
<p>
<b>Version 1.0.8</b><br/>
- Updated Help

+ 10
- 6
README.md Просмотреть файл

@@ -84,18 +84,22 @@ The XOR operation operates in a one, and only one mode, i.e. (A ^ B) ^ C ... ^ n
</p>
<p>

## OTHER NODES
# OTHER USEFUL NODES

**Interrupt Flow**

Whenever this node receives a payload = false from a specific topic, it stops output messages to the flow. As soon it receives payload = true from this topic, the output messages start to flow out again.

**Invert Ultimate**

<b>Invert Ultimate</b><br />
Outputs the inverted input. For example true -> false
</p>
<p>

<b>Filter Ultimate</b><br />
**Filter Ultimate**

This node has 2 outputs.<br />
If the input payload is true, the node will send <code>true</code> on output 1 and nothing on oputput 2<br />
If the input payload is false, the node will send nothing on output 1, and <code>false</code> on oputput 2<br />
</p>

[license-image]: https://img.shields.io/badge/license-MIT-blue.svg
[license-url]: https://github.com/Supergiovane/node-red-contrib-boolean-logic-ultimate/master/LICENSE

+ 58
- 0
boolean-logic-ultimate/InterruptFlowUltimate.html Просмотреть файл

@@ -0,0 +1,58 @@
<script type="text/javascript">
RED.nodes.registerType('InterruptFlowUltimate',{
category: 'boolean logic ultimate',
color: '#ff8080',
defaults: {
name: {
value: "Interrupt Flow"
},
triggertopic: {
value: "trigger"
}
},
inputs:1,
outputs:1,
outputLabels: function(i) {
var ret="";
switch (i) {
case 0:
return "True";
break;
case 1:
return "False";
break;
default:
break;
}
},
icon: "file-in.png",
label:
function() {
return (this.name||"Interrupt") + " (" + this.triggertopic + ")";
},
paletteLabel: function() {
return "InterruptFlowUltimate";
}
});
</script>

<script type="text/x-red" data-template-name="InterruptFlowUltimate">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-triggertopic"><i class="icon-tag"></i> Trigger by topic</label>
<input type="text" id="node-input-triggertopic" placeholder="Name">
<div><i>Whenever the node receives a payload = false from this topic, it stops output messages to the flow. As soon it receives payload = true from this topic, the output messages start to flow out again.</i></div>
</div>
</script>

<script type="text/x-red" data-help-name="InterruptFlowUltimate">
<p>The meaning of this node is to interrupt/reactivate flow messages.<br/>
<p>The node will stop output messages, if it receives a payload = false from the specified topic.<br/>
</p>
<a href="https://www.paypal.me/techtoday" target="_blank"><img src='https://img.shields.io/badge/Donate-PayPal-blue.svg?style=flat-square' width='30%'></a>

</script>

+ 57
- 0
boolean-logic-ultimate/InterruptFlowUltimate.js Просмотреть файл

@@ -0,0 +1,57 @@
module.exports = function(RED) {
function InterruptFlowUltimate(config) {
RED.nodes.createNode(this,config);
this.config = config;
var node = this;
setNodeStatus({ fill: "green", shape: "ring", text: "-> pass" });
node.bInviaMessaggio = true; // Send the message or not
this.on('input', function (msg) {
var sTriggerTopic = node.config.triggertopic || "trigger"; // Topic controlling the bInviaMessaggio
if (msg.hasOwnProperty("topic")) {
// 06/11/2019
if (msg.topic==sTriggerTopic && ToBoolean(msg.payload)===true) {
node.bInviaMessaggio = true;
setNodeStatus({ fill: "green", shape: "dot", text: "-> pass" });
return;
} else if (msg.topic==sTriggerTopic && ToBoolean(msg.payload)===false){
node.bInviaMessaggio = false;
setNodeStatus({ fill: "red", shape: "dot", text: "|| stop" });
return;
}
}
if (node.bInviaMessaggio) node.send(msg);
});
function setNodeStatus({fill, shape, text})
{
var dDate = new Date();
node.status({fill: fill,shape: shape,text: text + " (" + dDate.getDate() + ", " + dDate.toLocaleTimeString() + ")"})
}

function ToBoolean( value ) {
var res = false;
if (typeof value === 'boolean') {
res = value;
}
else if( typeof value === 'number' || typeof value === 'string' ) {
// Is it formated as a decimal number?
if( decimal.test( value ) ) {
var v = parseFloat( value );
res = v != 0;
}
else {
res = value.toLowerCase() === "true";
}
}
return res;
};
}

RED.nodes.registerType("InterruptFlowUltimate",InterruptFlowUltimate);
}

+ 4
- 2
package.json Просмотреть файл

@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-boolean-logic-ultimate",
"version": "1.0.8",
"version": "1.0.9",
"description": "A set of Node-RED enhanced boolean logic, with persisten values after reboot and more",
"author": "Supergiovane (https://github.com/Supergiovane)",
"dependencies": {
@@ -22,7 +22,9 @@
"nodes": {
"BooleanLogicUltimate": "boolean-logic-ultimate/BooleanLogicUltimate.js",
"InvertUltimate": "boolean-logic-ultimate/InvertUltimate.js",
"FilterUltimate": "boolean-logic-ultimate/FilterUltimate.js"
"FilterUltimate": "boolean-logic-ultimate/FilterUltimate.js",
"InterruptFlowUltimate": "boolean-logic-ultimate/InterruptFlowUltimate.js"
}
}
}

Загрузка…
Отмена
Сохранить