@strato-automation/node-red-contrib-strato-automation
Version:
Strato Automation Official Node Red Library
112 lines (102 loc) • 4.82 kB
HTML
<script type="text/javascript">
RED.nodes.registerType('func-ramp', {
category: 'Strato Automation',
color: '#f3b567',
defaults: {
name: { value: "", label: "name" },
x1: { value: 0, required: true, label: "x1" },
y1: { value: 0, required: true, label: "y1" },
x2: { value: 100, required: true, label: "x2" },
y2: { value: 100, required: true, label: "y2" },
limit: { value: true, required: true, label: "limit" },
},
inputs: 1,
outputs: 1,
icon: "font-awesome/fa-line-chart",
paletteLabel: function() {
return "Linear Reset";
},
label: function () {
return (this.name || "Linear Reset")
},
labelStyle: function () {
return this.name ? "node_label_italic" : "";
},
inputLabels: function (index) {
return "Input 1: X1\nInput 2: Y1\nInput 3: X2\nInput 4: Y2";
}
});
</script>
<script type="text/html" data-template-name="func-ramp">
<div class="form-tips" style="margin-bottom: 20px;">
<b>Basic Settings</b>
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-bookmark"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Optional name for this function">
</div>
<div class="form-tips" style="margin: 20px 0;">
<b>Linear Mapping</b>
</div>
<div style="padding-left: 10px; border-left: 3px solid #ddd;">
<div class="form-row">
<label><i class="fa fa-arrows-h"></i> Map the input range:</label>
<span style="margin-left:10px;">from</span>
<input type="num" id="node-input-x1" style="width:60px; margin:0 5px;" placeholder="X1">
<span>to</span>
<input type="num" id="node-input-x2" style="width:60px; margin:0 5px;" placeholder="X2">
</div>
<div class="form-row">
<label><i class="fa fa-arrows-h"></i> to the output range:</label>
<span style="margin-left:10px;">from</span>
<input type="num" id="node-input-y1" style="width:60px; margin:0 5px;" placeholder="Y1">
<span>to</span>
<input type="num" id="node-input-y2" style="width:60px; margin:0 5px;" placeholder="Y2">
</div>
</div>
<div class="form-tips" style="margin: 20px 0;">
<b>Output Settings</b>
</div>
<div style="padding-left: 10px; border-left: 3px solid #ddd;">
<div class="form-row">
<label for="node-input-limit"><i class="fa fa-compress"></i> Limit Output</label>
<input type="checkbox" id="node-input-limit" style="width: auto; margin-top: 0;">
<span class="form-tips" style="margin-left: 10px;">Constrain output between Y1 and Y2 values</span>
</div>
</div>
<div class="form-tips" style="margin-top: 20px;">
<p><i class="fa fa-info-circle"></i> Tip: Points can be dynamically updated through input messages using topics x1, y1, x2, y2.</p>
</div>
</script>
<script type="text/html" data-help-name="func-ramp">
<p>Maps input X linearly along the line from (X1,Y1) to (X2,Y2).</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>Payload <span class="property-type">number</span></dt>
<dd>The value X to map.</dd>
<dt class="optional">Topic <span class="property-type">string</span></dt>
<dd>
Special topics for parameter updates (case-insensitive):
<ul>
<li><code>input</code> [<code>in</code>, <code>default</code>] – Same as default payload (input value)</li>
<li><code>in1</code> [<code>x1</code>] – Update input range start (X1)</li>
<li><code>in2</code> [<code>y1</code>] – Update output range start (Y1)</li>
<li><code>in3</code> [<code>x2</code>] – Update input range end (X2)</li>
<li><code>in4</code> [<code>y2</code>] – Update output range end (Y2)</li>
</ul>
</dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>Payload <span class="property-type">number</span></dt>
<dd>The mapped output value (Y) from linear interpolation: Y = Y1 + (Y2−Y1)/(X2−X1) × (X−X1)</dd>
</dl>
<h3>Details</h3>
<p>This node implements linear mapping between two points:</p>
<ul>
<li>Input range: X1 to X2 (configurable or via messages)</li>
<li>Output range: Y1 to Y2 (configurable or via messages)</li>
<li>Optional output limiting: constrain result between Y1 and Y2</li>
<li>Points can be updated dynamically via input messages (topics x1, y1, x2, y2)</li>
</ul>
</script>