opcua-webapi-ts 1.1.16 → 1.1.18
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.
- package/dist/cjs/client/UaWebClient.js +2 -92
- package/dist/cjs/client/utils/UaDataTypeDictionary.js +11 -11
- package/dist/cjs/client/utils/UaModelling.js +129 -0
- package/dist/cjs/client/utils/UaNodeReader.js +66 -60
- package/dist/cjs/client/utils/UaObjectTypeDictionary.js +11 -11
- package/dist/cjs/client/utils/UaReferenceTypeDictionary.js +11 -11
- package/dist/cjs/common/nodes/UaDataType.js +2 -2
- package/dist/cjs/common/nodes/UaNode.js +27 -6
- package/dist/cjs/common/nodes/UaObjectType.js +7 -0
- package/dist/cjs/common/payload/UaDeleteNodesItem.js +1 -1
- package/dist/cjs/common/types/UaModellingRule.js +10 -0
- package/dist/cjs/common/types/index.js +1 -1
- package/dist/client/UaWebClient.d.ts +7 -5
- package/dist/client/UaWebClient.js +2 -92
- package/dist/client/utils/UaDataTypeDictionary.d.ts +3 -3
- package/dist/client/utils/UaDataTypeDictionary.js +11 -11
- package/dist/client/utils/UaModelling.d.ts +13 -0
- package/dist/client/utils/UaModelling.js +129 -0
- package/dist/client/utils/UaNodeReader.d.ts +17 -12
- package/dist/client/utils/UaNodeReader.js +66 -60
- package/dist/client/utils/UaObjectTypeDictionary.d.ts +3 -3
- package/dist/client/utils/UaObjectTypeDictionary.js +11 -11
- package/dist/client/utils/UaReferenceTypeDictionary.d.ts +3 -3
- package/dist/client/utils/UaReferenceTypeDictionary.js +11 -11
- package/dist/common/nodes/UaAttributes.d.ts +0 -4
- package/dist/common/nodes/UaDataType.d.ts +1 -1
- package/dist/common/nodes/UaDataType.js +2 -2
- package/dist/common/nodes/UaNode.d.ts +10 -6
- package/dist/common/nodes/UaNode.js +27 -6
- package/dist/common/nodes/UaObjectType.d.ts +3 -0
- package/dist/common/nodes/UaObjectType.js +7 -0
- package/dist/common/payload/UaDeleteNodesItem.d.ts +1 -1
- package/dist/common/payload/UaDeleteNodesItem.js +1 -1
- package/dist/common/types/UaModellingRule.d.ts +6 -0
- package/dist/common/types/UaModellingRule.js +10 -0
- package/dist/common/types/index.d.ts +1 -1
- package/dist/common/types/index.js +1 -1
- package/package.json +1 -1
|
@@ -9,16 +9,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.UaTypeReader = exports.UaObjectReader = exports.UaNodeReader = exports.UaLinkBrowser = exports.UaChildBrowser = exports.UaNodeReferenceBrowser = void 0;
|
|
12
|
+
exports.UaTypeReader = exports.UaObjectReader = exports.UaNodeReader = exports.UaSubtypeBrowser = exports.UaLinkBrowser = exports.UaChildBrowser = exports.UaNodeReferenceBrowser = void 0;
|
|
13
13
|
const opcua_webapi_1 = require("opcua-webapi");
|
|
14
14
|
const common_1 = require("../../common");
|
|
15
15
|
class UaNodeReferenceBrowser {
|
|
16
|
-
constructor(nodeIds, referenceType, nodeClassToReturn, returnDescription, maxNodesPerBrowse, maxReferencesPerNode) {
|
|
16
|
+
constructor(client, nodeIds, referenceType, nodeClassToReturn, returnDescription, maxNodesPerBrowse, maxReferencesPerNode) {
|
|
17
|
+
this._client = client;
|
|
17
18
|
this._nodesToBrowse = [];
|
|
18
19
|
this._referenceType = referenceType;
|
|
19
20
|
this._nodeClassToReturn = nodeClassToReturn;
|
|
20
21
|
this._continuationPointToBrowse = [];
|
|
21
|
-
this._returnDescription = returnDescription;
|
|
22
|
+
this._returnDescription = returnDescription !== null && returnDescription !== void 0 ? returnDescription : false;
|
|
22
23
|
this._maxNodesPerBrowse = (null == maxNodesPerBrowse || maxNodesPerBrowse <= 0) ? 50 : maxNodesPerBrowse;
|
|
23
24
|
this._maxReferencesPerNode = (null == maxReferencesPerNode || maxReferencesPerNode < 0) ? 50 : maxReferencesPerNode;
|
|
24
25
|
this._readResults = new Map();
|
|
@@ -32,21 +33,21 @@ class UaNodeReferenceBrowser {
|
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
|
-
browse(
|
|
36
|
+
browse() {
|
|
36
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
37
38
|
if (this.isFinish())
|
|
38
39
|
return;
|
|
39
|
-
yield this.browseOnce(
|
|
40
|
-
yield this.browse(
|
|
40
|
+
yield this.browseOnce();
|
|
41
|
+
yield this.browse();
|
|
41
42
|
});
|
|
42
43
|
}
|
|
43
|
-
browseOnce(
|
|
44
|
+
browseOnce() {
|
|
44
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
if (this.
|
|
46
|
-
yield this.
|
|
46
|
+
if (this._continuationPointToBrowse.length != 0) {
|
|
47
|
+
yield this._browseContinuationPoints();
|
|
47
48
|
}
|
|
48
|
-
else if (this.
|
|
49
|
-
yield this.
|
|
49
|
+
else if (this._nodesToBrowse.length != 0) {
|
|
50
|
+
yield this._browseNodes();
|
|
50
51
|
}
|
|
51
52
|
});
|
|
52
53
|
}
|
|
@@ -64,18 +65,16 @@ class UaNodeReferenceBrowser {
|
|
|
64
65
|
isFinish() {
|
|
65
66
|
return (this._nodesToBrowse.length == 0) && (this._continuationPointToBrowse.length == 0);
|
|
66
67
|
}
|
|
67
|
-
_browseNodes(
|
|
68
|
+
_browseNodes() {
|
|
68
69
|
return __awaiter(this, void 0, void 0, function* () {
|
|
69
70
|
var _a;
|
|
70
|
-
if (this._nodesToBrowse.length == 0)
|
|
71
|
-
return;
|
|
72
71
|
let nodesToBrowse = this._nodesToBrowse.splice(0, this._maxNodesPerBrowse);
|
|
73
72
|
let browseDescriptions = [];
|
|
74
73
|
for (let item of nodesToBrowse) {
|
|
75
74
|
let browseDescription = new common_1.UaBrowseDescription(item, opcua_webapi_1.BrowseDirection.Forward, this._referenceType, true, this._nodeClassToReturn, 63);
|
|
76
75
|
browseDescriptions.push(browseDescription);
|
|
77
76
|
}
|
|
78
|
-
let results = yield
|
|
77
|
+
let results = yield this._client.browse(browseDescriptions, this._maxReferencesPerNode);
|
|
79
78
|
for (let i = 0; i < nodesToBrowse.length; ++i) {
|
|
80
79
|
let currentNodeId = nodesToBrowse[i];
|
|
81
80
|
let currentResult = results[i];
|
|
@@ -103,11 +102,11 @@ class UaNodeReferenceBrowser {
|
|
|
103
102
|
});
|
|
104
103
|
}
|
|
105
104
|
if (this._returnDescription)
|
|
106
|
-
yield this._readDescriptions(
|
|
105
|
+
yield this._readDescriptions(newReferences);
|
|
107
106
|
}
|
|
108
107
|
});
|
|
109
108
|
}
|
|
110
|
-
_browseContinuationPoints(
|
|
109
|
+
_browseContinuationPoints() {
|
|
111
110
|
return __awaiter(this, void 0, void 0, function* () {
|
|
112
111
|
var _a;
|
|
113
112
|
let cpsToBrowse = this._continuationPointToBrowse.splice(0, this._maxNodesPerBrowse);
|
|
@@ -115,7 +114,7 @@ class UaNodeReferenceBrowser {
|
|
|
115
114
|
for (let item of cpsToBrowse) {
|
|
116
115
|
continuationPoints.push(item.continuationPoint);
|
|
117
116
|
}
|
|
118
|
-
let results = yield
|
|
117
|
+
let results = yield this._client.browseNext(continuationPoints, false);
|
|
119
118
|
for (let i = 0; i < cpsToBrowse.length; ++i) {
|
|
120
119
|
let currentNodeId = cpsToBrowse[i].nodeId;
|
|
121
120
|
let currentResult = results[i];
|
|
@@ -143,11 +142,11 @@ class UaNodeReferenceBrowser {
|
|
|
143
142
|
});
|
|
144
143
|
}
|
|
145
144
|
if (this._returnDescription)
|
|
146
|
-
yield this._readDescriptions(
|
|
145
|
+
yield this._readDescriptions(newReferences);
|
|
147
146
|
}
|
|
148
147
|
});
|
|
149
148
|
}
|
|
150
|
-
_readDescriptions(
|
|
149
|
+
_readDescriptions(references) {
|
|
151
150
|
return __awaiter(this, void 0, void 0, function* () {
|
|
152
151
|
if (references.length === 0)
|
|
153
152
|
return;
|
|
@@ -155,7 +154,7 @@ class UaNodeReferenceBrowser {
|
|
|
155
154
|
for (let item of references) {
|
|
156
155
|
nodesToRead.push(new common_1.UaReadValueId(item.nodeId, opcua_webapi_1.Attributes.Description));
|
|
157
156
|
}
|
|
158
|
-
let dataValues = yield
|
|
157
|
+
let dataValues = yield this._client.read(nodesToRead);
|
|
159
158
|
for (let i = 0; i < references.length; ++i) {
|
|
160
159
|
if (dataValues[i].statusCode.isGood()) {
|
|
161
160
|
let description = dataValues[i].value.toLocalizedText();
|
|
@@ -168,19 +167,26 @@ class UaNodeReferenceBrowser {
|
|
|
168
167
|
}
|
|
169
168
|
exports.UaNodeReferenceBrowser = UaNodeReferenceBrowser;
|
|
170
169
|
class UaChildBrowser extends UaNodeReferenceBrowser {
|
|
171
|
-
constructor(nodeIds, returnDescription) {
|
|
172
|
-
super(nodeIds, common_1.UaNodeId.from(common_1.ReferenceTypeIds.HierarchicalReferences), opcua_webapi_1.NodeClass.Object
|
|
170
|
+
constructor(client, nodeIds, returnDescription) {
|
|
171
|
+
super(client, nodeIds, common_1.UaNodeId.from(common_1.ReferenceTypeIds.HierarchicalReferences), opcua_webapi_1.NodeClass.Object, returnDescription !== null && returnDescription !== void 0 ? returnDescription : false, 20);
|
|
173
172
|
}
|
|
174
173
|
}
|
|
175
174
|
exports.UaChildBrowser = UaChildBrowser;
|
|
176
175
|
class UaLinkBrowser extends UaNodeReferenceBrowser {
|
|
177
|
-
constructor(nodeIds, returnDescription) {
|
|
178
|
-
super(nodeIds, common_1.UaNodeId.from(common_1.ReferenceTypeIds.NonHierarchicalReferences), opcua_webapi_1.NodeClass.Object, returnDescription !== null && returnDescription !== void 0 ? returnDescription : false, 20);
|
|
176
|
+
constructor(client, nodeIds, returnDescription) {
|
|
177
|
+
super(client, nodeIds, common_1.UaNodeId.from(common_1.ReferenceTypeIds.NonHierarchicalReferences), opcua_webapi_1.NodeClass.Object, returnDescription !== null && returnDescription !== void 0 ? returnDescription : false, 20);
|
|
179
178
|
}
|
|
180
179
|
}
|
|
181
180
|
exports.UaLinkBrowser = UaLinkBrowser;
|
|
181
|
+
class UaSubtypeBrowser extends UaNodeReferenceBrowser {
|
|
182
|
+
constructor(client, nodeIds, returnDescription) {
|
|
183
|
+
super(client, nodeIds, common_1.UaNodeId.from(common_1.ReferenceTypeIds.HierarchicalReferences), opcua_webapi_1.NodeClass.ObjectType | opcua_webapi_1.NodeClass.VariableType | opcua_webapi_1.NodeClass.DataType | opcua_webapi_1.NodeClass.ReferenceType, returnDescription !== null && returnDescription !== void 0 ? returnDescription : false, 20);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
exports.UaSubtypeBrowser = UaSubtypeBrowser;
|
|
182
187
|
class UaNodeReader {
|
|
183
|
-
constructor(returnDescription, returnVariable, returnMethod, returnAttributes, returnValue) {
|
|
188
|
+
constructor(client, returnDescription, returnVariable, returnMethod, returnAttributes, returnValue) {
|
|
189
|
+
this._client = client;
|
|
184
190
|
this._returnDescription = (returnDescription) ? returnDescription : false;
|
|
185
191
|
this._returnAttributes = (returnAttributes) ? returnAttributes : false;
|
|
186
192
|
this._returnValue = (returnValue) ? returnValue : false;
|
|
@@ -203,7 +209,7 @@ class UaNodeReader {
|
|
|
203
209
|
UaNodeReader.s_variablesNameToRead.add("EnumValues");
|
|
204
210
|
}
|
|
205
211
|
}
|
|
206
|
-
read(nodeIds
|
|
212
|
+
read(nodeIds) {
|
|
207
213
|
return __awaiter(this, void 0, void 0, function* () {
|
|
208
214
|
if (nodeIds.length == 0)
|
|
209
215
|
return [];
|
|
@@ -215,11 +221,11 @@ class UaNodeReader {
|
|
|
215
221
|
nodeIdsToRead.push(item);
|
|
216
222
|
nodeIdsSet.add(item.toString());
|
|
217
223
|
}
|
|
218
|
-
let rootReferences = yield this._readRootNodes(nodeIdsToRead
|
|
219
|
-
return yield this.readByReferences(rootReferences
|
|
224
|
+
let rootReferences = yield this._readRootNodes(nodeIdsToRead);
|
|
225
|
+
return yield this.readByReferences(rootReferences);
|
|
220
226
|
});
|
|
221
227
|
}
|
|
222
|
-
readByReferences(references
|
|
228
|
+
readByReferences(references) {
|
|
223
229
|
return __awaiter(this, void 0, void 0, function* () {
|
|
224
230
|
if (references.length == 0)
|
|
225
231
|
return [];
|
|
@@ -233,8 +239,8 @@ class UaNodeReader {
|
|
|
233
239
|
nodeIdsToBrowse.push(item.nodeId);
|
|
234
240
|
nodeIdsSet.add(item.nodeId.toString());
|
|
235
241
|
}
|
|
236
|
-
let nodeReferenceBrowser = new UaNodeReferenceBrowser(nodeIdsToBrowse, common_1.UaNodeId.from(common_1.ReferenceTypeIds.HierarchicalReferences), this._nodeClassToReturn, false);
|
|
237
|
-
yield nodeReferenceBrowser.browse(
|
|
242
|
+
let nodeReferenceBrowser = new UaNodeReferenceBrowser(this._client, nodeIdsToBrowse, common_1.UaNodeId.from(common_1.ReferenceTypeIds.HierarchicalReferences), this._nodeClassToReturn, false);
|
|
243
|
+
yield nodeReferenceBrowser.browse();
|
|
238
244
|
let childReferences = nodeReferenceBrowser.results();
|
|
239
245
|
let childNodesToBrowse = [];
|
|
240
246
|
for (let item of childReferences) {
|
|
@@ -250,8 +256,8 @@ class UaNodeReader {
|
|
|
250
256
|
}
|
|
251
257
|
let variableReferences = [];
|
|
252
258
|
if (childNodesToBrowse.length != 0) {
|
|
253
|
-
let childReferenceBrowser = new UaNodeReferenceBrowser(childNodesToBrowse, common_1.UaNodeId.from(common_1.ReferenceTypeIds.HierarchicalReferences), opcua_webapi_1.NodeClass.Variable, false);
|
|
254
|
-
yield childReferenceBrowser.browse(
|
|
259
|
+
let childReferenceBrowser = new UaNodeReferenceBrowser(this._client, childNodesToBrowse, common_1.UaNodeId.from(common_1.ReferenceTypeIds.HierarchicalReferences), opcua_webapi_1.NodeClass.Variable, false);
|
|
260
|
+
yield childReferenceBrowser.browse();
|
|
255
261
|
variableReferences = childReferenceBrowser.results();
|
|
256
262
|
}
|
|
257
263
|
let allReferences = [];
|
|
@@ -270,7 +276,7 @@ class UaNodeReader {
|
|
|
270
276
|
;
|
|
271
277
|
}
|
|
272
278
|
let nodesMap = new Map();
|
|
273
|
-
yield this._readNodes(allReferences, nodesMap
|
|
279
|
+
yield this._readNodes(allReferences, nodesMap);
|
|
274
280
|
for (let item of variableReferences) {
|
|
275
281
|
this._buildNodeTree(item, nodesMap);
|
|
276
282
|
}
|
|
@@ -286,7 +292,7 @@ class UaNodeReader {
|
|
|
286
292
|
return rootNodes;
|
|
287
293
|
});
|
|
288
294
|
}
|
|
289
|
-
_readRootNodes(nodeIds
|
|
295
|
+
_readRootNodes(nodeIds) {
|
|
290
296
|
return __awaiter(this, void 0, void 0, function* () {
|
|
291
297
|
let nodesToRead = [];
|
|
292
298
|
for (let item of nodeIds) {
|
|
@@ -294,7 +300,7 @@ class UaNodeReader {
|
|
|
294
300
|
nodesToRead.push(new common_1.UaReadValueId(item, opcua_webapi_1.Attributes.BrowseName));
|
|
295
301
|
nodesToRead.push(new common_1.UaReadValueId(item, opcua_webapi_1.Attributes.DisplayName));
|
|
296
302
|
}
|
|
297
|
-
let dataValues = yield
|
|
303
|
+
let dataValues = yield this._client.read(nodesToRead);
|
|
298
304
|
let references = [];
|
|
299
305
|
let typeDefinitionsToRead = [];
|
|
300
306
|
for (let i = 0; i < nodeIds.length; ++i) {
|
|
@@ -327,7 +333,7 @@ class UaNodeReader {
|
|
|
327
333
|
let browseDescription = new common_1.UaBrowseDescription(item.nodeId, opcua_webapi_1.BrowseDirection.Forward, common_1.UaNodeId.from(common_1.ReferenceTypeIds.HasTypeDefinition), false, opcua_webapi_1.NodeClass.ObjectType, 0);
|
|
328
334
|
browseDescriptions.push(browseDescription);
|
|
329
335
|
}
|
|
330
|
-
let results = yield
|
|
336
|
+
let results = yield this._client.browse(browseDescriptions);
|
|
331
337
|
for (let i = 0; i < browseDescriptions.length; ++i) {
|
|
332
338
|
if (results[i].statusCode.isNotGood())
|
|
333
339
|
throw new common_1.UaError(results[i].statusCode);
|
|
@@ -339,7 +345,7 @@ class UaNodeReader {
|
|
|
339
345
|
return references;
|
|
340
346
|
});
|
|
341
347
|
}
|
|
342
|
-
_readNodes(references, nodes
|
|
348
|
+
_readNodes(references, nodes) {
|
|
343
349
|
return __awaiter(this, void 0, void 0, function* () {
|
|
344
350
|
if (references.length == 0)
|
|
345
351
|
return;
|
|
@@ -348,14 +354,14 @@ class UaNodeReader {
|
|
|
348
354
|
refrencesToRead.push(references.splice(0, 100));
|
|
349
355
|
}
|
|
350
356
|
for (let item of refrencesToRead) {
|
|
351
|
-
yield this._readTypes(item, nodes
|
|
352
|
-
yield this._readObjects(item, nodes
|
|
353
|
-
yield this._readVariables(item, nodes
|
|
354
|
-
yield this._readMethods(item, nodes
|
|
357
|
+
yield this._readTypes(item, nodes);
|
|
358
|
+
yield this._readObjects(item, nodes);
|
|
359
|
+
yield this._readVariables(item, nodes);
|
|
360
|
+
yield this._readMethods(item, nodes);
|
|
355
361
|
}
|
|
356
362
|
});
|
|
357
363
|
}
|
|
358
|
-
_readTypes(references, nodes
|
|
364
|
+
_readTypes(references, nodes) {
|
|
359
365
|
return __awaiter(this, void 0, void 0, function* () {
|
|
360
366
|
let typesToRead = [];
|
|
361
367
|
let needReadAttributes = this._returnAttributes || this._returnDescription;
|
|
@@ -380,7 +386,7 @@ class UaNodeReader {
|
|
|
380
386
|
nodesToRead.push(new common_1.UaReadValueId(item.nodeId, opcua_webapi_1.Attributes.ValueRank));
|
|
381
387
|
}
|
|
382
388
|
}
|
|
383
|
-
dataValues = yield
|
|
389
|
+
dataValues = yield this._client.read(nodesToRead);
|
|
384
390
|
}
|
|
385
391
|
for (let i = 0; i < typesToRead.length; ++i) {
|
|
386
392
|
let isAbstract = false;
|
|
@@ -435,7 +441,7 @@ class UaNodeReader {
|
|
|
435
441
|
}
|
|
436
442
|
});
|
|
437
443
|
}
|
|
438
|
-
_readObjects(references, nodes
|
|
444
|
+
_readObjects(references, nodes) {
|
|
439
445
|
return __awaiter(this, void 0, void 0, function* () {
|
|
440
446
|
let objectsToRead = [];
|
|
441
447
|
for (let item of references) {
|
|
@@ -456,7 +462,7 @@ class UaNodeReader {
|
|
|
456
462
|
}
|
|
457
463
|
let dataValues = [];
|
|
458
464
|
if (nodesToRead.length != 0) {
|
|
459
|
-
dataValues = yield
|
|
465
|
+
dataValues = yield this._client.read(nodesToRead);
|
|
460
466
|
}
|
|
461
467
|
for (let i = 0; i < objectsToRead.length; ++i) {
|
|
462
468
|
let dataIndex = (this._returnAttributes && this._returnDescription) ? i * 2 : i;
|
|
@@ -483,7 +489,7 @@ class UaNodeReader {
|
|
|
483
489
|
}
|
|
484
490
|
});
|
|
485
491
|
}
|
|
486
|
-
_readVariables(references, nodes
|
|
492
|
+
_readVariables(references, nodes) {
|
|
487
493
|
return __awaiter(this, void 0, void 0, function* () {
|
|
488
494
|
let variablesToRead = [];
|
|
489
495
|
let nodeIds = [];
|
|
@@ -497,7 +503,7 @@ class UaNodeReader {
|
|
|
497
503
|
return;
|
|
498
504
|
let results = [];
|
|
499
505
|
if (this._returnAttributes) {
|
|
500
|
-
results = yield
|
|
506
|
+
results = yield this._client.readVariableAttributes(nodeIds);
|
|
501
507
|
}
|
|
502
508
|
let variablesToReadValue = [];
|
|
503
509
|
for (let i = 0; i < variablesToRead.length; ++i) {
|
|
@@ -518,7 +524,7 @@ class UaNodeReader {
|
|
|
518
524
|
for (let item of variablesToReadValue) {
|
|
519
525
|
valuesToRead.push(item.nodeId);
|
|
520
526
|
}
|
|
521
|
-
let values = yield
|
|
527
|
+
let values = yield this._client.readValues(valuesToRead);
|
|
522
528
|
for (let i = 0; i < valuesToRead.length; ++i) {
|
|
523
529
|
let variableNode = nodes.get(valuesToRead[i].toString());
|
|
524
530
|
variableNode.dataValue = values[i];
|
|
@@ -526,7 +532,7 @@ class UaNodeReader {
|
|
|
526
532
|
}
|
|
527
533
|
});
|
|
528
534
|
}
|
|
529
|
-
_readMethods(references, nodes
|
|
535
|
+
_readMethods(references, nodes) {
|
|
530
536
|
return __awaiter(this, void 0, void 0, function* () {
|
|
531
537
|
let methodsToRead = [];
|
|
532
538
|
for (let item of references) {
|
|
@@ -544,7 +550,7 @@ class UaNodeReader {
|
|
|
544
550
|
}
|
|
545
551
|
let dataValues = [];
|
|
546
552
|
if (nodesToRead.length != 0) {
|
|
547
|
-
dataValues = yield
|
|
553
|
+
dataValues = yield this._client.read(nodesToRead);
|
|
548
554
|
}
|
|
549
555
|
for (let i = 0; i < methodsToRead.length; ++i) {
|
|
550
556
|
let methodNode = new common_1.UaMethod(methodsToRead[i].nodeId, methodsToRead[i].browseName, methodsToRead[i].displayName);
|
|
@@ -613,15 +619,15 @@ exports.UaNodeReader = UaNodeReader;
|
|
|
613
619
|
UaNodeReader.s_variableTypeWithoutMember = null;
|
|
614
620
|
UaNodeReader.s_variablesNameToRead = null;
|
|
615
621
|
class UaObjectReader extends UaNodeReader {
|
|
616
|
-
constructor(returnDescription, returnValue) {
|
|
617
|
-
super(returnDescription !== null && returnDescription !== void 0 ? returnDescription : false, true, true, true, returnValue !== null && returnValue !== void 0 ? returnValue : false);
|
|
622
|
+
constructor(client, returnDescription, returnValue) {
|
|
623
|
+
super(client, returnDescription !== null && returnDescription !== void 0 ? returnDescription : false, true, true, true, returnValue !== null && returnValue !== void 0 ? returnValue : false);
|
|
618
624
|
}
|
|
619
|
-
read(nodeIds
|
|
625
|
+
read(nodeIds) {
|
|
620
626
|
const _super = Object.create(null, {
|
|
621
627
|
read: { get: () => super.read }
|
|
622
628
|
});
|
|
623
629
|
return __awaiter(this, void 0, void 0, function* () {
|
|
624
|
-
let nodes = yield _super.read.call(this, nodeIds
|
|
630
|
+
let nodes = yield _super.read.call(this, nodeIds);
|
|
625
631
|
let objectNodes = [];
|
|
626
632
|
for (let item of nodes) {
|
|
627
633
|
if (item.nodeClass == opcua_webapi_1.NodeClass.Object) {
|
|
@@ -634,15 +640,15 @@ class UaObjectReader extends UaNodeReader {
|
|
|
634
640
|
}
|
|
635
641
|
exports.UaObjectReader = UaObjectReader;
|
|
636
642
|
class UaTypeReader extends UaNodeReader {
|
|
637
|
-
constructor() {
|
|
638
|
-
super(true, true, true, true, false);
|
|
643
|
+
constructor(client) {
|
|
644
|
+
super(client, true, true, true, true, false);
|
|
639
645
|
}
|
|
640
|
-
read(nodeIds
|
|
646
|
+
read(nodeIds) {
|
|
641
647
|
const _super = Object.create(null, {
|
|
642
648
|
read: { get: () => super.read }
|
|
643
649
|
});
|
|
644
650
|
return __awaiter(this, void 0, void 0, function* () {
|
|
645
|
-
let nodes = yield _super.read.call(this, nodeIds
|
|
651
|
+
let nodes = yield _super.read.call(this, nodeIds);
|
|
646
652
|
let typeNodes = [];
|
|
647
653
|
for (let item of nodes) {
|
|
648
654
|
if (item.nodeClass == opcua_webapi_1.NodeClass.ObjectType ||
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { UaNodeId, UaObjectType } from "../../common";
|
|
2
2
|
import { UaWebClient } from "../UaWebClient";
|
|
3
3
|
export declare class UaObjectTypeDictionary {
|
|
4
|
+
private _client;
|
|
4
5
|
private _objectTypes;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
read(client: UaWebClient): Promise<void>;
|
|
6
|
+
constructor(client: UaWebClient);
|
|
7
|
+
read(): Promise<void>;
|
|
8
8
|
getObjectType(nodeId: UaNodeId): UaObjectType | null;
|
|
9
9
|
getObjectTypes(): Array<UaObjectType>;
|
|
10
10
|
private _read;
|
|
@@ -14,16 +14,16 @@ const opcua_webapi_1 = require("opcua-webapi");
|
|
|
14
14
|
const common_1 = require("../../common");
|
|
15
15
|
const UaNodeReader_1 = require("./UaNodeReader");
|
|
16
16
|
class UaObjectTypeDictionary {
|
|
17
|
-
constructor(
|
|
17
|
+
constructor(client) {
|
|
18
|
+
this._client = client;
|
|
18
19
|
this._objectTypes = new Map;
|
|
19
|
-
this._returnAllAttributes = (null == simpleMode) ? false : !simpleMode;
|
|
20
20
|
let baseObjectTypeId = common_1.UaNodeId.from(common_1.ObjectTypeIds.BaseObjectType);
|
|
21
21
|
this._objectTypes.set(baseObjectTypeId.toString(), new common_1.UaObjectType(baseObjectTypeId, "BaseObjectType", new common_1.UaLocalizedText("BaseObjectType"), false));
|
|
22
22
|
}
|
|
23
|
-
read(
|
|
23
|
+
read() {
|
|
24
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
let browser = new UaNodeReader_1.
|
|
26
|
-
yield this._read(browser
|
|
25
|
+
let browser = new UaNodeReader_1.UaSubtypeBrowser(this._client, [common_1.UaNodeId.from(common_1.ObjectTypeIds.BaseObjectType)]);
|
|
26
|
+
yield this._read(browser);
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
getObjectType(nodeId) {
|
|
@@ -33,10 +33,10 @@ class UaObjectTypeDictionary {
|
|
|
33
33
|
getObjectTypes() {
|
|
34
34
|
return [...this._objectTypes.values()];
|
|
35
35
|
}
|
|
36
|
-
_read(browser
|
|
36
|
+
_read(browser) {
|
|
37
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
38
|
// Browse child type
|
|
39
|
-
yield browser.browse(
|
|
39
|
+
yield browser.browse();
|
|
40
40
|
let results = browser.results();
|
|
41
41
|
let referencesToRead = [];
|
|
42
42
|
for (let item of results) {
|
|
@@ -47,8 +47,8 @@ class UaObjectTypeDictionary {
|
|
|
47
47
|
return;
|
|
48
48
|
// Read child type
|
|
49
49
|
let nodeIdsToBrowse = [];
|
|
50
|
-
let nodeReader = new UaNodeReader_1.UaNodeReader(this.
|
|
51
|
-
let nodes = yield nodeReader.readByReferences(referencesToRead
|
|
50
|
+
let nodeReader = new UaNodeReader_1.UaNodeReader(this._client, false, false, false, false, false);
|
|
51
|
+
let nodes = yield nodeReader.readByReferences(referencesToRead);
|
|
52
52
|
for (let node of nodes) {
|
|
53
53
|
if (opcua_webapi_1.NodeClass.ObjectType != node.nodeClass)
|
|
54
54
|
continue;
|
|
@@ -68,8 +68,8 @@ class UaObjectTypeDictionary {
|
|
|
68
68
|
return;
|
|
69
69
|
yield this.__delay(20);
|
|
70
70
|
// Continue to browse and read child type
|
|
71
|
-
let childBrowser = new UaNodeReader_1.
|
|
72
|
-
yield this._read(childBrowser
|
|
71
|
+
let childBrowser = new UaNodeReader_1.UaSubtypeBrowser(this._client, nodeIdsToBrowse);
|
|
72
|
+
yield this._read(childBrowser);
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
__delay(ms) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { UaReferenceType, UaNodeId } from "../../common";
|
|
2
2
|
import { UaWebClient } from "../UaWebClient";
|
|
3
3
|
export declare class UaReferenceTypeDictionary {
|
|
4
|
+
private _client;
|
|
4
5
|
private _referenceTypes;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
read(client: UaWebClient): Promise<void>;
|
|
6
|
+
constructor(client: UaWebClient);
|
|
7
|
+
read(): Promise<void>;
|
|
8
8
|
getReferenceType(nodeId: UaNodeId): UaReferenceType | null;
|
|
9
9
|
getReferenceTypes(): Array<UaReferenceType>;
|
|
10
10
|
private _read;
|
|
@@ -14,16 +14,16 @@ const opcua_webapi_1 = require("opcua-webapi");
|
|
|
14
14
|
const common_1 = require("../../common");
|
|
15
15
|
const UaNodeReader_1 = require("./UaNodeReader");
|
|
16
16
|
class UaReferenceTypeDictionary {
|
|
17
|
-
constructor(
|
|
17
|
+
constructor(client) {
|
|
18
|
+
this._client = client;
|
|
18
19
|
this._referenceTypes = new Map;
|
|
19
|
-
this._returnAllAttributes = (null == simpleMode) ? false : !simpleMode;
|
|
20
20
|
let referencesId = common_1.UaNodeId.from(common_1.ReferenceTypeIds.References);
|
|
21
21
|
this._referenceTypes.set(referencesId.toString(), new common_1.UaReferenceType(referencesId, "References", new common_1.UaLocalizedText("References"), true, common_1.UaLocalizedText.nullText, true));
|
|
22
22
|
}
|
|
23
|
-
read(
|
|
23
|
+
read() {
|
|
24
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
let browser = new UaNodeReader_1.UaChildBrowser([common_1.UaNodeId.from(common_1.ReferenceTypeIds.References)]);
|
|
26
|
-
yield this._read(browser
|
|
25
|
+
let browser = new UaNodeReader_1.UaChildBrowser(this._client, [common_1.UaNodeId.from(common_1.ReferenceTypeIds.References)]);
|
|
26
|
+
yield this._read(browser);
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
getReferenceType(nodeId) {
|
|
@@ -33,10 +33,10 @@ class UaReferenceTypeDictionary {
|
|
|
33
33
|
getReferenceTypes() {
|
|
34
34
|
return [...this._referenceTypes.values()];
|
|
35
35
|
}
|
|
36
|
-
_read(browser
|
|
36
|
+
_read(browser) {
|
|
37
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
38
|
// Browse child type
|
|
39
|
-
yield browser.browse(
|
|
39
|
+
yield browser.browse();
|
|
40
40
|
let results = browser.results();
|
|
41
41
|
let referencesToRead = [];
|
|
42
42
|
for (let item of results) {
|
|
@@ -47,8 +47,8 @@ class UaReferenceTypeDictionary {
|
|
|
47
47
|
return;
|
|
48
48
|
// Read child type
|
|
49
49
|
let nodeIdsToBrowse = [];
|
|
50
|
-
let nodeReader = new UaNodeReader_1.UaNodeReader(this.
|
|
51
|
-
let nodes = yield nodeReader.readByReferences(referencesToRead
|
|
50
|
+
let nodeReader = new UaNodeReader_1.UaNodeReader(this._client, false, false, false, false, false);
|
|
51
|
+
let nodes = yield nodeReader.readByReferences(referencesToRead);
|
|
52
52
|
for (let node of nodes) {
|
|
53
53
|
if (opcua_webapi_1.NodeClass.ReferenceType != node.nodeClass)
|
|
54
54
|
continue;
|
|
@@ -68,8 +68,8 @@ class UaReferenceTypeDictionary {
|
|
|
68
68
|
return;
|
|
69
69
|
yield this.__delay(20);
|
|
70
70
|
// Continue to browse and read child type
|
|
71
|
-
let childBrowser = new UaNodeReader_1.UaChildBrowser(nodeIdsToBrowse);
|
|
72
|
-
yield this._read(childBrowser
|
|
71
|
+
let childBrowser = new UaNodeReader_1.UaChildBrowser(this._client, nodeIdsToBrowse);
|
|
72
|
+
yield this._read(childBrowser);
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
__delay(ms) {
|
|
@@ -3,12 +3,8 @@ export type OpcUaNodeAttributes = {
|
|
|
3
3
|
nodeClass: number;
|
|
4
4
|
browseName: string;
|
|
5
5
|
displayName: UaLocalizedText;
|
|
6
|
-
writeMask: number;
|
|
7
6
|
description: UaLocalizedText | null;
|
|
8
7
|
};
|
|
9
|
-
export type OpcUaObjectAttributes = {
|
|
10
|
-
eventNotifier: number;
|
|
11
|
-
};
|
|
12
8
|
export type OpcUaVariableAttributes = {
|
|
13
9
|
dataType: UaNodeId;
|
|
14
10
|
valueRank: number;
|
|
@@ -4,7 +4,7 @@ import { UaDefintionNode, UaVariable } from ".";
|
|
|
4
4
|
export declare class UaDataType extends UaDefintionNode {
|
|
5
5
|
private _valueType;
|
|
6
6
|
private _enumValues;
|
|
7
|
-
constructor(nodeId: UaNodeId, browseName: string, displayName: UaLocalizedText, isAbstract: boolean
|
|
7
|
+
constructor(nodeId: UaNodeId, browseName: string, displayName: UaLocalizedText, isAbstract: boolean);
|
|
8
8
|
get nodeClass(): NodeClass;
|
|
9
9
|
get valueType(): number;
|
|
10
10
|
get enumValues(): Map<number, UaLocalizedText> | null;
|
|
@@ -6,8 +6,8 @@ const types_1 = require("../types");
|
|
|
6
6
|
const _1 = require(".");
|
|
7
7
|
const structure_1 = require("../structure");
|
|
8
8
|
class UaDataType extends _1.UaDefintionNode {
|
|
9
|
-
constructor(nodeId, browseName, displayName, isAbstract
|
|
10
|
-
super(nodeId, browseName, displayName, isAbstract
|
|
9
|
+
constructor(nodeId, browseName, displayName, isAbstract) {
|
|
10
|
+
super(nodeId, browseName, displayName, isAbstract);
|
|
11
11
|
this._valueType = 0;
|
|
12
12
|
this._enumValues = null;
|
|
13
13
|
}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { NodeClass } from "opcua-webapi";
|
|
2
|
-
import { UaLocalizedText, UaNodeId } from "../types";
|
|
2
|
+
import { UaLocalizedText, UaModellingRule, UaNodeId } from "../types";
|
|
3
3
|
export declare abstract class UaNode {
|
|
4
4
|
protected _nodeId: UaNodeId;
|
|
5
5
|
protected _browseName: string;
|
|
6
6
|
protected _displayName: UaLocalizedText;
|
|
7
7
|
protected _description: UaLocalizedText | null;
|
|
8
|
-
protected _writeMask: number;
|
|
8
|
+
protected _writeMask: number | null;
|
|
9
9
|
protected _parent: UaNode | null;
|
|
10
10
|
protected _children: Array<UaNode>;
|
|
11
11
|
protected _refToParent: UaNodeId | null;
|
|
12
|
-
constructor(nodeId: UaNodeId, browseName: string, displayName: UaLocalizedText
|
|
12
|
+
constructor(nodeId: UaNodeId, browseName: string, displayName: UaLocalizedText);
|
|
13
13
|
abstract get nodeClass(): NodeClass;
|
|
14
14
|
get nodeId(): UaNodeId;
|
|
15
15
|
get browseName(): string;
|
|
16
16
|
get displayName(): UaLocalizedText;
|
|
17
|
-
get writeMask(): number;
|
|
17
|
+
get writeMask(): number | null;
|
|
18
|
+
set writeMask(writeMask: number);
|
|
18
19
|
get description(): UaLocalizedText | null;
|
|
19
20
|
set description(description: UaLocalizedText | null);
|
|
20
21
|
get refToParent(): UaNodeId | null;
|
|
@@ -23,7 +24,7 @@ export declare abstract class UaNode {
|
|
|
23
24
|
}
|
|
24
25
|
export declare abstract class UaDefintionNode extends UaNode {
|
|
25
26
|
protected _isAbstract: boolean;
|
|
26
|
-
constructor(nodeId: UaNodeId, browseName: string, displayName: UaLocalizedText, isAbstract: boolean
|
|
27
|
+
constructor(nodeId: UaNodeId, browseName: string, displayName: UaLocalizedText, isAbstract: boolean);
|
|
27
28
|
get isAbstract(): boolean;
|
|
28
29
|
get refToParent(): UaNodeId | null;
|
|
29
30
|
set refToParent(referenceTypeId: UaNodeId);
|
|
@@ -33,6 +34,9 @@ export declare abstract class UaDefintionNode extends UaNode {
|
|
|
33
34
|
childTypes(): Array<UaDefintionNode>;
|
|
34
35
|
}
|
|
35
36
|
export declare abstract class UaInstanceNode extends UaNode {
|
|
36
|
-
|
|
37
|
+
private _modellingRule;
|
|
38
|
+
constructor(nodeId: UaNodeId, browseName: string, displayName: UaLocalizedText);
|
|
37
39
|
getMembers(nodeClass?: NodeClass): Array<UaInstanceNode>;
|
|
40
|
+
get modellingRule(): UaModellingRule;
|
|
41
|
+
setModellingRule(modellingRuleId: UaNodeId): void;
|
|
38
42
|
}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UaInstanceNode = exports.UaDefintionNode = exports.UaNode = void 0;
|
|
4
|
+
const types_1 = require("../types");
|
|
5
|
+
const _1 = require(".");
|
|
4
6
|
class UaNode {
|
|
5
|
-
constructor(nodeId, browseName, displayName
|
|
7
|
+
constructor(nodeId, browseName, displayName) {
|
|
6
8
|
this._nodeId = nodeId;
|
|
7
9
|
this._browseName = browseName;
|
|
8
10
|
this._displayName = displayName;
|
|
9
11
|
this._description = null;
|
|
10
|
-
this._writeMask =
|
|
12
|
+
this._writeMask = null;
|
|
11
13
|
this._parent = null;
|
|
12
14
|
this._children = [];
|
|
13
15
|
this._refToParent = null;
|
|
@@ -24,6 +26,9 @@ class UaNode {
|
|
|
24
26
|
get writeMask() {
|
|
25
27
|
return this._writeMask;
|
|
26
28
|
}
|
|
29
|
+
set writeMask(writeMask) {
|
|
30
|
+
this._writeMask = writeMask;
|
|
31
|
+
}
|
|
27
32
|
get description() {
|
|
28
33
|
return this._description;
|
|
29
34
|
}
|
|
@@ -39,8 +44,8 @@ class UaNode {
|
|
|
39
44
|
}
|
|
40
45
|
exports.UaNode = UaNode;
|
|
41
46
|
class UaDefintionNode extends UaNode {
|
|
42
|
-
constructor(nodeId, browseName, displayName, isAbstract
|
|
43
|
-
super(nodeId, browseName, displayName
|
|
47
|
+
constructor(nodeId, browseName, displayName, isAbstract) {
|
|
48
|
+
super(nodeId, browseName, displayName);
|
|
44
49
|
this._isAbstract = isAbstract;
|
|
45
50
|
}
|
|
46
51
|
get isAbstract() {
|
|
@@ -80,8 +85,9 @@ class UaDefintionNode extends UaNode {
|
|
|
80
85
|
}
|
|
81
86
|
exports.UaDefintionNode = UaDefintionNode;
|
|
82
87
|
class UaInstanceNode extends UaNode {
|
|
83
|
-
constructor(nodeId, browseName, displayName
|
|
84
|
-
super(nodeId, browseName, displayName
|
|
88
|
+
constructor(nodeId, browseName, displayName) {
|
|
89
|
+
super(nodeId, browseName, displayName);
|
|
90
|
+
this._modellingRule = types_1.UaModellingRule.None;
|
|
85
91
|
}
|
|
86
92
|
getMembers(nodeClass) {
|
|
87
93
|
let ret = [];
|
|
@@ -92,5 +98,20 @@ class UaInstanceNode extends UaNode {
|
|
|
92
98
|
}
|
|
93
99
|
return ret;
|
|
94
100
|
}
|
|
101
|
+
get modellingRule() {
|
|
102
|
+
return this._modellingRule;
|
|
103
|
+
}
|
|
104
|
+
setModellingRule(modellingRuleId) {
|
|
105
|
+
if (modellingRuleId.equal(types_1.UaNodeId.from(_1.ObjectIds.ModellingRule_Mandatory)))
|
|
106
|
+
this._modellingRule = types_1.UaModellingRule.Mandatory;
|
|
107
|
+
else if (modellingRuleId.equal(types_1.UaNodeId.from(_1.ObjectIds.ModellingRule_Optional)))
|
|
108
|
+
this._modellingRule = types_1.UaModellingRule.Optional;
|
|
109
|
+
else if (modellingRuleId.equal(types_1.UaNodeId.from(_1.ObjectIds.ModellingRule_OptionalPlaceholder)))
|
|
110
|
+
this._modellingRule = types_1.UaModellingRule.PlaceHolder;
|
|
111
|
+
else if (modellingRuleId.equal(types_1.UaNodeId.from(_1.ObjectIds.ModellingRule_MandatoryPlaceholder)))
|
|
112
|
+
this._modellingRule = types_1.UaModellingRule.PlaceHolder;
|
|
113
|
+
else
|
|
114
|
+
this._modellingRule = types_1.UaModellingRule.None;
|
|
115
|
+
}
|
|
95
116
|
}
|
|
96
117
|
exports.UaInstanceNode = UaInstanceNode;
|