Bläddra i källkod

Added trigger mode

master
Massimo 5 år sedan
förälder
incheckning
43daa6e71c
3 ändrade filer med 104 tillägg och 55 borttagningar
  1. +25
    -0
      README.md
  2. +79
    -16
      boolean-logic-ultimate/BooleanLogicUltimate.html
  3. +0
    -39
      boolean-logic-ultimate/CHANGELOG.md

+ 25
- 0
README.md Visa fil

@@ -16,6 +16,10 @@ The node performs 3 checks (<b>AND,OR,XOR</b>) on the incoming boolean payloads

The node can have a persistent input: the input values are retained after a node-red reboot. That means, that if you reboot your node-red, you don't need to wait all inputs to arrive and initialize the node, before the node can output a payload.

## FUNCTIONS
* Filter ouput results (outputs only true or trye/false)
* Trigger mode selection (Can output a payload only by single input's topic trigger and after evaluation ot other inputs, or can oputput a payload by change of every input)

## CHANGELOG
* See <a href="https://github.com/Supergiovane/node-red-contrib-boolean-logic-ultimate/blob/master/CHANGELOG.md">here the changelog</a>

@@ -31,6 +35,23 @@ Changing the topic is usually only needed when chaining multiple boolean nodes a
<li>Output only 'true' results: whenever the node receives an input, it outputs a payload <b>true</b> only if the result of the logic is true. <b>False</b> results are filtered out.</li>
</ol>
<br/>

<b>Trigger mode</b><br />
The node can acts ad a standard boolean logic or as single topic triggered boolean logic.<br/>
As single topic triggered boolean logic, the node will evaluate the inputs (and thus will output a payload) only if a specified topic input arrives.<br/>
In a coding perspectives, it acts as follows:<br/>
<code>
if (msg.topic == specified topic)<br/>
{<br/>
If (all other inputs are true) -> outputs true otherwise false<br/>
}<br/>
</code>
<ol>
<li>All topics: standard behaviour, the node will output <b>true</b> and <b>false</b> by evaluating all inputs. Each input change will trigger the node output.</li>
<li>Single topic + eval: <u>only whenever the node receives a msg input with the <b>specified topic</b> (having payload = true)</u>, it starts the evaluation of all other inputs as well and outputs the evaluated payload. If the node receives a msg input other than the <b>specified topic</b>), it only retains it's value for the boolean evaluation.</li>
</ol>
<br/><br/>

<b>Remember latest input values after reboot</b><br />
If checked, the input values are retained after a node-red reboot. That means, that if you reboot your node-red, you don't need to wait all inputs to arrive and initialize the node, before the node can output a payload.<br/>
Every time you modify the node's config, <b>the retained values are cleared</b>.<br/>
@@ -45,10 +66,14 @@ All incoming msg.payloads are converted into a boolean value according to the fo
The XOR operation operates in a one, and only one mode, i.e. (A ^ B) ^ C ... ^ n
</p>
<p>

## OTHER NODES

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

<b>Filter Ultimate</b><br />
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 />

+ 79
- 16
boolean-logic-ultimate/BooleanLogicUltimate.html Visa fil

@@ -8,22 +8,29 @@
},
filtertrue: {value:"both"},
persist: {value:true},
inputCount: {
value: 2,
required: true,
validate:
function(v) {
return !isNaN( parseInt( v ) ) && parseInt( v ) >= 2;
}
triggertopic: {
value: "trigger",
required: false
},
topic: {
value: "result",
required: true,
validate:
function(v) {
return v !== undefined && v.length > 0;
}
}
outputtriggeredby:{
value:"all",
required: false},
inputCount: {
value: 2,
required: true,
validate:
function(v) {
return !isNaN( parseInt( v ) ) && parseInt( v ) >= 2;
}
},
topic: {
value: "result",
required: true,
validate:
function(v) {
return v !== undefined && v.length > 0;
}
}
},
inputs:1,
outputs:3,
@@ -56,11 +63,37 @@
paletteLabel: function() {
return "Boolean Logic Ultimate";
},
oneditprepare: function () {
// Add write and response as default for existing nodes like was default before
if (this.outputtriggeredby === 'all') {
$("#triggertopic").hide()
}else
{
$("#triggertopic").show()
}
$("#node-input-outputtriggeredby").on('change',function() {
if ($("#node-input-outputtriggeredby").val()==="all") {
$("#triggertopic").hide()
}else{
$("#triggertopic").show()
}
})
// default
if(typeof this.outputtriggeredby === "undefined")
{
$("#node-input-outputtriggeredby").val("all");
this.outputtriggeredby="all";
}
},
oneditsave: function () {
// Delete persistent state file
$.get( "stateoperation_delete?nodeid=" +this.id, function( data ) {});
}
});
});
</script>

