opcua-webapi-ts 1.1.3 → 1.1.4
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 +52 -15
- package/dist/cjs/common/nodes/UaNode.js +4 -2
- package/dist/cjs/common/types/UaLink.js +18 -0
- package/dist/client/utils/UaNodeReader.d.ts +5 -1
- package/dist/client/utils/UaNodeReader.js +52 -15
- package/dist/common/nodes/UaNode.d.ts +4 -4
- package/dist/common/nodes/UaNode.js +4 -2
- package/dist/common/types/UaLink.d.ts +4 -0
- package/dist/common/types/UaLink.js +18 -0
- package/package.json +1 -1
|
@@ -565,10 +565,12 @@ class UaNodeChildReader extends UaNodeReaderBase {
|
|
|
565
565
|
}
|
|
566
566
|
exports.UaNodeChildReader = UaNodeChildReader;
|
|
567
567
|
class UaNodeLinkReader {
|
|
568
|
-
constructor(nodeIds) {
|
|
568
|
+
constructor(nodeIds, returnDescription) {
|
|
569
569
|
this._nodesToBrowse = nodeIds;
|
|
570
570
|
this._continuationPointToBrowse = [];
|
|
571
571
|
this._browseResults = [];
|
|
572
|
+
this._returnDescription = (returnDescription) ? returnDescription : false;
|
|
573
|
+
this._readResults = null;
|
|
572
574
|
}
|
|
573
575
|
readAll(client) {
|
|
574
576
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -588,25 +590,17 @@ class UaNodeLinkReader {
|
|
|
588
590
|
else if (this._continuationPointToBrowse.length != 0) {
|
|
589
591
|
yield this._browseContinuationPoints(client);
|
|
590
592
|
}
|
|
593
|
+
else {
|
|
594
|
+
this._buildResults();
|
|
595
|
+
yield this._readDescriptions(client);
|
|
596
|
+
}
|
|
591
597
|
});
|
|
592
598
|
}
|
|
593
599
|
isFinish() {
|
|
594
|
-
return
|
|
600
|
+
return null != this._readResults;
|
|
595
601
|
}
|
|
596
602
|
getResults() {
|
|
597
|
-
|
|
598
|
-
for (let item of this._browseResults) {
|
|
599
|
-
let result = ret.get(item.fromNodeId.toString());
|
|
600
|
-
if (!result) {
|
|
601
|
-
result = {
|
|
602
|
-
nodeId: item.fromNodeId,
|
|
603
|
-
links: []
|
|
604
|
-
};
|
|
605
|
-
ret.set(item.fromNodeId.toString(), result);
|
|
606
|
-
}
|
|
607
|
-
result.links.push(new common_1.UaLink(item.nodeId, item.nodeClass, item.browseName, item.displayName, item.referenceTypeId, item.isForward));
|
|
608
|
-
}
|
|
609
|
-
return [...ret.values()];
|
|
603
|
+
return (this._readResults) ? this._readResults : [];
|
|
610
604
|
}
|
|
611
605
|
_browseNodes(client) {
|
|
612
606
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -689,5 +683,48 @@ class UaNodeLinkReader {
|
|
|
689
683
|
}
|
|
690
684
|
});
|
|
691
685
|
}
|
|
686
|
+
_buildResults() {
|
|
687
|
+
if (this._readResults != null)
|
|
688
|
+
return;
|
|
689
|
+
this._readResults = [];
|
|
690
|
+
let ret = new Map;
|
|
691
|
+
for (let item of this._browseResults) {
|
|
692
|
+
let result = ret.get(item.fromNodeId.toString());
|
|
693
|
+
if (!result) {
|
|
694
|
+
result = {
|
|
695
|
+
nodeId: item.fromNodeId,
|
|
696
|
+
links: []
|
|
697
|
+
};
|
|
698
|
+
ret.set(item.fromNodeId.toString(), result);
|
|
699
|
+
}
|
|
700
|
+
result.links.push(new common_1.UaLink(item.nodeId, item.nodeClass, item.browseName, item.displayName, item.referenceTypeId, item.isForward));
|
|
701
|
+
}
|
|
702
|
+
this._readResults = Array.from(ret.values());
|
|
703
|
+
}
|
|
704
|
+
_readDescriptions(client) {
|
|
705
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
706
|
+
if (!this._returnDescription)
|
|
707
|
+
return;
|
|
708
|
+
let linkedNodesToRead = [];
|
|
709
|
+
for (let item of this._readResults) {
|
|
710
|
+
for (let link of item.links) {
|
|
711
|
+
if (link.nodeClass == opcua_webapi_1.NodeClass.Object)
|
|
712
|
+
linkedNodesToRead.push(link);
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
if (linkedNodesToRead.length == 0)
|
|
716
|
+
return;
|
|
717
|
+
let nodesToRead = [];
|
|
718
|
+
for (let item of linkedNodesToRead) {
|
|
719
|
+
nodesToRead.push(new common_1.UaReadValueId(item.targetId, opcua_webapi_1.Attributes.Description));
|
|
720
|
+
}
|
|
721
|
+
let dataValues = yield client.read(nodesToRead);
|
|
722
|
+
for (let i = 0; i < linkedNodesToRead.length; ++i) {
|
|
723
|
+
if (dataValues[i].statusCode.isGood()) {
|
|
724
|
+
linkedNodesToRead[i].description = dataValues[i].value.toLocalizedText();
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
});
|
|
728
|
+
}
|
|
692
729
|
}
|
|
693
730
|
exports.UaNodeLinkReader = UaNodeLinkReader;
|
|
@@ -6,9 +6,11 @@ class UaNode {
|
|
|
6
6
|
this._nodeId = nodeId;
|
|
7
7
|
this._browseName = browseName;
|
|
8
8
|
this._displayName = displayName;
|
|
9
|
+
this._description = null;
|
|
9
10
|
this._writeMask = (writeMask) ? writeMask : 0;
|
|
10
11
|
this._parent = null;
|
|
11
12
|
this._children = [];
|
|
13
|
+
this._refToParent = null;
|
|
12
14
|
}
|
|
13
15
|
get nodeId() {
|
|
14
16
|
return this._nodeId;
|
|
@@ -23,13 +25,13 @@ class UaNode {
|
|
|
23
25
|
return this._writeMask;
|
|
24
26
|
}
|
|
25
27
|
get description() {
|
|
26
|
-
return
|
|
28
|
+
return this._description;
|
|
27
29
|
}
|
|
28
30
|
set description(description) {
|
|
29
31
|
this._description = description;
|
|
30
32
|
}
|
|
31
33
|
get refToParent() {
|
|
32
|
-
return
|
|
34
|
+
return this._refToParent;
|
|
33
35
|
}
|
|
34
36
|
set refToParent(referenceTypeId) {
|
|
35
37
|
this._refToParent = referenceTypeId;
|
|
@@ -6,6 +6,7 @@ class UaLink {
|
|
|
6
6
|
this._targetId = targetId;
|
|
7
7
|
this._browseName = browseName;
|
|
8
8
|
this._displayName = displayName;
|
|
9
|
+
this._description = null;
|
|
9
10
|
this._nodeClass = nodeClass;
|
|
10
11
|
this._referenceTypeId = referenceTypeId;
|
|
11
12
|
this._isForward = isForward;
|
|
@@ -19,6 +20,12 @@ class UaLink {
|
|
|
19
20
|
get displayName() {
|
|
20
21
|
return this._displayName;
|
|
21
22
|
}
|
|
23
|
+
get description() {
|
|
24
|
+
return this._description;
|
|
25
|
+
}
|
|
26
|
+
set description(description) {
|
|
27
|
+
this._description = description;
|
|
28
|
+
}
|
|
22
29
|
get nodeClass() {
|
|
23
30
|
return this._nodeClass;
|
|
24
31
|
}
|
|
@@ -28,5 +35,16 @@ class UaLink {
|
|
|
28
35
|
get isForward() {
|
|
29
36
|
return this._isForward;
|
|
30
37
|
}
|
|
38
|
+
toJson() {
|
|
39
|
+
return {
|
|
40
|
+
targetId: this._targetId.toString(),
|
|
41
|
+
nodeClass: this._nodeClass,
|
|
42
|
+
reference: this._referenceTypeId.toString(),
|
|
43
|
+
isForward: this._isForward,
|
|
44
|
+
browseName: this._browseName,
|
|
45
|
+
displayName: this._displayName.text,
|
|
46
|
+
description: (this._description) ? this._description.text : undefined,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
31
49
|
}
|
|
32
50
|
exports.UaLink = UaLink;
|
|
@@ -73,12 +73,16 @@ export declare class UaNodeLinkReader {
|
|
|
73
73
|
private _nodesToBrowse;
|
|
74
74
|
private _continuationPointToBrowse;
|
|
75
75
|
private _browseResults;
|
|
76
|
-
|
|
76
|
+
private _returnDescription;
|
|
77
|
+
private _readResults;
|
|
78
|
+
constructor(nodeIds: Array<UaNodeId>, returnDescription?: boolean | null);
|
|
77
79
|
readAll(client: UaWebClient): Promise<void>;
|
|
78
80
|
read(client: UaWebClient): Promise<void>;
|
|
79
81
|
isFinish(): boolean;
|
|
80
82
|
getResults(): Array<ReadLinkResult>;
|
|
81
83
|
private _browseNodes;
|
|
82
84
|
private _browseContinuationPoints;
|
|
85
|
+
private _buildResults;
|
|
86
|
+
private _readDescriptions;
|
|
83
87
|
}
|
|
84
88
|
export {};
|
|
@@ -565,10 +565,12 @@ class UaNodeChildReader extends UaNodeReaderBase {
|
|
|
565
565
|
}
|
|
566
566
|
exports.UaNodeChildReader = UaNodeChildReader;
|
|
567
567
|
class UaNodeLinkReader {
|
|
568
|
-
constructor(nodeIds) {
|
|
568
|
+
constructor(nodeIds, returnDescription) {
|
|
569
569
|
this._nodesToBrowse = nodeIds;
|
|
570
570
|
this._continuationPointToBrowse = [];
|
|
571
571
|
this._browseResults = [];
|
|
572
|
+
this._returnDescription = (returnDescription) ? returnDescription : false;
|
|
573
|
+
this._readResults = null;
|
|
572
574
|
}
|
|
573
575
|
readAll(client) {
|
|
574
576
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -588,25 +590,17 @@ class UaNodeLinkReader {
|
|
|
588
590
|
else if (this._continuationPointToBrowse.length != 0) {
|
|
589
591
|
yield this._browseContinuationPoints(client);
|
|
590
592
|
}
|
|
593
|
+
else {
|
|
594
|
+
this._buildResults();
|
|
595
|
+
yield this._readDescriptions(client);
|
|
596
|
+
}
|
|
591
597
|
});
|
|
592
598
|
}
|
|
593
599
|
isFinish() {
|
|
594
|
-
return
|
|
600
|
+
return null != this._readResults;
|
|
595
601
|
}
|
|
596
602
|
getResults() {
|
|
597
|
-
|
|
598
|
-
for (let item of this._browseResults) {
|
|
599
|
-
let result = ret.get(item.fromNodeId.toString());
|
|
600
|
-
if (!result) {
|
|
601
|
-
result = {
|
|
602
|
-
nodeId: item.fromNodeId,
|
|
603
|
-
links: []
|
|
604
|
-
};
|
|
605
|
-
ret.set(item.fromNodeId.toString(), result);
|
|
606
|
-
}
|
|
607
|
-
result.links.push(new common_1.UaLink(item.nodeId, item.nodeClass, item.browseName, item.displayName, item.referenceTypeId, item.isForward));
|
|
608
|
-
}
|
|
609
|
-
return [...ret.values()];
|
|
603
|
+
return (this._readResults) ? this._readResults : [];
|
|
610
604
|
}
|
|
611
605
|
_browseNodes(client) {
|
|
612
606
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -689,5 +683,48 @@ class UaNodeLinkReader {
|
|
|
689
683
|
}
|
|
690
684
|
});
|
|
691
685
|
}
|
|
686
|
+
_buildResults() {
|
|
687
|
+
if (this._readResults != null)
|
|
688
|
+
return;
|
|
689
|
+
this._readResults = [];
|
|
690
|
+
let ret = new Map;
|
|
691
|
+
for (let item of this._browseResults) {
|
|
692
|
+
let result = ret.get(item.fromNodeId.toString());
|
|
693
|
+
if (!result) {
|
|
694
|
+
result = {
|
|
695
|
+
nodeId: item.fromNodeId,
|
|
696
|
+
links: []
|
|
697
|
+
};
|
|
698
|
+
ret.set(item.fromNodeId.toString(), result);
|
|
699
|
+
}
|
|
700
|
+
result.links.push(new common_1.UaLink(item.nodeId, item.nodeClass, item.browseName, item.displayName, item.referenceTypeId, item.isForward));
|
|
701
|
+
}
|
|
702
|
+
this._readResults = Array.from(ret.values());
|
|
703
|
+
}
|
|
704
|
+
_readDescriptions(client) {
|
|
705
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
706
|
+
if (!this._returnDescription)
|
|
707
|
+
return;
|
|
708
|
+
let linkedNodesToRead = [];
|
|
709
|
+
for (let item of this._readResults) {
|
|
710
|
+
for (let link of item.links) {
|
|
711
|
+
if (link.nodeClass == opcua_webapi_1.NodeClass.Object)
|
|
712
|
+
linkedNodesToRead.push(link);
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
if (linkedNodesToRead.length == 0)
|
|
716
|
+
return;
|
|
717
|
+
let nodesToRead = [];
|
|
718
|
+
for (let item of linkedNodesToRead) {
|
|
719
|
+
nodesToRead.push(new common_1.UaReadValueId(item.targetId, opcua_webapi_1.Attributes.Description));
|
|
720
|
+
}
|
|
721
|
+
let dataValues = yield client.read(nodesToRead);
|
|
722
|
+
for (let i = 0; i < linkedNodesToRead.length; ++i) {
|
|
723
|
+
if (dataValues[i].statusCode.isGood()) {
|
|
724
|
+
linkedNodesToRead[i].description = dataValues[i].value.toLocalizedText();
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
});
|
|
728
|
+
}
|
|
692
729
|
}
|
|
693
730
|
exports.UaNodeLinkReader = UaNodeLinkReader;
|
|
@@ -4,11 +4,11 @@ export declare abstract class UaNode {
|
|
|
4
4
|
protected _nodeId: UaNodeId;
|
|
5
5
|
protected _browseName: string;
|
|
6
6
|
protected _displayName: UaLocalizedText;
|
|
7
|
-
protected _description: UaLocalizedText |
|
|
7
|
+
protected _description: UaLocalizedText | null;
|
|
8
8
|
protected _writeMask: number;
|
|
9
9
|
protected _parent: UaNode | null;
|
|
10
10
|
protected _children: Array<UaNode>;
|
|
11
|
-
protected _refToParent: UaNodeId |
|
|
11
|
+
protected _refToParent: UaNodeId | null;
|
|
12
12
|
constructor(nodeId: UaNodeId, browseName: string, displayName: UaLocalizedText, writeMask?: number | null);
|
|
13
13
|
abstract get nodeClass(): NodeClass;
|
|
14
14
|
get nodeId(): UaNodeId;
|
|
@@ -16,9 +16,9 @@ export declare abstract class UaNode {
|
|
|
16
16
|
get displayName(): UaLocalizedText;
|
|
17
17
|
get writeMask(): number;
|
|
18
18
|
get description(): UaLocalizedText | null;
|
|
19
|
-
set description(description: UaLocalizedText);
|
|
19
|
+
set description(description: UaLocalizedText | null);
|
|
20
20
|
get refToParent(): UaNodeId | null;
|
|
21
|
-
set refToParent(referenceTypeId: UaNodeId);
|
|
21
|
+
set refToParent(referenceTypeId: UaNodeId | null);
|
|
22
22
|
abstract toJson(): any;
|
|
23
23
|
}
|
|
24
24
|
export declare abstract class UaDefintionNode extends UaNode {
|
|
@@ -6,9 +6,11 @@ class UaNode {
|
|
|
6
6
|
this._nodeId = nodeId;
|
|
7
7
|
this._browseName = browseName;
|
|
8
8
|
this._displayName = displayName;
|
|
9
|
+
this._description = null;
|
|
9
10
|
this._writeMask = (writeMask) ? writeMask : 0;
|
|
10
11
|
this._parent = null;
|
|
11
12
|
this._children = [];
|
|
13
|
+
this._refToParent = null;
|
|
12
14
|
}
|
|
13
15
|
get nodeId() {
|
|
14
16
|
return this._nodeId;
|
|
@@ -23,13 +25,13 @@ class UaNode {
|
|
|
23
25
|
return this._writeMask;
|
|
24
26
|
}
|
|
25
27
|
get description() {
|
|
26
|
-
return
|
|
28
|
+
return this._description;
|
|
27
29
|
}
|
|
28
30
|
set description(description) {
|
|
29
31
|
this._description = description;
|
|
30
32
|
}
|
|
31
33
|
get refToParent() {
|
|
32
|
-
return
|
|
34
|
+
return this._refToParent;
|
|
33
35
|
}
|
|
34
36
|
set refToParent(referenceTypeId) {
|
|
35
37
|
this._refToParent = referenceTypeId;
|
|
@@ -5,13 +5,17 @@ export declare class UaLink {
|
|
|
5
5
|
private _nodeClass;
|
|
6
6
|
private _browseName;
|
|
7
7
|
private _displayName;
|
|
8
|
+
private _description;
|
|
8
9
|
private _referenceTypeId;
|
|
9
10
|
private _isForward;
|
|
10
11
|
constructor(targetId: UaNodeId, nodeClass: number, browseName: string, displayName: UaLocalizedText, referenceTypeId: UaNodeId, isForward: boolean);
|
|
11
12
|
get targetId(): UaNodeId;
|
|
12
13
|
get browseName(): string;
|
|
13
14
|
get displayName(): UaLocalizedText;
|
|
15
|
+
get description(): UaLocalizedText | null;
|
|
16
|
+
set description(description: UaLocalizedText | null);
|
|
14
17
|
get nodeClass(): number;
|
|
15
18
|
get referenceTypeId(): UaNodeId;
|
|
16
19
|
get isForward(): boolean;
|
|
20
|
+
toJson(): any;
|
|
17
21
|
}
|
|
@@ -6,6 +6,7 @@ class UaLink {
|
|
|
6
6
|
this._targetId = targetId;
|
|
7
7
|
this._browseName = browseName;
|
|
8
8
|
this._displayName = displayName;
|
|
9
|
+
this._description = null;
|
|
9
10
|
this._nodeClass = nodeClass;
|
|
10
11
|
this._referenceTypeId = referenceTypeId;
|
|
11
12
|
this._isForward = isForward;
|
|
@@ -19,6 +20,12 @@ class UaLink {
|
|
|
19
20
|
get displayName() {
|
|
20
21
|
return this._displayName;
|
|
21
22
|
}
|
|
23
|
+
get description() {
|
|
24
|
+
return this._description;
|
|
25
|
+
}
|
|
26
|
+
set description(description) {
|
|
27
|
+
this._description = description;
|
|
28
|
+
}
|
|
22
29
|
get nodeClass() {
|
|
23
30
|
return this._nodeClass;
|
|
24
31
|
}
|
|
@@ -28,5 +35,16 @@ class UaLink {
|
|
|
28
35
|
get isForward() {
|
|
29
36
|
return this._isForward;
|
|
30
37
|
}
|
|
38
|
+
toJson() {
|
|
39
|
+
return {
|
|
40
|
+
targetId: this._targetId.toString(),
|
|
41
|
+
nodeClass: this._nodeClass,
|
|
42
|
+
reference: this._referenceTypeId.toString(),
|
|
43
|
+
isForward: this._isForward,
|
|
44
|
+
browseName: this._browseName,
|
|
45
|
+
displayName: this._displayName.text,
|
|
46
|
+
description: (this._description) ? this._description.text : undefined,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
31
49
|
}
|
|
32
50
|
exports.UaLink = UaLink;
|