opcua-webapi-ts 1.1.17 → 1.1.19
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 +95 -101
- package/dist/cjs/client/utils/UaDataTypeDictionary.js +11 -11
- package/dist/cjs/client/utils/UaModelling.js +137 -0
- package/dist/cjs/client/utils/UaNodeBrowser.js +186 -0
- package/dist/cjs/client/utils/UaNodeReader.js +38 -203
- package/dist/cjs/client/utils/UaObjectTypeDictionary.js +12 -11
- package/dist/cjs/client/utils/UaReferenceTypeDictionary.js +12 -11
- package/dist/cjs/client/utils/index.js +2 -0
- package/dist/cjs/common/nodes/UaDataType.js +2 -2
- package/dist/cjs/common/nodes/UaNode.js +27 -6
- package/dist/cjs/common/nodes/UaObjectType.js +7 -0
- package/dist/cjs/common/types/UaModellingRule.js +10 -0
- package/dist/cjs/common/types/index.js +1 -1
- package/dist/client/UaWebClient.d.ts +15 -6
- package/dist/client/UaWebClient.js +95 -101
- package/dist/client/utils/UaDataTypeDictionary.d.ts +3 -3
- package/dist/client/utils/UaDataTypeDictionary.js +11 -11
- package/dist/client/utils/UaModelling.d.ts +14 -0
- package/dist/client/utils/UaModelling.js +137 -0
- package/dist/client/utils/UaNodeBrowser.d.ts +34 -0
- package/dist/client/utils/UaNodeBrowser.js +186 -0
- package/dist/client/utils/UaNodeReader.d.ts +8 -39
- package/dist/client/utils/UaNodeReader.js +38 -203
- package/dist/client/utils/UaObjectTypeDictionary.d.ts +3 -3
- package/dist/client/utils/UaObjectTypeDictionary.js +12 -11
- package/dist/client/utils/UaReferenceTypeDictionary.d.ts +3 -3
- package/dist/client/utils/UaReferenceTypeDictionary.js +12 -11
- package/dist/client/utils/index.d.ts +2 -0
- package/dist/client/utils/index.js +2 -0
- package/dist/common/nodes/UaAttributes.d.ts +0 -4
- package/dist/common/nodes/UaDataType.d.ts +1 -1
- package/dist/common/nodes/UaDataType.js +2 -2
- package/dist/common/nodes/UaNode.d.ts +10 -6
- package/dist/common/nodes/UaNode.js +27 -6
- package/dist/common/nodes/UaObjectType.d.ts +3 -0
- package/dist/common/nodes/UaObjectType.js +7 -0
- package/dist/common/types/UaModellingRule.d.ts +6 -0
- package/dist/common/types/UaModellingRule.js +10 -0
- package/dist/common/types/index.d.ts +1 -1
- package/dist/common/types/index.js +1 -1
- package/package.json +2 -2
|
@@ -9,178 +9,13 @@ 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 =
|
|
12
|
+
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
|
-
|
|
16
|
-
constructor(nodeIds, referenceType, nodeClassToReturn, returnDescription, maxNodesPerBrowse, maxReferencesPerNode) {
|
|
17
|
-
this._nodesToBrowse = [];
|
|
18
|
-
this._referenceType = referenceType;
|
|
19
|
-
this._nodeClassToReturn = nodeClassToReturn;
|
|
20
|
-
this._continuationPointToBrowse = [];
|
|
21
|
-
this._returnDescription = returnDescription;
|
|
22
|
-
this._maxNodesPerBrowse = (null == maxNodesPerBrowse || maxNodesPerBrowse <= 0) ? 50 : maxNodesPerBrowse;
|
|
23
|
-
this._maxReferencesPerNode = (null == maxReferencesPerNode || maxReferencesPerNode < 0) ? 50 : maxReferencesPerNode;
|
|
24
|
-
this._readResults = new Map();
|
|
25
|
-
if (this._nodeClassToReturn != 0) {
|
|
26
|
-
let nodeIdSet = new Set;
|
|
27
|
-
for (let item of nodeIds) {
|
|
28
|
-
if (nodeIdSet.has(item.toString()))
|
|
29
|
-
continue;
|
|
30
|
-
nodeIdSet.add(item.toString());
|
|
31
|
-
this._nodesToBrowse.push(item);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
browse(client) {
|
|
36
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
if (this.isFinish())
|
|
38
|
-
return;
|
|
39
|
-
yield this.browseOnce(client);
|
|
40
|
-
yield this.browse(client);
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
browseOnce(client) {
|
|
44
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
if (this._nodesToBrowse.length != 0) {
|
|
46
|
-
yield this._browseNodes(client);
|
|
47
|
-
}
|
|
48
|
-
else if (this._continuationPointToBrowse.length != 0) {
|
|
49
|
-
yield this._browseContinuationPoints(client);
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
results() {
|
|
54
|
-
let results = [];
|
|
55
|
-
for (let item of this._readResults) {
|
|
56
|
-
results.push({
|
|
57
|
-
nodeId: (0, common_1.parseUaNodeId)(item[0]),
|
|
58
|
-
references: item[1]
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
this._readResults.clear();
|
|
62
|
-
return results;
|
|
63
|
-
}
|
|
64
|
-
isFinish() {
|
|
65
|
-
return (this._nodesToBrowse.length == 0) && (this._continuationPointToBrowse.length == 0);
|
|
66
|
-
}
|
|
67
|
-
_browseNodes(client) {
|
|
68
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
-
var _a;
|
|
70
|
-
if (this._nodesToBrowse.length == 0)
|
|
71
|
-
return;
|
|
72
|
-
let nodesToBrowse = this._nodesToBrowse.splice(0, this._maxNodesPerBrowse);
|
|
73
|
-
let browseDescriptions = [];
|
|
74
|
-
for (let item of nodesToBrowse) {
|
|
75
|
-
let browseDescription = new common_1.UaBrowseDescription(item, opcua_webapi_1.BrowseDirection.Forward, this._referenceType, true, this._nodeClassToReturn, 63);
|
|
76
|
-
browseDescriptions.push(browseDescription);
|
|
77
|
-
}
|
|
78
|
-
let results = yield client.browse(browseDescriptions, this._maxReferencesPerNode);
|
|
79
|
-
for (let i = 0; i < nodesToBrowse.length; ++i) {
|
|
80
|
-
let currentNodeId = nodesToBrowse[i];
|
|
81
|
-
let currentResult = results[i];
|
|
82
|
-
if (currentResult.statusCode.isNotGood())
|
|
83
|
-
throw new common_1.UaError(currentResult.statusCode);
|
|
84
|
-
let currentReferences = this._readResults.get(currentNodeId.toString());
|
|
85
|
-
if (!currentReferences) {
|
|
86
|
-
currentReferences = [];
|
|
87
|
-
this._readResults.set(currentNodeId.toString(), currentReferences);
|
|
88
|
-
}
|
|
89
|
-
let newReferences = [];
|
|
90
|
-
for (let item of currentResult.references) {
|
|
91
|
-
let nodeId = item.nodeId.getNodeId();
|
|
92
|
-
let typeDefinition = (_a = item.typeDefinition) === null || _a === void 0 ? void 0 : _a.getNodeId();
|
|
93
|
-
if (null == nodeId || null === typeDefinition)
|
|
94
|
-
continue;
|
|
95
|
-
let reference = new common_1.UaReference(nodeId, (item.nodeClass) ? item.nodeClass : opcua_webapi_1.NodeClass.Unspecified, item.browseName ? item.browseName : "", item.displayName ? item.displayName : common_1.UaLocalizedText.nullText, item.referenceTypeId ? item.referenceTypeId : common_1.UaNodeId.nullNodeId, (typeDefinition) ? typeDefinition : common_1.UaNodeId.nullNodeId);
|
|
96
|
-
currentReferences.push(reference);
|
|
97
|
-
newReferences.push(reference);
|
|
98
|
-
}
|
|
99
|
-
if (currentResult.continuationPoint) {
|
|
100
|
-
this._continuationPointToBrowse.push({
|
|
101
|
-
nodeId: currentNodeId,
|
|
102
|
-
continuationPoint: currentResult.continuationPoint
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
if (this._returnDescription)
|
|
106
|
-
yield this._readDescriptions(client, newReferences);
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
_browseContinuationPoints(client) {
|
|
111
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
-
var _a;
|
|
113
|
-
let cpsToBrowse = this._continuationPointToBrowse.splice(0, this._maxNodesPerBrowse);
|
|
114
|
-
let continuationPoints = [];
|
|
115
|
-
for (let item of cpsToBrowse) {
|
|
116
|
-
continuationPoints.push(item.continuationPoint);
|
|
117
|
-
}
|
|
118
|
-
let results = yield client.browseNext(continuationPoints, false);
|
|
119
|
-
for (let i = 0; i < cpsToBrowse.length; ++i) {
|
|
120
|
-
let currentNodeId = cpsToBrowse[i].nodeId;
|
|
121
|
-
let currentResult = results[i];
|
|
122
|
-
if (currentResult.statusCode.isNotGood())
|
|
123
|
-
throw new common_1.UaError(currentResult.statusCode);
|
|
124
|
-
let newReferences = [];
|
|
125
|
-
for (let item of currentResult.references) {
|
|
126
|
-
let nodeId = item.nodeId.getNodeId();
|
|
127
|
-
let typeDefinition = (_a = item.typeDefinition) === null || _a === void 0 ? void 0 : _a.getNodeId();
|
|
128
|
-
if (null == nodeId || null === typeDefinition)
|
|
129
|
-
continue;
|
|
130
|
-
let currentReferences = this._readResults.get(currentNodeId.toString());
|
|
131
|
-
if (!currentReferences) {
|
|
132
|
-
currentReferences = [];
|
|
133
|
-
this._readResults.set(currentNodeId.toString(), currentReferences);
|
|
134
|
-
}
|
|
135
|
-
let reference = new common_1.UaReference(nodeId, (item.nodeClass) ? item.nodeClass : opcua_webapi_1.NodeClass.Unspecified, item.browseName ? item.browseName : "", item.displayName ? item.displayName : common_1.UaLocalizedText.nullText, item.referenceTypeId ? item.referenceTypeId : common_1.UaNodeId.nullNodeId, (typeDefinition) ? typeDefinition : common_1.UaNodeId.nullNodeId);
|
|
136
|
-
currentReferences.push(reference);
|
|
137
|
-
newReferences.push(reference);
|
|
138
|
-
}
|
|
139
|
-
if (currentResult.continuationPoint) {
|
|
140
|
-
this._continuationPointToBrowse.push({
|
|
141
|
-
nodeId: currentNodeId,
|
|
142
|
-
continuationPoint: currentResult.continuationPoint
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
if (this._returnDescription)
|
|
146
|
-
yield this._readDescriptions(client, newReferences);
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
_readDescriptions(client, references) {
|
|
151
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
152
|
-
if (references.length === 0)
|
|
153
|
-
return;
|
|
154
|
-
let nodesToRead = [];
|
|
155
|
-
for (let item of references) {
|
|
156
|
-
nodesToRead.push(new common_1.UaReadValueId(item.nodeId, opcua_webapi_1.Attributes.Description));
|
|
157
|
-
}
|
|
158
|
-
let dataValues = yield client.read(nodesToRead);
|
|
159
|
-
for (let i = 0; i < references.length; ++i) {
|
|
160
|
-
if (dataValues[i].statusCode.isGood()) {
|
|
161
|
-
let description = dataValues[i].value.toLocalizedText();
|
|
162
|
-
if (description)
|
|
163
|
-
references[i].description = description;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
exports.UaNodeReferenceBrowser = UaNodeReferenceBrowser;
|
|
170
|
-
class UaChildBrowser extends UaNodeReferenceBrowser {
|
|
171
|
-
constructor(nodeIds, returnDescription) {
|
|
172
|
-
super(nodeIds, common_1.UaNodeId.from(common_1.ReferenceTypeIds.HierarchicalReferences), opcua_webapi_1.NodeClass.Object | opcua_webapi_1.NodeClass.ObjectType | opcua_webapi_1.NodeClass.VariableType | opcua_webapi_1.NodeClass.DataType | opcua_webapi_1.NodeClass.ReferenceType, returnDescription !== null && returnDescription !== void 0 ? returnDescription : false, 20);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
exports.UaChildBrowser = UaChildBrowser;
|
|
176
|
-
class UaLinkBrowser extends UaNodeReferenceBrowser {
|
|
177
|
-
constructor(nodeIds, returnDescription) {
|
|
178
|
-
super(nodeIds, common_1.UaNodeId.from(common_1.ReferenceTypeIds.NonHierarchicalReferences), opcua_webapi_1.NodeClass.Object, returnDescription !== null && returnDescription !== void 0 ? returnDescription : false, 20);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
exports.UaLinkBrowser = UaLinkBrowser;
|
|
15
|
+
const UaNodeBrowser_1 = require("./UaNodeBrowser");
|
|
182
16
|
class UaNodeReader {
|
|
183
|
-
constructor(returnDescription, returnVariable, returnMethod, returnAttributes, returnValue) {
|
|
17
|
+
constructor(client, returnDescription, returnVariable, returnMethod, returnAttributes, returnValue) {
|
|
18
|
+
this._client = client;
|
|
184
19
|
this._returnDescription = (returnDescription) ? returnDescription : false;
|
|
185
20
|
this._returnAttributes = (returnAttributes) ? returnAttributes : false;
|
|
186
21
|
this._returnValue = (returnValue) ? returnValue : false;
|
|
@@ -203,7 +38,7 @@ class UaNodeReader {
|
|
|
203
38
|
UaNodeReader.s_variablesNameToRead.add("EnumValues");
|
|
204
39
|
}
|
|
205
40
|
}
|
|
206
|
-
read(nodeIds
|
|
41
|
+
read(nodeIds) {
|
|
207
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
208
43
|
if (nodeIds.length == 0)
|
|
209
44
|
return [];
|
|
@@ -215,11 +50,11 @@ class UaNodeReader {
|
|
|
215
50
|
nodeIdsToRead.push(item);
|
|
216
51
|
nodeIdsSet.add(item.toString());
|
|
217
52
|
}
|
|
218
|
-
let rootReferences = yield this._readRootNodes(nodeIdsToRead
|
|
219
|
-
return yield this.readByReferences(rootReferences
|
|
53
|
+
let rootReferences = yield this._readRootNodes(nodeIdsToRead);
|
|
54
|
+
return yield this.readByReferences(rootReferences);
|
|
220
55
|
});
|
|
221
56
|
}
|
|
222
|
-
readByReferences(references
|
|
57
|
+
readByReferences(references) {
|
|
223
58
|
return __awaiter(this, void 0, void 0, function* () {
|
|
224
59
|
if (references.length == 0)
|
|
225
60
|
return [];
|
|
@@ -233,8 +68,8 @@ class UaNodeReader {
|
|
|
233
68
|
nodeIdsToBrowse.push(item.nodeId);
|
|
234
69
|
nodeIdsSet.add(item.nodeId.toString());
|
|
235
70
|
}
|
|
236
|
-
let nodeReferenceBrowser = new
|
|
237
|
-
yield nodeReferenceBrowser.browse(
|
|
71
|
+
let nodeReferenceBrowser = new UaNodeBrowser_1.UaNodeBrowser(this._client, nodeIdsToBrowse, common_1.UaNodeId.from(common_1.ReferenceTypeIds.HierarchicalReferences), this._nodeClassToReturn, false);
|
|
72
|
+
yield nodeReferenceBrowser.browse();
|
|
238
73
|
let childReferences = nodeReferenceBrowser.results();
|
|
239
74
|
let childNodesToBrowse = [];
|
|
240
75
|
for (let item of childReferences) {
|
|
@@ -250,8 +85,8 @@ class UaNodeReader {
|
|
|
250
85
|
}
|
|
251
86
|
let variableReferences = [];
|
|
252
87
|
if (childNodesToBrowse.length != 0) {
|
|
253
|
-
let childReferenceBrowser = new
|
|
254
|
-
yield childReferenceBrowser.browse(
|
|
88
|
+
let childReferenceBrowser = new UaNodeBrowser_1.UaNodeBrowser(this._client, childNodesToBrowse, common_1.UaNodeId.from(common_1.ReferenceTypeIds.HierarchicalReferences), opcua_webapi_1.NodeClass.Variable, false);
|
|
89
|
+
yield childReferenceBrowser.browse();
|
|
255
90
|
variableReferences = childReferenceBrowser.results();
|
|
256
91
|
}
|
|
257
92
|
let allReferences = [];
|
|
@@ -270,7 +105,7 @@ class UaNodeReader {
|
|
|
270
105
|
;
|
|
271
106
|
}
|
|
272
107
|
let nodesMap = new Map();
|
|
273
|
-
yield this._readNodes(allReferences, nodesMap
|
|
108
|
+
yield this._readNodes(allReferences, nodesMap);
|
|
274
109
|
for (let item of variableReferences) {
|
|
275
110
|
this._buildNodeTree(item, nodesMap);
|
|
276
111
|
}
|
|
@@ -286,7 +121,7 @@ class UaNodeReader {
|
|
|
286
121
|
return rootNodes;
|
|
287
122
|
});
|
|
288
123
|
}
|
|
289
|
-
_readRootNodes(nodeIds
|
|
124
|
+
_readRootNodes(nodeIds) {
|
|
290
125
|
return __awaiter(this, void 0, void 0, function* () {
|
|
291
126
|
let nodesToRead = [];
|
|
292
127
|
for (let item of nodeIds) {
|
|
@@ -294,7 +129,7 @@ class UaNodeReader {
|
|
|
294
129
|
nodesToRead.push(new common_1.UaReadValueId(item, opcua_webapi_1.Attributes.BrowseName));
|
|
295
130
|
nodesToRead.push(new common_1.UaReadValueId(item, opcua_webapi_1.Attributes.DisplayName));
|
|
296
131
|
}
|
|
297
|
-
let dataValues = yield
|
|
132
|
+
let dataValues = yield this._client.read(nodesToRead);
|
|
298
133
|
let references = [];
|
|
299
134
|
let typeDefinitionsToRead = [];
|
|
300
135
|
for (let i = 0; i < nodeIds.length; ++i) {
|
|
@@ -327,7 +162,7 @@ class UaNodeReader {
|
|
|
327
162
|
let browseDescription = new common_1.UaBrowseDescription(item.nodeId, opcua_webapi_1.BrowseDirection.Forward, common_1.UaNodeId.from(common_1.ReferenceTypeIds.HasTypeDefinition), false, opcua_webapi_1.NodeClass.ObjectType, 0);
|
|
328
163
|
browseDescriptions.push(browseDescription);
|
|
329
164
|
}
|
|
330
|
-
let results = yield
|
|
165
|
+
let results = yield this._client.browse(browseDescriptions);
|
|
331
166
|
for (let i = 0; i < browseDescriptions.length; ++i) {
|
|
332
167
|
if (results[i].statusCode.isNotGood())
|
|
333
168
|
throw new common_1.UaError(results[i].statusCode);
|
|
@@ -339,7 +174,7 @@ class UaNodeReader {
|
|
|
339
174
|
return references;
|
|
340
175
|
});
|
|
341
176
|
}
|
|
342
|
-
_readNodes(references, nodes
|
|
177
|
+
_readNodes(references, nodes) {
|
|
343
178
|
return __awaiter(this, void 0, void 0, function* () {
|
|
344
179
|
if (references.length == 0)
|
|
345
180
|
return;
|
|
@@ -348,14 +183,14 @@ class UaNodeReader {
|
|
|
348
183
|
refrencesToRead.push(references.splice(0, 100));
|
|
349
184
|
}
|
|
350
185
|
for (let item of refrencesToRead) {
|
|
351
|
-
yield this._readTypes(item, nodes
|
|
352
|
-
yield this._readObjects(item, nodes
|
|
353
|
-
yield this._readVariables(item, nodes
|
|
354
|
-
yield this._readMethods(item, nodes
|
|
186
|
+
yield this._readTypes(item, nodes);
|
|
187
|
+
yield this._readObjects(item, nodes);
|
|
188
|
+
yield this._readVariables(item, nodes);
|
|
189
|
+
yield this._readMethods(item, nodes);
|
|
355
190
|
}
|
|
356
191
|
});
|
|
357
192
|
}
|
|
358
|
-
_readTypes(references, nodes
|
|
193
|
+
_readTypes(references, nodes) {
|
|
359
194
|
return __awaiter(this, void 0, void 0, function* () {
|
|
360
195
|
let typesToRead = [];
|
|
361
196
|
let needReadAttributes = this._returnAttributes || this._returnDescription;
|
|
@@ -380,7 +215,7 @@ class UaNodeReader {
|
|
|
380
215
|
nodesToRead.push(new common_1.UaReadValueId(item.nodeId, opcua_webapi_1.Attributes.ValueRank));
|
|
381
216
|
}
|
|
382
217
|
}
|
|
383
|
-
dataValues = yield
|
|
218
|
+
dataValues = yield this._client.read(nodesToRead);
|
|
384
219
|
}
|
|
385
220
|
for (let i = 0; i < typesToRead.length; ++i) {
|
|
386
221
|
let isAbstract = false;
|
|
@@ -435,7 +270,7 @@ class UaNodeReader {
|
|
|
435
270
|
}
|
|
436
271
|
});
|
|
437
272
|
}
|
|
438
|
-
_readObjects(references, nodes
|
|
273
|
+
_readObjects(references, nodes) {
|
|
439
274
|
return __awaiter(this, void 0, void 0, function* () {
|
|
440
275
|
let objectsToRead = [];
|
|
441
276
|
for (let item of references) {
|
|
@@ -456,7 +291,7 @@ class UaNodeReader {
|
|
|
456
291
|
}
|
|
457
292
|
let dataValues = [];
|
|
458
293
|
if (nodesToRead.length != 0) {
|
|
459
|
-
dataValues = yield
|
|
294
|
+
dataValues = yield this._client.read(nodesToRead);
|
|
460
295
|
}
|
|
461
296
|
for (let i = 0; i < objectsToRead.length; ++i) {
|
|
462
297
|
let dataIndex = (this._returnAttributes && this._returnDescription) ? i * 2 : i;
|
|
@@ -483,7 +318,7 @@ class UaNodeReader {
|
|
|
483
318
|
}
|
|
484
319
|
});
|
|
485
320
|
}
|
|
486
|
-
_readVariables(references, nodes
|
|
321
|
+
_readVariables(references, nodes) {
|
|
487
322
|
return __awaiter(this, void 0, void 0, function* () {
|
|
488
323
|
let variablesToRead = [];
|
|
489
324
|
let nodeIds = [];
|
|
@@ -497,7 +332,7 @@ class UaNodeReader {
|
|
|
497
332
|
return;
|
|
498
333
|
let results = [];
|
|
499
334
|
if (this._returnAttributes) {
|
|
500
|
-
results = yield
|
|
335
|
+
results = yield this._client.readVariableAttributes(nodeIds);
|
|
501
336
|
}
|
|
502
337
|
let variablesToReadValue = [];
|
|
503
338
|
for (let i = 0; i < variablesToRead.length; ++i) {
|
|
@@ -518,7 +353,7 @@ class UaNodeReader {
|
|
|
518
353
|
for (let item of variablesToReadValue) {
|
|
519
354
|
valuesToRead.push(item.nodeId);
|
|
520
355
|
}
|
|
521
|
-
let values = yield
|
|
356
|
+
let values = yield this._client.readValues(valuesToRead);
|
|
522
357
|
for (let i = 0; i < valuesToRead.length; ++i) {
|
|
523
358
|
let variableNode = nodes.get(valuesToRead[i].toString());
|
|
524
359
|
variableNode.dataValue = values[i];
|
|
@@ -526,7 +361,7 @@ class UaNodeReader {
|
|
|
526
361
|
}
|
|
527
362
|
});
|
|
528
363
|
}
|
|
529
|
-
_readMethods(references, nodes
|
|
364
|
+
_readMethods(references, nodes) {
|
|
530
365
|
return __awaiter(this, void 0, void 0, function* () {
|
|
531
366
|
let methodsToRead = [];
|
|
532
367
|
for (let item of references) {
|
|
@@ -544,7 +379,7 @@ class UaNodeReader {
|
|
|
544
379
|
}
|
|
545
380
|
let dataValues = [];
|
|
546
381
|
if (nodesToRead.length != 0) {
|
|
547
|
-
dataValues = yield
|
|
382
|
+
dataValues = yield this._client.read(nodesToRead);
|
|
548
383
|
}
|
|
549
384
|
for (let i = 0; i < methodsToRead.length; ++i) {
|
|
550
385
|
let methodNode = new common_1.UaMethod(methodsToRead[i].nodeId, methodsToRead[i].browseName, methodsToRead[i].displayName);
|
|
@@ -613,15 +448,15 @@ exports.UaNodeReader = UaNodeReader;
|
|
|
613
448
|
UaNodeReader.s_variableTypeWithoutMember = null;
|
|
614
449
|
UaNodeReader.s_variablesNameToRead = null;
|
|
615
450
|
class UaObjectReader extends UaNodeReader {
|
|
616
|
-
constructor(returnDescription, returnValue) {
|
|
617
|
-
super(returnDescription !== null && returnDescription !== void 0 ? returnDescription : false, true, true, true, returnValue !== null && returnValue !== void 0 ? returnValue : false);
|
|
451
|
+
constructor(client, returnDescription, returnValue) {
|
|
452
|
+
super(client, returnDescription !== null && returnDescription !== void 0 ? returnDescription : false, true, true, true, returnValue !== null && returnValue !== void 0 ? returnValue : false);
|
|
618
453
|
}
|
|
619
|
-
read(nodeIds
|
|
454
|
+
read(nodeIds) {
|
|
620
455
|
const _super = Object.create(null, {
|
|
621
456
|
read: { get: () => super.read }
|
|
622
457
|
});
|
|
623
458
|
return __awaiter(this, void 0, void 0, function* () {
|
|
624
|
-
let nodes = yield _super.read.call(this, nodeIds
|
|
459
|
+
let nodes = yield _super.read.call(this, nodeIds);
|
|
625
460
|
let objectNodes = [];
|
|
626
461
|
for (let item of nodes) {
|
|
627
462
|
if (item.nodeClass == opcua_webapi_1.NodeClass.Object) {
|
|
@@ -634,15 +469,15 @@ class UaObjectReader extends UaNodeReader {
|
|
|
634
469
|
}
|
|
635
470
|
exports.UaObjectReader = UaObjectReader;
|
|
636
471
|
class UaTypeReader extends UaNodeReader {
|
|
637
|
-
constructor() {
|
|
638
|
-
super(true, true, true, true, false);
|
|
472
|
+
constructor(client) {
|
|
473
|
+
super(client, true, true, true, true, false);
|
|
639
474
|
}
|
|
640
|
-
read(nodeIds
|
|
475
|
+
read(nodeIds) {
|
|
641
476
|
const _super = Object.create(null, {
|
|
642
477
|
read: { get: () => super.read }
|
|
643
478
|
});
|
|
644
479
|
return __awaiter(this, void 0, void 0, function* () {
|
|
645
|
-
let nodes = yield _super.read.call(this, nodeIds
|
|
480
|
+
let nodes = yield _super.read.call(this, nodeIds);
|
|
646
481
|
let typeNodes = [];
|
|
647
482
|
for (let item of nodes) {
|
|
648
483
|
if (item.nodeClass == opcua_webapi_1.NodeClass.ObjectType ||
|
|
@@ -13,17 +13,18 @@ exports.UaObjectTypeDictionary = void 0;
|
|
|
13
13
|
const opcua_webapi_1 = require("opcua-webapi");
|
|
14
14
|
const common_1 = require("../../common");
|
|
15
15
|
const UaNodeReader_1 = require("./UaNodeReader");
|
|
16
|
+
const UaNodeBrowser_1 = require("./UaNodeBrowser");
|
|
16
17
|
class UaObjectTypeDictionary {
|
|
17
|
-
constructor(
|
|
18
|
+
constructor(client) {
|
|
19
|
+
this._client = client;
|
|
18
20
|
this._objectTypes = new Map;
|
|
19
|
-
this._returnAllAttributes = (null == simpleMode) ? false : !simpleMode;
|
|
20
21
|
let baseObjectTypeId = common_1.UaNodeId.from(common_1.ObjectTypeIds.BaseObjectType);
|
|
21
22
|
this._objectTypes.set(baseObjectTypeId.toString(), new common_1.UaObjectType(baseObjectTypeId, "BaseObjectType", new common_1.UaLocalizedText("BaseObjectType"), false));
|
|
22
23
|
}
|
|
23
|
-
read(
|
|
24
|
+
read() {
|
|
24
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
let browser = new
|
|
26
|
-
yield this._read(browser
|
|
26
|
+
let browser = new UaNodeBrowser_1.UaTypeBrowser(this._client, [common_1.UaNodeId.from(common_1.ObjectTypeIds.BaseObjectType)]);
|
|
27
|
+
yield this._read(browser);
|
|
27
28
|
});
|
|
28
29
|
}
|
|
29
30
|
getObjectType(nodeId) {
|
|
@@ -33,10 +34,10 @@ class UaObjectTypeDictionary {
|
|
|
33
34
|
getObjectTypes() {
|
|
34
35
|
return [...this._objectTypes.values()];
|
|
35
36
|
}
|
|
36
|
-
_read(browser
|
|
37
|
+
_read(browser) {
|
|
37
38
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
39
|
// Browse child type
|
|
39
|
-
yield browser.browse(
|
|
40
|
+
yield browser.browse();
|
|
40
41
|
let results = browser.results();
|
|
41
42
|
let referencesToRead = [];
|
|
42
43
|
for (let item of results) {
|
|
@@ -47,8 +48,8 @@ class UaObjectTypeDictionary {
|
|
|
47
48
|
return;
|
|
48
49
|
// Read child type
|
|
49
50
|
let nodeIdsToBrowse = [];
|
|
50
|
-
let nodeReader = new UaNodeReader_1.UaNodeReader(this.
|
|
51
|
-
let nodes = yield nodeReader.readByReferences(referencesToRead
|
|
51
|
+
let nodeReader = new UaNodeReader_1.UaNodeReader(this._client, false, false, false, false, false);
|
|
52
|
+
let nodes = yield nodeReader.readByReferences(referencesToRead);
|
|
52
53
|
for (let node of nodes) {
|
|
53
54
|
if (opcua_webapi_1.NodeClass.ObjectType != node.nodeClass)
|
|
54
55
|
continue;
|
|
@@ -68,8 +69,8 @@ class UaObjectTypeDictionary {
|
|
|
68
69
|
return;
|
|
69
70
|
yield this.__delay(20);
|
|
70
71
|
// Continue to browse and read child type
|
|
71
|
-
let childBrowser = new
|
|
72
|
-
yield this._read(childBrowser
|
|
72
|
+
let childBrowser = new UaNodeBrowser_1.UaTypeBrowser(this._client, nodeIdsToBrowse);
|
|
73
|
+
yield this._read(childBrowser);
|
|
73
74
|
});
|
|
74
75
|
}
|
|
75
76
|
__delay(ms) {
|
|
@@ -13,17 +13,18 @@ exports.UaReferenceTypeDictionary = void 0;
|
|
|
13
13
|
const opcua_webapi_1 = require("opcua-webapi");
|
|
14
14
|
const common_1 = require("../../common");
|
|
15
15
|
const UaNodeReader_1 = require("./UaNodeReader");
|
|
16
|
+
const UaNodeBrowser_1 = require("./UaNodeBrowser");
|
|
16
17
|
class UaReferenceTypeDictionary {
|
|
17
|
-
constructor(
|
|
18
|
+
constructor(client) {
|
|
19
|
+
this._client = client;
|
|
18
20
|
this._referenceTypes = new Map;
|
|
19
|
-
this._returnAllAttributes = (null == simpleMode) ? false : !simpleMode;
|
|
20
21
|
let referencesId = common_1.UaNodeId.from(common_1.ReferenceTypeIds.References);
|
|
21
22
|
this._referenceTypes.set(referencesId.toString(), new common_1.UaReferenceType(referencesId, "References", new common_1.UaLocalizedText("References"), true, common_1.UaLocalizedText.nullText, true));
|
|
22
23
|
}
|
|
23
|
-
read(
|
|
24
|
+
read() {
|
|
24
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
let browser = new
|
|
26
|
-
yield this._read(browser
|
|
26
|
+
let browser = new UaNodeBrowser_1.UaTypeBrowser(this._client, [common_1.UaNodeId.from(common_1.ReferenceTypeIds.References)]);
|
|
27
|
+
yield this._read(browser);
|
|
27
28
|
});
|
|
28
29
|
}
|
|
29
30
|
getReferenceType(nodeId) {
|
|
@@ -33,10 +34,10 @@ class UaReferenceTypeDictionary {
|
|
|
33
34
|
getReferenceTypes() {
|
|
34
35
|
return [...this._referenceTypes.values()];
|
|
35
36
|
}
|
|
36
|
-
_read(browser
|
|
37
|
+
_read(browser) {
|
|
37
38
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
39
|
// Browse child type
|
|
39
|
-
yield browser.browse(
|
|
40
|
+
yield browser.browse();
|
|
40
41
|
let results = browser.results();
|
|
41
42
|
let referencesToRead = [];
|
|
42
43
|
for (let item of results) {
|
|
@@ -47,8 +48,8 @@ class UaReferenceTypeDictionary {
|
|
|
47
48
|
return;
|
|
48
49
|
// Read child type
|
|
49
50
|
let nodeIdsToBrowse = [];
|
|
50
|
-
let nodeReader = new UaNodeReader_1.UaNodeReader(this.
|
|
51
|
-
let nodes = yield nodeReader.readByReferences(referencesToRead
|
|
51
|
+
let nodeReader = new UaNodeReader_1.UaNodeReader(this._client, false, false, false, false, false);
|
|
52
|
+
let nodes = yield nodeReader.readByReferences(referencesToRead);
|
|
52
53
|
for (let node of nodes) {
|
|
53
54
|
if (opcua_webapi_1.NodeClass.ReferenceType != node.nodeClass)
|
|
54
55
|
continue;
|
|
@@ -68,8 +69,8 @@ class UaReferenceTypeDictionary {
|
|
|
68
69
|
return;
|
|
69
70
|
yield this.__delay(20);
|
|
70
71
|
// Continue to browse and read child type
|
|
71
|
-
let childBrowser = new
|
|
72
|
-
yield this._read(childBrowser
|
|
72
|
+
let childBrowser = new UaNodeBrowser_1.UaTypeBrowser(this._client, nodeIdsToBrowse);
|
|
73
|
+
yield this._read(childBrowser);
|
|
73
74
|
});
|
|
74
75
|
}
|
|
75
76
|
__delay(ms) {
|
|
@@ -17,4 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./UaDataTypeDictionary"), exports);
|
|
18
18
|
__exportStar(require("./UaObjectTypeDictionary"), exports);
|
|
19
19
|
__exportStar(require("./UaReferenceTypeDictionary"), exports);
|
|
20
|
+
__exportStar(require("./UaNodeBrowser"), exports);
|
|
20
21
|
__exportStar(require("./UaNodeReader"), exports);
|
|
22
|
+
__exportStar(require("./UaModelling"), exports);
|
|
@@ -6,8 +6,8 @@ const types_1 = require("../types");
|
|
|
6
6
|
const _1 = require(".");
|
|
7
7
|
const structure_1 = require("../structure");
|
|
8
8
|
class UaDataType extends _1.UaDefintionNode {
|
|
9
|
-
constructor(nodeId, browseName, displayName, isAbstract
|
|
10
|
-
super(nodeId, browseName, displayName, isAbstract
|
|
9
|
+
constructor(nodeId, browseName, displayName, isAbstract) {
|
|
10
|
+
super(nodeId, browseName, displayName, isAbstract);
|
|
11
11
|
this._valueType = 0;
|
|
12
12
|
this._enumValues = null;
|
|
13
13
|
}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UaInstanceNode = exports.UaDefintionNode = exports.UaNode = void 0;
|
|
4
|
+
const types_1 = require("../types");
|
|
5
|
+
const _1 = require(".");
|
|
4
6
|
class UaNode {
|
|
5
|
-
constructor(nodeId, browseName, displayName
|
|
7
|
+
constructor(nodeId, browseName, displayName) {
|
|
6
8
|
this._nodeId = nodeId;
|
|
7
9
|
this._browseName = browseName;
|
|
8
10
|
this._displayName = displayName;
|
|
9
11
|
this._description = null;
|
|
10
|
-
this._writeMask =
|
|
12
|
+
this._writeMask = null;
|
|
11
13
|
this._parent = null;
|
|
12
14
|
this._children = [];
|
|
13
15
|
this._refToParent = null;
|
|
@@ -24,6 +26,9 @@ class UaNode {
|
|
|
24
26
|
get writeMask() {
|
|
25
27
|
return this._writeMask;
|
|
26
28
|
}
|
|
29
|
+
set writeMask(writeMask) {
|
|
30
|
+
this._writeMask = writeMask;
|
|
31
|
+
}
|
|
27
32
|
get description() {
|
|
28
33
|
return this._description;
|
|
29
34
|
}
|
|
@@ -39,8 +44,8 @@ class UaNode {
|
|
|
39
44
|
}
|
|
40
45
|
exports.UaNode = UaNode;
|
|
41
46
|
class UaDefintionNode extends UaNode {
|
|
42
|
-
constructor(nodeId, browseName, displayName, isAbstract
|
|
43
|
-
super(nodeId, browseName, displayName
|
|
47
|
+
constructor(nodeId, browseName, displayName, isAbstract) {
|
|
48
|
+
super(nodeId, browseName, displayName);
|
|
44
49
|
this._isAbstract = isAbstract;
|
|
45
50
|
}
|
|
46
51
|
get isAbstract() {
|
|
@@ -80,8 +85,9 @@ class UaDefintionNode extends UaNode {
|
|
|
80
85
|
}
|
|
81
86
|
exports.UaDefintionNode = UaDefintionNode;
|
|
82
87
|
class UaInstanceNode extends UaNode {
|
|
83
|
-
constructor(nodeId, browseName, displayName
|
|
84
|
-
super(nodeId, browseName, displayName
|
|
88
|
+
constructor(nodeId, browseName, displayName) {
|
|
89
|
+
super(nodeId, browseName, displayName);
|
|
90
|
+
this._modellingRule = types_1.UaModellingRule.None;
|
|
85
91
|
}
|
|
86
92
|
getMembers(nodeClass) {
|
|
87
93
|
let ret = [];
|
|
@@ -92,5 +98,20 @@ class UaInstanceNode extends UaNode {
|
|
|
92
98
|
}
|
|
93
99
|
return ret;
|
|
94
100
|
}
|
|
101
|
+
get modellingRule() {
|
|
102
|
+
return this._modellingRule;
|
|
103
|
+
}
|
|
104
|
+
setModellingRule(modellingRuleId) {
|
|
105
|
+
if (modellingRuleId.equal(types_1.UaNodeId.from(_1.ObjectIds.ModellingRule_Mandatory)))
|
|
106
|
+
this._modellingRule = types_1.UaModellingRule.Mandatory;
|
|
107
|
+
else if (modellingRuleId.equal(types_1.UaNodeId.from(_1.ObjectIds.ModellingRule_Optional)))
|
|
108
|
+
this._modellingRule = types_1.UaModellingRule.Optional;
|
|
109
|
+
else if (modellingRuleId.equal(types_1.UaNodeId.from(_1.ObjectIds.ModellingRule_OptionalPlaceholder)))
|
|
110
|
+
this._modellingRule = types_1.UaModellingRule.PlaceHolder;
|
|
111
|
+
else if (modellingRuleId.equal(types_1.UaNodeId.from(_1.ObjectIds.ModellingRule_MandatoryPlaceholder)))
|
|
112
|
+
this._modellingRule = types_1.UaModellingRule.PlaceHolder;
|
|
113
|
+
else
|
|
114
|
+
this._modellingRule = types_1.UaModellingRule.None;
|
|
115
|
+
}
|
|
95
116
|
}
|
|
96
117
|
exports.UaInstanceNode = UaInstanceNode;
|
|
@@ -6,6 +6,7 @@ const _1 = require(".");
|
|
|
6
6
|
class UaObjectType extends _1.UaDefintionNode {
|
|
7
7
|
constructor(nodeId, browseName, displayName, isAbstract) {
|
|
8
8
|
super(nodeId, browseName, displayName, isAbstract);
|
|
9
|
+
this._isObjectMemberRead = false;
|
|
9
10
|
}
|
|
10
11
|
get nodeClass() {
|
|
11
12
|
return opcua_webapi_1.NodeClass.ObjectType;
|
|
@@ -40,6 +41,12 @@ class UaObjectType extends _1.UaDefintionNode {
|
|
|
40
41
|
}
|
|
41
42
|
return ret;
|
|
42
43
|
}
|
|
44
|
+
get isObjectMemberRead() {
|
|
45
|
+
return this._isObjectMemberRead;
|
|
46
|
+
}
|
|
47
|
+
set isObjectMemberRead(value) {
|
|
48
|
+
this._isObjectMemberRead = value;
|
|
49
|
+
}
|
|
43
50
|
toJson() {
|
|
44
51
|
let children = [];
|
|
45
52
|
for (let item of this._children) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UaModellingRule = void 0;
|
|
4
|
+
var UaModellingRule;
|
|
5
|
+
(function (UaModellingRule) {
|
|
6
|
+
UaModellingRule[UaModellingRule["None"] = 0] = "None";
|
|
7
|
+
UaModellingRule[UaModellingRule["Mandatory"] = 1] = "Mandatory";
|
|
8
|
+
UaModellingRule[UaModellingRule["Optional"] = 2] = "Optional";
|
|
9
|
+
UaModellingRule[UaModellingRule["PlaceHolder"] = 3] = "PlaceHolder";
|
|
10
|
+
})(UaModellingRule || (exports.UaModellingRule = UaModellingRule = {}));
|
|
@@ -14,7 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./UaTypes"), exports);
|
|
18
17
|
__exportStar(require("./UaDataValue"), exports);
|
|
19
18
|
__exportStar(require("./UaError"), exports);
|
|
20
19
|
__exportStar(require("./UaExpandedNodeId"), exports);
|
|
@@ -34,4 +33,5 @@ __exportStar(require("./UaBrowseMask"), exports);
|
|
|
34
33
|
__exportStar(require("./UaValueRank"), exports);
|
|
35
34
|
__exportStar(require("./UaWriteMask"), exports);
|
|
36
35
|
__exportStar(require("./UaReference"), exports);
|
|
36
|
+
__exportStar(require("./UaModellingRule"), exports);
|
|
37
37
|
__exportStar(require("./UaEventNotifier"), exports);
|