Initial commit

This commit is contained in:
Marcelo
2025-11-20 15:27:34 -06:00
commit cc72c9fc5d
3221 changed files with 737477 additions and 0 deletions

110
node_modules/node-red-node-smooth/17-smooth.html generated vendored Normal file
View File

@@ -0,0 +1,110 @@
<script type="text/x-red" data-template-name="smooth">
<div class="form-row">
<label for="node-input-property"><i class="fa fa-ellipsis-h"></i> <span data-i18n="node-red:common.label.property"></span></label>
<input type="text" id="node-input-property" style="width:70%;"/>
</div>
<div class="form-row">
<label for="node-input-action"><i class="fa fa-bolt"></i> Action</label>
<select id="node-input-action" style="width:60%; margin-right:5px;">
<option value="max">Return the maximum value seen</option>
<option value="min">Return the minimum value seen</option>
<option value="mean">Return the mean value</option>
<option value="sd">Return the standard deviation</option>
<option value="low">Perform low pass filter</option>
<option value="high">Perform high pass filter</option>
</select>
</div>
<div class="form-row">
<label for="node-input-count">&nbsp;</label>
<span id="node-over">over the most recent </span>
<input type="text" id="node-input-count" placeholder="10" style="width:50px;"/>
<span id="node-over2"> values</span>
</div>
<div class="form-row">
<label for="node-input-round">(optionally)</label>
round to <input type="text" id="node-input-round" placeholder="ignore" style="width:50px;"/> decimal places
</div>
<div class="form-row">
<label for="node-input-mult">Treat</label>
<select id="node-input-mult" style="width:60%; margin-right:5px;">
<option value="single">All msg as one stream.</option>
<option value="multi">Different msg.topic as individual streams.</option>
</select>
</div>
<div class="form-row" id="row-input-reduce">
<label for="node-input-reduce"><i class="fa fa-compress"></i> Reduce</label>
<input type="checkbox" id="node-input-reduce" style="display:inline-block; width:20px; vertical-align:baseline;">
only emit one message per most recent N values
</div>
<br/>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-tips" id="node-tip">Tip: This node ONLY works with numbers.</div>
</script>
<script type="text/x-red" data-help-name="smooth">
<p>A simple node to provide various functions across several previous values, including max, min, mean, high and low pass filters.</p>
<p>Messages arriving with different <code>msg.topic</code> can be treated as separate streams if so configured.</p>
<p>Max, Min and Mean work over a specified number of previous values.</p>
<p>The High and Low pass filters use a smoothing factor. The higher the number the more the smoothing. E.g. a value of 10 is similar to an &alpha; of 0.1. It is analagous to an RC time constant - but there is no time component to this as the time is based on events arriving.</p>
<p>Enabling the Reduce option causes the node to only emit one message per N values (available for the Max, Min and Mean functions). E.g. if set to Mean over 10 values, there will only be one outgoing message per 10 incoming ones.</p>
<p>If <code>msg.reset</code> is received (with any value), all the counters and intermediate values are reset to an initial state.</p>
<p><b>Note:</b> This only operates on <b>numbers</b>. Anything else will try to be made into a number and rejected if that fails.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('smooth', {
color: "#E2D96E",
category: 'function',
defaults: {
name: {value:""},
property: {value:"payload",required:true},
action: {value:"mean"},
count: {value:"10",required:true,validate:RED.validators.number()},
round: {value:""},
mult: {value:"single"},
reduce: {value:false}
},
inputs: 1,
outputs: 1,
icon: "smooth.png",
label: function() {
return this.name || "smooth";
},
labelStyle: function() {
return this.name ? "node_label_italic" : "";
},
outputLabels: function() { return this.reduce === true ? (this.action+" of "+this.count) : (this.action); },
oneditprepare: function() {
if (this.property === undefined) {
$("#node-input-property").val("payload");
}
$("#node-input-property").typedInput({default:'msg',types:['msg']});
$("#node-input-count").spinner({
min:1
});
$("#node-input-round").spinner({
});
$("#node-input-action").change( function() {
var a = $("#node-input-action").val();
if ((a === "high") || ( a === "low" )) {
$("#node-over").html("with a smoothing factor of ");
$("#node-over2").html("");
$("#row-input-reduce").hide();
}
else {
$("#node-over").html("over the most recent ");
$("#node-over2").html(" values");
$("#row-input-reduce").show();
}
});
$("#node-input-action").change();
if ($("#node-input-round").val() === "true") {
$("#node-input-round").val(0);
}
}
});
</script>

80
node_modules/node-red-node-smooth/17-smooth.js generated vendored Normal file
View File

