node-opcua-address-space 2.58.0 → 2.62.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 (85) hide show
  1. package/dist/source/address_space_ts.d.ts +0 -2
  2. package/dist/source/helpers/argument_list.js +12 -1
  3. package/dist/source/helpers/argument_list.js.map +1 -1
  4. package/dist/source/helpers/multiform_func.d.ts +11 -0
  5. package/dist/source/helpers/multiform_func.js +74 -0
  6. package/dist/source/helpers/multiform_func.js.map +1 -0
  7. package/dist/source/loader/load_nodeset2.js +47 -64
  8. package/dist/source/loader/load_nodeset2.js.map +1 -1
  9. package/dist/source/set_namespace_meta_data.js +1 -1
  10. package/dist/src/address_space.js +12 -6
  11. package/dist/src/address_space.js.map +1 -1
  12. package/dist/src/alarms_and_conditions/condition_snapshot.js +3 -3
  13. package/dist/src/alarms_and_conditions/condition_snapshot.js.map +1 -1
  14. package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js +1 -1
  15. package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js.map +1 -1
  16. package/dist/src/alarms_and_conditions/ua_condition_impl.js +8 -6
  17. package/dist/src/alarms_and_conditions/ua_condition_impl.js.map +1 -1
  18. package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.js +1 -1
  19. package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.js.map +1 -1
  20. package/dist/src/base_node_impl.js +2 -0
  21. package/dist/src/base_node_impl.js.map +1 -1
  22. package/dist/src/base_node_private.d.ts +3 -3
  23. package/dist/src/base_node_private.js +198 -25
  24. package/dist/src/base_node_private.js.map +1 -1
  25. package/dist/src/event_data.js +1 -1
  26. package/dist/src/event_data.js.map +1 -1
  27. package/dist/src/namespace_impl.js +5 -5
  28. package/dist/src/namespace_impl.js.map +1 -1
  29. package/dist/src/nodeset_tools/nodeset_to_xml.js +15 -9
  30. package/dist/src/nodeset_tools/nodeset_to_xml.js.map +1 -1
  31. package/dist/src/nodeset_tools/typedictionary_to_xml.js +17 -10
  32. package/dist/src/nodeset_tools/typedictionary_to_xml.js.map +1 -1
  33. package/dist/src/reference_impl.js +1 -1
  34. package/dist/src/reference_impl.js.map +1 -1
  35. package/dist/src/state_machine/ua_shelving_state_machine_ex.js +20 -13
  36. package/dist/src/state_machine/ua_shelving_state_machine_ex.js.map +1 -1
  37. package/dist/src/ua_data_type_impl.d.ts +15 -5
  38. package/dist/src/ua_data_type_impl.js +129 -51
  39. package/dist/src/ua_data_type_impl.js.map +1 -1
  40. package/dist/src/ua_method_impl.js +2 -1
  41. package/dist/src/ua_method_impl.js.map +1 -1
  42. package/dist/src/ua_object_impl.js +2 -1
  43. package/dist/src/ua_object_impl.js.map +1 -1
  44. package/dist/src/ua_object_type_impl.js +1 -0
  45. package/dist/src/ua_object_type_impl.js.map +1 -1
  46. package/dist/src/ua_variable_impl.d.ts +12 -18
  47. package/dist/src/ua_variable_impl.js +285 -215
  48. package/dist/src/ua_variable_impl.js.map +1 -1
  49. package/dist/src/ua_variable_type_impl.d.ts +3 -4
  50. package/dist/src/ua_variable_type_impl.js +61 -52
  51. package/dist/src/ua_variable_type_impl.js.map +1 -1
  52. package/dist/src/ua_view_impl.js +1 -1
  53. package/dist/src/ua_view_impl.js.map +1 -1
  54. package/distHelpers/mock_session.js +1 -1
  55. package/distHelpers/mock_session.js.map +1 -1
  56. package/package.json +35 -35
  57. package/source/address_space_ts.ts +0 -1
  58. package/source/helpers/argument_list.ts +13 -3
  59. package/source/helpers/multiform_func.ts +76 -0
  60. package/source/loader/load_nodeset2.ts +64 -80
  61. package/source/set_namespace_meta_data.ts +1 -1
  62. package/src/address_space.ts +16 -7
  63. package/src/alarms_and_conditions/condition_snapshot.ts +4 -4
  64. package/src/alarms_and_conditions/ua_alarm_condition_impl.ts +2 -2
  65. package/src/alarms_and_conditions/ua_condition_impl.ts +18 -8
  66. package/src/alarms_and_conditions/ua_off_normal_alarm_impl.ts +1 -1
  67. package/src/base_node_impl.ts +3 -1
  68. package/src/base_node_private.ts +282 -36
  69. package/src/event_data.ts +1 -1
  70. package/src/namespace_impl.ts +6 -6
  71. package/src/nodeset_tools/nodeset_to_xml.ts +20 -10
  72. package/src/nodeset_tools/typedictionary_to_xml.ts +17 -7
  73. package/src/reference_impl.ts +3 -3
  74. package/src/state_machine/ua_shelving_state_machine_ex.ts +28 -16
  75. package/src/ua_data_type_impl.ts +168 -61
  76. package/src/ua_method_impl.ts +10 -2
  77. package/src/ua_object_impl.ts +10 -2
  78. package/src/ua_object_type_impl.ts +1 -0
  79. package/src/ua_variable_impl.ts +419 -325
  80. package/src/ua_variable_type_impl.ts +87 -52
  81. package/src/ua_view_impl.ts +1 -1
  82. package/test_helpers/mock_session.ts +1 -1
  83. package/test_helpers/test_fixtures/fixture_simple_statemachine_nodeset2.xml +18 -0
  84. package/test_helpers/test_fixtures/fixuture_nodeset_objects_with_some_methods.xml +9 -1
  85. package/test_helpers/test_fixtures/mini.Node.Set2.xml +22 -1
