@t0a5tbr0t/node-red-contrib-opcua 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/LICENSE +20 -0
  3. package/Readme.md +239 -0
  4. package/images/PROSYS-OPC-UA-EXAMPLE2.png +0 -0
  5. package/images/nodeopcua64.png +0 -0
  6. package/images/opcuanode.png +0 -0
  7. package/images/opcuanodeLogo64.png +0 -0
  8. package/opcua/101-opcuaitem.html +106 -0
  9. package/opcua/101-opcuaitem.js +82 -0
  10. package/opcua/102-opcuaclient.html +274 -0
  11. package/opcua/102-opcuaclient.js +2741 -0
  12. package/opcua/103-opcuabrowser.html +71 -0
  13. package/opcua/103-opcuabrowser.js +230 -0
  14. package/opcua/104-opcuaserver.html +261 -0
  15. package/opcua/104-opcuaserver.js +1844 -0
  16. package/opcua/105-opcuaendpoint.html +224 -0
  17. package/opcua/105-opcuaendpoint.js +64 -0
  18. package/opcua/106-opcuaevent.html +110 -0
  19. package/opcua/106-opcuaevent.js +50 -0
  20. package/opcua/107-opcuamethod.html +244 -0
  21. package/opcua/107-opcuamethod.js +521 -0
  22. package/opcua/108-opcuarights.html +223 -0
  23. package/opcua/108-opcuarights.js +156 -0
  24. package/opcua/109-opcuadiscovery.html +51 -0
  25. package/opcua/109-opcuadiscovery.js +180 -0
  26. package/opcua/dump_certificates.js +55 -0
  27. package/opcua/icons/opcuanode.png +0 -0
  28. package/opcua/icons/opcuanodeLogo.png +0 -0
  29. package/opcua/opcua-basics.js +1061 -0
  30. package/opcua/public/vendor/opc-foundation/binary/OPC.ISA95.Types.bsd.xml +141 -0
  31. package/opcua/public/vendor/opc-foundation/binary/Opc.Ua.Adi.Types.bsd.xml +76 -0
  32. package/opcua/public/vendor/opc-foundation/binary/Opc.Ua.Di.Types.bsd.xml +11 -0
  33. package/opcua/public/vendor/opc-foundation/binary/Opc.Ua.Gds.Types.bsd.xml +25 -0
  34. package/opcua/public/vendor/opc-foundation/binary/Opc.Ua.Types.bsd.xml +2391 -0
  35. package/opcua/public/vendor/opc-foundation/csv/AttributeIds.csv +22 -0
  36. package/opcua/public/vendor/opc-foundation/csv/NodeIds.csv +5746 -0
  37. package/opcua/public/vendor/opc-foundation/csv/Opc.Ua.StatusCodes.csv +227 -0
  38. package/opcua/public/vendor/opc-foundation/csv/OpcUaDiModel.csv +1523 -0
  39. package/opcua/public/vendor/opc-foundation/csv/OpcUaGdsModel.csv +400 -0
  40. package/opcua/public/vendor/opc-foundation/csv/ServerCapabilities.csv +13 -0
  41. package/opcua/public/vendor/opc-foundation/csv/ServerCapabilityIdentifiers.csv +13 -0
  42. package/opcua/public/vendor/opc-foundation/csv/StatusCode.csv +227 -0
  43. package/opcua/public/vendor/opc-foundation/csv/StatusCodes.csv +227 -0
  44. package/opcua/public/vendor/opc-foundation/schema/OPC.ISA95.Types.xsd +163 -0
  45. package/opcua/public/vendor/opc-foundation/schema/OPCBinarySchema.xsd +119 -0
  46. package/opcua/public/vendor/opc-foundation/schema/Opc.Ua.Types.xsd +3938 -0
  47. package/opcua/public/vendor/opc-foundation/schema/SecuredApplication.xsd +106 -0
  48. package/opcua/public/vendor/opc-foundation/schema/UANodeSet.xsd +420 -0
  49. package/opcua/public/vendor/opc-foundation/xml/OPC.ISA95.NodeSet2.Nov52013.xml +3293 -0
  50. package/opcua/public/vendor/opc-foundation/xml/Opc.ISA95.NodeSet2.xml +3589 -0
  51. package/opcua/public/vendor/opc-foundation/xml/Opc.Ua.Adi.NodeSet2.xml +8301 -0
  52. package/opcua/public/vendor/opc-foundation/xml/Opc.Ua.Adi.Types.bsd.xml +76 -0
  53. package/opcua/public/vendor/opc-foundation/xml/Opc.Ua.Adi.Types.xsd +157 -0
  54. package/opcua/public/vendor/opc-foundation/xml/Opc.Ua.AutoID.NodeSet2.xml +6062 -0
  55. package/opcua/public/vendor/opc-foundation/xml/Opc.Ua.Di.NodeSet2.xml +5066 -0
  56. package/opcua/public/vendor/opc-foundation/xml/Opc.Ua.Di.PredefinedNodes.xml +11495 -0
  57. package/opcua/public/vendor/opc-foundation/xml/Opc.Ua.Di.Types.bsd +86 -0
  58. package/opcua/public/vendor/opc-foundation/xml/Opc.Ua.Di.Types.bsd.xml +11 -0
  59. package/opcua/public/vendor/opc-foundation/xml/Opc.Ua.Di.Types.xsd +155 -0
  60. package/opcua/public/vendor/opc-foundation/xml/Opc.Ua.Gds.NodeSet.xml +15226 -0
  61. package/opcua/public/vendor/opc-foundation/xml/Opc.Ua.Gds.NodeSet2.xml +6214 -0
  62. package/opcua/public/vendor/opc-foundation/xml/Opc.Ua.Gds.Types.bsd.xml +25 -0
  63. package/opcua/public/vendor/opc-foundation/xml/Opc.Ua.Gds.Types.xsd +30 -0
  64. package/opcua/public/vendor/opc-foundation/xml/Opc.Ua.NodeSet-2.xml +134881 -0
  65. package/opcua/public/vendor/opc-foundation/xml/Opc.Ua.NodeSet-3.xml +134881 -0
  66. package/opcua/public/vendor/opc-foundation/xml/Opc.Ua.NodeSet.xml +134881 -0
  67. package/opcua/public/vendor/opc-foundation/xml/Opc.Ua.NodeSet2.Part10.xml +832 -0
  68. package/opcua/public/vendor/opc-foundation/xml/Opc.Ua.NodeSet2.Part11.xml +793 -0
  69. package/opcua/public/vendor/opc-foundation/xml/Opc.Ua.NodeSet2.Part12.xml +3877 -0
  70. package/opcua/public/vendor/opc-foundation/xml/Opc.Ua.NodeSet2.Part13.xml +344 -0
  71. package/opcua/public/vendor/opc-foundation/xml/Opc.Ua.NodeSet2.Part3.xml +1103 -0
  72. package/opcua/public/vendor/opc-foundation/xml/Opc.Ua.NodeSet2.Part4.xml +3091 -0
  73. package/opcua/public/vendor/opc-foundation/xml/Opc.Ua.NodeSet2.Part5.xml +17092 -0
  74. package/opcua/public/vendor/opc-foundation/xml/Opc.Ua.NodeSet2.Part8.xml +525 -0
  75. package/opcua/public/vendor/opc-foundation/xml/Opc.Ua.NodeSet2.Part9.xml +2049 -0
  76. package/opcua/public/vendor/opc-foundation/xml/Opc.Ua.NodeSet2.Part999.xml +134 -0
  77. package/opcua/public/vendor/opc-foundation/xml/Opc.Ua.NodeSet2.xml +67169 -0
  78. package/opcua/public/vendor/opc-foundation/xml/Opc.Ua.PredefinedNodes.xml +64500 -0
  79. package/opcua/public/vendor/opc-foundation/xml/OpcUaDiModel.xml +1239 -0
  80. package/opcua/utils.js +55 -0
  81. package/package.json +68 -0
  82. package/users.json +22 -0