@@ -0,0 +1,80 @@
module.exports = function(RED) {
"use strict";
function SmoothNode(n) {
RED.nodes.createNode(this, n);
this.action = n.action;
this.round = n.round || false;
if (this.round == "true") { this.round = 0; }
this.count = Number(n.count);
this.mult = n.mult || "single";
this.reduce = n.reduce || false;
this.property = n.property || "payload";
var node = this;
var v = {};
this.on('input', function (msg) {
var value = RED.util.getMessageProperty(msg,node.property);
var top = msg.topic || "_my_default_topic";
var reduce = node.reduce;
if (this.mult === "single") { top = "a"; }
if ((v.hasOwnProperty(top) !== true) || msg.hasOwnProperty("reset")) {
v[top] = {};
v[top].a = [];
v[top].tot = 0;
v[top].tot2 = 0;
v[top].pop = 0;
v[top].old = null;
v[top].count = this.count;
v[top].iter = 0;
}
if (value !== undefined) {
var n = Number(value);
if (!isNaN(n)) {
v[top].iter++;
if ((node.action === "low") || (node.action === "high")) {
if (v[top].old == null) { v[top].old = n; }
v[top].old = v[top].old + (n - v[top].old) / v[top].count;
if (node.action === "low") { value = v[top].old; }
else { value = n - v[top].old; }
reduce = false;
}
else {
v[top].a.push(n);
if (v[top].a.length > v[top].count) { v[top].pop = v[top].a.shift(); }
if (node.action === "max") {
value = Math.max.apply(Math, v[top].a);
}
if (node.action === "min") {
value = Math.min.apply(Math, v[top].a);
}
if (node.action === "mean") {
v[top].tot = v[top].tot + n - v[top].pop;
value = v[top].tot / v[top].a.length;
}
if (node.action === "sd") {
v[top].tot = v[top].tot + n - v[top].pop;
v[top].tot2 = v[top].tot2 + (n*n) - (v[top].pop * v[top].pop);
if (v[top].a.length > 1) {
value = Math.sqrt((v[top].a.length * v[top].tot2 - v[top].tot * v[top].tot)/(v[top].a.length * (v[top].a.length - 1)));
}
else { value = 0; }
}
}
if (node.round !== false) {
value = Math.round(value * Math.pow(10, node.round)) / Math.pow(10, node.round);
}
if (reduce == false || v[top].iter == v[top].count) {
v[top].iter = 0;
RED.util.setMessageProperty(msg,node.property,value);
node.send(msg);
}
}
else { node.log("Not a number: " + value); }
} // ignore msg with no payload property.
});
}
RED.nodes.registerType("smooth", SmoothNode);
}

14
node_modules/node-red-node-smooth/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,14 @@
Copyright 2016 JS Foundation and other contributors, https://js.foundation/
Copyright 2013-2016 IBM Corp.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

39
node_modules/node-red-node-smooth/README.md generated vendored Normal file
View File

@@ -0,0 +1,39 @@
node-red-node-smooth
====================
A <a href="http://nodered.org" target="_new">Node-RED</a> node that provides
several simple smoothing algorithms for incoming data values. These include
- Minimum
- Maximum
- Mean
- Standard Deviation
- High Pass Smoothing
- Low Pass Smoothing
Install
-------
Run the following command in your Node-RED user directory - typically `~/.node-red`
npm install node-red-node-smooth
Usage
-----
A simple node to provide various functions across several previous values,
including max, min, mean, standard deviation, high and low pass filters.
Max, Min, Mean and Standard Deviation work over a rolling window, based on a
specified number of previous values.
The High and Low pass filters use a smoothing factor. The higher the number
the more the smoothing. E.g. a value of 10 is similar to an &alpha; of 0.1.
It is analogous to an RC time constant - but there is no time component to
this as the code is based on events arriving.
If `msg.reset` is received (with any value), all the counters and intermediate values are reset to an initial state.
**Note:** This node only operates on **numbers**. Anything else will try to be
made into a number and rejected if that fails.

BIN
node_modules/node-red-node-smooth/icons/smooth.png generated vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 725 B

24
node_modules/node-red-node-smooth/package.json generated vendored Normal file
View File

@@ -0,0 +1,24 @@
{
"name" : "node-red-node-smooth",
"version" : "0.1.2",
"description" : "A Node-RED node that provides several simple smoothing algorithms for incoming data values.",
"dependencies" : {
},
"repository" : {
"type":"git",
"url":"https://github.com/node-red/node-red-nodes/tree/master/function/smooth"
},
"license": "Apache-2.0",
"keywords": [ "node-red", "smooth", "average", "standard deviation" ],
"node-red" : {
"nodes" : {
"smooth": "17-smooth.js"
}
},
"author": {
"name": "Dave Conway-Jones",
"email": "ceejay@vnet.ibm.com",
"url": "http://nodered.org"
},
"contributors" : [ "@clickworkorange" ]
}