opcua-webapi-ts 1.0.21 → 1.0.23

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 (93) hide show
  1. package/dist/cjs/client/UaWebClient.d.ts +10 -11
  2. package/dist/cjs/client/UaWebClient.js +154 -174
  3. package/dist/cjs/client/utils/UaDataTypeDictionary.js +15 -27
  4. package/dist/cjs/client/utils/UaNodeReader.d.ts +1 -1
  5. package/dist/cjs/client/utils/UaNodeReader.js +95 -145
  6. package/dist/cjs/client/utils/UaObjectTypeDictionary.js +8 -15
  7. package/dist/cjs/client/utils/UaReferenceTypeDictionary.js +8 -15
  8. package/dist/cjs/common/index.d.ts +1 -1
  9. package/dist/cjs/common/index.js +1 -1
  10. package/dist/cjs/common/payload/UaBrowseDescription.d.ts +20 -0
  11. package/dist/cjs/common/payload/UaBrowseDescription.js +58 -0
  12. package/dist/cjs/common/payload/UaBrowseResult.d.ts +16 -0
  13. package/dist/cjs/common/payload/UaBrowseResult.js +52 -0
  14. package/dist/cjs/common/payload/UaCallMethodRequest.d.ts +14 -0
  15. package/dist/cjs/common/payload/UaCallMethodRequest.js +48 -0
  16. package/dist/cjs/common/payload/UaCallMethodResult.d.ts +14 -0
  17. package/dist/cjs/common/payload/UaCallMethodResult.js +59 -0
  18. package/dist/cjs/common/payload/UaHistoryReadResult.d.ts +14 -0
  19. package/dist/cjs/common/payload/UaHistoryReadResult.js +38 -0
  20. package/dist/cjs/common/payload/UaHistoryReadValueId.d.ts +14 -0
  21. package/dist/cjs/common/payload/UaHistoryReadValueId.js +39 -0
  22. package/dist/cjs/common/payload/UaPayloadMapper.d.ts +15 -0
  23. package/dist/cjs/common/payload/UaPayloadMapper.js +444 -0
  24. package/dist/cjs/common/payload/UaReadValueId.d.ts +14 -0
  25. package/dist/cjs/common/payload/UaReadValueId.js +39 -0
  26. package/dist/cjs/common/payload/UaReferenceDescription.d.ts +22 -0
  27. package/dist/cjs/common/payload/UaReferenceDescription.js +61 -0
  28. package/dist/cjs/common/payload/UaWriteValue.d.ts +16 -0
  29. package/dist/cjs/common/payload/UaWriteValue.js +49 -0
  30. package/dist/cjs/common/payload/index.d.ts +10 -0
  31. package/dist/cjs/common/payload/index.js +26 -0
  32. package/dist/cjs/common/structure/UaArgument.js +3 -3
  33. package/dist/cjs/common/structure/UaContentFilterElement.js +3 -3
  34. package/dist/cjs/common/structure/UaEUInformation.js +5 -5
  35. package/dist/cjs/common/structure/UaEnumValueType.js +5 -5
  36. package/dist/cjs/common/structure/UaHistoryData.js +3 -3
  37. package/dist/cjs/common/structure/UaHistoryEvent.js +3 -3
  38. package/dist/cjs/common/structure/UaLiteralOperand.js +3 -3
  39. package/dist/cjs/common/types/UaAccessLevel.d.ts +10 -0
  40. package/dist/cjs/common/types/UaAccessLevel.js +14 -0
  41. package/dist/cjs/common/types/UaExpandedNodeId.d.ts +1 -0
  42. package/dist/cjs/common/types/UaExpandedNodeId.js +11 -0
  43. package/dist/cjs/common/types/UaWriteMask.d.ts +28 -0
  44. package/dist/cjs/common/types/UaWriteMask.js +32 -0
  45. package/dist/cjs/common/types/index.d.ts +2 -1
  46. package/dist/cjs/common/types/index.js +2 -1
  47. package/dist/client/UaWebClient.d.ts +10 -11
  48. package/dist/client/UaWebClient.js +154 -174
  49. package/dist/client/utils/UaDataTypeDictionary.js +15 -27
  50. package/dist/client/utils/UaNodeReader.d.ts +1 -1
  51. package/dist/client/utils/UaNodeReader.js +95 -145
  52. package/dist/client/utils/UaObjectTypeDictionary.js +8 -15
  53. package/dist/client/utils/UaReferenceTypeDictionary.js +8 -15
  54. package/dist/common/index.d.ts +1 -1
  55. package/dist/common/index.js +1 -1
  56. package/dist/common/payload/UaBrowseDescription.d.ts +20 -0
  57. package/dist/common/payload/UaBrowseDescription.js +58 -0
  58. package/dist/common/payload/UaBrowseResult.d.ts +16 -0
  59. package/dist/common/payload/UaBrowseResult.js +52 -0
  60. package/dist/common/payload/UaCallMethodRequest.d.ts +14 -0
  61. package/dist/common/payload/UaCallMethodRequest.js +48 -0
  62. package/dist/common/payload/UaCallMethodResult.d.ts +14 -0
  63. package/dist/common/payload/UaCallMethodResult.js +59 -0
  64. package/dist/common/payload/UaHistoryReadResult.d.ts +14 -0
  65. package/dist/common/payload/UaHistoryReadResult.js +38 -0
  66. package/dist/common/payload/UaHistoryReadValueId.d.ts +14 -0
  67. package/dist/common/payload/UaHistoryReadValueId.js +39 -0
  68. package/dist/common/payload/UaPayloadMapper.d.ts +15 -0
  69. package/dist/common/payload/UaPayloadMapper.js +444 -0
  70. package/dist/common/payload/UaReadValueId.d.ts +14 -0
  71. package/dist/common/payload/UaReadValueId.js +39 -0
  72. package/dist/common/payload/UaReferenceDescription.d.ts +22 -0
  73. package/dist/common/payload/UaReferenceDescription.js +61 -0
  74. package/dist/common/payload/UaWriteValue.d.ts +16 -0
  75. package/dist/common/payload/UaWriteValue.js +49 -0
  76. package/dist/common/payload/index.d.ts +10 -0
  77. package/dist/common/payload/index.js +26 -0
  78. package/dist/common/structure/UaArgument.js +3 -3
  79. package/dist/common/structure/UaContentFilterElement.js +3 -3
  80. package/dist/common/structure/UaEUInformation.js +5 -5
  81. package/dist/common/structure/UaEnumValueType.js +5 -5
  82. package/dist/common/structure/UaHistoryData.js +3 -3
  83. package/dist/common/structure/UaHistoryEvent.js +3 -3
  84. package/dist/common/structure/UaLiteralOperand.js +3 -3
  85. package/dist/common/types/UaAccessLevel.d.ts +10 -0
  86. package/dist/common/types/UaAccessLevel.js +14 -0
  87. package/dist/common/types/UaExpandedNodeId.d.ts +1 -0
  88. package/dist/common/types/UaExpandedNodeId.js +11 -0
  89. package/dist/common/types/UaWriteMask.d.ts +28 -0
  90. package/dist/common/types/UaWriteMask.js +32 -0
  91. package/dist/common/types/index.d.ts +2 -1
  92. package/dist/common/types/index.js +2 -1
  93. 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
