node-opcua-address-space 2.70.3 → 2.72.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 (72) hide show
  1. package/dist/source/loader/load_nodeset2.js +18 -14
  2. package/dist/source/loader/load_nodeset2.js.map +1 -1
  3. package/dist/source/loader/make_semver_compatible.d.ts +6 -0
  4. package/dist/source/loader/make_semver_compatible.js +26 -0
  5. package/dist/source/loader/make_semver_compatible.js.map +1 -0
  6. package/dist/source/loader/make_xml_extension_object_parser.js +12 -2
  7. package/dist/source/loader/make_xml_extension_object_parser.js.map +1 -1
  8. package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.d.ts +3 -1
  9. package/dist/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.js.map +1 -1
  10. package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.d.ts +12 -6
  11. package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js +2 -2
  12. package/dist/src/alarms_and_conditions/ua_alarm_condition_impl.js.map +1 -1
  13. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.d.ts +18 -3
  14. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js +95 -5
  15. package/dist/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.js.map +1 -1
  16. package/dist/src/alarms_and_conditions/ua_condition_impl.d.ts +7 -2
  17. package/dist/src/alarms_and_conditions/ua_condition_impl.js +6 -4
  18. package/dist/src/alarms_and_conditions/ua_condition_impl.js.map +1 -1
  19. package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.d.ts +4 -3
  20. package/dist/src/alarms_and_conditions/ua_discrete_alarm_impl.js.map +1 -1
  21. package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm_impl.d.ts +6 -3
  22. package/dist/src/alarms_and_conditions/ua_exclusive_deviation_alarm_impl.js.map +1 -1
  23. package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm_impl.d.ts +3 -1
  24. package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm_impl.js +2 -2
  25. package/dist/src/alarms_and_conditions/ua_exclusive_level_alarm_impl.js.map +1 -1
  26. package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.d.ts +5 -3
  27. package/dist/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.js.map +1 -1
  28. package/dist/src/alarms_and_conditions/ua_limit_alarm_impl.d.ts +12 -4
  29. package/dist/src/alarms_and_conditions/ua_limit_alarm_impl.js +3 -3
  30. package/dist/src/alarms_and_conditions/ua_limit_alarm_impl.js.map +1 -1
  31. package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl.d.ts +4 -3
  32. package/dist/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl.js.map +1 -1
  33. package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.d.ts +4 -3
  34. package/dist/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.js.map +1 -1
  35. package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.d.ts +17 -8
  36. package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.js +45 -19
  37. package/dist/src/alarms_and_conditions/ua_off_normal_alarm_impl.js.map +1 -1
  38. package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm_impl.d.ts +4 -3
  39. package/dist/src/alarms_and_conditions/ua_system_off_normal_alarm_impl.js.map +1 -1
  40. package/dist/src/ua_object_impl.d.ts +4 -2
  41. package/dist/src/ua_object_impl.js +7 -1
  42. package/dist/src/ua_object_impl.js.map +1 -1
  43. package/dist/src/ua_variable_type_impl.js +8 -2
  44. package/dist/src/ua_variable_type_impl.js.map +1 -1
  45. package/dist/src/ua_view_impl.d.ts +6 -2
  46. package/dist/src/ua_view_impl.js +8 -1
  47. package/dist/src/ua_view_impl.js.map +1 -1
  48. package/package.json +38 -38
  49. package/source/loader/load_nodeset2.ts +21 -17
  50. package/source/loader/make_semver_compatible.ts +23 -0
  51. package/source/loader/make_xml_extension_object_parser.ts +16 -6
  52. package/src/alarms_and_conditions/ua_acknowledgeable_condition_impl.ts +13 -6
  53. package/src/alarms_and_conditions/ua_alarm_condition_impl.ts +15 -10
  54. package/src/alarms_and_conditions/ua_certificate_expiration_alarm_impl.ts +126 -10
  55. package/src/alarms_and_conditions/ua_condition_impl.ts +26 -13
  56. package/src/alarms_and_conditions/ua_discrete_alarm_impl.ts +10 -4
  57. package/src/alarms_and_conditions/ua_exclusive_deviation_alarm_impl.ts +7 -6
  58. package/src/alarms_and_conditions/ua_exclusive_level_alarm_impl.ts +5 -3
  59. package/src/alarms_and_conditions/ua_exclusive_limit_alarm_impl.ts +7 -6
  60. package/src/alarms_and_conditions/ua_exclusive_rate_of_change_alarm_impl.ts +1 -1
  61. package/src/alarms_and_conditions/ua_limit_alarm_impl.ts +23 -13
  62. package/src/alarms_and_conditions/ua_non_exclusive_deviation_alarm_impl.ts +6 -7
  63. package/src/alarms_and_conditions/ua_non_exclusive_limit_alarm_impl.ts +6 -7
  64. package/src/alarms_and_conditions/ua_off_normal_alarm_impl.ts +62 -30
  65. package/src/alarms_and_conditions/ua_system_off_normal_alarm_impl.ts +5 -5
  66. package/src/ua_object_impl.ts +11 -3
  67. package/src/ua_variable_type_impl.ts +11 -4
  68. package/src/ua_view_impl.ts +6 -4
  69. package/test_helpers/test_fixtures/dataType_issue.xml +9 -9
  70. package/test_helpers/test_fixtures/eurange_issue.xml +73 -0
  71. package/test_helpers/test_fixtures/nodeset_with_guid.xml +1442 -0
  72. package/test_helpers/test_fixtures/nodeset_with_int64_values.xml +31 -0
