-
Notifications
You must be signed in to change notification settings - Fork 11
/
ads-out.html
190 lines (188 loc) · 9.83 KB
/
ads-out.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
<script type="text/x-red" data-help-name="ADS Output">
<p>Node for sending data to Beckhoff TwinCAT ADS</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.timezone: (string) only on date and time type 'TO_LOCAL' or 'UNCHANGED'</li>
<li>config.outProperty: (string) the property for the outvalue</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 Output">
<div class="form-row">
<label for="node-input-datasource"><i class="fa fa-random"></i> <span data-i18n="ads-out.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-out.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-out.label.varName"></span></label>
<input type="text" id="node-input-varName" data-i18n="[placeholder]ads-out.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-out.label.indexGroup"></span></label>
<input type="text" id="node-input-indexGroup" data-i18n="[placeholder]ads-out.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-out.label.indexOffset"></span></label>
<input type="text" id="node-input-indexOffset" data-i18n="[placeholder]ads-out.placeholder.indexOffset">
</div>
<div class="form-row">
<label for="node-input-varTyp"><i class="fa fa-code"></i> <span data-i18n="ads-out.label.varTyp"></span></label>
<select id="node-input-varTyp">
<option value="BOOL" data-i18n="ads-out.varTyp.BOOL"></option>
<option value="BYTE" data-i18n="ads-out.varTyp.BYTE"></option>
<option value="WORD" data-i18n="ads-out.varTyp.WORD"></option>
<option value="DWORD" data-i18n="ads-out.varTyp.DWORD"></option>
<option value="SINT" data-i18n="ads-out.varTyp.SINT"></option>
<option value="USINT" data-i18n="ads-out.varTyp.USINT"></option>
<option value="INT" data-i18n="ads-out.varTyp.INT"></option>
<option value="UINT" data-i18n="ads-out.varTyp.UINT"></option>
<option value="DINT" data-i18n="ads-out.varTyp.DINT"></option>
<option value="UDINT" data-i18n="ads-out.varTyp.UDINT"></option>
<option value="LINT" data-i18n="ads-out.varTyp.LINT"></option>
<option value="ULINT" data-i18n="ads-out.varTyp.ULINT"></option>
<option value="REAL" data-i18n="ads-out.varTyp.REAL"></option>
<option value="LREAL" data-i18n="ads-out.varTyp.LREAL"></option>
<option value="TIME" data-i18n="ads-out.varTyp.TIME"></option>
<option value="TIME_OF_DAY" data-i18n="ads-out.varTyp.TIME_OF_DAY"></option>
<option value="TOD" data-i18n="ads-out.varTyp.TOD"></option>
<option value="DATE" data-i18n="ads-out.varTyp.DATE"></option>
<option value="DATE_AND_TIME" data-i18n="ads-out.varTyp.DATE_AND_TIME"></option>
<option value="DT" data-i18n="ads-out.varTyp.DT"></option>
<option value="STRING" data-i18n="ads-out.varTyp.STRING"></option>
<option value="RAW" data-i18n="ads-out.varTyp.RAW"></option>
</select>
</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-out.label.varSize"></span></label>
<input type="number" id="node-input-varSize" data-i18n="[placeholder]ads-out.placeholder.varSize">
</div>
<div class="form-row" id="node-row-timezone">
<label for="node-input-timezone"><i class="fa fa-plane"></i> <span data-i18n="ads-out.label.timezone"></span></label>
<select id="node-input-timezone">
<option value="UNCHANGED" data-i18n="ads-out.timezone.UNCHANGED"></option>
<option value="TO_LOCAL" data-i18n="ads-out.timezone.TO_LOCAL"></option>
</select>
</div>
<div class="form-row">
<label for="node-input-outValue"><i class="fa fa-ellipsis-h"></i> <span data-i18n="ads-out.label.outValue"></span></label>
<input type="text" id="node-input-outValue" data-i18n="[placeholder]ads-out.placeholder.outValue">
</div>
<div class="form-row">
<label for="node-input-topic"><i class="fa fa-tasks"></i> <span data-i18n="ads-out.label.topic"></span></label>
<input type="text" id="node-input-topic" data-i18n="[placeholder]ads-out.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 Output", {
category: "Beckhoff PLC",
color: "#00cc00",
align: 'right',
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
},
outValue: {
value: "payload",
required: true
},
varSize: {
value: "",
validate: function (val) {return ($("#node-input-varTyp").val()!== "RAW") || (RED.validators.number(val) && val>0)}
},
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: 0,
icon: "tcat.png",
label: function () {
return this.name || this.varName || "ADS Output";
},
labelStyle: function () {
return this.name ? "node_label_italic" : "";
},
oneditprepare: function() {
if (this.outValue === undefined) {
$("#node-input-outValue").val("payload");
}
$("#node-input-outValue").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();
}
/* node.resize();*/
});
$('#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>