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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-opcua-address-space",
3
- "version": "2.106.0",
3
+ "version": "2.107.0",
4
4
  "description": "pure nodejs OPCUA SDK - module address-space",
5
5
  "main": "./dist/src/index_current.js",
6
6
  "types": "./dist/source/index.d.ts",
@@ -22,14 +22,14 @@
22
22
  "chalk": "4.1.2",
23
23
  "dequeue": "^1.0.5",
24
24
  "lodash": "4.17.21",
25
- "node-opcua-address-space-base": "2.106.0",
25
+ "node-opcua-address-space-base": "2.107.0",
26
26
  "node-opcua-assert": "2.105.0",
27
27
  "node-opcua-basic-types": "2.105.0",
28
28
  "node-opcua-binary-stream": "2.105.0",
29
- "node-opcua-client-dynamic-extension-object": "2.106.0",
29
+ "node-opcua-client-dynamic-extension-object": "2.107.0",
30
30
  "node-opcua-constants": "2.98.1",
31
31
  "node-opcua-crypto": "3.0.6",
32
- "node-opcua-data-access": "2.105.0",
32
+ "node-opcua-data-access": "2.107.0",
33
33
  "node-opcua-data-model": "2.105.0",
34
34
  "node-opcua-data-value": "2.105.0",
35
35
  "node-opcua-date-time": "2.105.0",
@@ -38,20 +38,20 @@
38
38
  "node-opcua-extension-object": "2.105.0",
39
39
  "node-opcua-factory": "2.105.0",
40
40
  "node-opcua-nodeid": "2.105.0",
41
- "node-opcua-nodeset-ua": "2.106.0",
41
+ "node-opcua-nodeset-ua": "2.107.0",
42
42
  "node-opcua-numeric-range": "2.105.0",
43
43
  "node-opcua-object-registry": "2.105.0",
44
- "node-opcua-pseudo-session": "2.106.0",
45
- "node-opcua-service-browse": "2.105.0",
46
- "node-opcua-service-call": "2.105.0",
47
- "node-opcua-service-history": "2.105.0",
48
- "node-opcua-service-translate-browse-path": "2.105.0",
49
- "node-opcua-service-write": "2.105.0",
44
+ "node-opcua-pseudo-session": "2.107.0",
45
+ "node-opcua-service-browse": "2.107.0",
46
+ "node-opcua-service-call": "2.107.0",
47
+ "node-opcua-service-history": "2.107.0",
48
+ "node-opcua-service-translate-browse-path": "2.107.0",
49
+ "node-opcua-service-write": "2.107.0",
50
50
  "node-opcua-status-code": "2.105.0",
51
- "node-opcua-types": "2.105.0",
51
+ "node-opcua-types": "2.107.0",
52
52
  "node-opcua-utils": "2.105.0",
53
53
  "node-opcua-variant": "2.105.0",
54
- "node-opcua-xml2json": "2.105.0",
54
+ "node-opcua-xml2json": "2.107.0",
55
55
  "semver": "^7.5.1",
56
56
  "set-prototype-of": "^1.0.0",
57
57
  "thenify": "^3.3.1",
@@ -61,10 +61,10 @@
61
61
  "mocha": "^10.2.0",
62
62
  "node-opcua-benchmarker": "2.105.0",
63
63
  "node-opcua-leak-detector": "2.105.0",
64
- "node-opcua-nodesets": "2.103.0",
64
+ "node-opcua-nodesets": "2.107.0",
65
65
  "node-opcua-packet-analyzer": "2.105.0",
66
- "node-opcua-service-filter": "2.106.0",
67
- "node-opcua-test-fixtures": "2.105.0",
66
+ "node-opcua-service-filter": "2.107.0",
67
+ "node-opcua-test-fixtures": "2.107.0",
68
68
  "should": "^13.2.3",
69
69
  "sinon": "^15.1.0",
70
70
  "source-map-support": "^0.5.21"
@@ -84,7 +84,7 @@
84
84
  "internet of things"
85
85
  ],
86
86
  "homepage": "http://node-opcua.github.io/",
