node-opcua-address-space 2.60.0 → 2.61.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/helpers/multiform_func.d.ts +11 -0
- package/dist/source/helpers/multiform_func.js +74 -0
- package/dist/source/helpers/multiform_func.js.map +1 -0
- package/dist/src/address_space.js +4 -1
- package/dist/src/address_space.js.map +1 -1
- package/dist/src/base_node_impl.js +2 -0
- package/dist/src/base_node_impl.js.map +1 -1
- package/dist/src/base_node_private.d.ts +3 -3
- package/dist/src/base_node_private.js +196 -23
- package/dist/src/base_node_private.js.map +1 -1
- package/dist/src/ua_method_impl.js +2 -1
- package/dist/src/ua_method_impl.js.map +1 -1
- package/dist/src/ua_object_impl.js +2 -1
- package/dist/src/ua_object_impl.js.map +1 -1
- package/dist/src/ua_variable_impl.d.ts +6 -12
- package/dist/src/ua_variable_impl.js +58 -36
- package/dist/src/ua_variable_impl.js.map +1 -1
- package/dist/src/ua_variable_type_impl.js +47 -34
- package/dist/src/ua_variable_type_impl.js.map +1 -1
- package/dist/src/ua_view_impl.js +1 -1
- package/dist/src/ua_view_impl.js.map +1 -1
- package/package.json +30 -30
- package/source/helpers/multiform_func.ts +76 -0
- package/src/address_space.ts +11 -8
- package/src/base_node_impl.ts +3 -1
- package/src/base_node_private.ts +276 -34
- package/src/ua_method_impl.ts +10 -2
- package/src/ua_object_impl.ts +10 -2
- package/src/ua_variable_impl.ts +153 -131
- package/src/ua_variable_type_impl.ts +79 -39
- package/src/ua_view_impl.ts +1 -1
- package/test_helpers/test_fixtures/fixture_simple_statemachine_nodeset2.xml +9 -0
- package/test_helpers/test_fixtures/fixuture_nodeset_objects_with_some_methods.xml +9 -1
- package/test_helpers/test_fixtures/mini.Node.Set2.xml +8 -1
package/src/base_node_private.ts
CHANGED
|
@@ -34,12 +34,16 @@ import {
|
|
|
34
34
|
CloneOptions
|
|
35
35
|
} from "node-opcua-address-space-base";
|
|
36
36
|
import { DataValue } from "node-opcua-data-value";
|
|
37
|
+
import { ObjectTypeIds, VariableTypeIds } from "node-opcua-constants";
|
|
37
38
|
|
|
38
39
|
import { UANamespace_process_modelling_rule } from "./namespace_private";
|
|
39
40
|
import { ReferenceImpl } from "./reference_impl";
|
|
40
41
|
import { BaseNodeImpl, getReferenceType } from "./base_node_impl";
|
|
41
42
|
import { AddressSpacePrivate } from "./address_space_private";
|
|
42
|
-
|
|
43
|
+
|
|
44
|
+
// eslint-disable-next-line prefer-const
|
|
45
|
+
let dotrace = false;
|
|
46
|
+
const traceLog = console.log.bind(console);
|
|
43
47
|
|
|
44
48
|
const g_weakMap = new WeakMap();
|
|
45
49
|
|
|
@@ -184,7 +188,10 @@ export function BaseNode_References_toString(this: BaseNode, options: ToStringOp
|
|
|
184
188
|
const addressSpace = this.addressSpace;
|
|
185
189
|
|
|
186
190
|
options.add(
|
|
187
|
-
options.padding +
|
|
191
|
+
options.padding +
|
|
192
|
+
chalk.yellow(" references : ") +
|
|
193
|
+
" length =" +
|
|
194
|
+
Object.keys(_private._referenceIdx).length
|
|
188
195
|
);
|
|
189
196
|
|
|
190
197
|
function dump_reference(follow: boolean, reference: UAReference | null) {
|
|
@@ -193,8 +200,37 @@ export function BaseNode_References_toString(this: BaseNode, options: ToStringOp
|
|
|
193
200
|
}
|
|
194
201
|
const o = ReferenceImpl.resolveReferenceNode(addressSpace, reference);
|
|
195
202
|
const name = o ? o.browseName.toString() : "<???>";
|
|
203
|
+
const extra =
|
|
204
|
+
(o.modellingRule || " ")[0] +
|
|
205
|
+
(() => {
|
|
206
|
+
switch (o.nodeClass) {
|
|
207
|
+
case NodeClass.Object:
|
|
208
|
+
return "[O] ";
|
|
209
|
+
case NodeClass.Variable:
|
|
210
|
+
return "[V] " + (o as UAVariable).dataType.toString(displayOptions).padEnd(10);
|
|
211
|
+
case NodeClass.Method:
|
|
212
|
+
return "[M] ";
|
|
213
|
+
case NodeClass.DataType:
|
|
214
|
+
return "[DT]";
|
|
215
|
+
case NodeClass.ReferenceType:
|
|
216
|
+
return "[RT]";
|
|
217
|
+
case NodeClass.ObjectType:
|
|
218
|
+
return "[OT]";
|
|
219
|
+
case NodeClass.VariableType:
|
|
220
|
+
return "[VT]";
|
|
221
|
+
case NodeClass.View:
|
|
222
|
+
return "[V] ";
|
|
223
|
+
}
|
|
224
|
+
return "";
|
|
225
|
+
})();
|
|
196
226
|
options.add(
|
|
197
|
-
options.padding +
|
|
227
|
+
options.padding +
|
|
228
|
+
chalk.yellow(" +-> ") +
|
|
229
|
+
reference.toString(displayOptions) +
|
|
230
|
+
" " +
|
|
231
|
+
chalk.cyan(name.padEnd(25, " ")) +
|
|
232
|
+
" " +
|
|
233
|
+
chalk.magentaBright(extra)
|
|
198
234
|
);
|
|
199
235
|
|
|
200
236
|
// ignore HasTypeDefinition as it has been already handled
|
|
@@ -223,7 +259,7 @@ export function BaseNode_References_toString(this: BaseNode, options: ToStringOp
|
|
|
223
259
|
|
|
224
260
|
options.add(
|
|
225
261
|
options.padding +
|
|
226
|
-
chalk.yellow("
|
|
262
|
+
chalk.yellow(" back_references : ") +
|
|
227
263
|
chalk.cyan(" length =") +
|
|
228
264
|
br.length +
|
|
229
265
|
chalk.grey(" ( references held by other nodes involving this node)")
|
|
@@ -396,6 +432,16 @@ export function VariableOrVariableType_toString(this: UAVariableType | UAVariabl
|
|
|
396
432
|
}
|
|
397
433
|
}
|
|
398
434
|
|
|
435
|
+
const defaultExtraInfo = {
|
|
436
|
+
level: 0,
|
|
437
|
+
pad(): string {
|
|
438
|
+
return "";
|
|
439
|
+
},
|
|
440
|
+
registerClonedObject(node: BaseNode, node1: BaseNode): void {
|
|
441
|
+
/** */
|
|
442
|
+
}
|
|
443
|
+
};
|
|
444
|
+
|
|
399
445
|
/**
|
|
400
446
|
* clone properties and methods
|
|
401
447
|
* @private
|
|
@@ -404,17 +450,17 @@ function _clone_collection_new(
|
|
|
404
450
|
newParent: BaseNode,
|
|
405
451
|
collectionRef: UAReference[],
|
|
406
452
|
copyAlsoModellingRules: boolean,
|
|
407
|
-
optionalFilter
|
|
408
|
-
extraInfo
|
|
453
|
+
optionalFilter: CloneFilter,
|
|
454
|
+
extraInfo: CloneExtraInfo,
|
|
455
|
+
browseNameMap: Set<string>
|
|
409
456
|
): void {
|
|
410
457
|
const namespace = newParent.namespace;
|
|
411
|
-
|
|
458
|
+
extraInfo = extraInfo || defaultExtraInfo;
|
|
412
459
|
const addressSpace = newParent.addressSpace;
|
|
413
460
|
assert(!optionalFilter || (typeof optionalFilter.shouldKeep === "function" && typeof optionalFilter.filterFor === "function"));
|
|
414
461
|
|
|
415
462
|
for (const reference of collectionRef) {
|
|
416
|
-
const node
|
|
417
|
-
|
|
463
|
+
const node = ReferenceImpl.resolveReferenceNode(addressSpace, reference) as UAVariable | UAObject | UAMethod;
|
|
418
464
|
// ensure node is of the correct type,
|
|
419
465
|
// it may happen that the xml nodeset2 file was malformed
|
|
420
466
|
|
|
@@ -433,18 +479,41 @@ function _clone_collection_new(
|
|
|
433
479
|
}
|
|
434
480
|
|
|
435
481
|
if (optionalFilter && node && !optionalFilter.shouldKeep(node)) {
|
|
482
|
+
dotrace && traceLog(extraInfo.pad(), "skipping ", node.browseName.toString());
|
|
436
483
|
continue; // skip this node
|
|
437
484
|
}
|
|
485
|
+
const key = node.browseName.toString();
|
|
486
|
+
if (browseNameMap?.has(key)) {
|
|
487
|
+
continue; // skipping node with same browseName
|
|
488
|
+
}
|
|
489
|
+
browseNameMap?.add(key);
|
|
438
490
|
|
|
439
|
-
assert(reference.isForward);
|
|
440
|
-
assert(reference.referenceType instanceof NodeId, "" + reference.referenceType.toString());
|
|
491
|
+
// assert(reference.isForward);
|
|
492
|
+
// assert(reference.referenceType instanceof NodeId, "" + reference.referenceType.toString());
|
|
441
493
|
const options = {
|
|
442
494
|
namespace,
|
|
443
495
|
references: [new ReferenceImpl({ referenceType: reference.referenceType, isForward: false, nodeId: newParent.nodeId })],
|
|
444
496
|
copyAlsoModellingRules
|
|
445
497
|
};
|
|
446
498
|
|
|
499
|
+
dotrace &&
|
|
500
|
+
traceLog(
|
|
501
|
+
extraInfo.pad(),
|
|
502
|
+
"cloning => ",
|
|
503
|
+
reference.referenceType.toString({ addressSpace }),
|
|
504
|
+
"=>",
|
|
505
|
+
node.browseName.toString(),
|
|
506
|
+
chalk.magentaBright(node.typeDefinitionObj?.browseName.toString())
|
|
507
|
+
);
|
|
508
|
+
|
|
509
|
+
extraInfo.level += 4;
|
|
447
510
|
const clone = (node as UAVariable | UAMethod | UAObject).clone(options, optionalFilter, extraInfo);
|
|
511
|
+
extraInfo.level -= 4;
|
|
512
|
+
|
|
513
|
+
// also clone or instantiate interface members that may be required in the optionals
|
|
514
|
+
extraInfo.level++;
|
|
515
|
+
_cloneInterface(newParent, node, optionalFilter, extraInfo, browseNameMap);
|
|
516
|
+
extraInfo.level--;
|
|
448
517
|
|
|
449
518
|
if (extraInfo) {
|
|
450
519
|
extraInfo.registerClonedObject(node, clone);
|
|
@@ -452,24 +521,179 @@ function _clone_collection_new(
|
|
|
452
521
|
}
|
|
453
522
|
}
|
|
454
523
|
|
|
455
|
-
|
|
456
|
-
|
|
524
|
+
type UAInterface = UAObjectType;
|
|
525
|
+
function _extractInterfaces2(typeDefinitionNode: UAObjectType | UAVariableType, extraInfo: CloneExtraInfo): UAInterface[] {
|
|
526
|
+
if (
|
|
527
|
+
!typeDefinitionNode ||
|
|
528
|
+
(typeDefinitionNode.nodeId.namespace === 0 &&
|
|
529
|
+
(typeDefinitionNode.nodeId.value === ObjectTypeIds.BaseObjectType ||
|
|
530
|
+
typeDefinitionNode.nodeId.value === VariableTypeIds.BaseVariableType))
|
|
531
|
+
) {
|
|
532
|
+
return [];
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
const addressSpace = typeDefinitionNode.addressSpace;
|
|
536
|
+
// example:
|
|
537
|
+
// FolderType
|
|
538
|
+
// FunctionalGroupType
|
|
539
|
+
// MachineryItemIdentificationType : IMachineryItemVendorNameplateType
|
|
540
|
+
// MachineIdentificationType : IMachineTagNameplateType, IMachineVendorNamePlateType
|
|
541
|
+
// MachineToolIdentificationType
|
|
542
|
+
//
|
|
543
|
+
//
|
|
544
|
+
// IMachineTagNameplateType -subTypeOf-> ITagNameplateType
|
|
545
|
+
// IMachineVendorNamePlateType -subTypeOf-> IMachineryItemVendorNamePlateType
|
|
546
|
+
// IMachineryItemVendorNamePlateType -subTypeOf-> IVendorNameplateType
|
|
547
|
+
const interfacesRef = typeDefinitionNode.findReferencesEx("HasInterface", BrowseDirection.Forward);
|
|
548
|
+
const interfaces = interfacesRef.map((r) => addressSpace.findNode(r.nodeId) as UAInterface);
|
|
549
|
+
|
|
550
|
+
const baseInterfaces: UAInterface[] = [];
|
|
551
|
+
for (const iface of interfaces) {
|
|
552
|
+
dotrace &&
|
|
553
|
+
traceLog(
|
|
554
|
+
extraInfo.pad(),
|
|
555
|
+
typeDefinitionNode.browseName.toString(),
|
|
556
|
+
" - has interface -> ",
|
|
557
|
+
iface.browseName.toString()
|
|
558
|
+
);
|
|
559
|
+
baseInterfaces.push(iface);
|
|
560
|
+
if (iface.subtypeOfObj) {
|
|
561
|
+
extraInfo.level++;
|
|
562
|
+
baseInterfaces.push(..._extractInterfaces2(iface.subtypeOfObj, extraInfo));
|
|
563
|
+
extraInfo.level--;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
interfaces.push(...baseInterfaces);
|
|
567
|
+
if (typeDefinitionNode.subtypeOfObj) {
|
|
568
|
+
dotrace &&
|
|
569
|
+
traceLog(
|
|
570
|
+
extraInfo.pad(),
|
|
571
|
+
typeDefinitionNode.browseName.toString(),
|
|
572
|
+
" - subtypef -> ",
|
|
573
|
+
typeDefinitionNode.subtypeOfObj.browseName.toString()
|
|
574
|
+
);
|
|
575
|
+
extraInfo.level++;
|
|
576
|
+
interfaces.push(..._extractInterfaces2(typeDefinitionNode.subtypeOfObj, extraInfo));
|
|
577
|
+
extraInfo.level--;
|
|
578
|
+
}
|
|
579
|
+
const dedupedInterfaces = [...new Set(interfaces)];
|
|
580
|
+
|
|
581
|
+
dotrace &&
|
|
582
|
+
traceLog(
|
|
583
|
+
extraInfo.pad(),
|
|
584
|
+
chalk.yellow("Interface for ", typeDefinitionNode.browseName.toString()),
|
|
585
|
+
"=",
|
|
586
|
+
dedupedInterfaces.map((x) => x.browseName.toString()).join(" ")
|
|
587
|
+
);
|
|
588
|
+
return dedupedInterfaces;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
/*
|
|
592
|
+
|
|
593
|
+
// also find all related interfaces
|
|
594
|
+
if (false && typeDefinitionNode) {
|
|
595
|
+
dotrace && tracelog("typeDefinitionNode = ", typeDefinitionNode.browseName.toString());
|
|
596
|
+
const interfaces = _extractInterfaces(typeDefinitionNode);
|
|
597
|
+
for (const interfaceNode of interfaces) {
|
|
598
|
+
dotrace && tracelog(" adding member of interface ", interfaceNode.browseName.toString());
|
|
599
|
+
const fromInterface = interfaceNode.findReferencesEx("Aggregates", BrowseDirection.Forward);
|
|
600
|
+
dotrace && tracelog(
|
|
601
|
+
" B ",
|
|
602
|
+
fromInterface.map((r) => r.toString({ addressSpace }) + " " + r.node!.browseName.toString()).join("\n")
|
|
603
|
+
);
|
|
604
|
+
add(fromInterface);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
*/
|
|
608
|
+
|
|
609
|
+
function _crap_extractInterfaces(typeDefinitionNode: UAObjectType | UAVariableType, extraInfo: CloneExtraInfo): UAInterface[] {
|
|
610
|
+
if (
|
|
611
|
+
typeDefinitionNode.nodeId.namespace === 0 &&
|
|
612
|
+
(typeDefinitionNode.nodeId.value === ObjectTypeIds.BaseObjectType ||
|
|
613
|
+
typeDefinitionNode.nodeId.value === VariableTypeIds.BaseVariableType)
|
|
614
|
+
) {
|
|
615
|
+
return [];
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
const addressSpace = typeDefinitionNode.addressSpace;
|
|
619
|
+
// example:
|
|
620
|
+
// FolderType
|
|
621
|
+
// FunctionalGroupType
|
|
622
|
+
// MachineryItemIdentificationType : IMachineryItemVendorNameplateType
|
|
623
|
+
// MachineIdentificationType : IMachineTagNameplateType, IMachineVendorNamePlateType
|
|
624
|
+
// MachineToolIdentificationType
|
|
625
|
+
//
|
|
626
|
+
//
|
|
627
|
+
// IMachineTagNameplateType -subTypeOf-> ITagNameplateType
|
|
628
|
+
// IMachineVendorNamePlateType -subTypeOf-> IMachineryItemVendorNamePlateType
|
|
629
|
+
// IMachineryItemVendorNamePlateType -subTypeOf-> IVendorNameplateType
|
|
630
|
+
const interfacesRef = typeDefinitionNode.findReferencesEx("HasInterface", BrowseDirection.Forward);
|
|
631
|
+
const interfaces = interfacesRef.map((r) => r.node! as UAInterface);
|
|
632
|
+
for (const iface of interfaces) {
|
|
633
|
+
dotrace && traceLog(extraInfo.pad(), " interface ", iface.browseName.toString());
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
return interfaces;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
function _cloneInterface(
|
|
457
640
|
newParent: BaseNode,
|
|
641
|
+
node: UAObject | UAVariable | UAMethod,
|
|
642
|
+
optionalFilter: CloneFilter,
|
|
643
|
+
extraInfo: CloneExtraInfo,
|
|
644
|
+
browseNameMap: Set<string>
|
|
645
|
+
): void {
|
|
646
|
+
dotrace &&
|
|
647
|
+
traceLog(
|
|
648
|
+
extraInfo?.pad(),
|
|
649
|
+
chalk.green("-------------------- now cloning interfaces of ", node.browseName.toString(), node.nodeId.toString())
|
|
650
|
+
);
|
|
651
|
+
|
|
652
|
+
extraInfo = extraInfo || defaultExtraInfo;
|
|
653
|
+
const addressSpace = node.addressSpace;
|
|
654
|
+
const typeDefinitionNode = node.typeDefinitionObj;
|
|
655
|
+
if (!typeDefinitionNode) {
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
dotrace && traceLog(extraInfo.pad(), " --- {");
|
|
659
|
+
const interfaces = _extractInterfaces2(typeDefinitionNode, extraInfo);
|
|
660
|
+
dotrace && traceLog(extraInfo.pad(), " --- }");
|
|
661
|
+
dotrace && traceLog(extraInfo?.pad(), chalk.green("-------------------- interfaces are ", interfaces.length));
|
|
662
|
+
|
|
663
|
+
const localFilter = optionalFilter.filterFor(node);
|
|
664
|
+
|
|
665
|
+
for (const iface of interfaces) {
|
|
666
|
+
const aggregates = iface.findReferencesEx("Aggregates", BrowseDirection.Forward);
|
|
667
|
+
dotrace &&
|
|
668
|
+
traceLog(
|
|
669
|
+
extraInfo.pad(),
|
|
670
|
+
chalk.magentaBright(" interface ", iface.browseName.toString()),
|
|
671
|
+
"\n" + extraInfo?.pad(),
|
|
672
|
+
aggregates.map((r) => r.toString({ addressSpace })).join("\n" + extraInfo?.pad())
|
|
673
|
+
);
|
|
674
|
+
_clone_collection_new(newParent, aggregates, false, localFilter, extraInfo, browseNameMap);
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
export function _clone_children_references(
|
|
678
|
+
node: UAObject | UAVariable | UAMethod | UAObjectType | UAVariableType,
|
|
679
|
+
newParent: UAObject | UAVariable | UAMethod,
|
|
458
680
|
copyAlsoModellingRules: boolean,
|
|
459
|
-
optionalFilter
|
|
460
|
-
extraInfo
|
|
681
|
+
optionalFilter: CloneFilter,
|
|
682
|
+
extraInfo: CloneExtraInfo,
|
|
683
|
+
browseNameMap: Set<string>
|
|
461
684
|
): void {
|
|
462
685
|
// find all reference that derives from the Aggregates
|
|
463
686
|
const aggregatesRef = node.findReferencesEx("Aggregates", BrowseDirection.Forward);
|
|
464
|
-
_clone_collection_new(newParent, aggregatesRef, copyAlsoModellingRules, optionalFilter, extraInfo);
|
|
687
|
+
_clone_collection_new(newParent, aggregatesRef, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap);
|
|
465
688
|
}
|
|
466
689
|
|
|
467
690
|
export function _clone_non_hierarchical_references(
|
|
468
691
|
node: BaseNode,
|
|
469
692
|
newParent: BaseNode,
|
|
470
693
|
copyAlsoModellingRules: boolean,
|
|
471
|
-
optionalFilter
|
|
472
|
-
extraInfo
|
|
694
|
+
optionalFilter: CloneFilter,
|
|
695
|
+
extraInfo: CloneExtraInfo,
|
|
696
|
+
browseNameMap: Set<string>
|
|
473
697
|
): void {
|
|
474
698
|
// clone only some non hierarchical_references that we do want to clone
|
|
475
699
|
// such as:
|
|
@@ -478,7 +702,7 @@ export function _clone_non_hierarchical_references(
|
|
|
478
702
|
assert(newParent instanceof BaseNodeImpl);
|
|
479
703
|
// find all reference that derives from the HasSubStateMachine
|
|
480
704
|
const references = node.findReferencesEx("HasSubStateMachine", BrowseDirection.Forward);
|
|
481
|
-
_clone_collection_new(newParent, references, copyAlsoModellingRules, optionalFilter, extraInfo);
|
|
705
|
+
_clone_collection_new(newParent, references, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap);
|
|
482
706
|
}
|
|
483
707
|
|
|
484
708
|
/**
|
|
@@ -489,8 +713,8 @@ export function _clone<T extends UAObject | UAVariable | UAMethod>(
|
|
|
489
713
|
this: T,
|
|
490
714
|
Constructor: new (options: any) => T,
|
|
491
715
|
options: CloneOptions,
|
|
492
|
-
optionalFilter
|
|
493
|
-
extraInfo
|
|
716
|
+
optionalFilter: CloneFilter,
|
|
717
|
+
extraInfo: CloneExtraInfo
|
|
494
718
|
): T {
|
|
495
719
|
assert(typeof Constructor === "function");
|
|
496
720
|
assert(options !== null && typeof options === "object");
|
|
@@ -548,9 +772,31 @@ export function _clone<T extends UAObject | UAVariable | UAMethod>(
|
|
|
548
772
|
|
|
549
773
|
options.copyAlsoModellingRules = options.copyAlsoModellingRules || false;
|
|
550
774
|
|
|
551
|
-
const newFilter = optionalFilter
|
|
552
|
-
|
|
553
|
-
|
|
775
|
+
const newFilter = optionalFilter.filterFor(cloneObj);
|
|
776
|
+
|
|
777
|
+
const browseNameMap = new Set<string>();
|
|
778
|
+
_clone_children_references(this, cloneObj, options.copyAlsoModellingRules, newFilter!, extraInfo, browseNameMap);
|
|
779
|
+
|
|
780
|
+
//
|
|
781
|
+
let typeDefinitionNode: UAVariableType | UAObjectType | null = this.typeDefinitionObj;
|
|
782
|
+
while (typeDefinitionNode) {
|
|
783
|
+
dotrace &&
|
|
784
|
+
traceLog(
|
|
785
|
+
extraInfo?.pad(),
|
|
786
|
+
chalk.blueBright("---------------------- Exploring ", typeDefinitionNode.browseName.toString())
|
|
787
|
+
);
|
|
788
|
+
_clone_children_references(
|
|
789
|
+
typeDefinitionNode,
|
|
790
|
+
cloneObj,
|
|
791
|
+
options.copyAlsoModellingRules,
|
|
792
|
+
newFilter,
|
|
793
|
+
extraInfo,
|
|
794
|
+
browseNameMap
|
|
795
|
+
);
|
|
796
|
+
typeDefinitionNode = typeDefinitionNode.subtypeOfObj;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
_clone_non_hierarchical_references(this, cloneObj, options.copyAlsoModellingRules, newFilter, extraInfo, browseNameMap);
|
|
554
800
|
|
|
555
801
|
cloneObj.propagate_back_references();
|
|
556
802
|
|
|
@@ -588,7 +834,7 @@ function _remove_HierarchicalReference(node: BaseNode, reference: UAReference) {
|
|
|
588
834
|
if (referenceType.isSupertypeOf(HierarchicalReferencesType!)) {
|
|
589
835
|
assert(reference.isForward);
|
|
590
836
|
const targetNode = ReferenceImpl.resolveReferenceNode(addressSpace, reference);
|
|
591
|
-
// Xx
|
|
837
|
+
// Xx dotrace && tracelog(" adding object to map");
|
|
592
838
|
delete _cache._childByNameMap[targetNode.browseName!.name!.toString()];
|
|
593
839
|
}
|
|
594
840
|
}
|
|
@@ -669,18 +915,14 @@ export function BaseNode_add_backward_reference(this: BaseNode, reference: UARef
|
|
|
669
915
|
// istanbul ignore next
|
|
670
916
|
if (_private._back_referenceIdx[h]) {
|
|
671
917
|
const opts = { addressSpace: this.addressSpace };
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
// tslint:disable-next-line:no-console
|
|
677
|
-
console.warn(" already found in ===>");
|
|
678
|
-
// tslint:disable-next-line:no-console
|
|
679
|
-
console.warn(
|
|
918
|
+
warningLog(" Warning !", this.browseName.toString());
|
|
919
|
+
warningLog(" ", reference.toString(opts));
|
|
920
|
+
warningLog(" already found in ===>");
|
|
921
|
+
warningLog(
|
|
680
922
|
(Object.values(_private._back_referenceIdx) as UAReference[]).map((c: UAReference) => c.toString(opts)).join("\n")
|
|
681
923
|
);
|
|
682
924
|
// tslint:disable-next-line:no-console
|
|
683
|
-
|
|
925
|
+
warningLog("===>");
|
|
684
926
|
throw new Error("reference exists already in _back_references");
|
|
685
927
|
}
|
|
686
928
|
|
package/src/ua_method_impl.ts
CHANGED
|
@@ -27,7 +27,9 @@ import {
|
|
|
27
27
|
CloneOptions,
|
|
28
28
|
UAObjectType,
|
|
29
29
|
ISessionContext,
|
|
30
|
-
UAVariable
|
|
30
|
+
UAVariable,
|
|
31
|
+
defaultCloneFilter,
|
|
32
|
+
defaultCloneExtraInfo
|
|
31
33
|
} from "node-opcua-address-space-base";
|
|
32
34
|
import { SessionContext } from "../source";
|
|
33
35
|
import { _clone } from "./base_node_private";
|
|
@@ -256,7 +258,13 @@ export class UAMethodImpl extends BaseNodeImpl implements UAMethod {
|
|
|
256
258
|
|
|
257
259
|
_handle_hierarchy_parent(addressSpace, options.references, options);
|
|
258
260
|
|
|
259
|
-
const clonedMethod = _clone.call(
|
|
261
|
+
const clonedMethod = _clone.call(
|
|
262
|
+
this,
|
|
263
|
+
UAMethodImpl,
|
|
264
|
+
options,
|
|
265
|
+
optionalFilter || defaultCloneFilter,
|
|
266
|
+
extraInfo || defaultCloneExtraInfo
|
|
267
|
+
) as UAMethodImpl;
|
|
260
268
|
|
|
261
269
|
clonedMethod._asyncExecutionFunction = this._asyncExecutionFunction;
|
|
262
270
|
clonedMethod._getExecutableFlag = this._getExecutableFlag;
|
package/src/ua_object_impl.ts
CHANGED
|
@@ -25,7 +25,9 @@ import {
|
|
|
25
25
|
CloneExtraInfo,
|
|
26
26
|
BaseNode,
|
|
27
27
|
UAEventType,
|
|
28
|
-
IEventData
|
|
28
|
+
IEventData,
|
|
29
|
+
defaultCloneFilter,
|
|
30
|
+
defaultCloneExtraInfo
|
|
29
31
|
} from "node-opcua-address-space-base";
|
|
30
32
|
|
|
31
33
|
import { BaseNodeImpl, InternalBaseNodeOptions } from "./base_node_impl";
|
|
@@ -80,7 +82,13 @@ export class UAObjectImpl extends BaseNodeImpl implements UAObject {
|
|
|
80
82
|
symbolicName: this.symbolicName || undefined
|
|
81
83
|
};
|
|
82
84
|
|
|
83
|
-
const cloneObject = _clone.call(
|
|
85
|
+
const cloneObject = _clone.call(
|
|
86
|
+
this,
|
|
87
|
+
UAObjectImpl,
|
|
88
|
+
options,
|
|
89
|
+
optionalFilter || defaultCloneFilter,
|
|
90
|
+
extraInfo || defaultCloneExtraInfo
|
|
91
|
+
) as UAObject;
|
|
84
92
|
// xx newObject.propagate_back_references();
|
|
85
93
|
// xx newObject.install_extra_properties();
|
|
86
94
|
return cloneObject;
|