opcua-webapi-ts 1.1.23 → 1.1.24

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.
Files changed (34) hide show
  1. package/dist/cjs/client/utils/UaDataTypeDictionary.js +1 -1
  2. package/dist/cjs/client/utils/UaModelling.js +2 -2
  3. package/dist/cjs/client/utils/UaNodeBrowser.js +7 -36
  4. package/dist/cjs/client/utils/UaNodeReader.js +102 -144
  5. package/dist/cjs/client/utils/UaNodeSerializer.js +166 -0
  6. package/dist/cjs/client/utils/UaObjectTypeDictionary.js +1 -1
  7. package/dist/cjs/client/utils/UaReferenceTypeDictionary.js +1 -1
  8. package/dist/cjs/client/utils/index.js +1 -0
  9. package/dist/cjs/common/nodes/UaMethod.js +22 -0
  10. package/dist/cjs/common/nodes/UaNode.js +0 -13
  11. package/dist/cjs/common/nodes/UaObject.js +3 -10
  12. package/dist/cjs/common/nodes/UaObjectType.js +3 -12
  13. package/dist/cjs/common/nodes/UaVariable.js +12 -5
  14. package/dist/client/utils/UaDataTypeDictionary.js +1 -1
  15. package/dist/client/utils/UaModelling.js +2 -2
  16. package/dist/client/utils/UaNodeBrowser.d.ts +3 -8
  17. package/dist/client/utils/UaNodeBrowser.js +7 -36
  18. package/dist/client/utils/UaNodeReader.d.ts +15 -18
  19. package/dist/client/utils/UaNodeReader.js +102 -144
  20. package/dist/client/utils/UaNodeSerializer.d.ts +14 -0
  21. package/dist/client/utils/UaNodeSerializer.js +166 -0
  22. package/dist/client/utils/UaObjectTypeDictionary.js +1 -1
  23. package/dist/client/utils/UaReferenceTypeDictionary.js +1 -1
  24. package/dist/client/utils/index.d.ts +1 -0
  25. package/dist/client/utils/index.js +1 -0
  26. package/dist/common/nodes/UaMethod.d.ts +1 -0
  27. package/dist/common/nodes/UaMethod.js +22 -0
  28. package/dist/common/nodes/UaNode.d.ts +0 -5
  29. package/dist/common/nodes/UaNode.js +0 -13
  30. package/dist/common/nodes/UaObject.js +3 -10
  31. package/dist/common/nodes/UaObjectType.js +3 -12
  32. package/dist/common/nodes/UaVariable.d.ts +4 -1
  33. package/dist/common/nodes/UaVariable.js +12 -5
  34. package/package.json +1 -1