87
- "gitHead": "6fe67f5a64192bff5c7f590c4de4e827ae0c551a",
87
+ "gitHead": "df5c9168eea0d1a521603d181fa66ace7649e79e",
88
88
  "files": [
89
89
  "dist",
90
90
  "distHelpers",
@@ -3,10 +3,7 @@ import { UAObject, UAVariable } from "node-opcua-address-space-base";
3
3
 
4
4
  import { g_promotableObject, Promoter } from "./namespace_post_step";
5
5
 
6
- export function registerNodePromoter(
7
- standardNodeId: number,
8
- promoter: Promoter,
9
- applyOnTypes = false
10
- ): void {
11
- g_promotableObject[resolveNodeId(standardNodeId).toString()] = { promoter, onInstanceOnly: applyOnTypes };
6
+ export function registerNodePromoter(standardNodeId: number, promoter: Promoter, onInstanceOnly = false): void {
7
+
8
+ g_promotableObject[resolveNodeId(standardNodeId).toString()] = { promoter, onInstanceOnly };
12
9
  }
@@ -0,0 +1,141 @@
1
+ /**
2
+ * @module node-opcua-address-space
3
+ */
4
+ // tslint:disable:max-classes-per-file
5
+ // tslint:disable:no-console
6
+ import chalk from "chalk";
7
+
8
+ import {
9
+ UAMethod,
10
+ UAObject,
11
+ UAObjectType,
12
+ UAVariable,
13
+ UAVariableType,
14
+ reconstructFunctionalGroupType,
15
+ reconstructNonHierarchicalReferences,
16
+ CloneHelper
17
+ } from "node-opcua-address-space-base";
18
+
19
+ import { checkDebugFlag, make_debugLog, make_warningLog, make_errorLog } from "node-opcua-debug";
20
+ import { sameNodeId } from "node-opcua-nodeid";
21
+
22
+ import { makeOptionalsMap, OptionalMap } from "../source/helpers/make_optionals_map";
23
+
24
+ import { _clone_hierarchical_references } from "./base_node_private";
25
+ import { MandatoryChildOrRequestedOptionalFilter } from "./_mandatory_child_or_requested_optional_filter";
26
+
27
+ const debugLog = make_debugLog(__filename);
28
+ const doDebug = checkDebugFlag(__filename);
29
+ const warningLog = make_warningLog(__filename);
30
+ const errorLog = make_errorLog(__filename);
31
+
32
+ // eslint-disable-next-line prefer-const
33
+ let doTrace = checkDebugFlag("INSTANTIATE");
34
+ const traceLog = errorLog;
35
+
36
+ // install properties and components on a instantiated Object
37
+ //
38
+ // based on their ModelingRule
39
+ // => Mandatory => Installed
40
+ // => Optional => Not Installed , unless it appear in optionals array
41
+ // => OptionalPlaceHolder => Not Installed
42
+ // => null (no modelling rule ) => Not Installed
43
+ //
44
+
45
+ function _initialize_properties_and_components<B extends UAObject | UAVariable | UAMethod, T extends UAObjectType | UAVariableType>(
46
+ instance: B,
47
+ topMostType: T,
48
+ typeDefinitionNode: T,
49
+ copyAlsoModellingRules: boolean,
50
+ optionalsMap: OptionalMap,
51
+ extraInfo: CloneHelper,
52
+ browseNameMap: Set<string>
53
+ ) {
54
+ if (doTrace) {
55
+ warningLog("instance browseName =", instance.browseName.toString());
56
+ warningLog("typeNode =", typeDefinitionNode.browseName.toString());
57
+ warningLog("optionalsMap =", Object.keys(optionalsMap).join(" "));
58
+
59
+ const c = typeDefinitionNode.findReferencesEx("Aggregates");
60
+ warningLog("typeDefinition aggregates =", c.map((x) => x.node!.browseName.toString()).join(" "));
61
+ }
62
+ optionalsMap = optionalsMap || {};
63
+
64
+ if (sameNodeId(topMostType.nodeId, typeDefinitionNode.nodeId)) {
65
+ return; // nothing to do
66
+ }
67
+
68
+ const filter = new MandatoryChildOrRequestedOptionalFilter(instance, optionalsMap);
69
+
70
+ doTrace &&
71
+ traceLog(
72
+ chalk.cyan(extraInfo.pad(), "cloning relevant member of typeDefinition class"),
73
+ typeDefinitionNode.browseName.toString()
74
+ );
75
+
76
+ _clone_hierarchical_references(typeDefinitionNode, instance, copyAlsoModellingRules, filter, extraInfo, browseNameMap);
77
+
78
+ // now apply recursion on baseTypeDefinition to get properties and components from base class
79
+
80
+ const baseTypeDefinitionNodeId = typeDefinitionNode.subtypeOf;
81
+ const baseTypeDefinition = typeDefinitionNode.subtypeOfObj!;
82
+
83
+ doTrace &&
84
+ traceLog(
85
+ chalk.cyan(
86
+ extraInfo.pad(),
87
+ "now apply recursion on baseTypeDefinition to get properties and components from base class"
88
+ ),
89
+ baseTypeDefinition.browseName.toString()
90
+ );
91
+
92
+ // istanbul ignore next
93
+ if (!baseTypeDefinition) {
94
+ throw new Error(chalk.red("Cannot find object with nodeId ") + baseTypeDefinitionNodeId);
95
+ }
96
+ extraInfo.level++;
97
+ _initialize_properties_and_components(
98
+ instance,
99
+ topMostType,
100
+ baseTypeDefinition,
101
+ copyAlsoModellingRules,
102
+ optionalsMap,
103
+ extraInfo,
104
+ browseNameMap
105
+ );
106
+ extraInfo.level--;
107
+ }
108
+
109
+ export function initialize_properties_and_components<
110
+ B extends UAObject | UAVariable | UAMethod,
111
+ T extends UAVariableType | UAObjectType
112
+ >(instance: B, topMostType: T, nodeType: T, copyAlsoModellingRules: boolean, optionals?: string[]): void {
113
+ const extraInfo = new CloneHelper();
114
+
115
+ extraInfo.pushContext({
116
+ clonedParent: instance,
117
+ originalParent: nodeType
118
+ });
119
+ extraInfo.registerClonedObject({
120
+ clonedNode: instance,
121
+ originalNode: nodeType
122
+ });
123
+
124
+ const optionalsMap = makeOptionalsMap(optionals);
125
+
126
+ const browseNameMap = new Set<string>();
127
+
128
+ _initialize_properties_and_components(
129
+ instance,
130
+ topMostType,
131
+ nodeType,
132
+ copyAlsoModellingRules,
133
+ optionalsMap,
134
+ extraInfo,
135
+ browseNameMap
136
+ );
137
+
138
+ reconstructFunctionalGroupType(extraInfo);
139
+
140
+ reconstructNonHierarchicalReferences(extraInfo);
141
+ }
@@ -0,0 +1,98 @@
1
+ import { assert } from "node-opcua-assert";
2
+ import { BaseNode, UAMethod, UAObject, UAReference, UAVariable, CloneFilter, fullPath2 } from "node-opcua-address-space-base";
3
+
4
+ import { checkDebugFlag, make_debugLog, make_warningLog, make_errorLog } from "node-opcua-debug";
5
+
6
+ import { _clone_hierarchical_references } from "./base_node_private";
7
+
8
+ // const debugLog = make_debugLog(__filename);
9
+ const doDebug = checkDebugFlag(__filename);
10
+ const warningLog = make_warningLog(__filename);
11
+ const errorLog = make_errorLog(__filename);
12
+ const doTrace = checkDebugFlag("INSTANTIATE");
13
+ const traceLog = errorLog;
14
+
15
+ export class MandatoryChildOrRequestedOptionalFilter implements CloneFilter {
16
+ private readonly instance: BaseNode;
17
+ private readonly optionalsMap: any;
18
+ private readonly references: UAReference[];
19
+
20
+ constructor(instance: BaseNode, optionalsMap: any) {
21
+ // should we clone the node to be a component or propertyOf of a instance
22
+ assert(optionalsMap !== null && typeof optionalsMap === "object");
23
+ assert(null !== instance);
24
+ this.optionalsMap = optionalsMap;
25
+ this.instance = instance;
26
+ this.references = instance.allReferences();
27
+ }
28
+
29
+ public shouldKeep(node: BaseNode): boolean {
30
+ const addressSpace = node.addressSpace;
31
+
32
+ const alreadyIn = this.references.filter((r: UAReference) => {
33
+ const n = addressSpace.findNode(r.nodeId)!;
34
+ // istanbul ignore next
35
+ if (!n) {
36
+ warningLog(" cannot find node ", r.nodeId.toString());
37
+ return false;
38
+ }
39
+ return n.browseName!.name!.toString() === node.browseName!.name!.toString();
40
+ });
41
+
42
+ if (alreadyIn.length > 0) {
43
+ assert(alreadyIn.length === 1, "Duplication found ?");
44
+ // a child with the same browse name has already been install
45
+ // probably from a SuperClass, we should ignore this.
46
+ return false; // ignore
47
+ }
48
+
49
+ const modellingRule = node.modellingRule;
50
+
51
+ switch (modellingRule) {
52
+ case null:
53
+ case undefined:
54
+ // istanbul ignore next
55
+ doTrace &&
56
+ traceLog(
57
+ "node ",
58
+ fullPath2(node),
59
+ " has no modellingRule ",
60
+ node ? fullPath2(node) : ""
61
+ );
62
+ /**
63
+ * in some badly generated NodeSet2.xml file, the modellingRule is not specified
64
+ *
65
+ * but in some other NodeSet2.xml, this means that the data are only attached to the Type node and shall not be
66
+ * instantiate in the corresponding instance (example is the state variable of a finite state machine that are only
67
+ * defined in the Type node)
68
+ *
69
+ * we should not consider it as an error, and treat it as not present
70
+ */
71
+ return false;
72
+
73
+ case "Mandatory":
74
+ return true; // keep;
75
+ case "Optional":
76
+ // only if in requested optionals
77
+ return node.browseName!.name! in this.optionalsMap;
78
+ case "OptionalPlaceholder":
79
+ return false; // ignored
80
+ default:
81
+ return false; // ignored
82
+ }
83
+ }
84
+
85
+ public filterFor(childInstance: UAVariable | UAObject | UAMethod): CloneFilter {
86
+ const browseName: string = childInstance.browseName.name!;
87
+
88
+ let map = {};
89
+
90
+ if (browseName in this.optionalsMap) {
91
+ map = this.optionalsMap[browseName];
92
+ }
93
+ // istanbul ignore next
94
+ doTrace && traceLog("filterFor ", browseName, map);
95
+ const newFilter = new MandatoryChildOrRequestedOptionalFilter(childInstance, map);
96
+ return newFilter;
97
+ }
98
+ }
@@ -201,6 +201,9 @@ export class UAAlarmConditionImpl extends UAAcknowledgeableConditionImpl impleme
201
201
 
202
202
  public deactivateAlarm(retain?: boolean): void {
203
203
  const branch = this.currentBranch();
204
+ if (!branch) {
205
+ return;
206
+ }
204
207
  branch.setRetain(retain === undefined ? true : retain);
205
208
  branch.setActiveState(false);
206
209
  }
@@ -193,7 +193,7 @@ class UACertificateExpirationAlarmImpl extends UASystemOffNormalAlarmImpl implem
193
193
  this.expirationLimit.accessLevel = makeAccessLevelExFlag("CurrentRead | CurrentWrite");
194
194
  this.expirationLimit.userAccessLevel = makeAccessLevelExFlag("CurrentRead | CurrentWrite");
195
195
  this.expirationLimit.on("value_changed", (dataValue) => {
196
- // make sure we re-evaluate the certificfate
196
+ // make sure we re-evaluate the certificate
197
197
  const certificate = this.getCertificate();
198
198
  this.setCertificate(certificate);
199
199
  });
@@ -32,7 +32,8 @@ import {
32
32
  BaseNode,
33
33
  UAObject,
34
34
  InstantiateObjectOptions,
35
- UAProperty
35
+ UAProperty,
36
+ fullPath2
36
37
  } from "node-opcua-address-space-base";
37
38
  import { UAConditionVariable } from "node-opcua-nodeset-ua";
38
39
 
@@ -89,7 +90,7 @@ export class UAConditionImpl extends UABaseEventImpl implements UAConditionEx {
89
90
  namespace: INamespace,
90
91
  conditionTypeId: NodeId | string | UAEventType,
91
92
  options: any,
92
- data: any
93
+ data?: Record<string, VariantOptions>
93
94
  ): UAConditionImpl {
94
95
  return UACondition_instantiate(namespace, conditionTypeId, options, data) as UAConditionImpl;
95
96
  }
@@ -455,9 +456,10 @@ export class UAConditionImpl extends UABaseEventImpl implements UAConditionEx {
455
456
  }
456
457
  } else {
457
458
  warningLog(
458
- "Condition ",
459
- this.nodeId.toString(),
460
- "is not linked to a Object with a IsConditionOf(reversed(HasCondition))"
459
+ "raiseConditionEvent: the condition ",
460
+ fullPath2(this),
461
+ "is not linked to a Object with a IsConditionOf(reversed(HasCondition)) reference",
462
+ "therefore event cannot bubble-up to the server object"
461
463
  );
462
464
  }
463
465
  // xx console.log("MMMMMMMM%%%%%%%%%%%%%%%%%%%%% branch " +