node-opcua-address-space 2.106.0 → 2.107.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 (53) hide show
  1. package/dist/source/loader/register_node_promoter.d.ts +1 -1
  2. package/dist/source/loader/register_node_promoter.js +2 -2
  3. package/dist/source/loader/register_node_promoter.js.map +1 -1
  4. package/dist/src/_instantiate_helpers.d.ts +2 -0
  5. package/dist/src/_instantiate_helpers.js +80 -0
  6. package/dist/src/_instantiate_helpers.js.map +1 -0
  7. package/dist/src/_mandatory_child_or_requested_optional_filter.d.ts +9 -0
  8. package/dist/src/_mandatory_child_or_requested_optional_filter.js +80 -0
  9. package/dist/src/_mandatory_child_or_requested_optional_filter.js.map +1 -0
  10. package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js +3 -0
  11. package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js.map +1 -1
  12. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js +1 -1
  13. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js.map +1 -1
  14. package/dist/src/alarms_and_conditions/ua_condition_impl.d.ts +2 -2
  15. package/dist/src/alarms_and_conditions/ua_condition_impl.js +2 -1
  16. package/dist/src/alarms_and_conditions/ua_condition_impl.js.map +1 -1
  17. package/dist/src/base_node_private.d.ts +1 -1
  18. package/dist/src/base_node_private.js +82 -82
  19. package/dist/src/base_node_private.js.map +1 -1
  20. package/dist/src/namespace_impl.d.ts +1 -1
  21. package/dist/src/namespace_impl.js +6 -6
  22. package/dist/src/namespace_impl.js.map +1 -1
  23. package/dist/src/state_machine/finite_state_machine.d.ts +1 -1
  24. package/dist/src/state_machine/finite_state_machine.js +204 -19
  25. package/dist/src/state_machine/finite_state_machine.js.map +1 -1
  26. package/dist/src/ua_method_impl.js +4 -1
  27. package/dist/src/ua_method_impl.js.map +1 -1
  28. package/dist/src/ua_object_impl.js +2 -3
  29. package/dist/src/ua_object_impl.js.map +1 -1
  30. package/dist/src/ua_object_type_impl.js +2 -1
  31. package/dist/src/ua_object_type_impl.js.map +1 -1
  32. package/dist/src/ua_variable_impl.d.ts +1 -1
  33. package/dist/src/ua_variable_impl.js +6 -4
  34. package/dist/src/ua_variable_impl.js.map +1 -1
  35. package/dist/src/ua_variable_type_impl.d.ts +5 -3
  36. package/dist/src/ua_variable_type_impl.js +8 -132
  37. package/dist/src/ua_variable_type_impl.js.map +1 -1
  38. package/dist/tsconfig_common.tsbuildinfo +1 -1
  39. package/package.json +17 -17
  40. package/source/loader/register_node_promoter.ts +3 -6
  41. package/src/_instantiate_helpers.ts +141 -0
  42. package/src/_mandatory_child_or_requested_optional_filter.ts +98 -0
  43. package/src/alarms_and_conditions/ua_alarm_condition_impl.ts +3 -0
  44. package/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.ts +1 -1
  45. package/src/alarms_and_conditions/ua_condition_impl.ts +7 -5
  46. package/src/base_node_private.ts +100 -117
  47. package/src/namespace_impl.ts +11 -7
  48. package/src/state_machine/finite_state_machine.ts +250 -37
  49. package/src/ua_method_impl.ts +4 -1
  50. package/src/ua_object_impl.ts +2 -3
  51. package/src/ua_object_type_impl.ts +1 -1
  52. package/src/ua_variable_impl.ts +7 -7
  53. package/src/ua_variable_type_impl.ts +4 -202
@@ -5,28 +5,41 @@ import chalk from "chalk";
5
5
  import { UAState, UAStateVariable, UATransition, UATransition_Base, UATransitionVariable } from "node-opcua-nodeset-ua";
6
6
  import { assert } from "node-opcua-assert";
7
7
  import { ObjectTypeIds } from "node-opcua-constants";
8
- import { coerceLocalizedText, LocalizedText, NodeClass } from "node-opcua-data-model";
8
+ import {
9
+ BrowseDirection,
10
+ coerceLocalizedText,
11
+ coerceQualifiedName,
12
+ LocalizedText,
13
+ NodeClass,
14
+ QualifiedName
15
+ } from "node-opcua-data-model";
9
16
  import { AttributeIds } from "node-opcua-data-model";