@@ -0,0 +1,224 @@
1
+ <!--
2
+
3
+ Copyright 2015 Valmet Automation Inc.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+
17
+ -->
18
+
19
+ <script type="text/javascript">
20
+ RED.nodes.registerType('OpcUa-Endpoint', {
21
+ category: 'config',
22
+ label: function () {
23
+ return this.name || "OPC UA Endpoint";
24
+ },
25
+ labelStyle: function () {
26
+ return this.name ? "node_label_italic" : "";
27
+ },
28
+ defaults: {
29
+ name: {value: "", required: false},
30
+ endpoint: {value: "", required: true},
31
+ secpol: {value: "None"},
32
+ secmode: {value: "None"},
33
+ none: {value: true},
34
+ login: {value: false},
35
+ usercert: {value: false},
36
+ usercertificate: {value: ""},
37
+ userprivatekey: {value: ""},
38
+ },
39
+ credentials: {
40
+ user: {type: "text"},
41
+ password: {type: "password"}
42
+ },
43
+ // label: function () {
44
+ // return this.endpoint || "OPC UA Endpoint";
45
+ // },
46
+ oneditprepare: function () {
47
+ var node = this;
48
+ try {
49
+ var noneCheckbox = $("#node-config-input-none");
50
+ var loginCheckbox = $("#node-config-input-login");
51
+ var usercertCheckbox = $("#node-config-input-usercert");
52
+ var authRow = $(".node-input-useAuth-row");
53
+ var certRow = $(".node-input-userCert-row");
54
+ noneCheckbox.prop('checked', node.none);
55
+ loginCheckbox.prop('checked', node.login);
56
+ usercertCheckbox.prop('checked', node.usercert);
57
+
58
+ if (node.none === true) {
59
+ noneCheckbox.prop('checked', true);
60
+ // authRow.show();
61
+ $('#node-input-user').val('');
62
+ $('#node-input-password').val('');
63
+ } else {
64
+ noneCheckbox.prop('checked', false);
65
+ // loginCheckbox.prop('checked', false);
66
+ // usercertCheckbox.prop('checked', false);
67
+ // authRow.hide();
68
+ if (node.login === true) {
69
+ authRow.show();
70
+ }
71
+ else {
72
+ authRow.hide();
73
+ }
74
+ if (node.usercert === true) {
75
+ certRow.show();
76
+ }
77
+ else {
78
+ certRow.hide();
79
+ }
80
+ }
81
+
82
+ if (node.login === true) {
83
+ loginCheckbox.prop('checked', true);
84
+ authRow.show();
85
+ } else {
86
+ loginCheckbox.prop('checked', false);
87
+ authRow.hide();
88
+ }
89
+
90
+ if (node.usercert === true) {
91
+ usercertCheckbox.prop('checked', true);
92
+ certRow.show();
93
+ $('#node-input-user').val('');
94
+ $('#node-input-password').val('');
95
+ } else {
96
+ usercertCheckbox.prop('checked', false);
97
+ certRow.hide();
98
+ }
99
+ noneCheckbox.change(function () {
100
+ if ($(this).is(":checked")) {
101
+ console.log("Changed Anonymous: TRUE");
102
+ node.none = true;
103
+ noneCheckbox.prop('checked', true);
104
+ loginCheckbox.prop('checked', false);
105
+ usercertCheckbox.prop('checked', false);
106
+ $('#node-input-user').val('');
107
+ $('#node-input-password').val('');
108
+ authRow.hide();
109
+ certRow.hide();
110
+ } else {
111
+ console.log("Changed Anonymous: FALSE");
112
+ node.none = false;
113
+ // $('#node-input-user').val('');
114
+ // $('#node-input-password').val('');
115
+ }
116
+ });
117
+
118
+ loginCheckbox.change(function () {
119
+ if ($(this).is(":checked")) {
120
+ login = true;
121
+ usercertCheckbox.prop('checked', false);
122
+ noneCheckbox.prop('checked', false);
123
+ authRow.show();
124
+ certRow.hide();
125
+ } else {
126
+ login = false;
127
+ authRow.hide();
128
+ certRow.hide();
129
+ // DO NOT CLEAR
130
+ // $('#node-input-user').val('');
131
+ // $('#node-input-password').val('');
132
+ }
133
+ });
134
+
135
+ usercertCheckbox.change(function () {
136
+ if ($(this).is(":checked")) {
137
+ usercert = true;
138
+ loginCheckbox.prop('checked', false);
139
+ noneCheckbox.prop('checked', false);
140
+ certRow.show();
141
+ authRow.hide();
142
+ } else {
143
+ usercert = false;
144
+ certRow.hide();
145
+ authRow.hide();
146
+ $('#node-input-usercertificate').val('');
147
+ $('#node-input-userprivatekey').val('');
148
+ }
149
+ });
150
+
151
+ } catch (err) {
152
+ console.error(err);
153
+ }
154
+ finally {
155
+ // console.debug("finally"); // Nothing to do
156
+ }
157
+ }
158
+ });
159
+
160
+ </script>
161
+
162
+ <script type="text/x-red" data-template-name="OpcUa-Endpoint">
163
+ <div class="form-row">
164
+ <label for="node-config-input-name"><i class="icon-tasks"></i> Name</label>
165
+ <input type="text" id="node-config-input-name" placeholder="">
166
+ </div>
167
+ <div class="form-row">
168
+ <label for="node-config-input-endpoint"><i class="icon-link"></i> Endpoint</label>
169
+ <input type="text" id="node-config-input-endpoint">
170
+ </div>
171
+ <div class="form-row">
172
+ <label for="node-config-input-secpol"><i class="icon-key"></i> SecurityPolicy</label>
173
+ <select type="text" id="node-config-input-secpol">
174
+ <option value="None">None</option>
175
+ <option value="Basic128">Basic128</option>
176
+ <option value="Basic192">Basic192</option>
177
+ <option value="Basic192Rsa15">Basic192Rsa15</option>
178
+ <option value="Basic256Rsa15">Basic256Rsa15</option>
179
+ <option value="Basic256Sha256">Basic256Sha256</option>
180
+ <option value="Aes128_Sha256">Aes128_Sha256</option>
181
+ <option value="Aes128_Sha256_RsaOaep">Aes128_Sha256_RsaOaep</option>
182
+ <option value="PubSub_Aes128_CTR">PubSub_Aes128_CTR</option>
183
+ <option value="PubSub_Aes256_CTR">PubSub_Aes256_CTR</option>
184
+ <option value="Basic128Rsa15">Basic128Rsa15</option>
185
+ <option value="Basic256">Basic256</option>
186
+ </select>
187
+ </div>
188
+ <div class="form-row">
189
+ <label for="node-config-input-secmode"><i class="icon-key"></i> SecurityMode</label>
190
+ <select type="text" id="node-config-input-secmode">
191
+ <option value="None">None</option>
192
+ <option value="Sign">Sign</option>
193
+ <option value="SignAndEncrypt">Sign&Encrypt</option>
194
+ </select>
195
+ </div>
196
+ <div class="form-row">
197
+ <lable><input type="checkbox" id="node-config-input-none" > Anonymous</lable>
198
+ </div>
199
+ <div class="form-row">
200
+ <lable><input type="checkbox" id="node-config-input-login" > use credentials</lable>
201
+ </div>
202
+ <div class="form-row">
203
+ <lable><input type="checkbox" id="node-config-input-usercert" > user certificate</lable>
204
+ </div>
205
+
206
+ <div class="form-row node-input-useAuth-row">
207
+ <label for="node-config-input-user"><i class="icon-user"></i> User</label>
208
+ <input type="text" id="node-config-input-user">
209
+ </div>
210
+ <div class="form-row node-input-useAuth-row">
211
+ <label for="node-config-input-password"><i class="icon-password"></i> Password</label>
212
+ <input type="password" id="node-config-input-password">
213
+ </div>
214
+
215
+ <div class="form-row node-input-userCert-row">
216
+ <label for="node-config-input-usercertificate"><i class="icon-file"></i> Certificate file</label>
217
+ <input type="text" id="node-config-input-usercertificate">
218
+ </div>
219
+ <div class="form-row node-input-userCert-row">
220
+ <label for="node-config-input-userprivatekey"><i class="icon-file"></i> Private key file</label>
221
+ <input type="text" id="node-config-input-userprivatekey">
222
+ </div>
223
+
224
+ </script>
@@ -0,0 +1,64 @@
1
+ /**
2
+
3
+ Copyright 2015 Valmet Automation Inc.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+
17
+ **/
18
+
19
+ module.exports = function (RED) {
20
+ "use strict";
21
+
22
+ function OpcUaEndpointNode(n) {
23
+
24
+ RED.nodes.createNode(this, n);
25
+
26
+ // Used to translate node-opcua old (v0.x.x) secmode strings to new (v2.x.x) secmode strings
27
+ const security_mode_map_compat = {
28
+ "NONE": "None",
29
+ "None": "None",
30
+ "SIGN": "Sign",
31
+ "Sign": "Sign",
32
+ "SIGNANDENCRYPT": "SignAndEncrypt",
33
+ "SignAndEncrypt": "SignAndEncrypt"
34
+ };
35
+ this.name = n.name; // Added, issue #842
36
+ this.endpoint = n.endpoint;
37
+ this.securityPolicy = n.secpol;
38
+ this.securityMode = security_mode_map_compat[n.secmode];
39
+ this.login = n.login;
40
+ this.none = n.none;
41
+ this.usercert = n.usercert;
42
+ this.userCertificate = n.usercertificate;
43
+ this.userPrivatekey = n.userprivatekey;
44
+
45
+ if (this.credentials) {
46
+ // from node-opcua version 2.0.0 and onwards empty strings are not allowed anymore, so use null instead
47
+ this.user = this.credentials.user && this.credentials.user.length > 0 ? this.credentials.user : null;
48
+ this.password = this.credentials.password && this.credentials.password.length > 0 ? this.credentials.password : null;
49
+ }
50
+ }
51
+
52
+ RED.nodes.registerType("OpcUa-Endpoint", OpcUaEndpointNode, {
53
+
54
+ credentials: {
55
+ user: {
56
+ type: "text"
57
+ },
58
+ password: {
59
+ type: "password"
60
+ }
61
+ }
62
+ });
63
+
64
+ };
@@ -0,0 +1,110 @@
1
+ <!--
2
+
3
+ Copyright 2016 Valmet Automation Inc.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+
17
+ -->
18
+
19
+ <script type="text/javascript">
20
+ RED.nodes.registerType('OpcUa-Event',{
21
+ category: 'opcua',
22
+ color:"#3FADB5",
23
+ defaults: {
24
+ root: {value:"", required:true}, // ns=2;i=85 Server object to look through all objects under it
25
+ activatecustomevent: {value: false, required:true},
26
+ eventtype: {value:"", required:true},
27
+ customeventtype: {value:""},
28
+ name: {value:""}
29
+ },
30
+ inputs:1,
31
+ outputs:1,
32
+ align: "right",
33
+ icon: "opcuanodeLogo.png",
34
+ label: function() {
35
+ return this.name || "OPC UA Event";
36
+ },
37
+ labelStyle: function() {
38
+ return this.name?"node_label_italic":"";
39
+ },
40
+ oneditprepare: function () {
41
+
42
+ var node = this;
43
+
44
+ try {
45
+ var inputActivateCustomEvent = $('#node-input-activatecustomevent');
46
+ var inputCustomEventTypeRow = $('#node-input-customeventtyperow');
47
+ var inputEventTypeRow = $('#node-input-eventtype-row');
48
+ adapt_input(); // initialize
49
+ inputActivateCustomEvent.change(adapt_input);
50
+
51
+ } catch (err) {
52
+ node.error(err);
53
+ }
54
+
55
+ function adapt_input() {
56
+ if (inputActivateCustomEvent.is(':checked')) {
57
+ inputCustomEventTypeRow.show();
58
+ inputEventTypeRow.hide();
59
+ }
60
+ else {
61
+ inputCustomEventTypeRow.hide();
62
+ inputEventTypeRow.show();
63
+ }
64
+ }
65
+ }
66
+ });
67
+ </script>
68
+
69
+ <script type="text/x-red" data-template-name="OpcUa-Event">
70
+ <div class="form-row">
71
+ <label for="node-input-root"><i class="icon-tasks"></i> Source node</label>
72
+ <input type="text" id="node-input-root" placeholder="i=2253">
73
+ </div>
74
+ <div class="form-row" id="node-input-activatecustomeventrow">
75
+ <label for="node-input-activatecustomevent"><i class="icon-tasks"></i> Custom event</label>
76
+ <input type="checkbox" id="node-input-activatecustomevent" style="width: auto">
77
+ </div>
78
+ <div class="form-row" id="node-input-customeventtyperow">
79
+ <label for="node-input-customeventtype"><i class="icon-tasks"></i> Event Type</label>
80
+ <input type="text" id="node-input-customeventtype" placeholder="ns=2;i=1234">
81
+ </div>
82
+ <div class="form-row" id="node-input-eventtype-row">
83
+ <label for="node-input-datatype"><i class="icon-tag"></i> Event Type</label>
84
+ <select type="text" id="node-input-eventtype" style="display: inline-block; vertical-align: middle; width:60%;">
85
+ <option selected disabled value="" >Choose a Event Type</option>
86
+ <option selected value="i=2041">BaseEvent (all)</option>
87
+ <option value="i=2052">AuditEvent</option>
88
+ <option value="i=2132">BaseModelChangeEvent</option>
89
+ <option value="i=2782">ConditionType</option>
90
+ <option value="i=3035">Event Queue Overflow</option>
91
+ <option value="i=11436">Progress Event</option>
92
+ <option value="i=2130">System Event</option>
93
+ </select>
94
+ </div>
95
+ <div class="form-row">
96
+ <label for="node-input-name"><i class="icon-tag"></i> Name</label>
97
+ <input type="text" id="node-input-name" placeholder="">
98
+ </div>
99
+ </script>
100
+
101
+ <script type="text/x-red" data-help-name="OpcUa-Event">
102
+ <p>Defines the OPC UA events that will be subscribed from the server.</p>
103
+ <p>The Source node defines the node where events are subscribed for.
104
+ The root Server node id is used, if all events of the server shall be processed.
105
+ If available, other specific node ids can be used for a subset of events.
106
+ Not using the root Server node might for example make sense in case of an aggregating server.</p>
107
+ <p>The Event Type defines what kind of events are subscribed. Events of the given Event Type and all subtypes are returned.
108
+ An event type can be selected in the dropdown field, or manually entered when marking the checkbox.
109
+ </p>
110
+ </script>
@@ -0,0 +1,50 @@
1
+ /**
2
+
3
+ Copyright 2016 Valmet Automation Inc.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+
17
+ **/
18
+
19
+ module.exports = function (RED) {
20
+ "use strict";
21
+ var opcua = require('node-opcua');
22
+ var opcuaBasic = require('./opcua-basics');
23
+
24
+ function OpcUaEventNode(n) {
25
+
26
+ RED.nodes.createNode(this, n);
27
+
28
+ this.root = n.root; // OPC UA item nodeID subscription source
29
+ this.customeventtype = n.customeventtype;
30
+ this.eventtype = n.eventtype; // eventType
31
+ this.name = n.name; // Node name
32
+ this.activatecustomevent = n.activatecustomevent;
33
+
34
+ var node = this;
35
+
36
+ node.on("input", function (msg) {
37
+ msg.topic = node.root; // example: ns=0;i=85;
38
+
39
+ if (node.activatecustomevent)
40
+ {
41
+ msg.eventTypeIds = node.customeventtype; // example: ns=2;i=1234
42
+ } else {
43
+ msg.eventTypeIds = node.eventtype; // example: ns=0;i=10751;
44
+ }
45
+ node.send(msg);
46
+ });
47
+ }
48
+
49
+ RED.nodes.registerType("OpcUa-Event", OpcUaEventNode);
50
+ };