node-red-contrib-bitunloader
Version:
Unload numbers to a binary string, array of bits, array of bools, object of bits, or object of bools.
78 lines (75 loc) • 3.48 kB
HTML
<script type="text/javascript">
RED.nodes.registerType('bitreloader', {
category: 'function',
color: '#AAAA66',
defaults:{
name: {value:''},
autoMode: {value:'auto'},
prop: {value:'_prop'},
mode: {value:'_mode'}
},
inputs:1,
outputs:1,
icon: 'binary_40x60.png',
align: 'right',
label: function() {
return this.name || 'bitreloader';
},
labelStyle: function() {
return this.name?'node_label_italic':'';
},
oneditprepare: function() {
var node = this;
$("#node-input-autoMode").on("change", function(e) {
var val = $(this).val();
$(".node-row-config").toggle(val==='manual');
});
$("#node-input-prop").typedInput({default:'msg',types:['msg']});
},
oneditsave: function() {
if (this.prop === undefined) {
$("#node-input-prop").val("payload");
}
}
});
</script>
<script type="text/html" data-template-name="bitreloader">
<div class="form-row">
<label for="node-input-autoMode"> Configuration:</label>
<select id="node-input-autoMode" style="width:200px;">
<option value="auto" selected="selected">Auto</option>
<option value="manual">Manual</option>
</select>
</div>
<div class="node-row-config">
<div class="form-row">
<label for="node-input-prop" style="width:120px;"><i class="fa fa-ellipsis-h"></i> Property</label>
<input type="text" id="node-input-prop" placeholder="payload" style="width:70%;">
</div>
<div class="form-row">
<label for="node-input-mode" style="width:120px;"><i class="fa fa-sign-out"></i> Input Format</label>
<select id="node-input-mode">
<option value="string" selected="selected">Binary string</option>
<option value="arrayBits">Array of bits</option>
<option value="arrayBools">Array of bools</option>
<option value="objectBits">Object of bits</option>
<option value="objectBools">Object of bools</option>
</select>
</div>
</div>
<div class="form-row">
<label for="node-input-name" style="width:120px;"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-tips">
In auto configuration mode, bitreloader node will accept a msg from a bitunloader node and automatically reverse the unloading action. In manual configuration mode, you can specify the <code>msg</code> property and data format manually for use without a bitunloader node.
</div>
</script>
<script type="text/html" data-help-name="bitreloader">
<p>Converts messages which were altered by a bitunloader node back to a number.</p>
<h3>Details</h3>
<p>Set the mode in configuration to <code>Automatic</code> to use with a bitunloader node without any further configuration.</p><br>
<p>You can also use the bitreloader node stand-alone by setting the configuration to 'manual'. This will allow you to configure the msg property that you wish to turn into an integer as well as define the input data format of the msg property.</p>
<b>Warning:</b> if the property that has been "unloaded" changes type (eg. from an array of bits to an object of bools) between the bitunloader node and bitreloader node, this will result in an error produced by the bitreloader node.
</p>
</script>