-
Notifications
You must be signed in to change notification settings - Fork 0
/
modbustcp.html
283 lines (268 loc) · 11.9 KB
/
modbustcp.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
<!--
*
* 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-server">
<div class="form-row">
<label for="node-config-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-config-input-name" placeholder="Name">
</div>
<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>
<div class="form-row1">
<label for="node-config-input-reconnecttimeout"><i class="fa fa-clock-o"></i> Reconnect Interval (s)</label>
<input type="text" id="node-config-input-reconnecttimeout">
</div>
</script>
<script type="text/x-red" data-help-name="modbustcp-server">
<p>Uses MODBUSTCP to read/write ethernet host:port and register/coil addresses.</p>
<p>Reconnect Interval allows the MODBUSTCP connection to automatically reconnect after the interval has elapsed to re-establish a TCP connection.
Reconnect Interval is an optional input. Leave blank if auto-reconnect is not desired. </p>
</script>
<script type="text/x-red" data-template-name="modbustcp-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-topic"><i class="icon-tag"></i> Topic</label>
<input type="text" id="node-input-topic" placeholder="topic">
</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>
<option value="Coils">FC 15: Write Multiple Coils</option>
<option value="HoldingRegisters">FC 16: Write Multiple Holding Registers</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-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>
<li>FC 15: Write Multiple Coils</li>
<li>FC 16: Write Multiple Holding Registers</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.
For FC15, <b>msg.payload</b> must be an array of numbers or strings with values of 0 or 1. For FC 16, <b>msg.payload</b> must be an array of numbers or strings with values between 0:65535.
</p>
</script>
<script type="text/x-red" data-template-name="modbustcp-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-topic"><i class="icon-tag"></i> Topic</label>
<input type="text" id="node-input-topic" placeholder="topic">
</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="fa fa-clock-o"></i> Poll Rate </label>
<input type="number" id="node-input-rate" placeholder="1-65535" style="max-width:120px">
<select id="node-input-rateUnit" style="max-width:160px">
<option value="ms">millisecond(s)</option>
<option value="s">second(s)</option>
<option value="m">minute(s)</option>
<option value="h">hour(s)</option>
</select>
</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>
<div class="header">IEEE-754</div>
<div class="bordered">
<div class="form-row">
<label for="node-input-ieeeType"><i class="fa fa-hashtag"></i> Type</label>
<select id="node-input-ieeeType">
<option selected="selected" value="off"><off></option>
<option value="single">single</option>
<option value="double">double</option>
</select>
</div>
<div class="form-row">
<label for="node-input-ieeeBE"><i class="fa fa-exchange"></i> Endian</label>
<select id="node-input-ieeeBE">
<option selected="selected" value=true>Big Endian</option>
<option value=false>Little Endian</option>
</select>
</div>
</div>
</script>
<script type="text/x-red" data-help-name="modbustcp-read">
<p>Modbus TCP client node. Connects to a Modbus TCP server to read register values at a given poll rate.
<h3>Configuration Settings</h3>
<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>
<p><strong>IEEE-754</strong> Valid for register values, you can choose to have the output formatted
for IEEE 754 Single and Double percision. Choose also the input format for Big or Little endian</p>
<h3>Input</h3>
You may input one or more payload values to initiate one or more additional timed read events.
<br/><br/>
For example, use an inject node to inject a JSON payload similar to the following:
<br/>
<pre>
<code>
{
"name": "HoldingsDblBig",
"topic": "Topic1",
"address": 0,
"quantity": 4,
"dataType": "FC3",
"interval": 3000, // in ms
"ieeeBE": true,
"ieeeType": "double"
}
</code>
</pre>
<i>*Refer to the Readme file for further explaination.</i>Explanation
<br/><br/>
<h3>Output</h3>
Outputs an object called <b>msg</b> containing <b>msg.payload</b> with an array of the read coils/inputs/registers.</p>
<b>msg.settings</b> also cotains further information about the request used to generate the read information, including
a <b>msg.settings.name</b> which can be used to distinguish output values when a single node is generating multiple
output events.
</script>
<script type="text/javascript">
RED.nodes.registerType('modbustcp-server', {
category: 'config',
defaults: {
name: {value: "", required: false},
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()},
reconnecttimeout: {value: "", required: false}
},
label: function () {
return (this.name || "modbustcp@" + this.host + ":" + this.port);
}
});
</script>
<script type="text/javascript">
RED.nodes.registerType('modbustcp-write', {
category: 'output',
color: '#E9967A',
defaults: {
name: {value: ""},
topic: {value: ""},
dataType: {value: "", required: true},
adr: {value: "", required: true, validate: RED.validators.number()},
server: {value: "", type: "modbustcp-server"}
},
inputs: 1,
outputs: 0,
icon: "bridge.png",
align: 'right',
paletteLabel: "modbustcp",
label: function () {
return (this.name || "modbustcp");
}
});
</script>
<script type="text/javascript">
RED.nodes.registerType('modbustcp-read', {
category: 'input',
color: '#E9967A',
defaults: {
name: {value: ""},
topic: {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
}
},
rateUnit: {
value: "", required: true, validate: function (v) {
return "ms" == v || "s" == v || "m" == v || "h" == v
}
},
server: {value: "", type: "modbustcp-server"},
ieeeType: {value: "off", required: true},
ieeeBE: {value: true, required: true}
},
inputs: 1,
outputs: 1,
icon: "bridge.png",
paletteLabel: "modbustcp",
label: function () {
return (this.name || "modbustcp");
}
});
</script>