forked from bitpool/edge-modbus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bp-modbus-reader.html
187 lines (175 loc) · 7.69 KB
/
bp-modbus-reader.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
<!--
MIT License Copyright 2021, 2022 - Bitpool Pty Ltd
-->
<script type="text/javascript">
RED.nodes.registerType("bp-reader", {
category: "Bitpool Modbus",
defaults: {
name: { value: null },
showStatusActivities: { value: true },
showErrors: { value: true },
showWarnings: {value: true},
logIOActivities: { value: false },
server: { type: 'bp-modbus-client', required: true },
useIOFile: { value: false },
ioFile: { value: '', type: 'bp-modbus-io-config', required: false },
useIOForPayload: { value: false },
emptyMsgOnFail: { value: false },
keepMsgProperties: { value: true },
delayOnStart: {value: false},
startDelayTime: {value: ''},
},
inputs: 1,
outputs: 1,
color: "#00aeef",
icon: "bitpool.svg",
label: function () {
return this.name || "reader";
},
paletteLabel: function () {
return "reader";
},
oneditprepare: function () {
var node = this;
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._("bp-modbus-contrib.tabs-label.settings")
})
$("#node-input-name").typedInput({ type: 'str', types: ['str'] })
$("#node-input-name").on('change', function (event, type, value) {
node.name = value
});
let useIOFileCheckbox = $('#node-input-useIOFile')
let modbusiofileRow = $('#modbusiofile-row')
useIOFileCheckbox.change(function () {
if ($(this).is(':checked')) {
modbusiofileRow.show()
} else {
modbusiofileRow.hide()
}
})
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()
}
})
},
});
</script>
<script type="text/html" data-template-name="bp-reader">
<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">
<ul style="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" style="display: flex;">
<input type="text" id="node-input-server" style="width: 100%;">
</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="bp-modbus-contrib.label.delayOnStart"></span></label>
<input type="checkbox" id="node-input-delayOnStart" 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="bp-modbus-contrib.label.startDelayTime"></span></label>
<input type="text" id="node-input-startDelayTime" placeholder="10" style="width:80px">
</div> -->
</div>
<div id="modbus-options-tab" style="display:none">
<div class="form-row">
<label style="min-width:160px" for="node-input-emptyMsgOnFail"><i class="fa fa-th"></i> <span
data-i18n="bp-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:160px" for="node-input-keepMsgProperties"><i class="fa fa-th"></i> <span
data-i18n="bp-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:160px" for="node-input-showStatusActivities"><i class="fa fa-th"></i> <span
data-i18n="bp-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:160px" for="node-input-showErrors"><i class="fa fa-th"></i> <span
data-i18n="bp-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:160px" for="node-input-showWarnings"><i class="fa fa-th"></i> <span
data-i18n="bp-modbus-contrib.label.showWarnings"></span></label>
<input type="checkbox" id="node-input-showWarnings" style="max-width:30px">
</div>
<hr>
<div class="form-row">
<label style="min-width:160px" for="node-input-useIOFile"><i class="fa fa-file-code-o"></i> <span
data-i18n="bp-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:160px" for="node-input-logIOActivities"><i class="fa fa-th"></i> <span
data-i18n="bp-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:160px" for="node-input-useIOForPayload"><i class="fa fa-comment-o"></i> <span data-i18n="bp-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="bp-modbus-contrib.label.ioFile"></span></label>
<input type="text" id="node-input-ioFile">
</div>
</div>
</div>
</div>
</script>
<script type="text/html" data-help-name="bp-reader">
<p>
Allows the reading of a Modbus device with user defined input object.
</p>
<p>Connects to a Modbus device via TCP or serial connection.</p>
<p>
<h4>Function codes (1-4):</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>Input object code example:</p>
<code>
msg.payload = { value: msg.payload, 'fc': 1, 'unitid': 1, 'address': 0 , 'quantity': 1 }
return msg
</code>
<hr>
<h3>Resources:</h3>
<h4><strong>Online Docs:</strong></h4>
<ul type="1">
<li><a href="https://www.bitpool.com/">bitpool.com</a> - check us out here.</li>
<li><a href="https://app.bitpool.com/">app.bitpool.com</a> - set up your account.</li>
<li><a href="https://wiki.bitpool.com/">wiki.bitpool.com</a> - find more documentation.</li>
</ul>
</script>