Explorar el Código

Output the entire message input, replacing only topic and payload.

master
Massimo hace 4 años
padre
commit
bee3172a6c
Se han modificado 5 ficheros con 67 adiciones y 33 borrados
  1. +5
    -0
      CHANGELOG.md
  2. +43
    -21
      boolean-logic-ultimate/BooleanLogicUltimate.js
  3. +10
    -9
      boolean-logic-ultimate/FilterUltimate.js
  4. +8
    -2
      boolean-logic-ultimate/InvertUltimate.js
  5. +1
    -1
      package.json

+ 5
- 0
CHANGELOG.md Ver fichero

@@ -3,6 +3,11 @@

<a href="http://eepurl.com/gJm095" target="_blank">Subscribe to my channel.</a> Only news about my nodes, no spam, no ads. I'm a github developer, not a merchant.

<p>
<b>Version 1.0.12</b><br/>
- Boolean Logic, FilterUltimate and InvertUltimate now output the entire message input, replacing only topic and payload.</br>
</p>
<p>
<p>
<b>Version 1.0.11</b><br/>
- Enhanced help.</br>

+ 43
- 21
boolean-logic-ultimate/BooleanLogicUltimate.js Ver fichero

@@ -104,14 +104,14 @@ module.exports = function(RED) {
&& msg.hasOwnProperty("topic") && msg.topic !==""
&& node.config.triggertopic === msg.topic)
{
SetResult(resAND, resOR, resXOR, node.config.topic);
SetResult(resAND, resOR, resXOR, node.config.topic,msg);
} else
{
setNodeStatus({ fill: "grey", shape: "ring", text: "Saved (" + (msg.hasOwnProperty("topic") ? msg.topic : "empty input topic") + ") " + value});
}
} else
{
SetResult(resAND, resOR, resXOR, node.config.topic);
SetResult(resAND, resOR, resXOR, node.config.topic,msg);
}
}
else if(keyCount > node.config.inputCount ) {
@@ -237,31 +237,53 @@ module.exports = function(RED) {
return res;
};
function SetResult(_valueAND, _valueOR, _valueXOR, optionalTopic) {
function SetResult(_valueAND, _valueOR, _valueXOR, optionalTopic,_msg) {
setNodeStatus({fill: "green",shape: "dot",text: "(AND)" + _valueAND + " (OR)" +_valueOR + " (XOR)" +_valueXOR});
if (_valueAND!=null){
var msgAND = {
topic: optionalTopic === undefined ? "result" : optionalTopic,
operation:"AND",
payload: _valueAND
};
// 24/01/2020 Output the entire input msg by duplicating the input and replacing only relevant fields.
if (_valueAND != null) {
var msgAND = RED.util.cloneMessage(_msg);
msgAND.topic = optionalTopic === undefined ? "result" : optionalTopic;
msgAND.operation = "AND";
msgAND.payload = _valueAND;
}
if (_valueOR!=null){
var msgOR = {
topic: optionalTopic === undefined ? "result" : optionalTopic,
operation:"OR",
payload: _valueOR
};
var msgOR = RED.util.cloneMessage(_msg);
msgOR.topic = optionalTopic === undefined ? "result" : optionalTopic;
msgOR.operation = "OR";
msgOR.payload= _valueOR;
}
if (_valueXOR!=null){
var msgXOR = {
topic: optionalTopic === undefined ? "result" : optionalTopic,
operation:"XOR",
payload: _valueXOR
};
if (_valueXOR != null) {
var msgXOR = RED.util.cloneMessage(_msg);
msgXOR.topic = optionalTopic === undefined ? "result" : optionalTopic;
msgXOR.operation = "XOR";
msgXOR.payload= _valueXOR;
}
node.send([msgAND,msgOR,msgXOR]);
node.send([msgAND, msgOR, msgXOR]);
// if (_valueAND!=null){
// var msgAND = {
// topic: optionalTopic === undefined ? "result" : optionalTopic,
// operation:"AND",
// payload: _valueAND
// };
// }
// if (_valueOR!=null){
// var msgOR = {
// topic: optionalTopic === undefined ? "result" : optionalTopic,
// operation:"OR",
// payload: _valueOR
// };
// }
// if (_valueXOR!=null){
// var msgXOR = {
// topic: optionalTopic === undefined ? "result" : optionalTopic,
// operation:"XOR",
// payload: _valueXOR
// };
// }
// node.send([msgAND,msgOR,msgXOR]);
};
}

+ 10
- 9
boolean-logic-ultimate/FilterUltimate.js Ver fichero

@@ -13,16 +13,17 @@ module.exports = function(RED) {
if (typeof msg.payload !== "undefined") {
var bRes = ToBoolean(msg.payload);
if (typeof bRes === "undefined") return;
var msgTrue = {
topic: sTopic,
payload: true
};
var msgFalse = {
topic: sTopic,
payload: false
};
// 24/01/2020 Clone input message and replace only relevant topics
var msgTrue = RED.util.cloneMessage(msg);
msgTrue.topic = sTopic;
msgTrue.payload = true;
var msgFalse = RED.util.cloneMessage(msg);
msgFalse.topic = sTopic;
msgFalse.payload = false;
if (bRes === true) {
setNodeStatus( {fill: "green" ,shape: "dot" ,text: "(Send) true,null"});
setNodeStatus({ fill: "green", shape: "dot", text: "(Send) true,null" });
node.send([msgTrue, null]);
} else
{

+ 8
- 2
boolean-logic-ultimate/InvertUltimate.js Ver fichero

@@ -10,8 +10,14 @@ module.exports = function(RED) {
var topic = msg.topic || "";
var payload = msg.payload;
if (topic !== undefined && payload !== undefined) {
setNodeStatus( {fill: "green" ,shape: "dot" ,text: "(Send) " + !ToBoolean(payload)});
node.send({ topic: topic, payload: !ToBoolean(payload) });
setNodeStatus({ fill: "green", shape: "dot", text: "(Send) " + !ToBoolean(payload) });
// 24/01/2020 Clone input message and replace only relevant topics
var msgOUt = RED.util.cloneMessage(msg);
msgOUt.topic = topic;
msgOUt.payload = !ToBoolean(payload);
node.send(msgOUt);
return;
}
});

+ 1
- 1
package.json Ver fichero

@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-boolean-logic-ultimate",
"version": "1.0.11",
"version": "1.0.12",
"description": "A set of Node-RED enhanced boolean logic, with persisten values after reboot and more",
"author": "Supergiovane (https://github.com/Supergiovane)",
"dependencies": {

Cargando…
Cancelar
Guardar