node-opcua-address-space 2.95.0 → 2.96.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.
Files changed (44) hide show
  1. package/dist/source/address_space_ts.d.ts +3 -3
  2. package/dist/source/address_space_ts.js +3 -3
  3. package/dist/source/address_space_ts.js.map +1 -1
  4. package/dist/source/helpers/call_helpers.d.ts +1 -1
  5. package/dist/source/helpers/multiform_func.d.ts +8 -8
  6. package/dist/source/interfaces/alarms_and_conditions/ua_condition_ex.d.ts +1 -1
  7. package/dist/source/interfaces/extension_object_constructor.d.ts +1 -1
  8. package/dist/source/interfaces/state_machine/ua_state_machine_type.d.ts +2 -2
  9. package/dist/source/loader/generateAddressSpaceRaw.d.ts +2 -2
  10. package/dist/source/loader/make_xml_extension_object_parser.d.ts +1 -1
  11. package/dist/source/loader/namespace_post_step.d.ts +1 -1
  12. package/dist/source/session_context.d.ts +1 -1
  13. package/dist/src/address_space.js +11 -11
  14. package/dist/src/address_space.js.map +1 -1
  15. package/dist/src/apply_condition_refresh.d.ts +1 -1
  16. package/dist/src/base_node_impl.js +44 -44
  17. package/dist/src/base_node_impl.js.map +1 -1
  18. package/dist/src/base_node_private.d.ts +1 -1
  19. package/dist/src/base_node_private.js +97 -12
  20. package/dist/src/base_node_private.js.map +1 -1
  21. package/dist/src/event_data.d.ts +2 -2
  22. package/dist/src/nodeid_manager.d.ts +3 -3
  23. package/dist/src/nodeset_tools/nodeset_to_xml.d.ts +1 -1
  24. package/dist/src/reference_impl.js +6 -6
  25. package/dist/src/reference_impl.js.map +1 -1
  26. package/dist/src/tool_isSubtypeOf.d.ts +4 -4
  27. package/dist/src/ua_data_type_impl.js +14 -14
  28. package/dist/src/ua_data_type_impl.js.map +1 -1
  29. package/dist/src/ua_method_impl.js +6 -6
  30. package/dist/src/ua_method_impl.js.map +1 -1
  31. package/dist/src/ua_object_impl.js +7 -7
  32. package/dist/src/ua_object_impl.js.map +1 -1
  33. package/dist/src/ua_object_type_impl.js +8 -8
  34. package/dist/src/ua_object_type_impl.js.map +1 -1
  35. package/dist/src/ua_reference_type_impl.js +6 -6
  36. package/dist/src/ua_reference_type_impl.js.map +1 -1
  37. package/dist/src/ua_variable_impl.js +11 -11
  38. package/dist/src/ua_variable_impl.js.map +1 -1
  39. package/dist/src/ua_variable_type_impl.js +6 -6
  40. package/dist/src/ua_variable_type_impl.js.map +1 -1
  41. package/dist/src/ua_view_impl.js +3 -3
  42. package/dist/src/ua_view_impl.js.map +1 -1
  43. package/package.json +17 -17
  44. package/src/base_node_private.ts +197 -56
@@ -190,8 +190,8 @@ export function BaseNode_toString(this: BaseNode, options: ToStringOption): void
190
190
  options.add(options.padding + chalk.yellow(" browseName : ") + this.browseName.toString());
191
191
  options.add(
192
192
  options.padding +
193
- chalk.yellow(" displayName : ") +
194
- this.displayName.map((f) => f.locale + " " + f.text).join(" | ")
193
+ chalk.yellow(" displayName : ") +
194
+ this.displayName.map((f) => f.locale + " " + f.text).join(" | ")
195
195
  );
196
196
 
