opcua-webapi-ts 1.1.5 → 1.1.7
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/UaDataTypeDictionary.js +38 -91
- package/dist/cjs/client/utils/UaNodeReader.js +459 -530
- package/dist/cjs/client/utils/UaObjectTypeDictionary.js +37 -29
- package/dist/cjs/client/utils/UaReferenceTypeDictionary.js +37 -29
- package/dist/cjs/common/nodes/UaDataType.js +35 -34
- package/dist/cjs/common/nodes/UaMethod.js +2 -2
- package/dist/cjs/common/nodes/UaObject.js +1 -1
- package/dist/cjs/common/nodes/UaVariable.js +10 -6
- package/dist/cjs/common/types/UaReference.js +59 -0
- package/dist/cjs/common/types/index.js +1 -1
- package/dist/client/utils/UaDataTypeDictionary.d.ts +3 -6
- package/dist/client/utils/UaDataTypeDictionary.js +38 -91
- package/dist/client/utils/UaNodeReader.d.ts +45 -73
- package/dist/client/utils/UaNodeReader.js +459 -530
- package/dist/client/utils/UaObjectTypeDictionary.d.ts +3 -3
- package/dist/client/utils/UaObjectTypeDictionary.js +37 -29
- package/dist/client/utils/UaReferenceTypeDictionary.d.ts +3 -3
- package/dist/client/utils/UaReferenceTypeDictionary.js +37 -29
- package/dist/common/nodes/UaDataType.d.ts +2 -2
- package/dist/common/nodes/UaDataType.js +35 -34
- package/dist/common/nodes/UaMethod.js +2 -2
- package/dist/common/nodes/UaObject.js +1 -1
- package/dist/common/nodes/UaVariable.d.ts +5 -4
- package/dist/common/nodes/UaVariable.js +10 -6
- package/dist/common/types/UaReference.d.ts +23 -0
- package/dist/common/types/UaReference.js +59 -0
- package/dist/common/types/index.d.ts +1 -1
- package/dist/common/types/index.js +1 -1
- package/package.json +1 -1
|
@@ -12,27 +12,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.UaDataTypeDictionary = void 0;
|
|
13
13
|
const opcua_webapi_1 = require("opcua-webapi");
|
|
14
14
|
const common_1 = require("../../common");
|
|
15
|
+
const __1 = require("../..");
|
|
15
16
|
class UaDataTypeDictionary {
|
|
16
|
-
constructor() {
|
|
17
|
-
if (null == UaDataTypeDictionary._abstractDataTypeIds) {
|
|
18
|
-
UaDataTypeDictionary._abstractDataTypeIds = new Set;
|
|
19
|
-
UaDataTypeDictionary._abstractDataTypeIds.add(common_1.DataTypeIds.BaseDataType);
|
|
20
|
-
UaDataTypeDictionary._abstractDataTypeIds.add(common_1.DataTypeIds.Number);
|
|
21
|
-
UaDataTypeDictionary._abstractDataTypeIds.add(common_1.DataTypeIds.Structure);
|
|
22
|
-
UaDataTypeDictionary._abstractDataTypeIds.add(common_1.DataTypeIds.Integer);
|
|
23
|
-
UaDataTypeDictionary._abstractDataTypeIds.add(common_1.DataTypeIds.UInteger);
|
|
24
|
-
UaDataTypeDictionary._abstractDataTypeIds.add(common_1.DataTypeIds.Enumeration);
|
|
25
|
-
}
|
|
17
|
+
constructor(simpleMode) {
|
|
26
18
|
this._dataTypes = new Map;
|
|
19
|
+
this._returnAllAttributes = (null == simpleMode) ? false : !simpleMode;
|
|
27
20
|
let baseDataTypeId = new common_1.UaNodeId(common_1.DataTypeIds.BaseDataType);
|
|
28
21
|
this._dataTypes.set(baseDataTypeId.toString(), new common_1.UaDataType(baseDataTypeId, "BaseDataType", new common_1.UaLocalizedText("BaseDataType"), true));
|
|
29
|
-
this._remainingNodesToBrowse = [new common_1.UaNodeId(common_1.DataTypeIds.BaseDataType)];
|
|
30
|
-
this._remainingEnumerationToRead = [];
|
|
31
22
|
}
|
|
32
23
|
read(client) {
|
|
33
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
|
|
35
|
-
yield this.
|
|
25
|
+
let browser = new __1.UaChildBrowser([common_1.UaNodeId.from(common_1.DataTypeIds.BaseDataType)]);
|
|
26
|
+
yield this._read(browser, client);
|
|
36
27
|
});
|
|
37
28
|
}
|
|
38
29
|
getDataType(nodeId) {
|
|
@@ -42,89 +33,46 @@ class UaDataTypeDictionary {
|
|
|
42
33
|
getDataTypes() {
|
|
43
34
|
return [...this._dataTypes.values()];
|
|
44
35
|
}
|
|
45
|
-
|
|
36
|
+
_read(browser, client) {
|
|
46
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
let
|
|
50
|
-
let
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
38
|
+
// Browse child type
|
|
39
|
+
yield browser.browse(client);
|
|
40
|
+
let results = browser.results();
|
|
41
|
+
let referencesToRead = [];
|
|
42
|
+
let needToReadEnumValue = false;
|
|
43
|
+
for (let item of results) {
|
|
44
|
+
for (let reference of item.references)
|
|
45
|
+
referencesToRead.push(reference);
|
|
46
|
+
if (item.nodeId.equal(common_1.UaNodeId.from(common_1.DataTypeIds.Enumeration)))
|
|
47
|
+
needToReadEnumValue = true;
|
|
54
48
|
}
|
|
55
|
-
|
|
56
|
-
for (let i = 0; i < nodeIds.length; ++i) {
|
|
57
|
-
if (results[i].statusCode.isNotGood())
|
|
58
|
-
continue;
|
|
59
|
-
let parentType = this._dataTypes.get(nodeIds[i].toString());
|
|
60
|
-
for (let item of results[i].references) {
|
|
61
|
-
let dataTypeId = item.nodeId.getNodeId();
|
|
62
|
-
if (null == dataTypeId ||
|
|
63
|
-
opcua_webapi_1.NodeClass.DataType != item.nodeClass ||
|
|
64
|
-
!item.browseName || !item.displayName)
|
|
65
|
-
continue;
|
|
66
|
-
let isAbstract = false;
|
|
67
|
-
if (dataTypeId.nsIndex == 0 &&
|
|
68
|
-
UaDataTypeDictionary._abstractDataTypeIds.has(dataTypeId.numericId()))
|
|
69
|
-
isAbstract = true;
|
|
70
|
-
let dataType = new common_1.UaDataType(dataTypeId, item.browseName, item.displayName, isAbstract);
|
|
71
|
-
this._dataTypes.set(dataTypeId.toString(), dataType);
|
|
72
|
-
this._remainingNodesToBrowse.push(dataTypeId);
|
|
73
|
-
if (parentType)
|
|
74
|
-
dataType.setParentType(parentType);
|
|
75
|
-
dataType.classify();
|
|
76
|
-
if (common_1.DataTypeIds.Enumeration == dataType.valueType) {
|
|
77
|
-
this._remainingEnumerationToRead.push(dataType.nodeId);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
if (this._remainingNodesToBrowse.length != 0) {
|
|
82
|
-
yield this.__delay(20);
|
|
83
|
-
yield this.__browseDataTypes(client);
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
__readEnumValues(client) {
|
|
88
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
-
if (this._remainingEnumerationToRead.length == 0)
|
|
49
|
+
if (0 == referencesToRead.length)
|
|
90
50
|
return;
|
|
91
|
-
|
|
92
|
-
let
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
let results = yield client.browse(nodesToBrowse);
|
|
98
|
-
let enumDataTypeIds = [];
|
|
99
|
-
let enumValueIds = [];
|
|
100
|
-
for (let i = 0; i < nodeIds.length; ++i) {
|
|
101
|
-
if (results[i].statusCode.isNotGood() ||
|
|
102
|
-
results[i].references.length == 0)
|
|
51
|
+
// Read child type
|
|
52
|
+
let nodeIdsToBrowse = [];
|
|
53
|
+
let nodeReader = new __1.UaNodeReader(this._returnAllAttributes, needToReadEnumValue, false, this._returnAllAttributes);
|
|
54
|
+
let nodes = yield nodeReader.readByReferences(referencesToRead, client);
|
|
55
|
+
for (let node of nodes) {
|
|
56
|
+
if (opcua_webapi_1.NodeClass.DataType != node.nodeClass)
|
|
103
57
|
continue;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if (enumValueId) {
|
|
107
|
-
enumDataTypeIds.push(nodeIds[i]);
|
|
108
|
-
enumValueIds.push(enumValueId);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
58
|
+
nodeIdsToBrowse.push(node.nodeId);
|
|
59
|
+
this._dataTypes.set(node.nodeId.toString(), node);
|
|
111
60
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (!dataType)
|
|
120
|
-
continue;
|
|
121
|
-
dataType.setEnumValues(values[i].value);
|
|
61
|
+
// Build parent-child relationship
|
|
62
|
+
for (let item of results) {
|
|
63
|
+
let parentType = this._dataTypes.get(item.nodeId.toString());
|
|
64
|
+
for (let reference of item.references) {
|
|
65
|
+
let dataType = this._dataTypes.get(reference.nodeId.toString());
|
|
66
|
+
if (dataType && parentType)
|
|
67
|
+
dataType.setParentType(parentType);
|
|
122
68
|
}
|
|
123
69
|
}
|
|
124
|
-
if (
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
70
|
+
if (0 == nodeIdsToBrowse.length)
|
|
71
|
+
return;
|
|
72
|
+
yield this.__delay(20);
|
|
73
|
+
// Continue to browse and read child type
|
|
74
|
+
let childBrowser = new __1.UaChildBrowser(nodeIdsToBrowse);
|
|
75
|
+
yield this._read(childBrowser, client);
|
|
128
76
|
});
|
|
129
77
|
}
|
|
130
78
|
__delay(ms) {
|
|
@@ -134,4 +82,3 @@ class UaDataTypeDictionary {
|
|
|
134
82
|
}
|
|
135
83
|
}
|
|
136
84
|
exports.UaDataTypeDictionary = UaDataTypeDictionary;
|
|
137
|
-
UaDataTypeDictionary._abstractDataTypeIds = null;
|