@@ -23,17 +23,25 @@ import { minDate } from "node-opcua-factory";
23
23
  import { coerceNodeId, makeNodeId, NodeId, resolveNodeId, sameNodeId } from "node-opcua-nodeid";
24
24
  import { CallbackT, StatusCode, StatusCodes } from "node-opcua-status-code";
25
25
  import { CallMethodResultOptions, TimeZoneDataType } from "node-opcua-types";
26
- import { DataType, Variant, VariantLike } from "node-opcua-variant";
27
- import { UAVariable, INamespace, ISessionContext, UAEventType, BaseNode, UAObject } from "node-opcua-address-space-base";
26
+ import { DataType, Variant, VariantLike, VariantOptions } from "node-opcua-variant";
27
+ import {
28
+ UAVariable,
29
+ INamespace,
30
+ ISessionContext,
31
+ UAEventType,
32
+ BaseNode,
33
+ UAObject,
34
+ InstantiateObjectOptions
35
+ } from "node-opcua-address-space-base";
28
36
  import { UACondition_Base, UAConditionVariable, UACondition } from "node-opcua-nodeset-ua";
29
37
 
30
38
  import { ConditionInfoOptions } from "../../source/interfaces/alarms_and_conditions/condition_info_i";
39
+ import { UATwoStateVariableEx } from "../../source/ua_two_state_variable_ex";
31
40
  import { AddressSpacePrivate } from "../address_space_private";
32
41
  import { _install_TwoStateVariable_machinery } from "../state_machine/ua_two_state_variable";
33
42
  import { UAObjectImpl } from "../ua_object_impl";
34
43
  import { UAVariableImpl } from "../ua_variable_impl";
35
44
  import { UAConditionType } from "../ua_condition_type";
36
- import { UATwoStateVariableEx } from "../../source/ua_two_state_variable_ex";
37
45
  import { UABaseEventHelper, UABaseEventImpl } from "./ua_base_event_impl";
38
46
  import { ConditionSnapshot } from "./condition_snapshot";
39
47
 
@@ -680,6 +688,11 @@ export class UAConditionImpl extends UABaseEventImpl implements UAConditionEx {
680
688
  }
681
689
  }
682
690
 
691
+ export interface InstantiateConditionOptions extends InstantiateObjectOptions {
692
+ conditionOf?: UAObject | BaseNode | NodeId | null;
693
+ conditionClass?: UAObject | BaseNode | NodeId | null;
694
+ conditionName?: string;
695
+ }
683
696
  /**
684
697
  * instantiate a Condition.
685
698
  * this will create the unique EventId and will set eventType
@@ -709,8 +722,8 @@ export class UAConditionImpl extends UABaseEventImpl implements UAConditionEx {
709
722
  function UACondition_instantiate(
710
723
  namespace: INamespace,
711
724
  conditionTypeId: UAEventType | NodeId | string,
712
- options: any,
713
- data: any
725
+ options: InstantiateConditionOptions,
726
+ data?: Record<string, VariantOptions>
714
727
  ): UAConditionEx {
715
728
  /* eslint max-statements: ["error", 100] */
716
729
  const addressSpace = namespace.addressSpace as AddressSpacePrivate;
@@ -766,7 +779,7 @@ function UACondition_instantiate(
766
779
  }
