@mschaeffler/node-red-logic 1.2.0 → 1.2.1
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/math_mean.html +8 -1
- package/math_mean.js +13 -2
- package/math_statistics.js +0 -1
- package/package.json +1 -1
package/math_mean.html
CHANGED
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
},
|
|
11
11
|
minData:{value:"1", required:true, validate:function(v){
|
|
12
12
|
return v!=='' && !isNaN(v) && Number(v)>0;}
|
|
13
|
-
}
|
|
13
|
+
},
|
|
14
|
+
filter:{value:"", required:true}
|
|
14
15
|
},
|
|
15
16
|
inputs:1,
|
|
16
17
|
outputs:1,
|
|
@@ -51,6 +52,10 @@
|
|
|
51
52
|
<label for="node-input-minData"><i class="fa fa-check-square-o "></i> min. Data</label>
|
|
52
53
|
<input type="text" id="node-input-minData">
|
|
53
54
|
</div>
|
|
55
|
+
<div class="form-row">
|
|
56
|
+
<label for="node-input-filter"><i class="fa fa-filter "></i> Filterzeit</label>
|
|
57
|
+
<input type="text" id="node-input-filter">
|
|
58
|
+
</div>
|
|
54
59
|
</script>
|
|
55
60
|
|
|
56
61
|
<script type="text/html" data-help-name="mean">
|
|
@@ -86,5 +91,7 @@
|
|
|
86
91
|
<dd> time frame to collect the data for the analysis.</dd>
|
|
87
92
|
<dt>min. Data <span class="property-type">number</span></dt>
|
|
88
93
|
<dd> min. amount of data points to generate an output.</dd>
|
|
94
|
+
<dt>Filterzeit <span class="property-type">number</span></dt>
|
|
95
|
+
<dd> send output only after this time.</dd>
|
|
89
96
|
</dl>
|
|
90
97
|
</script>
|
package/math_mean.js
CHANGED
|
@@ -8,6 +8,7 @@ module.exports = function(RED) {
|
|
|
8
8
|
this.property = config.property || "payload";
|
|
9
9
|
this.deltaTime= Number( config.deltaTime )*1000;
|
|
10
10
|
this.minData = Number( config.minData );
|
|
11
|
+
this.filter = Number( config.filter ?? 0 )*1000;
|
|
11
12
|
|
|
12
13
|
node.on('input', function(msg,send,done) {
|
|
13
14
|
if( msg.invalid )
|
|
@@ -45,8 +46,18 @@ module.exports = function(RED) {
|
|
|
45
46
|
sum += value.value;
|
|
46
47
|
}
|
|
47
48
|
msg.payload = sum/item.length;
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
let last = context.get( "last" ) ?? {};
|
|
50
|
+
if( (last[msg.topic]??0)+this.filter < now )
|
|
51
|
+
{
|
|
52
|
+
last[msg.topic] = now;
|
|
53
|
+
context.set( "last", last );
|
|
54
|
+
node.status({fill:"green",shape:"dot",text:`${item.length} / ${msg.payload.toPrecision(4)}`});
|
|
55
|
+
send( msg );
|
|
56
|
+
}
|
|
57
|
+
else
|
|
58
|
+
{
|
|
59
|
+
node.status({fill:"gray",shape:"dot",text:`${item.length} / ${msg.payload.toPrecision(4)}`});
|
|
60
|
+
}
|
|
50
61
|
}
|
|
51
62
|
else
|
|
52
63
|
{
|
package/math_statistics.js
CHANGED
package/package.json
CHANGED