node-opcua-address-space 2.164.2 → 2.165.0
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/source/loader/load_nodeset2.d.ts +6 -4
- package/dist/source/loader/load_nodeset2.js +100 -59
- package/dist/source/loader/load_nodeset2.js.map +1 -1
- package/dist/source/session_context.d.ts +24 -0
- package/dist/source/session_context.js +34 -0
- package/dist/source/session_context.js.map +1 -1
- package/dist/src/address_space.d.ts +13 -1
- package/dist/src/address_space.js +20 -0
- package/dist/src/address_space.js.map +1 -1
- package/dist/src/address_space_private.d.ts +2 -1
- package/dist/src/base_node_impl.d.ts +17 -17
- package/dist/src/base_node_impl.js +78 -58
- package/dist/src/base_node_impl.js.map +1 -1
- package/dist/src/ua_data_type_impl.d.ts +7 -11
- package/dist/src/ua_data_type_impl.js +30 -26
- package/dist/src/ua_data_type_impl.js.map +1 -1
- package/dist/src/ua_method_impl.js +71 -28
- package/dist/src/ua_method_impl.js.map +1 -1
- package/dist/src/ua_variable_impl_ext_obj.js +54 -2
- package/dist/src/ua_variable_impl_ext_obj.js.map +1 -1
- package/dist/tsconfig_base.tsbuildinfo +1 -1
- package/package.json +34 -34
- package/source/loader/load_nodeset2.ts +118 -95
- package/source/session_context.ts +52 -2
- package/src/address_space.ts +24 -1
- package/src/address_space_private.ts +4 -1
- package/src/base_node_impl.ts +142 -135
- package/src/ua_data_type_impl.ts +52 -81
- package/src/ua_method_impl.ts +82 -39
- package/src/ua_variable_impl_ext_obj.ts +46 -2
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @module node-opcua-address-space
|
|
3
|
+
*/
|
|
4
|
+
import type { IAddressSpace } from "node-opcua-address-space-base";
|
|
5
|
+
import type { NodeSetLoaderOptions } from "../interfaces/nodeset_loader_options";
|
|
3
6
|
export interface NodeSet2ParserEngine {
|
|
4
7
|
addNodeSet: (xmlData: string) => Promise<void>;
|
|
5
8
|
terminate: () => Promise<void>;
|
|
6
9
|
}
|
|
7
10
|
export declare class NodeSetLoader {
|
|
8
|
-
private options?;
|
|
9
11
|
_s: NodeSet2ParserEngine;
|
|
10
|
-
constructor(addressSpace: IAddressSpace, options?: NodeSetLoaderOptions
|
|
12
|
+
constructor(addressSpace: IAddressSpace, options?: NodeSetLoaderOptions);
|
|
11
13
|
addNodeSetAsync(xmlData: string): Promise<void>;
|
|
12
14
|
terminate(): Promise<void>;
|
|
13
15
|
}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/* eslint-disable max-statements */
|
|
3
|
+
/**
|
|
4
|
+
* @module node-opcua-address-space
|
|
5
|
+
*/
|
|
2
6
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
7
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
8
|
};
|
|
5
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
10
|
exports.NodeSetLoader = void 0;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @module node-opcua-address-space
|
|
10
|
-
*/
|
|
11
|
-
const util_1 = require("util");
|
|
11
|
+
const node_util_1 = require("node:util");
|
|
12
12
|
const chalk_1 = __importDefault(require("chalk"));
|
|
13
|
-
const semver_1 = __importDefault(require("semver"));
|
|
14
|
-
const node_opcua_basic_types_1 = require("node-opcua-basic-types");
|
|
15
13
|
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
16
|
-
const
|
|
14
|
+
const node_opcua_basic_types_1 = require("node-opcua-basic-types");
|
|
15
|
+
const node_opcua_constants_1 = require("node-opcua-constants");
|
|
17
16
|
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
18
17
|
const node_opcua_debug_1 = require("node-opcua-debug");
|
|
19
18
|
const node_opcua_factory_1 = require("node-opcua-factory");
|
|
20
19
|
const node_opcua_nodeid_1 = require("node-opcua-nodeid");
|
|
21
20
|
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
22
21
|
const node_opcua_xml2json_1 = require("node-opcua-xml2json");
|
|
23
|
-
const
|
|
22
|
+
const semver_1 = __importDefault(require("semver"));
|
|
24
23
|
const ensure_datatype_extracted_1 = require("./ensure_datatype_extracted");
|
|
25
24
|
const make_semver_compatible_1 = require("./make_semver_compatible");
|
|
25
|
+
const namespace_post_step_1 = require("./namespace_post_step");
|
|
26
26
|
const variant_parser_1 = require("./parsers/variant_parser");
|
|
27
27
|
const doDebug = (0, node_opcua_debug_1.checkDebugFlag)(__filename);
|
|
28
28
|
const debugLog = (0, node_opcua_debug_1.make_debugLog)(__filename);
|
|
@@ -52,7 +52,7 @@ function convertAccessLevel(accessLevel) {
|
|
|
52
52
|
function makeDefaultVariant(addressSpace, dataTypeNode, valueRank, arrayDimensions) {
|
|
53
53
|
let variant = { dataType: node_opcua_variant_1.DataType.Null };
|
|
54
54
|
const nodeDataType = addressSpace.findNode(dataTypeNode);
|
|
55
|
-
if (nodeDataType
|
|
55
|
+
if (nodeDataType?.basicDataType) {
|
|
56
56
|
const basicDataType = nodeDataType.basicDataType;
|
|
57
57
|
if (basicDataType === node_opcua_variant_1.DataType.Variant) {
|
|
58
58
|
/// we don't now what is the variant
|
|
@@ -107,7 +107,7 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
107
107
|
const postTasks0_DecodePojoString = [];
|
|
108
108
|
const postTasks1_InitializeVariable = [];
|
|
109
109
|
const postTasks2_AssignedExtensionObjectToDataValue = [];
|
|
110
|
-
|
|
110
|
+
const aliasMap = new Map();
|
|
111
111
|
/**
|
|
112
112
|
* @param aliasName
|
|
113
113
|
*/
|
|
@@ -118,9 +118,9 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
118
118
|
aliasMap.set(aliasName, nodeId);
|
|
119
119
|
addressSpace1.getNamespace(nodeId.namespace).addAlias(aliasName, nodeId);
|
|
120
120
|
}
|
|
121
|
-
|
|
121
|
+
const namespaceUriTranslationMap = new Map();
|
|
122
122
|
let namespaceCounter = 0;
|
|
123
|
-
|
|
123
|
+
const foundNamespaceMap = new Map();
|
|
124
124
|
let models = [];
|
|
125
125
|
let performedCalled = false;
|
|
126
126
|
function _reset_namespace_translation() {
|
|
@@ -137,7 +137,7 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
137
137
|
// c8 ignore next
|
|
138
138
|
if (namespaceIndex === undefined) {
|
|
139
139
|
errorLog("Error; namespace_uri_translation", namespaceUriTranslationMap.entries());
|
|
140
|
-
throw new Error(
|
|
140
|
+
throw new Error(`_translateNamespaceIndex() ! Cannot find namespace definition for index ${innerIndex}`);
|
|
141
141
|
}
|
|
142
142
|
return namespaceIndex;
|
|
143
143
|
}
|
|
@@ -146,7 +146,7 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
146
146
|
if (!(params.nodeId instanceof node_opcua_nodeid_1.NodeId)) {
|
|
147
147
|
throw new Error("invalid param");
|
|
148
148
|
} // already translated
|
|
149
|
-
const namespace = addressSpace1.getNamespace(params.nodeId
|
|
149
|
+
const namespace = addressSpace1.getNamespace(params.nodeId?.namespace);
|
|
150
150
|
namespace.addReferenceType(params);
|
|
151
151
|
}
|
|
152
152
|
function _internal_createNode(params) {
|
|
@@ -183,7 +183,7 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
183
183
|
// c8 ignore next
|
|
184
184
|
if (!existingNamespace) {
|
|
185
185
|
errorLog("Please ensure that the required namespace", requiredModel.modelUri, "is loaded first when loading", model.modelUri);
|
|
186
|
-
throw new Error(
|
|
186
|
+
throw new Error(`LoadNodeSet : Cannot find namespace for ${requiredModel.modelUri}`);
|
|
187
187
|
}
|
|
188
188
|
/**
|
|
189
189
|
* from https://reference.opcfoundation.org/Core/docs/Part6/F.2/
|
|
@@ -222,12 +222,14 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
222
222
|
if (aliasMap.has(nodeId)) {
|
|
223
223
|
// note alias are already translated to the right namespaces
|
|
224
224
|
const aliasedNodeId = aliasMap.get(nodeId);
|
|
225
|
-
|
|
225
|
+
if (aliasedNodeId) {
|
|
226
|
+
return aliasedNodeId;
|
|
227
|
+
}
|
|
226
228
|
}
|
|
227
229
|
const m = nodeId.match(reg);
|
|
228
230
|
if (m) {
|
|
229
231
|
const namespaceIndex = _translateNamespaceIndex(parseInt(m[1], 10));
|
|
230
|
-
nodeId =
|
|
232
|
+
nodeId = `ns=${namespaceIndex};${m[2]}`;
|
|
231
233
|
}
|
|
232
234
|
return (0, node_opcua_nodeid_1.resolveNodeId)(nodeId);
|
|
233
235
|
}
|
|
@@ -260,20 +262,23 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
260
262
|
return qn;
|
|
261
263
|
}
|
|
262
264
|
const state_Alias = {
|
|
265
|
+
// biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
|
|
263
266
|
finish() {
|
|
264
267
|
addAlias(this.attrs.Alias, this.text);
|
|
265
268
|
}
|
|
266
269
|
};
|
|
267
270
|
const references_parser = {
|
|
271
|
+
// biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
|
|
268
272
|
init() {
|
|
269
273
|
this.parent.obj.references = [];
|
|
270
274
|
this.array = this.parent.obj.references;
|
|
271
275
|
},
|
|
272
276
|
parser: {
|
|
273
277
|
Reference: {
|
|
278
|
+
// biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
|
|
274
279
|
finish() {
|
|
275
280
|
this.parent.array.push({
|
|
276
|
-
isForward: this.attrs.IsForward === undefined ? true : this.attrs.IsForward
|
|
281
|
+
isForward: this.attrs.IsForward === undefined ? true : this.attrs.IsForward !== "false",
|
|
277
282
|
nodeId: convertToNodeId(this.text),
|
|
278
283
|
referenceType: _translateReferenceType(this.attrs.ReferenceType)
|
|
279
284
|
});
|
|
@@ -283,7 +288,8 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
283
288
|
};
|
|
284
289
|
// #region UAObject
|
|
285
290
|
const state_UAObject = {
|
|
286
|
-
|
|
291
|
+
// biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
|
|
292
|
+
init(_name, attrs) {
|
|
287
293
|
_perform();
|
|
288
294
|
this.obj = {
|
|
289
295
|
nodeClass: node_opcua_data_model_1.NodeClass.Object,
|
|
@@ -296,6 +302,7 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
296
302
|
this.isDraft = attrs.ReleaseStatus === "Draft";
|
|
297
303
|
this.isDeprecated = attrs.ReleaseStatus === "Deprecated";
|
|
298
304
|
},
|
|
305
|
+
// biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
|
|
299
306
|
finish() {
|
|
300
307
|
if (canIgnore({ isDraft: this.isDraft, isDeprecated: this.isDeprecated }, this.obj)) {
|
|
301
308
|
return;
|
|
@@ -304,11 +311,13 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
304
311
|
},
|
|
305
312
|
parser: {
|
|
306
313
|
DisplayName: {
|
|
314
|
+
// biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
|
|
307
315
|
finish() {
|
|
308
316
|
this.parent.obj.displayName = this.text;
|
|
309
317
|
}
|
|
310
318
|
},
|
|
311
319
|
Description: {
|
|
320
|
+
// biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
|
|
312
321
|
finish() {
|
|
313
322
|
this.parent.obj.description = this.text;
|
|
314
323
|
}
|
|
@@ -319,7 +328,8 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
319
328
|
// #endregion
|
|
320
329
|
// #region UAObjectType
|
|
321
330
|
const state_UAObjectType = {
|
|
322
|
-
|
|
331
|
+
// biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
|
|
332
|
+
init(_name, attrs) {
|
|
323
333
|
_perform();
|
|
324
334
|
this.obj = {
|
|
325
335
|
nodeClass: node_opcua_data_model_1.NodeClass.ObjectType,
|
|
@@ -329,16 +339,19 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
329
339
|
eventNotifier: (0, node_opcua_basic_types_1.coerceByte)(attrs.EventNotifier) || 0
|
|
330
340
|
};
|
|
331
341
|
},
|
|
342
|
+
// biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
|
|
332
343
|
finish() {
|
|
333
344
|
_internal_createNode(this.obj);
|
|
334
345
|
},
|
|
335
346
|
parser: {
|
|
336
347
|
DisplayName: {
|
|
348
|
+
// biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
|
|
337
349
|
finish() {
|
|
338
350
|
this.parent.obj.displayName = this.text;
|
|
339
351
|
}
|
|
340
352
|
},
|
|
341
353
|
Description: {
|
|
354
|
+
// biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
|
|
342
355
|
finish() {
|
|
343
356
|
this.parent.obj.description = this.text;
|
|
344
357
|
}
|
|
@@ -349,7 +362,8 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
349
362
|
// #endregion
|
|
350
363
|
// #region UAReferenceType
|
|
351
364
|
const state_UAReferenceType = {
|
|
352
|
-
|
|
365
|
+
// biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
|
|
366
|
+
init(_name, attrs) {
|
|
353
367
|
_perform();
|
|
354
368
|
this.obj = {
|
|
355
369
|
nodeClass: node_opcua_data_model_1.NodeClass.ReferenceType,
|
|
@@ -358,21 +372,25 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
358
372
|
browseName: convertQualifiedName(attrs.BrowseName)
|
|
359
373
|
};
|
|
360
374
|
},
|
|
375
|
+
// biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
|
|
361
376
|
finish() {
|
|
362
377
|
_internal_addReferenceType(this.obj);
|
|
363
378
|
},
|
|
364
379
|
parser: {
|
|
365
380
|
DisplayName: {
|
|
381
|
+
// biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
|
|
366
382
|
finish() {
|
|
367
383
|
this.parent.obj.displayName = this.text;
|
|
368
384
|
}
|
|
369
385
|
},
|
|
370
386
|
Description: {
|
|
387
|
+
// biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
|
|
371
388
|
finish() {
|
|
372
389
|
this.parent.obj.description = this.text;
|
|
373
390
|
}
|
|
374
391
|
},
|
|
375
392
|
InverseName: {
|
|
393
|
+
// biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
|
|
376
394
|
finish() {
|
|
377
395
|
this.parent.obj.inverseName = this.text;
|
|
378
396
|
}
|
|
@@ -380,12 +398,11 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
380
398
|
References: references_parser
|
|
381
399
|
}
|
|
382
400
|
};
|
|
383
|
-
;
|
|
384
401
|
// #endregion
|
|
385
402
|
// #region UADataType
|
|
386
403
|
const pendingSimpleTypeToRegister = [];
|
|
387
404
|
const state_UADataType = {
|
|
388
|
-
init(
|
|
405
|
+
init(_name, attrs) {
|
|
389
406
|
_perform();
|
|
390
407
|
this.obj = {
|
|
391
408
|
nodeClass: node_opcua_data_model_1.NodeClass.DataType,
|
|
@@ -407,7 +424,8 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
407
424
|
}
|
|
408
425
|
const definitionFields = this.definitionFields;
|
|
409
426
|
// replace DataType with nodeId, and description to LocalizedText
|
|
410
|
-
|
|
427
|
+
// biome-ignore lint/suspicious/noExplicitAny: fields transition from raw XML strings to typed objects
|
|
428
|
+
for (const x of definitionFields) {
|
|
411
429
|
if (x.description) {
|
|
412
430
|
x.description = { text: x.description };
|
|
413
431
|
}
|
|
@@ -417,15 +435,19 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
417
435
|
if (x.dataType) {
|
|
418
436
|
x.dataType = convertToNodeId(x.dataType);
|
|
419
437
|
}
|
|
438
|
+
else {
|
|
439
|
+
x.dataType = (0, node_opcua_nodeid_1.resolveNodeId)(node_opcua_constants_1.DataTypeIds.BaseDataType);
|
|
440
|
+
}
|
|
420
441
|
if (x.allowSubTypes) {
|
|
421
442
|
x.allowSubTypes = (0, node_opcua_basic_types_1.coerceBoolean)(x.allowSubTypes);
|
|
422
443
|
}
|
|
423
|
-
|
|
424
|
-
});
|
|
444
|
+
}
|
|
425
445
|
this.obj.partialDefinition = definitionFields;
|
|
426
446
|
let capturedDataTypeNode = _internal_createNode(this.obj);
|
|
427
|
-
const processBasicDataType = async (
|
|
428
|
-
|
|
447
|
+
const processBasicDataType = async (_addressSpace2) => {
|
|
448
|
+
if (!capturedDataTypeNode)
|
|
449
|
+
return;
|
|
450
|
+
const definitionName = capturedDataTypeNode.browseName.name || "";
|
|
429
451
|
const isStructure = capturedDataTypeNode.isStructure();
|
|
430
452
|
const isEnumeration = capturedDataTypeNode.isEnumeration();
|
|
431
453
|
if (!isEnumeration && !isStructure && capturedDataTypeNode.nodeId.namespace !== 0) {
|
|
@@ -465,12 +487,14 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
465
487
|
};
|
|
466
488
|
function fixExtensionObjectAndArray(obj, deferred) {
|
|
467
489
|
// let's create the mechanism that postpone the assignment of the extension object
|
|
468
|
-
|
|
490
|
+
const capturedNode = obj;
|
|
469
491
|
const task = async (addressSpace2) => {
|
|
470
492
|
const extensionObjOrArray = deferred();
|
|
471
|
-
|
|
493
|
+
const nodeId = capturedNode.nodeId;
|
|
472
494
|
(0, node_opcua_assert_1.assert)(nodeId, "expecting a nodeid");
|
|
473
495
|
const node = addressSpace2.findNode(nodeId);
|
|
496
|
+
if (!node)
|
|
497
|
+
return;
|
|
474
498
|
if (node.nodeClass === node_opcua_data_model_1.NodeClass.Variable) {
|
|
475
499
|
const v = node;
|
|
476
500
|
(0, node_opcua_assert_1.assert)(v.getBasicDataType() === node_opcua_variant_1.DataType.ExtensionObject, "expecting an extension object");
|
|
@@ -480,13 +504,13 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
480
504
|
}
|
|
481
505
|
else if (node.nodeClass === node_opcua_data_model_1.NodeClass.VariableType) {
|
|
482
506
|
const v = node;
|
|
483
|
-
v
|
|
507
|
+
v.value.value = extensionObjOrArray;
|
|
484
508
|
}
|
|
485
509
|
};
|
|
486
510
|
postTasks2_AssignedExtensionObjectToDataValue.push(task);
|
|
487
511
|
}
|
|
488
512
|
const state_UAVariable = {
|
|
489
|
-
init(
|
|
513
|
+
init(_name, attrs) {
|
|
490
514
|
_perform();
|
|
491
515
|
const valueRank = attrs.ValueRank === undefined ? -1 : (0, node_opcua_basic_types_1.coerceInt32)(attrs.ValueRank);
|
|
492
516
|
const accessLevel = convertAccessLevel(attrs.AccessLevel);
|
|
@@ -526,11 +550,14 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
526
550
|
let capturedVariable;
|
|
527
551
|
if (this.obj.value && this.obj.value.dataType !== node_opcua_variant_1.DataType.Null) {
|
|
528
552
|
let capturedValue = this.obj.value;
|
|
529
|
-
const task = async (
|
|
553
|
+
const task = async (_addressSpace2) => {
|
|
554
|
+
if (!capturedVariable)
|
|
555
|
+
return;
|
|
556
|
+
const cv = capturedVariable;
|
|
530
557
|
if (false && doDebug) {
|
|
531
|
-
debugLog("1 setting value to ",
|
|
558
|
+
debugLog("1 setting value to ", cv.nodeId.toString(), new node_opcua_variant_1.Variant(capturedValue).toString());
|
|
532
559
|
}
|
|
533
|
-
|
|
560
|
+
cv.setValueFromSource(capturedValue);
|
|
534
561
|
capturedValue = undefined;
|
|
535
562
|
capturedVariable = undefined;
|
|
536
563
|
};
|
|
@@ -543,20 +570,23 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
543
570
|
}
|
|
544
571
|
}
|
|
545
572
|
else {
|
|
546
|
-
const task = async (
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
const
|
|
573
|
+
const task = async (_addressSpace2) => {
|
|
574
|
+
if (!capturedVariable)
|
|
575
|
+
return;
|
|
576
|
+
const cv = capturedVariable;
|
|
577
|
+
const dataTypeNode = cv.dataType;
|
|
578
|
+
const valueRank = cv.valueRank;
|
|
579
|
+
const arrayDimensions = cv.arrayDimensions;
|
|
550
580
|
const value = makeDefaultVariant(addressSpace, dataTypeNode, valueRank, arrayDimensions);
|
|
551
581
|
if (value) {
|
|
552
582
|
if (false && doDebug) {
|
|
553
|
-
debugLog("2 setting value to ",
|
|
583
|
+
debugLog("2 setting value to ", cv.nodeId.toString(), value);
|
|
554
584
|
}
|
|
555
585
|
if (value.dataType === node_opcua_variant_1.DataType.Null) {
|
|
556
|
-
|
|
586
|
+
cv.setValueFromSource(value, node_opcua_basic_types_1.StatusCodes.BadWaitingForInitialData);
|
|
557
587
|
}
|
|
558
588
|
else {
|
|
559
|
-
|
|
589
|
+
cv.setValueFromSource(value, node_opcua_basic_types_1.StatusCodes.Good);
|
|
560
590
|
}
|
|
561
591
|
}
|
|
562
592
|
capturedVariable = undefined;
|
|
@@ -569,12 +599,12 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
569
599
|
parser: {
|
|
570
600
|
DisplayName: {
|
|
571
601
|
finish() {
|
|
572
|
-
this.parent.obj.displayName = (0, node_opcua_data_model_1.coerceLocalizedText)(this.text);
|
|
602
|
+
this.parent.obj.displayName = (0, node_opcua_data_model_1.coerceLocalizedText)(this.text) ?? undefined;
|
|
573
603
|
}
|
|
574
604
|
},
|
|
575
605
|
Description: {
|
|
576
606
|
finish() {
|
|
577
|
-
this.parent.obj.description = (0, node_opcua_data_model_1.coerceLocalizedText)(this.text);
|
|
607
|
+
this.parent.obj.description = (0, node_opcua_data_model_1.coerceLocalizedText)(this.text) ?? undefined;
|
|
578
608
|
}
|
|
579
609
|
},
|
|
580
610
|
References: references_parser,
|
|
@@ -582,7 +612,7 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
582
612
|
self.parent.obj.value = data;
|
|
583
613
|
}, (self, data, deferredTask) => {
|
|
584
614
|
self.parent.obj.value = data;
|
|
585
|
-
const capturedVariable = { nodeId: self.parent.obj.nodeId };
|
|
615
|
+
const capturedVariable = { nodeId: self.parent.obj.nodeId ?? node_opcua_nodeid_1.NodeId.nullNodeId };
|
|
586
616
|
fixExtensionObjectAndArray(capturedVariable, deferredTask);
|
|
587
617
|
}, (task) => {
|
|
588
618
|
postTasks0_DecodePojoString.push(task);
|
|
@@ -590,7 +620,7 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
590
620
|
}
|
|
591
621
|
};
|
|
592
622
|
const state_UAVariableType = {
|
|
593
|
-
init(
|
|
623
|
+
init(_name, attrs) {
|
|
594
624
|
_perform();
|
|
595
625
|
const valueRank = (0, node_opcua_basic_types_1.coerceInt32)(attrs.ValueRank) || -1;
|
|
596
626
|
this.obj = {
|
|
@@ -618,12 +648,12 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
618
648
|
parser: {
|
|
619
649
|
DisplayName: {
|
|
620
650
|
finish() {
|
|
621
|
-
this.parent.obj.displayName = (0, node_opcua_data_model_1.coerceLocalizedText)(this.text || "");
|
|
651
|
+
this.parent.obj.displayName = (0, node_opcua_data_model_1.coerceLocalizedText)(this.text || "") ?? undefined;
|
|
622
652
|
}
|
|
623
653
|
},
|
|
624
654
|
Description: {
|
|
625
655
|
finish() {
|
|
626
|
-
this.parent.obj.description = (0, node_opcua_data_model_1.coerceLocalizedText)(this.text || "");
|
|
656
|
+
this.parent.obj.description = (0, node_opcua_data_model_1.coerceLocalizedText)(this.text || "") ?? undefined;
|
|
627
657
|
}
|
|
628
658
|
},
|
|
629
659
|
References: references_parser,
|
|
@@ -631,7 +661,7 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
631
661
|
self.parent.obj.value = data;
|
|
632
662
|
}, (self, data, deferredTask) => {
|
|
633
663
|
self.parent.obj.value = data;
|
|
634
|
-
const capturedVariable = { nodeId: self.parent.obj.nodeId };
|
|
664
|
+
const capturedVariable = { nodeId: self.parent.obj.nodeId ?? node_opcua_nodeid_1.NodeId.nullNodeId };
|
|
635
665
|
fixExtensionObjectAndArray(capturedVariable, deferredTask);
|
|
636
666
|
}, (task) => {
|
|
637
667
|
postTasks0_DecodePojoString.push(task);
|
|
@@ -641,7 +671,8 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
641
671
|
// #endregion
|
|
642
672
|
// #region UAMethod
|
|
643
673
|
const state_UAMethod = {
|
|
644
|
-
|
|
674
|
+
// biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
|
|
675
|
+
init(_name, attrs) {
|
|
645
676
|
_perform();
|
|
646
677
|
this.obj = {
|
|
647
678
|
nodeClass: node_opcua_data_model_1.NodeClass.Method,
|
|
@@ -655,6 +686,7 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
655
686
|
this.isDraft = attrs.ReleaseStatus === "Draft";
|
|
656
687
|
this.isDeprecated = attrs.ReleaseStatus === "Deprecated";
|
|
657
688
|
},
|
|
689
|
+
// biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
|
|
658
690
|
finish() {
|
|
659
691
|
if (canIgnore({ isDraft: this.isDraft, isDeprecated: this.isDeprecated }, this.obj)) {
|
|
660
692
|
return;
|
|
@@ -663,6 +695,7 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
663
695
|
},
|
|
664
696
|
parser: {
|
|
665
697
|
DisplayName: {
|
|
698
|
+
// biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
|
|
666
699
|
finish() {
|
|
667
700
|
this.parent.obj.displayName = this.text;
|
|
668
701
|
}
|
|
@@ -672,22 +705,26 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
672
705
|
};
|
|
673
706
|
const state_ModelTableEntry = new node_opcua_xml2json_1.ReaderState({
|
|
674
707
|
// ModelTableEntry
|
|
708
|
+
// biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
|
|
675
709
|
init() {
|
|
676
710
|
this._requiredModels = [];
|
|
677
711
|
},
|
|
678
712
|
parser: {
|
|
679
713
|
RequiredModel: {
|
|
680
|
-
|
|
714
|
+
// biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
|
|
715
|
+
init(_name, attrs) {
|
|
681
716
|
const modelUri = attrs.ModelUri;
|
|
682
717
|
const version = attrs.Version;
|
|
683
718
|
const publicationDate = new Date(Date.parse(attrs.PublicationDate));
|
|
684
719
|
this.parent._requiredModels.push({ modelUri, version, publicationDate });
|
|
685
720
|
},
|
|
721
|
+
// biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
|
|
686
722
|
finish() {
|
|
687
723
|
/** */
|
|
688
724
|
}
|
|
689
725
|
}
|
|
690
726
|
},
|
|
727
|
+
// biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
|
|
691
728
|
finish() {
|
|
692
729
|
const modelUri = this.attrs.ModelUri; // //"http://opcfoundation.org/UA/"
|
|
693
730
|
const version = this.attrs.Version; // 1.04
|
|
@@ -703,7 +740,7 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
703
740
|
symbolicName,
|
|
704
741
|
version
|
|
705
742
|
};
|
|
706
|
-
const
|
|
743
|
+
const _namespace = _add_namespace(model);
|
|
707
744
|
models.push(model);
|
|
708
745
|
}
|
|
709
746
|
});
|
|
@@ -739,35 +776,41 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
739
776
|
const state_0 = {
|
|
740
777
|
parser: {
|
|
741
778
|
Aliases: {
|
|
779
|
+
// biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
|
|
742
780
|
init() {
|
|
743
781
|
_perform();
|
|
744
782
|
},
|
|
745
783
|
parser: { Alias: state_Alias }
|
|
746
784
|
},
|
|
747
785
|
NamespaceUris: {
|
|
786
|
+
// biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
|
|
748
787
|
init() {
|
|
749
788
|
//
|
|
750
789
|
_namespaceUris = [];
|
|
751
790
|
},
|
|
752
791
|
parser: {
|
|
753
792
|
Uri: {
|
|
793
|
+
// biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
|
|
754
794
|
finish() {
|
|
755
795
|
_namespaceUris.push(this.text);
|
|
756
796
|
}
|
|
757
797
|
}
|
|
758
798
|
},
|
|
799
|
+
// biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
|
|
759
800
|
finish() {
|
|
760
801
|
// verify that requested namespaces are already loaded or abort with a message
|
|
761
802
|
}
|
|
762
803
|
},
|
|
763
804
|
Models: {
|
|
764
805
|
// ModelTable
|
|
765
|
-
|
|
806
|
+
// biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
|
|
807
|
+
init(_name, _attrs) {
|
|
766
808
|
/* */
|
|
767
809
|
},
|
|
768
810
|
parser: {
|
|
769
811
|
Model: state_ModelTableEntry
|
|
770
812
|
},
|
|
813
|
+
// biome-ignore lint/suspicious/noExplicitAny: xml2json parser callback with dynamic this binding
|
|
771
814
|
finish() {
|
|
772
815
|
/** */
|
|
773
816
|
}
|
|
@@ -807,7 +850,7 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
807
850
|
catch (err) {
|
|
808
851
|
// c8 ignore next
|
|
809
852
|
// tslint:disable:no-console
|
|
810
|
-
if (
|
|
853
|
+
if (node_util_1.types.isNativeError(err)) {
|
|
811
854
|
errorLog(" performPostLoadingTasks Err => ", err.message, "\n", err);
|
|
812
855
|
}
|
|
813
856
|
await task(addressSpace1);
|
|
@@ -829,11 +872,11 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
829
872
|
const dataTypeManager = addressSpace.getDataTypeManager();
|
|
830
873
|
/// ----------------------------------------------------------------------------------------
|
|
831
874
|
doDebug && debugLog(chalk_1.default.bgGreenBright("DataType extraction done ") + chalk_1.default.green("DONE"));
|
|
832
|
-
for (const { name, dataTypeNodeId } of pendingSimpleTypeToRegister) {
|
|
875
|
+
for (const { name: _name, dataTypeNodeId } of pendingSimpleTypeToRegister) {
|
|
833
876
|
if (dataTypeNodeId.namespace === 0) {
|
|
834
877
|
continue;
|
|
835
878
|
}
|
|
836
|
-
|
|
879
|
+
dataTypeManager.getDataTypeFactoryForNamespace(dataTypeNodeId.namespace);
|
|
837
880
|
}
|
|
838
881
|
pendingSimpleTypeToRegister.splice(0);
|
|
839
882
|
doDebug && debugLog(chalk_1.default.bgGreenBright("Performing post loading task: Decoding Pojo String (parsing XML objects) -"));
|
|
@@ -863,10 +906,8 @@ function makeNodeSetParserEngine(addressSpace, options) {
|
|
|
863
906
|
};
|
|
864
907
|
}
|
|
865
908
|
class NodeSetLoader {
|
|
866
|
-
options;
|
|
867
909
|
_s;
|
|
868
910
|
constructor(addressSpace, options) {
|
|
869
|
-
this.options = options;
|
|
870
911
|
this._s = makeNodeSetParserEngine(addressSpace, options || {});
|
|
871
912
|
}
|
|
872
913
|
async addNodeSetAsync(xmlData) {
|