@@ -6,20 +6,6 @@
6
6
  import * as chalk from "chalk";
7
7
 
8
8
  import { assert } from "node-opcua-assert";
9
- import { UInt32 } from "node-opcua-basic-types";
10
- import { ReferenceTypeIds } from "node-opcua-constants";
11
- import { coerceQualifiedName, NodeClass, QualifiedName } from "node-opcua-data-model";
12
- import { BrowseDirection } from "node-opcua-data-model";
13
- import { AttributeIds } from "node-opcua-data-model";
14
- import { DataValue, DataValueLike } from "node-opcua-data-value";
15
- import { checkDebugFlag, make_debugLog, make_warningLog } from "node-opcua-debug";
16
- import { coerceNodeId, makeNodeId, NodeId, NodeIdLike, sameNodeId } from "node-opcua-nodeid";
17
- import { StatusCodes } from "node-opcua-status-code";
18
- import { isNullOrUndefined } from "node-opcua-utils";
19
- import { DataType } from "node-opcua-variant";
20
- import { Variant } from "node-opcua-variant";
21
- import { VariantArrayType } from "node-opcua-variant";
22
-
23
9
  import {
24
10
  IAddressSpace,
25
11
  AddVariableOptions,
@@ -35,6 +21,15 @@ import {
35
21
  UAVariableType,
36
22
  CloneFilter
37
23
  } from "node-opcua-address-space-base";
24
+ import { ObjectTypeIds, ReferenceTypeIds, VariableTypeIds } from "node-opcua-constants";
25
+ import { coerceQualifiedName, NodeClass, QualifiedName, BrowseDirection, AttributeIds } from "node-opcua-data-model";
26
+ import { DataValue, DataValueLike } from "node-opcua-data-value";
27
+ import { checkDebugFlag, make_debugLog, make_warningLog, make_errorLog } from "node-opcua-debug";
28
+ import { coerceNodeId, makeNodeId, NodeId, NodeIdLike, sameNodeId } from "node-opcua-nodeid";
29
+ import { StatusCodes } from "node-opcua-status-code";
30
+ import { UInt32 } from "node-opcua-basic-types";
31
+ import { isNullOrUndefined } from "node-opcua-utils";
32
+ import { DataType, Variant, VariantArrayType, verifyRankAndDimensions } from "node-opcua-variant";
38
33
 
39
34
  import { SessionContext } from "../source/session_context";
40
35
  import { makeOptionalsMap, OptionalMap } from "../source/helpers/make_optionals_map";
@@ -45,11 +40,16 @@ import { _clone_children_references, ToStringBuilder, UAVariableType_toString }
45
40
  import * as tools from "./tool_isSupertypeOf";
46
41
  import { get_subtypeOfObj } from "./tool_isSupertypeOf";
47
42
  import { get_subtypeOf } from "./tool_isSupertypeOf";
48
- import { verifyRankAndDimensions } from "./ua_variable_impl";
43
+ import { resolveReferenceNode } from "./reference_impl";
49
44
 
50
45
  const debugLog = make_debugLog(__filename);
51
46
  const doDebug = checkDebugFlag(__filename);
52
47
  const warningLog = make_warningLog(__filename);
48
+ const errorLog = make_errorLog(__filename);
49
+
50
+ // eslint-disable-next-line prefer-const
51
+ let doTrace = false;
52
+ const traceLog = errorLog;
53
53
 
54
54
  interface InstantiateS {
55
55
  propertyOf?: any;
@@ -131,7 +131,6 @@ export class UAVariableTypeImpl extends BaseNodeImpl implements UAVariableType {
131
131
 
132
132
  if (options.value) {
133
133
  this.value = new Variant(options.value);
134
- // xx console.log("setting ",this.value.toString());
135
134
  }
136
135
  }
137
136
 
@@ -246,6 +245,7 @@ export class UAVariableTypeImpl extends BaseNodeImpl implements UAVariableType {
246
245
  componentOf: options.componentOf,
247
246
  dataType,
248
247
  description: options.description || this.description,
248
+ displayName: options.displayName || this.displayName,
249
249
  eventSourceOf: options.eventSourceOf,
250
250
  minimumSamplingInterval: options.minimumSamplingInterval,
251
251
  modellingRule: options.modellingRule,
@@ -309,7 +309,7 @@ class MandatoryChildOrRequestedOptionalFilter implements CloneFilter {
309
309
  const n = addressSpace.findNode(r.nodeId)!;
310
310
  // istanbul ignore next
311
311
  if (!n) {
312
- console.log(" cannot find node ", r.nodeId.toString());
312
+ warningLog(" cannot find node ", r.nodeId.toString());
313
313
  return false;
314
314
  }
315
315
  return n.browseName!.name!.toString() === node.browseName!.name!.toString();
@@ -327,7 +327,24 @@ class MandatoryChildOrRequestedOptionalFilter implements CloneFilter {
327
327
  switch (modellingRule) {
328
328
  case null:
329
329
  case undefined:
330
- return false; // skip
330
+ debugLog(
331
+ "node ",
332
+ node.browseName.toString(),
333
+ node.nodeId.toString(),
334
+ " has no modellingRule ",
335
+ node.parentNodeId?.toString()
336
+ );
337
+ /**
338
+ * in some badly generated NodeSet2.xml file, the modellingRule is not specified
339
+ *
340
+ * but in some other NodeSet2.xml, this means that the data are only attached to the Type node and shall not be
341
+ * instantiate in the corresponding instance (example is the state variable of a finite state machine that are only
342
+ * defined in the Type node)
343
+ *
344
+ * we should not consider it as an error, and treat it as not present
345
+ */
346
+ return false;
347
+
331
348
  case "Mandatory":
332
349
  return true; // keep;
333
350
  case "Optional":
@@ -370,11 +387,11 @@ function _get_parent_as_VariableOrObjectType(originalObject: BaseNode): UAVariab
370
387
 
371
388
  // istanbul ignore next
372
389
  if (parents.length > 1) {
373
- console.warn(" object ", originalObject.browseName.toString(), " has more than one parent !");
374
- console.warn(originalObject.toString());
375
- console.warn(" parents : ");
390
+ warningLog(" object ", originalObject.browseName.toString(), " has more than one parent !");
391
+ warningLog(originalObject.toString());
392
+ warningLog(" parents : ");
376
393
  for (const parent of parents) {
377
- console.log(" ", parent.toString(), addressSpace.findNode(parent.nodeId)!.browseName.toString());
394
+ warningLog(" ", parent.toString(), addressSpace.findNode(parent.nodeId)!.browseName.toString());
378
395
  }
379
396
  return null;
380
397
  }
@@ -395,8 +412,12 @@ interface CloneInfo {
395
412
  original: UAVariableType | UAObjectType;
396
413
  }
397
414
  class CloneHelper {
415
+ public level = 0;
398
416
  private readonly mapOrgToClone: Map<string, CloneInfo> = new Map();
399
417
 
418
+ public pad(): string {
419
+ return " ".padEnd(this.level * 2, " ");
420
+ }
400
421
  public registerClonedObject<TT extends UAVariableType | UAObjectType, T extends UAObject | UAVariable | UAMethod>(
401
422
  objInType: TT,
402
423
  clonedObj: T
@@ -439,7 +460,6 @@ class CloneHelper {
439
460
  // find subTypeOf
440
461
  }
441
462
  }
442
-
443
463
  // install properties and components on a instantiated Object
444
464
  //
445
465
  // based on their ModelingRule
@@ -452,39 +472,66 @@ class CloneHelper {
452
472
  function _initialize_properties_and_components<B extends UAObject | UAVariable | UAMethod, T extends UAObjectType | UAVariableType>(
453
473
  instance: B,
454
474
  topMostType: T,
455
- typeNode: T,
475
+ typeDefinitionNode: T,
456
476
  copyAlsoModellingRules: boolean,
457
477
  optionalsMap: OptionalMap,
458
478
  extraInfo: CloneHelper
459
479
  ) {
460
480
  if (doDebug) {
461
- console.log("instance browseName =", instance.browseName.toString());
462
- console.log("typeNode =", typeNode.browseName.toString());
463
- console.log("optionalsMap =", Object.keys(optionalsMap).join(" "));
481
+ debugLog("instance browseName =", instance.browseName.toString());
482
+ debugLog("typeNode =", typeDefinitionNode.browseName.toString());
483
+ debugLog("optionalsMap =", Object.keys(optionalsMap).join(" "));
464
484
 
465
- const c = typeNode.findReferencesEx("Aggregates");
466
- console.log("type possibilities =", c.map((x) => x.node!.browseName.toString()).join(" "));
485
+ const c = typeDefinitionNode.findReferencesEx("Aggregates");
486
+ debugLog("typeDefinition aggregates =", c.map((x) => x.node!.browseName.toString()).join(" "));
467
487
  }
468
488
  optionalsMap = optionalsMap || {};
469
489
 
470
- if (sameNodeId(topMostType.nodeId, typeNode.nodeId)) {
490
+ if (sameNodeId(topMostType.nodeId, typeDefinitionNode.nodeId)) {
471
491
  return; // nothing to do
472
492
  }
473
493
 
474
- const baseTypeNodeId = typeNode.subtypeOf;
475
- const baseType = typeNode.subtypeOfObj;
494
+ const filter = new MandatoryChildOrRequestedOptionalFilter(instance, optionalsMap);
476
495
 
477
- // istanbul ignore next
478
- if (!baseType) {
479
- throw new Error(chalk.red("Cannot find object with nodeId ") + baseTypeNodeId);
480
- }
496
+ doTrace &&
497
+ traceLog(
498
+ chalk.cyan(extraInfo.pad(), "cloning relevant member of typeDefinition class"),
499
+ typeDefinitionNode.browseName.toString()
500
+ );
481
501
 
482
- const filter = new MandatoryChildOrRequestedOptionalFilter(instance, optionalsMap);
502
+ const browseNameMap = new Set<string>();
503
+
504
+ _clone_children_references(typeDefinitionNode, instance, copyAlsoModellingRules, filter, extraInfo, browseNameMap);
505
+
506
+ // now apply recursion on baseTypeDefinition to get properties and components from base class
483
507
 
484
- _clone_children_references(typeNode, instance, copyAlsoModellingRules, filter, extraInfo);
508
+ const baseTypeDefinitionNodeId = typeDefinitionNode.subtypeOf;
509
+ const baseTypeDefinition = typeDefinitionNode.subtypeOfObj!;
510
+
511
+ doTrace &&
512
+ traceLog(
513
+ chalk.cyan(
514
+ extraInfo.pad(),
515
+ "now apply recursion on baseTypeDefinition to get properties and components from base class"
516
+ ),
517
+ baseTypeDefinition.browseName.toString()
518
+ );
519
+
520
+ // istanbul ignore next
521
+ if (!baseTypeDefinition) {
522
+ throw new Error(chalk.red("Cannot find object with nodeId ") + baseTypeDefinitionNodeId);
523
+ }
524
+ extraInfo.level++;
525
+ _initialize_properties_and_components(
526
+ instance,
527
+ topMostType,
528
+ baseTypeDefinition,
529
+ copyAlsoModellingRules,
530
+ optionalsMap,
531
+ extraInfo
532
+ );
533
+ extraInfo.level--;
485
534
 
486
- // get properties and components from base class
487
- _initialize_properties_and_components(instance, topMostType, baseType, copyAlsoModellingRules, optionalsMap, extraInfo);
488
535
  }
489
536
 
490
537
  /**
@@ -595,8 +642,6 @@ function findNonHierarchicalReferences(originalObject: BaseNode): UAReference[]
595
642
 
596
643
  if (child) {
597
644
  const baseRef = findNonHierarchicalReferences(child);
598
- // xx console.log(" ... ",originalObject.browseName.toString(),
599
- // parent.browseName.toString(), references.length, baseRef.length);
600
645
  references = ([] as UAReference[]).concat(references, baseRef);
601
646
  }
602
647
  }
@@ -691,15 +736,6 @@ function reconstructFunctionalGroupType(extraInfo: any) {
691
736
  for (const { original, cloned } of extraInfo.mapOrgToClone.values()) {
692
737
  const organizedByArray = original.findReferencesEx("Organizes", BrowseDirection.Inverse);
693
738
 
694
- // function dumpRef(r) {
695
- // var referenceTd = addressSpace.findNode(r.referenceTypeId);
696
- // var obj = addressSpace.findNode(r.nodeId);
697
- // return "<-- " + referenceTd.browseName.toString() + " -- " + obj.browseName.toString();
698
- // }
699
- //
700
- // console.log("xxxxx ========================================================",
701
- // originalObject.browseName.toString(),
702
- // organizedByArray.map(dumpRef).join("\n"));
703
739
  for (const ref of organizedByArray) {
704
740
  const info = extraInfo.mapOrgToClone.get(ref.nodeId.toString());
705
741
  if (!info) continue;
@@ -718,7 +754,6 @@ function reconstructFunctionalGroupType(extraInfo: any) {
718
754
  nodeId: cloned.nodeId,
719
755
  referenceType: ref.referenceType
720
756
  });
721
- // xx console.log("xxx ============> adding reference ",ref.browse )
722
757
  }
723
758
  }
724
759
  }
@@ -34,7 +34,7 @@ export class UAViewImpl extends BaseNodeImpl implements UAView {
34
34
 
35
35
  switch (attributeId) {
36
36
  case AttributeIds.EventNotifier:
37
- options.value = { dataType: DataType.UInt32, value: this.eventNotifier };
37
+ options.value = { dataType: DataType.Byte, value: this.eventNotifier };
38
38
  options.statusCode = StatusCodes.Good;
39
39
  break;
40
40
 
@@ -28,7 +28,7 @@ export class MockContinuationPointManager implements IContinuationPointManager {
28
28
 
29
29
  export const mockSession = {
30
30
  getSessionId() {
31
- return NodeId.nullNodeId;
31
+ return new NodeId();
32
32
  },
33
33
  continuationPointManager: new MockContinuationPointManager()
34
34
  };
@@ -13,6 +13,7 @@
13
13
  <Alias Alias="HasTypeDefinition">i=40</Alias>
14
14
  <Alias Alias="HasProperty">i=46</Alias>
15
15
  <Alias Alias="HasNotifier">i=48</Alias>
16
+ <Alias Alias="HasEncoding">i=38</Alias>
16
17
  <Alias Alias="LocalizedText">i=21</Alias>
17
18
  </Aliases>
18
19
  <UADataType NodeId="i=6" BrowseName="Int32">
@@ -231,6 +232,23 @@
231
232
  </References>
232
233
  <InverseName>MayBeEffectedBy</InverseName>
233
234
  </UAReferenceType>
235
+ <UAReferenceType NodeId="i=38" BrowseName="HasEncoding">
236
+ <DisplayName>HasEncoding</DisplayName>
237
+ <Description>The type for references from data type nodes to to data type encoding nodes.</Description>
238
+ <References>
239
+ <Reference ReferenceType="HasSubtype" IsForward="false">i=32</Reference>
240
+ </References>
241
+ <InverseName>EncodingOf</InverseName>
242
+ </UAReferenceType>
243
+ <UAReferenceType NodeId="i=17603" BrowseName="HasInterface">
244
+ <DisplayName>HasInterface</DisplayName>
245
+ <Documentation>https://reference.opcfoundation.org/v104/Core/docs/Amendment7/11.20</Documentation>
246
+ <References>
247
+ <Reference ReferenceType="HasSubtype" IsForward="false">i=32</Reference>
248
+ </References>
249
+ <InverseName>InterfaceOf</InverseName>
250
+ </UAReferenceType>
251
+
234
252
  <UAObjectType NodeId="i=58" BrowseName="BaseObjectType">
235
253
  <DisplayName>BaseObjectType</DisplayName>
236
254
  <Description>The base type for all object nodes.</Description>
@@ -357,6 +357,14 @@
357
357
  <Reference ReferenceType="HasSubtype" IsForward="false">i=58</Reference>
358
358
  </References>
359
359
  </UAObjectType>
360
-
360
+
361
+ <UAReferenceType NodeId="i=38" BrowseName="HasEncoding">
362
+ <DisplayName>HasEncoding</DisplayName>
363
+ <Documentation>https://reference.opcfoundation.org/v104/Core/docs/Part5/11.13</Documentation>
364
+ <References>
365
+ <Reference ReferenceType="HasSubtype" IsForward="false">i=32</Reference>
366
+ </References>
367
+ <InverseName>EncodingOf</InverseName>
368
+ </UAReferenceType>
361
369
 
362
370
  </UANodeSet>
@@ -442,7 +442,14 @@
442
442
  </References>
443
443
  <InverseName>HistoricalConfigurationOf</InverseName>
444
444
  </UAReferenceType>
445
-
445
+ <UAReferenceType NodeId="i=17603" BrowseName="HasInterface">
446
+ <DisplayName>HasInterface</DisplayName>
447
+ <Documentation>https://reference.opcfoundation.org/v104/Core/docs/Amendment7/11.20</Documentation>
448
+ <References>
449
+ <Reference ReferenceType="HasSubtype" IsForward="false">i=32</Reference>
450
+ </References>
451
+ <InverseName>InterfaceOf</InverseName>
452
+ </UAReferenceType>
446
453
 
447
454
 
448
455
  <UAObjectType NodeId="i=75" BrowseName="DataTypeSystemType">
@@ -4505,4 +4512,18 @@
4505
4512
  <Reference ReferenceType="HasProperty" IsForward="false">i=11646</Reference>
4506
4513
  </References>
4507
4514
  </UAVariable>
4515
+ <UADataType NodeId="i=256" BrowseName="IdType">
4516
+ <DisplayName>IdType</DisplayName>
4517
+ <Documentation>https://reference.opcfoundation.org/v104/Core/docs/Part3/8.2.3</Documentation>
4518
+ <References>
4519
+ <Reference ReferenceType="HasProperty">i=7591</Reference>
4520
+ <Reference ReferenceType="HasSubtype" IsForward="false">i=29</Reference>
4521
+ </References>
4522
+ <Definition Name="IdType">
4523
+ <Field Name="Numeric" Value="0" />
4524
+ <Field Name="String" Value="1" />
4525
+ <Field Name="Guid" Value="2" />
4526
+ <Field Name="Opaque" Value="3" />
4527
+ </Definition>
4528
+ </UADataType>
4508
4529
  </UANodeSet>