10
- import { NodeId } from "node-opcua-nodeid";
17
+ import { make_warningLog } from "node-opcua-debug";
18
+ import { NodeId, sameNodeId } from "node-opcua-nodeid";
11
19
  import { StatusCodes } from "node-opcua-status-code";
12
- import { DataType } from "node-opcua-variant";
20
+ import { DataType, Variant, VariantArrayType } from "node-opcua-variant";
13
21
  import { UAString } from "node-opcua-basic-types";
14
22
  import { BaseNode, UAMethod, UAObject, UAObjectType, UAVariable, UAVariableT } from "node-opcua-address-space-base";
15
23
  import { registerNodePromoter } from "../../source/loader/register_node_promoter";
16
24
 
17
- import { UAStateMachineEx, TransitionSelector, UAStateMachineTypeHelper } from "../../source/interfaces/state_machine/ua_state_machine_type";
25
+ import {
26
+ UAStateMachineEx,
27
+ TransitionSelector,
28
+ UAStateMachineTypeHelper
29
+ } from "../../source/interfaces/state_machine/ua_state_machine_type";
18
30
  import { UAObjectImpl } from "../ua_object_impl";
19
31
  import { UATransitionEx } from "../../source/interfaces/state_machine/ua_transition_ex";
20
32
  import { BaseNodeImpl } from "../base_node_impl";
21
33
  import { UAObjectTypeImpl } from "../ua_object_type_impl";
22
34
 
35
+ const warningLog = make_warningLog(__filename);
36
+
23
37
  const doDebug = false;
24
38
 
25
- export declare interface UATransitionImpl extends UATransition, UATransitionEx { }
26
- export class UATransitionImpl implements UATransition, UATransitionEx { }
39
+ export declare interface UATransitionImpl extends UATransition, UATransitionEx {}
40
+ export class UATransitionImpl implements UATransition, UATransitionEx {}
27
41
 
