node-red-contrib-modbustcp-no-pooling
Version:
Node-RED nodes for communicating with a MODBUS TCP Server with no pooling to slave device registers.
191 lines (178 loc) • 8.35 kB
HTML
<!--
*
* Original work Copyright 2015 Valmet Automation Inc.
*
* 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.
*
* Modified work Copyright 2016 Argonne National Laboratory.
*
* Licensed under the the BSD 3-Clause License (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://opensource.org/licenses/BSD-3-Clause
*
* 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.
-->
<script type="text/x-red" data-template-name="modbustcp-no-pooling-server">
<div class="form-row">
<label for="node-config-input-host"><i class="icon-bookmark"></i> Host</label>
<input type="text" id="node-config-input-host">
</div>
<div class="form-row">
<label for="node-config-input-port"><i class="icon-bookmark"></i> Port</label>
<input type="text" id="node-config-input-port">
</div>
<div class="form-row">
<label for="node-config-input-unit_id"><i class="icon-bookmark"></i> Unit Id</label>
<input type="text" id="node-config-input-unit_id">
</div>
</script>
<script type="text/x-red" data-help-name="modbustcp-no-pooling-server">
<p>Uses MODBUS TCP to read/write ethernet host:port and register/coil addresses.</p>
</script>
<script type="text/x-red" data-template-name="modbustcp-no-pooling-write">
<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-dataType"><i class="icon-list"></i> Type</label>
<select id="node-input-dataType">
<option value="Coil">FC 5: Write Single Coil</option>
<option value="HoldingRegister">FC 6: Write Single Holding Register</option>
</select>
</div>
<div class="form-row">
<label for="node-input-adr"><i class="icon-bookmark"></i> Address</label>
<input type="text" id="node-input-adr">
</div>
<div class="form-row">
<label for="node-input-server"><i class="icon-bookmark"></i> Server</label>
<input type="text" id="node-input-server">
</div>
</script>
<script type="text/x-red" data-help-name="modbustcp-no-pooling-write">
<p>Modbus TCP client node. Connects to a Modbus TCP server to write <b>msg.payload</b> to a coil or register.
<h4>Function codes currently supported include:</h4>
<ul>
<li>FC 5: Write Single Coil</li>
<li>FC 6: Write Single Holding Register</li>
</ul>
Choose a function code (FC) from the dropdown menu, select the coil/register start address (0:65535). Choose or edit the Modbus TCP server configuration.
<br><br>
For FC 5, <b>msg.payload</b> must be a number or string value of 0 or 1. For FC 6, <b>msg.payload</b> must be a number or string value between 0:65535.
</p>
</script>
<script type="text/x-red" data-template-name="modbustcp-no-pooling-read">
<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-dataType"><i class="icon-list"></i> FC</label>
<select id="node-input-dataType">
<option value="Coil">FC 1: Read Coils</option>
<option value="Input">FC 2: Read Discrete Inputs</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> Address</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> Quantity</label>
<input type="text" id="node-input-quantity" placeholder="1-65535">
</div>
<!--<div class="form-row">
<label for="node-input-rate"><i class="icon-bookmark"></i> Poll Rate (s)</label>
<input type="number" id="node-input-rate" placeholder="1-65535">
</div>-->
<div class="form-row">
<label for="node-input-server"><i class="icon-globe"></i> Server</label>
<input type="text" id="node-input-server">
</div>
</script>
<script type="text/x-red" data-help-name="modbustcp-no-pooling-read">
<p>Modbus TCP client node. Connects to a Modbus TCP server to read register values at a given poll rate.
<h4>Function codes currently supported include:</h4>
<ul>
<li>FC 1: Read Coils</li>
<li>FC 2: Read Discrete Inputs</li>
<li>FC 3: Read Holding Registers</li>
<li>FC 4: Read Input Registers</li>
</ul>
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. Input a poll rate (greater than zero) in seconds to setup the poll rate. Choose or edit the Modbus TCP server configuration.
<br><br>
Outputs an object called <b>msg</b> containing <b>msg.payload</b> with an array of the read coils/inputs/registers.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('modbustcp-no-pooling-server', {
category: 'config',
defaults: {
host: {value: "127.0.0.1", required: true},
port: {value: 502, required: true, validate: RED.validators.number()},
unit_id: {value:1, required:true, validate: RED.validators.number()}
},
label: function () {
return "modbustcp-no-pooling@" + this.host + ":" + this.port;
}
});
</script>
<script type="text/javascript">
RED.nodes.registerType('modbustcp-no-pooling-write', {
category: 'output',
color: '#E9967A',
defaults: {
name: {value: ""},
dataType: {value: "", required: true},
adr: {value: "", required: true, validate: RED.validators.number()},
server: {value: "", type: "modbustcp-no-pooling-server"}
},
inputs: 1,
outputs: 2,
icon: "bridge.png",
align: 'right',
paletteLabel: "modbustcp-no-pooling",
label: function () {
return (this.name || "modbustcp-no-pooling");
}
});
</script>
<script type="text/javascript">
RED.nodes.registerType('modbustcp-no-pooling-read', {
category: 'input',
color: '#E9967A',
defaults: {
name: {value: ""},
dataType: {value: "", required: true},
adr: {value: "", required: true, validate: RED.validators.number()},
quantity: {value: "", required:true, validate: RED.validators.number()},
//rate: {value:"", required:true, validate:function(v) { return v > 0 } },
server: {value: "", type: "modbustcp-no-pooling-server"}
},
inputs: 1,
outputs: 2,
icon: "bridge.png",
paletteLabel: "modbustcp-no-pooling",
label: function () {
return (this.name || "modbustcp no pooling");
}
});
</script>