<script type="text/x-red" data-template-name="BooleanLogicUltimate">
@@ -83,6 +116,17 @@
<option value="onlytrue">Output only 'true' results</option>
</select>
</div>
<div class="form-row">
<label for="node-input-outputtriggeredby"><i class="fa fa-filter"></i> Trigger mode</label>
<select type="text" id="node-input-outputtriggeredby" placeholder="Event">
<option value="all">All topics</option>
<option value="onlyonetopic">Single topic + eval</option>
</select>
</div>
<div class="form-row" id="triggertopic">
<label for="node-input-triggertopic"><i class="fa fa-tasks"></i> Topic that start boolean logic evaluation</label>
<input type="text" id="node-input-triggertopic" placeholder="Input topic">
</div>
<div class="form-row">
<i class="fa fa-floppy-o"></i>
<label style="width:auto" for="node-input-persist"> Remember latest input values after reboot</label> <input type="checkbox" id="node-input-persist" style="display:inline-block; width:auto; vertical-align:top;">
@@ -111,10 +155,29 @@
</ol>
<b>filtered</b>: shown on label, means that the node will pass out only <code>true</code> values (Output only 'true' results). <br/>
<br/><br/>
<b>Trigger mode</b><br />
The node can acts ad a standard boolean logic or as single topic triggered boolean logic.<br/>
As single topic triggered boolean logic, the node will evaluate the inputs (and thus will output a payload) only if a specified topic input arrives.<br/>
In a coding perspectives, it acts as follows:<br/>
<code>
if (msg.topic == specified topic)<br/>
{<br/>
If (all other inputs are true) -> outputs true otherwise false<br/>
}<br/>
</code>
<ol>
<li>All topics: standard behaviour, the node will output <b>true</b> and <b>false</b> by evaluating all inputs. Each input change will trigger the node output.</li>
<li>Single topic + eval: <u>only whenever the node receives a msg input with the <b>specified topic</b> (having payload = true)</u>, it starts the evaluation of all other inputs as well and outputs the evaluated payload. If the node receives a msg input other than the <b>specified topic</b>), it only retains it's value for the boolean evaluation.</li>
</ol>
<br/><br/>

<b>Remember latest input values after reboot</b><br />
If checked, the input values are retained after a node-red reboot. That means, that if you reboot your node-red, you don't need to wait all inputs to arrive and initialize the node, before the node can output a payload.<br/>
Every time you modify the node's config, <b>the retained values are cleared</b>.<br/>
<br/>

All incoming msg.payloads are converted into a boolean value according to the following rules (this applies to all boolean logic nodes):
<ol>
<li>Boolean values are taken as-is.</li>

+ 0
- 39
boolean-logic-ultimate/CHANGELOG.md Visa fil

@@ -1,39 +0,0 @@
# node-red-contrib-boolean-logic-ultimate
<p>
<b>Version 1.0.0 LTS (Long term stable)</b><br/>
- For invert node, changed the category in the palette list to match the boolean logic ultimate's category<br/>
</p>
<p>
<b>Version 0.0.8</b><br/>
- Delete persistent states when a new unexpected topic arrrives<br/>
- Better status representation<br/>
- Better and clearer configuration UI <br/>
</p>
<p>
<b>Version 0.0.7</b><br/>
- Fixed decimal error in the "Invert" node.<br/>
</p>
<p>
<b>Version 0.0.6</b><br/>
- Fixed crappy "Invert" node.<br/>
</p>
<p>
<b>Version 0.0.5</b><br/>
- Bypass persistency if node-red user hasn't permissions to write to the filesystem.<br/>
</p>
<p>
<b>Version 0.0.4</b><br/>
- Fixed conflict issue if you have the old boolean logic installed<br/>
</p>
<p>
<b>Version 0.0.3</b><br/>
- Fixed status display<br/>
</p>
<p>
<b>Version 0.0.2</b><br/>
- Fixed persistent state deletion upon node update/delete<br/>
</p>
<p>
<b>Version 0.0.1</b><br/>
- Initial release<br/>
</p>

Laddar…
Avbryt
Spara