- browseDescriptions.push({
48
- NodeId: item.nodeId.toString(),
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
- let statusCode = common_1.UaPayloadMapper.statusCodeFromWebApi(currentResult.StatusCode);
61
- if (statusCode.isNotGood())
62
- throw new common_1.UaError(statusCode);
63
- if (!currentResult.References)
64
- continue;
65
- for (let item of currentResult.References) {
66
- let reference = common_1.UaPayloadMapper.referenceDescriptionFromWebApi(item);
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: reference.nodeId.getNodeId(),
70
- nodeClass: reference.nodeClass,
71
- browseName: reference.browseName,
72
- displayName: reference.displayName,
73
- referenceTypeId: reference.referenceTypeId,
74
- isForward: reference.isForward,
75
- typeDefinitionId: (_a = reference.typeDefinition) === null || _a === void 0 ? void 0 : _a.getNodeId()
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(reference);
71
+ this._updateNodesToBrowse(item);
78
72
  }
79
- if (currentResult.ContinuationPoint && currentResult.ContinuationPoint.length != 0) {
73
+ if (currentResult.continuationPoint) {
80
74
  this._continuationPointToBrowse.push({
81
75
  nodeId: currentNode.nodeId,
82
- continuationPoint: currentResult.ContinuationPoint
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
- let statusCode = common_1.UaPayloadMapper.statusCodeFromWebApi(currentResult.StatusCode);
101
- if (statusCode.isNotGood())
102
- throw new common_1.UaError(statusCode);
103
- if (!currentResult.References)
104
- continue;
105
- for (let item of currentResult.References) {
106
- let reference = common_1.UaPayloadMapper.referenceDescriptionFromWebApi(item);
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: reference.nodeId.getNodeId(),
110
- nodeClass: reference.nodeClass,
111
- browseName: reference.browseName,
112
- displayName: reference.displayName,
113
- referenceTypeId: reference.referenceTypeId,
114
- isForward: reference.isForward,
115
- typeDefinitionId: (_a = reference.typeDefinition) === null || _a === void 0 ? void 0 : _a.getNodeId()
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(reference);
110
+ this._updateNodesToBrowse(item);
118
111
  }
119
- if (currentResult.ContinuationPoint && currentResult.ContinuationPoint.length != 0) {
112
+ if (currentResult.continuationPoint && currentResult.continuationPoint.length != 0) {
120
113
  this._continuationPointToBrowse.push({
121
114
  nodeId: currentNode.nodeId,
122
- continuationPoint: currentResult.ContinuationPoint
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
- nodesToRead.push({
204
- NodeId: item.nodeId.toString(),
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
- NodeId: item.nodeId.toString(),
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 results = yield client.read(nodesToRead);
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
- nodesToRead.push({
276
- NodeId: item.nodeId.toString(),
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.getNodeId().toString())) {
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
- nodeIds.push((0, common_1.parseUaNodeId)(item));
434
- nodesToRead.push({
435
- NodeId: item,
436
- AttributeId: opcua_webapi_1.Attributes.NodeClass
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
- if (item[1].nodeClass != opcua_webapi_1.NodeClass.Object &&
487
- item[1].nodeClass != opcua_webapi_1.NodeClass.Variable)
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
- browseDescriptions.push({
490
- NodeId: item[0],
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].NodeId);
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
- let statusCode = common_1.UaPayloadMapper.statusCodeFromWebApi(results[i].StatusCode);
505
- if (statusCode.isNotGood())
506
- throw new common_1.UaError(statusCode);
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
- let reference = common_1.UaPayloadMapper.referenceDescriptionFromWebApi(results[i].References[0]);
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
- browseDescriptions.push({
635
- NodeId: item.toString(),
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
- let statusCode = common_1.UaPayloadMapper.statusCodeFromWebApi(currentResult.StatusCode);
648
- if (statusCode.isNotGood())
649
- throw new common_1.UaError(statusCode);
650
- if (!currentResult.References)
651
- continue;
652
- for (let item of currentResult.References) {
653
- let reference = common_1.UaPayloadMapper.referenceDescriptionFromWebApi(item);
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: reference.nodeId.getNodeId(),
657
- nodeClass: reference.nodeClass,
658
- browseName: reference.browseName,
659
- displayName: reference.displayName,
660
- referenceTypeId: reference.referenceTypeId,
661
- isForward: reference.isForward,
662
- typeDefinitionId: (_a = reference.typeDefinition) === null || _a === void 0 ? void 0 : _a.getNodeId()
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.ContinuationPoint && currentResult.ContinuationPoint.length != 0) {
615
+ if (currentResult.continuationPoint) {
666
616
  this._continuationPointToBrowse.push({
667
617
  nodeId: currentNodeId,
668
- continuationPoint: currentResult.ContinuationPoint
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
- let statusCode = common_1.UaPayloadMapper.statusCodeFromWebApi(currentResult.StatusCode);
687
- if (statusCode.isNotGood())
688
- throw new common_1.UaError(statusCode);
689
- if (!currentResult.References)
690
- continue;
691
- for (let item of currentResult.References) {
692
- let reference = common_1.UaPayloadMapper.referenceDescriptionFromWebApi(item);
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: reference.nodeId.getNodeId(),
696
- nodeClass: reference.nodeClass,
697
- browseName: reference.browseName,
698
- displayName: reference.displayName,
699
- referenceTypeId: reference.referenceTypeId,
700
- isForward: reference.isForward,
701
- typeDefinitionId: (_a = reference.typeDefinition) === null || _a === void 0 ? void 0 : _a.getNodeId()
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.ContinuationPoint && currentResult.ContinuationPoint.length != 0) {
654
+ if (currentResult.continuationPoint) {
705
655
  this._continuationPointToBrowse.push({
706
656
  nodeId: currentNodeId,
707
- continuationPoint: currentResult.ContinuationPoint
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
- nodesToBrowse.push({
42
- NodeId: item.toString(),
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
- let statusCode = common_1.UaPayloadMapper.statusCodeFromWebApi(results[i].StatusCode);
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].References) {
57
- let objectTypeId = (0, common_1.parseUaNodeIdOrNull)(item.NodeId);
58
- if (!objectTypeId || opcua_webapi_1.NodeClass.ObjectType != item.NodeClass ||
59
- !item.BrowseName || !item.DisplayName)
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.BrowseName, common_1.UaPayloadMapper.localizedTextFromWebApi(item.DisplayName), false);
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
- nodesToBrowse.push({
42
- NodeId: item.toString(),
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
- let statusCode = common_1.UaPayloadMapper.statusCodeFromWebApi(results[i].StatusCode);
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].References) {
57
- let referenceTypeId = (0, common_1.parseUaNodeIdOrNull)(item.NodeId);
58
- if (!referenceTypeId || opcua_webapi_1.NodeClass.ReferenceType != item.NodeClass ||
59
- !item.BrowseName || !item.DisplayName)
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.BrowseName, common_1.UaPayloadMapper.localizedTextFromWebApi(item.DisplayName), false, common_1.UaLocalizedText.nullText, false);
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)
@@ -1,4 +1,4 @@
1
- export * from "./mapper";
1
+ export * from "./payload";
2
2
  export * from "./types";
3
3
  export * from "./structure";
4
4
  export * from "./nodes";
@@ -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("./mapper"), exports);
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
+ }