node-opcua-address-space 2.112.0 → 2.113.1

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 (99) hide show
  1. package/dist/source/interfaces/alarms_and_conditions/condition_info_i.d.ts +2 -0
  2. package/dist/source/interfaces/alarms_and_conditions/condition_snapshot.d.ts +2 -1
  3. package/dist/source/interfaces/alarms_and_conditions/ua_condition_ex.d.ts +3 -2
  4. package/dist/source/interfaces/data_access/ua_multistate_discrete_ex.d.ts +2 -1
  5. package/dist/source/interfaces/data_access/ua_multistate_value_discrete_ex.d.ts +2 -1
  6. package/dist/source/interfaces/data_access/ua_two_state_discrete_ex.d.ts +2 -1
  7. package/dist/source/interfaces/i_set_state_options.d.ts +4 -0
  8. package/dist/source/interfaces/i_set_state_options.js +3 -0
  9. package/dist/source/interfaces/i_set_state_options.js.map +1 -0
  10. package/dist/source/loader/decode_xml_extension_object.js +0 -2
  11. package/dist/source/loader/decode_xml_extension_object.js.map +1 -1
  12. package/dist/source/loader/load_nodeset2.js +4 -2
  13. package/dist/source/loader/load_nodeset2.js.map +1 -1
  14. package/dist/source/loader/make_xml_extension_object_parser.js +1 -3
  15. package/dist/source/loader/make_xml_extension_object_parser.js.map +1 -1
  16. package/dist/source/loader/namespace_post_step.js +1 -0
  17. package/dist/source/loader/namespace_post_step.js.map +1 -1
  18. package/dist/source/ua_two_state_variable_ex.d.ts +2 -1
  19. package/dist/src/address_space.js +6 -14
  20. package/dist/src/address_space.js.map +1 -1
  21. package/dist/src/alarms_and_conditions/condition.js.map +1 -1
  22. package/dist/src/alarms_and_conditions/condition_snapshot_impl.d.ts +6 -5
  23. package/dist/src/alarms_and_conditions/condition_snapshot_impl.js +13 -15
  24. package/dist/src/alarms_and_conditions/condition_snapshot_impl.js.map +1 -1
  25. package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js +6 -2
  26. package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js.map +1 -1
  27. package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js +5 -5
  28. package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js.map +1 -1
  29. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js +0 -1
  30. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js.map +1 -1
  31. package/dist/src/alarms_and_conditions/ua_condition_impl.d.ts +3 -2
  32. package/dist/src/alarms_and_conditions/ua_condition_impl.js +12 -14
  33. package/dist/src/alarms_and_conditions/ua_condition_impl.js.map +1 -1
  34. package/dist/src/base_node_impl.js +9 -19
  35. package/dist/src/base_node_impl.js.map +1 -1
  36. package/dist/src/data_access/ua_multistate_discrete_impl.d.ts +3 -2
  37. package/dist/src/data_access/ua_multistate_discrete_impl.js +2 -2
  38. package/dist/src/data_access/ua_multistate_discrete_impl.js.map +1 -1
  39. package/dist/src/data_access/ua_multistate_value_discrete_impl.d.ts +3 -2
  40. package/dist/src/data_access/ua_multistate_value_discrete_impl.js +3 -3
  41. package/dist/src/data_access/ua_multistate_value_discrete_impl.js.map +1 -1
  42. package/dist/src/data_access/ua_two_state_discrete_impl.d.ts +2 -1
  43. package/dist/src/data_access/ua_two_state_discrete_impl.js +3 -3
  44. package/dist/src/data_access/ua_two_state_discrete_impl.js.map +1 -1
  45. package/dist/src/namespace_impl.js +5 -6
  46. package/dist/src/namespace_impl.js.map +1 -1
  47. package/dist/src/nodeset_tools/construct_namespace_dependency.js +11 -6
  48. package/dist/src/nodeset_tools/construct_namespace_dependency.js.map +1 -1
  49. package/dist/src/nodeset_tools/nodeset_to_xml.js +8 -9
  50. package/dist/src/nodeset_tools/nodeset_to_xml.js.map +1 -1
  51. package/dist/src/reference_impl.js +4 -1
  52. package/dist/src/reference_impl.js.map +1 -1
  53. package/dist/src/state_machine/finite_state_machine.js +2 -3
  54. package/dist/src/state_machine/finite_state_machine.js.map +1 -1
  55. package/dist/src/state_machine/ua_shelving_state_machine_ex.js +2 -2
  56. package/dist/src/state_machine/ua_shelving_state_machine_ex.js.map +1 -1
  57. package/dist/src/state_machine/ua_two_state_variable.d.ts +2 -1
  58. package/dist/src/state_machine/ua_two_state_variable.js +10 -9
  59. package/dist/src/state_machine/ua_two_state_variable.js.map +1 -1
  60. package/dist/src/ua_data_type_impl.js +0 -23
  61. package/dist/src/ua_data_type_impl.js.map +1 -1
  62. package/dist/src/ua_variable_impl_ext_obj.js +15 -8
  63. package/dist/src/ua_variable_impl_ext_obj.js.map +1 -1
  64. package/dist/tsconfig_common.tsbuildinfo +1 -1
  65. package/distHelpers/add_event_generator_object.js +0 -4
  66. package/distHelpers/add_event_generator_object.js.map +1 -1
  67. package/package.json +30 -30
  68. package/source/interfaces/alarms_and_conditions/condition_info_i.ts +3 -0
  69. package/source/interfaces/alarms_and_conditions/condition_snapshot.ts +2 -1
  70. package/source/interfaces/alarms_and_conditions/ua_condition_ex.ts +4 -2
  71. package/source/interfaces/data_access/ua_multistate_discrete_ex.ts +2 -1
  72. package/source/interfaces/data_access/ua_multistate_value_discrete_ex.ts +2 -1
  73. package/source/interfaces/data_access/ua_two_state_discrete_ex.ts +2 -1
  74. package/source/interfaces/i_set_state_options.ts +4 -0
  75. package/source/loader/decode_xml_extension_object.ts +0 -2
  76. package/source/loader/load_nodeset2.ts +4 -2
  77. package/source/loader/make_xml_extension_object_parser.ts +1 -4
  78. package/source/loader/namespace_post_step.ts +1 -0
  79. package/source/ua_two_state_variable_ex.ts +2 -1
  80. package/src/address_space.ts +7 -15
  81. package/src/alarms_and_conditions/condition.ts +1 -1
  82. package/src/alarms_and_conditions/condition_snapshot_impl.ts +16 -16
  83. package/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.ts +6 -3
  84. package/src/alarms_and_conditions/ua_alarm_condition_impl.ts +6 -6
  85. package/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.ts +0 -1
  86. package/src/alarms_and_conditions/ua_condition_impl.ts +13 -14
  87. package/src/base_node_impl.ts +12 -20
  88. package/src/data_access/ua_multistate_discrete_impl.ts +5 -3
  89. package/src/data_access/ua_multistate_value_discrete_impl.ts +5 -4
  90. package/src/data_access/ua_two_state_discrete_impl.ts +5 -3
  91. package/src/namespace_impl.ts +5 -6
  92. package/src/nodeset_tools/construct_namespace_dependency.ts +12 -7
  93. package/src/nodeset_tools/nodeset_to_xml.ts +8 -9
  94. package/src/reference_impl.ts +5 -1
  95. package/src/state_machine/finite_state_machine.ts +3 -4
  96. package/src/state_machine/ua_shelving_state_machine_ex.ts +2 -3
  97. package/src/state_machine/ua_two_state_variable.ts +14 -9
  98. package/src/ua_data_type_impl.ts +0 -24
  99. package/src/ua_variable_impl_ext_obj.ts +110 -82
