node-opcua-address-space 2.106.0 → 2.108.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/coerce_enum_value.js +5 -4
- package/dist/source/helpers/coerce_enum_value.js.map +1 -1
- package/dist/source/loader/load_nodeset2.js +1 -1
- package/dist/source/loader/load_nodeset2.js.map +1 -1
- package/dist/source/loader/register_node_promoter.d.ts +1 -1
- package/dist/source/loader/register_node_promoter.js +2 -2
- package/dist/source/loader/register_node_promoter.js.map +1 -1
- package/dist/src/_instantiate_helpers.d.ts +2 -0
- package/dist/src/_instantiate_helpers.js +80 -0
- package/dist/src/_instantiate_helpers.js.map +1 -0
- package/dist/src/_mandatory_child_or_requested_optional_filter.d.ts +9 -0
- package/dist/src/_mandatory_child_or_requested_optional_filter.js +80 -0
- package/dist/src/_mandatory_child_or_requested_optional_filter.js.map +1 -0
- package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js +3 -0
- package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js +1 -1
- package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js.map +1 -1
- package/dist/src/alarms_and_conditions/ua_condition_impl.d.ts +2 -2
- package/dist/src/alarms_and_conditions/ua_condition_impl.js +2 -1
- package/dist/src/alarms_and_conditions/ua_condition_impl.js.map +1 -1
- package/dist/src/base_node_private.d.ts +1 -1
- package/dist/src/base_node_private.js +82 -82
- package/dist/src/base_node_private.js.map +1 -1
- package/dist/src/extension_object_array_node.js +2 -1
- package/dist/src/extension_object_array_node.js.map +1 -1
- package/dist/src/namespace_impl.d.ts +1 -1
- package/dist/src/namespace_impl.js +6 -6
- package/dist/src/namespace_impl.js.map +1 -1
- package/dist/src/state_machine/finite_state_machine.d.ts +1 -1
- package/dist/src/state_machine/finite_state_machine.js +204 -19
- package/dist/src/state_machine/finite_state_machine.js.map +1 -1
- package/dist/src/ua_method_impl.js +4 -1
- package/dist/src/ua_method_impl.js.map +1 -1
- package/dist/src/ua_object_impl.js +2 -3
- package/dist/src/ua_object_impl.js.map +1 -1
- package/dist/src/ua_object_type_impl.js +2 -1
- package/dist/src/ua_object_type_impl.js.map +1 -1
- package/dist/src/ua_variable_impl.d.ts +1 -1
- package/dist/src/ua_variable_impl.js +6 -4
- package/dist/src/ua_variable_impl.js.map +1 -1
- package/dist/src/ua_variable_type_impl.d.ts +5 -3
- package/dist/src/ua_variable_type_impl.js +8 -132
- package/dist/src/ua_variable_type_impl.js.map +1 -1
- package/dist/tsconfig_common.tsbuildinfo +1 -1
- package/package.json +38 -38
- package/source/helpers/coerce_enum_value.ts +5 -5
- package/source/loader/load_nodeset2.ts +1 -1
- package/source/loader/register_node_promoter.ts +3 -6
- package/src/_instantiate_helpers.ts +141 -0
- package/src/_mandatory_child_or_requested_optional_filter.ts +98 -0
- package/src/alarms_and_conditions/ua_alarm_condition_impl.ts +3 -0
- package/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.ts +1 -1
- package/src/alarms_and_conditions/ua_condition_impl.ts +7 -5
- package/src/base_node_private.ts +100 -117
- package/src/extension_object_array_node.ts +4 -3
- package/src/namespace_impl.ts +11 -7
- package/src/state_machine/finite_state_machine.ts +250 -37
- package/src/ua_method_impl.ts +4 -1
- package/src/ua_object_impl.ts +2 -3
- package/src/ua_object_type_impl.ts +1 -1
- package/src/ua_variable_impl.ts +7 -7
- package/src/ua_variable_type_impl.ts +4 -202
package/src/base_node_private.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* eslint-disable complexity */
|
|
2
|
+
/* eslint-disable max-statements */
|
|
1
3
|
/**
|
|
2
4
|
* @module node-opcua-address-space.Private
|
|
3
5
|
*/
|
|
@@ -32,7 +34,8 @@ import {
|
|
|
32
34
|
ISessionContext,
|
|
33
35
|
UAReference,
|
|
34
36
|
CloneOptions,
|
|
35
|
-
CloneHelper
|
|
37
|
+
CloneHelper,
|
|
38
|
+
fullPath2
|
|
36
39
|
} from "node-opcua-address-space-base";
|
|
37
40
|
import { DataValue } from "node-opcua-data-value";
|
|
38
41
|
import { ObjectTypeIds, VariableTypeIds } from "node-opcua-constants";
|
|
@@ -222,7 +225,7 @@ export function BaseNode_References_toString(this: BaseNode, options: ToStringOp
|
|
|
222
225
|
}
|
|
223
226
|
const o = ReferenceImpl.resolveReferenceNode(addressSpace, reference);
|
|
224
227
|
if (!o) {
|
|
225
|
-
warningLog("cannot find
|
|
228
|
+
warningLog("cannot find reference", reference.toString());
|
|
226
229
|
return;
|
|
227
230
|
}
|
|
228
231
|
const name = o.browseName.toString();
|
|
@@ -464,7 +467,7 @@ export function VariableOrVariableType_toString(this: UAVariableType | UAVariabl
|
|
|
464
467
|
*
|
|
465
468
|
* MyDeriveType ------------------- -> MyBaseType --------------> TopologyElementType
|
|
466
469
|
* | | |
|
|
467
|
-
* +-
|
|
470
|
+
* +- ParameterSet +-> ParameterSet +-> ParameterSet
|
|
468
471
|
* | |
|
|
469
472
|
* +- Foo1 |
|
|
470
473
|
* +- Bar
|
|
@@ -485,8 +488,7 @@ function _clone_children_on_template(
|
|
|
485
488
|
node: BaseNode,
|
|
486
489
|
copyAlsoModellingRules: boolean,
|
|
487
490
|
optionalFilter: CloneFilter,
|
|
488
|
-
extraInfo: CloneExtraInfo
|
|
489
|
-
browseNameMap: Set<string>
|
|
491
|
+
extraInfo: CloneExtraInfo
|
|
490
492
|
) {
|
|
491
493
|
/**
|
|
492
494
|
* the type definition node of the node to clone
|
|
@@ -497,10 +499,11 @@ function _clone_children_on_template(
|
|
|
497
499
|
: null;
|
|
498
500
|
if (!nodeToCloneTypeDefinition) return;
|
|
499
501
|
|
|
502
|
+
// istanbul ignore next
|
|
500
503
|
doTrace &&
|
|
501
504
|
traceLog(
|
|
502
505
|
extraInfo?.pad(),
|
|
503
|
-
chalk.
|
|
506
|
+
chalk.gray(
|
|
504
507
|
"-------------------- now cloning children on template ",
|
|
505
508
|
node.browseName.toString(),
|
|
506
509
|
node.nodeId.toString(),
|
|
@@ -523,6 +526,7 @@ function _clone_children_on_template(
|
|
|
523
526
|
|
|
524
527
|
let typeDefinitionNode: UAVariableType | UAObjectType | null = nodeToCloneTypeDefinition;
|
|
525
528
|
while (typeDefinitionNode) {
|
|
529
|
+
// istanbul ignore next
|
|
526
530
|
doTrace &&
|
|
527
531
|
traceLog(
|
|
528
532
|
extraInfo?.pad(),
|
|
@@ -550,6 +554,7 @@ function _clone_children_on_template(
|
|
|
550
554
|
const hasAlready = newParentChild.getChildByName(grandChild.browseName) !== null;
|
|
551
555
|
if (!hasAlready) {
|
|
552
556
|
if (optionalFilter && node && !optionalFilter.shouldKeep(node)) {
|
|
557
|
+
// istanbul ignore next
|
|
553
558
|
doTrace &&
|
|
554
559
|
traceLog(
|
|
555
560
|
extraInfo.pad(),
|
|
@@ -572,7 +577,11 @@ function _clone_children_on_template(
|
|
|
572
577
|
copyAlsoModellingRules
|
|
573
578
|
};
|
|
574
579
|
|
|
575
|
-
const alreadyCloned = extraInfo.getCloned(
|
|
580
|
+
const alreadyCloned = extraInfo.getCloned({
|
|
581
|
+
originalParent: nodeToClone,
|
|
582
|
+
clonedParent: newParent,
|
|
583
|
+
originalNode: grandChild
|
|
584
|
+
});
|
|
576
585
|
if (alreadyCloned) {
|
|
577
586
|
alreadyCloned.addReference({
|
|
578
587
|
referenceType: ref.referenceType,
|
|
@@ -581,7 +590,10 @@ function _clone_children_on_template(
|
|
|
581
590
|
});
|
|
582
591
|
} else {
|
|
583
592
|
const clonedGrandChild = grandChild.clone(options, optionalFilter, extraInfo);
|
|
584
|
-
extraInfo.registerClonedObject(
|
|
593
|
+
extraInfo.registerClonedObject({
|
|
594
|
+
originalNode: grandChild,
|
|
595
|
+
clonedNode: clonedGrandChild
|
|
596
|
+
});
|
|
585
597
|
}
|
|
586
598
|
}
|
|
587
599
|
}
|
|
@@ -589,7 +601,8 @@ function _clone_children_on_template(
|
|
|
589
601
|
typeDefinitionNode = typeDefinitionNode.subtypeOfObj;
|
|
590
602
|
}
|
|
591
603
|
}
|
|
592
|
-
|
|
604
|
+
|
|
605
|
+
/*
|
|
593
606
|
* clone properties and methods
|
|
594
607
|
* @private
|
|
595
608
|
*/
|
|
@@ -617,31 +630,38 @@ function _clone_collection_new(
|
|
|
617
630
|
// tslint:disable-next-line:no-console
|
|
618
631
|
warningLog(
|
|
619
632
|
chalk.red("Warning : cannot clone node ") +
|
|
620
|
-
node
|
|
633
|
+
fullPath2(node) +
|
|
621
634
|
" of class " +
|
|
622
635
|
NodeClass[node.nodeClass].toString() +
|
|
623
636
|
" while cloning " +
|
|
624
|
-
newParent
|
|
637
|
+
fullPath2(newParent)
|
|
625
638
|
);
|
|
626
639
|
continue;
|
|
627
640
|
}
|
|
641
|
+
if (node && !node.modellingRule) {
|
|
642
|
+
// istanbul ignore next
|
|
643
|
+
doTrace && traceLog(extraInfo.pad(), "skipping with no modelling rule", fullPath2(node));
|
|
644
|
+
// those node stays in the Type
|
|
645
|
+
continue; // skip this node
|
|
646
|
+
}
|
|
628
647
|
|
|
629
648
|
if (optionalFilter && node && !optionalFilter.shouldKeep(node)) {
|
|
630
|
-
|
|
631
|
-
|
|
649
|
+
// istanbul ignore next
|
|
650
|
+
doTrace && traceLog(extraInfo.pad(), "skipping optional that doesn't appear in the filter", fullPath2(node));
|
|
632
651
|
continue; // skip this node
|
|
633
652
|
}
|
|
634
|
-
const key = node.browseName.toString();
|
|
653
|
+
const key = newParent.nodeId.toString() + "(" + newParent.browseName.toString() + ")" + "/" + node.browseName.toString();
|
|
635
654
|
if (browseNameMap?.has(key)) {
|
|
636
|
-
_clone_children_on_template(
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
655
|
+
_clone_children_on_template(nodeToClone, newParent, node, copyAlsoModellingRules, optionalFilter, extraInfo);
|
|
656
|
+
doTrace &&
|
|
657
|
+
traceLog(
|
|
658
|
+
extraInfo.pad(),
|
|
659
|
+
"skipping required node with same browseName",
|
|
660
|
+
fullPath2(node),
|
|
661
|
+
"because it has already been cloned",
|
|
662
|
+
"key=",
|
|
663
|
+
key
|
|
664
|
+
);
|
|
645
665
|
|
|
646
666
|
continue; // skipping node with same browseName
|
|
647
667
|
}
|
|
@@ -655,17 +675,20 @@ function _clone_collection_new(
|
|
|
655
675
|
copyAlsoModellingRules
|
|
656
676
|
};
|
|
657
677
|
|
|
658
|
-
const alreadyCloned = extraInfo.getCloned(node);
|
|
678
|
+
const alreadyCloned = extraInfo.getCloned({ originalParent: nodeToClone, clonedParent: newParent, originalNode: node });
|
|
659
679
|
if (alreadyCloned) {
|
|
660
|
-
//
|
|
680
|
+
// istanbul ignore next
|
|
661
681
|
doTrace &&
|
|
662
682
|
traceLog(
|
|
663
683
|
extraInfo.pad(),
|
|
664
684
|
"node ",
|
|
665
|
-
node
|
|
666
|
-
node.nodeId.toString(),
|
|
685
|
+
fullPath2(node),
|
|
667
686
|
"already cloned as",
|
|
668
|
-
alreadyCloned
|
|
687
|
+
fullPath2(alreadyCloned),
|
|
688
|
+
"\nnode to clone =",
|
|
689
|
+
fullPath2(nodeToClone),
|
|
690
|
+
"\nnew parent =",
|
|
691
|
+
fullPath2(newParent)
|
|
669
692
|
);
|
|
670
693
|
|
|
671
694
|
const hasReference =
|
|
@@ -677,39 +700,31 @@ function _clone_collection_new(
|
|
|
677
700
|
nodeId: newParent.nodeId
|
|
678
701
|
});
|
|
679
702
|
} else {
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
extraInfo.pad(),
|
|
683
|
-
"reference to node ",
|
|
684
|
-
alreadyCloned.browseName.toString(),
|
|
685
|
-
alreadyCloned.nodeId.toString(),
|
|
686
|
-
" already exists !"
|
|
687
|
-
);
|
|
703
|
+
// istanbul ignore next
|
|
704
|
+
doTrace && traceLog(extraInfo.pad(), "reference to node ", fullPath2(alreadyCloned), " already exists !");
|
|
688
705
|
}
|
|
689
706
|
} else {
|
|
707
|
+
// istanbul ignore next
|
|
690
708
|
doTrace &&
|
|
691
709
|
traceLog(
|
|
692
710
|
extraInfo.pad(),
|
|
693
711
|
"cloning => ",
|
|
694
712
|
reference.referenceType.toString({ addressSpace }),
|
|
695
713
|
"=>",
|
|
696
|
-
node
|
|
697
|
-
node.nodeId.toString(),
|
|
714
|
+
fullPath2(node),
|
|
698
715
|
chalk.magentaBright(node.typeDefinitionObj?.browseName.toString())
|
|
699
716
|
);
|
|
700
717
|
|
|
701
718
|
extraInfo.level += 1;
|
|
702
719
|
const clonedNode = node.clone(options, optionalFilter, extraInfo);
|
|
703
|
-
assert(extraInfo.getCloned(node));
|
|
704
|
-
|
|
705
720
|
extraInfo.level -= 1;
|
|
706
721
|
|
|
707
|
-
//
|
|
722
|
+
// istanbul ignore next
|
|
708
723
|
doTrace &&
|
|
709
724
|
traceLog(
|
|
710
725
|
extraInfo.pad(),
|
|
711
726
|
"cloned => ",
|
|
712
|
-
node
|
|
727
|
+
fullPath2(node),
|
|
713
728
|
"",
|
|
714
729
|
extraInfo.pad(),
|
|
715
730
|
" original nodeId",
|
|
@@ -718,19 +733,11 @@ function _clone_collection_new(
|
|
|
718
733
|
extraInfo.pad(),
|
|
719
734
|
" cloned nodeId",
|
|
720
735
|
clonedNode.nodeId.toString(),
|
|
721
|
-
""
|
|
736
|
+
fullPath2(clonedNode) + ""
|
|
722
737
|
);
|
|
723
738
|
|
|
724
739
|
extraInfo.level++;
|
|
725
|
-
_clone_children_on_template(
|
|
726
|
-
nodeToClone,
|
|
727
|
-
newParent,
|
|
728
|
-
node,
|
|
729
|
-
copyAlsoModellingRules,
|
|
730
|
-
optionalFilter,
|
|
731
|
-
extraInfo,
|
|
732
|
-
browseNameMap
|
|
733
|
-
);
|
|
740
|
+
_clone_children_on_template(nodeToClone, newParent, node, copyAlsoModellingRules, optionalFilter, extraInfo);
|
|
734
741
|
extraInfo.level--;
|
|
735
742
|
|
|
736
743
|
// also clone or instantiate interface members that may be required in the optionals
|
|
@@ -777,6 +784,7 @@ function _extractInterfaces2(typeDefinitionNode: UAObjectType | UAVariableType,
|
|
|
777
784
|
|
|
778
785
|
const baseInterfaces: UAInterface[] = [];
|
|
779
786
|
for (const iface of interfaces) {
|
|
787
|
+
// istanbul ignore next
|
|
780
788
|
doTrace &&
|
|
781
789
|
traceLog(
|
|
782
790
|
extraInfo.pad(),
|
|
@@ -793,76 +801,30 @@ function _extractInterfaces2(typeDefinitionNode: UAObjectType | UAVariableType,
|
|
|
793
801
|
}
|
|
794
802
|
interfaces.push(...baseInterfaces);
|
|
795
803
|
if (typeDefinitionNode.subtypeOfObj) {
|
|
804
|
+
// istanbul ignore next
|
|
796
805
|
doTrace &&
|
|
797
806
|
traceLog(
|
|
798
807
|
extraInfo.pad(),
|
|
799
808
|
typeDefinitionNode.browseName.toString(),
|
|
800
|
-
" -
|
|
809
|
+
" - subtypeOf -> ",
|
|
801
810
|
typeDefinitionNode.subtypeOfObj.browseName.toString()
|
|
802
811
|
);
|
|
803
812
|
extraInfo.level++;
|
|
804
813
|
interfaces.push(..._extractInterfaces2(typeDefinitionNode.subtypeOfObj, extraInfo));
|
|
805
814
|
extraInfo.level--;
|
|
806
815
|
}
|
|
807
|
-
const
|
|
816
|
+
const deduplicatedInterfaces = [...new Set(interfaces)];
|
|
808
817
|
|
|
818
|
+
// istanbul ignore next
|
|
809
819
|
doTrace &&
|
|
810
|
-
|
|
820
|
+
deduplicatedInterfaces.length &&
|
|
811
821
|
traceLog(
|
|
812
822
|
extraInfo.pad(),
|
|
813
823
|
chalk.yellow("Interface for ", typeDefinitionNode.browseName.toString()),
|
|
814
824
|
"=",
|
|
815
|
-
|
|
825
|
+
deduplicatedInterfaces.map((x) => x.browseName.toString()).join(" ")
|
|
816
826
|
);
|
|
817
|
-
return
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
/*
|
|
821
|
-
|
|
822
|
-
// also find all related interfaces
|
|
823
|
-
if (false && typeDefinitionNode) {
|
|
824
|
-
dotrace && tracelog("typeDefinitionNode = ", typeDefinitionNode.browseName.toString());
|
|
825
|
-
const interfaces = _extractInterfaces(typeDefinitionNode);
|
|
826
|
-
for (const interfaceNode of interfaces) {
|
|
827
|
-
dotrace && tracelog(" adding member of interface ", interfaceNode.browseName.toString());
|
|
828
|
-
const fromInterface = interfaceNode.findReferencesEx("Aggregates", BrowseDirection.Forward);
|
|
829
|
-
dotrace && tracelog(
|
|
830
|
-
" B ",
|
|
831
|
-
fromInterface.map((r) => r.toString({ addressSpace }) + " " + r.node!.browseName.toString()).join("\n")
|
|
832
|
-
);
|
|
833
|
-
add(fromInterface);
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
*/
|
|
837
|
-
|
|
838
|
-
function _crap_extractInterfaces(typeDefinitionNode: UAObjectType | UAVariableType, extraInfo: CloneExtraInfo): UAInterface[] {
|
|
839
|
-
if (
|
|
840
|
-
typeDefinitionNode.nodeId.namespace === 0 &&
|
|
841
|
-
(typeDefinitionNode.nodeId.value === ObjectTypeIds.BaseObjectType ||
|
|
842
|
-
typeDefinitionNode.nodeId.value === VariableTypeIds.BaseVariableType)
|
|
843
|
-
) {
|
|
844
|
-
return [];
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
const addressSpace = typeDefinitionNode.addressSpace;
|
|
848
|
-
// example:
|
|
849
|
-
// FolderType
|
|
850
|
-
// (di):FunctionalGroupType
|
|
851
|
-
// MachineryItemIdentificationType : IMachineryItemVendorNameplateType
|
|
852
|
-
// MachineIdentificationType : IMachineTagNameplateType, IMachineVendorNamePlateType
|
|
853
|
-
// MachineToolIdentificationType
|
|
854
|
-
//
|
|
855
|
-
//
|
|
856
|
-
// IMachineTagNameplateType -subtypeOf-> ITagNameplateType
|
|
857
|
-
// IMachineVendorNamePlateType -subtypeOf-> IMachineryItemVendorNamePlateType
|
|
858
|
-
// IMachineryItemVendorNamePlateType -subtypeOf-> IVendorNameplateType
|
|
859
|
-
const interfacesRef = typeDefinitionNode.findReferencesEx("HasInterface", BrowseDirection.Forward);
|
|
860
|
-
const interfaces = interfacesRef.map((r) => r.node! as UAInterface);
|
|
861
|
-
for (const iface of interfaces) {
|
|
862
|
-
doTrace && traceLog(extraInfo.pad(), " interface ", iface.browseName.toString());
|
|
863
|
-
}
|
|
864
|
-
|
|
865
|
-
return interfaces;
|
|
827
|
+
return deduplicatedInterfaces;
|
|
866
828
|
}
|
|
867
829
|
|
|
868
830
|
function _cloneInterface(
|
|
@@ -873,6 +835,7 @@ function _cloneInterface(
|
|
|
873
835
|
extraInfo: CloneExtraInfo,
|
|
874
836
|
browseNameMap: Set<string>
|
|
875
837
|
): void {
|
|
838
|
+
// istanbul ignore next
|
|
876
839
|
doTrace &&
|
|
877
840
|
traceLog(
|
|
878
841
|
extraInfo?.pad(),
|
|
@@ -891,17 +854,22 @@ function _cloneInterface(
|
|
|
891
854
|
}
|
|
892
855
|
const interfaces = _extractInterfaces2(typeDefinitionNode, extraInfo);
|
|
893
856
|
if (interfaces.length === 0) {
|
|
857
|
+
// istanbul ignore next
|
|
894
858
|
doTrace &&
|
|
895
859
|
false &&
|
|
896
860
|
traceLog(extraInfo.pad(), chalk.yellow("No interface for ", node.browseName.toString(), node.nodeId.toString()));
|
|
897
861
|
return;
|
|
898
862
|
}
|
|
863
|
+
|
|
864
|
+
// istanbul ignore next
|
|
899
865
|
doTrace && traceLog(extraInfo?.pad(), chalk.green("-------------------- interfaces are ", interfaces.length));
|
|
900
866
|
|
|
901
867
|
const localFilter = optionalFilter.filterFor(node);
|
|
902
868
|
|
|
903
869
|
for (const iface of interfaces) {
|
|
904
870
|
const aggregates = iface.findReferencesEx("Aggregates", BrowseDirection.Forward);
|
|
871
|
+
if (aggregates.length === 0) continue;
|
|
872
|
+
// istanbul ignore next
|
|
905
873
|
doTrace &&
|
|
906
874
|
traceLog(
|
|
907
875
|
extraInfo.pad(),
|
|
@@ -914,7 +882,7 @@ function _cloneInterface(
|
|
|
914
882
|
}
|
|
915
883
|
|
|
916
884
|
function __clone_organizes_references(
|
|
917
|
-
|
|
885
|
+
nodeToClone: UAObject | UAVariable | UAMethod | UAObjectType | UAVariableType,
|
|
918
886
|
newParent: UAObject | UAVariable | UAMethod,
|
|
919
887
|
copyAlsoModellingRules: boolean,
|
|
920
888
|
optionalFilter: CloneFilter,
|
|
@@ -922,12 +890,13 @@ function __clone_organizes_references(
|
|
|
922
890
|
browseNameMap: Set<string>
|
|
923
891
|
): void {
|
|
924
892
|
// find all references that derives from the Organizes
|
|
925
|
-
const organizedRef =
|
|
926
|
-
|
|
893
|
+
const organizedRef = nodeToClone.findReferencesEx("Organizes", BrowseDirection.Forward);
|
|
894
|
+
if (organizedRef.length === 0) return;
|
|
895
|
+
_clone_collection_new(nodeToClone, newParent, organizedRef, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap);
|
|
927
896
|
}
|
|
928
897
|
|
|
929
898
|
function __clone_children_references(
|
|
930
|
-
|
|
899
|
+
nodeToClone: UAObject | UAVariable | UAMethod | UAObjectType | UAVariableType,
|
|
931
900
|
newParent: UAObject | UAVariable | UAMethod,
|
|
932
901
|
copyAlsoModellingRules: boolean,
|
|
933
902
|
optionalFilter: CloneFilter,
|
|
@@ -935,20 +904,21 @@ function __clone_children_references(
|
|
|
935
904
|
browseNameMap: Set<string>
|
|
936
905
|
): void {
|
|
937
906
|
// find all references that derives from the Aggregates
|
|
938
|
-
const aggregatesRef =
|
|
939
|
-
|
|
907
|
+
const aggregatesRef = nodeToClone.findReferencesEx("Aggregates", BrowseDirection.Forward);
|
|
908
|
+
if (aggregatesRef.length === 0) return;
|
|
909
|
+
_clone_collection_new(nodeToClone, newParent, aggregatesRef, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap);
|
|
940
910
|
}
|
|
941
911
|
|
|
942
912
|
export function _clone_hierarchical_references(
|
|
943
|
-
|
|
913
|
+
nodeToClone: UAObject | UAVariable | UAMethod | UAObjectType | UAVariableType,
|
|
944
914
|
newParent: UAObject | UAVariable | UAMethod,
|
|
945
915
|
copyAlsoModellingRules: boolean,
|
|
946
916
|
optionalFilter: CloneFilter,
|
|
947
917
|
extraInfo: CloneExtraInfo,
|
|
948
918
|
browseNameMap: Set<string>
|
|
949
919
|
) {
|
|
950
|
-
__clone_children_references(
|
|
951
|
-
__clone_organizes_references(
|
|
920
|
+
__clone_children_references(nodeToClone, newParent, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap);
|
|
921
|
+
__clone_organizes_references(nodeToClone, newParent, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap);
|
|
952
922
|
}
|
|
953
923
|
export function _clone_non_hierarchical_references(
|
|
954
924
|
nodeToClone: UAObject | UAVariable | UAMethod | UAObjectType | UAVariableType,
|
|
@@ -965,6 +935,7 @@ export function _clone_non_hierarchical_references(
|
|
|
965
935
|
assert(newParent instanceof BaseNodeImpl);
|
|
966
936
|
// find all reference that derives from the HasSubStateMachine
|
|
967
937
|
const references = nodeToClone.findReferencesEx("HasSubStateMachine", BrowseDirection.Forward);
|
|
938
|
+
if (references.length === 0) return;
|
|
968
939
|
_clone_collection_new(nodeToClone, newParent, references, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap);
|
|
969
940
|
}
|
|
970
941
|
|
|
@@ -985,7 +956,6 @@ export function _clone<T extends UAObject | UAVariable | UAMethod>(
|
|
|
985
956
|
!extraInfo || (extraInfo !== null && typeof extraInfo === "object" && typeof extraInfo.registerClonedObject === "function")
|
|
986
957
|
);
|
|
987
958
|
assert(!(originalNode as any).subtypeOf, "We do not do cloning of Type yet");
|
|
988
|
-
assert(!extraInfo.getCloned(originalNode), "object has already been cloned");
|
|
989
959
|
const namespace = options.namespace;
|
|
990
960
|
const constructorOptions: any = {
|
|
991
961
|
...options,
|
|
@@ -1032,7 +1002,11 @@ export function _clone<T extends UAObject | UAVariable | UAMethod>(
|
|
|
1032
1002
|
|
|
1033
1003
|
const clonedNode = new Constructor(constructorOptions);
|
|
1034
1004
|
(originalNode.addressSpace as AddressSpacePrivate)._register(clonedNode);
|
|
1035
|
-
|
|
1005
|
+
|
|
1006
|
+
extraInfo.registerClonedObject({
|
|
1007
|
+
originalNode,
|
|
1008
|
+
clonedNode
|
|
1009
|
+
});
|
|
1036
1010
|
|
|
1037
1011
|
if (!options.ignoreChildren) {
|
|
1038
1012
|
// clone children and the rest ....
|
|
@@ -1052,7 +1026,14 @@ export function _clone<T extends UAObject | UAVariable | UAMethod>(
|
|
|
1052
1026
|
|
|
1053
1027
|
if (originalNode.nodeClass === NodeClass.Object || originalNode.nodeClass === NodeClass.Variable) {
|
|
1054
1028
|
let typeDefinitionNode: UAVariableType | UAObjectType | null = originalNode.typeDefinitionObj;
|
|
1029
|
+
|
|
1030
|
+
extraInfo.pushContext({
|
|
1031
|
+
clonedParent : clonedNode,
|
|
1032
|
+
originalParent: originalNode
|
|
1033
|
+
});
|
|
1034
|
+
|
|
1055
1035
|
while (typeDefinitionNode) {
|
|
1036
|
+
// istanbul ignore next
|
|
1056
1037
|
doTrace &&
|
|
1057
1038
|
traceLog(
|
|
1058
1039
|
extraInfo?.pad(),
|
|
@@ -1072,6 +1053,9 @@ export function _clone<T extends UAObject | UAVariable | UAMethod>(
|
|
|
1072
1053
|
);
|
|
1073
1054
|
typeDefinitionNode = typeDefinitionNode.subtypeOfObj;
|
|
1074
1055
|
}
|
|
1056
|
+
|
|
1057
|
+
extraInfo.popContext();
|
|
1058
|
+
|
|
1075
1059
|
}
|
|
1076
1060
|
_clone_non_hierarchical_references(
|
|
1077
1061
|
originalNode,
|
|
@@ -1117,7 +1101,6 @@ function _remove_HierarchicalReference(node: BaseNode, reference: UAReference) {
|
|
|
1117
1101
|
if (referenceType.isSubtypeOf(HierarchicalReferencesType!)) {
|
|
1118
1102
|
assert(reference.isForward);
|
|
1119
1103
|
const targetNode = ReferenceImpl.resolveReferenceNode(addressSpace, reference);
|
|
1120
|
-
// Xx dotrace && tracelog(" adding object to map");
|
|
1121
1104
|
delete _cache._childByNameMap[targetNode.browseName!.name!.toString()];
|
|
1122
1105
|
}
|
|
1123
1106
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { assert } from "node-opcua-assert";
|
|
5
5
|
|
|
6
6
|
import { BrowseDirection, NodeClass } from "node-opcua-data-model";
|
|
7
|
-
import { checkDebugFlag, make_debugLog, make_errorLog } from "node-opcua-debug";
|
|
7
|
+
import { checkDebugFlag, make_debugLog, make_errorLog, make_warningLog } from "node-opcua-debug";
|
|
8
8
|
import { NodeId } from "node-opcua-nodeid";
|
|
9
9
|
import { Variant } from "node-opcua-variant";
|
|
10
10
|
import { DataType } from "node-opcua-variant";
|
|
@@ -13,11 +13,12 @@ import { VariantArrayType } from "node-opcua-variant";
|
|
|
13
13
|
import { ExtensionObject } from "node-opcua-extension-object";
|
|
14
14
|
import { UADataType, UADynamicVariableArray, UAObject, UAReferenceType, UAVariable } from "node-opcua-address-space-base";
|
|
15
15
|
import { UAVariableImpl } from "./ua_variable_impl";
|
|
16
|
-
import { getProxyTarget } from "./ua_variable_impl_ext_obj";
|
|
17
16
|
|
|
18
17
|
const doDebug = checkDebugFlag(__filename);
|
|
19
18
|
const debugLog = make_debugLog(__filename);
|
|
20
19
|
const errorLog = make_errorLog(__filename);
|
|
20
|
+
const warningLog= make_warningLog(__filename);
|
|
21
|
+
|
|
21
22
|
/*
|
|
22
23
|
* define a complex Variable containing a array of extension objects
|
|
23
24
|
* each element of the array is also accessible as a component variable.
|
|
@@ -129,7 +130,7 @@ function _getElementBrowseName<T extends ExtensionObject>
|
|
|
129
130
|
const indexPropertyName1 = this.$$indexPropertyName;
|
|
130
131
|
|
|
131
132
|
if (!Object.prototype.hasOwnProperty.call(extObj, indexPropertyName1)) {
|
|
132
|
-
|
|
133
|
+
warningLog(" extension object does not have ", indexPropertyName1, extObj);
|
|
133
134
|
}
|
|
134
135
|
// assert(extObj.constructor === addressSpace.constructExtensionObject(dataType));
|
|
135
136
|
assert(Object.prototype.hasOwnProperty.call(extObj, indexPropertyName1));
|
package/src/namespace_impl.ts
CHANGED
|
@@ -1554,7 +1554,11 @@ export class NamespaceImpl implements NamespacePrivate {
|
|
|
1554
1554
|
}
|
|
1555
1555
|
|
|
1556
1556
|
// --- Alarms & Conditions -------------------------------------------------
|
|
1557
|
-
public instantiateCondition(
|
|
1557
|
+
public instantiateCondition(
|
|
1558
|
+
conditionTypeId: UAEventType | NodeId | string,
|
|
1559
|
+
options: any,
|
|
1560
|
+
data: Record<string, VariantOptions>
|
|
1561
|
+
): UAConditionEx {
|
|
1558
1562
|
return UAConditionImpl.instantiate(this, conditionTypeId, options, data);
|
|
1559
1563
|
}
|
|
1560
1564
|
|
|
@@ -1662,7 +1666,7 @@ export class NamespaceImpl implements NamespacePrivate {
|
|
|
1662
1666
|
|
|
1663
1667
|
// istanbul ignore next
|
|
1664
1668
|
if (this._nodeid_index.has(hashKey)) {
|
|
1665
|
-
const
|
|
1669
|
+
const existingNode = this.findNode(node.nodeId)!;
|
|
1666
1670
|
throw new Error(
|
|
1667
1671
|
"node " +
|
|
1668
1672
|
node.browseName.toString() +
|
|
@@ -1677,7 +1681,7 @@ export class NamespaceImpl implements NamespacePrivate {
|
|
|
1677
1681
|
this.index +
|
|
1678
1682
|
"\n" +
|
|
1679
1683
|
"existing node = " +
|
|
1680
|
-
|
|
1684
|
+
existingNode.toString() +
|
|
1681
1685
|
"this parent : " +
|
|
1682
1686
|
node.parentNodeId?.toString()
|
|
1683
1687
|
);
|
|
@@ -1737,12 +1741,12 @@ export class NamespaceImpl implements NamespacePrivate {
|
|
|
1737
1741
|
console.log(" ", options.browseName, " will be replaced with ", correctedName);
|
|
1738
1742
|
console.log(" Please update your code");
|
|
1739
1743
|
|
|
1740
|
-
const
|
|
1741
|
-
if (
|
|
1744
|
+
const indexVerify = parseInt(match[0], 10);
|
|
1745
|
+
if (indexVerify !== this.index) {
|
|
1742
1746
|
errorLog(
|
|
1743
1747
|
chalk.red.bold(
|
|
1744
1748
|
"Error: namespace index used at the front of the browseName " +
|
|
1745
|
-
|
|
1749
|
+
indexVerify +
|
|
1746
1750
|
" do not match the index of the current namespace (" +
|
|
1747
1751
|
this.index +
|
|
1748
1752
|
")"
|
|
@@ -2009,7 +2013,7 @@ export class NamespaceImpl implements NamespacePrivate {
|
|
|
2009
2013
|
if (options.minimumSamplingInterval === 0 && hasGetter(options)) {
|
|
2010
2014
|
warningLog(
|
|
2011
2015
|
"[NODE-OPCUA-W31",
|
|
2012
|
-
"namespace#addVariable a getter has been specified and minimumSamplingInterval is 0.\nThis may conduct to an
|
|
2016
|
+
"namespace#addVariable a getter has been specified and minimumSamplingInterval is 0.\nThis may conduct to an unpredictable behavior.\nPlease specify a non zero minimum sampling interval"
|
|
2013
2017
|
);
|
|
2014
2018
|
}
|
|
2015
2019
|
|