28
42
  function getComponentOfType(typeDef: UAObjectType, typedefinition: UAObjectType): UAObject[] {
29
-
30
43
  const get = (typeDef: UAObjectType) =>
31
44
  typeDef.getComponents().filter((cc) => {
32
45
  const c = cc as UAObject | UAVariable | UAMethod;
@@ -45,7 +58,6 @@ function getComponentOfType(typeDef: UAObjectType, typedefinition: UAObjectType)
45
58
  components_parts = get(typeDef);
46
59
  }
47
60
  return components_parts as UAObject[];
48
-
49
61
  }
50
62
 
51
63
  export interface UAStateMachineImpl {
@@ -63,25 +75,18 @@ const defaultPredicate = (transitions: UATransition[], fromState: UAState, toSta
63
75
  if (transitions.length === 1) {
64
76
  return transitions[0];
65
77
  }
66
- // tslint:disable-next-line: no-console
67
- console.log(" FromState = ", fromState.browseName.toString());
68
- // tslint:disable-next-line: no-console
69
- console.log(" ToState = ", toState.browseName.toString());
78
+ warningLog(" FromState = ", fromState.browseName.toString());
79
+ warningLog(" ToState = ", toState.browseName.toString());
70
80
  for (const transition of transitions) {
71
- // tslint:disable-next-line: no-console
72
- console.log(" possible transition : ", transition.browseName.toString(), " ", transition.nodeId.toString());
81
+ warningLog(" possible transition : ", transition.browseName.toString(), " ", transition.nodeId.toString());
73
82
  }
74
- // tslint:disable-next-line: no-console
75
- console.log(
83
+ warningLog(
76
84
  "warning: a duplicated FromState Reference to the same target has been found.\nPlease check your model or provide a predicate method to select which one to use"
77
85
  );
78
- // tslint:disable-next-line: no-console
79
- console.log("fromStateNode: ", fromState.toString());
86
+ warningLog("fromStateNode: ", fromState.toString());
80
87
  return transitions[0];
81
88
  };
82
89
 
83
-
84
-
85
90
  export function getFiniteStateMachineTypeStates(uaFiniteStateMachineType: UAObjectType): UAState[] {
86
91
  const addressSpace = uaFiniteStateMachineType.addressSpace;
87
92
 
@@ -113,7 +118,6 @@ export function getFiniteStateMachineTypeTransitions(uaFiniteStateMachineType: U
113
118
  }
114
119
  const comp = getComponentOfType(uaFiniteStateMachineType, transitionType);
115
120
  return comp as UATransitionEx[];
116
-
117
121
  }
118
122
 
119
123
  export function getFiniteStateMachineTypeStateByName(uaFiniteStateMachineType: UAObjectType, stateName: string): UAState | null {
@@ -185,13 +189,10 @@ export class UAStateMachineImpl extends UAObjectImpl implements UAStateMachineEx
185
189
  * @private
186
190
  */
187
191
  public _coerceNode(node: UAState | BaseNode | null | string | NodeId): BaseNode | null {
188
- if (node === null) {
189
- return null;
190
- }
191
- const addressSpace = this.addressSpace;
192
192
  if (node instanceof BaseNodeImpl) {
193
193
  return node;
194
194
  } else if (node instanceof NodeId) {
195
+ const addressSpace = this.addressSpace;
195
196
  return addressSpace.findNode(node) as BaseNode;
196
197
  } else if (typeof node === "string") {
197
198
  return this.getStateByName(node) as any as BaseNode;
@@ -243,14 +244,18 @@ export class UAStateMachineImpl extends UAObjectImpl implements UAStateMachineEx
243
244
  return null;
244
245
  }
245
246
 
247
+ // istanbul ignore next
246
248
  if (_fromStateNode.nodeClass !== NodeClass.Object) {
247
249
  throw new Error("Internal Error");
248
250
  }
251
+ // istanbul ignore next
249
252
  if (_toStateNode && _toStateNode.nodeClass !== NodeClass.Object) {
250
253
  throw new Error("Internal Error");
251
254
  }
252
255
 
253
256
  const stateType = addressSpace.findObjectType("StateType");
257
+
258
+ // istanbul ignore next
254
259
  if (!stateType) {
255
260
  throw new Error("Cannot find StateType");
256
261
  }
@@ -318,7 +323,6 @@ export class UAStateMachineImpl extends UAObjectImpl implements UAStateMachineEx
318
323
  if (!state) {
319
324
  throw new Error("Cannot find state with name " + toStateNode);
320
325
  }
321
- assert(state.browseName.name!.toString() === toStateNode);
322
326
  toStateNode = state;
323
327
  }
324
328
  const fromStateNode = this.currentStateNode;
@@ -329,16 +333,195 @@ export class UAStateMachineImpl extends UAObjectImpl implements UAStateMachineEx
329
333
  this.currentState.setValueFromSource(
330
334
  {
331
335
  dataType: DataType.LocalizedText,
332
- value: coerceLocalizedText(toStateNode.browseName.toString())
336
+ value: coerceLocalizedText(toStateNode.displayName[0] || toStateNode.browseName.name!)
333
337
  },
334
338
  StatusCodes.Good
335
339
  );
336
340
 
337
341
  this.currentStateNode = toStateNode;
338
342
 
339
- const transitionNode = this.findTransitionNode(fromStateNode, toStateNode, predicate) as UATransitionImpl;
343
+ const applyCurrentStateOptionalProps = () => {
344
+ const uaId = this.currentState.getPropertyByName("Id")! as UAVariable;
345
+ if (uaId) {
346
+ uaId.setValueFromSource({
347
+ dataType: DataType.NodeId,
348
+ value: this.currentStateNode ? this.currentStateNode.nodeId : NodeId.nullNodeId
349
+ });
350
+ }
351
+
352
+ const uaName = this.currentState.getPropertyByName("Name")! as UAVariable;
353
+ if (uaName) {
354
+ uaName.setValueFromSource({
355
+ dataType: DataType.QualifiedName,
356
+ value: this.currentStateNode ? this.currentStateNode.browseName : coerceQualifiedName("")
357
+ });
358
+ }
340
359
 
360
+ const uaNumber = this.currentState.getPropertyByName("Number")! as UAVariable;
361
+ if (uaNumber) {
362
+ if (!this.currentStateNode) {
363
+ const n = uaNumber.setValueFromSource({
364
+ dataType: DataType.UInt32,
365
+ value: 0 // may be wrong !
366
+ });
367
+ } else {
368
+ const n = uaNumber.setValueFromSource({
369
+ dataType: DataType.UInt32,
370
+ value: this.currentStateNode.stateNumber.readValue().value.value
371
+ });
372
+ }
373
+ }
374
+
375
+ const uaEffectiveDisplayName = this.currentState.getPropertyByName("EffectiveDisplayName")! as UAVariable;
376
+ if (uaEffectiveDisplayName) {
377
+ uaEffectiveDisplayName.setValueFromSource({
378
+ dataType: DataType.LocalizedText,
379
+ value: coerceLocalizedText(
380
+ this.currentStateNode ? this.currentStateNode.displayName[0] || this.currentStateNode.browseName.name : ""
381
+ )
382
+ });
383
+ }
384
+ };
385
+ applyCurrentStateOptionalProps();
386
+
387
+ const transitionTime = new Date();
388
+ const applyTransitionOptionalPropsPhase1 = () => {
389
+ // +-----------------------------+
390
+ // +--------------------------------|>|>| MainStateMachineType |
391
+ // | +-----------------------------+
392
+ // | |
393
+ // | | +--------+
394
+ // +------------------+ +--->| State1 |
395
+ // | MainStateMachine | | +--------+
396
+ // +------------------+ |
397
+ // | | +--------+
398
+ // | +----------------+ +--->| State2 | --- HasSubStateMachine --+
399
+ // +---||->| SubStateMachine| | +--------+ |
400
+ // +----------------+ | |
401
+ // | | +-----------------+ |
402
+ // +--->| SubStateMachine |<------------------+
403
+ // +-----------------+
404
+ //
405
+ // * `this` is potentially a subState machine
406
+ // * get mainState = parent of `this`
407
+ // * is mainState.typeDefinition is not StateMachineType -> exit
408
+ // * find subMachine in mainState.typeDefinition (or any subtype of it) that has the same browse name as this.browseName
409
+ const ms = this.findReferencesExAsObject("Aggregates", BrowseDirection.Inverse)[0] as
410
+ | UAStateMachineEx
411
+ | undefined
412
+ | null;
413
+ if (!ms) return;
414
+ if (ms.nodeClass !== NodeClass.Object) return;
415
+ const stateMachineType = this.addressSpace.findObjectType("StateMachineType")!;
416
+ if (!ms.typeDefinitionObj.isSubtypeOf(stateMachineType)) return;
417
+
418
+ const find = (node: UAObjectType, browseName: QualifiedName): UAObject | UAVariable | null => {
419
+ const r = node
420
+ .getAggregates()
421
+ .filter((x) => x.browseName.name! === browseName.name && x.namespaceIndex === browseName.namespaceIndex);
422
+ if (r.length === 0) {
423
+ // look in subType
424
+ const subType = node.subtypeOfObj;
425
+ if (subType) {
426
+ return find(subType, browseName);
427
+ }
428
+ return null;
429
+ } else {
430
+ const retVal = r[0];
431
+
432
+ // istanbul ignore next
433
+ if (retVal.nodeClass !== NodeClass.Variable && retVal.nodeClass !== NodeClass.Object) {
434
+ throw new Error("find: expecting only object and variable here");
435
+ }
436
+ return retVal as UAObject | UAVariable;
437
+ }
438
+ };
439
+ const stateMachineInType = find(ms.typeDefinitionObj, this.browseName);
440
+ if (!stateMachineInType) return;
441
+ const mainState = stateMachineInType.findReferencesAsObject("HasSubStateMachine", false)[0] as UAVariable;
442
+
443
+ if (mainState) {
444
+ if (!ms.currentStateNode || !sameNodeId(mainState.nodeId, ms.currentStateNode.nodeId)) {
445
+ return;
446
+ }
447
+
448
+ // also update uaLastTransition.EffectiveTransitionTime
449
+ const uaLastTransitionMain = ms.getComponentByName("LastTransition") as UAVariable;
450
+ if (uaLastTransitionMain) {
451
+ const uaEffectiveTransitionTimeMain = uaLastTransitionMain.getPropertyByName(
452
+ "EffectiveTransitionTime"
453
+ )! as UAVariable;
454
+ if (uaEffectiveTransitionTimeMain) {
455
+ uaEffectiveTransitionTimeMain.setValueFromSource({
456
+ dataType: DataType.DateTime,
457
+ value: transitionTime
458
+ });
459
+ }
460
+ }
461
+ }
462
+ };
463
+ applyTransitionOptionalPropsPhase1();
464
+
465
+ const transitionNode = this.findTransitionNode(fromStateNode, toStateNode, predicate) as UATransitionImpl;
341
466
  if (transitionNode) {
467
+ const applyLastTransitionOptionalProps = () => {
468
+ const uaLastTransition = this.getComponentByName("LastTransition") as UAVariable;
469
+ if (uaLastTransition) {
470
+ uaLastTransition.setValueFromSource(
471
+ {
472
+ dataType: DataType.LocalizedText,
473
+ value: transitionNode.displayName[0] || transitionNode.browseName.name!
474
+ },
475
+ StatusCodes.Good,
476
+ transitionTime
477
+ );
478
+
479
+ const uaId = uaLastTransition.getPropertyByName("Id")! as UAVariable;
480
+ if (uaId) {
481
+ uaId.setValueFromSource({
482
+ dataType: DataType.NodeId,
483
+ value: transitionNode.nodeId
484
+ });
485
+ }
486
+
487
+ const uaLastTransitionTime = uaLastTransition.getPropertyByName("TransitionTime")! as UAVariable;
488
+ if (uaLastTransitionTime) {
489
+ uaLastTransitionTime.setValueFromSource({
490
+ dataType: DataType.DateTime,
491
+ value: transitionTime
492
+ });
493
+ }
494
+ /**
495
+ * EffectiveTransitionTime specifies the time when the current state or one of its sub-states was entered.
496
+ * If, for example, a StateA is active and – while active – switches several times between its sub-states
497
+ * SubA and SubB, then the TransitionTime stays at the point in time where StateA became active whereas the *
498
+ * EffectiveTransitionTime changes with each change of a sub-state.
499
+ */
500
+ const uaEffectiveTransitionTime = uaLastTransition.getPropertyByName("EffectiveTransitionTime")! as UAVariable;
501
+ if (uaEffectiveTransitionTime) {
502
+ uaEffectiveTransitionTime.setValueFromSource({
503
+ dataType: DataType.DateTime,
504
+ value: transitionTime
505
+ });
506
+ }
507
+ //
508
+ const uaName = uaLastTransition.getPropertyByName("Name")! as UAVariable;
509
+ if (uaName) {
510
+ uaName.setValueFromSource({
511
+ dataType: DataType.QualifiedName,
512
+ value: transitionNode.browseName
513
+ });
514
+ }
515
+ const uaNumber = uaLastTransition.getPropertyByName("Number")! as UAVariable;
516
+ if (uaNumber) {
517
+ uaNumber.setValueFromSource({
518
+ dataType: DataType.UInt32,
519
+ value: transitionNode.transitionNumber.readValue().value.value
520
+ });
521
+ }
522
+ }
523
+ };
524
+ applyLastTransitionOptionalProps();
342
525
  // xx console.log("transitionNode ",transitionNode.toString());
343
526
  // The inherited Property SourceNode shall be filled with the NodeId of the StateMachine instance where the
344
527
  // Transition occurs. If the Transition occurs in a SubStateMachine, then the NodeId of the SubStateMachine
@@ -367,8 +550,8 @@ export class UAStateMachineImpl extends UAObjectImpl implements UAStateMachineEx
367
550
  "fromState.id": fromStateNode
368
551
  ? fromStateNode.stateNumber.readValue().value
369
552
  : {
370
- dataType: "Null"
371
- },
553
+ dataType: "Null"
554
+ },
372
555
 
373
556
  toState: {
374
557
  dataType: "LocalizedText",
@@ -383,8 +566,7 @@ export class UAStateMachineImpl extends UAObjectImpl implements UAStateMachineEx
383
566
  if (doDebug) {
384
567
  const f = fromStateNode.browseName.toString();
385
568
  const t = toStateNode.browseName.toString();
386
- // tslint:disable-next-line:no-console
387
- console.log(chalk.red("Warning"), " cannot raise event : transition " + f + " to " + t + " is missing");
569
+ warningLog(chalk.red("Warning"), " cannot raise event : transition " + f + " to " + t + " is missing");
388
570
  }
389
571
  }
390
572
  }
@@ -397,11 +579,13 @@ export class UAStateMachineImpl extends UAObjectImpl implements UAStateMachineEx
397
579
 
398
580
  /**
399
581
  * @internal
400
- * @private
582
+ * @private|
401
583
  */
402
584
  public _post_initialize(): void {
403
585
  const addressSpace = this.addressSpace;
404
586
  const finiteStateMachineType = addressSpace.findObjectType("FiniteStateMachineType");
587
+
588
+ // istanbul ignore next
405
589
  if (!finiteStateMachineType) {
406
590
  throw new Error("cannot find FiniteStateMachineType");
407
591
  }
@@ -419,6 +603,38 @@ export class UAStateMachineImpl extends UAObjectImpl implements UAStateMachineEx
419
603
  d.value && d.value.value ? (d.value.value.text ? d.value.value.text.toString() : d.value.value.toString()) : "";
420
604
  this.currentStateNode = this.getStateByName(txt);
421
605
  }
606
+
607
+ // Install AvailableStatesVariable if available
608
+ const uaAvailableStates = this.getComponentByName("AvailableStates", 0) as UAVariable;
609
+ if (uaAvailableStates) {
610
+ uaAvailableStates.bindVariable(
611
+ {
612
+ get: () => {
613
+ return new Variant({
614
+ arrayType: VariantArrayType.Array,
615
+ dataType: DataType.NodeId,
616
+ value: this.getStates().map((state) => state.nodeId)
617
+ });
618
+ }
619
+ },
620
+ true
621
+ );
622
+ }
623
+ const uaAvailableTransitions = this.getComponentByName("AvailableTransitions", 0) as UAVariable;
624
+ if (uaAvailableTransitions) {
625
+ uaAvailableTransitions.bindVariable(
626
+ {
627
+ get: () => {
628
+ return new Variant({
629
+ arrayType: VariantArrayType.Array,
630
+ dataType: DataType.NodeId,
631
+ value: this.getTransitions().map((state) => state.nodeId)
632
+ });
633
+ }
634
+ },
635
+ true
636
+ );
637
+ }
422
638
  }
423
639
  }
424
640
 
@@ -434,14 +650,12 @@ export function promoteToStateMachine(node: UAObject): UAStateMachineEx {
434
650
  }
435
651
  registerNodePromoter(ObjectTypeIds.FiniteStateMachineType, promoteToStateMachine);
436
652
 
437
-
438
653
  export class UAStateMachineTypeImpl extends UAObjectTypeImpl implements UAStateMachineTypeHelper {
439
654
  getStateByName(name: string): UAState | null {
440
655
  return getFiniteStateMachineTypeStateByName(this, name);
441
656
  }
442
657
  getStates(): UAState[] {
443
658
  return getFiniteStateMachineTypeStates(this);
444
-
445
659
  }
446
660
  getTransitions(): UATransitionEx[] {
447
661
  return getFiniteStateMachineTypeTransitions(this);
@@ -450,7 +664,6 @@ export class UAStateMachineTypeImpl extends UAObjectTypeImpl implements UAStateM
450
664
  _post_initialize(): void {
451
665
  /** */
452
666
  }
453
-
454
667
  }
455
668
  export function promoteToStateMachineType(node: UAObject): UAStateMachineTypeHelper {
456
669
  if (node instanceof UAStateMachineTypeImpl) {
@@ -461,4 +674,4 @@ export function promoteToStateMachineType(node: UAObject): UAStateMachineTypeHel
461
674
  const _node = node as unknown as UAStateMachineTypeImpl;
462
675
  _node._post_initialize();
463
676
  return _node;
464
- }
677
+ }
@@ -264,12 +264,15 @@ export class UAMethodImpl extends BaseNodeImpl implements UAMethod {
264
264
 
265
265
  _handle_hierarchy_parent(addressSpace, options.references, options);
266
266
 
267
+ if (!extraInfo) {
268
+ extraInfo = makeDefaultCloneExtraInfo(this);
269
+ }
267
270
  const clonedMethod = _clone(
268
271
  this,
269
272
  UAMethodImpl,
270
273
  options,
271
274
  optionalFilter || defaultCloneFilter,
272
- extraInfo || makeDefaultCloneExtraInfo()
275
+ extraInfo
273
276
  ) as UAMethodImpl;
274
277
 
275
278
  clonedMethod._asyncExecutionFunction = this._asyncExecutionFunction;
@@ -101,7 +101,7 @@ export class UAObjectImpl extends BaseNodeImpl implements UAObject {
101
101
  UAObjectImpl,
102
102
  options,
103
103
  optionalFilter || defaultCloneFilter,
104
- extraInfo || makeDefaultCloneExtraInfo()
104
+ extraInfo || makeDefaultCloneExtraInfo(this)
105
105
  ) as UAObject;
106
106
  // xx newObject.propagate_back_references();
107
107
  // xx newObject.install_extra_properties();
@@ -191,8 +191,7 @@ export class UAObjectImpl extends BaseNodeImpl implements UAObject {
191
191
  server.emit("event", eventData);
192
192
  m[server.nodeId.toString()] = server;
193
193
  } else {
194
- // tslint:disable:no-console
195
- console.warn(
194
+ errorLog(
196
195
  chalk.yellow("Warning. ") +
197
196
  chalk.cyan("UAObject#raiseEvent") +
198
197
  chalk.red(" cannot find Server object on addressSpace")
@@ -25,10 +25,10 @@ import { get_subtypeOf, get_subtypeOfObj } from "./tool_isSubtypeOf";
25
25
  import * as tools from "./tool_isSubtypeOf";
26
26
  import {
27
27
  assertUnusedChildBrowseName,
28
- initialize_properties_and_components,
29
28
  topMostParentIsObjectTypeOrVariableType
30
29
  } from "./ua_variable_type_impl";
31
30
  import { AddressSpacePrivate } from "./address_space_private";
31
+ import { initialize_properties_and_components } from "./_instantiate_helpers";
32
32
 
33
33
  export class UAObjectTypeImpl extends BaseNodeImpl implements UAObjectType {
34
34
  public readonly nodeClass = NodeClass.ObjectType;
@@ -249,7 +249,7 @@ interface UAVariableOptions extends InternalBaseNodeOptions {
249
249
  value?: any;
250
250
  dataType: NodeId | string;
251
251
  /**
252
- * This attribute indicates whether the Value attribute of the Variableis an array and how many dimensions the array has.
252
+ * This attribute indicates whether the Value attribute of the Variable is an array and how many dimensions the array has.
253
253
  * It may have the following values:
254
254
  * * n > 1: the Value is an array with the specified number of dimensions.
255
255
  * * OneDimension (1): The value is an array with one dimension.
@@ -327,10 +327,10 @@ export class UAVariableImpl extends BaseNodeImpl implements UAVariable {
327
327
  get typeDefinitionObj(): UAVariableType {
328
328
  // istanbul ignore next
329
329
  if (super.typeDefinitionObj && super.typeDefinitionObj.nodeClass !== NodeClass.VariableType) {
330
- console.log(super.typeDefinitionObj.toString());
331
- throw new Error(
332
- "Invalid type definition node class , expecting a VariableType got " + NodeClass[super.typeDefinitionObj.nodeClass]
333
- );
330
+ // this could happen in faulty external nodeset and has been seen once
331
+ // in an nano server
332
+ warningLog(super.typeDefinitionObj.toString());
333
+ return this.addressSpace.findVariableType("BaseVariableType")!;
334
334
  }
335
335
  return super.typeDefinitionObj as UAVariableType;
336
336
  }
@@ -1371,7 +1371,7 @@ export class UAVariableImpl extends BaseNodeImpl implements UAVariable {
1371
1371
  UAVariableImpl,
1372
1372
  options,
1373
1373
  optionalFilter || defaultCloneFilter,
1374
- extraInfo || makeDefaultCloneExtraInfo()
1374
+ extraInfo || makeDefaultCloneExtraInfo(this)
1375
1375
  ) as UAVariableImpl;
1376
1376
 
1377
1377
  newVariable.bindVariable();
@@ -1387,7 +1387,7 @@ export class UAVariableImpl extends BaseNodeImpl implements UAVariable {
1387
1387
  try {
1388
1388
  newVariable.bindExtensionObject(newVariable.$dataValue.value.value);
1389
1389
  } catch (err) {
1390
- errorLog("Errro binding extension objects");
1390
+ errorLog("Error binding extension objects");
1391
1391
  errorLog((err as Error).message);
1392
1392
  errorLog(this.toString());
1393
1393
  errorLog("---------------------------------------");