UNPKG

node-red-contrib-modbus

Version:

The all in one Modbus TCP, UDP and Serial contribution long term supported package for Node-RED.

144 lines (136 loc) 9.22 kB
<!-- Copyright (c) since the year 2016 Klaus Landsdorf (http://plus4nodered.com/) All rights reserved. node-red-contrib-modbus - The BSD 3-Clause License @author <a href="mailto:klaus.landsdorf@bianco-royal.de">Klaus Landsdorf</a> (Bianco Royal) --> <script type='text/javascript'> RED.nodes.registerType('modbus-getter', { category: 'modbus', color: '#E9967A', defaults: { name: {value: ''}, showStatusActivities: {value: false}, showErrors: {value: false}, showWarnings: {value: true}, logIOActivities: {value: false}, unitid: {value: ''}, dataType: {value: '', required: true}, adr: {value: '', required: true, validate: RED.validators.number()}, quantity: {value: '', required: true, validate: RED.validators.number()}, server: {type: 'modbus-client', required: true}, useIOFile: {value: false}, ioFile: {value: '', type: 'modbus-io-config', required: false}, useIOForPayload: {value: false}, emptyMsgOnFail: {value: false}, keepMsgProperties: {value: false}, delayOnStart: {value: false}, enableDeformedMessages: {value: false, required: false}, startDelayTime: {value: ''}, }, inputs: 1, outputs: 2, align: "left", icon: 'modbus.png', paletteLabel: 'Modbus-Getter', label: function () { return this.name || 'Modbus Getter' }, oneditprepare: function () { let tabs = RED.tabs.create({ id: "node-input-modbus-tabs", onchange: function (tab) { $("#node-input-tabs-content").children().hide() $("#" + tab.id).show() } }) tabs.addTab({ id: "modbus-settings-tab", label: this._("modbus-contrib.tabs-label.settings") }) tabs.addTab({ id: "modbus-options-tab", label: this._("modbus-contrib.tabs-label.options") }) if (this.delayOnStart) { $('#node-delay').show() } else { $('#node-delay').hide() $('#node-input-delayOnStart').prop('checked', false) } $('#node-input-delayOnStart').change(function () { if ($(this).is(':checked')) { $('#node-delay').show() } else { $('#node-delay').hide() } }) let useIOFileCheckbox = $('#node-input-useIOFile') let modbusiofileRow = $('#modbusiofile-row') useIOFileCheckbox.change(function () { if ($(this).is(':checked')) { modbusiofileRow.show() } else { modbusiofileRow.hide() } }) } }) </script> <script type='text/x-red' data-template-name='modbus-getter'> <div class='form-row'> <ul style='background:#fff;min-width:600px;margin-bottom:20px' id='node-input-modbus-tabs'></ul> </div> <div id='node-input-tabs-content' style='min-height:170px'> <div id='modbus-settings-tab' style='display:none'> <div class='form-row'> <label for='node-input-name'><i class='icon-tag'></i> <span data-i18n='node-red:common.label.name'></span></label> <input type='text' id='node-input-name' placeholder='Name'> </div> <div class='form-row'> <label for='node-input-unitid'><i class='icon-bookmark'></i> <span data-i18n='modbus-contrib.label.unitId'></span></label> <input type='text' id='node-input-unitid'> </div> <div class='form-row'> <label for='node-input-dataType'><i class='icon-list'></i> <span data-i18n='modbus-contrib.label.functioncode'></span></label> <select id='node-input-dataType'> <option value='Coil'> FC 1: Read Coil Status</option> <option value='Input'>FC 2: Read Input Status</option> <option value='HoldingRegister'> FC 3: Read Holding Registers</option> <option value='InputRegister'>FC 4: Read Input Registers</option> </select> </div> <div class='form-row'> <label for='node-input-adr'><i class='icon-home'></i> <span data-i18n='modbus-contrib.label.address'></span></label> <input type='text' id='node-input-adr' placeholder='0:65535'> </div> <div class='form-row'> <label for='node-input-quantity'><i class='icon-bookmark'></i> <span data-i18n='modbus-contrib.label.quantity'></span></label> <input type='text' id='node-input-quantity' placeholder='1-65535'> </div> <div class='form-row' id='node-delayonstart'> <label for='node-input-delayOnStart' style='width:160px'> <i class='fa fa-power-off'></i> <span data-i18n='modbus-contrib.label.delayOnStart'></span></label> <input type='checkbox' id='node-input-delayOnStart' style='width:40px'> </div> <div class='form-row' id='node-enabledeformedmessages'> <label for='node-input-enableDeformedMessages' style='width:160px'><span data-i18n='modbus-contrib.label.enableDeformedMessages'></span></label> <input type='checkbox' id='node-input-enableDeformedMessages' style='width:40px'> </div> <div class='form-row' id='node-delay'> <label for='node-input-startDelayTime'><i class='fa fa-clock-o'></i> <span data-i18n='modbus-contrib.label.startDelayTime'> </span></label> <input type='text' id='node-input-startDelayTime' placeholder='10' style='width:80px'> </div> <div class='form-row'> <label for='node-input-server'><i class='icon-globe'></i> <span data-i18n='modbus-contrib.label.server'></span></label> <input type='text' id='node-input-server'> </div> </div> <div id='modbus-options-tab' style='display:none'> <div class='form-row'> <label style='min-width:190px' for='node-input-emptyMsgOnFail'><i class='fa fa-th'></i> <span data-i18n='modbus-contrib.label.emptyMsgOnFail'></span> </label> <input type='checkbox' id='node-input-emptyMsgOnFail' style='max-width:30px'> </div> <div class='form-row'> <label style='min-width:190px' for='node-input-keepMsgProperties'><i class='fa fa-th'></i> <span data-i18n='modbus-contrib.label.keepMsgProperties'></span></label> <input type='checkbox' id='node-input-keepMsgProperties' style='max-width:30px'> </div> <div class='form-row'> <label style='min-width:190px' for='node-input-showStatusActivities'><i class='fa fa-th'></i> <span data-i18n='modbus-contrib.label.showActivities'> </span></label> <input type='checkbox' id='node-input-showStatusActivities' style='max-width:30px'> </div> <div class='form-row'> <label style='min-width:190px' for='node-input-showErrors'><i class='fa fa-th'></i> <span data-i18n='modbus-contrib.label.showErrors'></span></label> <input type='checkbox' id='node-input-showErrors' style='max-width:30px'> </div> <div class='form-row'> <label style='min-width:190px' for='node-input-showWarnings'><i class='fa fa-th'></i> <span data-i18n='modbus-contrib.label.showWarnings'></span></label> <input type='checkbox' checked='checked' id='node-input-showWarnings' style='max-width:30px'> </div> <hr> <div class='form-row'> <label style='min-width:190px' for='node-input-useIOFile'><i class='fa fa-file-code-o'></i> <span data-i18n='modbus-contrib.label.useIOFile'></span></label> <input type='checkbox' id='node-input-useIOFile' style='max-width:30px'> </div> <div id='modbusiofile-row'> <div class='form-row'> <label style='min-width:190px' for='node-input-logIOActivities'><i class='fa fa-th'></i> <span data-i18n='modbus-contrib.label.logIOActivities'></span> </label> <input type='checkbox' id='node-input-logIOActivities' style='max-width:30px'> </div> <div class='form-row'> <label style='min-width:190px' for='node-input-useIOForPayload'><i class='fa fa-comment-o'></i> <span data-i18n='modbus-contrib.label.useIOForPayload'></span></label> <input type='checkbox' id='node-input-useIOForPayload' style='max-width:30px'> </div> <div class='form-row'> <label for='node-input-ioFile'><i class='icon-file'></i> <span data-i18n='modbus-contrib.label.ioFile'></span></label> <input type='text' id='node-input-ioFile'> </div> </div> </div> </div> </script> <script type='text/x-red' data-help-name='modbus-getter'> <p><strong> If you have more than 10 nodes on one communication configuration, use the Modbus-Flex-Getter or think about multiple connections to your Modbus Device, please! </strong></p> <p>Modbus TCP/Serial node with triggered read function by input.</p> <p> Connects to a Modbus TCP or serial to read coils/inputs/registers at the rate of the incoming msg.</p> <p> </p><h4> Function codes currently supported include:</h4> <ul> <li>FC 1: Read Coil Status</li> <li>FC 2: Read Input Status</li> <li>FC 3: Read Holding Registers</li> <li>FC 4: Read Input Registers</li> </ul> <p></p> <p> Choose a function code (FC) from the dropdown menu, select the coil/input/register start address (0:65535), and the quantity of coils/inputs/registers to be read from the start address. Choose or edit the Modbus connection configuration. </p> <p>Unit-Id (0..255 tcp | 0..247 serial) - leave empty, otherwise it overrides the default Unit-ID of client config </p> <p> If the device you are communicating with sends data that is longer than expected for one of the following Functioncodes 1,2,3 or 4, you can enable allow oversized messages in the options. <strong>NOTE: This is a last resort option and could deliver potential faulty data please use this option with care </strong> </p><p>Output 1: data Array (PDU), modbus response Buffer, input message</p> <p> Output 2: modbus response Buffer, data Array (PDU), input message</p> </script>