@mschaeffler/node-red-logic 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/logic_not.html +97 -0
- package/logic_not.js +51 -0
- package/math_minus.html +83 -0
- package/math_minus.js +54 -0
- package/package.json +3 -1
package/logic_not.html
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
RED.nodes.registerType('not',{
|
|
3
|
+
category: 'function',
|
|
4
|
+
color: "#C0DEED",
|
|
5
|
+
defaults: {
|
|
6
|
+
name:{value:""},
|
|
7
|
+
property:{value:"payload",required:true},
|
|
8
|
+
showState:{value:false},
|
|
9
|
+
filter:{value:false}
|
|
10
|
+
},
|
|
11
|
+
inputs:1,
|
|
12
|
+
outputs:1,
|
|
13
|
+
icon: "font-awesome/fa-exclamation",
|
|
14
|
+
label: function() {
|
|
15
|
+
return this.name||"not";
|
|
16
|
+
},
|
|
17
|
+
labelStyle: function() {
|
|
18
|
+
return this.name?"node_label_italic":"";
|
|
19
|
+
},
|
|
20
|
+
paletteLabel: "not",
|
|
21
|
+
inputLabels: 'input',
|
|
22
|
+
outputLabels: 'boolean',
|
|
23
|
+
oneditprepare: function() {
|
|
24
|
+
$("#node-input-property").typedInput({
|
|
25
|
+
type:"msg",
|
|
26
|
+
types:["msg"],
|
|
27
|
+
typeField: "#node-input-property-type"
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<script type="text/html" data-template-name="not">
|
|
34
|
+
<div class="form-row">
|
|
35
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
36
|
+
<input type="text" id="node-input-name" placeholder="Name">
|
|
37
|
+
</div>
|
|
38
|
+
<div class="form-row">
|
|
39
|
+
<label for="node-input-input"><i class="fa fa-ellipsis-h"></i> Eigenschaft</label>
|
|
40
|
+
<input type="text" id="node-input-property">
|
|
41
|
+
<input type="hidden" id="node-input-property-type">
|
|
42
|
+
</div>
|
|
43
|
+
<div class="form-row">
|
|
44
|
+
<label for="node-input-showStatus"><i class="fa fa-star-o"></i> Status</label>
|
|
45
|
+
<input type="checkbox" id="node-input-showState" style="display:inline-block; width:20px; vertical-align:baseline;">
|
|
46
|
+
</div>
|
|
47
|
+
<div class="form-row">
|
|
48
|
+
<label for="node-input-filter"><i class="fa fa-filter"></i> Filter</label>
|
|
49
|
+
<input type="checkbox" id="node-input-filter" style="display:inline-block; width:20px; vertical-align:baseline;">
|
|
50
|
+
</div>
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<script type="text/html" data-help-name="not">
|
|
54
|
+
|
|
55
|
+
<p>Inverts the boolean value.</p>
|
|
56
|
+
<p>If the msg property <code>invalid</code> is present in the message, all nodes ignore the message.</p>
|
|
57
|
+
|
|
58
|
+
<table>
|
|
59
|
+
<tr> <th>type</th> <th>input</th> <th>output</th> </tr>
|
|
60
|
+
<tr> <td>boolean</td> <td>false</td> <td>false</td> </tr>
|
|
61
|
+
<tr> <td></td> <td>true</td> <td>true</td> </tr>
|
|
62
|
+
<tr> <td>number</td> <td>0</td> <td>false</td> </tr>
|
|
63
|
+
<tr> <td></td> <td>1</td> <td>true</td> </tr>
|
|
64
|
+
<tr> <td>string</td> <td>false</td> <td>false</td> </tr>
|
|
65
|
+
<tr> <td></td> <td>true</td> <td>true</td> </tr>
|
|
66
|
+
<tr> <td></td> <td>0</td> <td>false</td> </tr>
|
|
67
|
+
<tr> <td></td> <td>1</td> <td>true</td> </tr>
|
|
68
|
+
<tr> <td></td> <td>off</td> <td>false</td> </tr>
|
|
69
|
+
<tr> <td></td> <td>on</td> <td>true</td> </tr>
|
|
70
|
+
</table>
|
|
71
|
+
|
|
72
|
+
<h3>Input</h3>
|
|
73
|
+
|
|
74
|
+
<p>The message property to be used as payload can be defined with the <code>Property</code> property.</p>
|
|
75
|
+
|
|
76
|
+
<dl class="message-properties">
|
|
77
|
+
<dt>payload <span class="property-type"></span></dt>
|
|
78
|
+
<dd> input value.</dd>
|
|
79
|
+
</dl>
|
|
80
|
+
|
|
81
|
+
<h3>Output</h3>
|
|
82
|
+
|
|
83
|
+
<dl class="message-properties">
|
|
84
|
+
<dt>payload <span class="property-type">boolean</span></dt>
|
|
85
|
+
<dd> bool value of payload.</dd>
|
|
86
|
+
</dl>
|
|
87
|
+
|
|
88
|
+
<h3>Parameter</h3>
|
|
89
|
+
|
|
90
|
+
<dl class="message-properties">
|
|
91
|
+
<dt>Property <span class="property-type">string</span></dt>
|
|
92
|
+
<dd> defines the message property to be used as payload.</dd>
|
|
93
|
+
<dt>Status <span class="property-type">boolean</span></dt>
|
|
94
|
+
<dd> shows the actual value as a node status.</dd>
|
|
95
|
+
</dl>
|
|
96
|
+
|
|
97
|
+
</script>
|
package/logic_not.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
module.exports = function(RED) {
|
|
2
|
+
var tools = require('./tools.js');
|
|
3
|
+
|
|
4
|
+
function NotNode(config) {
|
|
5
|
+
RED.nodes.createNode(this,config);
|
|
6
|
+
//this.config = config;
|
|
7
|
+
var node = this;
|
|
8
|
+
this.property = config.property || "payload";
|
|
9
|
+
this.showState = config.showState;
|
|
10
|
+
this.filter = Boolean( config.filter );
|
|
11
|
+
this.last = null;
|
|
12
|
+
|
|
13
|
+
node.on('input', function(msg,send,done) {
|
|
14
|
+
if( msg.invalid )
|
|
15
|
+
{
|
|
16
|
+
done();
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
msg.payload = ! tools.property2boolean( RED.util.getMessageProperty( msg, node.property ) );
|
|
20
|
+
let status = { text:msg.payload ?? "error" };
|
|
21
|
+
if( msg.payload !== null )
|
|
22
|
+
{
|
|
23
|
+
if( node.filter )
|
|
24
|
+
{
|
|
25
|
+
status.shape = "dot";
|
|
26
|
+
if( msg.payload !== node.last )
|
|
27
|
+
{
|
|
28
|
+
node.last = msg.payload;
|
|
29
|
+
status.fill = "green";
|
|
30
|
+
send( msg );
|
|
31
|
+
}
|
|
32
|
+
else
|
|
33
|
+
{
|
|
34
|
+
status.fill = "gray";
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else
|
|
38
|
+
{
|
|
39
|
+
send( msg );
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if( node.showState )
|
|
43
|
+
{
|
|
44
|
+
node.status( status );
|
|
45
|
+
}
|
|
46
|
+
done();
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
RED.nodes.registerType("not",NotNode);
|
|
51
|
+
}
|
package/math_minus.html
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#<script type="text/javascript">
|
|
2
|
+
RED.nodes.registerType('negate',{
|
|
3
|
+
category: 'function',
|
|
4
|
+
color: "#C0DEED",
|
|
5
|
+
defaults: {
|
|
6
|
+
name:{value:""},
|
|
7
|
+
property:{value:"payload",required:true},
|
|
8
|
+
showState:{value:false},
|
|
9
|
+
filter:{value:false}
|
|
10
|
+
},
|
|
11
|
+
inputs:1,
|
|
12
|
+
outputs:1,
|
|
13
|
+
icon: "font-awesome/fa-minus",
|
|
14
|
+
label: function() {
|
|
15
|
+
return this.name||"minus";
|
|
16
|
+
},
|
|
17
|
+
labelStyle: function() {
|
|
18
|
+
return this.name?"node_label_italic":"";
|
|
19
|
+
},
|
|
20
|
+
paletteLabel: "minus",
|
|
21
|
+
inputLabels: 'input',
|
|
22
|
+
outputLabels: 'number',
|
|
23
|
+
oneditprepare: function() {
|
|
24
|
+
$("#node-input-property").typedInput({
|
|
25
|
+
type:"msg",
|
|
26
|
+
types:["msg"],
|
|
27
|
+
typeField: "#node-input-property-type"
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<script type="text/html" data-template-name="negate">
|
|
34
|
+
<div class="form-row">
|
|
35
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
36
|
+
<input type="text" id="node-input-name" placeholder="Name">
|
|
37
|
+
</div>
|
|
38
|
+
<div class="form-row">
|
|
39
|
+
<label for="node-input-input"><i class="fa fa-ellipsis-h"></i> Eigenschaft</label>
|
|
40
|
+
<input type="text" id="node-input-property">
|
|
41
|
+
<input type="hidden" id="node-input-property-type">
|
|
42
|
+
</div>
|
|
43
|
+
<div class="form-row">
|
|
44
|
+
<label for="node-input-showStatus"><i class="fa fa-star-o"></i> Status</label>
|
|
45
|
+
<input type="checkbox" id="node-input-showState" style="display:inline-block; width:20px; vertical-align:baseline;">
|
|
46
|
+
</div>
|
|
47
|
+
<div class="form-row">
|
|
48
|
+
<label for="node-input-filter"><i class="fa fa-filter"></i> Filter</label>
|
|
49
|
+
<input type="checkbox" id="node-input-filter" style="display:inline-block; width:20px; vertical-align:baseline;">
|
|
50
|
+
</div>
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<script type="text/html" data-help-name="negate">
|
|
54
|
+
|
|
55
|
+
<p>negates the payload.</p>
|
|
56
|
+
<p>If the msg property <code>invalid</code> is present in the message, all nodes ignore the message.</p>
|
|
57
|
+
|
|
58
|
+
<h3>Input</h3>
|
|
59
|
+
|
|
60
|
+
<p>The message property to be used as payload can be defined with the <code>Property</code> property.</p>
|
|
61
|
+
|
|
62
|
+
<dl class="message-properties">
|
|
63
|
+
<dt>payload <span class="property-type"></span></dt>
|
|
64
|
+
<dd> input value.</dd>
|
|
65
|
+
</dl>
|
|
66
|
+
|
|
67
|
+
<h3>Output</h3>
|
|
68
|
+
|
|
69
|
+
<dl class="message-properties">
|
|
70
|
+
<dt>payload <span class="property-type">number</span></dt>
|
|
71
|
+
<dd> number value of payload.</dd>
|
|
72
|
+
</dl>
|
|
73
|
+
|
|
74
|
+
<h3>Parameter</h3>
|
|
75
|
+
|
|
76
|
+
<dl class="message-properties">
|
|
77
|
+
<dt>Property <span class="property-type">string</span></dt>
|
|
78
|
+
<dd> defines the message property to be used as payload.</dd>
|
|
79
|
+
<dt>Status <span class="property-type">boolean</span></dt>
|
|
80
|
+
<dd> shows the actual value as a node status.</dd>
|
|
81
|
+
</dl>
|
|
82
|
+
|
|
83
|
+
</script>
|
package/math_minus.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
module.exports = function(RED) {
|
|
2
|
+
|
|
3
|
+
function MinusNode(config) {
|
|
4
|
+
RED.nodes.createNode(this,config);
|
|
5
|
+
//this.config = config;
|
|
6
|
+
var node = this;
|
|
7
|
+
this.property = config.property ?? "payload";
|
|
8
|
+
this.showState = config.showState;
|
|
9
|
+
this.filter = Boolean( config.filter );
|
|
10
|
+
this.last = null;
|
|
11
|
+
|
|
12
|
+
node.on('input', function(msg,send,done) {
|
|
13
|
+
if( msg.invalid )
|
|
14
|
+
{
|
|
15
|
+
done();
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
msg.payload = - Number( RED.util.getMessageProperty( msg, node.property ) );
|
|
19
|
+
let status = { text:msg.payload };
|
|
20
|
+
if( ! isNaN( msg.payload ) )
|
|
21
|
+
{
|
|
22
|
+
if( node.filter )
|
|
23
|
+
{
|
|
24
|
+
status.shape = "dot";
|
|
25
|
+
if( msg.payload !== node.last )
|
|
26
|
+
{
|
|
27
|
+
node.last = msg.payload;
|
|
28
|
+
status.fill = "green";
|
|
29
|
+
send( msg );
|
|
30
|
+
}
|
|
31
|
+
else
|
|
32
|
+
{
|
|
33
|
+
status.fill = "gray";
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else
|
|
37
|
+
{
|
|
38
|
+
send( msg );
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else
|
|
42
|
+
{
|
|
43
|
+
status.text = "not a Number";
|
|
44
|
+
}
|
|
45
|
+
if( node.showState )
|
|
46
|
+
{
|
|
47
|
+
node.status( status );
|
|
48
|
+
}
|
|
49
|
+
done();
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
RED.nodes.registerType("negate",MinusNode);
|
|
54
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mschaeffler/node-red-logic",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "nodes for simple operations.",
|
|
5
5
|
"license": "LGPL-2.1",
|
|
6
6
|
"homepage": "https://github.com/m-schaeffler/node-red-my-nodes/tree/main/node-red-logic",
|
|
@@ -19,9 +19,11 @@
|
|
|
19
19
|
"nodes": {
|
|
20
20
|
"counter":"counter.js",
|
|
21
21
|
"tobool":"logic_bool.js",
|
|
22
|
+
"not":"logic_not.js",
|
|
22
23
|
"or":"logic_or.js",
|
|
23
24
|
"and":"logic_and.js",
|
|
24
25
|
"tonumber":"math_number.js",
|
|
26
|
+
"negate":"math_minus.js",
|
|
25
27
|
"reduce":"math_reduce.js",
|
|
26
28
|
"fallingEdge":"math_falling.js",
|
|
27
29
|
"raisingEdge":"math_raising.js",
|