767
780
  if (options.conditionOf) {
768
781
  assert(Object.prototype.hasOwnProperty.call(options, "conditionOf")); // must provide a conditionOf
769
- options.conditionOf = addressSpace._coerceNode(options.conditionOf);
782
+ options.conditionOf = addressSpace._coerceNode(options.conditionOf)!;
770
783
 
771
784
  // HasCondition References can be used in the Type definition of an Object or a Variable.
772
785
  assert(options.conditionOf.nodeClass === NodeClass.Object || options.conditionOf.nodeClass === NodeClass.Variable);
@@ -826,11 +839,11 @@ function UACondition_instantiate(
826
839
  conditionNode.enabledState.setValue(true);
827
840
 
828
841
  // set properties to in initial values
829
- Object.keys(data).forEach((key: string) => {
842
+ Object.entries(data).forEach(([key, value]) => {
830
843
  const varNode = _getCompositeKey(conditionNode, key);
831
844
  assert(varNode.nodeClass === NodeClass.Variable);
832
845
 
833
- const variant = new Variant(data[key]);
846
+ const variant = new Variant(value);
834
847
 
835
848
  // check that Variant DataType is compatible with the UAVariable dataType
836
849
  // xx var nodeDataType = addressSpace.findNode(varNode.dataType).browseName;
@@ -839,10 +852,7 @@ function UACondition_instantiate(
839
852
  if (!varNode._validate_DataType(variant.dataType)) {
840
853
  throw new Error(" Invalid variant dataType " + variant + " " + varNode.browseName.toString());
841
854
  }
842
-
843
- const value = new Variant(data[key]);
844
-
845
- varNode.setValueFromSource(value);
855
+ varNode.setValueFromSource(variant);
846
856
  });
847
857
 
848
858
  // bind condition methods -
@@ -880,7 +890,7 @@ function UACondition_instantiate(
880
890
  // with the motor.
881
891
 
882
892
  if (options.conditionSource) {
883
- options.conditionSource = addressSpace._coerceNode(options.conditionSource);
893
+ options.conditionSource = addressSpace._coerceNode(options.conditionSource)!;
884
894
  if (options.conditionSource.nodeClass !== NodeClass.Object && options.conditionSource.nodeClass !== NodeClass.Variable) {
885
895
  // tslint:disable:no-console
886
896
  console.log(options.conditionSource);
@@ -960,6 +970,9 @@ function UACondition_instantiate(
960
970
  if (options.conditionClass) {
961
971
  if (typeof options.conditionClass === "string") {
962
972
  options.conditionClass = addressSpace.findObjectType(options.conditionClass);
973
+ if (!options.conditionClass) {
974
+ throw new Error("cannot find condition class " + options.conditionClass);
975
+ }
963
976
  }
964
977
  const conditionClassNode = addressSpace._coerceNode(options.conditionClass);
965
978
  if (!conditionClassNode) {
@@ -4,8 +4,14 @@
4
4
  import { assert } from "node-opcua-assert";
5
5
  import { NodeId } from "node-opcua-nodeid";
6
6
  import { UADiscreteAlarm, UADiscreteAlarm_Base } from "node-opcua-nodeset-ua";
7
- import { INamespace, UAEventType } from "../../source";
8
- import { UAAlarmConditionEx, UAAlarmConditionHelper, UAAlarmConditionImpl } from "./ua_alarm_condition_impl";
7
+ import { VariantOptions } from "node-opcua-variant";
8
+ import { INamespace, UAEventType } from "node-opcua-address-space-base";
9
+ import {
10
+ InstantiateAlarmConditionOptions,
11
+ UAAlarmConditionEx,
12
+ UAAlarmConditionHelper,
13
+ UAAlarmConditionImpl
14
+ } from "./ua_alarm_condition_impl";
9
15
 
10
16
  export interface UADiscreteAlarmHelper extends UAAlarmConditionHelper {
11
17
  on(eventName: string, eventHandle: any): this;
@@ -59,8 +65,8 @@ export class UADiscreteAlarmImpl extends UAAlarmConditionImpl implements UADiscr
59
65
  public static instantiate(
60
66
  namespace: INamespace,
61
67
  discreteAlarmTypeId: UAEventType | NodeId | string,
62
- options: any,
63
- data: any
68
+ options: InstantiateAlarmConditionOptions,
69
+ data?: Record<string, VariantOptions>
64
70
  ): UADiscreteAlarmImpl {
65
71
  const addressSpace = namespace.addressSpace;
66
72
 
@@ -4,10 +4,9 @@
4
4
  import { assert } from "node-opcua-assert";
5
5
  import { DataValue } from "node-opcua-data-value";
6
6
  import { NodeId } from "node-opcua-nodeid";
7
- import { DataType } from "node-opcua-variant";
7
+ import { DataType, VariantOptions } from "node-opcua-variant";
8
8
  import { UAExclusiveDeviationAlarm_Base } from "node-opcua-nodeset-ua";
9
-
10
- import { UAVariable, UAVariableT } from "../../source";
9
+ import { UAVariable, UAVariableT } from "node-opcua-address-space-base";
11
10
  import { AddressSpace } from "../address_space";
12
11
  import { NamespacePrivate } from "../namespace_private";
13
12
  import {
@@ -20,7 +19,7 @@ import {
20
19
  } from "./deviation_alarm_helper";
21
20
 
22
21
  import { UAExclusiveLimitAlarmEx, UAExclusiveLimitAlarmImpl } from "./ua_exclusive_limit_alarm_impl";
23
- import { UALimitAlarmImpl } from "./ua_limit_alarm_impl";
22
+ import { InstantiateLimitAlarmOptions, UALimitAlarmImpl } from "./ua_limit_alarm_impl";
24
23
 
25
24
  export interface UAExclusiveDeviationAlarmEx
26
25
  extends Omit<
@@ -43,12 +42,14 @@ export declare interface UAExclusiveDeviationAlarmImpl extends UAExclusiveDeviat
43
42
  on(eventName: string, eventHandler: any): this;
44
43
  get addressSpace(): AddressSpace;
45
44
  }
45
+
46
+ export interface InstantiateExclusiveLimitAlarmOptions extends InstantiateLimitAlarmOptions, InstallSetPointOptions {}
46
47
  export class UAExclusiveDeviationAlarmImpl extends UAExclusiveLimitAlarmImpl implements UAExclusiveDeviationAlarmEx {
47
48
  public static instantiate(
48
49
  namespace: NamespacePrivate,
49
50
  type: string | NodeId,
50
- options: any,
51
- data: any
51
+ options: InstantiateExclusiveLimitAlarmOptions,
52
+ data?: Record<string, VariantOptions>
52
53
  ): UAExclusiveDeviationAlarmImpl {
53
54
  const addressSpace = namespace.addressSpace;
54
55
 
@@ -2,17 +2,19 @@
2
2
  * @module node-opcua-address-space.AlarmsAndConditions
3
3
  */
4
4
  import { NodeId } from "node-opcua-nodeid";
5
+ import { VariantOptions } from "node-opcua-variant";
5
6
  import { NamespacePrivate } from "../namespace_private";
6
7
  import { UAExclusiveLimitAlarmImpl } from "./ua_exclusive_limit_alarm_impl";
8
+ import { InstantiateLimitAlarmOptions } from "./ua_limit_alarm_impl";
7
9
 
8
10
  export class UAExclusiveLevelAlarmImpl extends UAExclusiveLimitAlarmImpl {
9
11
  public static instantiate(
10
12
  namespace: NamespacePrivate,
11
13
  type: NodeId | string,
12
- option: any,
13
- data: any
14
+ options: InstantiateLimitAlarmOptions,
15
+ data?: Record<string, VariantOptions>
14
16
  ): UAExclusiveLevelAlarmImpl {
15
17
  const addressSpace = namespace.addressSpace;
16
- return UAExclusiveLimitAlarmImpl.instantiate(namespace, type, option, data) as UAExclusiveLevelAlarmImpl;
18
+ return UAExclusiveLimitAlarmImpl.instantiate(namespace, type, options, data) as UAExclusiveLevelAlarmImpl;
17
19
  }
18
20
  }
@@ -4,14 +4,15 @@
4
4
  import { assert } from "node-opcua-assert";
5
5
  import { NodeId } from "node-opcua-nodeid";
6
6
  import { UAObject } from "node-opcua-address-space-base";
7
- import { UAExclusiveLimitAlarm, UAExclusiveLimitAlarm_Base } from "node-opcua-nodeset-ua";
8
-
9
- import { UAEventType, UAExclusiveLimitStateMachineEx } from "../../source";
7
+ import { UAExclusiveLimitAlarm_Base } from "node-opcua-nodeset-ua";
8
+ import { VariantOptions } from "node-opcua-variant";
9
+ import { UAEventType } from "node-opcua-address-space-base";
10
10
  import { UATwoStateVariableEx } from "../../source/ua_two_state_variable_ex";
11
11
  import { NamespacePrivate } from "../namespace_private";
12
12
  import { promoteToStateMachine } from "../state_machine/finite_state_machine";
13
13
  import { UAShelvedStateMachineEx } from "../state_machine/ua_shelving_state_machine_ex";
14
- import { UALimitAlarmEx, UALimitAlarmHelper, UALimitAlarmImpl } from "./ua_limit_alarm_impl";
14
+ import { UAExclusiveLimitStateMachineEx } from "../../source/interfaces/state_machine/ua_exclusive_limit_state_machine_type_ex";
15
+ import { InstantiateLimitAlarmOptions, UALimitAlarmEx, UALimitAlarmHelper, UALimitAlarmImpl } from "./ua_limit_alarm_impl";
15
16
 
16
17
  const validState = ["HighHigh", "High", "Low", "LowLow", null];
17
18
 
@@ -49,8 +50,8 @@ export class UAExclusiveLimitAlarmImpl extends UALimitAlarmImpl implements UAExc
49
50
  public static instantiate(
50
51
  namespace: NamespacePrivate,
51
52
  type: UAEventType | string | NodeId,
52
- options: any,
53
- data: any
53
+ options: InstantiateLimitAlarmOptions,
54
+ data?: Record<string, VariantOptions>
54
55
  ): UAExclusiveLimitAlarmImpl {
55
56
  const addressSpace = namespace.addressSpace;
56
57
 
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @module node-opcua-address-space.AlarmsAndConditions
3
3
  */
4
- import { UAExclusiveRateOfChangeAlarm, UAExclusiveRateOfChangeAlarm_Base } from "node-opcua-nodeset-ua";
4
+ import { UAExclusiveRateOfChangeAlarm_Base } from "node-opcua-nodeset-ua";
5
5
  import { UAExclusiveLimitAlarmEx, UAExclusiveLimitAlarmImpl } from "./ua_exclusive_limit_alarm_impl";
6
6
 
7
7
  export interface UAExclusiveRateOfChangeAlarmEx
@@ -8,14 +8,18 @@ import { NodeClass } from "node-opcua-data-model";
8
8
  import { DataValue } from "node-opcua-data-value";
9
9
  import { make_warningLog } from "node-opcua-debug";
10
10
  import { NodeId } from "node-opcua-nodeid";
11
- import { UALimitAlarm_Base, UALimitAlarm } from "node-opcua-nodeset-ua";
11
+ import { UALimitAlarm_Base } from "node-opcua-nodeset-ua";
12
12
  import { StatusCodes } from "node-opcua-status-code";
13
- import { DataType } from "node-opcua-variant";
13
+ import { DataType, VariantOptions } from "node-opcua-variant";
14
14
  import { UATwoStateVariableEx } from "../../source/ua_two_state_variable_ex";
15
-
16
15
  import { NamespacePrivate } from "../namespace_private";
17
16
  import { UAShelvedStateMachineEx } from "../state_machine/ua_shelving_state_machine_ex";
18
- import { UAAlarmConditionEx, UAAlarmConditionHelper, UAAlarmConditionImpl } from "./ua_alarm_condition_impl";
17
+ import {
18
+ InstantiateAlarmConditionOptions,
19
+ UAAlarmConditionEx,
20
+ UAAlarmConditionHelper,
21
+ UAAlarmConditionImpl
22
+ } from "./ua_alarm_condition_impl";
19
23
 
20
24
  const warningLog = make_warningLog("AlarmsAndConditions");
21
25
  export interface UALimitAlarmHelper extends UAAlarmConditionHelper {
@@ -57,6 +61,14 @@ const uaLimitAlarmInputSupportedDataType: DataType[] = [
57
61
  DataType.UInt32
58
62
  ];
59
63
 
64
+ export interface InstantiateLimitAlarmOptions extends InstantiateAlarmConditionOptions {
65
+ highHighLimit: number;
66
+ highLimit: number;
67
+ lowLimit: number;
68
+ lowLowLimit: number;
69
+ inputNode: UAVariable;
70
+ }
71
+
60
72
  export class UALimitAlarmImpl extends UAAlarmConditionImpl implements UALimitAlarmEx {
61
73
  /**
62
74
  * @method (static)UALimitAlarm.instantiate
@@ -75,8 +87,8 @@ export class UALimitAlarmImpl extends UAAlarmConditionImpl implements UALimitAla
75
87
  public static instantiate(
76
88
  namespace: NamespacePrivate,
77
89
  limitAlarmTypeId: UAEventType | NodeId | string,
78
- options: any,
79
- data: any
90
+ options: InstantiateLimitAlarmOptions,
91
+ data?: Record<string, VariantOptions>
80
92
  ): UALimitAlarmImpl {
81
93
  const addressSpace = namespace.addressSpace;
82
94
 
@@ -139,13 +151,11 @@ export class UALimitAlarmImpl extends UAAlarmConditionImpl implements UALimitAla
139
151
  const dataType = addressSpace.findCorrespondingBasicDataType(options.inputNode.dataType);
140
152
 
141
153
  if (-1 === uaLimitAlarmInputSupportedDataType.indexOf(dataType)) {
142
- const message =(
143
- `UALimitAlarm.instantiate: inputNode must be of type ${uaLimitAlarmInputSupportedDataType
144
- .map((a) => DataType[a])
145
- .join("|")}, got ${DataType[dataType]}`
146
- );
154
+ const message = `UALimitAlarm.instantiate: inputNode must be of type ${uaLimitAlarmInputSupportedDataType
155
+ .map((a) => DataType[a])
156
+ .join("|")}, got ${DataType[dataType]}`;
147
157
  warningLog(message);
148
- throw(new Error(message));
158
+ throw new Error(message);
149
159
  }
150
160
 
151
161
  if (Object.prototype.hasOwnProperty.call(options, "highHighLimit")) {
@@ -265,7 +275,7 @@ export class UALimitAlarmImpl extends UAAlarmConditionImpl implements UALimitAla
265
275
  this.lowLowLimit.setValueFromSource({ dataType: DataType.Double, value });
266
276
  }
267
277
 
268
- public _onInputDataValueChange(dataValue: DataValue): void {
278
+ protected _onInputDataValueChange(dataValue: DataValue): void {
269
279
  assert(dataValue instanceof DataValue);
270
280
 
271
281
  if (
@@ -6,10 +6,9 @@ import { assert } from "node-opcua-assert";
6
6
 
7
7
  import { DataValue } from "node-opcua-data-value";
8
8
  import { NodeId } from "node-opcua-nodeid";
9
- import { DataType } from "node-opcua-variant";
10
- import { UANonExclusiveDeviationAlarm_Base, UANonExclusiveLimitAlarm_Base } from "node-opcua-nodeset-ua";
11
-
12
- import { UAVariable, UAVariableT } from "../../source";
9
+ import { DataType, VariantOptions } from "node-opcua-variant";
10
+ import { UANonExclusiveDeviationAlarm_Base } from "node-opcua-nodeset-ua";
11
+ import { UAVariable, UAVariableT } from "node-opcua-address-space-base";
13
12
  import { NamespacePrivate } from "../namespace_private";
14
13
  import { AddressSpace } from "../address_space";
15
14
  import {
@@ -19,7 +18,7 @@ import {
19
18
  DeviationAlarmHelper_onSetpointDataValueChange,
20
19
  DeviationStuff
21
20
  } from "./deviation_alarm_helper";
22
- import { UALimitAlarmImpl } from "./ua_limit_alarm_impl";
21
+ import { InstantiateLimitAlarmOptions, UALimitAlarmImpl } from "./ua_limit_alarm_impl";
23
22
  import { UANonExclusiveLimitAlarmEx, UANonExclusiveLimitAlarmImpl } from "./ua_non_exclusive_limit_alarm_impl";
24
23
 
25
24
  export interface UANonExclusiveDeviationAlarmEx
@@ -56,8 +55,8 @@ export class UANonExclusiveDeviationAlarmImpl extends UANonExclusiveLimitAlarmIm
56
55
  public static instantiate(
57
56
  namespace: NamespacePrivate,
58
57
  type: string | NodeId,
59
- options: any,
60
- data: any
58
+ options: InstantiateLimitAlarmOptions,
59
+ data?: Record<string, VariantOptions>
61
60
  ): UANonExclusiveDeviationAlarmImpl {
62
61
  const addressSpace = namespace.addressSpace;
63
62
 
@@ -3,17 +3,16 @@
3
3
  * @module node-opcua-address-space.AlarmsAndConditions
4
4
  */
5
5
  import { assert } from "node-opcua-assert";
6
- import { LocalizedText } from "node-opcua-data-model";
7
6
  import { NodeId } from "node-opcua-nodeid";
8
- import { UANonExclusiveLimitAlarm_Base, UATwoStateVariable } from "node-opcua-nodeset-ua";
7
+ import { UANonExclusiveLimitAlarm_Base } from "node-opcua-nodeset-ua";
9
8
  import { StatusCodes } from "node-opcua-status-code";
10
-
11
- import { UAEventType } from "../../source";
9
+ import { VariantOptions } from "node-opcua-variant";
10
+ import { UAEventType } from "node-opcua-address-space-base";
12
11
  import { UATwoStateVariableEx } from "../../source/ua_two_state_variable_ex";
13
12
  import { NamespacePrivate } from "../namespace_private";
14
13
  import { _install_TwoStateVariable_machinery } from "../state_machine/ua_two_state_variable";
15
14
  import { ConditionInfo } from "./condition_info";
16
- import { UALimitAlarmEx, UALimitAlarmImpl } from "./ua_limit_alarm_impl";
15
+ import { InstantiateLimitAlarmOptions, UALimitAlarmEx, UALimitAlarmImpl } from "./ua_limit_alarm_impl";
17
16
 
18
17
  export interface UANonExclusiveLimitAlarmEx
19
18
  extends UALimitAlarmEx,
@@ -44,8 +43,8 @@ export class UANonExclusiveLimitAlarmImpl extends UALimitAlarmImpl implements UA
44
43
  public static instantiate(
45
44
  namespace: NamespacePrivate,
46
45
  type: UAEventType | NodeId | string,
47
- options: any,
48
- data: any
46
+ options: InstantiateLimitAlarmOptions,
47
+ data?: Record<string, VariantOptions>
49
48
  ): UANonExclusiveLimitAlarmImpl {
50
49
  const addressSpace = namespace.addressSpace;
51
50
 
@@ -1,15 +1,17 @@
1
1
  /**
2
2
  * @module node-opcua-address-space.AlarmsAndConditions
3
3
  */
4
+ import { INamespace, UAVariable } from "node-opcua-address-space-base";
4
5
  import { assert } from "node-opcua-assert";
5
6
  import { DataValue } from "node-opcua-data-value";
6
- import { NodeId } from "node-opcua-nodeid";
7
+ import { NodeId, NodeIdLike } from "node-opcua-nodeid";
7
8
  import { UAOffNormalAlarm_Base } from "node-opcua-nodeset-ua";
8
9
  import { StatusCodes } from "node-opcua-status-code";
9
10
  import * as utils from "node-opcua-utils";
10
- import { DataType } from "node-opcua-variant";
11
- import { INamespace, UAVariable } from "../../source";
11
+ import { DataType, VariantOptions } from "node-opcua-variant";
12
+
12
13
  import { AddressSpacePrivate } from "../address_space_private";
14
+ import { InstantiateAlarmConditionOptions } from "./ua_alarm_condition_impl";
13
15
  import { UADiscreteAlarmEx, UADiscreteAlarmImpl } from "./ua_discrete_alarm_impl";
14
16
 
15
17
  function isEqual(value1: any, value2: any) {
@@ -30,13 +32,16 @@ export declare interface UAOffNormalAlarmEx
30
32
  | "suppressedState"
31
33
  >,
32
34
  UADiscreteAlarmEx {
33
- getNormalStateNode(): UAVariable;
35
+ getNormalStateNode(): UAVariable | null;
34
36
 
35
37
  getNormalStateValue(): any;
36
38
 
37
39
  setNormalStateValue(value: any): void;
38
40
  }
39
41
 
42
+ export interface InstantiateOffNormalAlarmOptions extends InstantiateAlarmConditionOptions {
43
+ normalState: NodeIdLike;
44
+ }
40
45
  export declare interface UAOffNormalAlarmImpl extends UAOffNormalAlarmEx, UADiscreteAlarmImpl {
41
46
  on(eventName: string, eventHandler: any): this;
42
47
  }
@@ -54,8 +59,8 @@ export class UAOffNormalAlarmImpl extends UADiscreteAlarmImpl implements UAOffNo
54
59
  public static instantiate(
55
60
  namespace: INamespace,
56
61
  limitAlarmTypeId: string | NodeId,
57
- options: any,
58
- data: any
62
+ options: InstantiateOffNormalAlarmOptions,
63
+ data?: Record<string, VariantOptions>
59
64
  ): UAOffNormalAlarmImpl {
60
65
  const addressSpace = namespace.addressSpace as AddressSpacePrivate;
61
66
 
@@ -73,20 +78,36 @@ export class UAOffNormalAlarmImpl extends UADiscreteAlarmImpl implements UAOffNo
73
78
  const alarmNode = UADiscreteAlarmImpl.instantiate(namespace, limitAlarmTypeId, options, data) as UAOffNormalAlarmImpl;
74
79
  Object.setPrototypeOf(alarmNode, UAOffNormalAlarmImpl.prototype);
75
80
 
76
- const inputNode = addressSpace._coerceNode(options.inputNode);
77
- // assert(inputNode, "Expecting a valid input node");
78
-
79
- const normalState = addressSpace._coerceNode(options.normalState)! as UAVariable;
80
- // assert(normalState, "Expecting a valid normalState node");
81
-
82
- const normalStateNodeId = normalState ? normalState.nodeId : new NodeId();
83
- alarmNode.normalState.setValueFromSource({ dataType: DataType.NodeId, value: normalStateNodeId });
81
+ /**
82
+ * The InputNode Property provides the NodeId of the Variable the Value of which is used as primary input in
83
+ * the calculation of the Alarm state.
84
+ *
85
+ * If this Variable is not in the AddressSpace, a NULL NodeId shall be provided.
86
+ *
87
+ * In some systems, an Alarm may be calculated based on multiple Variables Values;
88
+ * it is up to the system to determine which Variable’s NodeId is used.
89
+ */
90
+ const inputNode = addressSpace._coerceNode(options.inputNode) as UAVariable | null;
91
+ // note: alarmNode.inputNode.readValue() already set by DiscreteAlarmImpl.instantiate
84
92
 
85
93
  if (inputNode) {
86
94
  // install inputNode Node monitoring for change
87
95
  alarmNode.installInputNodeMonitoring(options.inputNode);
88
96
  }
89
97
 
98
+ /**
99
+ * The NormalState Property is a Property that points to a Variable which has a value that corresponds to one
100
+ * of the possible values of the Variable pointed to by the InputNode Property where the NormalState Property
101
+ * Variable value is the value that is considered to be the normal state of the Variable pointed to by the InputNode
102
+ * Property. When the value of the Variable referenced by the InputNode Property is not equal to the value of the
103
+ * NormalState Property the Alarm is Active.
104
+ *
105
+ * If this Variable is not in the AddressSpace, a NULL NodeId shall be provided.
106
+ *
107
+ */
108
+ const normalState = addressSpace._coerceNode(options.normalState) as UAVariable | null;
109
+ const normalStateNodeId = normalState ? normalState.nodeId : new NodeId();
110
+ alarmNode.normalState.setValueFromSource({ dataType: DataType.NodeId, value: normalStateNodeId });
90
111
  alarmNode.normalState.on("value_changed", (newDataValue: DataValue /*, oldDataValue: DataValue*/) => {
91
112
  // The node that contains the normalState value has changed.
92
113
  // we must remove the listener on current normalState and replace
@@ -100,7 +121,8 @@ export class UAOffNormalAlarmImpl extends UADiscreteAlarmImpl implements UAOffNo
100
121
  alarmNode._onNormalStateDataValueChange(newDataValue);
101
122
  });
102
123
  }
103
- alarmNode._updateAlarmState();
124
+
125
+ alarmNode._mayBe_updateAlarmState();
104
126
 
105
127
  return alarmNode;
106
128
  }
@@ -114,18 +136,23 @@ export class UAOffNormalAlarmImpl extends UADiscreteAlarmImpl implements UAOffNo
114
136
  // Property the Alarm is Active. If this Variable is not in the AddressSpace, a Null NodeId shall
115
137
  // be provided.
116
138
 
117
- public getNormalStateNode(): UAVariable {
139
+ public getNormalStateNode(): UAVariable | null {
118
140
  const nodeId = this.normalState.readValue().value.value;
119
141
  const node = this.addressSpace.findNode(nodeId) as UAVariable;
120
- assert(node, "getNormalStateNode ");
142
+ if (!node) {
143
+ return null;
144
+ }
121
145
  return node;
122
146
  }
123
147
 
124
148
  /**
125
149
  * @method getNormalStateValue
126
150
  */
127
- public getNormalStateValue(): any {
151
+ public getNormalStateValue(): any | null {
128
152
  const normalStateNode = this.getNormalStateNode();
153
+ if (!normalStateNode) {
154
+ return null;
155
+ }
129
156
  return normalStateNode.readValue().value.value;
130
157
  }
131
158
 
@@ -138,24 +165,29 @@ export class UAOffNormalAlarmImpl extends UADiscreteAlarmImpl implements UAOffNo
138
165
  throw new Error("Not Implemented yet");
139
166
  }
140
167
 
141
- public _updateAlarmState(normalStateValue?: any, inputValue?: any): void {
142
- if (utils.isNullOrUndefined(normalStateValue) || utils.isNullOrUndefined(inputValue)) {
143
- this.activeState.setValue(false);
144
- return;
145
- }
146
- const isActive = !isEqual(normalStateValue, inputValue);
147
-
168
+ public updateAlarmState(isActive: boolean, message: string) {
148
169
  if (isActive === this.activeState.getValue()) {
149
170
  // no change => ignore !
150
171
  return;
151
172
  }
152
-
153
173
  const stateName = isActive ? "Active" : "Inactive";
154
174
  // also raise the event
155
- this._signalNewCondition(stateName, isActive, "");
175
+ this._signalNewCondition(stateName, isActive, message);
176
+ if (!isActive) {
177
+ this.currentBranch().setRetain(false);
178
+ }
179
+ }
180
+
181
+ private _mayBe_updateAlarmState(normalStateValue?: any, inputValue?: any): void {
182
+ if (utils.isNullOrUndefined(normalStateValue) || utils.isNullOrUndefined(inputValue)) {
183
+ this.activeState.setValue(false);
184
+ return;
185
+ }
186
+ const isActive = !isEqual(normalStateValue, inputValue);
187
+ this.updateAlarmState(isActive, "automatique update");
156
188
  }
157
189
 
158
- public _onInputDataValueChange(dataValue: DataValue): void {
190
+ protected _onInputDataValueChange(dataValue: DataValue): void {
159
191
  if (dataValue.statusCode !== StatusCodes.Good) {
160
192
  // what shall we do ?
161
193
  return;
@@ -166,7 +198,7 @@ export class UAOffNormalAlarmImpl extends UADiscreteAlarmImpl implements UAOffNo
166
198
  }
167
199
  const inputValue = dataValue.value.value;
168
200
  const normalStateValue = this.getNormalStateValue();
169
- this._updateAlarmState(normalStateValue, inputValue);
201
+ this._mayBe_updateAlarmState(normalStateValue, inputValue);
170
202
  }
171
203
 
172
204
  protected _onNormalStateDataValueChange(dataValue: DataValue): void {
@@ -180,6 +212,6 @@ export class UAOffNormalAlarmImpl extends UADiscreteAlarmImpl implements UAOffNo
180
212
  }
181
213
  const normalStateValue = dataValue.value.value;
182
214
  const inputValue = this.getInputNodeValue();
183
- this._updateAlarmState(normalStateValue, inputValue);
215
+ this._mayBe_updateAlarmState(normalStateValue, inputValue);
184
216
  }
185
217
  }
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * @module node-opcua-address-space.AlarmsAndConditions
3
3
  */
4
+ import { INamespace } from "node-opcua-address-space-base";
4
5
  import { NodeId } from "node-opcua-nodeid";
5
-
6
- import { INamespace } from "../../source";
7
- import { UAOffNormalAlarmImpl } from "./ua_off_normal_alarm_impl";
6
+ import { VariantOptions } from "node-opcua-variant";
7
+ import { InstantiateOffNormalAlarmOptions, UAOffNormalAlarmImpl } from "./ua_off_normal_alarm_impl";
8
8
 
9
9
  /**
10
10
  *
@@ -17,8 +17,8 @@ export class UASystemOffNormalAlarmImpl extends UAOffNormalAlarmImpl {
17
17
  public static instantiate(
18
18
  namespace: INamespace,
19
19
  limitAlarmTypeId: string | NodeId,
20
- options: any,
21
- data: any
20
+ options: InstantiateOffNormalAlarmOptions,
21
+ data?: Record<string, VariantOptions>
22
22
  ): UASystemOffNormalAlarmImpl {
23
23
  return UAOffNormalAlarmImpl.instantiate(namespace, limitAlarmTypeId, options, data) as UASystemOffNormalAlarmImpl;
24
24
  }
@@ -27,7 +27,8 @@ import {
27
27
  UAEventType,
28
28
  IEventData,
29
29
  defaultCloneFilter,
30
- defaultCloneExtraInfo
30
+ defaultCloneExtraInfo,
31
+ EventNotifierFlags
31
32
  } from "node-opcua-address-space-base";
32
33
 
33
34
  import { BaseNodeImpl, InternalBaseNodeOptions } from "./base_node_impl";
@@ -35,8 +36,11 @@ import { _clone, ToStringBuilder, UAObject_toString } from "./base_node_private"
35
36
  import { apply_condition_refresh, ConditionRefreshCache } from "./apply_condition_refresh";
36
37
 
37
38
  export class UAObjectImpl extends BaseNodeImpl implements UAObject {
39
+ private _eventNotifier: EventNotifierFlags;
38
40
  public readonly nodeClass = NodeClass.Object;
39
- public readonly eventNotifier: number;
41
+ public get eventNotifier(): EventNotifierFlags {
42
+ return this._eventNotifier;
43
+ }
40
44
  public readonly symbolicName: string | null;
41
45
 
42
46
  get typeDefinitionObj(): UAObjectType {
@@ -45,7 +49,7 @@ export class UAObjectImpl extends BaseNodeImpl implements UAObject {
45
49
 
46
50
  constructor(options: InternalBaseNodeOptions & { eventNotifier?: number; symbolicName?: string | null }) {
47
51
  super(options);
48
- this.eventNotifier = options.eventNotifier || 0;
52
+ this._eventNotifier = options.eventNotifier || EventNotifierFlags.None;
49
53
  assert(typeof this.eventNotifier === "number" && isValidByte(this.eventNotifier));
50
54
  this.symbolicName = options.symbolicName || null;
51
55
  }
@@ -111,6 +115,10 @@ export class UAObjectImpl extends BaseNodeImpl implements UAObject {
111
115
  return super.getMethods();
112
116
  }
113
117
 
118
+ public setEventNotifier(eventNotifierFlags: EventNotifierFlags): void {
119
+ this._eventNotifier = eventNotifierFlags;
120
+ }
121
+
114
122
  /**
115
123
  * Raise a transient Event
116
124
  */