# node-red-contrib-boolean-logic-ultimate | # node-red-contrib-boolean-logic-ultimate | ||||
<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/> | <b>Version 0.0.7</b><br/> | ||||
- Fixed decimal error in the "Invert" node.<br/> | - Fixed decimal error in the "Invert" node.<br/> | ||||
</p> | </p> |
</script> | </script> | ||||
<script type="text/x-red" data-template-name="BooleanLogicUltimate"> | <script type="text/x-red" data-template-name="BooleanLogicUltimate"> | ||||
<div class="form-row"> | |||||
<label for="node-input-inputCount"><i class="fa fa-indent"></i> Number of different topics to evaluate</label> | |||||
<input type="text" id="node-input-inputCount" placeholder="Number of different topics to consider"> | |||||
</div> | |||||
<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-topic"><i class="fa fa-tasks"></i> Node topic</label> | |||||
<input type="text" id="node-input-topic" placeholder="Node's own topic"> | |||||
</div> | |||||
<div class="form-row"> | <div class="form-row"> | ||||
<label for="node-input-filtertrue"><i class="icon-tag"></i> Filter output result</label> | |||||
<label for="node-input-filtertrue"><i class="fa fa-filter"></i> Filter output result</label> | |||||
<select type="text" id="node-input-filtertrue" placeholder="Filter"> | <select type="text" id="node-input-filtertrue" placeholder="Filter"> | ||||
<option value="both">Output both 'true' and 'false' results</option> | <option value="both">Output both 'true' and 'false' results</option> | ||||
<option value="onlytrue">Output only 'true' results</option> | <option value="onlytrue">Output only 'true' results</option> | ||||
</select> | </select> | ||||
</div> | </div> | ||||
<div class="form-row"> | <div class="form-row"> | ||||
<input type="checkbox" id="node-input-persist" style="display:inline-block; width:auto; vertical-align:top;"> | |||||
<label style="width:auto" for="node-input-persist"> Remember latest input values after reboot</label> | |||||
<div id="helpallga"><i> 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.</div> | |||||
<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;"> | |||||
<div id="helpallga"><i> If checked, the input values are retained <br /> after a node-red reboot.<br/>If you reboot your node-red, <br />you don't need to wait all inputs <br />to arrive and initialize the node, <br />before the node can output a payload.</div> | |||||
</div> | </div> | ||||
<div class="form-row"> | |||||
<label for="node-input-inputCount"><i class="icon-tag"></i> Number of topics</label> | |||||
<input type="text" id="node-input-inputCount" placeholder="Number of topics to consider"> | |||||
</div> | |||||
<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-topic"><i class="icon-tag"></i> Topic</label> | |||||
<input type="text" id="node-input-topic" placeholder="Topic"> | |||||
</div> | |||||
</script> | </script> | ||||
<script type="text/x-red" data-help-name="BooleanLogicUltimate"> | <script type="text/x-red" data-help-name="BooleanLogicUltimate"> |
node.status({fill: "blue",shape: "ring",text: "Loaded persistent states (" + Object.keys(node.state).length + " total)."}); | node.status({fill: "blue",shape: "ring",text: "Loaded persistent states (" + Object.keys(node.state).length + " total)."}); | ||||
} | } | ||||
} catch (error) { | } catch (error) { | ||||
node.status({fill: "grey",shape: "ring",text: "No persistent states: " + error}); | |||||
node.status({fill: "grey",shape: "ring",text: "No persistent states"}); | |||||
} | } | ||||
} else { | } else { | ||||
state[topic] = value; | state[topic] = value; | ||||
// Sabe the state array to a perisistent file | |||||
// Save the state array to a perisistent file | |||||
if (this.config.persist == true) { | if (this.config.persist == true) { | ||||
try { | try { | ||||
if (!fs.existsSync("states")) fs.mkdirSync("states"); | if (!fs.existsSync("states")) fs.mkdirSync("states"); | ||||
+ " [Logic]: More than the specified " | + " [Logic]: More than the specified " | ||||
+ node.config.inputCount + " topics received, resetting. Will not output new value until " + node.config.inputCount + " new topics have been received."); | + node.config.inputCount + " topics received, resetting. Will not output new value until " + node.config.inputCount + " new topics have been received."); | ||||
node.state = {}; | node.state = {}; | ||||
DeletePersistFile(node.id); | |||||
DisplayUnkownStatus(); | DisplayUnkownStatus(); | ||||
} else { | |||||
node.status({ fill: "green", shape: "ring", text: " Arrived topic " + keyCount + " of " + node.config.inputCount}); | |||||
} | } | ||||
} | } | ||||
}); | }); | ||||
node.status( | node.status( | ||||
{ | { | ||||
fill: "gray", | fill: "gray", | ||||
shape: "dot", | |||||
text: "Unknown" | |||||
shape: "ring", | |||||
text: "Reset due to unexpected new topic" | |||||
}); | }); | ||||
}; | }; | ||||
function SetResult(_valueAND, _valueOR, _valueXOR, optionalTopic) { | function SetResult(_valueAND, _valueOR, _valueXOR, optionalTopic) { | ||||
node.status({fill: "green",shape: "dot",text: "Sent:("+"AND:" + _valueAND + " OR:" +_valueOR + " XOR:" +_valueXOR+")"}); | |||||
node.status({fill: "green",shape: "dot",text: "(AND)" + _valueAND + " (OR)" +_valueOR + " (XOR)" +_valueXOR}); | |||||
if (_valueAND!=null){ | if (_valueAND!=null){ | ||||
var msgAND = { | var msgAND = { |
{ | { | ||||
"name": "node-red-contrib-boolean-logic-ultimate", | "name": "node-red-contrib-boolean-logic-ultimate", | ||||
"version": "0.0.7", | |||||
"version": "0.0.8", | |||||
"description": "A set of Node-RED enhanced boolean logic, with persisten values after reboot and more", | "description": "A set of Node-RED enhanced boolean logic, with persisten values after reboot and more", | ||||
"author": "Supergiovane (https://github.com/Supergiovane)", | "author": "Supergiovane (https://github.com/Supergiovane)", | ||||
"dependencies": { | "dependencies": { |