opcua-webapi-ts 1.0.22 → 1.0.24
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.d.ts +10 -11
- package/dist/cjs/client/UaWebClient.js +156 -174
- package/dist/cjs/client/utils/UaDataTypeDictionary.js +15 -27
- package/dist/cjs/client/utils/UaNodeReader.d.ts +1 -1
- package/dist/cjs/client/utils/UaNodeReader.js +95 -145
- package/dist/cjs/client/utils/UaObjectTypeDictionary.js +8 -15
- package/dist/cjs/client/utils/UaReferenceTypeDictionary.js +8 -15
- package/dist/cjs/common/index.d.ts +1 -1
- package/dist/cjs/common/index.js +1 -1
- package/dist/cjs/common/payload/UaBrowseDescription.d.ts +20 -0
- package/dist/cjs/common/payload/UaBrowseDescription.js +58 -0
- package/dist/cjs/common/payload/UaBrowseResult.d.ts +16 -0
- package/dist/cjs/common/payload/UaBrowseResult.js +52 -0
- package/dist/cjs/common/payload/UaCallMethodRequest.d.ts +14 -0
- package/dist/cjs/common/payload/UaCallMethodRequest.js +50 -0
- package/dist/cjs/common/payload/UaCallMethodResult.d.ts +14 -0
- package/dist/cjs/common/payload/UaCallMethodResult.js +61 -0
- package/dist/cjs/common/payload/UaHistoryReadResult.d.ts +14 -0
- package/dist/cjs/common/payload/UaHistoryReadResult.js +41 -0
- package/dist/cjs/common/payload/UaHistoryReadValueId.d.ts +14 -0
- package/dist/cjs/common/payload/UaHistoryReadValueId.js +39 -0
- package/dist/cjs/common/payload/UaPayloadMapper.d.ts +15 -0
- package/dist/cjs/common/payload/UaPayloadMapper.js +444 -0
- package/dist/cjs/common/payload/UaReadValueId.d.ts +14 -0
- package/dist/cjs/common/payload/UaReadValueId.js +39 -0
- package/dist/cjs/common/payload/UaReferenceDescription.d.ts +22 -0
- package/dist/cjs/common/payload/UaReferenceDescription.js +61 -0
- package/dist/cjs/common/payload/UaWriteValue.d.ts +16 -0
- package/dist/cjs/common/payload/UaWriteValue.js +49 -0
- package/dist/cjs/common/payload/index.d.ts +10 -0
- package/dist/cjs/common/payload/index.js +26 -0
- package/dist/cjs/common/structure/UaArgument.js +3 -3
- package/dist/cjs/common/structure/UaContentFilterElement.js +3 -3
- package/dist/cjs/common/structure/UaEUInformation.js +5 -5
- package/dist/cjs/common/structure/UaEnumValueType.js +5 -5
- package/dist/cjs/common/structure/UaHistoryData.js +3 -3
- package/dist/cjs/common/structure/UaHistoryEvent.js +3 -3
- package/dist/cjs/common/structure/UaLiteralOperand.js +3 -3
- package/dist/cjs/common/types/UaExpandedNodeId.d.ts +1 -0
- package/dist/cjs/common/types/UaExpandedNodeId.js +11 -0
- package/dist/cjs/common/types/index.d.ts +0 -1
- package/dist/cjs/common/types/index.js +0 -1
- package/dist/client/UaWebClient.d.ts +10 -11
- package/dist/client/UaWebClient.js +156 -174
- package/dist/client/utils/UaDataTypeDictionary.js +15 -27
- package/dist/client/utils/UaNodeReader.d.ts +1 -1
- package/dist/client/utils/UaNodeReader.js +95 -145
- package/dist/client/utils/UaObjectTypeDictionary.js +8 -15
- package/dist/client/utils/UaReferenceTypeDictionary.js +8 -15
- package/dist/common/index.d.ts +1 -1
- package/dist/common/index.js +1 -1
- package/dist/common/payload/UaBrowseDescription.d.ts +20 -0
- package/dist/common/payload/UaBrowseDescription.js +58 -0
- package/dist/common/payload/UaBrowseResult.d.ts +16 -0
- package/dist/common/payload/UaBrowseResult.js +52 -0
- package/dist/common/payload/UaCallMethodRequest.d.ts +14 -0
- package/dist/common/payload/UaCallMethodRequest.js +50 -0
- package/dist/common/payload/UaCallMethodResult.d.ts +14 -0
- package/dist/common/payload/UaCallMethodResult.js +61 -0
- package/dist/common/payload/UaHistoryReadResult.d.ts +14 -0
- package/dist/common/payload/UaHistoryReadResult.js +41 -0
- package/dist/common/payload/UaHistoryReadValueId.d.ts +14 -0
- package/dist/common/payload/UaHistoryReadValueId.js +39 -0
- package/dist/common/payload/UaPayloadMapper.d.ts +15 -0
- package/dist/common/payload/UaPayloadMapper.js +444 -0
- package/dist/common/payload/UaReadValueId.d.ts +14 -0
- package/dist/common/payload/UaReadValueId.js +39 -0
- package/dist/common/payload/UaReferenceDescription.d.ts +22 -0
- package/dist/common/payload/UaReferenceDescription.js +61 -0
- package/dist/common/payload/UaWriteValue.d.ts +16 -0
- package/dist/common/payload/UaWriteValue.js +49 -0
- package/dist/common/payload/index.d.ts +10 -0
- package/dist/common/payload/index.js +26 -0
- package/dist/common/structure/UaArgument.js +3 -3
- package/dist/common/structure/UaContentFilterElement.js +3 -3
- package/dist/common/structure/UaEUInformation.js +5 -5
- package/dist/common/structure/UaEnumValueType.js +5 -5
- package/dist/common/structure/UaHistoryData.js +3 -3
- package/dist/common/structure/UaHistoryEvent.js +3 -3
- package/dist/common/structure/UaLiteralOperand.js +3 -3
- package/dist/common/types/UaExpandedNodeId.d.ts +1 -0
- package/dist/common/types/UaExpandedNodeId.js +11 -0
- package/dist/common/types/index.d.ts +0 -1
- package/dist/common/types/index.js +0 -1
- package/package.json +1 -1
|
@@ -44,42 +44,36 @@ class UaNodeReaderBase {
|
|
|
44
44
|
let nodesToBrowse = this._nodesToBrowse.splice(0, 50);
|
|
45
45
|
let browseDescriptions = [];
|
|
46
46
|
for (let item of nodesToBrowse) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
BrowseDirection: opcua_webapi_1.BrowseDirection.Forward,
|
|
50
|
-
ReferenceTypeId: opcua_webapi_1.ReferenceTypeIds.HierarchicalReferences,
|
|
51
|
-
IncludeSubtypes: true,
|
|
52
|
-
NodeClassMask: item.nodeClassToReturn,
|
|
53
|
-
ResultMask: 63
|
|
54
|
-
});
|
|
47
|
+
let browseDescription = new common_1.UaBrowseDescription(item.nodeId, opcua_webapi_1.BrowseDirection.Forward, common_1.UaNodeId.from(common_1.ReferenceTypeIds.HierarchicalReferences), true, item.nodeClassToReturn, 63);
|
|
48
|
+
browseDescriptions.push(browseDescription);
|
|
55
49
|
}
|
|
56
50
|
let results = yield client.browse(browseDescriptions, 50);
|
|
57
51
|
for (let i = 0; i < nodesToBrowse.length; ++i) {
|
|
58
52
|
let currentNode = nodesToBrowse[i];
|
|
59
53
|
let currentResult = results[i];
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
54
|
+
if (currentResult.statusCode.isNotGood())
|
|
55
|
+
throw new common_1.UaError(currentResult.statusCode);
|
|
56
|
+
for (let item of currentResult.references) {
|
|
57
|
+
let nodeId = item.nodeId.getNodeId();
|
|
58
|
+
let typeDefinition = (_a = item.typeDefinition) === null || _a === void 0 ? void 0 : _a.getNodeId();
|
|
59
|
+
if (null == nodeId || null == typeDefinition)
|
|
60
|
+
continue;
|
|
67
61
|
this._browseResults.push({
|
|
68
62
|
fromNodeId: currentNode.nodeId,
|
|
69
|
-
nodeId:
|
|
70
|
-
nodeClass:
|
|
71
|
-
browseName:
|
|
72
|
-
displayName:
|
|
73
|
-
referenceTypeId:
|
|
74
|
-
isForward:
|
|
75
|
-
typeDefinitionId: (
|
|
63
|
+
nodeId: nodeId,
|
|
64
|
+
nodeClass: item.nodeClass,
|
|
65
|
+
browseName: item.browseName,
|
|
66
|
+
displayName: item.displayName,
|
|
67
|
+
referenceTypeId: item.referenceTypeId,
|
|
68
|
+
isForward: item.isForward,
|
|
69
|
+
typeDefinitionId: (typeDefinition) ? typeDefinition : undefined
|
|
76
70
|
});
|
|
77
|
-
this._updateNodesToBrowse(
|
|
71
|
+
this._updateNodesToBrowse(item);
|
|
78
72
|
}
|
|
79
|
-
if (currentResult.
|
|
73
|
+
if (currentResult.continuationPoint) {
|
|
80
74
|
this._continuationPointToBrowse.push({
|
|
81
75
|
nodeId: currentNode.nodeId,
|
|
82
|
-
continuationPoint: currentResult.
|
|
76
|
+
continuationPoint: currentResult.continuationPoint
|
|
83
77
|
});
|
|
84
78
|
}
|
|
85
79
|
}
|
|
@@ -87,7 +81,6 @@ class UaNodeReaderBase {
|
|
|
87
81
|
}
|
|
88
82
|
_browseContinuationPoints(client) {
|
|
89
83
|
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
-
var _a;
|
|
91
84
|
let cpsToBrowse = this._continuationPointToBrowse.splice(0, 50);
|
|
92
85
|
let continuationPoints = [];
|
|
93
86
|
for (let item of cpsToBrowse) {
|
|
@@ -97,29 +90,29 @@ class UaNodeReaderBase {
|
|
|
97
90
|
for (let i = 0; i < cpsToBrowse.length; ++i) {
|
|
98
91
|
let currentNode = cpsToBrowse[i];
|
|
99
92
|
let currentResult = results[i];
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
93
|
+
if (currentResult.statusCode.isNotGood())
|
|
94
|
+
throw new common_1.UaError(currentResult.statusCode);
|
|
95
|
+
for (let item of currentResult.references) {
|
|
96
|
+
let nodeId = item.nodeId.getNodeId();
|
|
97
|
+
let typeDefinition = item.typeDefinition ? item.typeDefinition.getNodeId() : undefined;
|
|
98
|
+
if (null == nodeId)
|
|
99
|
+
continue;
|
|
107
100
|
this._browseResults.push({
|
|
108
101
|
fromNodeId: currentNode.nodeId,
|
|
109
|
-
nodeId:
|
|
110
|
-
nodeClass:
|
|
111
|
-
browseName:
|
|
112
|
-
displayName:
|
|
113
|
-
referenceTypeId:
|
|
114
|
-
isForward:
|
|
115
|
-
typeDefinitionId: (
|
|
102
|
+
nodeId: nodeId,
|
|
103
|
+
nodeClass: item.nodeClass,
|
|
104
|
+
browseName: item.browseName,
|
|
105
|
+
displayName: item.displayName,
|
|
106
|
+
referenceTypeId: item.referenceTypeId,
|
|
107
|
+
isForward: item.isForward,
|
|
108
|
+
typeDefinitionId: (typeDefinition) ? typeDefinition : undefined
|
|
116
109
|
});
|
|
117
|
-
this._updateNodesToBrowse(
|
|
110
|
+
this._updateNodesToBrowse(item);
|
|
118
111
|
}
|
|
119
|
-
if (currentResult.
|
|
112
|
+
if (currentResult.continuationPoint && currentResult.continuationPoint.length != 0) {
|
|
120
113
|
this._continuationPointToBrowse.push({
|
|
121
114
|
nodeId: currentNode.nodeId,
|
|
122
|
-
continuationPoint: currentResult.
|
|
115
|
+
continuationPoint: currentResult.continuationPoint
|
|
123
116
|
});
|
|
124
117
|
}
|
|
125
118
|
}
|
|
@@ -200,26 +193,14 @@ class UaNodeReaderBase {
|
|
|
200
193
|
return;
|
|
201
194
|
let nodesToRead = [];
|
|
202
195
|
for (let item of typesToRead) {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
AttributeId: opcua_webapi_1.Attributes.IsAbstract
|
|
206
|
-
});
|
|
196
|
+
let nodeToRead = new common_1.UaReadValueId(item.nodeId, opcua_webapi_1.Attributes.IsAbstract);
|
|
197
|
+
nodesToRead.push(nodeToRead);
|
|
207
198
|
if (item.nodeClass == opcua_webapi_1.NodeClass.VariableType) {
|
|
208
|
-
nodesToRead.push(
|
|
209
|
-
|
|
210
|
-
AttributeId: opcua_webapi_1.Attributes.DataType
|
|
211
|
-
});
|
|
212
|
-
nodesToRead.push({
|
|
213
|
-
NodeId: item.nodeId.toString(),
|
|
214
|
-
AttributeId: opcua_webapi_1.Attributes.ValueRank
|
|
215
|
-
});
|
|
199
|
+
nodesToRead.push(new common_1.UaReadValueId(item.nodeId, opcua_webapi_1.Attributes.DataType));
|
|
200
|
+
nodesToRead.push(new common_1.UaReadValueId(item.nodeId, opcua_webapi_1.Attributes.ValueRank));
|
|
216
201
|
}
|
|
217
202
|
}
|
|
218
|
-
let
|
|
219
|
-
let dataValues = [];
|
|
220
|
-
for (let item of results) {
|
|
221
|
-
dataValues.push(common_1.UaPayloadMapper.dataValueFromWebApi(item));
|
|
222
|
-
}
|
|
203
|
+
let dataValues = yield client.read(nodesToRead);
|
|
223
204
|
for (let i = 0; i < typesToRead.length; ++i) {
|
|
224
205
|
let dataIndex = (typesToRead[i].nodeClass == opcua_webapi_1.NodeClass.VariableType) ? i * 3 : i;
|
|
225
206
|
if (dataValues[dataIndex].statusCode.isNotGood())
|
|
@@ -272,16 +253,10 @@ class UaNodeReaderBase {
|
|
|
272
253
|
return;
|
|
273
254
|
let nodesToRead = [];
|
|
274
255
|
for (let item of objectsToRead) {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
AttributeId: opcua_webapi_1.Attributes.EventNotifier
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
let results = yield client.read(nodesToRead);
|
|
281
|
-
let dataValues = [];
|
|
282
|
-
for (let item of results) {
|
|
283
|
-
dataValues.push(common_1.UaPayloadMapper.dataValueFromWebApi(item));
|
|
256
|
+
let nodeToRead = new common_1.UaReadValueId(item.nodeId, opcua_webapi_1.Attributes.EventNotifier);
|
|
257
|
+
nodesToRead.push(nodeToRead);
|
|
284
258
|
}
|
|
259
|
+
let dataValues = yield client.read(nodesToRead);
|
|
285
260
|
for (let i = 0; i < objectsToRead.length; ++i) {
|
|
286
261
|
if (dataValues[i].statusCode.isNotGood())
|
|
287
262
|
throw new common_1.UaError(dataValues[i].statusCode);
|
|
@@ -352,7 +327,7 @@ class UaNodeReaderBase {
|
|
|
352
327
|
}
|
|
353
328
|
else if (reference.nodeClass == opcua_webapi_1.NodeClass.Variable) {
|
|
354
329
|
if (reference.typeDefinition &&
|
|
355
|
-
!UaNodeReaderBase.s_variableTypeWithoutMember.has(reference.typeDefinition.
|
|
330
|
+
!UaNodeReaderBase.s_variableTypeWithoutMember.has(reference.typeDefinition.toString())) {
|
|
356
331
|
nodeClassToReturn = opcua_webapi_1.NodeClass.Variable;
|
|
357
332
|
}
|
|
358
333
|
}
|
|
@@ -430,25 +405,13 @@ class UaNodeReader extends UaNodeReaderBase {
|
|
|
430
405
|
let nodeIds = [];
|
|
431
406
|
let nodesToRead = [];
|
|
432
407
|
for (let item of this._nodeIds) {
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
nodesToRead.push({
|
|
439
|
-
NodeId: item,
|
|
440
|
-
AttributeId: opcua_webapi_1.Attributes.BrowseName
|
|
441
|
-
});
|
|
442
|
-
nodesToRead.push({
|
|
443
|
-
NodeId: item,
|
|
444
|
-
AttributeId: opcua_webapi_1.Attributes.DisplayName
|
|
445
|
-
});
|
|
446
|
-
}
|
|
447
|
-
let results = yield client.read(nodesToRead);
|
|
448
|
-
let dataValues = [];
|
|
449
|
-
for (let item of results) {
|
|
450
|
-
dataValues.push(common_1.UaPayloadMapper.dataValueFromWebApi(item));
|
|
408
|
+
let nodeId = (0, common_1.parseUaNodeId)(item);
|
|
409
|
+
nodeIds.push(nodeId);
|
|
410
|
+
nodesToRead.push(new common_1.UaReadValueId(nodeId, opcua_webapi_1.Attributes.NodeClass));
|
|
411
|
+
nodesToRead.push(new common_1.UaReadValueId(nodeId, opcua_webapi_1.Attributes.BrowseName));
|
|
412
|
+
nodesToRead.push(new common_1.UaReadValueId(nodeId, opcua_webapi_1.Attributes.DisplayName));
|
|
451
413
|
}
|
|
414
|
+
let dataValues = yield client.read(nodesToRead);
|
|
452
415
|
let browseResults = new Map;
|
|
453
416
|
for (let i = 0; i < nodeIds.length; ++i) {
|
|
454
417
|
let dataIndex = i * 3;
|
|
@@ -483,31 +446,24 @@ class UaNodeReader extends UaNodeReaderBase {
|
|
|
483
446
|
}
|
|
484
447
|
let browseDescriptions = [];
|
|
485
448
|
for (let item of browseResults) {
|
|
486
|
-
|
|
487
|
-
|
|
449
|
+
let currentNode = item[1];
|
|
450
|
+
if (currentNode.nodeClass != opcua_webapi_1.NodeClass.Object &&
|
|
451
|
+
currentNode.nodeClass != opcua_webapi_1.NodeClass.Variable)
|
|
488
452
|
continue;
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
BrowseDirection: opcua_webapi_1.BrowseDirection.Forward,
|
|
492
|
-
ReferenceTypeId: opcua_webapi_1.ReferenceTypeIds.HasTypeDefinition,
|
|
493
|
-
IncludeSubtypes: false,
|
|
494
|
-
NodeClassMask: opcua_webapi_1.NodeClass.ObjectType | opcua_webapi_1.NodeClass.VariableType,
|
|
495
|
-
ResultMask: 0
|
|
496
|
-
});
|
|
453
|
+
let browseDescription = new common_1.UaBrowseDescription(currentNode.nodeId, opcua_webapi_1.BrowseDirection.Forward, common_1.UaNodeId.from(common_1.ReferenceTypeIds.HierarchicalReferences), false, opcua_webapi_1.NodeClass.ObjectType | opcua_webapi_1.NodeClass.VariableType, 0);
|
|
454
|
+
browseDescriptions.push(browseDescription);
|
|
497
455
|
}
|
|
498
456
|
if (browseDescriptions.length != 0) {
|
|
499
457
|
let results = yield client.browse(browseDescriptions);
|
|
500
458
|
for (let i = 0; i < browseDescriptions.length; ++i) {
|
|
501
|
-
let browseResult = browseResults.get(browseDescriptions[i].
|
|
459
|
+
let browseResult = browseResults.get(browseDescriptions[i].nodeId.toString());
|
|
502
460
|
if (undefined == browseResult)
|
|
503
461
|
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadUnexpectedError));
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
if (!results[i].References || results[i].References.length != 1)
|
|
462
|
+
if (results[i].statusCode.isNotGood())
|
|
463
|
+
throw new common_1.UaError(results[i].statusCode);
|
|
464
|
+
if (results[i].references.length != 1)
|
|
508
465
|
continue;
|
|
509
|
-
|
|
510
|
-
browseResult.typeDefinitionId = reference.nodeId.getNodeId();
|
|
466
|
+
browseResult.typeDefinitionId = results[i].references[0].nodeId.getNodeId();
|
|
511
467
|
}
|
|
512
468
|
}
|
|
513
469
|
this._browseResults = Array.from(browseResults.values());
|
|
@@ -631,41 +587,35 @@ class UaNodeLinkReader {
|
|
|
631
587
|
let nodesToBrowse = this._nodesToBrowse.splice(0, 50);
|
|
632
588
|
let browseDescriptions = [];
|
|
633
589
|
for (let item of nodesToBrowse) {
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
BrowseDirection: opcua_webapi_1.BrowseDirection.Both,
|
|
637
|
-
ReferenceTypeId: opcua_webapi_1.ReferenceTypeIds.NonHierarchicalReferences,
|
|
638
|
-
IncludeSubtypes: true,
|
|
639
|
-
NodeClassMask: opcua_webapi_1.NodeClass.Object | opcua_webapi_1.NodeClass.Variable | opcua_webapi_1.NodeClass.Method,
|
|
640
|
-
ResultMask: 7
|
|
641
|
-
});
|
|
590
|
+
let browseDescription = new common_1.UaBrowseDescription(item, opcua_webapi_1.BrowseDirection.Both, common_1.UaNodeId.from(common_1.ReferenceTypeIds.NonHierarchicalReferences), true, opcua_webapi_1.NodeClass.Object | opcua_webapi_1.NodeClass.Variable | opcua_webapi_1.NodeClass.Method, 7);
|
|
591
|
+
browseDescriptions.push(browseDescription);
|
|
642
592
|
}
|
|
643
593
|
let results = yield client.browse(browseDescriptions, 50);
|
|
644
594
|
for (let i = 0; i < nodesToBrowse.length; ++i) {
|
|
645
595
|
let currentNodeId = nodesToBrowse[i];
|
|
646
596
|
let currentResult = results[i];
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
597
|
+
if (currentResult.statusCode.isNotGood())
|
|
598
|
+
throw new common_1.UaError(currentResult.statusCode);
|
|
599
|
+
for (let item of currentResult.references) {
|
|
600
|
+
let nodeId = item.nodeId.getNodeId();
|
|
601
|
+
let typeDefinition = (_a = item.typeDefinition) === null || _a === void 0 ? void 0 : _a.getNodeId();
|
|
602
|
+
if (null == nodeId || null == typeDefinition)
|
|
603
|
+
continue;
|
|
654
604
|
this._browseResults.push({
|
|
655
605
|
fromNodeId: currentNodeId,
|
|
656
|
-
nodeId:
|
|
657
|
-
nodeClass:
|
|
658
|
-
browseName:
|
|
659
|
-
displayName:
|
|
660
|
-
referenceTypeId:
|
|
661
|
-
isForward:
|
|
662
|
-
typeDefinitionId:
|
|
606
|
+
nodeId: nodeId,
|
|
607
|
+
nodeClass: item.nodeClass,
|
|
608
|
+
browseName: item.browseName,
|
|
609
|
+
displayName: item.displayName,
|
|
610
|
+
referenceTypeId: item.referenceTypeId,
|
|
611
|
+
isForward: item.isForward,
|
|
612
|
+
typeDefinitionId: typeDefinition
|
|
663
613
|
});
|
|
664
614
|
}
|
|
665
|
-
if (currentResult.
|
|
615
|
+
if (currentResult.continuationPoint) {
|
|
666
616
|
this._continuationPointToBrowse.push({
|
|
667
617
|
nodeId: currentNodeId,
|
|
668
|
-
continuationPoint: currentResult.
|
|
618
|
+
continuationPoint: currentResult.continuationPoint
|
|
669
619
|
});
|
|
670
620
|
}
|
|
671
621
|
}
|
|
@@ -683,28 +633,28 @@ class UaNodeLinkReader {
|
|
|
683
633
|
for (let i = 0; i < cpsToBrowse.length; ++i) {
|
|
684
634
|
let currentNodeId = cpsToBrowse[i].nodeId;
|
|
685
635
|
let currentResult = results[i];
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
636
|
+
if (currentResult.statusCode.isNotGood())
|
|
637
|
+
throw new common_1.UaError(currentResult.statusCode);
|
|
638
|
+
for (let item of currentResult.references) {
|
|
639
|
+
let nodeId = item.nodeId.getNodeId();
|
|
640
|
+
let typeDefinition = (_a = item.typeDefinition) === null || _a === void 0 ? void 0 : _a.getNodeId();
|
|
641
|
+
if (null == nodeId || null == typeDefinition)
|
|
642
|
+
continue;
|
|
693
643
|
this._browseResults.push({
|
|
694
644
|
fromNodeId: currentNodeId,
|
|
695
|
-
nodeId:
|
|
696
|
-
nodeClass:
|
|
697
|
-
browseName:
|
|
698
|
-
displayName:
|
|
699
|
-
referenceTypeId:
|
|
700
|
-
isForward:
|
|
701
|
-
typeDefinitionId:
|
|
645
|
+
nodeId: nodeId,
|
|
646
|
+
nodeClass: item.nodeClass,
|
|
647
|
+
browseName: item.browseName,
|
|
648
|
+
displayName: item.displayName,
|
|
649
|
+
referenceTypeId: item.referenceTypeId,
|
|
650
|
+
isForward: item.isForward,
|
|
651
|
+
typeDefinitionId: typeDefinition
|
|
702
652
|
});
|
|
703
653
|
}
|
|
704
|
-
if (currentResult.
|
|
654
|
+
if (currentResult.continuationPoint) {
|
|
705
655
|
this._continuationPointToBrowse.push({
|
|
706
656
|
nodeId: currentNodeId,
|
|
707
|
-
continuationPoint: currentResult.
|
|
657
|
+
continuationPoint: currentResult.continuationPoint
|
|
708
658
|
});
|
|
709
659
|
}
|
|
710
660
|
}
|
|
@@ -38,27 +38,20 @@ class UaObjectTypeDictionary {
|
|
|
38
38
|
let nodeIds = this._remainingNodesToBrowse.splice(0, 15);
|
|
39
39
|
let nodesToBrowse = [];
|
|
40
40
|
for (let item of nodeIds) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
BrowseDirection: opcua_webapi_1.BrowseDirection.Forward,
|
|
44
|
-
ReferenceTypeId: new common_1.UaNodeId(common_1.ReferenceTypeIds.HasSubtype).toString(),
|
|
45
|
-
IncludeSubtypes: false,
|
|
46
|
-
NodeClassMask: opcua_webapi_1.NodeClass.ObjectType,
|
|
47
|
-
ResultMask: 31
|
|
48
|
-
});
|
|
41
|
+
let browseDescription = new common_1.UaBrowseDescription(item, opcua_webapi_1.BrowseDirection.Forward, new common_1.UaNodeId(common_1.ReferenceTypeIds.HasSubtype), false, opcua_webapi_1.NodeClass.ObjectType, 31);
|
|
42
|
+
nodesToBrowse.push(browseDescription);
|
|
49
43
|
}
|
|
50
44
|
let results = yield client.browse(nodesToBrowse);
|
|
51
45
|
for (let i = 0; i < nodeIds.length; ++i) {
|
|
52
|
-
|
|
53
|
-
if (statusCode.isNotGood() || !results[i].References)
|
|
46
|
+
if (results[i].statusCode.isNotGood())
|
|
54
47
|
continue;
|
|
55
48
|
let parentType = this._objectTypes.get(nodeIds[i].toString());
|
|
56
|
-
for (let item of results[i].
|
|
57
|
-
let objectTypeId =
|
|
58
|
-
if (
|
|
59
|
-
!item.
|
|
49
|
+
for (let item of results[i].references) {
|
|
50
|
+
let objectTypeId = item.nodeId.getNodeId();
|
|
51
|
+
if (null == objectTypeId || opcua_webapi_1.NodeClass.ObjectType != item.nodeClass ||
|
|
52
|
+
!item.browseName || !item.displayName)
|
|
60
53
|
continue;
|
|
61
|
-
let objectType = new common_1.UaObjectType(objectTypeId, item.
|
|
54
|
+
let objectType = new common_1.UaObjectType(objectTypeId, item.browseName, item.displayName, false);
|
|
62
55
|
this._objectTypes.set(objectTypeId.toString(), objectType);
|
|
63
56
|
this._remainingNodesToBrowse.push(objectTypeId);
|
|
64
57
|
if (parentType)
|
|
@@ -38,27 +38,20 @@ class UaReferenceTypeDictionary {
|
|
|
38
38
|
let nodeIds = this._remainingNodesToBrowse.splice(0, 15);
|
|
39
39
|
let nodesToBrowse = [];
|
|
40
40
|
for (let item of nodeIds) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
BrowseDirection: opcua_webapi_1.BrowseDirection.Forward,
|
|
44
|
-
ReferenceTypeId: new common_1.UaNodeId(common_1.ReferenceTypeIds.HasSubtype).toString(),
|
|
45
|
-
IncludeSubtypes: false,
|
|
46
|
-
NodeClassMask: opcua_webapi_1.NodeClass.ReferenceType,
|
|
47
|
-
ResultMask: 31
|
|
48
|
-
});
|
|
41
|
+
let browseDescription = new common_1.UaBrowseDescription(item, opcua_webapi_1.BrowseDirection.Forward, new common_1.UaNodeId(common_1.ReferenceTypeIds.HasSubtype), false, opcua_webapi_1.NodeClass.ReferenceType, 31);
|
|
42
|
+
nodesToBrowse.push(browseDescription);
|
|
49
43
|
}
|
|
50
44
|
let results = yield client.browse(nodesToBrowse);
|
|
51
45
|
for (let i = 0; i < nodeIds.length; ++i) {
|
|
52
|
-
|
|
53
|
-
if (statusCode.isNotGood() || !results[i].References)
|
|
46
|
+
if (results[i].statusCode.isNotGood())
|
|
54
47
|
continue;
|
|
55
48
|
let parentType = this._referenceTypes.get(nodeIds[i].toString());
|
|
56
|
-
for (let item of results[i].
|
|
57
|
-
let referenceTypeId =
|
|
58
|
-
if (
|
|
59
|
-
!item.
|
|
49
|
+
for (let item of results[i].references) {
|
|
50
|
+
let referenceTypeId = item.nodeId.getNodeId();
|
|
51
|
+
if (null == referenceTypeId || opcua_webapi_1.NodeClass.ReferenceType != item.nodeClass ||
|
|
52
|
+
!item.browseName || !item.displayName)
|
|
60
53
|
continue;
|
|
61
|
-
let referenceType = new common_1.UaReferenceType(referenceTypeId, item.
|
|
54
|
+
let referenceType = new common_1.UaReferenceType(referenceTypeId, item.browseName, item.displayName, false, common_1.UaLocalizedText.nullText, false);
|
|
62
55
|
this._referenceTypes.set(referenceTypeId.toString(), referenceType);
|
|
63
56
|
this._remainingNodesToBrowse.push(referenceTypeId);
|
|
64
57
|
if (parentType)
|
package/dist/common/index.d.ts
CHANGED
package/dist/common/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./payload"), exports);
|
|
18
18
|
__exportStar(require("./types"), exports);
|
|
19
19
|
__exportStar(require("./structure"), exports);
|
|
20
20
|
__exportStar(require("./nodes"), exports);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BrowseDescription } from "opcua-webapi";
|
|
2
|
+
import { UaNodeId } from "../types";
|
|
3
|
+
export declare class UaBrowseDescription {
|
|
4
|
+
static dataTypeId: UaNodeId;
|
|
5
|
+
private _nodeId;
|
|
6
|
+
private _browseDirection;
|
|
7
|
+
private _referenceTypeId;
|
|
8
|
+
private _includeSubtypes;
|
|
9
|
+
private _nodeClassMask;
|
|
10
|
+
private _resultMask;
|
|
11
|
+
constructor(nodeId: UaNodeId, browseDirection: number, referenceTypeId: UaNodeId, includeSubtypes: boolean, nodeClassMask: number, resultMask: number);
|
|
12
|
+
get nodeId(): UaNodeId;
|
|
13
|
+
get browseDirection(): number;
|
|
14
|
+
get referenceTypeId(): UaNodeId;
|
|
15
|
+
get includeSubtypes(): boolean;
|
|
16
|
+
get nodeClassMask(): number;
|
|
17
|
+
get resultMask(): number;
|
|
18
|
+
toStruct(): BrowseDescription;
|
|
19
|
+
static fromStruct(browseDescription: BrowseDescription): UaBrowseDescription | null;
|
|
20
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UaBrowseDescription = void 0;
|
|
4
|
+
const opcua_webapi_1 = require("opcua-webapi");
|
|
5
|
+
const nodes_1 = require("../nodes");
|
|
6
|
+
const types_1 = require("../types");
|
|
7
|
+
class UaBrowseDescription {
|
|
8
|
+
constructor(nodeId, browseDirection, referenceTypeId, includeSubtypes, nodeClassMask, resultMask) {
|
|
9
|
+
this._nodeId = nodeId;
|
|
10
|
+
this._browseDirection = browseDirection;
|
|
11
|
+
this._referenceTypeId = referenceTypeId;
|
|
12
|
+
this._includeSubtypes = includeSubtypes;
|
|
13
|
+
this._nodeClassMask = nodeClassMask;
|
|
14
|
+
this._resultMask = resultMask;
|
|
15
|
+
}
|
|
16
|
+
get nodeId() {
|
|
17
|
+
return this._nodeId;
|
|
18
|
+
}
|
|
19
|
+
get browseDirection() {
|
|
20
|
+
return this._browseDirection;
|
|
21
|
+
}
|
|
22
|
+
get referenceTypeId() {
|
|
23
|
+
return this._referenceTypeId;
|
|
24
|
+
}
|
|
25
|
+
get includeSubtypes() {
|
|
26
|
+
return this._includeSubtypes;
|
|
27
|
+
}
|
|
28
|
+
get nodeClassMask() {
|
|
29
|
+
return this._nodeClassMask;
|
|
30
|
+
}
|
|
31
|
+
get resultMask() {
|
|
32
|
+
return this._resultMask;
|
|
33
|
+
}
|
|
34
|
+
toStruct() {
|
|
35
|
+
let browseDescription = {
|
|
36
|
+
NodeId: this._nodeId.toString(),
|
|
37
|
+
BrowseDirection: this._browseDirection,
|
|
38
|
+
ReferenceTypeId: this._referenceTypeId.toString(),
|
|
39
|
+
IncludeSubtypes: this._includeSubtypes,
|
|
40
|
+
NodeClassMask: this._nodeClassMask,
|
|
41
|
+
ResultMask: this._resultMask
|
|
42
|
+
};
|
|
43
|
+
return browseDescription;
|
|
44
|
+
}
|
|
45
|
+
static fromStruct(browseDescription) {
|
|
46
|
+
let nodeId = (0, types_1.parseUaNodeIdOrNull)(browseDescription.NodeId);
|
|
47
|
+
let referenceTypeId = (0, types_1.parseUaNodeIdOrNull)(browseDescription.ReferenceTypeId);
|
|
48
|
+
if (null == nodeId || null == referenceTypeId)
|
|
49
|
+
return null;
|
|
50
|
+
let browseDirection = (typeof browseDescription.BrowseDirection === "number") ? browseDescription.BrowseDirection : opcua_webapi_1.BrowseDirection.Invalid;
|
|
51
|
+
let includeSubtypes = (browseDescription.IncludeSubtypes) ? true : false;
|
|
52
|
+
let nodeClassMask = (browseDescription.NodeClassMask) ? browseDescription.NodeClassMask : 0;
|
|
53
|
+
let resultMask = (browseDescription.ResultMask) ? browseDescription.ResultMask : 0;
|
|
54
|
+
return new UaBrowseDescription(nodeId, browseDirection, referenceTypeId, includeSubtypes, nodeClassMask, resultMask);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.UaBrowseDescription = UaBrowseDescription;
|
|
58
|
+
UaBrowseDescription.dataTypeId = new types_1.UaNodeId(nodes_1.DataTypeIds.BrowseDescription);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BrowseResult } from "opcua-webapi";
|
|
2
|
+
import { UaNodeId, UaStatusCode } from "../types";
|
|
3
|
+
import { UaReferenceDescription } from ".";
|
|
4
|
+
export declare class UaBrowseResult {
|
|
5
|
+
static dataTypeId: UaNodeId;
|
|
6
|
+
private _references;
|
|
7
|
+
private _continuationPoint;
|
|
8
|
+
private _statusCode;
|
|
9
|
+
constructor(references: Array<UaReferenceDescription>, continuationPoint: string | null, statusCode: UaStatusCode);
|
|
10
|
+
get references(): Array<UaReferenceDescription>;
|
|
11
|
+
get results(): Array<UaReferenceDescription>;
|
|
12
|
+
get continuationPoint(): string | null;
|
|
13
|
+
get statusCode(): UaStatusCode;
|
|
14
|
+
toStruct(): BrowseResult;
|
|
15
|
+
static fromStruct(browseResult: BrowseResult): UaBrowseResult | null;
|
|
16
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UaBrowseResult = void 0;
|
|
4
|
+
const opcua_webapi_1 = require("opcua-webapi");
|
|
5
|
+
const nodes_1 = require("../nodes");
|
|
6
|
+
const types_1 = require("../types");
|
|
7
|
+
const _1 = require(".");
|
|
8
|
+
class UaBrowseResult {
|
|
9
|
+
constructor(references, continuationPoint, statusCode) {
|
|
10
|
+
this._references = references;
|
|
11
|
+
this._continuationPoint = continuationPoint;
|
|
12
|
+
this._statusCode = statusCode;
|
|
13
|
+
}
|
|
14
|
+
get references() {
|
|
15
|
+
return this._references;
|
|
16
|
+
}
|
|
17
|
+
get results() {
|
|
18
|
+
return this._references;
|
|
19
|
+
}
|
|
20
|
+
get continuationPoint() {
|
|
21
|
+
return this._continuationPoint;
|
|
22
|
+
}
|
|
23
|
+
get statusCode() {
|
|
24
|
+
return this._statusCode;
|
|
25
|
+
}
|
|
26
|
+
toStruct() {
|
|
27
|
+
let references = [];
|
|
28
|
+
for (let item of this._references) {
|
|
29
|
+
references.push(item.toStruct());
|
|
30
|
+
}
|
|
31
|
+
let browseResult = {
|
|
32
|
+
StatusCode: _1.UaPayloadMapper.statusCodeToWebApi(this._statusCode),
|
|
33
|
+
ContinuationPoint: (this._continuationPoint) ? this._continuationPoint : undefined,
|
|
34
|
+
References: references
|
|
35
|
+
};
|
|
36
|
+
return browseResult;
|
|
37
|
+
}
|
|
38
|
+
static fromStruct(browseResult) {
|
|
39
|
+
let references = [];
|
|
40
|
+
if (browseResult.References) {
|
|
41
|
+
for (let item of browseResult.References) {
|
|
42
|
+
let reference = _1.UaReferenceDescription.fromStruct(item);
|
|
43
|
+
if (null == reference)
|
|
44
|
+
return null;
|
|
45
|
+
references.push(reference);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return new UaBrowseResult(references, browseResult.ContinuationPoint, (browseResult.StatusCode) ? (0, types_1.makeUaStatusCode)(browseResult.StatusCode.Code) : (0, types_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.Good));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.UaBrowseResult = UaBrowseResult;
|
|
52
|
+
UaBrowseResult.dataTypeId = new types_1.UaNodeId(nodes_1.DataTypeIds.BrowseResult);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CallMethodRequest } from "opcua-webapi";
|
|
2
|
+
import { UaNodeId, UaVariant } from "../types";
|
|
3
|
+
export declare class UaCallMethodRequest {
|
|
4
|
+
static dataTypeId: UaNodeId;
|
|
5
|
+
private _objectId;
|
|
6
|
+
private _methodId;
|
|
7
|
+
private _inputArguments;
|
|
8
|
+
constructor(objectId: UaNodeId, methodId: UaNodeId, inputArguments?: Array<UaVariant>);
|
|
9
|
+
get objectId(): UaNodeId;
|
|
10
|
+
get methodId(): UaNodeId;
|
|
11
|
+
get inputArguments(): Array<UaVariant>;
|
|
12
|
+
toStruct(): CallMethodRequest;
|
|
13
|
+
static fromStruct(callMethodRequest: CallMethodRequest): UaCallMethodRequest | null;
|
|
14
|
+
}
|