@mschaeffler/node-red-logic 3.3.1 → 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/math_statistics.html +8 -1
- package/math_statistics.js +13 -3
- package/package.json +1 -1
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">
|
|
@@ -104,5 +109,7 @@
|
|
|
104
109
|
<dd> time frame to collect the data for the analysis.</dd>
|
|
105
110
|
<dt>min. Data <span class="property-type">number</span></dt>
|
|
106
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>
|
|
107
114
|
</dl>
|
|
108
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