node-red-contrib-float
Version:
Node-RED node to parse decimal and binary numbers to IEEE-754 Floating Point Numbers
69 lines (63 loc) • 2.54 kB
HTML
<script type="text/javascript">
RED.nodes.registerType('toFloat',{
category: 'function',
color: '#FFAAAA',
defaults: {
name: {value:""},
toFixed: {value:""}
},
inputs:1,
outputs:1,
icon: "arrow-in.png",
label: function() {
return this.name||"toFloat";
}
});
</script>
<script type="text/x-red" data-template-name="toFloat">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-toFixed"><i class="icon-tag"></i> Decimal digits</label>
<input type="number" id="node-input-toFixed" placeholder="Example 1: 0.1 - 2: 0.01">
</div>
</script>
<script type="text/x-red" data-help-name="toFloat">
<p>Converts Binary Strings and Decimals Digits (32 bit) into IEEE-754 Floating Point numbers. Works also with arrays.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>payload
<span class="property-type"> string | Int </span>
</dt>
<dd> the number or the array of numbers to decode in Float 32 bit. </dd>
<dt class="optional">Decimals Number <span class="property-type">Number</span></dt>
<dd> max digits you want to keep after the '.'.</dd>
</dl>
<h3>Outputs</h3>
<ol class="node-ports">
<li>Standard output
<dl class="message-properties">
<dt>payload <span class="property-type">Number | Array</span></dt>
<dd>the standard output of the command.</dd>
</dl>
</li>
<li>Standard error
<dl class="message-properties">
<dt>payload <span class="property-type">string</span></dt>
<dd>the standard error of the command.</dd>
</dl>
</li>
</ol>
<h3>Details</h3>
<p><code>msg.payload</code> must be an Integer 32 bit or a Binary string like
'1000000010010001111010111000011' (3.14) if the type is wrong an error is returned,
if the input is an Array the index of the wrong element is returned with the error.
<p>Decimals digits can be configured in the node or if left blank the numbers will not
be truncated</p>
<h3>References</h3>
<ul>
<li><a href="https://github.com/robertsLando/node-red-contrib-float">GitHub</a> - the node github repository</li>
</ul>
</script>