@@ -9,7 +9,7 @@ import { DataValue } from "node-opcua-data-value";
9
9
  import { NodeId, sameNodeId } from "node-opcua-nodeid";
10
10
  import { StatusCodes } from "node-opcua-status-code";
11
11
  import { DataType, VariantOptions } from "node-opcua-variant";
12
- import { UAShelvedStateMachine } from "node-opcua-nodeset-ua";
12
+ import { make_debugLog } from "node-opcua-debug";
13
13
  import { BaseNode, INamespace, UAEventType, UAVariable } from "node-opcua-address-space-base";
14
14
 
15
15
  import { _install_TwoStateVariable_machinery } from "../state_machine/ua_two_state_variable";
@@ -22,6 +22,8 @@ import { InstantiateAlarmConditionOptions } from "../../source/interfaces/alarms
22
22
  import { ConditionInfoImpl } from "./condition_info_impl";
23
23
  import { UAAcknowledgeableConditionImpl } from "./ua_acknowledgeable_condition_impl";
24
24
 
25
+ const debugLog = make_debugLog(__filename);
26
+
25
27
  function _update_suppressedOrShelved(alarmNode: UAAlarmConditionImpl) {
26
28
  alarmNode.suppressedOrShelved.setValueFromSource({
27
29
  dataType: DataType.Boolean,
@@ -226,9 +228,7 @@ export class UAAlarmConditionImpl extends UAAcknowledgeableConditionImpl impleme
226
228
  if (shelvedValue && shelvedValue.text !== "Unshelved") {
227
229
  shelved = true;
228
230
  }
229
- // console.log("shelved = shelved",shelvedValue,shelved);
230
231
  }
231
- // xx console.log(" isSuppressedOrShelved ",suppressed,shelved);
232
232
  return suppressed || shelved;
233
233
  }
234
234
 
@@ -339,8 +339,7 @@ export class UAAlarmConditionImpl extends UAAcknowledgeableConditionImpl impleme
339
339
 
340
340
  const _node = addressSpace._coerceNode(inputNode);
341
341
  if (_node === null) {
342
- // tslint:disable-next-line:no-console
343
- console.log(" cannot find nodeId ", inputNode);
342
+ debugLog(" cannot find nodeId ", inputNode);
344
343
  } else {
345
344
  assert(_node, "Expecting a valid input node");
346
345
  this.inputNode.setValueFromSource({
@@ -451,7 +450,8 @@ export class UAAlarmConditionImpl extends UAAcknowledgeableConditionImpl impleme
451
450
  // detect potential internal bugs due to misused of _signalNewCondition
452
451
  if (isEqual(oldConditionInfo, newConditionInfo)) {
453
452
  // tslint:disable-next-line:no-console
454
- console.log(oldConditionInfo);
453
+ debugLog("oldConditionInfo", oldConditionInfo);
454
+ debugLog("oldConditionInfo", newConditionInfo);
455
455
  throw new Error(
456
456
  "condition values have not change, shall we really raise an event ? alarm " + this.browseName.toString()
457
457
  );
@@ -72,7 +72,6 @@ class UACertificateExpirationAlarmImpl extends UASystemOffNormalAlarmImpl implem
72
72
  }
73
73
 
74
74
  public updateAlarmState2(isActive: boolean, severity: number, message: string) {
75
- //xx console.log(`${message} ${severity} ${d(new Date())}`);
76
75
  isActive ? this.activateAlarm() : this.deactivateAlarm();
77
76
 
78
77
  this.raiseNewCondition({
@@ -41,6 +41,7 @@ import { ConditionInfoOptions } from "../../source/interfaces/alarms_and_conditi
41
41
  import { UAConditionEx } from "../../source/interfaces/alarms_and_conditions/ua_condition_ex";
42
42
  import { ConditionSnapshot } from "../../source/interfaces/alarms_and_conditions/condition_snapshot";
43
43
  import { InstantiateConditionOptions } from "../../source/interfaces/alarms_and_conditions/instantiate_condition_options";
44
+ import { ISetStateOptions } from "../../source/interfaces/i_set_state_options";
44
45
 
45
46
  import { AddressSpacePrivate } from "../address_space_private";
46
47
  import { _install_TwoStateVariable_machinery } from "../state_machine/ua_two_state_variable";
@@ -143,7 +144,6 @@ export class UAConditionImpl extends UABaseEventImpl implements UAConditionEx {
143
144
  ): void {
144
145
  const conditionNode = context.object;
145
146
 
146
- // xx console.log(inputArguments.map(function(a){return a.toString()}));
147
147
  if (!(conditionNode instanceof UAConditionImpl)) {
148
148
  callback(null, {
149
149
  statusCode: StatusCodes.BadNodeIdInvalid
@@ -278,7 +278,7 @@ export class UAConditionImpl extends UABaseEventImpl implements UAConditionEx {
278
278
  * returns {StatusCode} StatusCodes.Good if successful or BadConditionAlreadyEnabled/BadConditionAlreadyDisabled
279
279
  * @private
280
280
  */
281
- public _setEnabledState(requestedEnabledState: boolean): StatusCode {
281
+ public _setEnabledState(requestedEnabledState: boolean, options?: ISetStateOptions): StatusCode {
282
282
  assert(typeof requestedEnabledState === "boolean");
283
283
 
284
284
  const enabledState = this.getEnabledState();
@@ -289,7 +289,7 @@ export class UAConditionImpl extends UABaseEventImpl implements UAConditionEx {
289
289
  return StatusCodes.BadConditionAlreadyDisabled;
290
290
  }
291
291
 
292
- this._branch0.setEnabledState(requestedEnabledState);
292
+ this._branch0.setEnabledState(requestedEnabledState, options);
293
293
  // conditionNode.enabledState.setValue(requestedEnabledState);
294
294
 
295
295
  // xx assert(conditionNode.enabledState.id.readValue().value.value === requestedEnabledState,"sanity check 1");
@@ -347,8 +347,8 @@ export class UAConditionImpl extends UABaseEventImpl implements UAConditionEx {
347
347
  * @param requestedEnabledState {Boolean}
348
348
  * @private
349
349
  */
350
- public setEnabledState(requestedEnabledState: boolean): StatusCode {
351
- return this._setEnabledState(requestedEnabledState);
350
+ public setEnabledState(requestedEnabledState: boolean, options?:ISetStateOptions): StatusCode {
351
+ return this._setEnabledState(requestedEnabledState, options);
352
352
  }
353
353
 
354
354
  /**
@@ -426,7 +426,6 @@ export class UAConditionImpl extends UABaseEventImpl implements UAConditionEx {
426
426
  branch.renewEventId();
427
427
  }
428
428
 
429
- // xx console.log("MMMMMMMM%%%%%%%%%%%%%%%%%%%%% branch " +
430
429
  // branch.getBranchId().toString() + " eventId = " + branch.getEventId().toString("hex"));
431
430
 
432
431
  assert(branch instanceof ConditionSnapshotImpl);
@@ -462,7 +461,6 @@ export class UAConditionImpl extends UABaseEventImpl implements UAConditionEx {
462
461
  "therefore event cannot bubble-up to the server object"
463
462
  );
464
463
  }
465
- // xx console.log("MMMMMMMM%%%%%%%%%%%%%%%%%%%%% branch " +
466
464
  // branch.getBranchId().toString() + " eventId = " + branch.getEventId().toString("hex"));
467
465
  }
468
466
 
@@ -494,11 +492,13 @@ export class UAConditionImpl extends UABaseEventImpl implements UAConditionEx {
494
492
 
495
493
  const branch = this.currentBranch();
496
494
 
497
- const now = new Date();
495
+ const currentDefaultDate = new Date();
496
+ const time = conditionInfo.time || currentDefaultDate;
497
+ const receiveTime = conditionInfo.receiveTime || currentDefaultDate;
498
498
  // install the eventTimestamp
499
499
  // set the received Time
500
- branch.setTime(now);
501
- branch.setReceiveTime(now);
500
+ branch.setTime(time);
501
+ branch.setReceiveTime(receiveTime);
502
502
 
503
503
  // note : in 1.04 LocalTime property is optional
504
504
  if (Object.prototype.hasOwnProperty.call(this, "localTime")) {
@@ -536,7 +536,6 @@ export class UAConditionImpl extends UABaseEventImpl implements UAConditionEx {
536
536
  this.raiseConditionEvent(branch, true);
537
537
 
538
538
  if (!sameNodeId(branch.getBranchId(), NodeId.nullNodeId) && !branch.getRetain()) {
539
- // xx console.log(" Deleting not longer needed branch ", branch.getBranchId().toString());
540
539
  // branch can be deleted
541
540
  this.deleteBranch(branch);
542
541
  }
@@ -854,8 +853,7 @@ function UACondition_instantiate(
854
853
  if (options.conditionSource) {
855
854
  options.conditionSource = addressSpace._coerceNode(options.conditionSource)!;
856
855
  if (options.conditionSource.nodeClass !== NodeClass.Object && options.conditionSource.nodeClass !== NodeClass.Variable) {
857
- // tslint:disable:no-console
858
- console.log(options.conditionSource);
856
+ debugLog(options.conditionSource);
859
857
  throw new Error("Expecting condition source to be NodeClass.Object or Variable");
860
858
  }
861
859
 
@@ -1013,7 +1011,7 @@ function _disable_method(inputArguments: VariantLike[], context: ISessionContext
1013
1011
 
1014
1012
  // istanbul ignore next
1015
1013
  if (!(conditionNode instanceof UAConditionImpl)) {
1016
- console.log("conditionNode is not a UACondition ", conditionNode?.toString());
1014
+ debugLog("conditionNode is not a UACondition ", conditionNode?.toString());
1017
1015
  return callback(null, {
1018
1016
  statusCode: StatusCodes.BadNodeIdInvalid
1019
1017
  });
@@ -1048,6 +1046,7 @@ function _condition_refresh_method(
1048
1046
  // arguments : IntegerId SubscriptionId
1049
1047
  assert(inputArguments.length === 1);
1050
1048
  const addressSpace = context.object!.addressSpace as AddressSpacePrivate;
1049
+ // istanbul ignore next
1051
1050
  if (doDebug) {
1052
1051
  debugLog(chalk.red(" ConditionType.ConditionRefresh ! subscriptionId ="), inputArguments[0].toString());
1053
1052
  }
@@ -38,7 +38,7 @@ import {
38
38
  AccessRestrictionsFlag
39
39
  } from "node-opcua-data-model";
40
40
  import { DataValue } from "node-opcua-data-value";
41
- import { dumpIf, make_warningLog, make_errorLog } from "node-opcua-debug";
41
+ import { dumpIf, make_debugLog, make_warningLog, make_errorLog } from "node-opcua-debug";
42
42
  import { coerceNodeId, makeNodeId, NodeId, NodeIdLike, resolveNodeId, sameNodeId } from "node-opcua-nodeid";
43
43
  import { NumericRange } from "node-opcua-numeric-range";
44
44
  import { ReferenceDescription } from "node-opcua-service-browse";
@@ -85,6 +85,8 @@ import { coerceRolePermissions } from "./role_permissions";
85
85
  const doDebug = false;
86
86
  const warningLog = make_warningLog(__filename);
87
87
  const errorLog = make_errorLog(__filename);
88
+ const debugLog = make_debugLog(__filename);
89
+
88
90
 
89
91
  function defaultBrowseFilterFunc(context?: ISessionContext): boolean {
90
92
  return true;
@@ -867,7 +869,7 @@ export class BaseNodeImpl extends EventEmitter implements BaseNode {
867
869
 
868
870
  /* istanbul ignore next */
869
871
  if (do_debug) {
870
- console.log("all references :", this.nodeId.toString(), this.browseName.toString());
872
+ debugLog("all references :", this.nodeId.toString(), this.browseName.toString());
871
873
  dumpReferences(addressSpace, (Object as any).values(_private._referenceIdx));
872
874
  }
873
875
 
@@ -940,7 +942,7 @@ export class BaseNodeImpl extends EventEmitter implements BaseNode {
940
942
 
941
943
  // istanbul ignore next
942
944
  if (!addressSpace) {
943
- console.log(" Where is addressSpace ?");
945
+ debugLog("Where is addressSpace ?");
944
946
  }
945
947
  const reference = addressSpace.normalizeReferenceTypes([referenceOpts!])![0];
946
948
  const h = (<ReferenceImpl>reference).hash;
@@ -1021,7 +1023,7 @@ export class BaseNodeImpl extends EventEmitter implements BaseNode {
1021
1023
  // istanbul ignore next
1022
1024
  if (doDebug) {
1023
1025
  // tslint:disable-next-line:no-console
1024
- console.log(chalk.bgWhite.red("Ignoring reserved keyword " + name));
1026
+ debugLog(chalk.bgWhite.red("Ignoring reserved keyword " + name));
1025
1027
  }
1026
1028
  return;
1027
1029
  }
@@ -1508,9 +1510,8 @@ function _asObject<T extends BaseNode>(references: UAReference[], addressSpace:
1508
1510
  function toObject(reference: UAReference): T {
1509
1511
  const obj = resolveReferenceNode(addressSpace, reference);
1510
1512
  // istanbul ignore next
1511
- if (false && !obj) {
1512
- // tslint:disable-next-line:no-console
1513
- console.log(
1513
+ if (doDebug&& !obj) {
1514
+ debugLog(
1514
1515
  chalk.red(" Warning : object with nodeId ") +
1515
1516
  chalk.cyan(reference.nodeId.toString()) +
1516
1517
  chalk.red(" cannot be found in the address space !")
@@ -1584,16 +1585,7 @@ function _propagate_ref(this: BaseNode, addressSpace: MinimalistAddressSpace, re
1584
1585
  displayWarningReferencePointingToItSelf = false;
1585
1586
  }
1586
1587
  }
1587
- // xx ignore this assert(reference.nodeId.toString() !== this.nodeId.toString());
1588
- // function w(s,l) { return (s+" ").substring(0,l);}
1589
- // if (reference.isForward) {
1590
- // console.log(" CHILD => ",w(related_node.browseName + " " + related_node.nodeId.toString(),30),
1591
- // " PARENT ",w(this.browseName + " " + this.nodeId.toString(),30) , reference.toString());
1592
- // } else {
1593
- // console.log(" CHILD => ",w(this.browseName + " " + this.nodeId.toString(),30),
1594
- // " PARENT ",w(related_node.browseName + " " + related_node.nodeId.toString(),30) , reference.toString());
1595
- //
1596
- // }
1588
+
1597
1589
  (related_node as BaseNodeImpl)._add_backward_reference(
1598
1590
  new ReferenceImpl({
1599
1591
  _referenceType: getReferenceType(reference),
@@ -1630,7 +1622,7 @@ function normalize_referenceTypeId(addressSpace: IAddressSpace, referenceTypeId?
1630
1622
  try {
1631
1623
  nodeId = addressSpace.resolveNodeId(referenceTypeId);
1632
1624
  } catch (err) {
1633
- console.log("cannot normalize_referenceTypeId", referenceTypeId);
1625
+ errorLog("cannot normalize_referenceTypeId", referenceTypeId);
1634
1626
  throw err;
1635
1627
  }
1636
1628
  assert(nodeId);
@@ -1790,14 +1782,14 @@ function install_components_as_object_properties(parentObj: BaseNode) {
1790
1782
  if (Object.prototype.hasOwnProperty.call(reservedNames, name)) {
1791
1783
  // ignore reserved names
1792
1784
  if (doDebug) {
1793
- console.log(chalk.bgWhite.red("Ignoring reserved keyword " + name));
1785
+ debugLog(chalk.bgWhite.red("Ignoring reserved keyword " + name));
1794
1786
  }
1795
1787
  continue;
1796
1788
  }
1797
1789
 
1798
1790
  // ignore reserved names
1799
1791
  if (doDebug) {
1800
- console.log("Installing property " + name, " on ", parentObj.browseName.toString());
1792
+ debugLog("Installing property " + name, " on ", parentObj.browseName.toString());
1801
1793
  }
1802
1794
 
1803
1795
  /* istanbul ignore next */
@@ -11,6 +11,8 @@ import { BindVariableOptions, INamespace, UAVariable, UAProperty } from "node-op
11
11
  import { UAMultiStateDiscrete, UAMultiStateDiscrete_Base } from "node-opcua-nodeset-ua";
12
12
  import { registerNodePromoter } from "../../source/loader/register_node_promoter";
13
13
  import { UAVariableImpl } from "../ua_variable_impl";
14
+ import { ISetStateOptions } from "../../source/interfaces/i_set_state_options";
15
+
14
16
  import { AddMultiStateDiscreteOptions } from "../../source/address_space_ts";
15
17
  import { add_dataItem_stuff } from "./add_dataItem_stuff";
16
18
 
@@ -21,7 +23,7 @@ export interface UAMultiStateDiscreteEx<T, DT extends DataType> extends UAMultiS
21
23
  getValue(): number;
22
24
  getValueAsString(): string;
23
25
  getIndex(value: string): number;
24
- setValue(value: string | number): void;
26
+ setValue(value: string | number, options?: ISetStateOptions): void;
25
27
  checkVariantCompatibility(value: Variant): StatusCode;
26
28
  }
27
29
 
@@ -50,13 +52,13 @@ export class UAMultiStateDiscreteImpl<T, DT extends DataType> extends UAVariable
50
52
  return index;
51
53
  }
52
54
 
53
- public setValue(value: string | number): void {
55
+ public setValue(value: string | number, options?: ISetStateOptions): void {
54
56
  if (typeof value === "string") {
55
57
  const index = this.getIndex(value);
56
58
  if (index < 0) {
57
59
  throw new Error("UAMultiStateDiscrete#setValue invalid multi state value provided : " + value);
58
60
  }
59
- return this.setValue(index);
61
+ return this.setValue(index, options);
60
62
  }
61
63
  const arrayEnumStrings = this.enumStrings.readValue().value.value;
62
64
  if (value >= arrayEnumStrings.length) {
@@ -17,6 +17,7 @@ import { registerNodePromoter } from "../../source/loader/register_node_promoter
17
17
  import { coerceEnumValues } from "../../source/helpers/coerce_enum_value";
18
18
  import { UAMultiStateValueDiscreteEx } from "../../source/interfaces/data_access/ua_multistate_value_discrete_ex";
19
19
  import { AddMultiStateValueDiscreteOptions } from "../../source/address_space_ts";
20
+ import { ISetStateOptions } from "../../source/interfaces/i_set_state_options";
20
21
  import { UAVariableImpl } from "../ua_variable_impl";
21
22
 
22
23
  import { add_dataItem_stuff } from "./add_dataItem_stuff";
@@ -50,7 +51,7 @@ export class UAMultiStateValueDiscreteImpl<T, DT extends DataType>
50
51
  extends UAVariableImpl
51
52
  implements UAMultiStateValueDiscreteEx<T, DT>
52
53
  {
53
- public setValue(value: string | number | Int64): void {
54
+ public setValue(value: string | number | Int64, options?: ISetStateOptions): void {
54
55
  if (typeof value === "string") {
55
56
  const enumValues = this.enumValues.readValue().value.value;
56
57
  const selected = enumValues.filter((a: any) => a.displayName.text === value)[0];
@@ -60,7 +61,7 @@ export class UAMultiStateValueDiscreteImpl<T, DT extends DataType>
60
61
  throw new Error("cannot find enum string " + value + " in " + enumValues.toString());
61
62
  }
62
63
  } else {
63
- this._setValue(coerceUInt64(value));
64
+ this._setValue(coerceUInt64(value), options);
64
65
  }
65
66
  }
66
67
 
@@ -116,7 +117,7 @@ export class UAMultiStateValueDiscreteImpl<T, DT extends DataType>
116
117
  *
117
118
  * @private
118
119
  */
119
- public _setValue(value: Int64): void {
120
+ public _setValue(value: Int64, options?: ISetStateOptions): void {
120
121
  // check that value is in bound
121
122
  if (!this._isValueInRange(coerceInt32(value))) {
122
123
  throw new Error("UAMultiStateValueDiscrete#_setValue out of range " + value);
@@ -301,4 +302,4 @@ export function validateDataType(dataTypeValue: any): void {
301
302
  if (typeof dataTypeValue !== "number" || validTypes.indexOf(dataTypeValue) < 0) {
302
303
  throw new Error(`Invalid DataType in UAMultiStateValueDiscrete => ${dataTypeValue.toString()}`);
303
304
  }
304
- }
305
+ }
@@ -10,9 +10,11 @@ import { UAVariableImpl } from "../ua_variable_impl";
10
10
  import { registerNodePromoter } from "../../source/loader/register_node_promoter";
11
11
  import { AddTwoStateDiscreteOptions } from "../../source/address_space_ts";
12
12
  import { UATwoStateDiscreteEx } from "../../source/interfaces/data_access/ua_two_state_discrete_ex";
13
+ import { ISetStateOptions } from "../../source/interfaces/i_set_state_options";
13
14
 
14
15
  import { add_dataItem_stuff } from "./add_dataItem_stuff";
15
16
 
17
+
16
18
  export interface UATwoStateDiscreteImpl {
17
19
  falseState: UAProperty<LocalizedText, /*c*/ DataType.LocalizedText>;
18
20
  trueState: UAProperty<LocalizedText, /*c*/ DataType.LocalizedText>;
@@ -58,15 +60,15 @@ export class UATwoStateDiscreteImpl extends UAVariableImpl implements UATwoState
58
60
  );
59
61
  }
60
62
  }
61
- setValue(value: boolean | LocalizedTextLike): void {
63
+ setValue(value: boolean | LocalizedTextLike, options?: ISetStateOptions): void {
62
64
  if (typeof value === "boolean") {
63
65
  this.setValueFromSource({ dataType: DataType.Boolean, value });
64
66
  } else {
65
67
  const text: string = (typeof value === "string" ? value : value.text) || "";
66
68
  if (text === this.getTrueStateAsString()) {
67
- this.setValue(true);
69
+ this.setValue(true, options);
68
70
  } else if (text === this.getFalseStateAsString()) {
69
- this.setValue(false);
71
+ this.setValue(false, options);
70
72
  } else {
71
73
  throw new Error("setValue invalid value " + value);
72
74
  }
@@ -1709,7 +1709,7 @@ export class NamespaceImpl implements NamespacePrivate {
1709
1709
  break;
1710
1710
  default:
1711
1711
  // tslint:disable-next-line:no-console
1712
- console.log("Invalid class Name", node.nodeClass);
1712
+ errorLog("Invalid class Name", node.nodeClass);
1713
1713
  throw new Error("Invalid class name specified");
1714
1714
  }
1715
1715
  }
@@ -1733,13 +1733,13 @@ export class NamespaceImpl implements NamespacePrivate {
1733
1733
  if (match) {
1734
1734
  const correctedName = match[1];
1735
1735
  // the application is using an old scheme
1736
- console.log(
1736
+ warningLog(
1737
1737
  chalk.green(
1738
1738
  "Warning : since node-opcua 0.4.2 " + "namespace index should not be prepended to the browse name anymore"
1739
1739
  )
1740
1740
  );
1741
- console.log(" ", options.browseName, " will be replaced with ", correctedName);
1742
- console.log(" Please update your code");
1741
+ warningLog(" ", options.browseName, " will be replaced with ", correctedName);
1742
+ warningLog(" Please update your code");
1743
1743
 
1744
1744
  const indexVerify = parseInt(match[0], 10);
1745
1745
  if (indexVerify !== this.index) {
@@ -1819,7 +1819,7 @@ export class NamespaceImpl implements NamespacePrivate {
1819
1819
  break;
1820
1820
  default:
1821
1821
  // tslint:disable:no-console
1822
- console.log("Invalid class Name", node.nodeClass);
1822
+ warningLog("Invalid class Name", node.nodeClass);
1823
1823
  throw new Error("Invalid class name specified");
1824
1824
  }
1825
1825
  const deleted = this._nodeid_index.delete(hashKey);
@@ -2234,7 +2234,6 @@ function _create_node_version_if_needed(node: BaseNode, options: { nodeVersion:
2234
2234
  propertyOf: node
2235
2235
  });
2236
2236
  const initialValue = typeof options.nodeVersion === "string" ? options.nodeVersion : "0";
2237
- // xx console.log(" init value =",initialValue);
2238
2237
  nodeVersion.setValueFromSource({ dataType: "String", value: initialValue });
2239
2238
  }
2240
2239
  }
@@ -1,11 +1,12 @@
1
1
  import { INamespace, UADataType, UAVariable, UAVariableType } from "node-opcua-address-space-base";
2
2
  import { NodeClass } from "node-opcua-data-model";
3
3
  import { StructureField } from "node-opcua-types";
4
- import { make_warningLog } from "node-opcua-debug";
4
+ import { make_debugLog, make_warningLog } from "node-opcua-debug";
5
5
  import { NamespacePrivate } from "../namespace_private";
6
6
  import { BaseNodeImpl, getReferenceType } from "../base_node_impl";
7
7
 
8
8
  const warningLog = make_warningLog(__filename);
9
+ const debugLog = make_debugLog(__filename);
9
10
 
10
11
  function _constructNamespaceDependency(
11
12
  namespace: INamespace,
@@ -71,7 +72,7 @@ function _constructNamespaceDependency(
71
72
  } else {
72
73
  // istanbul ignore next
73
74
  if (dataTypeNodeId.value != 0) {
74
- console.log("Internal error: Cannot find dataType", dataTypeNodeId.toString());
75
+ warningLog("Warning: Cannot find dataType", dataTypeNodeId.toString());
75
76
  }
76
77
  }
77
78
  }
@@ -151,12 +152,16 @@ export function constructNamespaceDependency(namespace: INamespace, priorityTabl
151
152
 
152
153
  _constructNamespaceDependency(namespace, dependency, depMap, _visitedDataType, priorityTable);
153
154
 
154
- doDebug && console.log("namespace : ", namespace.index, namespace.namespaceUri);
155
- doDebug && console.log(" ", dependency.map((d)=>d.index + " " + d.namespaceUri).join("\n "));
155
+ // istanbul ignore next
156
+ doDebug && debugLog("namespace : ", namespace.index, namespace.namespaceUri);
157
+ // istanbul ignore next
158
+ doDebug && debugLog(" ", dependency.map((d) => d.index + " " + d.namespaceUri).join("\n "));
156
159
 
157
- const sorted = dependency.sort((a, b) => priorityTable![a.index] < priorityTable![b.index] ? -1 : 1);
158
- doDebug && console.log("sorted:")
159
- doDebug && console.log(" ", sorted.map((d)=>d.index + " " + d.namespaceUri).join("\n "));
160
+ const sorted = dependency.sort((a, b) => (priorityTable![a.index] < priorityTable![b.index] ? -1 : 1));
161
+ // istanbul ignore next
162
+ doDebug && debugLog("sorted:");
163
+ // istanbul ignore next
164
+ doDebug && debugLog(" ", sorted.map((d) => d.index + " " + d.namespaceUri).join("\n "));
160
165
 
161
166
  return sorted;
162
167
  }
@@ -48,6 +48,7 @@ import { UAMethodImpl } from "../ua_method_impl";
48
48
  import { UADataTypeImpl } from "../ua_data_type_impl";
49
49
  import { UAVariableTypeImpl } from "../ua_variable_type_impl";
50
50
  import { SessionContext } from "../index_current";
51
+ import { UAViewImpl } from "../ua_view_impl";
51
52
 
52
53
  import { DefinitionMap2, TypeInfo } from "../../source/loader/make_xml_extension_object_parser";
53
54
  import { makeDefinitionMap } from "../../source/loader/decode_xml_extension_object";
@@ -56,7 +57,6 @@ import {
56
57
  constructNamespacePriorityTable,
57
58
  hasHigherPriorityThan
58
59
  } from "./construct_namespace_dependency";
59
- import { UAViewImpl } from "../ua_view_impl";
60
60
 
61
61
  // tslint:disable:no-var-requires
62
62
  const XMLWriter = require("xml-writer");
@@ -141,7 +141,6 @@ function _dumpReferences(xw: XmlWriter, node: BaseNode) {
141
141
  if (reference.nodeId.namespace !== node.nodeId.namespace) {
142
142
  // todo: may be check that reference.nodeId.namespace is one of the namespace
143
143
  // on which our namespace is build and not a derived one !
144
- // xx console.log("xxxxxxxxxxxxxx Keeping => ", referenceType.toString(), reference.node?.nodeId.toString());
145
144
  return true;
146
145
  }
147
146
  }
@@ -374,8 +373,8 @@ function _dumpVariantInnerExtensionObject(
374
373
  if (types.isNativeError(err)) {
375
374
  errorLog("Error in _dumpVariantExtensionObjectValue_Body !!!", err.message);
376
375
  }
377
- console.log(name);
378
- console.log(field);
376
+ debugLog(name);
377
+ debugLog(field);
379
378
  // throw err;
380
379
  }
381
380
  restoreDefaultNamespace(xw);
@@ -616,7 +615,7 @@ function _dumpValue(xw: XmlWriter, node: UAVariable | UAVariableType, value: Var
616
615
 
617
616
  const dataTypeNode = addressSpace.findDataType(node.dataType);
618
617
  if (!dataTypeNode) {
619
- console.log("Cannot find dataType:", node.dataType);
618
+ debugLog("Cannot find dataType:", node.dataType);
620
619
  return;
621
620
  }
622
621
  const dataTypeName = dataTypeNode.browseName.name!.toString();
@@ -764,7 +763,7 @@ function dumpReferencedNodes(xw: XmlWriter, node: BaseNode, forward: boolean) {
764
763
  assert(nodeChild instanceof BaseNodeImpl);
765
764
  if (nodeChild.nodeId.namespace === node.nodeId.namespace) {
766
765
  if (!xw.visitedNode[_hash(nodeChild)]) {
767
- console.log(
766
+ debugLog(
768
767
  node.nodeId.toString(),
769
768
  " dumping child ",
770
769
  nodeChild.browseName.toString(),
@@ -1053,7 +1052,7 @@ function dumpUAVariableType(xw: XmlWriter, node: UAVariableType) {
1053
1052
  const dataTypeNode = addressSpace.findNode(node.dataType);
1054
1053
  if (!dataTypeNode) {
1055
1054
  // throw new Error(" cannot find datatype " + node.dataType);
1056
- console.log(
1055
+ debugLog(
1057
1056
  " cannot find datatype " +
1058
1057
  node.dataType +
1059
1058
  " for node " +
@@ -1418,8 +1417,8 @@ NamespaceImpl.prototype.toNodeset2XML = function (this: NamespaceImpl) {
1418
1417
  // let's sort the dependencies in the same order as the translation table
1419
1418
  const sortedDependencies = dependency.sort((a, b) => translationTable[a.index] > translationTable[b.index] ? 1 : -1);
1420
1419
 
1421
- doDebug && console.log(sortedDependencies.map((a) => a.index + " + " + a.namespaceUri).join("\n"));
1422
- doDebug && console.log("translation table ", translationTable);
1420
+ doDebug && debugLog(sortedDependencies.map((a) => a.index + " + " + a.namespaceUri).join("\n"));
1421
+ doDebug && debugLog("translation table ", translationTable);
1423
1422
 
1424
1423
  for (const depend of sortedDependencies) {
1425
1424
  if (depend.index === 0) {
@@ -78,7 +78,7 @@ export function resolveReferenceType(addressSpace: MinimalistAddressSpace, refer
78
78
  const _reference = reference as ReferenceImpl;
79
79
  if (!_reference._referenceType) {
80
80
  if (!_reference.referenceType) {
81
- console.log(chalk.red("ERROR MISSING reference"), reference);
81
+ errorLog(chalk.red("ERROR MISSING reference"), reference);
82
82
  }
83
83
  _reference._referenceType = addressSpace.findReferenceType(reference.referenceType)!;
84
84
  }
@@ -169,3 +169,7 @@ export class ReferenceImpl implements UAReference {
169
169
  */
170
170
  }
171
171
  }
172
+ function errorLog(arg0: string, reference: UAReference) {
173
+ throw new Error("Function not implemented.");
174
+ }
175
+
@@ -14,7 +14,7 @@ import {
14
14
  QualifiedName
15
15
  } from "node-opcua-data-model";
16
16
  import { AttributeIds } from "node-opcua-data-model";
17
- import { make_warningLog } from "node-opcua-debug";
17
+ import { make_debugLog, make_warningLog } from "node-opcua-debug";
18
18
  import { NodeId, sameNodeId } from "node-opcua-nodeid";
19
19
  import { StatusCodes } from "node-opcua-status-code";
20
20
  import { DataType, Variant, VariantArrayType } from "node-opcua-variant";
@@ -35,6 +35,7 @@ import { UAObjectTypeImpl } from "../ua_object_type_impl";
35
35
  const warningLog = make_warningLog(__filename);
36
36
 
37
37
  const doDebug = false;
38
+ const debugLog = make_debugLog(__filename);
38
39
 
39
40
  export declare interface UATransitionImpl extends UATransition, UATransitionEx {}
40
41
  export class UATransitionImpl implements UATransition, UATransitionEx {}
@@ -217,8 +218,7 @@ export class UAStateMachineImpl extends UAObjectImpl implements UAStateMachineEx
217
218
  if (!transition) {
218
219
  // istanbul ignore next
219
220
  if (doDebug) {
220
- // tslint:disable-next-line: no-console
221
- console.log(" No transition from ", this.currentStateNode.browseName.toString(), " to ", toStateNode.toString());
221
+ debugLog(" No transition from ", this.currentStateNode.browseName.toString(), " to ", toStateNode.toString());
222
222
  }
223
223
  return false;
224
224
  }
@@ -522,7 +522,6 @@ export class UAStateMachineImpl extends UAObjectImpl implements UAStateMachineEx
522
522
  }
523
523
  };
524
524
  applyLastTransitionOptionalProps();
525
- // xx console.log("transitionNode ",transitionNode.toString());
526
525
  // The inherited Property SourceNode shall be filled with the NodeId of the StateMachine instance where the
527
526
  // Transition occurs. If the Transition occurs in a SubStateMachine, then the NodeId of the SubStateMachine
528
527
  // has to be used. If the Transition occurs between a StateMachine and a SubStateMachine, then the NodeId of
@@ -125,7 +125,6 @@ function _unshelve_method(inputArguments: VariantLike[], context: ISessionContex
125
125
  export function _clear_timer_if_any(shelvingState: UAShelvedStateMachineExImpl): void {
126
126
  if (shelvingState._timer) {
127
127
  clearTimeout(shelvingState._timer);
128
- // xx console.log("_clear_timer_if_any shelvingState = ",shelvingState._timer,shelvingState.constructor.name);
129
128
  shelvingState._timer = null;
130
129
  }
131
130
  }
@@ -134,6 +133,7 @@ function _automatically_unshelve(shelvingState: UAShelvedStateMachineExImpl) {
134
133
  assert(shelvingState._timer, "expecting timerId to be set");
135
134
  shelvingState._timer = null;
136
135
 
136
+ // istanbul ignore next
137
137
  if (doDebug) {
138
138
  debugLog("Automatically unshelving variable ", shelvingState.browseName.toString());
139
139
  }
@@ -157,6 +157,7 @@ function _start_timer_for_automatic_unshelve(shelvingState: UAShelvedStateMachin
157
157
  shelvingState._sheveldTime = new Date(); // now
158
158
  shelvingState._duration = duration;
159
159
 
160
+ // istanbul ignore next
160
161
  if (doDebug) {
161
162
  debugLog("shelvingState._duration", shelvingState._duration);
162
163
  }
@@ -217,8 +218,6 @@ function _timedShelve_method(
217
218
  assert(inputArguments[0].dataType === DataType.Double); // Duration
218
219
  assert(inputArguments[0] instanceof Variant);
219
220
 
220
- // xx console.log("inputArguments",inputArguments[0].toString());
221
-
222
221
  const proposedDuration = inputArguments[0].value; // as double (milliseconds)
223
222
  if (proposedDuration > maxTimeShelved) {
224
223
  return callback(null, {