@mschaeffler/node-red-logic 4.3.5 → 5.0.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_blinker.js +12 -5
- package/math_reduce.html +0 -19
- package/math_reduce.js +10 -21
- package/package.json +1 -1
package/logic_blinker.js
CHANGED
|
@@ -9,11 +9,11 @@ module.exports = function(RED) {
|
|
|
9
9
|
this.onTime = Number( config.onTime ?? 1 ) * tools.timeUnits( config.onTimeUnit );
|
|
10
10
|
this.offTime = Number( config.offTime ?? 1 ) * tools.timeUnits( config.offTimeUnit );
|
|
11
11
|
this.firstType = config.outputFirstType ?? "bool";
|
|
12
|
-
this.lastType = config.outputLastType
|
|
13
|
-
this.
|
|
14
|
-
this.
|
|
15
|
-
this.
|
|
16
|
-
this.
|
|
12
|
+
this.lastType = config.outputLastType ?? "bool";
|
|
13
|
+
this.configOutputFirst = RED.util.evaluateNodeProperty( config.outputFirst ?? "true", this.firstType );
|
|
14
|
+
this.configOutputOn = RED.util.evaluateNodeProperty( config.outputOn ?? "true", config.outputOnType ?? "bool" );
|
|
15
|
+
this.configOutputOff = RED.util.evaluateNodeProperty( config.outputOff ?? "false", config.outputOffType ?? "bool" );
|
|
16
|
+
this.configOutputLast = RED.util.evaluateNodeProperty( config.outputLast ?? "false", this.lastType );
|
|
17
17
|
this.filter = Boolean( config.filter );
|
|
18
18
|
this.showState = Boolean( config.showState );
|
|
19
19
|
this.timerOn = null;
|
|
@@ -95,6 +95,13 @@ module.exports = function(RED) {
|
|
|
95
95
|
done();
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
98
|
+
if( msg.output || node.outputFirst === undefined )
|
|
99
|
+
{
|
|
100
|
+
node.outputFirst = msg.output?.first ?? node.configOutputFirst;
|
|
101
|
+
node.outputOn = msg.output?.on ?? node.configOutputOn;
|
|
102
|
+
node.outputOff = msg.output?.off ?? node.configOutputOff;
|
|
103
|
+
node.outputLast = msg.output?.last ?? node.configOutputLast;
|
|
104
|
+
}
|
|
98
105
|
node.state = tools.property2boolean( RED.util.getMessageProperty( msg, node.property ) );
|
|
99
106
|
if( node.state !== null )
|
|
100
107
|
{
|
package/math_reduce.html
CHANGED
|
@@ -7,13 +7,6 @@
|
|
|
7
7
|
topic:{value:""},
|
|
8
8
|
property:{value:"payload", required:true},
|
|
9
9
|
propertyType:{value:"msg"},
|
|
10
|
-
minMean:{value:"1", required:true, validate:function(v){
|
|
11
|
-
return v!=='' && !isNaN(v) && Number(v)>0;}
|
|
12
|
-
},
|
|
13
|
-
maxMean:{value:"1", required:true, validate:function(v){
|
|
14
|
-
const minMean = $("#node-input-minMean").length ? $("#node-input-minMean").val() : this.minMean;
|
|
15
|
-
return v!=='' && !isNaN(v) && Number(v)>=minMean;}
|
|
16
|
-
},
|
|
17
10
|
minData:{value:"1", required:true, validate:function(v){
|
|
18
11
|
return v!=='' && !isNaN(v) && Number(v)>0;}
|
|
19
12
|
},
|
|
@@ -66,14 +59,6 @@
|
|
|
66
59
|
<input type="text" id="node-input-property">
|
|
67
60
|
<input type="hidden" id="node-input-propertyType">
|
|
68
61
|
</div>
|
|
69
|
-
<div class="form-row">
|
|
70
|
-
<label for="node-input-minMean"><i class="fa fa-hourglass-o"></i> min. Mean</label>
|
|
71
|
-
<input type="number" id="node-input-minMean">
|
|
72
|
-
</div>
|
|
73
|
-
<div class="form-row">
|
|
74
|
-
<label for="node-input-maxMean"><i class="fa fa-hourglass"></i> max. Mean</label>
|
|
75
|
-
<input type="number" id="node-input-maxMean">
|
|
76
|
-
</div>
|
|
77
62
|
<div class="form-row">
|
|
78
63
|
<label for="node-input-minData"><i class="fa fa-check-square-o "></i> min. Data</label>
|
|
79
64
|
<input type="number" id="node-input-minData">
|
|
@@ -134,10 +119,6 @@
|
|
|
134
119
|
<dd> defines the topic for the output message.</dd>
|
|
135
120
|
<dt>Property <span class="property-type">string</span></dt>
|
|
136
121
|
<dd> defines the message property to be used as payload.</dd>
|
|
137
|
-
<dt>min. Mean <span class="property-type">number</span></dt>
|
|
138
|
-
<dd> min. amount of values for the arithmatic mean of one topic.</dd>
|
|
139
|
-
<dt>max. Mean <span class="property-type">number</span></dt>
|
|
140
|
-
<dd> max. amount of values for the arithmatic mean of one topic.</dd>
|
|
141
122
|
<dt>min. Data <span class="property-type">number</span></dt>
|
|
142
123
|
<dd> min. amount of topics to generate an output.</dd>
|
|
143
124
|
<dt>Algorithm <span class="property-type">string</span></dt>
|
package/math_reduce.js
CHANGED
|
@@ -9,8 +9,6 @@ module.exports = function(RED) {
|
|
|
9
9
|
this.topic = config.topic ?? "";
|
|
10
10
|
this.property = config.property ?? "payload";
|
|
11
11
|
this.propertyType = config.propertyType ?? "msg";
|
|
12
|
-
this.minMean = Number( config.minMean ?? 1 );
|
|
13
|
-
this.maxMean = Number( config.maxMean ?? 1 );
|
|
14
12
|
this.minData = Number( config.minData ?? 1 );
|
|
15
13
|
this.algo = config.algo;
|
|
16
14
|
this.showState= Boolean( config.showState );
|
|
@@ -69,9 +67,8 @@ module.exports = function(RED) {
|
|
|
69
67
|
if( ! isNaN( payload ) )
|
|
70
68
|
{
|
|
71
69
|
let data = context.get( "data" ) ?? {};
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
data[msg.topic] = item;
|
|
70
|
+
data[msg.topic] = payload;
|
|
71
|
+
context.set( "data", data );
|
|
75
72
|
|
|
76
73
|
msg.topic = node.topic;
|
|
77
74
|
msg.count = 0;
|
|
@@ -87,25 +84,17 @@ module.exports = function(RED) {
|
|
|
87
84
|
}
|
|
88
85
|
for( const key in data )
|
|
89
86
|
{
|
|
90
|
-
|
|
87
|
+
msg.count++;
|
|
88
|
+
const help = data[key];
|
|
89
|
+
switch( node.algo )
|
|
91
90
|
{
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const help = data[key].reduce( (accumulator,value)=>accumulator+value ) / data[key].length;
|
|
98
|
-
switch( node.algo )
|
|
99
|
-
{
|
|
100
|
-
case "add":
|
|
101
|
-
case "mean": msg.payload += help; break;
|
|
102
|
-
case "prod": msg.payload *= help; break;
|
|
103
|
-
case "min": msg.payload = Math.min( msg.payload, help ); break;
|
|
104
|
-
case "max": msg.payload = Math.max( msg.payload, help ); break;
|
|
105
|
-
}
|
|
91
|
+
case "add":
|
|
92
|
+
case "mean": msg.payload += help; break;
|
|
93
|
+
case "prod": msg.payload *= help; break;
|
|
94
|
+
case "min": msg.payload = Math.min( msg.payload, help ); break;
|
|
95
|
+
case "max": msg.payload = Math.max( msg.payload, help ); break;
|
|
106
96
|
}
|
|
107
97
|
}
|
|
108
|
-
context.set( "data", data );
|
|
109
98
|
|
|
110
99
|
if( msg.count >= node.minData )
|
|
111
100
|
{
|
package/package.json
CHANGED