-
Notifications
You must be signed in to change notification settings - Fork 11
/
ads-in.html
244 lines (241 loc) · 13.1 KB
/
ads-in.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
<script type="text/x-red" data-help-name="ADS In">
<p>Node to provide data from Beckhoff TwinCAT ADS</p>
<p><b>This note is not for the transmission of cyclic data. Do not use it in conjunction with a timer. There is a notification node for this.</b></p>
<p>The data are fetched from the PLC when an object is transferred to the input. The entry data will be ignored.</p>
<p>There is an possible to override the node configuration. You can add an property config to the message object. Not all configuration properties need to be overridden.</p>
<li>config.useIndex: (boolean) override the variable use ID (true is not recommended for Twincat)</li>
<li>config.varName: (string) override the variable name</li>
<li>config.indexGroup: (integer/hex-string) override the variable indexGroup only used by useIndex varName is unused then</li>
<li>config.indexOffset: (integer/hex-string) override the variable indexOffset only used by useIndex varName is unused then</li>
<li>config.varType: (string) override the variable type</li>
<li>config.varSize: (integer) the length on RAW and STRING type</li>
<li>config.isarray: (bool) is an ARRAY type, varLowIndex and varHighIndex must set</li>
<li>config.varLowIndex: (integer) the Low index on ARRAY type</li>
<li>config.varHighIndex: (integer) the High index on ARRAY type</li>
<li>config.timezone: (string) only on date and time type 'TO_LOCAL' or 'UNCHANGED'</li>
<li>config.inProperty`: (string) the property for the outvalue</li>
<li>config.useInputMsg`: (bool) the input message will be used to build the out message or an new message will be build.</li>
<li>config.topic: (string) the topic being checked against the message topic. It can be '' to delete an topic.</li>
</script>
<script type="text/x-red" data-template-name="ADS In">
<div class="form-row">
<label for="node-input-datasource"><i class="fa fa-random"></i> <span data-i18n="ads-in.label.datasource"></span></label>
<input type="text" id="node-input-datasource">
</div>
<div class="form-row" id="node-row-useIndex">
<input type="checkbox" id="node-input-useIndex" style="display: inline-block; width: auto; vertical-align: text-bottom;" autocomplete="off">
<label for="node-input-useIndex"><span data-i18n="ads-in.label.useIndex"></span></label>
</div>
<div id="node-row-varName" class="form-row">
<label for="node-input-varName"><i class="fa fa-tag"></i> <span data-i18n="ads-in.label.varName"></span></label>
<input type="text" id="node-input-varName" data-i18n="[placeholder]ads-in.placeholder.varName">
</div>
<div id="node-row-indexGroup" class="form-row">
<label for="node-input-indexGroup"><i class="fa fa-tag"></i> <span data-i18n="ads-in.label.indexGroup"></span></label>
<input type="text" id="node-input-indexGroup" data-i18n="[placeholder]ads-in.placeholder.indexGroup">
</div>
<div id="node-row-indexOffset" class="form-row">
<label for="node-input-indexOffset"><i class="fa fa-tag"></i> <span data-i18n="ads-in.label.indexOffset"></span></label>
<input type="text" id="node-input-indexOffset" data-i18n="[placeholder]ads-in.placeholder.indexOffset">
</div>
<div class="form-row">
<label for="node-input-varTyp"><i class="fa fa-code"></i> <span data-i18n="ads-in.label.varTyp"></span></label>
<select id="node-input-varTyp">
<option value="BOOL" data-i18n="ads-in.varTyp.BOOL"></option>
<option value="BYTE" data-i18n="ads-in.varTyp.BYTE"></option>
<option value="WORD" data-i18n="ads-in.varTyp.WORD"></option>
<option value="DWORD" data-i18n="ads-in.varTyp.DWORD"></option>
<option value="SINT" data-i18n="ads-in.varTyp.SINT"></option>
<option value="USINT" data-i18n="ads-in.varTyp.USINT"></option>
<option value="INT" data-i18n="ads-in.varTyp.INT"></option>
<option value="UINT" data-i18n="ads-in.varTyp.UINT"></option>
<option value="DINT" data-i18n="ads-in.varTyp.DINT"></option>
<option value="UDINT" data-i18n="ads-in.varTyp.UDINT"></option>
<option value="LINT" data-i18n="ads-in.varTyp.LINT"></option>
<option value="ULINT" data-i18n="ads-in.varTyp.ULINT"></option>
<option value="REAL" data-i18n="ads-in.varTyp.REAL"></option>
<option value="LREAL" data-i18n="ads-in.varTyp.LREAL"></option>
<option value="TIME" data-i18n="ads-in.varTyp.TIME"></option>
<option value="TIME_OF_DAY" data-i18n="ads-in.varTyp.TIME_OF_DAY"></option>
<option value="TOD" data-i18n="ads-in.varTyp.TOD"></option>
<option value="DATE" data-i18n="ads-in.varTyp.DATE"></option>
<option value="DATE_AND_TIME" data-i18n="ads-in.varTyp.DATE_AND_TIME"></option>
<option value="DT" data-i18n="ads-in.varTyp.DT"></option>
<option value="STRING" data-i18n="ads-in.varTyp.STRING"></option>
<option value="RAW" data-i18n="ads-in.varTyp.RAW"></option>
</select>
<span id="node-row-isArray" style="display: inline-block; width: auto; vertical-align: center;" >
<input type="checkbox" id="node-input-isArray" style="display: inline-block; width: auto; vertical-align: text-bottom;" autocomplete="off">
<label for="node-input-isArray"><span data-i18n="ads-in.label.isArray"></span></label>
</span>
</div>
<div class="form-row" id="node-row-varSize">
<label for="node-input-varSize"><i class="fa fa-arrows-h"></i> <span data-i18n="ads-in.label.varSize"></span></label>
<input type="number" id="node-input-varSize" data-i18n="[placeholder]ads-in.placeholder.varSize">
</div>
<div class="form-row" id="node-row-varIndex">
<label for="node-input-varLowIndex"><i class="fa fa-caret-down"></i> <span data-i18n="ads-in.label.varLowIndex"></span></label>
<input type="text" id="node-input-varLowIndex" data-i18n="[placeholder]ads-in.placeholder.varLowIndex" maxlength="6" size="6" style="width: 58px;">
<label for="node-input-varHighIndex" style="width:90px;"><i class="fa fa-caret-up"></i> <span data-i18n="ads-in.label.varHighIndex"></span></label>
<input type="text" id="node-input-varHighIndex" data-i18n="[placeholder]ads-in.placeholder.varHighIndex" maxlength="6" size="6" style="width: 58px;">
</div>
<div class="form-row" id="node-row-timezone">
<label for="node-input-timezone"><i class="fa fa-plane"></i> <span data-i18n="ads-in.label.timezone"></span></label>
<select id="node-input-timezone">
<option value="UNCHANGED" data-i18n="ads-in.timezone.UNCHANGED"></option>
<option value="TO_LOCAL" data-i18n="ads-in.timezone.TO_LOCAL"></option>
</select>
</div>
<div class="form-row">
<label for="node-input-inValue"><i class="fa fa-ellipsis-h"></i> <span data-i18n="ads-in.label.inValue"></span></label>
<input type="text" id="node-input-inValue" data-i18n="[placeholder]ads-in.placeholder.inValue">
</div>
<div class="form-row">
<label> </label>
<input type="checkbox" id="node-input-useInputMsg" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-useInputMsg" style="width: 70%;"><span data-i18n="ads-in.label.useInputMsg"></span></label>
</div>
<div class="form-row">
<label for="node-input-topic"><i class="fa fa-tasks"></i> <span data-i18n="ads-in.label.topic"></span></label>
<input type="text" id="node-input-topic" data-i18n="[placeholder]ads-in.placeholder.topic">
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
<input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
</div>
</script>
<script type="text/javascript">
RED.nodes.registerType("ADS In", {
category: "Beckhoff PLC",
color: "#00dd00",
defaults: {
name: {
name: ""
},
datasource: {
type: "ads-connection",
required: true
},
useIndex: {
value: false
},
varName: {
value: "",
validate: function (val) {return ($("#node-input-useIndex").prop('checked')||val!="")}
},
indexGroup: {
value: "",
validate: function (val) {return (!($("#node-input-useIndex").prop('checked'))||/^((0[xX][0-9A-Fa-f]+)|([0-9]+))$/.test(val))}
},
indexOffset: {
value: "",
validate: function (val) {return (!($("#node-input-useIndex").prop('checked'))||/^((0[xX][0-9A-Fa-f]+)|([0-9]+))$/.test(val))}
},
varTyp: {
value: "",
required: true
},
inValue: {
value: "payload",
required: true
},
varSize: {
value: "",
validate: function (val) {return ($("#node-input-varTyp").val()!== "RAW") || (RED.validators.number(val) && val>0)}
},
varLowIndex: {
value: "",
validate: function (val) {return ($("#node-input-varTyp").val()!== "ARRAY") || (RED.validators.number(val) && val>0)}
},
varHighIndex: {
value: "",
validate: function (val) {return ($("#node-input-varTyp").val()!== "ARRAY") || (RED.validators.number(val) && val>0)}
},
useInputMsg: {
value: false
},
isArray: {
value: false
},
timezone: {
value: "UNCHANGED",
validate: function (val) {return ((val !== "TIME" &&
val !== "TIME_OF_DAY" &&
val !== "TOD" &&
val !== "DATE" &&
val !== "DATE_AND_TIME" &&
val !== "DT")
|| (val === "UNCHANGED") || (val === "TO_LOCAL"))}
},
topic: {
value: "",
required: false
}
},
inputs: 1,
outputs: 1,
icon: "tcat.png",
label: function () {
return this.name || this.varName || "ADS In";
},
labelStyle: function () {
return this.name ? "node_label_italic" : "";
},
oneditprepare: function() {
if (this.inValue === undefined) {
$("#node-input-inValue").val("payload");
}
$("#node-input-inValue").typedInput({default:'msg',types:['msg']});
$("#node-input-varTyp").change(function(e) {
var varType = $(this).val();
if (varType === "RAW" ||
varType === "STRING") {
$("#node-row-varSize").show();
} else {
$("#node-row-varSize").hide();
}
if (varType === "TIME" ||
varType === "TIME_OF_DAY" ||
varType === "TOD" ||
varType === "DATE" ||
varType === "DATE_AND_TIME" ||
varType === "DT") {
$("#node-row-timezone").show();
} else {
$("#node-row-timezone").hide();
}
if (varType === "RAW" ) {
$("#node-row-isArray").hide();
$("#node-row-varIndex").hide();
$("#node-row-varLowIndex").hide();
$("#node-row-varHighIndex").hide();
} else {
$("#node-row-isArray").show();
}
/* node.resize();*/
});
$('#node-input-isArray[type="checkbox"]').change(function() {
if (this.checked) {
$("#node-row-varIndex").show();
$("#node-row-varLowIndex").show();
$("#node-row-varHighIndex").show();
} else {
$("#node-row-varIndex").hide();
$("#node-row-varLowIndex").hide();
$("#node-row-varHighIndex").hide();
}
});
$('#node-input-useIndex[type="checkbox"]').change(function() {
if (this.checked) {
$("#node-row-varName").hide();
$("#node-row-indexGroup").show();
$("#node-row-indexOffset").show();
} else {
$("#node-row-varName").show();
$("#node-row-indexGroup").hide();
$("#node-row-indexOffset").hide();
}
});
}
});
</script>