@mschaeffler/node-red-logic 3.3.0 → 3.4.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/README.md +2 -0
- package/math_statistics.html +12 -1
- package/math_statistics.js +13 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -226,6 +226,8 @@ The message property to be used as payload can be defined with the `Property` pr
|
|
|
226
226
|
|msg. | type | description |
|
|
227
227
|
|:-------|:-------|:----------------------------------|
|
|
228
228
|
|payload | | same as in input message.|
|
|
229
|
+
|stat.first | number | oldest data element.|
|
|
230
|
+
|stat.last | number | newest data element.|
|
|
229
231
|
|stat.count | number | number of data elements.|
|
|
230
232
|
|stat.min number | number | minimal value.|
|
|
231
233
|
|stat.max number | number | maximal value.|
|
package/math_statistics.html
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
},
|
|
12
12
|
minData:{value:"1", required:true, validate:function(v){
|
|
13
13
|
return v!=='' && !isNaN(v) && Number(v)>0;}
|
|
14
|
-
}
|
|
14
|
+
},
|
|
15
|
+
showState:{value:false}
|
|
15
16
|
},
|
|
16
17
|
inputs:1,
|
|
17
18
|
outputs:1,
|
|
@@ -52,6 +53,10 @@
|
|
|
52
53
|
<label for="node-input-minData"><i class="fa fa-check-square-o "></i> min. Data</label>
|
|
53
54
|
<input type="text" id="node-input-minData">
|
|
54
55
|
</div>
|
|
56
|
+
<div class="form-row">
|
|
57
|
+
<label for="node-input-showStatus"><i class="fa fa-star-o"></i> Status</label>
|
|
58
|
+
<input type="checkbox" id="node-input-showState" style="display:inline-block; width:20px; vertical-align:baseline;">
|
|
59
|
+
</div>
|
|
55
60
|
</script>
|
|
56
61
|
|
|
57
62
|
<script type="text/html" data-help-name="statistics">
|
|
@@ -77,6 +82,10 @@
|
|
|
77
82
|
<dl class="message-properties">
|
|
78
83
|
<dt>payload <span class="property-type">number</span></dt>
|
|
79
84
|
<dd> same as in input message.</dd>
|
|
85
|
+
<dt>stat.first <span class="property-type">number</span></dt>
|
|
86
|
+
<dd> oldest data element.</dd>
|
|
87
|
+
<dt>stat.last <span class="property-type">number</span></dt>
|
|
88
|
+
<dd> newest data element.</dd>
|
|
80
89
|
<dt>stat.count <span class="property-type">number</span></dt>
|
|
81
90
|
<dd> number of data elements.</dd>
|
|
82
91
|
<dt>stat.min <span class="property-type">number</span></dt>
|
|
@@ -100,5 +109,7 @@
|
|
|
100
109
|
<dd> time frame to collect the data for the analysis.</dd>
|
|
101
110
|
<dt>min. Data <span class="property-type">number</span></dt>
|
|
102
111
|
<dd> min. amount of data points to generate an output.</dd>
|
|
112
|
+
<dt>Status <span class="property-type">boolean</span></dt>
|
|
113
|
+
<dd> shows the actual value as a node status.</dd>
|
|
103
114
|
</dl>
|
|
104
115
|
</script>
|
package/math_statistics.js
CHANGED
|
@@ -9,6 +9,7 @@ module.exports = function(RED) {
|
|
|
9
9
|
this.propertyType = config.propertyType ?? "msg";
|
|
10
10
|
this.deltaTime = Number( config.deltaTime ?? 60 )*1000;
|
|
11
11
|
this.minData = Number( config.minData ?? 1 );
|
|
12
|
+
this.showState = Boolean( config.showState );
|
|
12
13
|
if( this.propertyType === "jsonata" )
|
|
13
14
|
{
|
|
14
15
|
try {
|
|
@@ -99,17 +100,26 @@ module.exports = function(RED) {
|
|
|
99
100
|
}
|
|
100
101
|
msg.stat.deviation = Math.sqrt( varianz / msg.stat.count );
|
|
101
102
|
msg.stat.variation = msg.stat.deviation / msg.stat.average;
|
|
102
|
-
node.
|
|
103
|
+
if( node.showState )
|
|
104
|
+
{
|
|
105
|
+
node.status({fill:"green",shape:"dot",text:`${msg.stat.count} / ${msg.stat.deviation.toPrecision(4)}`});
|
|
106
|
+
}
|
|
103
107
|
send( msg );
|
|
104
108
|
}
|
|
105
109
|
else
|
|
106
110
|
{
|
|
107
|
-
node.
|
|
111
|
+
if( node.showState )
|
|
112
|
+
{
|
|
113
|
+
node.status({fill:"gray",shape:"dot",text:"to less data"});
|
|
114
|
+
}
|
|
108
115
|
}
|
|
109
116
|
}
|
|
110
117
|
else
|
|
111
118
|
{
|
|
112
|
-
node.
|
|
119
|
+
if( node.showState )
|
|
120
|
+
{
|
|
121
|
+
node.status({fill:"red",shape:"dot",text:"payload is NaN"});
|
|
122
|
+
}
|
|
113
123
|
}
|
|
114
124
|
done();
|
|
115
125
|
} );
|
package/package.json
CHANGED