opcua-webapi-ts 1.1.0 → 1.1.2
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/utils/UaNodeReader.js +58 -29
- package/dist/cjs/client/utils/UaObjectTypeDictionary.js +1 -1
- package/dist/cjs/common/types/UaLink.js +9 -1
- package/dist/client/utils/UaNodeReader.d.ts +4 -3
- package/dist/client/utils/UaNodeReader.js +58 -29
- package/dist/client/utils/UaObjectTypeDictionary.js +1 -1
- package/dist/common/types/UaLink.d.ts +6 -1
- package/dist/common/types/UaLink.js +9 -1
- package/package.json +1 -1
|
@@ -13,16 +13,17 @@ exports.UaNodeLinkReader = exports.UaNodeChildReader = exports.UaNodeReader = ex
|
|
|
13
13
|
const opcua_webapi_1 = require("opcua-webapi");
|
|
14
14
|
const common_1 = require("../../common");
|
|
15
15
|
class UaNodeReaderBase {
|
|
16
|
-
constructor(returnVariables, returnMethod) {
|
|
16
|
+
constructor(returnDescription, returnVariables, returnMethod) {
|
|
17
17
|
this._finished = false;
|
|
18
18
|
this._nodesToBrowse = [];
|
|
19
19
|
this._continuationPointToBrowse = [];
|
|
20
20
|
this._browseResults = [];
|
|
21
21
|
this._readResults = new Map;
|
|
22
|
+
this._returnDescription = returnDescription;
|
|
22
23
|
this._nodeClassToReturn = 0;
|
|
23
|
-
if (
|
|
24
|
+
if (returnVariables)
|
|
24
25
|
this._nodeClassToReturn += opcua_webapi_1.NodeClass.Variable;
|
|
25
|
-
if (
|
|
26
|
+
if (returnMethod)
|
|
26
27
|
this._nodeClassToReturn += opcua_webapi_1.NodeClass.Method;
|
|
27
28
|
if (null == UaNodeReaderBase.s_variableTypeWithoutMember) {
|
|
28
29
|
UaNodeReaderBase.s_variableTypeWithoutMember = new Set;
|
|
@@ -56,7 +57,7 @@ class UaNodeReaderBase {
|
|
|
56
57
|
for (let item of currentResult.references) {
|
|
57
58
|
let nodeId = item.nodeId.getNodeId();
|
|
58
59
|
let typeDefinition = (_a = item.typeDefinition) === null || _a === void 0 ? void 0 : _a.getNodeId();
|
|
59
|
-
if (null == nodeId || null
|
|
60
|
+
if (null == nodeId || null === typeDefinition)
|
|
60
61
|
continue;
|
|
61
62
|
this._browseResults.push({
|
|
62
63
|
fromNodeId: currentNode.nodeId,
|
|
@@ -193,16 +194,24 @@ class UaNodeReaderBase {
|
|
|
193
194
|
return;
|
|
194
195
|
let nodesToRead = [];
|
|
195
196
|
for (let item of typesToRead) {
|
|
196
|
-
|
|
197
|
-
nodesToRead.push(nodeToRead);
|
|
197
|
+
nodesToRead.push(new common_1.UaReadValueId(item.nodeId, opcua_webapi_1.Attributes.IsAbstract));
|
|
198
198
|
if (item.nodeClass == opcua_webapi_1.NodeClass.VariableType) {
|
|
199
199
|
nodesToRead.push(new common_1.UaReadValueId(item.nodeId, opcua_webapi_1.Attributes.DataType));
|
|
200
200
|
nodesToRead.push(new common_1.UaReadValueId(item.nodeId, opcua_webapi_1.Attributes.ValueRank));
|
|
201
201
|
}
|
|
202
|
+
if (this._returnDescription) {
|
|
203
|
+
nodesToRead.push(new common_1.UaReadValueId(item.nodeId, opcua_webapi_1.Attributes.Description));
|
|
204
|
+
}
|
|
202
205
|
}
|
|
203
206
|
let dataValues = yield client.read(nodesToRead);
|
|
204
207
|
for (let i = 0; i < typesToRead.length; ++i) {
|
|
205
|
-
let dataIndex
|
|
208
|
+
let dataIndex;
|
|
209
|
+
if (this._returnDescription) {
|
|
210
|
+
dataIndex = (typesToRead[i].nodeClass == opcua_webapi_1.NodeClass.VariableType) ? i * 4 : i * 2;
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
dataIndex = (typesToRead[i].nodeClass == opcua_webapi_1.NodeClass.VariableType) ? i * 3 : i;
|
|
214
|
+
}
|
|
206
215
|
if (dataValues[dataIndex].statusCode.isNotGood())
|
|
207
216
|
throw new common_1.UaError(dataValues[dataIndex].statusCode);
|
|
208
217
|
let isAbstract = dataValues[dataIndex].value.toBoolean();
|
|
@@ -233,6 +242,14 @@ class UaNodeReaderBase {
|
|
|
233
242
|
else if (typesToRead[i].nodeClass == opcua_webapi_1.NodeClass.ReferenceType) {
|
|
234
243
|
typeNode = new common_1.UaReferenceType(typesToRead[i].nodeId, typesToRead[i].browseName, typesToRead[i].displayName, isAbstract, common_1.UaLocalizedText.nullText, false);
|
|
235
244
|
}
|
|
245
|
+
if (this._returnDescription) {
|
|
246
|
+
let descriptionIndex = (typesToRead[i].nodeClass == opcua_webapi_1.NodeClass.VariableType) ? dataIndex + 3 : dataIndex + 1;
|
|
247
|
+
if (dataValues[descriptionIndex].statusCode.isGood()) {
|
|
248
|
+
let descriptionValue = dataValues[descriptionIndex].value.toLocalizedText();
|
|
249
|
+
if (null != descriptionValue)
|
|
250
|
+
typeNode.description = descriptionValue;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
236
253
|
typeNode.refToParent = typesToRead[i].referenceTypeId;
|
|
237
254
|
this._readResults.set(typeNode.nodeId.toString(), {
|
|
238
255
|
parentId: typesToRead[i].fromNodeId,
|
|
@@ -253,18 +270,30 @@ class UaNodeReaderBase {
|
|
|
253
270
|
return;
|
|
254
271
|
let nodesToRead = [];
|
|
255
272
|
for (let item of objectsToRead) {
|
|
256
|
-
|
|
257
|
-
|
|
273
|
+
nodesToRead.push(new common_1.UaReadValueId(item.nodeId, opcua_webapi_1.Attributes.EventNotifier));
|
|
274
|
+
if (this._returnDescription) {
|
|
275
|
+
nodesToRead.push(new common_1.UaReadValueId(item.nodeId, opcua_webapi_1.Attributes.Description));
|
|
276
|
+
}
|
|
258
277
|
}
|
|
259
278
|
let dataValues = yield client.read(nodesToRead);
|
|
260
279
|
for (let i = 0; i < objectsToRead.length; ++i) {
|
|
261
|
-
if (
|
|
262
|
-
throw new common_1.UaError(dataValues[i].statusCode);
|
|
263
|
-
let eventNotifier = dataValues[i].value.toNumber();
|
|
264
|
-
if (null == eventNotifier || undefined == objectsToRead[i].typeDefinitionId)
|
|
280
|
+
if (!objectsToRead[i].typeDefinitionId)
|
|
265
281
|
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadNodeAttributesInvalid));
|
|
282
|
+
let dataIndex = (this._returnDescription) ? i * 2 : i;
|
|
283
|
+
let eventNotifier = 0;
|
|
284
|
+
if (dataValues[dataIndex].statusCode.isGood()) {
|
|
285
|
+
eventNotifier = dataValues[dataIndex].value.toNumber();
|
|
286
|
+
}
|
|
266
287
|
let objectNode = new common_1.UaObject(objectsToRead[i].nodeId, objectsToRead[i].browseName, objectsToRead[i].displayName, eventNotifier, objectsToRead[i].typeDefinitionId);
|
|
267
288
|
objectNode.refToParent = objectsToRead[i].referenceTypeId;
|
|
289
|
+
if (this._returnDescription) {
|
|
290
|
+
let descriptionIndex = dataIndex + 1;
|
|
291
|
+
if (dataValues[descriptionIndex].statusCode.isGood()) {
|
|
292
|
+
let descriptionValue = dataValues[descriptionIndex].value.toLocalizedText();
|
|
293
|
+
if (null != descriptionValue)
|
|
294
|
+
objectNode.description = descriptionValue;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
268
297
|
this._readResults.set(objectNode.nodeId.toString(), {
|
|
269
298
|
parentId: objectsToRead[i].fromNodeId,
|
|
270
299
|
node: objectNode
|
|
@@ -348,8 +377,8 @@ exports.UaNodeReaderBase = UaNodeReaderBase;
|
|
|
348
377
|
UaNodeReaderBase.s_variableTypeWithoutMember = null;
|
|
349
378
|
UaNodeReaderBase.s_variableNameToReadValue = null;
|
|
350
379
|
class UaNodeReader extends UaNodeReaderBase {
|
|
351
|
-
constructor(nodeIds, returnVariables, returnMethod) {
|
|
352
|
-
super(returnVariables, returnMethod);
|
|
380
|
+
constructor(nodeIds, returnDescription, returnVariables, returnMethod) {
|
|
381
|
+
super(returnDescription ? returnDescription : false, returnVariables ? returnVariables : false, returnMethod ? returnMethod : false);
|
|
353
382
|
if (nodeIds.length == 0)
|
|
354
383
|
this._finished = true;
|
|
355
384
|
this._nodeIds = new Set;
|
|
@@ -473,8 +502,8 @@ class UaNodeReader extends UaNodeReaderBase {
|
|
|
473
502
|
}
|
|
474
503
|
exports.UaNodeReader = UaNodeReader;
|
|
475
504
|
class UaNodeChildReader extends UaNodeReaderBase {
|
|
476
|
-
constructor(nodeIds, returnVariables, returnMethod) {
|
|
477
|
-
super(returnVariables, returnMethod);
|
|
505
|
+
constructor(nodeIds, returnDescription, returnVariables, returnMethod) {
|
|
506
|
+
super((returnDescription) ? returnDescription : false, (returnVariables) ? returnVariables : false, (returnMethod) ? returnMethod : false);
|
|
478
507
|
if (nodeIds.length == 0)
|
|
479
508
|
this._finished = true;
|
|
480
509
|
this._nodeIds = new Set;
|
|
@@ -575,7 +604,7 @@ class UaNodeLinkReader {
|
|
|
575
604
|
};
|
|
576
605
|
ret.set(item.fromNodeId.toString(), result);
|
|
577
606
|
}
|
|
578
|
-
result.links.push(new common_1.UaLink(item.nodeId, item.nodeClass, item.referenceTypeId, item.isForward));
|
|
607
|
+
result.links.push(new common_1.UaLink(item.nodeId, item.nodeClass, item.browseName, item.displayName, item.referenceTypeId, item.isForward));
|
|
579
608
|
}
|
|
580
609
|
return [...ret.values()];
|
|
581
610
|
}
|
|
@@ -587,7 +616,7 @@ class UaNodeLinkReader {
|
|
|
587
616
|
let nodesToBrowse = this._nodesToBrowse.splice(0, 50);
|
|
588
617
|
let browseDescriptions = [];
|
|
589
618
|
for (let item of nodesToBrowse) {
|
|
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
|
|
619
|
+
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, 63);
|
|
591
620
|
browseDescriptions.push(browseDescription);
|
|
592
621
|
}
|
|
593
622
|
let results = yield client.browse(browseDescriptions, 50);
|
|
@@ -599,15 +628,15 @@ class UaNodeLinkReader {
|
|
|
599
628
|
for (let item of currentResult.references) {
|
|
600
629
|
let nodeId = item.nodeId.getNodeId();
|
|
601
630
|
let typeDefinition = (_a = item.typeDefinition) === null || _a === void 0 ? void 0 : _a.getNodeId();
|
|
602
|
-
if (null == nodeId || null
|
|
631
|
+
if (null == nodeId || null === typeDefinition)
|
|
603
632
|
continue;
|
|
604
633
|
this._browseResults.push({
|
|
605
634
|
fromNodeId: currentNodeId,
|
|
606
635
|
nodeId: nodeId,
|
|
607
|
-
nodeClass: item.nodeClass,
|
|
608
|
-
browseName: item.browseName,
|
|
609
|
-
displayName: item.displayName,
|
|
610
|
-
referenceTypeId: item.referenceTypeId,
|
|
636
|
+
nodeClass: (item.nodeClass) ? item.nodeClass : opcua_webapi_1.NodeClass.Unspecified,
|
|
637
|
+
browseName: (item.browseName) ? item.browseName : "",
|
|
638
|
+
displayName: (item.displayName) ? item.displayName : common_1.UaLocalizedText.nullText,
|
|
639
|
+
referenceTypeId: (item.referenceTypeId) ? item.referenceTypeId : common_1.UaNodeId.nullNodeId,
|
|
611
640
|
isForward: item.isForward,
|
|
612
641
|
typeDefinitionId: typeDefinition
|
|
613
642
|
});
|
|
@@ -638,15 +667,15 @@ class UaNodeLinkReader {
|
|
|
638
667
|
for (let item of currentResult.references) {
|
|
639
668
|
let nodeId = item.nodeId.getNodeId();
|
|
640
669
|
let typeDefinition = (_a = item.typeDefinition) === null || _a === void 0 ? void 0 : _a.getNodeId();
|
|
641
|
-
if (null == nodeId || null
|
|
670
|
+
if (null == nodeId || null === typeDefinition)
|
|
642
671
|
continue;
|
|
643
672
|
this._browseResults.push({
|
|
644
673
|
fromNodeId: currentNodeId,
|
|
645
674
|
nodeId: nodeId,
|
|
646
|
-
nodeClass: item.nodeClass,
|
|
647
|
-
browseName: item.browseName,
|
|
648
|
-
displayName: item.displayName,
|
|
649
|
-
referenceTypeId: item.referenceTypeId,
|
|
675
|
+
nodeClass: (item.nodeClass) ? item.nodeClass : opcua_webapi_1.NodeClass.Unspecified,
|
|
676
|
+
browseName: (item.browseName) ? item.browseName : "",
|
|
677
|
+
displayName: (item.displayName) ? item.displayName : common_1.UaLocalizedText.nullText,
|
|
678
|
+
referenceTypeId: (item.referenceTypeId) ? item.referenceTypeId : common_1.UaNodeId.nullNodeId,
|
|
650
679
|
isForward: item.isForward,
|
|
651
680
|
typeDefinitionId: typeDefinition
|
|
652
681
|
});
|
|
@@ -38,7 +38,7 @@ class UaObjectTypeDictionary {
|
|
|
38
38
|
let nodeIds = this._remainingNodesToBrowse.splice(0, 15);
|
|
39
39
|
let nodesToBrowse = [];
|
|
40
40
|
for (let item of nodeIds) {
|
|
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,
|
|
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, 63);
|
|
42
42
|
nodesToBrowse.push(browseDescription);
|
|
43
43
|
}
|
|
44
44
|
let results = yield client.browse(nodesToBrowse);
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UaLink = void 0;
|
|
4
4
|
class UaLink {
|
|
5
|
-
constructor(targetId, nodeClass, referenceTypeId, isForward) {
|
|
5
|
+
constructor(targetId, nodeClass, browseName, displayName, referenceTypeId, isForward) {
|
|
6
6
|
this._targetId = targetId;
|
|
7
|
+
this._browseName = browseName;
|
|
8
|
+
this._displayName = displayName;
|
|
7
9
|
this._nodeClass = nodeClass;
|
|
8
10
|
this._referenceTypeId = referenceTypeId;
|
|
9
11
|
this._isForward = isForward;
|
|
@@ -11,6 +13,12 @@ class UaLink {
|
|
|
11
13
|
get targetId() {
|
|
12
14
|
return this._targetId;
|
|
13
15
|
}
|
|
16
|
+
get browseName() {
|
|
17
|
+
return this._browseName;
|
|
18
|
+
}
|
|
19
|
+
get displayName() {
|
|
20
|
+
return this._displayName;
|
|
21
|
+
}
|
|
14
22
|
get nodeClass() {
|
|
15
23
|
return this._nodeClass;
|
|
16
24
|
}
|
|
@@ -37,9 +37,10 @@ export declare abstract class UaNodeReaderBase {
|
|
|
37
37
|
protected _browseResults: Array<BrowseResult>;
|
|
38
38
|
protected _readResults: Map<string, ReadResult>;
|
|
39
39
|
protected _nodeClassToReturn: number;
|
|
40
|
+
protected _returnDescription: boolean;
|
|
40
41
|
private static s_variableTypeWithoutMember;
|
|
41
42
|
private static s_variableNameToReadValue;
|
|
42
|
-
constructor(
|
|
43
|
+
constructor(returnDescription: boolean, returnVariables: boolean, returnMethod: boolean);
|
|
43
44
|
protected _browseNodes(client: UaWebClient): Promise<void>;
|
|
44
45
|
protected _browseContinuationPoints(client: UaWebClient): Promise<void>;
|
|
45
46
|
protected _readNodes(client: UaWebClient): Promise<void>;
|
|
@@ -53,7 +54,7 @@ export declare abstract class UaNodeReaderBase {
|
|
|
53
54
|
export declare class UaNodeReader extends UaNodeReaderBase {
|
|
54
55
|
private _nodeIds;
|
|
55
56
|
private _isRootNodeRead;
|
|
56
|
-
constructor(nodeIds: Array<UaNodeId>, returnVariables?: boolean | null, returnMethod?: boolean | null);
|
|
57
|
+
constructor(nodeIds: Array<UaNodeId>, returnDescription?: boolean | null, returnVariables?: boolean | null, returnMethod?: boolean | null);
|
|
57
58
|
readAll(client: UaWebClient): Promise<void>;
|
|
58
59
|
read(client: UaWebClient): Promise<void>;
|
|
59
60
|
isFinish(): boolean;
|
|
@@ -62,7 +63,7 @@ export declare class UaNodeReader extends UaNodeReaderBase {
|
|
|
62
63
|
}
|
|
63
64
|
export declare class UaNodeChildReader extends UaNodeReaderBase {
|
|
64
65
|
private _nodeIds;
|
|
65
|
-
constructor(nodeIds: Array<UaNodeId>, returnVariables?: boolean | null, returnMethod?: boolean | null);
|
|
66
|
+
constructor(nodeIds: Array<UaNodeId>, returnDescription?: boolean | null, returnVariables?: boolean | null, returnMethod?: boolean | null);
|
|
66
67
|
readAll(client: UaWebClient): Promise<void>;
|
|
67
68
|
read(client: UaWebClient): Promise<void>;
|
|
68
69
|
isFinish(): boolean;
|
|
@@ -13,16 +13,17 @@ exports.UaNodeLinkReader = exports.UaNodeChildReader = exports.UaNodeReader = ex
|
|
|
13
13
|
const opcua_webapi_1 = require("opcua-webapi");
|
|
14
14
|
const common_1 = require("../../common");
|
|
15
15
|
class UaNodeReaderBase {
|
|
16
|
-
constructor(returnVariables, returnMethod) {
|
|
16
|
+
constructor(returnDescription, returnVariables, returnMethod) {
|
|
17
17
|
this._finished = false;
|
|
18
18
|
this._nodesToBrowse = [];
|
|
19
19
|
this._continuationPointToBrowse = [];
|
|
20
20
|
this._browseResults = [];
|
|
21
21
|
this._readResults = new Map;
|
|
22
|
+
this._returnDescription = returnDescription;
|
|
22
23
|
this._nodeClassToReturn = 0;
|
|
23
|
-
if (
|
|
24
|
+
if (returnVariables)
|
|
24
25
|
this._nodeClassToReturn += opcua_webapi_1.NodeClass.Variable;
|
|
25
|
-
if (
|
|
26
|
+
if (returnMethod)
|
|
26
27
|
this._nodeClassToReturn += opcua_webapi_1.NodeClass.Method;
|
|
27
28
|
if (null == UaNodeReaderBase.s_variableTypeWithoutMember) {
|
|
28
29
|
UaNodeReaderBase.s_variableTypeWithoutMember = new Set;
|
|
@@ -56,7 +57,7 @@ class UaNodeReaderBase {
|
|
|
56
57
|
for (let item of currentResult.references) {
|
|
57
58
|
let nodeId = item.nodeId.getNodeId();
|
|
58
59
|
let typeDefinition = (_a = item.typeDefinition) === null || _a === void 0 ? void 0 : _a.getNodeId();
|
|
59
|
-
if (null == nodeId || null
|
|
60
|
+
if (null == nodeId || null === typeDefinition)
|
|
60
61
|
continue;
|
|
61
62
|
this._browseResults.push({
|
|
62
63
|
fromNodeId: currentNode.nodeId,
|
|
@@ -193,16 +194,24 @@ class UaNodeReaderBase {
|
|
|
193
194
|
return;
|
|
194
195
|
let nodesToRead = [];
|
|
195
196
|
for (let item of typesToRead) {
|
|
196
|
-
|
|
197
|
-
nodesToRead.push(nodeToRead);
|
|
197
|
+
nodesToRead.push(new common_1.UaReadValueId(item.nodeId, opcua_webapi_1.Attributes.IsAbstract));
|
|
198
198
|
if (item.nodeClass == opcua_webapi_1.NodeClass.VariableType) {
|
|
199
199
|
nodesToRead.push(new common_1.UaReadValueId(item.nodeId, opcua_webapi_1.Attributes.DataType));
|
|
200
200
|
nodesToRead.push(new common_1.UaReadValueId(item.nodeId, opcua_webapi_1.Attributes.ValueRank));
|
|
201
201
|
}
|
|
202
|
+
if (this._returnDescription) {
|
|
203
|
+
nodesToRead.push(new common_1.UaReadValueId(item.nodeId, opcua_webapi_1.Attributes.Description));
|
|
204
|
+
}
|
|
202
205
|
}
|
|
203
206
|
let dataValues = yield client.read(nodesToRead);
|
|
204
207
|
for (let i = 0; i < typesToRead.length; ++i) {
|
|
205
|
-
let dataIndex
|
|
208
|
+
let dataIndex;
|
|
209
|
+
if (this._returnDescription) {
|
|
210
|
+
dataIndex = (typesToRead[i].nodeClass == opcua_webapi_1.NodeClass.VariableType) ? i * 4 : i * 2;
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
dataIndex = (typesToRead[i].nodeClass == opcua_webapi_1.NodeClass.VariableType) ? i * 3 : i;
|
|
214
|
+
}
|
|
206
215
|
if (dataValues[dataIndex].statusCode.isNotGood())
|
|
207
216
|
throw new common_1.UaError(dataValues[dataIndex].statusCode);
|
|
208
217
|
let isAbstract = dataValues[dataIndex].value.toBoolean();
|
|
@@ -233,6 +242,14 @@ class UaNodeReaderBase {
|
|
|
233
242
|
else if (typesToRead[i].nodeClass == opcua_webapi_1.NodeClass.ReferenceType) {
|
|
234
243
|
typeNode = new common_1.UaReferenceType(typesToRead[i].nodeId, typesToRead[i].browseName, typesToRead[i].displayName, isAbstract, common_1.UaLocalizedText.nullText, false);
|
|
235
244
|
}
|
|
245
|
+
if (this._returnDescription) {
|
|
246
|
+
let descriptionIndex = (typesToRead[i].nodeClass == opcua_webapi_1.NodeClass.VariableType) ? dataIndex + 3 : dataIndex + 1;
|
|
247
|
+
if (dataValues[descriptionIndex].statusCode.isGood()) {
|
|
248
|
+
let descriptionValue = dataValues[descriptionIndex].value.toLocalizedText();
|
|
249
|
+
if (null != descriptionValue)
|
|
250
|
+
typeNode.description = descriptionValue;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
236
253
|
typeNode.refToParent = typesToRead[i].referenceTypeId;
|
|
237
254
|
this._readResults.set(typeNode.nodeId.toString(), {
|
|
238
255
|
parentId: typesToRead[i].fromNodeId,
|
|
@@ -253,18 +270,30 @@ class UaNodeReaderBase {
|
|
|
253
270
|
return;
|
|
254
271
|
let nodesToRead = [];
|
|
255
272
|
for (let item of objectsToRead) {
|
|
256
|
-
|
|
257
|
-
|
|
273
|
+
nodesToRead.push(new common_1.UaReadValueId(item.nodeId, opcua_webapi_1.Attributes.EventNotifier));
|
|
274
|
+
if (this._returnDescription) {
|
|
275
|
+
nodesToRead.push(new common_1.UaReadValueId(item.nodeId, opcua_webapi_1.Attributes.Description));
|
|
276
|
+
}
|
|
258
277
|
}
|
|
259
278
|
let dataValues = yield client.read(nodesToRead);
|
|
260
279
|
for (let i = 0; i < objectsToRead.length; ++i) {
|
|
261
|
-
if (
|
|
262
|
-
throw new common_1.UaError(dataValues[i].statusCode);
|
|
263
|
-
let eventNotifier = dataValues[i].value.toNumber();
|
|
264
|
-
if (null == eventNotifier || undefined == objectsToRead[i].typeDefinitionId)
|
|
280
|
+
if (!objectsToRead[i].typeDefinitionId)
|
|
265
281
|
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadNodeAttributesInvalid));
|
|
282
|
+
let dataIndex = (this._returnDescription) ? i * 2 : i;
|
|
283
|
+
let eventNotifier = 0;
|
|
284
|
+
if (dataValues[dataIndex].statusCode.isGood()) {
|
|
285
|
+
eventNotifier = dataValues[dataIndex].value.toNumber();
|
|
286
|
+
}
|
|
266
287
|
let objectNode = new common_1.UaObject(objectsToRead[i].nodeId, objectsToRead[i].browseName, objectsToRead[i].displayName, eventNotifier, objectsToRead[i].typeDefinitionId);
|
|
267
288
|
objectNode.refToParent = objectsToRead[i].referenceTypeId;
|
|
289
|
+
if (this._returnDescription) {
|
|
290
|
+
let descriptionIndex = dataIndex + 1;
|
|
291
|
+
if (dataValues[descriptionIndex].statusCode.isGood()) {
|
|
292
|
+
let descriptionValue = dataValues[descriptionIndex].value.toLocalizedText();
|
|
293
|
+
if (null != descriptionValue)
|
|
294
|
+
objectNode.description = descriptionValue;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
268
297
|
this._readResults.set(objectNode.nodeId.toString(), {
|
|
269
298
|
parentId: objectsToRead[i].fromNodeId,
|
|
270
299
|
node: objectNode
|
|
@@ -348,8 +377,8 @@ exports.UaNodeReaderBase = UaNodeReaderBase;
|
|
|
348
377
|
UaNodeReaderBase.s_variableTypeWithoutMember = null;
|
|
349
378
|
UaNodeReaderBase.s_variableNameToReadValue = null;
|
|
350
379
|
class UaNodeReader extends UaNodeReaderBase {
|
|
351
|
-
constructor(nodeIds, returnVariables, returnMethod) {
|
|
352
|
-
super(returnVariables, returnMethod);
|
|
380
|
+
constructor(nodeIds, returnDescription, returnVariables, returnMethod) {
|
|
381
|
+
super(returnDescription ? returnDescription : false, returnVariables ? returnVariables : false, returnMethod ? returnMethod : false);
|
|
353
382
|
if (nodeIds.length == 0)
|
|
354
383
|
this._finished = true;
|
|
355
384
|
this._nodeIds = new Set;
|
|
@@ -473,8 +502,8 @@ class UaNodeReader extends UaNodeReaderBase {
|
|
|
473
502
|
}
|
|
474
503
|
exports.UaNodeReader = UaNodeReader;
|
|
475
504
|
class UaNodeChildReader extends UaNodeReaderBase {
|
|
476
|
-
constructor(nodeIds, returnVariables, returnMethod) {
|
|
477
|
-
super(returnVariables, returnMethod);
|
|
505
|
+
constructor(nodeIds, returnDescription, returnVariables, returnMethod) {
|
|
506
|
+
super((returnDescription) ? returnDescription : false, (returnVariables) ? returnVariables : false, (returnMethod) ? returnMethod : false);
|
|
478
507
|
if (nodeIds.length == 0)
|
|
479
508
|
this._finished = true;
|
|
480
509
|
this._nodeIds = new Set;
|
|
@@ -575,7 +604,7 @@ class UaNodeLinkReader {
|
|
|
575
604
|
};
|
|
576
605
|
ret.set(item.fromNodeId.toString(), result);
|
|
577
606
|
}
|
|
578
|
-
result.links.push(new common_1.UaLink(item.nodeId, item.nodeClass, item.referenceTypeId, item.isForward));
|
|
607
|
+
result.links.push(new common_1.UaLink(item.nodeId, item.nodeClass, item.browseName, item.displayName, item.referenceTypeId, item.isForward));
|
|
579
608
|
}
|
|
580
609
|
return [...ret.values()];
|
|
581
610
|
}
|
|
@@ -587,7 +616,7 @@ class UaNodeLinkReader {
|
|
|
587
616
|
let nodesToBrowse = this._nodesToBrowse.splice(0, 50);
|
|
588
617
|
let browseDescriptions = [];
|
|
589
618
|
for (let item of nodesToBrowse) {
|
|
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
|
|
619
|
+
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, 63);
|
|
591
620
|
browseDescriptions.push(browseDescription);
|
|
592
621
|
}
|
|
593
622
|
let results = yield client.browse(browseDescriptions, 50);
|
|
@@ -599,15 +628,15 @@ class UaNodeLinkReader {
|
|
|
599
628
|
for (let item of currentResult.references) {
|
|
600
629
|
let nodeId = item.nodeId.getNodeId();
|
|
601
630
|
let typeDefinition = (_a = item.typeDefinition) === null || _a === void 0 ? void 0 : _a.getNodeId();
|
|
602
|
-
if (null == nodeId || null
|
|
631
|
+
if (null == nodeId || null === typeDefinition)
|
|
603
632
|
continue;
|
|
604
633
|
this._browseResults.push({
|
|
605
634
|
fromNodeId: currentNodeId,
|
|
606
635
|
nodeId: nodeId,
|
|
607
|
-
nodeClass: item.nodeClass,
|
|
608
|
-
browseName: item.browseName,
|
|
609
|
-
displayName: item.displayName,
|
|
610
|
-
referenceTypeId: item.referenceTypeId,
|
|
636
|
+
nodeClass: (item.nodeClass) ? item.nodeClass : opcua_webapi_1.NodeClass.Unspecified,
|
|
637
|
+
browseName: (item.browseName) ? item.browseName : "",
|
|
638
|
+
displayName: (item.displayName) ? item.displayName : common_1.UaLocalizedText.nullText,
|
|
639
|
+
referenceTypeId: (item.referenceTypeId) ? item.referenceTypeId : common_1.UaNodeId.nullNodeId,
|
|
611
640
|
isForward: item.isForward,
|
|
612
641
|
typeDefinitionId: typeDefinition
|
|
613
642
|
});
|
|
@@ -638,15 +667,15 @@ class UaNodeLinkReader {
|
|
|
638
667
|
for (let item of currentResult.references) {
|
|
639
668
|
let nodeId = item.nodeId.getNodeId();
|
|
640
669
|
let typeDefinition = (_a = item.typeDefinition) === null || _a === void 0 ? void 0 : _a.getNodeId();
|
|
641
|
-
if (null == nodeId || null
|
|
670
|
+
if (null == nodeId || null === typeDefinition)
|
|
642
671
|
continue;
|
|
643
672
|
this._browseResults.push({
|
|
644
673
|
fromNodeId: currentNodeId,
|
|
645
674
|
nodeId: nodeId,
|
|
646
|
-
nodeClass: item.nodeClass,
|
|
647
|
-
browseName: item.browseName,
|
|
648
|
-
displayName: item.displayName,
|
|
649
|
-
referenceTypeId: item.referenceTypeId,
|
|
675
|
+
nodeClass: (item.nodeClass) ? item.nodeClass : opcua_webapi_1.NodeClass.Unspecified,
|
|
676
|
+
browseName: (item.browseName) ? item.browseName : "",
|
|
677
|
+
displayName: (item.displayName) ? item.displayName : common_1.UaLocalizedText.nullText,
|
|
678
|
+
referenceTypeId: (item.referenceTypeId) ? item.referenceTypeId : common_1.UaNodeId.nullNodeId,
|
|
650
679
|
isForward: item.isForward,
|
|
651
680
|
typeDefinitionId: typeDefinition
|
|
652
681
|
});
|
|
@@ -38,7 +38,7 @@ class UaObjectTypeDictionary {
|
|
|
38
38
|
let nodeIds = this._remainingNodesToBrowse.splice(0, 15);
|
|
39
39
|
let nodesToBrowse = [];
|
|
40
40
|
for (let item of nodeIds) {
|
|
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,
|
|
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, 63);
|
|
42
42
|
nodesToBrowse.push(browseDescription);
|
|
43
43
|
}
|
|
44
44
|
let results = yield client.browse(nodesToBrowse);
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
+
import { UaLocalizedText } from "./UaLocalizedText";
|
|
1
2
|
import { UaNodeId } from "./UaNodeId";
|
|
2
3
|
export declare class UaLink {
|
|
3
4
|
private _targetId;
|
|
4
5
|
private _nodeClass;
|
|
6
|
+
private _browseName;
|
|
7
|
+
private _displayName;
|
|
5
8
|
private _referenceTypeId;
|
|
6
9
|
private _isForward;
|
|
7
|
-
constructor(targetId: UaNodeId, nodeClass: number, referenceTypeId: UaNodeId, isForward: boolean);
|
|
10
|
+
constructor(targetId: UaNodeId, nodeClass: number, browseName: string, displayName: UaLocalizedText, referenceTypeId: UaNodeId, isForward: boolean);
|
|
8
11
|
get targetId(): UaNodeId;
|
|
12
|
+
get browseName(): string;
|
|
13
|
+
get displayName(): UaLocalizedText;
|
|
9
14
|
get nodeClass(): number;
|
|
10
15
|
get referenceTypeId(): UaNodeId;
|
|
11
16
|
get isForward(): boolean;
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UaLink = void 0;
|
|
4
4
|
class UaLink {
|
|
5
|
-
constructor(targetId, nodeClass, referenceTypeId, isForward) {
|
|
5
|
+
constructor(targetId, nodeClass, browseName, displayName, referenceTypeId, isForward) {
|
|
6
6
|
this._targetId = targetId;
|
|
7
|
+
this._browseName = browseName;
|
|
8
|
+
this._displayName = displayName;
|
|
7
9
|
this._nodeClass = nodeClass;
|
|
8
10
|
this._referenceTypeId = referenceTypeId;
|
|
9
11
|
this._isForward = isForward;
|
|
@@ -11,6 +13,12 @@ class UaLink {
|
|
|
11
13
|
get targetId() {
|
|
12
14
|
return this._targetId;
|
|
13
15
|
}
|
|
16
|
+
get browseName() {
|
|
17
|
+
return this._browseName;
|
|
18
|
+
}
|
|
19
|
+
get displayName() {
|
|
20
|
+
return this._displayName;
|
|
21
|
+
}
|
|
14
22
|
get nodeClass() {
|
|
15
23
|
return this._nodeClass;
|
|
16
24
|
}
|