@@ -50,7 +50,7 @@ class UaDataTypeDictionary {
50
50
  return;
51
51
  // Read child type
52
52
  let nodeIdsToBrowse = [];
53
- let nodeReader = new __1.UaNodeReader(this._client, false, needToReadEnumValue, false, false, true);
53
+ let nodeReader = new __1.UaNodeReader(this._client, false, needToReadEnumValue, false, common_1.UaNodeId.from(common_1.ReferenceTypeIds.HasProperty), false, false, false, false, false);
54
54
  let nodes = yield nodeReader.readByReferences(referencesToRead);
55
55
  for (let node of nodes) {
56
56
  if (opcua_webapi_1.NodeClass.DataType != node.nodeClass)
@@ -98,7 +98,7 @@ class UaModelling {
98
98
  return null;
99
99
  if (objectType.isObjectMemberRead)
100
100
  return objectType;
101
- let typeMemberBrowser = new __1.UaNodeBrowser(this._client, [objectType.nodeId], common_1.UaNodeId.from(common_1.ReferenceTypeIds.Aggregates), opcua_webapi_1.NodeClass.Object, false);
101
+ let typeMemberBrowser = new __1.UaNodeBrowser(this._client, [objectType.nodeId], common_1.UaNodeId.from(common_1.ReferenceTypeIds.Aggregates), opcua_webapi_1.NodeClass.Object);
102
102
  yield typeMemberBrowser.browse();
103
103
  let browseMemberResults = typeMemberBrowser.results();
104
104
  let instanceNodes = new Map();
@@ -113,7 +113,7 @@ class UaModelling {
113
113
  for (let node of instanceNodes) {
114
114
  memberObjectIds.push(node[1].nodeId);
115
115
  }
116
- let modellingRuleBrowser = new __1.UaNodeBrowser(this._client, memberObjectIds, common_1.UaNodeId.from(common_1.ReferenceTypeIds.HasModellingRule), opcua_webapi_1.NodeClass.Object, false);
116
+ let modellingRuleBrowser = new __1.UaNodeBrowser(this._client, memberObjectIds, common_1.UaNodeId.from(common_1.ReferenceTypeIds.HasModellingRule), opcua_webapi_1.NodeClass.Object);
117
117
  yield modellingRuleBrowser.browse();
118
118
  let browseModellingRuleResults = modellingRuleBrowser.results();
119
119
  for (let item of browseModellingRuleResults) {
@@ -9,17 +9,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.UaTypeBrowser = exports.UaLinkBrowser = exports.UaObjectBrowser = exports.UaNodeBrowser = void 0;
12
+ exports.UaTypeBrowser = exports.UaObjectBrowser = exports.UaNodeBrowser = void 0;
13
13
  const opcua_webapi_1 = require("opcua-webapi");
14
14
  const common_1 = require("../../common");
15
15
  class UaNodeBrowser {
16
- constructor(client, nodeIds, referenceType, nodeClassToReturn, returnDescription, maxNodesPerBrowse, maxReferencesPerNode) {
16
+ constructor(client, nodeIds, referenceType, nodeClassToReturn, maxNodesPerBrowse, maxReferencesPerNode) {
17
17
  this._client = client;
18
18
  this._nodesToBrowse = [];
19
19
  this._referenceType = referenceType;
20
20
  this._nodeClassToReturn = nodeClassToReturn;
21
21
  this._continuationPointToBrowse = [];
22
- this._returnDescription = returnDescription !== null && returnDescription !== void 0 ? returnDescription : false;
23
22
  this._maxNodesPerBrowse = (null == maxNodesPerBrowse || maxNodesPerBrowse <= 0) ? 50 : maxNodesPerBrowse;
24
23
  this._maxReferencesPerNode = (null == maxReferencesPerNode || maxReferencesPerNode < 0) ? 50 : maxReferencesPerNode;
25
24
  this._readResults = new Map();
@@ -63,7 +62,7 @@ class UaNodeBrowser {
63
62
  return results;
64
63
  }
65
64
  isFinish() {
66
- return (this._nodesToBrowse.length == 0) && (this._continuationPointToBrowse.length == 0);
65
+ return ((this._nodesToBrowse.length == 0) && (this._continuationPointToBrowse.length == 0)) || 0 == this._nodeClassToReturn;
67
66
  }
68
67
  _browseNodes() {
69
68
  return __awaiter(this, void 0, void 0, function* () {
@@ -101,8 +100,6 @@ class UaNodeBrowser {
101
100
  continuationPoint: currentResult.continuationPoint
102
101
  });
103
102
  }
104
- if (this._returnDescription)
105
- yield this._readDescriptions(newReferences);
106
103
  }
107
104
  });
108
105
  }
@@ -141,46 +138,20 @@ class UaNodeBrowser {
141
138
  continuationPoint: currentResult.continuationPoint
142
139
  });
143
140
  }
144
- if (this._returnDescription)
145
- yield this._readDescriptions(newReferences);
146
- }
147
- });
148
- }
149
- _readDescriptions(references) {
150
- return __awaiter(this, void 0, void 0, function* () {
151
- if (references.length === 0)
152
- return;
153
- let nodesToRead = [];
154
- for (let item of references) {
155
- nodesToRead.push(new common_1.UaReadValueId(item.nodeId, opcua_webapi_1.Attributes.Description));
156
- }
157
- let dataValues = yield this._client.read(nodesToRead);
158
- for (let i = 0; i < references.length; ++i) {
159
- if (dataValues[i].statusCode.isGood()) {
160
- let description = dataValues[i].value.toLocalizedText();
161
- if (description)
162
- references[i].description = description;
163
- }
164
141
  }
165
142
  });
166
143
  }
167
144
  }
168
145
  exports.UaNodeBrowser = UaNodeBrowser;