197
197
  options.add(
@@ -210,9 +210,9 @@ export function BaseNode_References_toString(this: BaseNode, options: ToStringOp
210
210
 
211
211
  options.add(
212
212
  options.padding +
213
- chalk.yellow(" references : ") +
214
- " length =" +
215
- Object.keys(_private._referenceIdx).length
213
+ chalk.yellow(" references : ") +
214
+ " length =" +
215
+ Object.keys(_private._referenceIdx).length
216
216
  );
217
217
 
218
218
  function dump_reference(follow: boolean, reference: UAReference | null) {
@@ -251,12 +251,12 @@ export function BaseNode_References_toString(this: BaseNode, options: ToStringOp
251
251
  })();
252
252
  options.add(
253
253
  options.padding +
254
- chalk.yellow(" +-> ") +
255
- reference.toString(displayOptions) +
256
- " " +
257
- chalk.cyan(name.padEnd(25, " ")) +
258
- " " +
259
- chalk.magentaBright(extra)
254
+ chalk.yellow(" +-> ") +
255
+ reference.toString(displayOptions) +
256
+ " " +
257
+ chalk.cyan(name.padEnd(25, " ")) +
258
+ " " +
259
+ chalk.magentaBright(extra)
260
260
  );
261
261
 
262
262
  // ignore HasTypeDefinition as it has been already handled
@@ -285,10 +285,10 @@ export function BaseNode_References_toString(this: BaseNode, options: ToStringOp
285
285
 
286
286
  options.add(
287
287
  options.padding +
288
- chalk.yellow(" back_references : ") +
289
- chalk.cyan(" length =") +
290
- br.length +
291
- chalk.grey(" ( references held by other nodes involving this node)")
288
+ chalk.yellow(" back_references : ") +
289
+ chalk.cyan(" length =") +
290
+ br.length +
291
+ chalk.grey(" ( references held by other nodes involving this node)")
292
292
  );
293
293
  // backward reference
294
294
  br.forEach(dump_reference.bind(null, false));
@@ -298,11 +298,11 @@ function _UAType_toString(this: UAReferenceType | UADataType | UAObjectType | UA
298
298
  if (this.subtypeOfObj) {
299
299
  options.add(
300
300
  options.padding +
301
- chalk.yellow(" subtypeOf : ") +
302
- this.subtypeOfObj.browseName.toString() +
303
- " (" +
304
- this.subtypeOfObj.nodeId.toString() +
305
- ")"
301
+ chalk.yellow(" subtypeOf : ") +
302
+ this.subtypeOfObj.browseName.toString() +
303
+ " (" +
304
+ this.subtypeOfObj.nodeId.toString() +
305
+ ")"
306
306
  );
307
307
  }
308
308
  }
@@ -311,11 +311,11 @@ function _UAInstance_toString(this: UAVariable | UAMethod | UAObject, options: T
311
311
  if (this.typeDefinitionObj) {
312
312
  options.add(
313
313
  options.padding +
314
- chalk.yellow(" typeDefinition : ") +
315
- this.typeDefinitionObj.browseName.toString() +
316
- " (" +
317
- this.typeDefinitionObj.nodeId.toString() +
318
- ")"
314
+ chalk.yellow(" typeDefinition : ") +
315
+ this.typeDefinitionObj.browseName.toString() +
316
+ " (" +
317
+ this.typeDefinitionObj.nodeId.toString() +
318
+ ")"
319
319
  );
320
320
  }
321
321
  }
@@ -422,9 +422,9 @@ export function VariableOrVariableType_toString(this: UAVariableType | UAVariabl
422
422
  if (_dataValue) {
423
423
  options.add(
424
424
  options.padding +
425
- chalk.yellow(" value : ") +
426
- "\n" +
427
- options.indent(_dataValue.toString(), options.padding + " | ")
425
+ chalk.yellow(" value : ") +
426
+ "\n" +
427
+ options.indent(_dataValue.toString(), options.padding + " | ")
428
428
  );
429
429
  }
430
430
  }
@@ -441,19 +441,19 @@ export function VariableOrVariableType_toString(this: UAVariableType | UAVariabl
441
441
  if (this.minimumSamplingInterval !== undefined) {
442
442
  options.add(
443
443
  options.padding +
444
- chalk.yellow(" minimumSamplingInterval : ") +
445
- " " +
446
- this.minimumSamplingInterval.toString() +
447
- " ms"
444
+ chalk.yellow(" minimumSamplingInterval : ") +
445
+ " " +
446
+ this.minimumSamplingInterval.toString() +
447
+ " ms"
448
448
  );
449
449
  }
450
450
  if (this.arrayDimensions) {
451
451
  options.add(
452
452
  options.padding +
453
- chalk.yellow(" arrayDimension : ") +
454
- " [" +
455
- this.arrayDimensions.join(",").toString() +
456
- " ]"
453
+ chalk.yellow(" arrayDimension : ") +
454
+ " [" +
455
+ this.arrayDimensions.join(",").toString() +
456
+ " ]"
457
457
  );
458
458
  }
459
459
  }
@@ -468,11 +468,131 @@ const defaultExtraInfo = {
468
468
  }
469
469
  };
470
470
 
471
+ /**
472
+ *
473
+ *
474
+ * MyDeriveType ------------------- -> MyBaseType --------------> TopologyElementType
475
+ * | | |
476
+ * +- ParamaterSet +-> ParameterSet +-> ParamaterSet
477
+ * | |
478
+ * +- Foo1 |
479
+ * +- Bar
480
+ *
481
+ * Instance
482
+ *
483
+ * @param newParent
484
+ * @param node
485
+ * @param copyAlsoModellingRules
486
+ * @param optionalFilter
487
+ * @param extraInfo
488
+ * @param browseNameMap
489
+ * @returns
490
+ */
491
+ function _clone_children_on_template(
492
+ nodeToClone: UAObject | UAVariable | UAMethod | UAObjectType | UAVariableType,
493
+ newParent: BaseNode,
494
+ node: BaseNode,
495
+ copyAlsoModellingRules: boolean,
496
+ optionalFilter: CloneFilter,
497
+ extraInfo: CloneExtraInfo,
498
+ browseNameMap: Set<string>
499
+ ) {
500
+ /**
501
+ * the type definition node of the node to clone
502
+ */
503
+ const nodeToCloneTypeDefinition =
504
+ nodeToClone.nodeClass === NodeClass.ObjectType || nodeToClone.nodeClass === NodeClass.VariableType
505
+ ? nodeToClone.subtypeOfObj
506
+ : null;
507
+ if (!nodeToCloneTypeDefinition) return;
508
+
509
+ doTrace &&
510
+ traceLog(
511
+ extraInfo?.pad(),
512
+ chalk.green(
513
+ "-------------------- now cloning children on template ",
514
+ node.browseName.toString(),
515
+ node.nodeId.toString(),
516
+ nodeToCloneTypeDefinition.browseName.toString()
517
+ )
518
+ );
519
+
520
+ const namespace = newParent.namespace;
521
+
522
+ /**
523
+ * the child node of the new parent that match the node to clone or enrich
524
+ */
525
+ const newParentChild = newParent.getChildByName(node.browseName);
526
+ if (!newParentChild) {
527
+ return;
528
+ }
529
+ // we have found a matching child on the new parent.
530
+ // the mission is to enrich this child node with compoents and property that
531
+ // exists also in the template
532
+
533
+ let typeDefinitionNode: UAVariableType | UAObjectType | null = nodeToCloneTypeDefinition;
534
+ while (typeDefinitionNode) {
535
+ doTrace &&
536
+ traceLog(
537
+ extraInfo?.pad(),
538
+ chalk.green(
539
+ "-------------------- now cloning children on ",
540
+ newParentChild.browseName.toString(),
541
+ newParentChild.nodeId.toString(),
542
+ " (child of ",
543
+ node.browseName.toString(),
544
+ node.nodeId.toString(),
545
+ ") from ",
546
+ typeDefinitionNode.browseName.toString()
547
+ )
548
+ );
549
+
550
+ const typeDefinitionChild = typeDefinitionNode.getChildByName(node.browseName);
551
+ if (typeDefinitionChild) {
552
+ const references = typeDefinitionChild.findReferencesEx("Aggregates", BrowseDirection.Forward);
553
+
554
+ for (const ref of references) {
555
+ const grandChild = ref.node as UAVariable | UAObject | UAMethod;
556
+ if (grandChild.modellingRule === "MandatoryPlaceholder" || grandChild.modellingRule === "OptionalPlaceholder")
557
+ continue;
558
+ // if not already node present in new Parent => just ignore
559
+ const hasAlready = newParentChild.getChildByName(grandChild.browseName) !== null;
560
+ if (!hasAlready) {
561
+ if (optionalFilter && node && !optionalFilter.shouldKeep(node)) {
562
+ doTrace &&
563
+ traceLog(
564
+ extraInfo.pad(),
565
+ "skipping optional ",
566
+ node.browseName.toString(),
567
+ "that doesn't appear in the filter"
568
+ );
569
+ continue; // skip this node
570
+ }
571
+
572
+ const options = {
573
+ namespace,
574
+ references: [
575
+ new ReferenceImpl({
576
+ referenceType: ref.referenceType,
577
+ isForward: false,
578
+ nodeId: newParentChild.nodeId
579
+ })
580
+ ],
581
+ copyAlsoModellingRules
582
+ };
583
+ const a = grandChild.clone(options, optionalFilter, extraInfo);
584
+ }
585
+ }
586
+ }
587
+ typeDefinitionNode = typeDefinitionNode.subtypeOfObj;
588
+ }
589
+ }
471
590
  /**
472
591
  * clone properties and methods
473
592
  * @private
474
593
  */
475
594
  function _clone_collection_new(
595
+ nodeToClone: UAObject | UAVariable | UAMethod | UAObjectType | UAVariableType,
476
596
  newParent: BaseNode,
477
597
  collectionRef: UAReference[],
478
598
  copyAlsoModellingRules: boolean,
@@ -495,11 +615,11 @@ function _clone_collection_new(
495
615
  // tslint:disable-next-line:no-console
496
616
  warningLog(
497
617
  chalk.red("Warning : cannot clone node ") +
498
- node.browseName.toString() +
499
- " of class " +
500
- NodeClass[node.nodeClass].toString() +
501
- " while cloning " +
502
- newParent.browseName.toString()
618
+ node.browseName.toString() +
619
+ " of class " +
620
+ NodeClass[node.nodeClass].toString() +
621
+ " while cloning " +
622
+ newParent.browseName.toString()
503
623
  );
504
624
  continue;
505
625
  }
@@ -511,6 +631,16 @@ function _clone_collection_new(
511
631
  }
512
632
  const key = node.browseName.toString();
513
633
  if (browseNameMap?.has(key)) {
634
+ _clone_children_on_template(
635
+ nodeToClone,
636
+ newParent,
637
+ node,
638
+ copyAlsoModellingRules,
639
+ optionalFilter,
640
+ extraInfo,
641
+ browseNameMap
642
+ );
643
+
514
644
  continue; // skipping node with same browseName
515
645
  }
516
646
  browseNameMap?.add(key);
@@ -534,17 +664,17 @@ function _clone_collection_new(
534
664
  );
535
665
 
536
666
  extraInfo.level += 4;
537
- const clone = (node as UAVariable | UAMethod | UAObject).clone(options, optionalFilter, extraInfo);
667
+ const clone = node.clone(options, optionalFilter, extraInfo);
538
668
  extraInfo.level -= 4;
539
- doTrace &&
540
- traceLog(
541
- extraInfo.pad(),
542
- "cloning => ", node.browseName.toString(), "nodeId", clone.nodeId.toString()
543
- );
669
+ doTrace && traceLog(extraInfo.pad(), "cloning => ", node.browseName.toString(), "nodeId", clone.nodeId.toString());
670
+
671
+ extraInfo.level++;
672
+ _clone_children_on_template(nodeToClone, newParent, node, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap);
673
+ extraInfo.level--;
544
674
 
545
675
  // also clone or instantiate interface members that may be required in the optionals
546
676
  extraInfo.level++;
547
- _cloneInterface(newParent, node, optionalFilter, extraInfo, browseNameMap);
677
+ _cloneInterface(nodeToClone, newParent, node, optionalFilter, extraInfo, browseNameMap);
548
678
  extraInfo.level--;
549
679
 
550
680
  if (extraInfo) {
@@ -616,7 +746,8 @@ function _extractInterfaces2(typeDefinitionNode: UAObjectType | UAVariableType,
616
746
  }
617
747
  const dedupedInterfaces = [...new Set(interfaces)];
618
748
 
619
- doTrace && dedupedInterfaces.length &&
749
+ doTrace &&
750
+ dedupedInterfaces.length &&
620
751
  traceLog(
621
752
  extraInfo.pad(),
622
753
  chalk.yellow("Interface for ", typeDefinitionNode.browseName.toString()),
@@ -675,6 +806,7 @@ function _crap_extractInterfaces(typeDefinitionNode: UAObjectType | UAVariableTy
675
806
  }
676
807
 
677
808
  function _cloneInterface(
809
+ nodeToClone: UAObject | UAVariable | UAMethod | UAObjectType | UAVariableType,
678
810
  newParent: BaseNode,
679
811
  node: UAObject | UAVariable | UAMethod,
680
812
  optionalFilter: CloneFilter,
@@ -699,7 +831,9 @@ function _cloneInterface(
699
831
  }
700
832
  const interfaces = _extractInterfaces2(typeDefinitionNode, extraInfo);
701
833
  if (interfaces.length === 0) {
702
- doTrace && false && traceLog(extraInfo.pad(), chalk.yellow("No interface for ", node.browseName.toString(), node.nodeId.toString()));
834
+ doTrace &&
835
+ false &&
836
+ traceLog(extraInfo.pad(), chalk.yellow("No interface for ", node.browseName.toString(), node.nodeId.toString()));
703
837
  return;
704
838
  }
705
839
  doTrace && traceLog(extraInfo?.pad(), chalk.green("-------------------- interfaces are ", interfaces.length));
@@ -715,7 +849,7 @@ function _cloneInterface(
715
849
  "\n" + extraInfo?.pad(),
716
850
  aggregates.map((r) => r.toString({ addressSpace })).join("\n" + extraInfo?.pad())
717
851
  );
718
- _clone_collection_new(node, aggregates, false, localFilter, extraInfo, browseNameMap);
852
+ _clone_collection_new(nodeToClone, node, aggregates, false, localFilter, extraInfo, browseNameMap);
719
853
  }
720
854
  }
721
855
  export function _clone_children_references(
@@ -728,11 +862,11 @@ export function _clone_children_references(
728
862
  ): void {
729
863
  // find all reference that derives from the Aggregates
730
864
  const aggregatesRef = node.findReferencesEx("Aggregates", BrowseDirection.Forward);
731
- _clone_collection_new(newParent, aggregatesRef, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap);
865
+ _clone_collection_new(node, newParent, aggregatesRef, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap);
732
866
  }
733
867
 
734
868
  export function _clone_non_hierarchical_references(
735
- node: BaseNode,
869
+ nodeToClone: UAObject | UAVariable | UAMethod | UAObjectType | UAVariableType,
736
870
  newParent: BaseNode,
737
871
  copyAlsoModellingRules: boolean,
738
872
  optionalFilter: CloneFilter,
@@ -745,8 +879,8 @@ export function _clone_non_hierarchical_references(
745
879
  // (may be other as well later ... to do )
746
880
  assert(newParent instanceof BaseNodeImpl);
747
881
  // find all reference that derives from the HasSubStateMachine
748
- const references = node.findReferencesEx("HasSubStateMachine", BrowseDirection.Forward);
749
- _clone_collection_new(newParent, references, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap);
882
+ const references = nodeToClone.findReferencesEx("HasSubStateMachine", BrowseDirection.Forward);
883
+ _clone_collection_new(nodeToClone, newParent, references, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap);
750
884
  }
751
885
 
752
886
  /**
@@ -842,7 +976,14 @@ export function _clone<T extends UAObject | UAVariable | UAMethod>(
842
976
  typeDefinitionNode = typeDefinitionNode.subtypeOfObj;
843
977
  }
844
978
  }
845
- _clone_non_hierarchical_references(this, cloneObj, options.copyAlsoModellingRules, newFilter, extraInfo, browseNameMap);
979
+ _clone_non_hierarchical_references(
980
+ this,
981
+ cloneObj,
982
+ options.copyAlsoModellingRules,
983
+ newFilter,
984
+ extraInfo,
985
+ browseNameMap
986
+ );
846
987
  }
847
988
  cloneObj.propagate_back_references();
848
989
  cloneObj.install_extra_properties();