node-opcua-address-space 2.77.0 → 2.78.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/continuation_points/continuation_point_manager.d.ts +59 -0
- package/dist/source/continuation_points/continuation_point_manager.js +6 -6
- package/dist/source/continuation_points/continuation_point_manager.js.map +1 -1
- package/dist/source/index.d.ts +1 -0
- package/dist/source/index.js +1 -0
- package/dist/source/index.js.map +1 -1
- package/dist/source/loader/ensure_datatype_extracted.js +25 -0
- package/dist/source/loader/ensure_datatype_extracted.js.map +1 -1
- package/dist/source/loader/generateAddressSpaceRaw.d.ts +2 -1
- package/dist/source/loader/generateAddressSpaceRaw.js +2 -2
- package/dist/source/loader/generateAddressSpaceRaw.js.map +1 -1
- package/dist/source/loader/load_nodeset2.d.ts +7 -3
- package/dist/source/loader/load_nodeset2.js +66 -31
- package/dist/source/loader/load_nodeset2.js.map +1 -1
- package/dist/source/xml_writer.d.ts +5 -0
- package/dist/src/base_node_private.js +5 -0
- package/dist/src/base_node_private.js.map +1 -1
- package/dist/src/index_current.d.ts +2 -1
- package/dist/src/index_current.js +3 -2
- package/dist/src/index_current.js.map +1 -1
- package/dist/src/namespace_impl.d.ts +2 -0
- package/dist/src/namespace_impl.js +11 -1
- package/dist/src/namespace_impl.js.map +1 -1
- package/dist/src/namespace_private.d.ts +1 -0
- package/dist/src/namespace_private.js.map +1 -1
- package/dist/src/nodeid_manager.d.ts +1 -0
- package/dist/src/nodeid_manager.js +14 -2
- package/dist/src/nodeid_manager.js.map +1 -1
- package/dist/src/nodeset_tools/dump_to_bsd.d.ts +2 -0
- package/dist/src/nodeset_tools/dump_to_bsd.js +164 -0
- package/dist/src/nodeset_tools/dump_to_bsd.js.map +1 -0
- package/dist/src/nodeset_tools/nodeset_to_xml.d.ts +9 -1
- package/dist/src/nodeset_tools/nodeset_to_xml.js +182 -87
- package/dist/src/nodeset_tools/nodeset_to_xml.js.map +1 -1
- package/dist/src/tool_isSupertypeOf.js +12 -2
- package/dist/src/tool_isSupertypeOf.js.map +1 -1
- package/dist/src/ua_data_type_impl.js +10 -5
- package/dist/src/ua_data_type_impl.js.map +1 -1
- package/dist/src/ua_object_impl.js +8 -1
- package/dist/src/ua_object_impl.js.map +1 -1
- package/dist/src/ua_variable_impl.js +4 -0
- package/dist/src/ua_variable_impl.js.map +1 -1
- package/dist/src/ua_variable_impl_ext_obj.js +1 -1
- package/dist/src/ua_variable_impl_ext_obj.js.map +1 -1
- package/distHelpers/get_mini_address_space.js +1 -1
- package/distHelpers/get_mini_address_space.js.map +1 -1
- package/distNodeJS/generate_address_space.d.ts +3 -1
- package/distNodeJS/generate_address_space.js +13 -2
- package/distNodeJS/generate_address_space.js.map +1 -1
- package/package.json +22 -22
- package/source/continuation_points/continuation_point_manager.ts +13 -12
- package/source/index.ts +1 -0
- package/source/loader/ensure_datatype_extracted.ts +38 -3
- package/source/loader/generateAddressSpaceRaw.ts +4 -3
- package/source/loader/load_nodeset2.ts +86 -33
- package/source/xml_writer.ts +3 -0
- package/source_nodejs/generate_address_space.ts +27 -5
- package/src/base_node_private.ts +6 -0
- package/src/index_current.ts +3 -1
- package/src/namespace_impl.ts +24 -1
- package/src/namespace_private.ts +2 -0
- package/src/nodeid_manager.ts +14 -5
- package/src/nodeset_tools/{typedictionary_to_xml.ts → dump_to_bsd.ts} +24 -14
- package/src/nodeset_tools/nodeset_to_xml.ts +231 -74
- package/src/tool_isSupertypeOf.ts +14 -2
- package/src/ua_data_type_impl.ts +11 -7
- package/src/ua_object_impl.ts +12 -2
- package/src/ua_variable_impl.ts +6 -0
- package/src/ua_variable_impl_ext_obj.ts +1 -1
- package/test_helpers/get_mini_address_space.ts +1 -1
- package/test_helpers/test_fixtures/mini.Node.Set2.xml +29 -0
- package/test_helpers/test_fixtures/nodeset_no_aliases.xml +30 -0
- package/test_helpers/test_fixtures/nodeset_no_aliases_with_aliases.xml +31 -0
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.dumpXml = void 0;
|
|
4
|
+
/* eslint-disable complexity */
|
|
4
5
|
/**
|
|
5
6
|
* @module node-opcua-address-space
|
|
6
7
|
*/
|
|
7
8
|
// produce nodeset xml files
|
|
8
9
|
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
10
|
+
const node_opcua_constants_1 = require("node-opcua-constants");
|
|
9
11
|
const node_opcua_debug_1 = require("node-opcua-debug");
|
|
10
12
|
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
11
13
|
const node_opcua_nodeid_1 = require("node-opcua-nodeid");
|
|
@@ -23,6 +25,7 @@ const namespace_impl_1 = require("../namespace_impl");
|
|
|
23
25
|
const ua_method_impl_1 = require("../ua_method_impl");
|
|
24
26
|
const ua_data_type_impl_1 = require("../ua_data_type_impl");
|
|
25
27
|
const ua_variable_type_impl_1 = require("../ua_variable_type_impl");
|
|
28
|
+
const index_current_1 = require("../index_current");
|
|
26
29
|
const decode_xml_extension_object_1 = require("../../source/loader/decode_xml_extension_object");
|
|
27
30
|
const construct_namespace_dependency_1 = require("./construct_namespace_dependency");
|
|
28
31
|
// tslint:disable:no-var-requires
|
|
@@ -63,6 +66,10 @@ function translateBrowseName(xw, browseName) {
|
|
|
63
66
|
function b(xw, browseName) {
|
|
64
67
|
return translateBrowseName(xw, browseName).toString().replace("ns=0;", "");
|
|
65
68
|
}
|
|
69
|
+
function _dumpReverseReferences(xw, node) {
|
|
70
|
+
const addressSpace = node.addressSpace;
|
|
71
|
+
const hasSubtypeReferenceType = addressSpace.findReferenceType("HasSubtype");
|
|
72
|
+
}
|
|
66
73
|
function _dumpReferences(xw, node) {
|
|
67
74
|
xw.startElement("References");
|
|
68
75
|
const addressSpace = node.addressSpace;
|
|
@@ -153,25 +160,42 @@ function _dumpQualifiedName(xw, v) {
|
|
|
153
160
|
function _dumpXmlElement(xw, v) {
|
|
154
161
|
xw.text(v);
|
|
155
162
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
163
|
+
function initXmlWriterEx(xw, map) {
|
|
164
|
+
const xwe = xw;
|
|
165
|
+
xwe.map = map;
|
|
166
|
+
xwe.stackMap = [];
|
|
167
|
+
}
|
|
168
|
+
function getPrefix(xw, namespace) {
|
|
169
|
+
const xwe = xw;
|
|
170
|
+
if (!xwe.map)
|
|
171
|
+
return "";
|
|
172
|
+
const p = xwe.map[namespace] || "";
|
|
173
|
+
return p ? p + ":" : "";
|
|
174
|
+
}
|
|
175
|
+
function restoreDefaultNamespace(xw) {
|
|
176
|
+
const xwe = xw;
|
|
177
|
+
if (!xwe.map)
|
|
178
|
+
return;
|
|
179
|
+
xwe.map = xwe.stackMap.pop();
|
|
180
|
+
}
|
|
181
|
+
function setDefaultNamespace(xw, namespace) {
|
|
182
|
+
const xwe = xw;
|
|
183
|
+
if (!xwe.map)
|
|
184
|
+
return;
|
|
185
|
+
if (xwe.map[namespace] !== "") {
|
|
186
|
+
xw.writeAttribute("xmlns", namespace);
|
|
187
|
+
}
|
|
188
|
+
xwe.stackMap.push(Object.assign({}, xwe.map));
|
|
189
|
+
xwe.map[namespace] = "";
|
|
190
|
+
}
|
|
191
|
+
function startElementEx(xw, ns, name, defaultNamespace) {
|
|
192
|
+
const xwe = xw;
|
|
193
|
+
xw.startElement(name);
|
|
194
|
+
setDefaultNamespace(xw, defaultNamespace);
|
|
195
|
+
}
|
|
173
196
|
function _dumpNodeId(xw, v) {
|
|
174
|
-
xw.
|
|
197
|
+
const xmlns = getPrefix(xw, "http://opcfoundation.org/UA/2008/02/Types.xsd");
|
|
198
|
+
xw.startElement(`${xmlns}Identifier`);
|
|
175
199
|
xw.text(n(xw, v));
|
|
176
200
|
xw.endElement();
|
|
177
201
|
}
|
|
@@ -184,7 +208,8 @@ function _dumpVariantValue(xw, dataType, node, value) {
|
|
|
184
208
|
if (dataType === node_opcua_variant_1.DataType.Null) {
|
|
185
209
|
return;
|
|
186
210
|
}
|
|
187
|
-
xw.
|
|
211
|
+
const uax = getPrefix(xw, "http://opcfoundation.org/UA/2008/02/Types.xsd");
|
|
212
|
+
xw.startElement(`${uax}${node_opcua_variant_1.DataType[dataType]}`);
|
|
188
213
|
const definitionMap = (0, decode_xml_extension_object_1.makeDefinitionMap)(node.addressSpace);
|
|
189
214
|
_dumpVariantInnerValue(xw, dataType, dataTypeNode.nodeId, definitionMap, value);
|
|
190
215
|
xw.endElement();
|
|
@@ -252,6 +277,7 @@ function _dumpVariantInnerValueEnum(xw, definition, value) {
|
|
|
252
277
|
}
|
|
253
278
|
// eslint-disable-next-line complexity
|
|
254
279
|
function _dumpVariantInnerValue(xw, dataType, dataTypeNodeId, definitionMap, value) {
|
|
280
|
+
const uax = getPrefix(xw, "http://opcfoundation.org/UA/2008/02/Types.xsd");
|
|
255
281
|
switch (dataType) {
|
|
256
282
|
case null:
|
|
257
283
|
case node_opcua_variant_1.DataType.Null:
|
|
@@ -293,12 +319,12 @@ function _dumpVariantInnerValue(xw, dataType, dataTypeNodeId, definitionMap, val
|
|
|
293
319
|
case node_opcua_variant_1.DataType.Guid:
|
|
294
320
|
/*
|
|
295
321
|
<uax:Guid>
|
|
296
|
-
|
|
322
|
+
<uax:String>947c29a7-490d-4dc9-adda-1109e3e8fcb7</uax:String>
|
|
297
323
|
</uax:Guid>
|
|
298
324
|
*/
|
|
299
325
|
if (value !== undefined && value !== null) {
|
|
300
326
|
// xw.writeAttribute("xmlns", "http://opcfoundation.org/UA/2008/02/Types.xsd");
|
|
301
|
-
xw.startElement(
|
|
327
|
+
xw.startElement(`${uax}String`);
|
|
302
328
|
xw.text(value.toString());
|
|
303
329
|
xw.endElement();
|
|
304
330
|
}
|
|
@@ -338,24 +364,29 @@ function _dumpVariantExtensionObjectValue(xw, dataTypeNodeId, definitionMap, val
|
|
|
338
364
|
// const encodingDefaultXml = (getStructureTypeConstructor(schema.name) as any).encodingDefaultXml;
|
|
339
365
|
const encodingDefaultXml = value.schema.encodingDefaultXml;
|
|
340
366
|
if (!encodingDefaultXml) {
|
|
367
|
+
warningLog("dataType Name ", name, "with ", dataTypeNodeId.toString(), " does not have xml encoding");
|
|
341
368
|
// throw new Error("Extension Object doesn't provide a XML ");
|
|
342
369
|
return;
|
|
343
370
|
}
|
|
344
|
-
xw.
|
|
371
|
+
const uax = getPrefix(xw, "http://opcfoundation.org/UA/2008/02/Types.xsd");
|
|
372
|
+
startElementEx(xw, uax, `ExtensionObject`, "http://opcfoundation.org/UA/2008/02/Types.xsd");
|
|
345
373
|
{
|
|
346
|
-
xw.
|
|
374
|
+
const uax = getPrefix(xw, "http://opcfoundation.org/UA/2008/02/Types.xsd");
|
|
375
|
+
xw.startElement(`${uax}TypeId`);
|
|
347
376
|
{
|
|
348
377
|
// find HasEncoding node
|
|
349
378
|
// xx var encodingDefaultXml = schema.encodingDefaultXml;
|
|
350
|
-
xw.startElement(
|
|
379
|
+
xw.startElement(`${uax}Identifier`);
|
|
351
380
|
xw.text(n(xw, encodingDefaultXml));
|
|
352
381
|
xw.endElement();
|
|
353
382
|
}
|
|
354
383
|
xw.endElement();
|
|
355
|
-
xw
|
|
384
|
+
startElementEx(xw, uax, "Body", "http://opcfoundation.org/UA/2008/02/Types.xsd");
|
|
356
385
|
_dumpVariantExtensionObjectValue_Body(xw, definitionMap, name, definition, value);
|
|
386
|
+
restoreDefaultNamespace(xw);
|
|
357
387
|
xw.endElement();
|
|
358
388
|
}
|
|
389
|
+
restoreDefaultNamespace(xw);
|
|
359
390
|
xw.endElement();
|
|
360
391
|
}
|
|
361
392
|
function _dumpVariantExtensionObjectValue2(xw, dataTypeNode, value) {
|
|
@@ -384,10 +415,7 @@ function _isDefaultValue(value) {
|
|
|
384
415
|
}
|
|
385
416
|
break;
|
|
386
417
|
case node_opcua_variant_1.DataType.Boolean:
|
|
387
|
-
|
|
388
|
-
return true;
|
|
389
|
-
}
|
|
390
|
-
break;
|
|
418
|
+
return false; // we want it all the time !
|
|
391
419
|
case node_opcua_variant_1.DataType.SByte:
|
|
392
420
|
case node_opcua_variant_1.DataType.Byte:
|
|
393
421
|
case node_opcua_variant_1.DataType.UInt16:
|
|
@@ -440,7 +468,7 @@ function _dumpValue(xw, node, value) {
|
|
|
440
468
|
return;
|
|
441
469
|
}
|
|
442
470
|
(0, node_opcua_assert_1.assert)(value instanceof node_opcua_variant_1.Variant);
|
|
443
|
-
const dataTypeNode = addressSpace.
|
|
471
|
+
const dataTypeNode = addressSpace.findDataType(node.dataType);
|
|
444
472
|
if (!dataTypeNode) {
|
|
445
473
|
console.log("Cannot find dataType:", node.dataType);
|
|
446
474
|
return;
|
|
@@ -457,15 +485,13 @@ function _dumpValue(xw, node, value) {
|
|
|
457
485
|
return;
|
|
458
486
|
}
|
|
459
487
|
xw.startElement("Value");
|
|
488
|
+
const uax = getPrefix(xw, "http://opcfoundation.org/UA/2008/02/Types.xsd");
|
|
460
489
|
if (isExtensionObject) {
|
|
461
|
-
const dataTypeNode = addressSpace.findDataType(node.dataType);
|
|
462
|
-
if (!dataTypeNode) {
|
|
463
|
-
throw new Error("Cannot find data type " + node.dataType.toString());
|
|
464
|
-
}
|
|
465
490
|
const encodeXml = _dumpVariantExtensionObjectValue2.bind(null, xw, dataTypeNode);
|
|
466
491
|
if (value.arrayType === node_opcua_variant_1.VariantArrayType.Array) {
|
|
467
|
-
xw
|
|
492
|
+
startElementEx(xw, uax, `ListOf${baseDataTypeName}`, "http://opcfoundation.org/UA/2008/02/Types.xsd");
|
|
468
493
|
value.value.forEach(encodeXml);
|
|
494
|
+
restoreDefaultNamespace(xw);
|
|
469
495
|
xw.endElement();
|
|
470
496
|
}
|
|
471
497
|
else if (value.arrayType === node_opcua_variant_1.VariantArrayType.Scalar) {
|
|
@@ -481,15 +507,15 @@ function _dumpValue(xw, node, value) {
|
|
|
481
507
|
const encodeXml = _dumpVariantValue.bind(null, xw, value.dataType, node);
|
|
482
508
|
if (value.arrayType === node_opcua_variant_1.VariantArrayType.Matrix) {
|
|
483
509
|
// console.log("Warning _dumpValue : Matrix not supported yet");
|
|
484
|
-
xw
|
|
485
|
-
xw.writeAttribute("xmlns", "http://opcfoundation.org/UA/2008/02/Types.xsd");
|
|
510
|
+
startElementEx(xw, uax, `ListOf${dataTypeName}`, "http://opcfoundation.org/UA/2008/02/Types.xsd");
|
|
486
511
|
value.value.forEach(encodeXml);
|
|
512
|
+
restoreDefaultNamespace(xw);
|
|
487
513
|
xw.endElement();
|
|
488
514
|
}
|
|
489
515
|
else if (value.arrayType === node_opcua_variant_1.VariantArrayType.Array) {
|
|
490
|
-
xw
|
|
491
|
-
xw.writeAttribute("xmlns", "http://opcfoundation.org/UA/2008/02/Types.xsd");
|
|
516
|
+
startElementEx(xw, uax, `ListOf${dataTypeName}`, "http://opcfoundation.org/UA/2008/02/Types.xsd");
|
|
492
517
|
value.value.forEach(encodeXml);
|
|
518
|
+
restoreDefaultNamespace(xw);
|
|
493
519
|
xw.endElement();
|
|
494
520
|
}
|
|
495
521
|
else if (value.arrayType === node_opcua_variant_1.VariantArrayType.Scalar) {
|
|
@@ -511,11 +537,9 @@ function _dumpArrayDimensionsAttribute(xw, node) {
|
|
|
511
537
|
xw.writeAttribute("ArrayDimensions", node.arrayDimensions.join(","));
|
|
512
538
|
}
|
|
513
539
|
}
|
|
514
|
-
function visitUANode(node,
|
|
540
|
+
function visitUANode(node, data, forward) {
|
|
515
541
|
(0, node_opcua_assert_1.assert)(typeof forward === "boolean");
|
|
516
542
|
const addressSpace = node.addressSpace;
|
|
517
|
-
options.elements = options.elements || [];
|
|
518
|
-
options.index_el = options.index_el || {};
|
|
519
543
|
// visit references
|
|
520
544
|
function process_reference(reference) {
|
|
521
545
|
// only backward or forward references
|
|
@@ -526,16 +550,16 @@ function visitUANode(node, options, forward) {
|
|
|
526
550
|
return; // skip OPCUA namespace
|
|
527
551
|
}
|
|
528
552
|
const k = _hash(reference);
|
|
529
|
-
if (!
|
|
530
|
-
|
|
553
|
+
if (!data.index_el[k]) {
|
|
554
|
+
data.index_el[k] = 1;
|
|
531
555
|
const o = addressSpace.findNode(k);
|
|
532
556
|
if (o) {
|
|
533
|
-
visitUANode(o,
|
|
557
|
+
visitUANode(o, data, forward);
|
|
534
558
|
}
|
|
535
559
|
}
|
|
536
560
|
}
|
|
537
561
|
node.ownReferences().forEach(process_reference);
|
|
538
|
-
|
|
562
|
+
data.elements.push(node);
|
|
539
563
|
return node;
|
|
540
564
|
}
|
|
541
565
|
function dumpNodeInXml(xw, node) {
|
|
@@ -593,10 +617,20 @@ function dumpReferencedNodes(xw, node, forward) {
|
|
|
593
617
|
}
|
|
594
618
|
}
|
|
595
619
|
}
|
|
620
|
+
function getParent(node) {
|
|
621
|
+
if (node instanceof ua_variable_impl_1.UAVariableImpl || node instanceof ua_method_impl_1.UAMethodImpl || node instanceof ua_object_impl_1.UAObjectImpl) {
|
|
622
|
+
return node.parent;
|
|
623
|
+
}
|
|
624
|
+
return null;
|
|
625
|
+
}
|
|
596
626
|
const currentReadFlag = (0, node_opcua_data_model_1.makeAccessLevelFlag)("CurrentRead");
|
|
597
627
|
function dumpCommonAttributes(xw, node) {
|
|
598
628
|
xw.writeAttribute("NodeId", n(xw, node.nodeId));
|
|
599
629
|
xw.writeAttribute("BrowseName", b(xw, node.browseName));
|
|
630
|
+
const parentNode = getParent(node);
|
|
631
|
+
if (parentNode) {
|
|
632
|
+
xw.writeAttribute("ParentNodeId", n(xw, parentNode.nodeId));
|
|
633
|
+
}
|
|
600
634
|
if (Object.prototype.hasOwnProperty.call(node, "symbolicName")) {
|
|
601
635
|
xw.writeAttribute("SymbolicName", node.symbolicName);
|
|
602
636
|
}
|
|
@@ -677,13 +711,20 @@ function _dumpStructureDefinition(xw, structureDefinition, baseStructureDefiniti
|
|
|
677
711
|
xw.endElement();
|
|
678
712
|
}
|
|
679
713
|
}
|
|
714
|
+
function _dumpEncoding(xw, uaEncoding) {
|
|
715
|
+
const uaDescription = uaEncoding.findReferencesAsObject("HasDescription")[0];
|
|
716
|
+
if (uaDescription) {
|
|
717
|
+
dumpUAVariable(xw, uaDescription);
|
|
718
|
+
}
|
|
719
|
+
_dumpUAObject(xw, uaEncoding);
|
|
720
|
+
}
|
|
680
721
|
function _dumpEncodings(xw, uaDataType) {
|
|
681
722
|
const encodings = uaDataType.findReferencesExAsObject("HasEncoding", node_opcua_data_model_1.BrowseDirection.Forward);
|
|
682
|
-
for (const
|
|
683
|
-
if (
|
|
723
|
+
for (const uaEncoding of encodings) {
|
|
724
|
+
if (uaEncoding.nodeClass !== node_opcua_data_model_1.NodeClass.Object) {
|
|
684
725
|
continue;
|
|
685
726
|
}
|
|
686
|
-
|
|
727
|
+
_dumpEncoding(xw, uaEncoding);
|
|
687
728
|
}
|
|
688
729
|
}
|
|
689
730
|
function _dumpUADataTypeDefinition(xw, uaDataType) {
|
|
@@ -696,15 +737,20 @@ function _dumpUADataTypeDefinition(xw, uaDataType) {
|
|
|
696
737
|
return;
|
|
697
738
|
}
|
|
698
739
|
if (uaDataType.isStructure()) {
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
740
|
+
// in case the namespace is conforming to 1.03 specification the DataTypeDefinition attribute
|
|
741
|
+
// will be not be readable....
|
|
742
|
+
const dataValue = uaDataType.readAttribute(index_current_1.SessionContext.defaultContext, node_opcua_basic_types_1.AttributeIds.DataTypeDefinition);
|
|
743
|
+
if (dataValue.statusCode === node_opcua_basic_types_1.StatusCodes.Good) {
|
|
744
|
+
const definition = uaDataType.getStructureDefinition();
|
|
745
|
+
const baseDefinition = uaDataTypeBase ? uaDataTypeBase.getStructureDefinition() : null;
|
|
746
|
+
xw.startElement("Definition");
|
|
747
|
+
xw.writeAttribute("Name", b(xw, uaDataType.browseName));
|
|
748
|
+
if (definition.structureType === node_opcua_types_1.StructureType.Union) {
|
|
749
|
+
xw.writeAttribute("IsUnion", "true");
|
|
750
|
+
}
|
|
751
|
+
_dumpStructureDefinition(xw, definition, baseDefinition);
|
|
752
|
+
xw.endElement();
|
|
705
753
|
}
|
|
706
|
-
_dumpStructureDefinition(xw, definition, baseDefinition);
|
|
707
|
-
xw.endElement();
|
|
708
754
|
return;
|
|
709
755
|
}
|
|
710
756
|
}
|
|
@@ -732,6 +778,10 @@ function _markAsVisited(xw, node) {
|
|
|
732
778
|
xw.visitedNode[_hash(node)] = 1;
|
|
733
779
|
}
|
|
734
780
|
function dumpUAVariable(xw, node) {
|
|
781
|
+
(0, node_opcua_assert_1.assert)(node.nodeClass === node_opcua_data_model_1.NodeClass.Variable);
|
|
782
|
+
if (xw.visitedNode[_hash(node)]) {
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
735
785
|
_markAsVisited(xw, node);
|
|
736
786
|
dumpReferencedNodes(xw, node, false);
|
|
737
787
|
const addressSpace = node.addressSpace;
|
|
@@ -764,6 +814,7 @@ function dumpUAVariable(xw, node) {
|
|
|
764
814
|
dumpAggregates(xw, node);
|
|
765
815
|
}
|
|
766
816
|
function dumpUAVariableType(xw, node) {
|
|
817
|
+
(0, node_opcua_assert_1.assert)(node.nodeClass === node_opcua_data_model_1.NodeClass.VariableType);
|
|
767
818
|
xw.visitedNode = xw.visitedNode || {};
|
|
768
819
|
(0, node_opcua_assert_1.assert)(!xw.visitedNode[_hash(node)]);
|
|
769
820
|
xw.visitedNode[_hash(node)] = 1;
|
|
@@ -809,6 +860,7 @@ function dumpUAObject(xw, node) {
|
|
|
809
860
|
xw.writeComment("Object - " + b(xw, node.browseName) + " }}}} ");
|
|
810
861
|
}
|
|
811
862
|
function _dumpUAObject(xw, node) {
|
|
863
|
+
(0, node_opcua_assert_1.assert)(node.nodeClass === node_opcua_data_model_1.NodeClass.Object);
|
|
812
864
|
xw.visitedNode = xw.visitedNode || {};
|
|
813
865
|
(0, node_opcua_assert_1.assert)(!xw.visitedNode[_hash(node)]);
|
|
814
866
|
xw.visitedNode[_hash(node)] = 1;
|
|
@@ -853,6 +905,7 @@ function dumpAggregates(xw, node) {
|
|
|
853
905
|
// Xx xw.writeComment("Aggregates }} ");
|
|
854
906
|
}
|
|
855
907
|
function dumpUAObjectType(xw, node) {
|
|
908
|
+
(0, node_opcua_assert_1.assert)(node.nodeClass === node_opcua_data_model_1.NodeClass.ObjectType);
|
|
856
909
|
(0, node_opcua_assert_1.assert)(node instanceof ua_object_type_impl_1.UAObjectTypeImpl);
|
|
857
910
|
xw.writeComment("ObjectType - " + b(xw, node.browseName) + " {{{{ ");
|
|
858
911
|
_markAsVisited(xw, node);
|
|
@@ -866,6 +919,7 @@ function dumpUAObjectType(xw, node) {
|
|
|
866
919
|
xw.writeComment("ObjectType - " + b(xw, node.browseName) + " }}}}");
|
|
867
920
|
}
|
|
868
921
|
function dumpUAMethod(xw, node) {
|
|
922
|
+
(0, node_opcua_assert_1.assert)(node.nodeClass === node_opcua_data_model_1.NodeClass.Method);
|
|
869
923
|
_markAsVisited(xw, node);
|
|
870
924
|
dumpReferencedNodes(xw, node, false);
|
|
871
925
|
xw.startElement("UAMethod");
|
|
@@ -894,16 +948,16 @@ function resolveDataTypeName(addressSpace, dataType) {
|
|
|
894
948
|
}
|
|
895
949
|
return dataTypeNode.browseName;
|
|
896
950
|
}
|
|
897
|
-
function buildUpAliases(node, xw,
|
|
951
|
+
function buildUpAliases(node, xw, data) {
|
|
898
952
|
const addressSpace = node.addressSpace;
|
|
899
|
-
|
|
900
|
-
|
|
953
|
+
if (!data.aliases_visited)
|
|
954
|
+
data.aliases_visited = {};
|
|
901
955
|
const k = _hash(node);
|
|
902
956
|
// istanbul ignore next
|
|
903
|
-
if (
|
|
957
|
+
if (data.aliases_visited[k]) {
|
|
904
958
|
return;
|
|
905
959
|
}
|
|
906
|
-
|
|
960
|
+
data.aliases_visited[k] = 1;
|
|
907
961
|
// put datatype into aliases list
|
|
908
962
|
if (node.nodeClass === node_opcua_data_model_1.NodeClass.Variable || node.nodeClass === node_opcua_data_model_1.NodeClass.VariableType) {
|
|
909
963
|
const nodeV = node;
|
|
@@ -911,8 +965,8 @@ function buildUpAliases(node, xw, options) {
|
|
|
911
965
|
// name
|
|
912
966
|
const dataTypeName = b(xw, resolveDataTypeName(addressSpace, nodeV.dataType));
|
|
913
967
|
if (dataTypeName) {
|
|
914
|
-
if (!
|
|
915
|
-
|
|
968
|
+
if (!data.aliases[dataTypeName]) {
|
|
969
|
+
data.aliases[dataTypeName] = n(xw, nodeV.dataType);
|
|
916
970
|
}
|
|
917
971
|
}
|
|
918
972
|
}
|
|
@@ -920,8 +974,8 @@ function buildUpAliases(node, xw, options) {
|
|
|
920
974
|
// name
|
|
921
975
|
const dataTypeName = b(xw, resolveDataTypeName(addressSpace, nodeV.dataType));
|
|
922
976
|
if (dataTypeName) {
|
|
923
|
-
if (!
|
|
924
|
-
|
|
977
|
+
if (!data.aliases[dataTypeName]) {
|
|
978
|
+
data.aliases[dataTypeName] = n(xw, nodeV.dataType);
|
|
925
979
|
}
|
|
926
980
|
}
|
|
927
981
|
}
|
|
@@ -929,12 +983,12 @@ function buildUpAliases(node, xw, options) {
|
|
|
929
983
|
function collectReferenceNameInAlias(reference) {
|
|
930
984
|
// reference.referenceType
|
|
931
985
|
const key = b(xw, (0, base_node_impl_1.getReferenceType)(reference).browseName);
|
|
932
|
-
if (!
|
|
986
|
+
if (!data.aliases.key) {
|
|
933
987
|
if (reference.referenceType.namespace === 0) {
|
|
934
|
-
|
|
988
|
+
data.aliases[key] = reference.referenceType.toString().replace("ns=0;", "");
|
|
935
989
|
}
|
|
936
990
|
else {
|
|
937
|
-
|
|
991
|
+
data.aliases[key] = n(xw, reference.referenceType);
|
|
938
992
|
}
|
|
939
993
|
}
|
|
940
994
|
}
|
|
@@ -989,12 +1043,12 @@ function sortByNodeId(a, b) {
|
|
|
989
1043
|
function dumpXml(node, options) {
|
|
990
1044
|
const namespace = node.namespace;
|
|
991
1045
|
// make a first visit so that we determine which node to output and in which order
|
|
992
|
-
const
|
|
1046
|
+
const data = { aliases: {}, aliases_visited: {}, index_el: {}, elements: [] };
|
|
993
1047
|
const dependency = (0, construct_namespace_dependency_1.constructNamespaceDependency)(namespace);
|
|
994
1048
|
const translationTable = constructNamespaceTranslationTable(dependency);
|
|
995
1049
|
const xw = new XMLWriter(true);
|
|
996
1050
|
xw.translationTable = translationTable;
|
|
997
|
-
visitUANode(node,
|
|
1051
|
+
visitUANode(node, data, false);
|
|
998
1052
|
xw.startDocument({ encoding: "utf-8" });
|
|
999
1053
|
xw.startElement("UANodeSet");
|
|
1000
1054
|
xw.writeAttribute("xmlns:xs", "http://www.w3.org/2001/XMLSchema-instance");
|
|
@@ -1002,9 +1056,23 @@ function dumpXml(node, options) {
|
|
|
1002
1056
|
xw.writeAttribute("Version", "1.02");
|
|
1003
1057
|
xw.writeAttribute("LastModified", new Date().toISOString());
|
|
1004
1058
|
xw.writeAttribute("xmlns", "http://opcfoundation.org/UA/2011/03/UANodeSet.xsd");
|
|
1005
|
-
buildUpAliases(node, xw,
|
|
1006
|
-
writeAliases(xw,
|
|
1007
|
-
|
|
1059
|
+
buildUpAliases(node, xw, data);
|
|
1060
|
+
writeAliases(xw, data.aliases);
|
|
1061
|
+
const xmlNamspace = {
|
|
1062
|
+
default: { namespace: "http://opcfoundation.org/UA/2011/03/UANodeSet.xsd" }
|
|
1063
|
+
};
|
|
1064
|
+
xw.startElement("Extensions");
|
|
1065
|
+
{
|
|
1066
|
+
xw.startElement("Extension");
|
|
1067
|
+
{
|
|
1068
|
+
xw.startElement("ModelInfo");
|
|
1069
|
+
xw.writeAttribute("NodeOPCUA");
|
|
1070
|
+
xw.endElement();
|
|
1071
|
+
}
|
|
1072
|
+
xw.endElement();
|
|
1073
|
+
}
|
|
1074
|
+
xw.endElement();
|
|
1075
|
+
for (const el of data.elements) {
|
|
1008
1076
|
el.dumpXML(xw);
|
|
1009
1077
|
}
|
|
1010
1078
|
xw.endElement();
|
|
@@ -1048,6 +1116,11 @@ namespace_impl_1.NamespaceImpl.prototype.toNodeset2XML = function () {
|
|
|
1048
1116
|
// xx xw.writeAttribute("LastModified", (new Date()).toISOString());
|
|
1049
1117
|
// ------------- INamespace Uris
|
|
1050
1118
|
xw.startElement("NamespaceUris");
|
|
1119
|
+
initXmlWriterEx(xw, {
|
|
1120
|
+
"http://opcfoundation.org/UA/2011/03/UANodeSet.xsd": "",
|
|
1121
|
+
"http://opcfoundation.org/UA/2008/02/Types.xsd": "uax",
|
|
1122
|
+
"http://www.w3.org/2001/XMLSchema-instance": "xsi"
|
|
1123
|
+
});
|
|
1051
1124
|
// xx const namespaceArray = namespace.addressSpace.getNamespaceArray();
|
|
1052
1125
|
for (const depend of dependency) {
|
|
1053
1126
|
if (depend.index === 0) {
|
|
@@ -1078,11 +1151,11 @@ namespace_impl_1.NamespaceImpl.prototype.toNodeset2XML = function () {
|
|
|
1078
1151
|
xw.endElement();
|
|
1079
1152
|
}
|
|
1080
1153
|
xw.endElement();
|
|
1081
|
-
const
|
|
1154
|
+
const data = { aliases: {} };
|
|
1082
1155
|
for (const node of this.nodeIterator()) {
|
|
1083
|
-
buildUpAliases(node, xw,
|
|
1156
|
+
buildUpAliases(node, xw, data);
|
|
1084
1157
|
}
|
|
1085
|
-
writeAliases(xw,
|
|
1158
|
+
writeAliases(xw, data.aliases);
|
|
1086
1159
|
xw.visitedNode = {};
|
|
1087
1160
|
// -------------- writeReferences
|
|
1088
1161
|
xw.writeComment("ReferenceTypes");
|
|
@@ -1092,10 +1165,7 @@ namespace_impl_1.NamespaceImpl.prototype.toNodeset2XML = function () {
|
|
|
1092
1165
|
}
|
|
1093
1166
|
// -------------- Dictionaries
|
|
1094
1167
|
const addressSpace = this.addressSpace;
|
|
1095
|
-
const
|
|
1096
|
-
if (opcBinaryTypeSystem) {
|
|
1097
|
-
// let find all DataType dictionary node corresponding to a given namespace
|
|
1098
|
-
// (have DataTypeDictionaryType)
|
|
1168
|
+
const getDataTypeDescription = (opcBinaryTypeSystem) => {
|
|
1099
1169
|
const nodeToBrowse = new node_opcua_types_1.BrowseDescription({
|
|
1100
1170
|
browseDirection: node_opcua_data_model_1.BrowseDirection.Forward,
|
|
1101
1171
|
includeSubtypes: false,
|
|
@@ -1106,12 +1176,8 @@ namespace_impl_1.NamespaceImpl.prototype.toNodeset2XML = function () {
|
|
|
1106
1176
|
});
|
|
1107
1177
|
const result = opcBinaryTypeSystem.browseNode(nodeToBrowse).filter((r) => r.nodeId.namespace === this.index);
|
|
1108
1178
|
(0, node_opcua_assert_1.assert)(result.length <= 1);
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
const dataSystemType = addressSpace.findNode(result[0].nodeId);
|
|
1112
|
-
dumpNodeInXml(xw, dataSystemType);
|
|
1113
|
-
}
|
|
1114
|
-
}
|
|
1179
|
+
return result;
|
|
1180
|
+
};
|
|
1115
1181
|
// -------------- DataTypes
|
|
1116
1182
|
const dataTypes = [...this._dataTypeIterator()].sort(sortByBrowseName);
|
|
1117
1183
|
if (dataTypes.length) {
|
|
@@ -1122,6 +1188,35 @@ namespace_impl_1.NamespaceImpl.prototype.toNodeset2XML = function () {
|
|
|
1122
1188
|
dumpNodeInXml(xw, dataType);
|
|
1123
1189
|
}
|
|
1124
1190
|
}
|
|
1191
|
+
// --------------
|
|
1192
|
+
const opcBinaryTypeSystem = addressSpace.findNode(node_opcua_constants_1.ObjectIds.OPCBinarySchema_TypeSystem);
|
|
1193
|
+
const opcXmlSchemaTypeSystem = addressSpace.findNode(node_opcua_constants_1.ObjectIds.XmlSchema_TypeSystem);
|
|
1194
|
+
if (opcBinaryTypeSystem) {
|
|
1195
|
+
// let find all DataType dictionary node corresponding to a given namespace
|
|
1196
|
+
// (have DataTypeDictionaryType)
|
|
1197
|
+
const result = getDataTypeDescription(opcBinaryTypeSystem);
|
|
1198
|
+
if (result.length === 1) {
|
|
1199
|
+
xw.writeComment("DataSystem - Binary");
|
|
1200
|
+
const dataSystemType = addressSpace.findNode(result[0].nodeId);
|
|
1201
|
+
const types = dataSystemType.getComponents();
|
|
1202
|
+
for (const f of types) {
|
|
1203
|
+
dumpNodeInXml(xw, f);
|
|
1204
|
+
}
|
|
1205
|
+
dumpNodeInXml(xw, dataSystemType);
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
if (opcXmlSchemaTypeSystem) {
|
|
1209
|
+
const result = getDataTypeDescription(opcXmlSchemaTypeSystem);
|
|
1210
|
+
if (result.length === 1) {
|
|
1211
|
+
xw.writeComment("DataSystem - Xml");
|
|
1212
|
+
const dataSystemType = addressSpace.findNode(result[0].nodeId);
|
|
1213
|
+
const types = dataSystemType.getComponents();
|
|
1214
|
+
for (const f of types) {
|
|
1215
|
+
dumpNodeInXml(xw, f);
|
|
1216
|
+
}
|
|
1217
|
+
dumpNodeInXml(xw, dataSystemType);
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1125
1220
|
}
|
|
1126
1221
|
// -------------- ObjectTypes
|
|
1127
1222
|
xw.writeComment("ObjectTypes");
|