opcua-webapi-ts 1.1.3 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/client/UaWebClient.js +24 -2
- package/dist/cjs/client/utils/UaNodeReader.js +52 -15
- package/dist/cjs/common/nodes/UaNode.js +4 -2
- package/dist/cjs/common/structure/UaReadProcessedDetails.js +70 -0
- package/dist/cjs/common/structure/index.js +2 -1
- package/dist/cjs/common/types/UaLink.js +18 -0
- package/dist/client/UaWebClient.d.ts +1 -0
- package/dist/client/UaWebClient.js +24 -2
- 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/structure/UaReadProcessedDetails.d.ts +18 -0
- package/dist/common/structure/UaReadProcessedDetails.js +70 -0
- package/dist/common/structure/index.d.ts +2 -1
- package/dist/common/structure/index.js +2 -1
- package/dist/common/types/UaLink.d.ts +4 -0
- package/dist/common/types/UaLink.js +18 -0
- package/package.json +1 -1
|
@@ -288,7 +288,7 @@ class UaWebClient {
|
|
|
288
288
|
let details = new common_2.UaReadRawModifiedDetails(startTime, endTime, (numValuesPerNode) ? numValuesPerNode : 0, (returnBounds) ? returnBounds : false, (isReadModified) ? isReadModified : false);
|
|
289
289
|
let historyReadDetails = details.toExtensionObject();
|
|
290
290
|
let nodesToRead = [nodeToRead];
|
|
291
|
-
let results = yield this.historyRead(nodesToRead, historyReadDetails, (timestampsToReturn) ? timestampsToReturn : opcua_webapi_1.TimestampsToReturn.
|
|
291
|
+
let results = yield this.historyRead(nodesToRead, historyReadDetails, (timestampsToReturn) ? timestampsToReturn : opcua_webapi_1.TimestampsToReturn.Both, (releaseContinuationPoints) ? releaseContinuationPoints : false);
|
|
292
292
|
if (results[0].statusCode.isNotGood())
|
|
293
293
|
throw new common_1.UaError(results[0].statusCode);
|
|
294
294
|
let extensionObject = results[0].historyData;
|
|
@@ -309,7 +309,29 @@ class UaWebClient {
|
|
|
309
309
|
let details = new common_2.UaReadAtTimeDetails(requiredTimes, useSimpleBounds);
|
|
310
310
|
let historyReadDetails = details.toExtensionObject();
|
|
311
311
|
let nodesToRead = [nodeToRead];
|
|
312
|
-
let results = yield this.historyRead(nodesToRead, historyReadDetails, (timestampsToReturn) ? timestampsToReturn : opcua_webapi_1.TimestampsToReturn.
|
|
312
|
+
let results = yield this.historyRead(nodesToRead, historyReadDetails, (timestampsToReturn) ? timestampsToReturn : opcua_webapi_1.TimestampsToReturn.Both, (releaseContinuationPoints) ? releaseContinuationPoints : false);
|
|
313
|
+
if (results[0].statusCode.isNotGood())
|
|
314
|
+
throw new common_1.UaError(results[0].statusCode);
|
|
315
|
+
let extensionObject = results[0].historyData;
|
|
316
|
+
if (!extensionObject)
|
|
317
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadDecodingError));
|
|
318
|
+
let historyData = common_1.UaHistoryData.fromExtensionObject(extensionObject);
|
|
319
|
+
if (null == historyData)
|
|
320
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadDecodingError));
|
|
321
|
+
let ret = new common_1.UaHistoryDataResult(historyData.dataValues, results[0].continuationPoint);
|
|
322
|
+
return ret;
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
historyReadProcessed(nodeId, startTime, endTime, processingInterval, aggregateType, continuationPoint, timestampsToReturn, releaseContinuationPoints) {
|
|
326
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
327
|
+
let nodeToRead = new common_1.UaHistoryReadValueId(nodeId, continuationPoint);
|
|
328
|
+
let aggregateTypeId = (aggregateType) ?
|
|
329
|
+
aggregateType :
|
|
330
|
+
common_1.UaNodeId.from(common_1.ObjectIds.AggregateFunction_Interpolative);
|
|
331
|
+
let details = new common_1.UaReadProcessedDetails(startTime, endTime, processingInterval, [aggregateTypeId]);
|
|
332
|
+
let historyReadDetails = details.toExtensionObject();
|
|
333
|
+
let nodesToRead = [nodeToRead];
|
|
334
|
+
let results = yield this.historyRead(nodesToRead, historyReadDetails, (timestampsToReturn) ? timestampsToReturn : opcua_webapi_1.TimestampsToReturn.Both, (releaseContinuationPoints) ? releaseContinuationPoints : false);
|
|
313
335
|
if (results[0].statusCode.isNotGood())
|
|
314
336
|
throw new common_1.UaError(results[0].statusCode);
|
|
315
337
|
let extensionObject = results[0].historyData;
|
|
@@ -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;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UaReadProcessedDetails = void 0;
|
|
4
|
+
const opcua_webapi_1 = require("opcua-webapi");
|
|
5
|
+
const nodes_1 = require("../nodes");
|
|
6
|
+
const types_1 = require("../types");
|
|
7
|
+
class UaReadProcessedDetails {
|
|
8
|
+
constructor(startTime, endTime, processingInterval, aggregateType) {
|
|
9
|
+
this._startTime = startTime;
|
|
10
|
+
this._endTime = endTime;
|
|
11
|
+
this._processingInterval = processingInterval;
|
|
12
|
+
this._aggregateType = (aggregateType) ? aggregateType : null;
|
|
13
|
+
}
|
|
14
|
+
get startTime() {
|
|
15
|
+
return this._startTime;
|
|
16
|
+
}
|
|
17
|
+
get endTime() {
|
|
18
|
+
return this._endTime;
|
|
19
|
+
}
|
|
20
|
+
get processingInterval() {
|
|
21
|
+
return this._processingInterval;
|
|
22
|
+
}
|
|
23
|
+
get aggregateType() {
|
|
24
|
+
return this._aggregateType;
|
|
25
|
+
}
|
|
26
|
+
toStruct() {
|
|
27
|
+
let aggregateType = [];
|
|
28
|
+
if (this._aggregateType) {
|
|
29
|
+
for (let item of this._aggregateType) {
|
|
30
|
+
aggregateType.push(item.toString());
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
let details = {
|
|
34
|
+
StartTime: this.startTime,
|
|
35
|
+
EndTime: this.endTime,
|
|
36
|
+
ProcessingInterval: this.processingInterval,
|
|
37
|
+
AggregateType: aggregateType
|
|
38
|
+
};
|
|
39
|
+
return details;
|
|
40
|
+
}
|
|
41
|
+
static fromStruct(details) {
|
|
42
|
+
let startTime = details.StartTime;
|
|
43
|
+
let endTime = details.EndTime;
|
|
44
|
+
let processingInterval = details.ProcessingInterval;
|
|
45
|
+
let aggregateType = null;
|
|
46
|
+
if (details.AggregateType && details.AggregateType.length > 0) {
|
|
47
|
+
aggregateType = [];
|
|
48
|
+
for (let item of details.AggregateType) {
|
|
49
|
+
let aggregateTypeId = (0, types_1.parseUaNodeIdOrNull)(item);
|
|
50
|
+
if (null == aggregateTypeId)
|
|
51
|
+
continue;
|
|
52
|
+
aggregateType.push(aggregateTypeId);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (null == startTime || null == endTime || null == processingInterval)
|
|
56
|
+
return null;
|
|
57
|
+
return new UaReadProcessedDetails(startTime, endTime, processingInterval, aggregateType);
|
|
58
|
+
}
|
|
59
|
+
toExtensionObject() {
|
|
60
|
+
return new types_1.UaExtensionObject(UaReadProcessedDetails.dataTypeId, (0, opcua_webapi_1.ReadProcessedDetailsToJSONTyped)(this.toStruct()));
|
|
61
|
+
}
|
|
62
|
+
static fromExtensionObject(extensionObject) {
|
|
63
|
+
if (!UaReadProcessedDetails.dataTypeId.equal(extensionObject.typeId))
|
|
64
|
+
return null;
|
|
65
|
+
let details = (0, opcua_webapi_1.ReadProcessedDetailsFromJSON)(extensionObject.body);
|
|
66
|
+
return UaReadProcessedDetails.fromStruct(details);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.UaReadProcessedDetails = UaReadProcessedDetails;
|
|
70
|
+
UaReadProcessedDetails.dataTypeId = new types_1.UaNodeId(nodes_1.DataTypeIds.ReadProcessedDetails);
|
|
@@ -26,6 +26,7 @@ __exportStar(require("./UaHistoryEvent"), exports);
|
|
|
26
26
|
__exportStar(require("./UaLiteralOperand"), exports);
|
|
27
27
|
__exportStar(require("./UaRange"), exports);
|
|
28
28
|
__exportStar(require("./UaReadAtTimeDetails"), exports);
|
|
29
|
-
__exportStar(require("./UaReadEventDetails"), exports);
|
|
30
29
|
__exportStar(require("./UaReadRawModifiedDetails"), exports);
|
|
30
|
+
__exportStar(require("./UaReadProcessedDetails"), exports);
|
|
31
|
+
__exportStar(require("./UaReadEventDetails"), exports);
|
|
31
32
|
__exportStar(require("./UaSimpleAttributeOperand"), exports);
|
|
@@ -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;
|
|
@@ -22,6 +22,7 @@ export declare class UaWebClient {
|
|
|
22
22
|
getGeneratedEventType(typeId: UaNodeId): Promise<Array<UaNodeId>>;
|
|
23
23
|
historyReadRawData(nodeId: UaNodeId, startTime: Date, endTime: Date, numValuesPerNode?: number | null, continuationPoint?: string | null, returnBounds?: boolean | null, isReadModified?: boolean | null, timestampsToReturn?: number | null, releaseContinuationPoints?: boolean | null): Promise<UaHistoryDataResult>;
|
|
24
24
|
historyReadAtTime(nodeId: UaNodeId, requiredTimes: Array<Date>, useSimpleBounds?: boolean | null, continuationPoint?: string | null, timestampsToReturn?: number | null, releaseContinuationPoints?: boolean | null): Promise<UaHistoryDataResult>;
|
|
25
|
+
historyReadProcessed(nodeId: UaNodeId, startTime: Date, endTime: Date, processingInterval: number, aggregateType?: UaNodeId | null, continuationPoint?: string | null, timestampsToReturn?: number | null, releaseContinuationPoints?: boolean | null): Promise<UaHistoryDataResult>;
|
|
25
26
|
historyReadEvent(nodeId: UaNodeId, startTime: Date, endTime: Date, select: Array<string>, where?: UaQuery | null, numValuesPerNode?: number | null, continuationPoint?: string | null, releaseContinuationPoints?: boolean | null): Promise<UaHistoryEventResult>;
|
|
26
27
|
browse(nodesToBrowse: Array<UaBrowseDescription>, maxReferencesPerNode?: number, view?: ViewDescription, additionalParameters?: UaClientParameters): Promise<Array<UaBrowseResult>>;
|
|
27
28
|
browseNext(continuationPoints: Array<string>, releaseContinuationPoints: boolean, additionalParameters?: UaClientParameters): Promise<Array<UaBrowseResult>>;
|
|
@@ -288,7 +288,7 @@ class UaWebClient {
|
|
|
288
288
|
let details = new common_2.UaReadRawModifiedDetails(startTime, endTime, (numValuesPerNode) ? numValuesPerNode : 0, (returnBounds) ? returnBounds : false, (isReadModified) ? isReadModified : false);
|
|
289
289
|
let historyReadDetails = details.toExtensionObject();
|
|
290
290
|
let nodesToRead = [nodeToRead];
|
|
291
|
-
let results = yield this.historyRead(nodesToRead, historyReadDetails, (timestampsToReturn) ? timestampsToReturn : opcua_webapi_1.TimestampsToReturn.
|
|
291
|
+
let results = yield this.historyRead(nodesToRead, historyReadDetails, (timestampsToReturn) ? timestampsToReturn : opcua_webapi_1.TimestampsToReturn.Both, (releaseContinuationPoints) ? releaseContinuationPoints : false);
|
|
292
292
|
if (results[0].statusCode.isNotGood())
|
|
293
293
|
throw new common_1.UaError(results[0].statusCode);
|
|
294
294
|
let extensionObject = results[0].historyData;
|
|
@@ -309,7 +309,29 @@ class UaWebClient {
|
|
|
309
309
|
let details = new common_2.UaReadAtTimeDetails(requiredTimes, useSimpleBounds);
|
|
310
310
|
let historyReadDetails = details.toExtensionObject();
|
|
311
311
|
let nodesToRead = [nodeToRead];
|
|
312
|
-
let results = yield this.historyRead(nodesToRead, historyReadDetails, (timestampsToReturn) ? timestampsToReturn : opcua_webapi_1.TimestampsToReturn.
|
|
312
|
+
let results = yield this.historyRead(nodesToRead, historyReadDetails, (timestampsToReturn) ? timestampsToReturn : opcua_webapi_1.TimestampsToReturn.Both, (releaseContinuationPoints) ? releaseContinuationPoints : false);
|
|
313
|
+
if (results[0].statusCode.isNotGood())
|
|
314
|
+
throw new common_1.UaError(results[0].statusCode);
|
|
315
|
+
let extensionObject = results[0].historyData;
|
|
316
|
+
if (!extensionObject)
|
|
317
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadDecodingError));
|
|
318
|
+
let historyData = common_1.UaHistoryData.fromExtensionObject(extensionObject);
|
|
319
|
+
if (null == historyData)
|
|
320
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadDecodingError));
|
|
321
|
+
let ret = new common_1.UaHistoryDataResult(historyData.dataValues, results[0].continuationPoint);
|
|
322
|
+
return ret;
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
historyReadProcessed(nodeId, startTime, endTime, processingInterval, aggregateType, continuationPoint, timestampsToReturn, releaseContinuationPoints) {
|
|
326
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
327
|
+
let nodeToRead = new common_1.UaHistoryReadValueId(nodeId, continuationPoint);
|
|
328
|
+
let aggregateTypeId = (aggregateType) ?
|
|
329
|
+
aggregateType :
|
|
330
|
+
common_1.UaNodeId.from(common_1.ObjectIds.AggregateFunction_Interpolative);
|
|
331
|
+
let details = new common_1.UaReadProcessedDetails(startTime, endTime, processingInterval, [aggregateTypeId]);
|
|
332
|
+
let historyReadDetails = details.toExtensionObject();
|
|
333
|
+
let nodesToRead = [nodeToRead];
|
|
334
|
+
let results = yield this.historyRead(nodesToRead, historyReadDetails, (timestampsToReturn) ? timestampsToReturn : opcua_webapi_1.TimestampsToReturn.Both, (releaseContinuationPoints) ? releaseContinuationPoints : false);
|
|
313
335
|
if (results[0].statusCode.isNotGood())
|
|
314
336
|
throw new common_1.UaError(results[0].statusCode);
|
|
315
337
|
let extensionObject = results[0].historyData;
|
|
@@ -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;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ReadProcessedDetails } from "opcua-webapi";
|
|
2
|
+
import { UaExtensionObject, UaNodeId } from "../types";
|
|
3
|
+
export declare class UaReadProcessedDetails {
|
|
4
|
+
static dataTypeId: UaNodeId;
|
|
5
|
+
private _startTime;
|
|
6
|
+
private _endTime;
|
|
7
|
+
private _processingInterval;
|
|
8
|
+
private _aggregateType;
|
|
9
|
+
constructor(startTime: Date, endTime: Date, processingInterval: number, aggregateType?: Array<UaNodeId> | null);
|
|
10
|
+
get startTime(): Date;
|
|
11
|
+
get endTime(): Date;
|
|
12
|
+
get processingInterval(): number;
|
|
13
|
+
get aggregateType(): Array<UaNodeId> | null;
|
|
14
|
+
toStruct(): ReadProcessedDetails;
|
|
15
|
+
static fromStruct(details: ReadProcessedDetails): UaReadProcessedDetails | null;
|
|
16
|
+
toExtensionObject(): UaExtensionObject;
|
|
17
|
+
static fromExtensionObject(extensionObject: UaExtensionObject): UaReadProcessedDetails | null;
|
|
18
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UaReadProcessedDetails = void 0;
|
|
4
|
+
const opcua_webapi_1 = require("opcua-webapi");
|
|
5
|
+
const nodes_1 = require("../nodes");
|
|
6
|
+
const types_1 = require("../types");
|
|
7
|
+
class UaReadProcessedDetails {
|
|
8
|
+
constructor(startTime, endTime, processingInterval, aggregateType) {
|
|
9
|
+
this._startTime = startTime;
|
|
10
|
+
this._endTime = endTime;
|
|
11
|
+
this._processingInterval = processingInterval;
|
|
12
|
+
this._aggregateType = (aggregateType) ? aggregateType : null;
|
|
13
|
+
}
|
|
14
|
+
get startTime() {
|
|
15
|
+
return this._startTime;
|
|
16
|
+
}
|
|
17
|
+
get endTime() {
|
|
18
|
+
return this._endTime;
|
|
19
|
+
}
|
|
20
|
+
get processingInterval() {
|
|
21
|
+
return this._processingInterval;
|
|
22
|
+
}
|
|
23
|
+
get aggregateType() {
|
|
24
|
+
return this._aggregateType;
|
|
25
|
+
}
|
|
26
|
+
toStruct() {
|
|
27
|
+
let aggregateType = [];
|
|
28
|
+
if (this._aggregateType) {
|
|
29
|
+
for (let item of this._aggregateType) {
|
|
30
|
+
aggregateType.push(item.toString());
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
let details = {
|
|
34
|
+
StartTime: this.startTime,
|
|
35
|
+
EndTime: this.endTime,
|
|
36
|
+
ProcessingInterval: this.processingInterval,
|
|
37
|
+
AggregateType: aggregateType
|
|
38
|
+
};
|
|
39
|
+
return details;
|
|
40
|
+
}
|
|
41
|
+
static fromStruct(details) {
|
|
42
|
+
let startTime = details.StartTime;
|
|
43
|
+
let endTime = details.EndTime;
|
|
44
|
+
let processingInterval = details.ProcessingInterval;
|
|
45
|
+
let aggregateType = null;
|
|
46
|
+
if (details.AggregateType && details.AggregateType.length > 0) {
|
|
47
|
+
aggregateType = [];
|
|
48
|
+
for (let item of details.AggregateType) {
|
|
49
|
+
let aggregateTypeId = (0, types_1.parseUaNodeIdOrNull)(item);
|
|
50
|
+
if (null == aggregateTypeId)
|
|
51
|
+
continue;
|
|
52
|
+
aggregateType.push(aggregateTypeId);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (null == startTime || null == endTime || null == processingInterval)
|
|
56
|
+
return null;
|
|
57
|
+
return new UaReadProcessedDetails(startTime, endTime, processingInterval, aggregateType);
|
|
58
|
+
}
|
|
59
|
+
toExtensionObject() {
|
|
60
|
+
return new types_1.UaExtensionObject(UaReadProcessedDetails.dataTypeId, (0, opcua_webapi_1.ReadProcessedDetailsToJSONTyped)(this.toStruct()));
|
|
61
|
+
}
|
|
62
|
+
static fromExtensionObject(extensionObject) {
|
|
63
|
+
if (!UaReadProcessedDetails.dataTypeId.equal(extensionObject.typeId))
|
|
64
|
+
return null;
|
|
65
|
+
let details = (0, opcua_webapi_1.ReadProcessedDetailsFromJSON)(extensionObject.body);
|
|
66
|
+
return UaReadProcessedDetails.fromStruct(details);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.UaReadProcessedDetails = UaReadProcessedDetails;
|
|
70
|
+
UaReadProcessedDetails.dataTypeId = new types_1.UaNodeId(nodes_1.DataTypeIds.ReadProcessedDetails);
|
|
@@ -10,6 +10,7 @@ export * from "./UaHistoryEvent";
|
|
|
10
10
|
export * from "./UaLiteralOperand";
|
|
11
11
|
export * from "./UaRange";
|
|
12
12
|
export * from "./UaReadAtTimeDetails";
|
|
13
|
-
export * from "./UaReadEventDetails";
|
|
14
13
|
export * from "./UaReadRawModifiedDetails";
|
|
14
|
+
export * from "./UaReadProcessedDetails";
|
|
15
|
+
export * from "./UaReadEventDetails";
|
|
15
16
|
export * from "./UaSimpleAttributeOperand";
|
|
@@ -26,6 +26,7 @@ __exportStar(require("./UaHistoryEvent"), exports);
|
|
|
26
26
|
__exportStar(require("./UaLiteralOperand"), exports);
|
|
27
27
|
__exportStar(require("./UaRange"), exports);
|
|
28
28
|
__exportStar(require("./UaReadAtTimeDetails"), exports);
|
|
29
|
-
__exportStar(require("./UaReadEventDetails"), exports);
|
|
30
29
|
__exportStar(require("./UaReadRawModifiedDetails"), exports);
|
|
30
|
+
__exportStar(require("./UaReadProcessedDetails"), exports);
|
|
31
|
+
__exportStar(require("./UaReadEventDetails"), exports);
|
|
31
32
|
__exportStar(require("./UaSimpleAttributeOperand"), exports);
|
|
@@ -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;
|