169
146
  class UaObjectBrowser extends UaNodeBrowser {
170
- constructor(client, nodeIds, returnDescription) {
171
- super(client, nodeIds, common_1.UaNodeId.from(common_1.ReferenceTypeIds.HierarchicalReferences), opcua_webapi_1.NodeClass.Object, returnDescription !== null && returnDescription !== void 0 ? returnDescription : false, 20);
147
+ constructor(client, nodeIds, referenceType = common_1.UaNodeId.from(common_1.ReferenceTypeIds.HierarchicalReferences)) {
148
+ super(client, nodeIds, referenceType, opcua_webapi_1.NodeClass.Object, 20);
172
149
  }
173
150
  }
174
151
  exports.UaObjectBrowser = UaObjectBrowser;
175
- class UaLinkBrowser extends UaNodeBrowser {
176
- constructor(client, nodeIds, returnDescription) {
177
- super(client, nodeIds, common_1.UaNodeId.from(common_1.ReferenceTypeIds.NonHierarchicalReferences), opcua_webapi_1.NodeClass.Object, returnDescription !== null && returnDescription !== void 0 ? returnDescription : false, 20);
178
- }
179
- }
180
- exports.UaLinkBrowser = UaLinkBrowser;
181
152
  class UaTypeBrowser extends UaNodeBrowser {
182
- constructor(client, nodeIds, returnDescription) {
183
- super(client, nodeIds, common_1.UaNodeId.from(common_1.ReferenceTypeIds.HierarchicalReferences), 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);
153
+ constructor(client, nodeIds) {
154
+ super(client, nodeIds, common_1.UaNodeId.from(common_1.ReferenceTypeIds.HierarchicalReferences), opcua_webapi_1.NodeClass.ObjectType | opcua_webapi_1.NodeClass.VariableType | opcua_webapi_1.NodeClass.DataType | opcua_webapi_1.NodeClass.ReferenceType, 20);
184
155
  }
185
156
  }
186
157
  exports.UaTypeBrowser = UaTypeBrowser;
@@ -9,17 +9,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.UaObjectDataReader = exports.UaTypeReader = exports.UaObjectReader = exports.UaNodeReader = void 0;
12
+ exports.UaTypeReader = exports.UaFullObjectReader = 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, referenceTypeToReturn) {
17
+ constructor(client, returnDescription, returnVariable, returnMethod, referenceTypeToReturn, returnObjectAttributes, returnVariableAttributes, returnVariableValue, returnPropertyAttributes, returnPropertyValue) {
18
18
  this._client = client;
19
- this._returnDescription = (returnDescription) ? returnDescription : false;
20
- this._returnAttributes = (returnAttributes) ? returnAttributes : false;
21
- this._returnValue = (returnValue) ? returnValue : false;
22
- this._referenceTypeToReturn = (referenceTypeToReturn) ? referenceTypeToReturn : common_1.UaNodeId.from(common_1.ReferenceTypeIds.HierarchicalReferences);
19
+ this._returnDescription = returnDescription;
20
+ this._referenceTypeToReturn = referenceTypeToReturn;
21
+ this._returnObjectAttributes = returnObjectAttributes;
22
+ this._returnVariableAttributes = returnVariableAttributes;
23
+ this._returnVariableValue = returnVariableValue;
24
+ this._returnPropertyAttributes = returnPropertyAttributes;
25
+ this._returnPropertyValue = returnPropertyValue;
23
26
  this._nodeClassToReturn = 0;
24
27
  if (returnVariable)
25
28
  this._nodeClassToReturn += opcua_webapi_1.NodeClass.Variable;
@@ -59,17 +62,15 @@ class UaNodeReader {
59
62
  return __awaiter(this, void 0, void 0, function* () {
60
63
  if (references.length == 0)
61
64
  return [];
62
- let referencesToRead = [];
63
65
  let nodeIdsToBrowse = [];
64
66
  let nodeIdsSet = new Set();
65
67
  for (let item of references) {
66
68
  if (nodeIdsSet.has(item.nodeId.toString()))
67
69
  continue;
68
- referencesToRead.push(item);
69
70
  nodeIdsToBrowse.push(item.nodeId);
70
71
  nodeIdsSet.add(item.nodeId.toString());
71
72
  }
72
- let nodeReferenceBrowser = new UaNodeBrowser_1.UaNodeBrowser(this._client, nodeIdsToBrowse, this._referenceTypeToReturn, this._nodeClassToReturn, false);
73
+ let nodeReferenceBrowser = new UaNodeBrowser_1.UaNodeBrowser(this._client, nodeIdsToBrowse, this._referenceTypeToReturn, this._nodeClassToReturn);
73
74
  yield nodeReferenceBrowser.browse();
74
75
  let childReferences = nodeReferenceBrowser.results();
75
76
  let childNodesToBrowse = [];
@@ -86,7 +87,7 @@ class UaNodeReader {
86
87
  }
87
88
  let variableReferences = [];
88
89
  if (childNodesToBrowse.length != 0) {
89
- let childReferenceBrowser = new UaNodeBrowser_1.UaNodeBrowser(this._client, childNodesToBrowse, common_1.UaNodeId.from(common_1.ReferenceTypeIds.HierarchicalReferences), opcua_webapi_1.NodeClass.Variable, false);
90
+ let childReferenceBrowser = new UaNodeBrowser_1.UaNodeBrowser(this._client, childNodesToBrowse, common_1.UaNodeId.from(common_1.ReferenceTypeIds.Aggregates), opcua_webapi_1.NodeClass.Variable);
90
91
  yield childReferenceBrowser.browse();
91
92
  variableReferences = childReferenceBrowser.results();
92
93
  }
@@ -194,7 +195,6 @@ class UaNodeReader {
194
195
  _readTypes(references, nodes) {
195
196
  return __awaiter(this, void 0, void 0, function* () {
196
197
  let typesToRead = [];
197
- let needReadAttributes = this._returnAttributes || this._returnDescription;
198
198
  for (let item of references) {
199
199
  if (item.nodeClass != opcua_webapi_1.NodeClass.ObjectType &&
200
200
  item.nodeClass != opcua_webapi_1.NodeClass.DataType &&
@@ -206,49 +206,45 @@ class UaNodeReader {
206
206
  if (0 == typesToRead.length)
207
207
  return;
208
208
  let dataValues = [];
209
- if (needReadAttributes) {
210
- let nodesToRead = [];
211
- for (let item of typesToRead) {
212
- nodesToRead.push(new common_1.UaReadValueId(item.nodeId, opcua_webapi_1.Attributes.IsAbstract));
213
- nodesToRead.push(new common_1.UaReadValueId(item.nodeId, opcua_webapi_1.Attributes.Description));
214
- if (item.nodeClass == opcua_webapi_1.NodeClass.VariableType) {
215
- nodesToRead.push(new common_1.UaReadValueId(item.nodeId, opcua_webapi_1.Attributes.DataType));
216
- nodesToRead.push(new common_1.UaReadValueId(item.nodeId, opcua_webapi_1.Attributes.ValueRank));
217
- }
209
+ let nodesToRead = [];
210
+ for (let item of typesToRead) {
211
+ nodesToRead.push(new common_1.UaReadValueId(item.nodeId, opcua_webapi_1.Attributes.IsAbstract));
212
+ nodesToRead.push(new common_1.UaReadValueId(item.nodeId, opcua_webapi_1.Attributes.Description));
213
+ if (item.nodeClass == opcua_webapi_1.NodeClass.VariableType) {
214
+ nodesToRead.push(new common_1.UaReadValueId(item.nodeId, opcua_webapi_1.Attributes.DataType));
215
+ nodesToRead.push(new common_1.UaReadValueId(item.nodeId, opcua_webapi_1.Attributes.ValueRank));
218
216
  }
219
- dataValues = yield this._client.read(nodesToRead);
220
217
  }
218
+ dataValues = yield this._client.read(nodesToRead);
221
219
  for (let i = 0; i < typesToRead.length; ++i) {
222
220
  let isAbstract = false;
223
221
  let description = undefined;
224
222
  let dataType = common_1.UaNodeId.nullNodeId;
225
223
  let valueRank = -1;
226
- if (needReadAttributes) {
227
- let dataIndex = (typesToRead[i].nodeClass == opcua_webapi_1.NodeClass.VariableType) ? i * 4 : i * 2;
224
+ let dataIndex = (typesToRead[i].nodeClass == opcua_webapi_1.NodeClass.VariableType) ? i * 4 : i * 2;
225
+ if (dataValues[dataIndex].statusCode.isNotGood())
226
+ throw new common_1.UaError(dataValues[dataIndex].statusCode);
227
+ isAbstract = dataValues[dataIndex].value.toBoolean();
228
+ if (null == isAbstract)
229
+ throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadNodeAttributesInvalid));
230
+ dataIndex++;
231
+ if (dataValues[dataIndex].statusCode.isGood()) {
232
+ description = dataValues[dataIndex].value.toLocalizedText();
233
+ if (null == description)
234
+ description = undefined;
235
+ }
236
+ dataIndex++;
237
+ if (typesToRead[i].nodeClass == opcua_webapi_1.NodeClass.VariableType) {
228
238
  if (dataValues[dataIndex].statusCode.isNotGood())
229
239
  throw new common_1.UaError(dataValues[dataIndex].statusCode);
230
- isAbstract = dataValues[dataIndex].value.toBoolean();
231
- if (null == isAbstract)
232
- throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadNodeAttributesInvalid));
240
+ dataType = dataValues[dataIndex].value.toNodeId();
233
241
  dataIndex++;
234
- if (this._returnDescription && dataValues[dataIndex].statusCode.isGood()) {
235
- description = dataValues[dataIndex].value.toLocalizedText();
236
- if (null == description)
237
- description = undefined;
238
- }
242
+ if (dataValues[dataIndex].statusCode.isNotGood())
243
+ throw new common_1.UaError(dataValues[dataIndex].statusCode);
244
+ valueRank = dataValues[dataIndex].value.toNumber();
239
245
  dataIndex++;
240
- if (typesToRead[i].nodeClass == opcua_webapi_1.NodeClass.VariableType) {
241
- if (dataValues[dataIndex].statusCode.isNotGood())
242
- throw new common_1.UaError(dataValues[dataIndex].statusCode);
243
- dataType = dataValues[dataIndex].value.toNodeId();
244
- dataIndex++;
245
- if (dataValues[dataIndex].statusCode.isNotGood())
246
- throw new common_1.UaError(dataValues[dataIndex].statusCode);
247
- valueRank = dataValues[dataIndex].value.toNumber();
248
- dataIndex++;
249
- if (null == dataType || null == valueRank)
250
- throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadNodeAttributesInvalid));
251
- }
246
+ if (null == dataType || null == valueRank)
247
+ throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadNodeAttributesInvalid));
252
248
  }
253
249
  let typeNode;
254
250
  if (typesToRead[i].nodeClass == opcua_webapi_1.NodeClass.ObjectType) {
@@ -263,10 +259,9 @@ class UaNodeReader {
263
259
  else if (typesToRead[i].nodeClass == opcua_webapi_1.NodeClass.ReferenceType) {
264
260
  typeNode = new common_1.UaReferenceType(typesToRead[i].nodeId, typesToRead[i].browseName, typesToRead[i].displayName, isAbstract, common_1.UaLocalizedText.nullText, false);
265
261
  }
266
- if (this._returnDescription && description) {
262
+ if (description) {
267
263
  typeNode.description = description;
268
264
  }
269
- typeNode.refToParent = typesToRead[i].referenceTypeId;
270
265
  nodes.set(typeNode.nodeId.toString(), typeNode);
271
266
  }
272
267
  });
@@ -283,7 +278,7 @@ class UaNodeReader {
283
278
  return;
284
279
  let nodesToRead = [];
285
280
  for (let item of objectsToRead) {
286
- if (this._returnAttributes) {
281
+ if (this._returnObjectAttributes) {
287
282
  nodesToRead.push(new common_1.UaReadValueId(item.nodeId, opcua_webapi_1.Attributes.EventNotifier));
288
283
  }
289
284
  if (this._returnDescription) {
@@ -295,10 +290,10 @@ class UaNodeReader {
295
290
  dataValues = yield this._client.read(nodesToRead);
296
291
  }
297
292
  for (let i = 0; i < objectsToRead.length; ++i) {
298
- let dataIndex = (this._returnAttributes && this._returnDescription) ? i * 2 : i;
293
+ let dataIndex = (this._returnObjectAttributes && this._returnDescription) ? i * 2 : i;
299
294
  let eventNotifier = 0;
300
295
  let description = undefined;
301
- if (this._returnAttributes && dataValues[dataIndex].statusCode.isGood()) {
296
+ if (this._returnObjectAttributes && dataValues[dataIndex].statusCode.isGood()) {
302
297
  eventNotifier = dataValues[dataIndex].value.toNumber();
303
298
  if (null == eventNotifier)
304
299
  eventNotifier = 0;
@@ -311,7 +306,6 @@ class UaNodeReader {
311
306
  dataIndex++;
312
307
  }
313
308
  let objectNode = new common_1.UaObject(objectsToRead[i].nodeId, objectsToRead[i].browseName, objectsToRead[i].displayName, eventNotifier, objectsToRead[i].typeDefinitionId);
314
- objectNode.refToParent = objectsToRead[i].referenceTypeId;
315
309
  if (this._returnDescription && description) {
316
310
  objectNode.description = description;
317
311
  }
@@ -322,30 +316,56 @@ class UaNodeReader {
322
316
  _readVariables(references, nodes) {
323
317
  return __awaiter(this, void 0, void 0, function* () {
324
318
  let variablesToRead = [];
325
- let nodeIds = [];
319
+ let nodeIdsToReadAttributes = [];
320
+ let variablesToReadValue = [];
326
321
  for (let item of references) {
327
322
  if (item.nodeClass != opcua_webapi_1.NodeClass.Variable)
328
323
  continue;
329
324
  variablesToRead.push(item);
330
- nodeIds.push(item.nodeId);
331
325
  }
332
- if (0 == nodeIds.length)
326
+ if (0 == variablesToRead.length)
333
327
  return;
328
+ let hasPropertyId = common_1.UaNodeId.from(common_1.ReferenceTypeIds.HasProperty);
329
+ let attributeIndexMap = new Map();
330
+ for (let i = 0; i < variablesToRead.length; ++i) {
331
+ let item = variablesToRead[i];
332
+ if (item.referenceTypeId.equal(hasPropertyId)) {
333
+ if (this._returnPropertyAttributes) {
334
+ attributeIndexMap.set(i, nodeIdsToReadAttributes.length);
335
+ nodeIdsToReadAttributes.push(item.nodeId);
336
+ }
337
+ }
338
+ else {
339
+ if (this._returnVariableAttributes) {
340
+ attributeIndexMap.set(i, nodeIdsToReadAttributes.length);
341
+ nodeIdsToReadAttributes.push(item.nodeId);
342
+ }
343
+ }
344
+ }
334
345
  let results = [];
335
- if (this._returnAttributes) {
336
- results = yield this._client.readVariableAttributes(nodeIds);
346
+ if (nodeIdsToReadAttributes.length != 0) {
347
+ results = yield this._client.readVariableAttributes(nodeIdsToReadAttributes);
337
348
  }
338
- let variablesToReadValue = [];
339
349
  for (let i = 0; i < variablesToRead.length; ++i) {
340
350
  let variableNode;
341
- if (this._returnAttributes) {
342
- variableNode = new common_1.UaVariable(variablesToRead[i].nodeId, variablesToRead[i].browseName, variablesToRead[i].displayName, results[i].dataType, results[i].valueRank, results[i].accessLevel, results[i].userAccessLevel, results[i].historizing, variablesToRead[i].typeDefinitionId);
351
+ let attributeIndex = attributeIndexMap.get(i);
352
+ if (null != attributeIndex) {
353
+ variableNode = new common_1.UaVariable(variablesToRead[i].nodeId, variablesToRead[i].browseName, variablesToRead[i].displayName, results[attributeIndex].dataType, results[attributeIndex].valueRank, results[attributeIndex].accessLevel, results[attributeIndex].userAccessLevel, results[attributeIndex].historizing, variablesToRead[i].typeDefinitionId);
343
354
  }
344
355
  else {
345
356
  variableNode = new common_1.UaVariable(variablesToRead[i].nodeId, variablesToRead[i].browseName, variablesToRead[i].displayName, common_1.UaNodeId.nullNodeId, -1, 0, 0, false, variablesToRead[i].typeDefinitionId);
346
357
  }
347
358
  nodes.set(variableNode.nodeId.toString(), variableNode);
348
- if (this._returnValue || (UaNodeReader.s_variablesNameToRead.has(variableNode.browseName))) {
359
+ if (variablesToRead[i].referenceTypeId.equal(hasPropertyId)) {
360
+ variableNode.isProperty = true;
361
+ }
362
+ if (this._returnVariableValue && !variableNode.isProperty) {
363
+ variablesToReadValue.push(variableNode);
364
+ }
365
+ else if (this._returnPropertyValue && variableNode.isProperty) {
366
+ variablesToReadValue.push(variableNode);
367
+ }
368
+ else if (UaNodeReader.s_variablesNameToRead.has(variableNode.browseName)) {
349
369
  variablesToReadValue.push(variableNode);
350
370
  }
351
371
  }
@@ -449,17 +469,8 @@ exports.UaNodeReader = UaNodeReader;
449
469
  UaNodeReader.s_variableTypeWithoutMember = null;
450
470
  UaNodeReader.s_variablesNameToRead = null;
451
471
  class UaObjectReader extends UaNodeReader {
452
- constructor(client, returnDescription, returnValue) {
453
- super(client, returnDescription !== null && returnDescription !== void 0 ? returnDescription : false, true, true, true, returnValue !== null && returnValue !== void 0 ? returnValue : false);
454
- }
455
- read(nodeIds) {
456
- const _super = Object.create(null, {
457
- read: { get: () => super.read }
458
- });
459
- return __awaiter(this, void 0, void 0, function* () {
460
- let nodes = yield _super.read.call(this, nodeIds);
461
- return this._processResult(nodes);
462
- });
472
+ constructor(client, returnVariable = true, returnMethod = true, returnDescription = false) {
473
+ super(client, returnDescription, returnVariable, returnMethod, common_1.UaNodeId.from(common_1.ReferenceTypeIds.Aggregates), false, true, false, false, true);
463
474
  }
464
475
  readByReferences(references) {
465
476
  const _super = Object.create(null, {
@@ -474,34 +485,37 @@ class UaObjectReader extends UaNodeReader {
474
485
  }
475
486
  if (0 == objectReferences.length)
476
487
  return [];
477
- let nodes = yield _super.readByReferences.call(this, objectReferences);
478
- return this._processResult(nodes);
488
+ return yield _super.readByReferences.call(this, objectReferences);
479
489
  });
480
490
  }
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
- }
490
491
  }
491
492
  exports.UaObjectReader = UaObjectReader;
492
- class UaTypeReader extends UaNodeReader {
493
- constructor(client) {
494
- super(client, true, true, true, true, false);
493
+ class UaFullObjectReader extends UaNodeReader {
494
+ constructor(client, returnDescription = true, returnValue = false) {
495
+ super(client, returnDescription, true, true, common_1.UaNodeId.from(common_1.ReferenceTypeIds.Aggregates), true, true, returnValue, true, returnValue);
495
496
  }
496
- read(nodeIds) {
497
+ readByReferences(references) {
497
498
  const _super = Object.create(null, {
498
- read: { get: () => super.read }
499
+ readByReferences: { get: () => super.readByReferences }
499
500
  });
500
501
  return __awaiter(this, void 0, void 0, function* () {
501
- let nodes = yield _super.read.call(this, nodeIds);
502
- return this._processResult(nodes);
502
+ let objectReferences = [];
503
+ for (let item of references) {
504
+ if (item.nodeClass == opcua_webapi_1.NodeClass.Object) {
505
+ objectReferences.push(item);
506
+ }
507
+ }
508
+ if (0 == objectReferences.length)
509
+ return [];
510
+ return yield _super.readByReferences.call(this, objectReferences);
503
511
  });
504
512
  }
513
+ }
514
+ exports.UaFullObjectReader = UaFullObjectReader;
515
+ class UaTypeReader extends UaNodeReader {
516
+ constructor(client, returnDescription = false) {
517
+ super(client, returnDescription, true, true, common_1.UaNodeId.from(common_1.ReferenceTypeIds.Aggregates), false, true, false, true, false);
518
+ }
505
519
  readByReferences(references) {
506
520
  const _super = Object.create(null, {
507
521
  readByReferences: { get: () => super.readByReferences }
@@ -518,64 +532,8 @@ class UaTypeReader extends UaNodeReader {
518
532
  }
519
533
  if (0 == typeReferences.length)
520
534
  return [];
521
- let nodes = yield _super.readByReferences.call(this, typeReferences);
522
- return this._processResult(nodes);
535
+ return yield _super.readByReferences.call(this, typeReferences);
523
536
  });
524
537
  }
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
- }
537
538
  }
538
539
  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;