opcua-webapi-ts 1.1.21 → 1.1.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.
- package/dist/cjs/client/utils/UaNodeReader.js +98 -11
- package/dist/cjs/common/nodes/UaObject.js +11 -4
- package/dist/cjs/common/nodes/UaObjectType.js +10 -3
- package/dist/cjs/common/nodes/UaVariable.js +2 -2
- package/dist/client/utils/UaNodeReader.d.ts +15 -4
- package/dist/client/utils/UaNodeReader.js +98 -11
- package/dist/common/nodes/UaObject.js +11 -4
- package/dist/common/nodes/UaObjectType.js +10 -3
- package/dist/common/nodes/UaVariable.js +2 -2
- package/package.json +1 -1
|
@@ -9,16 +9,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.UaTypeReader = exports.UaObjectReader = exports.UaNodeReader = void 0;
|
|
12
|
+
exports.UaObjectDataReader = exports.UaTypeReader = exports.UaObjectReader = exports.UaNodeReader = void 0;
|
|
13
13
|
const opcua_webapi_1 = require("opcua-webapi");
|
|
14
14
|
const common_1 = require("../../common");
|
|
15
15
|
const UaNodeBrowser_1 = require("./UaNodeBrowser");
|
|
16
16
|
class UaNodeReader {
|
|
17
|
-
constructor(client, returnDescription, returnVariable, returnMethod, returnAttributes, returnValue) {
|
|
17
|
+
constructor(client, returnDescription, returnVariable, returnMethod, returnAttributes, returnValue, referenceTypeToReturn) {
|
|
18
18
|
this._client = client;
|
|
19
19
|
this._returnDescription = (returnDescription) ? returnDescription : false;
|
|
20
20
|
this._returnAttributes = (returnAttributes) ? returnAttributes : false;
|
|
21
21
|
this._returnValue = (returnValue) ? returnValue : false;
|
|
22
|
+
this._referenceTypeToReturn = (referenceTypeToReturn) ? referenceTypeToReturn : common_1.UaNodeId.from(common_1.ReferenceTypeIds.HierarchicalReferences);
|
|
22
23
|
this._nodeClassToReturn = 0;
|
|
23
24
|
if (returnVariable)
|
|
24
25
|
this._nodeClassToReturn += opcua_webapi_1.NodeClass.Variable;
|
|
@@ -68,7 +69,7 @@ class UaNodeReader {
|
|
|
68
69
|
nodeIdsToBrowse.push(item.nodeId);
|
|
69
70
|
nodeIdsSet.add(item.nodeId.toString());
|
|
70
71
|
}
|
|
71
|
-
let nodeReferenceBrowser = new UaNodeBrowser_1.UaNodeBrowser(this._client, nodeIdsToBrowse,
|
|
72
|
+
let nodeReferenceBrowser = new UaNodeBrowser_1.UaNodeBrowser(this._client, nodeIdsToBrowse, this._referenceTypeToReturn, this._nodeClassToReturn, false);
|
|
72
73
|
yield nodeReferenceBrowser.browse();
|
|
73
74
|
let childReferences = nodeReferenceBrowser.results();
|
|
74
75
|
let childNodesToBrowse = [];
|
|
@@ -457,15 +458,35 @@ class UaObjectReader extends UaNodeReader {
|
|
|
457
458
|
});
|
|
458
459
|
return __awaiter(this, void 0, void 0, function* () {
|
|
459
460
|
let nodes = yield _super.read.call(this, nodeIds);
|
|
460
|
-
|
|
461
|
-
|
|
461
|
+
return this._processResult(nodes);
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
readByReferences(references) {
|
|
465
|
+
const _super = Object.create(null, {
|
|
466
|
+
readByReferences: { get: () => super.readByReferences }
|
|
467
|
+
});
|
|
468
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
469
|
+
let objectReferences = [];
|
|
470
|
+
for (let item of references) {
|
|
462
471
|
if (item.nodeClass == opcua_webapi_1.NodeClass.Object) {
|
|
463
|
-
|
|
472
|
+
objectReferences.push(item);
|
|
464
473
|
}
|
|
465
474
|
}
|
|
466
|
-
|
|
475
|
+
if (0 == objectReferences.length)
|
|
476
|
+
return [];
|
|
477
|
+
let nodes = yield _super.readByReferences.call(this, objectReferences);
|
|
478
|
+
return this._processResult(nodes);
|
|
467
479
|
});
|
|
468
480
|
}
|
|
481
|
+
_processResult(nodes) {
|
|
482
|
+
let objectNodes = [];
|
|
483
|
+
for (let item of nodes) {
|
|
484
|
+
if (item.nodeClass == opcua_webapi_1.NodeClass.Object) {
|
|
485
|
+
objectNodes.push(item);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
return objectNodes;
|
|
489
|
+
}
|
|
469
490
|
}
|
|
470
491
|
exports.UaObjectReader = UaObjectReader;
|
|
471
492
|
class UaTypeReader extends UaNodeReader {
|
|
@@ -478,17 +499,83 @@ class UaTypeReader extends UaNodeReader {
|
|
|
478
499
|
});
|
|
479
500
|
return __awaiter(this, void 0, void 0, function* () {
|
|
480
501
|
let nodes = yield _super.read.call(this, nodeIds);
|
|
481
|
-
|
|
482
|
-
|
|
502
|
+
return this._processResult(nodes);
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
readByReferences(references) {
|
|
506
|
+
const _super = Object.create(null, {
|
|
507
|
+
readByReferences: { get: () => super.readByReferences }
|
|
508
|
+
});
|
|
509
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
510
|
+
let typeReferences = [];
|
|
511
|
+
for (let item of references) {
|
|
483
512
|
if (item.nodeClass == opcua_webapi_1.NodeClass.ObjectType ||
|
|
484
513
|
item.nodeClass == opcua_webapi_1.NodeClass.VariableType ||
|
|
485
514
|
item.nodeClass == opcua_webapi_1.NodeClass.DataType ||
|
|
486
515
|
item.nodeClass == opcua_webapi_1.NodeClass.ReferenceType) {
|
|
487
|
-
|
|
516
|
+
typeReferences.push(item);
|
|
488
517
|
}
|
|
489
518
|
}
|
|
490
|
-
|
|
519
|
+
if (0 == typeReferences.length)
|
|
520
|
+
return [];
|
|
521
|
+
let nodes = yield _super.readByReferences.call(this, typeReferences);
|
|
522
|
+
return this._processResult(nodes);
|
|
491
523
|
});
|
|
492
524
|
}
|
|
525
|
+
_processResult(nodes) {
|
|
526
|
+
let typeNodes = [];
|
|
527
|
+
for (let item of nodes) {
|
|
528
|
+
if (item.nodeClass == opcua_webapi_1.NodeClass.ObjectType ||
|
|
529
|
+
item.nodeClass == opcua_webapi_1.NodeClass.VariableType ||
|
|
530
|
+
item.nodeClass == opcua_webapi_1.NodeClass.DataType ||
|
|
531
|
+
item.nodeClass == opcua_webapi_1.NodeClass.ReferenceType) {
|
|
532
|
+
typeNodes.push(item);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
return typeNodes;
|
|
536
|
+
}
|
|
493
537
|
}
|
|
494
538
|
exports.UaTypeReader = UaTypeReader;
|
|
539
|
+
class UaObjectDataReader extends UaNodeReader {
|
|
540
|
+
constructor(client) {
|
|
541
|
+
super(client, false, true, false, false, true);
|
|
542
|
+
}
|
|
543
|
+
readValues(nodeIds) {
|
|
544
|
+
const _super = Object.create(null, {
|
|
545
|
+
read: { get: () => super.read }
|
|
546
|
+
});
|
|
547
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
548
|
+
let nodes = yield _super.read.call(this, nodeIds);
|
|
549
|
+
return this._processResult(nodes);
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
readValuesByReferences(references) {
|
|
553
|
+
const _super = Object.create(null, {
|
|
554
|
+
readByReferences: { get: () => super.readByReferences }
|
|
555
|
+
});
|
|
556
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
557
|
+
let nodes = yield _super.readByReferences.call(this, references);
|
|
558
|
+
return this._processResult(nodes);
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
_processResult(nodes) {
|
|
562
|
+
let ret = new Map();
|
|
563
|
+
for (let item of nodes) {
|
|
564
|
+
if (item.nodeClass != opcua_webapi_1.NodeClass.Object)
|
|
565
|
+
continue;
|
|
566
|
+
let id = item.nodeId.toString();
|
|
567
|
+
let objectNode = item;
|
|
568
|
+
let members = objectNode.getMembers(opcua_webapi_1.NodeClass.Variable);
|
|
569
|
+
let serializedObject = {};
|
|
570
|
+
serializedObject["_id"] = id;
|
|
571
|
+
serializedObject["_name"] = objectNode.displayName.text;
|
|
572
|
+
for (let member of members) {
|
|
573
|
+
let value = member.value;
|
|
574
|
+
serializedObject[member.browseName] = (null == value) ? null : value.value;
|
|
575
|
+
}
|
|
576
|
+
ret.set(id, serializedObject);
|
|
577
|
+
}
|
|
578
|
+
return ret;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
exports.UaObjectDataReader = UaObjectDataReader;
|
|
@@ -49,9 +49,15 @@ class UaObject extends _1.UaInstanceNode {
|
|
|
49
49
|
return ret;
|
|
50
50
|
}
|
|
51
51
|
toJson() {
|
|
52
|
-
let
|
|
52
|
+
let variables = [];
|
|
53
|
+
let methods = [];
|
|
53
54
|
for (let item of this._children) {
|
|
54
|
-
|
|
55
|
+
if (opcua_webapi_1.NodeClass.Variable == item.nodeClass) {
|
|
56
|
+
variables.push(item.toJson());
|
|
57
|
+
}
|
|
58
|
+
else if (opcua_webapi_1.NodeClass.Method == item.nodeClass) {
|
|
59
|
+
methods.push(item.toJson());
|
|
60
|
+
}
|
|
55
61
|
}
|
|
56
62
|
let ret = {
|
|
57
63
|
nodeId: this._nodeId.toString(),
|
|
@@ -60,8 +66,9 @@ class UaObject extends _1.UaInstanceNode {
|
|
|
60
66
|
displayName: this._displayName.text,
|
|
61
67
|
description: (this._description) ? this._description.text : undefined,
|
|
62
68
|
typeDefinitionId: this._typeDefinitionId.toString(),
|
|
63
|
-
eventNotifier: this._eventNotifier,
|
|
64
|
-
|
|
69
|
+
eventNotifier: (this._eventNotifier != 0) ? this._eventNotifier : undefined,
|
|
70
|
+
variables: (variables.length != 0) ? variables : undefined,
|
|
71
|
+
methods: (methods.length != 0) ? methods : undefined
|
|
65
72
|
};
|
|
66
73
|
return ret;
|
|
67
74
|
}
|
|
@@ -48,11 +48,17 @@ class UaObjectType extends _1.UaDefintionNode {
|
|
|
48
48
|
this._isObjectMemberRead = value;
|
|
49
49
|
}
|
|
50
50
|
toJson() {
|
|
51
|
-
let
|
|
51
|
+
let variables = [];
|
|
52
|
+
let methods = [];
|
|
52
53
|
for (let item of this._children) {
|
|
53
54
|
if (item.nodeClass == opcua_webapi_1.NodeClass.ObjectType)
|
|
54
55
|
continue;
|
|
55
|
-
|
|
56
|
+
if (opcua_webapi_1.NodeClass.Variable == item.nodeClass) {
|
|
57
|
+
variables.push(item.toJson());
|
|
58
|
+
}
|
|
59
|
+
else if (opcua_webapi_1.NodeClass.Method == item.nodeClass) {
|
|
60
|
+
methods.push(item.toJson());
|
|
61
|
+
}
|
|
56
62
|
}
|
|
57
63
|
let ret = {
|
|
58
64
|
nodeId: this._nodeId.toString(),
|
|
@@ -61,7 +67,8 @@ class UaObjectType extends _1.UaDefintionNode {
|
|
|
61
67
|
displayName: this._displayName.text,
|
|
62
68
|
description: (this._description) ? this._description.text : undefined,
|
|
63
69
|
isAbstract: this._isAbstract,
|
|
64
|
-
|
|
70
|
+
variables: (variables.length != 0) ? variables : undefined,
|
|
71
|
+
methods: (methods.length != 0) ? methods : undefined
|
|
65
72
|
};
|
|
66
73
|
return ret;
|
|
67
74
|
}
|
|
@@ -68,9 +68,9 @@ class UaVariable extends _1.UaInstanceNode {
|
|
|
68
68
|
displayName: this._displayName.text,
|
|
69
69
|
typeDefinitionId: this._typeDefinitionId.toString(),
|
|
70
70
|
dataType: this._dataType.toString(),
|
|
71
|
-
valueRank: this._valueRank,
|
|
71
|
+
valueRank: (this._valueRank != 0) ? this._valueRank : undefined,
|
|
72
72
|
accessLevel: this._accessLevel,
|
|
73
|
-
historizing: this._historizing,
|
|
73
|
+
historizing: (this._historizing) ? true : undefined,
|
|
74
74
|
value: this._dataValue ? this._dataValue.value.value : undefined,
|
|
75
75
|
children: (children.length != 0) ? children : undefined
|
|
76
76
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UaNode, UaNodeId, UaReference } from "../../common";
|
|
1
|
+
import { UaNode, UaNodeId, UaObject, UaReference, UaDefintionNode } from "../../common";
|
|
2
2
|
import { UaWebClient } from "../UaWebClient";
|
|
3
3
|
export declare class UaNodeReader {
|
|
4
4
|
private _client;
|
|
@@ -6,9 +6,10 @@ export declare class UaNodeReader {
|
|
|
6
6
|
private _returnDescription;
|
|
7
7
|
private _returnAttributes;
|
|
8
8
|
private _returnValue;
|
|
9
|
+
private _referenceTypeToReturn;
|
|
9
10
|
private static s_variableTypeWithoutMember;
|
|
10
11
|
private static s_variablesNameToRead;
|
|
11
|
-
constructor(client: UaWebClient, returnDescription?: boolean | null, returnVariable?: boolean | null, returnMethod?: boolean | null, returnAttributes?: boolean | null, returnValue?: boolean | null);
|
|
12
|
+
constructor(client: UaWebClient, returnDescription?: boolean | null, returnVariable?: boolean | null, returnMethod?: boolean | null, returnAttributes?: boolean | null, returnValue?: boolean | null, referenceTypeToReturn?: UaNodeId);
|
|
12
13
|
read(nodeIds: Array<UaNodeId>): Promise<Array<UaNode>>;
|
|
13
14
|
readByReferences(references: Array<UaReference>): Promise<Array<UaNode>>;
|
|
14
15
|
private _readRootNodes;
|
|
@@ -21,9 +22,19 @@ export declare class UaNodeReader {
|
|
|
21
22
|
}
|
|
22
23
|
export declare class UaObjectReader extends UaNodeReader {
|
|
23
24
|
constructor(client: UaWebClient, returnDescription?: boolean | null, returnValue?: boolean | null);
|
|
24
|
-
read(nodeIds: Array<UaNodeId>): Promise<Array<
|
|
25
|
+
read(nodeIds: Array<UaNodeId>): Promise<Array<UaObject>>;
|
|
26
|
+
readByReferences(references: Array<UaReference>): Promise<Array<UaObject>>;
|
|
27
|
+
private _processResult;
|
|
25
28
|
}
|
|
26
29
|
export declare class UaTypeReader extends UaNodeReader {
|
|
27
30
|
constructor(client: UaWebClient);
|
|
28
|
-
read(nodeIds: Array<UaNodeId>): Promise<Array<
|
|
31
|
+
read(nodeIds: Array<UaNodeId>): Promise<Array<UaDefintionNode>>;
|
|
32
|
+
readByReferences(references: Array<UaReference>): Promise<Array<UaDefintionNode>>;
|
|
33
|
+
private _processResult;
|
|
34
|
+
}
|
|
35
|
+
export declare class UaObjectDataReader extends UaNodeReader {
|
|
36
|
+
constructor(client: UaWebClient);
|
|
37
|
+
readValues(nodeIds: Array<UaNodeId>): Promise<Map<string, any>>;
|
|
38
|
+
readValuesByReferences(references: Array<UaReference>): Promise<Map<string, any>>;
|
|
39
|
+
private _processResult;
|
|
29
40
|
}
|
|
@@ -9,16 +9,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.UaTypeReader = exports.UaObjectReader = exports.UaNodeReader = void 0;
|
|
12
|
+
exports.UaObjectDataReader = exports.UaTypeReader = exports.UaObjectReader = exports.UaNodeReader = void 0;
|
|
13
13
|
const opcua_webapi_1 = require("opcua-webapi");
|
|
14
14
|
const common_1 = require("../../common");
|
|
15
15
|
const UaNodeBrowser_1 = require("./UaNodeBrowser");
|
|
16
16
|
class UaNodeReader {
|
|
17
|
-
constructor(client, returnDescription, returnVariable, returnMethod, returnAttributes, returnValue) {
|
|
17
|
+
constructor(client, returnDescription, returnVariable, returnMethod, returnAttributes, returnValue, referenceTypeToReturn) {
|
|
18
18
|
this._client = client;
|
|
19
19
|
this._returnDescription = (returnDescription) ? returnDescription : false;
|
|
20
20
|
this._returnAttributes = (returnAttributes) ? returnAttributes : false;
|
|
21
21
|
this._returnValue = (returnValue) ? returnValue : false;
|
|
22
|
+
this._referenceTypeToReturn = (referenceTypeToReturn) ? referenceTypeToReturn : common_1.UaNodeId.from(common_1.ReferenceTypeIds.HierarchicalReferences);
|
|
22
23
|
this._nodeClassToReturn = 0;
|
|
23
24
|
if (returnVariable)
|
|
24
25
|
this._nodeClassToReturn += opcua_webapi_1.NodeClass.Variable;
|
|
@@ -68,7 +69,7 @@ class UaNodeReader {
|
|
|
68
69
|
nodeIdsToBrowse.push(item.nodeId);
|
|
69
70
|
nodeIdsSet.add(item.nodeId.toString());
|
|
70
71
|
}
|
|
71
|
-
let nodeReferenceBrowser = new UaNodeBrowser_1.UaNodeBrowser(this._client, nodeIdsToBrowse,
|
|
72
|
+
let nodeReferenceBrowser = new UaNodeBrowser_1.UaNodeBrowser(this._client, nodeIdsToBrowse, this._referenceTypeToReturn, this._nodeClassToReturn, false);
|
|
72
73
|
yield nodeReferenceBrowser.browse();
|
|
73
74
|
let childReferences = nodeReferenceBrowser.results();
|
|
74
75
|
let childNodesToBrowse = [];
|
|
@@ -457,15 +458,35 @@ class UaObjectReader extends UaNodeReader {
|
|
|
457
458
|
});
|
|
458
459
|
return __awaiter(this, void 0, void 0, function* () {
|
|
459
460
|
let nodes = yield _super.read.call(this, nodeIds);
|
|
460
|
-
|
|
461
|
-
|
|
461
|
+
return this._processResult(nodes);
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
readByReferences(references) {
|
|
465
|
+
const _super = Object.create(null, {
|
|
466
|
+
readByReferences: { get: () => super.readByReferences }
|
|
467
|
+
});
|
|
468
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
469
|
+
let objectReferences = [];
|
|
470
|
+
for (let item of references) {
|
|
462
471
|
if (item.nodeClass == opcua_webapi_1.NodeClass.Object) {
|
|
463
|
-
|
|
472
|
+
objectReferences.push(item);
|
|
464
473
|
}
|
|
465
474
|
}
|
|
466
|
-
|
|
475
|
+
if (0 == objectReferences.length)
|
|
476
|
+
return [];
|
|
477
|
+
let nodes = yield _super.readByReferences.call(this, objectReferences);
|
|
478
|
+
return this._processResult(nodes);
|
|
467
479
|
});
|
|
468
480
|
}
|
|
481
|
+
_processResult(nodes) {
|
|
482
|
+
let objectNodes = [];
|
|
483
|
+
for (let item of nodes) {
|
|
484
|
+
if (item.nodeClass == opcua_webapi_1.NodeClass.Object) {
|
|
485
|
+
objectNodes.push(item);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
return objectNodes;
|
|
489
|
+
}
|
|
469
490
|
}
|
|
470
491
|
exports.UaObjectReader = UaObjectReader;
|
|
471
492
|
class UaTypeReader extends UaNodeReader {
|
|
@@ -478,17 +499,83 @@ class UaTypeReader extends UaNodeReader {
|
|
|
478
499
|
});
|
|
479
500
|
return __awaiter(this, void 0, void 0, function* () {
|
|
480
501
|
let nodes = yield _super.read.call(this, nodeIds);
|
|
481
|
-
|
|
482
|
-
|
|
502
|
+
return this._processResult(nodes);
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
readByReferences(references) {
|
|
506
|
+
const _super = Object.create(null, {
|
|
507
|
+
readByReferences: { get: () => super.readByReferences }
|
|
508
|
+
});
|
|
509
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
510
|
+
let typeReferences = [];
|
|
511
|
+
for (let item of references) {
|
|
483
512
|
if (item.nodeClass == opcua_webapi_1.NodeClass.ObjectType ||
|
|
484
513
|
item.nodeClass == opcua_webapi_1.NodeClass.VariableType ||
|
|
485
514
|
item.nodeClass == opcua_webapi_1.NodeClass.DataType ||
|
|
486
515
|
item.nodeClass == opcua_webapi_1.NodeClass.ReferenceType) {
|
|
487
|
-
|
|
516
|
+
typeReferences.push(item);
|
|
488
517
|
}
|
|
489
518
|
}
|
|
490
|
-
|
|
519
|
+
if (0 == typeReferences.length)
|
|
520
|
+
return [];
|
|
521
|
+
let nodes = yield _super.readByReferences.call(this, typeReferences);
|
|
522
|
+
return this._processResult(nodes);
|
|
491
523
|
});
|
|
492
524
|
}
|
|
525
|
+
_processResult(nodes) {
|
|
526
|
+
let typeNodes = [];
|
|
527
|
+
for (let item of nodes) {
|
|
528
|
+
if (item.nodeClass == opcua_webapi_1.NodeClass.ObjectType ||
|
|
529
|
+
item.nodeClass == opcua_webapi_1.NodeClass.VariableType ||
|
|
530
|
+
item.nodeClass == opcua_webapi_1.NodeClass.DataType ||
|
|
531
|
+
item.nodeClass == opcua_webapi_1.NodeClass.ReferenceType) {
|
|
532
|
+
typeNodes.push(item);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
return typeNodes;
|
|
536
|
+
}
|
|
493
537
|
}
|
|
494
538
|
exports.UaTypeReader = UaTypeReader;
|
|
539
|
+
class UaObjectDataReader extends UaNodeReader {
|
|
540
|
+
constructor(client) {
|
|
541
|
+
super(client, false, true, false, false, true);
|
|
542
|
+
}
|
|
543
|
+
readValues(nodeIds) {
|
|
544
|
+
const _super = Object.create(null, {
|
|
545
|
+
read: { get: () => super.read }
|
|
546
|
+
});
|
|
547
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
548
|
+
let nodes = yield _super.read.call(this, nodeIds);
|
|
549
|
+
return this._processResult(nodes);
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
readValuesByReferences(references) {
|
|
553
|
+
const _super = Object.create(null, {
|
|
554
|
+
readByReferences: { get: () => super.readByReferences }
|
|
555
|
+
});
|
|
556
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
557
|
+
let nodes = yield _super.readByReferences.call(this, references);
|
|
558
|
+
return this._processResult(nodes);
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
_processResult(nodes) {
|
|
562
|
+
let ret = new Map();
|
|
563
|
+
for (let item of nodes) {
|
|
564
|
+
if (item.nodeClass != opcua_webapi_1.NodeClass.Object)
|
|
565
|
+
continue;
|
|
566
|
+
let id = item.nodeId.toString();
|
|
567
|
+
let objectNode = item;
|
|
568
|
+
let members = objectNode.getMembers(opcua_webapi_1.NodeClass.Variable);
|
|
569
|
+
let serializedObject = {};
|
|
570
|
+
serializedObject["_id"] = id;
|
|
571
|
+
serializedObject["_name"] = objectNode.displayName.text;
|
|
572
|
+
for (let member of members) {
|
|
573
|
+
let value = member.value;
|
|
574
|
+
serializedObject[member.browseName] = (null == value) ? null : value.value;
|
|
575
|
+
}
|
|
576
|
+
ret.set(id, serializedObject);
|
|
577
|
+
}
|
|
578
|
+
return ret;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
exports.UaObjectDataReader = UaObjectDataReader;
|
|
@@ -49,9 +49,15 @@ class UaObject extends _1.UaInstanceNode {
|
|
|
49
49
|
return ret;
|
|
50
50
|
}
|
|
51
51
|
toJson() {
|
|
52
|
-
let
|
|
52
|
+
let variables = [];
|
|
53
|
+
let methods = [];
|
|
53
54
|
for (let item of this._children) {
|
|
54
|
-
|
|
55
|
+
if (opcua_webapi_1.NodeClass.Variable == item.nodeClass) {
|
|
56
|
+
variables.push(item.toJson());
|
|
57
|
+
}
|
|
58
|
+
else if (opcua_webapi_1.NodeClass.Method == item.nodeClass) {
|
|
59
|
+
methods.push(item.toJson());
|
|
60
|
+
}
|
|
55
61
|
}
|
|
56
62
|
let ret = {
|
|
57
63
|
nodeId: this._nodeId.toString(),
|
|
@@ -60,8 +66,9 @@ class UaObject extends _1.UaInstanceNode {
|
|
|
60
66
|
displayName: this._displayName.text,
|
|
61
67
|
description: (this._description) ? this._description.text : undefined,
|
|
62
68
|
typeDefinitionId: this._typeDefinitionId.toString(),
|
|
63
|
-
eventNotifier: this._eventNotifier,
|
|
64
|
-
|
|
69
|
+
eventNotifier: (this._eventNotifier != 0) ? this._eventNotifier : undefined,
|
|
70
|
+
variables: (variables.length != 0) ? variables : undefined,
|
|
71
|
+
methods: (methods.length != 0) ? methods : undefined
|
|
65
72
|
};
|
|
66
73
|
return ret;
|
|
67
74
|
}
|
|
@@ -48,11 +48,17 @@ class UaObjectType extends _1.UaDefintionNode {
|
|
|
48
48
|
this._isObjectMemberRead = value;
|
|
49
49
|
}
|
|
50
50
|
toJson() {
|
|
51
|
-
let
|
|
51
|
+
let variables = [];
|
|
52
|
+
let methods = [];
|
|
52
53
|
for (let item of this._children) {
|
|
53
54
|
if (item.nodeClass == opcua_webapi_1.NodeClass.ObjectType)
|
|
54
55
|
continue;
|
|
55
|
-
|
|
56
|
+
if (opcua_webapi_1.NodeClass.Variable == item.nodeClass) {
|
|
57
|
+
variables.push(item.toJson());
|
|
58
|
+
}
|
|
59
|
+
else if (opcua_webapi_1.NodeClass.Method == item.nodeClass) {
|
|
60
|
+
methods.push(item.toJson());
|
|
61
|
+
}
|
|
56
62
|
}
|
|
57
63
|
let ret = {
|
|
58
64
|
nodeId: this._nodeId.toString(),
|
|
@@ -61,7 +67,8 @@ class UaObjectType extends _1.UaDefintionNode {
|
|
|
61
67
|
displayName: this._displayName.text,
|
|
62
68
|
description: (this._description) ? this._description.text : undefined,
|
|
63
69
|
isAbstract: this._isAbstract,
|
|
64
|
-
|
|
70
|
+
variables: (variables.length != 0) ? variables : undefined,
|
|
71
|
+
methods: (methods.length != 0) ? methods : undefined
|
|
65
72
|
};
|
|
66
73
|
return ret;
|
|
67
74
|
}
|
|
@@ -68,9 +68,9 @@ class UaVariable extends _1.UaInstanceNode {
|
|
|
68
68
|
displayName: this._displayName.text,
|
|
69
69
|
typeDefinitionId: this._typeDefinitionId.toString(),
|
|
70
70
|
dataType: this._dataType.toString(),
|
|
71
|
-
valueRank: this._valueRank,
|
|
71
|
+
valueRank: (this._valueRank != 0) ? this._valueRank : undefined,
|
|
72
72
|
accessLevel: this._accessLevel,
|
|
73
|
-
historizing: this._historizing,
|
|
73
|
+
historizing: (this._historizing) ? true : undefined,
|
|
74
74
|
value: this._dataValue ? this._dataValue.value.value : undefined,
|
|
75
75
|
children: (children.length != 0) ? children : undefined
|
|
76
76
|
};
|