node-opcua-address-space 2.169.0 → 2.170.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.
- package/dist/source/ua_interface.d.ts +2 -3
- package/dist/source/ua_interface.js +10 -33
- package/dist/source/ua_interface.js.map +1 -1
- package/dist/src/_instantiate_helpers.d.ts +1 -1
- package/dist/src/_instantiate_helpers.js +32 -9
- package/dist/src/_instantiate_helpers.js.map +1 -1
- package/dist/src/_mandatory_child_or_requested_optional_filter.js +3 -3
- package/dist/src/_mandatory_child_or_requested_optional_filter.js.map +1 -1
- package/dist/src/address_space.d.ts +2 -2
- package/dist/src/address_space.js +9 -11
- package/dist/src/address_space.js.map +1 -1
- package/dist/src/alarms_and_conditions/condition_snapshot_impl.js +1 -1
- package/dist/src/alarms_and_conditions/condition_snapshot_impl.js.map +1 -1
- package/dist/src/base_node_impl.d.ts +1 -1
- package/dist/src/base_node_private.d.ts +10 -7
- package/dist/src/base_node_private.js +74 -50
- package/dist/src/base_node_private.js.map +1 -1
- package/dist/src/check_value_rank_compatibility.js +1 -1
- package/dist/src/check_value_rank_compatibility.js.map +1 -1
- package/dist/src/event_data.d.ts +8 -21
- package/dist/src/event_data.js +24 -19
- package/dist/src/event_data.js.map +1 -1
- package/dist/src/ua_object_impl.d.ts +6 -5
- package/dist/src/ua_object_impl.js +30 -4
- package/dist/src/ua_object_impl.js.map +1 -1
- package/dist/src/ua_object_type_impl.js +2 -2
- package/dist/src/ua_object_type_impl.js.map +1 -1
- package/dist/src/ua_variable_impl.d.ts +1 -0
- package/dist/src/ua_variable_impl.js +79 -1
- package/dist/src/ua_variable_impl.js.map +1 -1
- package/dist/tsconfig_base.tsbuildinfo +1 -1
- package/distHelpers/get_address_space_fixture.js +14 -14
- package/distHelpers/get_address_space_fixture.js.map +1 -1
- package/distHelpers/index.d.ts +2 -2
- package/distHelpers/index.js +2 -2
- package/distHelpers/index.js.map +1 -1
- package/package.json +18 -18
- package/source/ua_interface.ts +24 -38
- package/src/_instantiate_helpers.ts +67 -24
- package/src/_mandatory_child_or_requested_optional_filter.ts +5 -5
- package/src/address_space.ts +15 -16
- package/src/alarms_and_conditions/condition_snapshot_impl.ts +3 -3
- package/src/base_node_impl.ts +1 -1
- package/src/base_node_private.ts +163 -139
- package/src/check_value_rank_compatibility.ts +1 -1
- package/src/event_data.ts +57 -54
- package/src/ua_object_impl.ts +51 -22
- package/src/ua_object_type_impl.ts +3 -3
- package/src/ua_variable_impl.ts +79 -2
package/src/base_node_private.ts
CHANGED
|
@@ -5,58 +5,53 @@
|
|
|
5
5
|
*/
|
|
6
6
|
// tslint:disable:no-bitwise
|
|
7
7
|
import chalk from "chalk";
|
|
8
|
+
import type {
|
|
9
|
+
BaseNode,
|
|
10
|
+
CloneExtraInfo,
|
|
11
|
+
CloneFilter,
|
|
12
|
+
IAddressSpace,
|
|
13
|
+
ISessionContext,
|
|
14
|
+
UADataType,
|
|
15
|
+
UAMethod,
|
|
16
|
+
UAObject,
|
|
17
|
+
UAObjectType,
|
|
18
|
+
UAReference,
|
|
19
|
+
UAReferenceType,
|
|
20
|
+
UAVariable,
|
|
21
|
+
UAVariableT,
|
|
22
|
+
UAVariableType
|
|
23
|
+
} from "node-opcua-address-space-base";
|
|
24
|
+
import { CloneHelper, type CloneOptions, type ConstructNodeIdOptions, fullPath2 } from "node-opcua-address-space-base";
|
|
8
25
|
import { assert } from "node-opcua-assert";
|
|
26
|
+
import type { DataType } from "node-opcua-basic-types";
|
|
27
|
+
import { ObjectTypeIds, VariableTypeIds } from "node-opcua-constants";
|
|
9
28
|
import {
|
|
10
29
|
AccessLevelFlag,
|
|
11
30
|
BrowseDirection,
|
|
12
31
|
coerceLocalizedText,
|
|
13
32
|
coerceQualifiedName,
|
|
14
|
-
LocalizedText,
|
|
33
|
+
type LocalizedText,
|
|
15
34
|
NodeClass,
|
|
16
35
|
ResultMask
|
|
17
36
|
} from "node-opcua-data-model";
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
|
|
23
|
-
UADataType,
|
|
24
|
-
UAReferenceType,
|
|
25
|
-
ConstructNodeIdOptions,
|
|
26
|
-
CloneExtraInfo,
|
|
27
|
-
CloneFilter,
|
|
28
|
-
BaseNode,
|
|
29
|
-
UAVariable,
|
|
30
|
-
UAMethod,
|
|
31
|
-
UAObject,
|
|
32
|
-
UAObjectType,
|
|
33
|
-
UAVariableType,
|
|
34
|
-
ISessionContext,
|
|
35
|
-
UAReference,
|
|
36
|
-
CloneOptions,
|
|
37
|
-
CloneHelper,
|
|
38
|
-
fullPath2,
|
|
39
|
-
UAVariableT
|
|
40
|
-
} from "node-opcua-address-space-base";
|
|
41
|
-
import { DataValue } from "node-opcua-data-value";
|
|
42
|
-
import { ObjectTypeIds, VariableTypeIds } from "node-opcua-constants";
|
|
43
|
-
|
|
44
|
-
import { UANamespace_process_modelling_rule } from "./namespace_private";
|
|
45
|
-
import { ReferenceImpl, resolveReferenceNode } from "./reference_impl";
|
|
37
|
+
import type { DataValue } from "node-opcua-data-value";
|
|
38
|
+
import { checkDebugFlag, make_errorLog, make_warningLog } from "node-opcua-debug";
|
|
39
|
+
import { ExpandedNodeId, NodeId, resolveNodeId, sameNodeId } from "node-opcua-nodeid";
|
|
40
|
+
import { ReferenceDescription, type ReferenceDescriptionOptions } from "node-opcua-types";
|
|
41
|
+
import type { AddressSpacePrivate } from "./address_space_private";
|
|
46
42
|
import { BaseNodeImpl, getReferenceType } from "./base_node_impl";
|
|
47
|
-
import {
|
|
43
|
+
import { UANamespace_process_modelling_rule } from "./namespace_private";
|
|
44
|
+
import { ReferenceImpl } from "./reference_impl";
|
|
48
45
|
import { wipeMemorizedStuff } from "./tool_isSubtypeOf";
|
|
49
|
-
import { DataType } from "node-opcua-basic-types";
|
|
50
46
|
|
|
51
47
|
// eslint-disable-next-line prefer-const
|
|
52
|
-
const errorLog = make_errorLog(
|
|
48
|
+
const errorLog = make_errorLog("address-space:BaseNode");
|
|
53
49
|
const doTrace = checkDebugFlag("INSTANTIATE");
|
|
54
50
|
const traceLog = errorLog;
|
|
51
|
+
const warningLog = make_warningLog("address-space:BaseNode");
|
|
55
52
|
|
|
56
53
|
const g_weakMap = new WeakMap();
|
|
57
54
|
|
|
58
|
-
const warningLog = make_warningLog(__filename);
|
|
59
|
-
|
|
60
55
|
interface BaseNodeCacheInner {
|
|
61
56
|
typeDefinition?: NodeId;
|
|
62
57
|
typeDefinitionObj?: UAVariableType | UAObjectType | null;
|
|
@@ -82,7 +77,6 @@ export type UAReferenceWithNodeRef = UAReference & { node: BaseNode };
|
|
|
82
77
|
export type HierarchicalIndexMap = Map<string, UAReferenceWithNodeRef | UAReferenceWithNodeRef[]>;
|
|
83
78
|
|
|
84
79
|
interface BaseNodeCache {
|
|
85
|
-
|
|
86
80
|
_childByNameMap?: HierarchicalIndexMap;
|
|
87
81
|
__address_space: IAddressSpace | null;
|
|
88
82
|
_browseFilter?: (this: BaseNode, context?: ISessionContext) => boolean;
|
|
@@ -105,7 +99,7 @@ export function BaseNode_initPrivate(self: BaseNode): BaseNodeCache {
|
|
|
105
99
|
_cache: {},
|
|
106
100
|
_description: undefined,
|
|
107
101
|
_displayName: [],
|
|
108
|
-
_parent: undefined
|
|
102
|
+
_parent: undefined
|
|
109
103
|
};
|
|
110
104
|
g_weakMap.set(self, _private);
|
|
111
105
|
return _private;
|
|
@@ -133,25 +127,26 @@ export function BaseNode_getCache(node: BaseNode): BaseNodeCacheInner {
|
|
|
133
127
|
}
|
|
134
128
|
export function BaseNode_clearCache(node: BaseNode): void {
|
|
135
129
|
const _private = BaseNode_getPrivate(node);
|
|
136
|
-
if (_private
|
|
130
|
+
if (_private?._cache) {
|
|
137
131
|
_private._cache = {};
|
|
138
132
|
}
|
|
139
133
|
wipeMemorizedStuff(node);
|
|
140
134
|
}
|
|
141
135
|
const hasTypeDefinition_ReferenceTypeNodeId = resolveNodeId("HasTypeDefinition");
|
|
142
136
|
|
|
143
|
-
export interface
|
|
137
|
+
export interface ToStringOptionBase {
|
|
144
138
|
level: number;
|
|
145
|
-
cycleDetector:
|
|
139
|
+
cycleDetector: Record<string, unknown>;
|
|
146
140
|
padding: string;
|
|
147
|
-
|
|
141
|
+
}
|
|
142
|
+
export interface ToStringOption extends ToStringOptionBase {
|
|
148
143
|
add(someLine: string): void;
|
|
149
144
|
indent(a: string, b: string | null): void;
|
|
150
145
|
}
|
|
151
146
|
|
|
152
147
|
export class ToStringBuilder implements ToStringOption {
|
|
153
148
|
public level = 0;
|
|
154
|
-
public cycleDetector:
|
|
149
|
+
public cycleDetector: Record<string, unknown> = {};
|
|
155
150
|
public padding = "";
|
|
156
151
|
|
|
157
152
|
private str: string[] = [];
|
|
@@ -193,13 +188,13 @@ export function BaseNode_toString(this: BaseNode, options: ToStringOption): void
|
|
|
193
188
|
options.add("");
|
|
194
189
|
options.add(options.padding + chalk.yellow(" nodeId : ") + this.nodeId.toString());
|
|
195
190
|
options.add(
|
|
196
|
-
options.padding + chalk.yellow(" nodeClass : ")
|
|
191
|
+
`${options.padding + chalk.yellow(" nodeClass : ")}${NodeClass[this.nodeClass]} (${this.nodeClass})`
|
|
197
192
|
);
|
|
198
193
|
options.add(options.padding + chalk.yellow(" browseName : ") + this.browseName.toString());
|
|
199
194
|
options.add(
|
|
200
195
|
options.padding +
|
|
201
|
-
|
|
202
|
-
|
|
196
|
+
chalk.yellow(" displayName : ") +
|
|
197
|
+
this.displayName.map((f) => `${f.locale} ${f.text}`).join(" | ")
|
|
203
198
|
);
|
|
204
199
|
|
|
205
200
|
options.add(
|
|
@@ -216,12 +211,7 @@ export function BaseNode_References_toString(this: BaseNode, options: ToStringOp
|
|
|
216
211
|
|
|
217
212
|
const addressSpace = this.addressSpace;
|
|
218
213
|
|
|
219
|
-
options.add(
|
|
220
|
-
options.padding +
|
|
221
|
-
chalk.yellow(" references : ") +
|
|
222
|
-
" length =" +
|
|
223
|
-
_private._referenceIdx.size
|
|
224
|
-
);
|
|
214
|
+
options.add(`${options.padding + chalk.yellow(" references : ")} length =${_private._referenceIdx.size}`);
|
|
225
215
|
|
|
226
216
|
function dump_reference(follow: boolean, reference: UAReference | null) {
|
|
227
217
|
if (!reference) {
|
|
@@ -241,7 +231,7 @@ export function BaseNode_References_toString(this: BaseNode, options: ToStringOp
|
|
|
241
231
|
case NodeClass.Object:
|
|
242
232
|
return "[O] ";
|
|
243
233
|
case NodeClass.Variable:
|
|
244
|
-
return
|
|
234
|
+
return `[V] ${(o as UAVariable).dataType.toString(displayOptions).padEnd(10)}`;
|
|
245
235
|
case NodeClass.Method:
|
|
246
236
|
return "[M] ";
|
|
247
237
|
case NodeClass.DataType:
|
|
@@ -259,12 +249,12 @@ export function BaseNode_References_toString(this: BaseNode, options: ToStringOp
|
|
|
259
249
|
})();
|
|
260
250
|
options.add(
|
|
261
251
|
options.padding +
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
252
|
+
chalk.yellow(" +-> ") +
|
|
253
|
+
reference.toString(displayOptions) +
|
|
254
|
+
" " +
|
|
255
|
+
chalk.cyan(name.padEnd(25, " ")) +
|
|
256
|
+
" " +
|
|
257
|
+
chalk.magentaBright(extra)
|
|
268
258
|
);
|
|
269
259
|
|
|
270
260
|
// ignore HasTypeDefinition as it has been already handled
|
|
@@ -275,10 +265,10 @@ export function BaseNode_References_toString(this: BaseNode, options: ToStringOp
|
|
|
275
265
|
if (!is_already_processed(options, o.nodeId)) {
|
|
276
266
|
set_as_processed(options, o.nodeId);
|
|
277
267
|
if (options.level > 1 && follow) {
|
|
278
|
-
const rr = (o as
|
|
268
|
+
const rr = (o as { toString(options: ToStringOptionBase): string }).toString({
|
|
279
269
|
cycleDetector: options.cycleDetector,
|
|
280
270
|
level: options.level - 1,
|
|
281
|
-
padding: options.padding
|
|
271
|
+
padding: `${options.padding} `
|
|
282
272
|
});
|
|
283
273
|
options.add(rr);
|
|
284
274
|
}
|
|
@@ -287,17 +277,16 @@ export function BaseNode_References_toString(this: BaseNode, options: ToStringOp
|
|
|
287
277
|
}
|
|
288
278
|
|
|
289
279
|
// direct reference
|
|
290
|
-
for (
|
|
280
|
+
for (const r of _private._referenceIdx.values()) {
|
|
291
281
|
dump_reference(false, r);
|
|
292
282
|
}
|
|
293
283
|
|
|
294
|
-
|
|
295
284
|
options.add(
|
|
296
285
|
options.padding +
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
286
|
+
chalk.yellow(" back_references : ") +
|
|
287
|
+
chalk.cyan(" length =") +
|
|
288
|
+
_private._back_referenceIdx.size +
|
|
289
|
+
chalk.grey(" ( references held by other nodes involving this node)")
|
|
301
290
|
);
|
|
302
291
|
for (const r of _private._back_referenceIdx.values()) {
|
|
303
292
|
dump_reference(false, r);
|
|
@@ -309,11 +298,11 @@ function _UAType_toString(this: UAReferenceType | UADataType | UAObjectType | UA
|
|
|
309
298
|
if (this.subtypeOfObj) {
|
|
310
299
|
options.add(
|
|
311
300
|
options.padding +
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
301
|
+
chalk.yellow(" subtypeOf : ") +
|
|
302
|
+
this.subtypeOfObj.browseName.toString() +
|
|
303
|
+
" (" +
|
|
304
|
+
this.subtypeOfObj.nodeId.toString() +
|
|
305
|
+
")"
|
|
317
306
|
);
|
|
318
307
|
}
|
|
319
308
|
}
|
|
@@ -322,11 +311,11 @@ function _UAInstance_toString(this: UAVariable | UAMethod | UAObject, options: T
|
|
|
322
311
|
if (this.typeDefinitionObj) {
|
|
323
312
|
options.add(
|
|
324
313
|
options.padding +
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
314
|
+
chalk.yellow(" typeDefinition : ") +
|
|
315
|
+
this.typeDefinitionObj.browseName.toString() +
|
|
316
|
+
" (" +
|
|
317
|
+
this.typeDefinitionObj.nodeId.toString() +
|
|
318
|
+
")"
|
|
330
319
|
);
|
|
331
320
|
}
|
|
332
321
|
}
|
|
@@ -372,9 +361,9 @@ export function valueRankToString(valueRank: number): string {
|
|
|
372
361
|
return "ScalarOrOneDimension (2)"; // The value can be a scalar or a one dimensional array.
|
|
373
362
|
default:
|
|
374
363
|
if (valueRank > 0) {
|
|
375
|
-
return
|
|
364
|
+
return `${valueRank}-Dimensions`;
|
|
376
365
|
} else {
|
|
377
|
-
return
|
|
366
|
+
return `Invalid (${valueRank})`;
|
|
378
367
|
}
|
|
379
368
|
}
|
|
380
369
|
}
|
|
@@ -408,11 +397,11 @@ function accessLevelFlagToString(flag: AccessLevelFlag): string {
|
|
|
408
397
|
function AccessLevelFlags_toString(this: UAVariable, options: ToStringOption) {
|
|
409
398
|
assert(options);
|
|
410
399
|
options.add(
|
|
411
|
-
options.padding + chalk.yellow(" accessLevel : ")
|
|
400
|
+
`${options.padding + chalk.yellow(" accessLevel : ")} ${accessLevelFlagToString(this.accessLevel)}`
|
|
412
401
|
);
|
|
413
402
|
if (this.userAccessLevel !== undefined) {
|
|
414
403
|
options.add(
|
|
415
|
-
options.padding + chalk.yellow(" userAccessLevel : ")
|
|
404
|
+
`${options.padding + chalk.yellow(" userAccessLevel : ")} ${accessLevelFlagToString(this.userAccessLevel)}`
|
|
416
405
|
);
|
|
417
406
|
}
|
|
418
407
|
}
|
|
@@ -425,46 +414,38 @@ export function VariableOrVariableType_toString(this: UAVariableType | UAVariabl
|
|
|
425
414
|
if (this.dataType) {
|
|
426
415
|
const addressSpace = this.addressSpace;
|
|
427
416
|
const d = addressSpace.findNode(this.dataType);
|
|
428
|
-
const n = d ?
|
|
429
|
-
options.add(options.padding + chalk.yellow(" dataType : ")
|
|
417
|
+
const n = d ? `(${d.browseName.toString()})` : " (???)";
|
|
418
|
+
options.add(`${options.padding + chalk.yellow(" dataType : ")} ${this.dataType} ${n}`);
|
|
430
419
|
}
|
|
431
420
|
if (this.nodeClass === NodeClass.Variable) {
|
|
432
421
|
const _dataValue = (<WithDataValue>this).$dataValue;
|
|
433
422
|
if (_dataValue) {
|
|
434
423
|
options.add(
|
|
435
424
|
options.padding +
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
425
|
+
chalk.yellow(" value : ") +
|
|
426
|
+
"\n" +
|
|
427
|
+
options.indent(_dataValue.toString(), `${options.padding} | `)
|
|
439
428
|
);
|
|
440
429
|
}
|
|
441
430
|
}
|
|
442
431
|
|
|
443
|
-
if (Object.
|
|
432
|
+
if (Object.hasOwn(this, "valueRank")) {
|
|
444
433
|
if (this.valueRank !== undefined) {
|
|
445
434
|
options.add(
|
|
446
|
-
options.padding + chalk.yellow(" valueRank : ")
|
|
435
|
+
`${options.padding + chalk.yellow(" valueRank : ")} ${valueRankToString(this.valueRank)}`
|
|
447
436
|
);
|
|
448
437
|
} else {
|
|
449
|
-
options.add(options.padding + chalk.yellow(" valueRank : ")
|
|
438
|
+
options.add(`${options.padding + chalk.yellow(" valueRank : ")} undefined`);
|
|
450
439
|
}
|
|
451
440
|
}
|
|
452
441
|
if (this.minimumSamplingInterval !== undefined) {
|
|
453
442
|
options.add(
|
|
454
|
-
options.padding +
|
|
455
|
-
chalk.yellow(" minimumSamplingInterval : ") +
|
|
456
|
-
" " +
|
|
457
|
-
this.minimumSamplingInterval.toString() +
|
|
458
|
-
" ms"
|
|
443
|
+
`${options.padding + chalk.yellow(" minimumSamplingInterval : ")} ${this.minimumSamplingInterval.toString()} ms`
|
|
459
444
|
);
|
|
460
445
|
}
|
|
461
446
|
if (this.arrayDimensions) {
|
|
462
447
|
options.add(
|
|
463
|
-
options.padding +
|
|
464
|
-
chalk.yellow(" arrayDimension : ") +
|
|
465
|
-
" [" +
|
|
466
|
-
this.arrayDimensions.join(",").toString() +
|
|
467
|
-
" ]"
|
|
448
|
+
`${options.padding + chalk.yellow(" arrayDimension : ")} [${this.arrayDimensions.join(",").toString()} ]`
|
|
468
449
|
);
|
|
469
450
|
}
|
|
470
451
|
}
|
|
@@ -636,15 +617,15 @@ function _clone_collection_new(
|
|
|
636
617
|
// it may happen that the xml nodeset2 file was malformed
|
|
637
618
|
|
|
638
619
|
// c8 ignore next
|
|
639
|
-
if (typeof
|
|
620
|
+
if (typeof node.clone !== "function") {
|
|
640
621
|
// tslint:disable-next-line:no-console
|
|
641
622
|
warningLog(
|
|
642
623
|
chalk.red("Warning : cannot clone node ") +
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
624
|
+
fullPath2(node) +
|
|
625
|
+
" of class " +
|
|
626
|
+
NodeClass[node.nodeClass].toString() +
|
|
627
|
+
" while cloning " +
|
|
628
|
+
fullPath2(newParent)
|
|
648
629
|
);
|
|
649
630
|
continue;
|
|
650
631
|
}
|
|
@@ -660,7 +641,7 @@ function _clone_collection_new(
|
|
|
660
641
|
doTrace && traceLog(extraInfo.pad(), "skipping optional that doesn't appear in the filter", fullPath2(node));
|
|
661
642
|
continue; // skip this node
|
|
662
643
|
}
|
|
663
|
-
const key = newParent.nodeId.toString()
|
|
644
|
+
const key = `${newParent.nodeId.toString()}(${newParent.browseName.toString()})/${node.browseName.toString()}`;
|
|
664
645
|
if (browseNameMap?.has(key)) {
|
|
665
646
|
_clone_children_on_template(nodeToClone, newParent, node, copyAlsoModellingRules, optionalFilter, extraInfo);
|
|
666
647
|
doTrace &&
|
|
@@ -743,7 +724,7 @@ function _clone_collection_new(
|
|
|
743
724
|
extraInfo.pad(),
|
|
744
725
|
" cloned nodeId",
|
|
745
726
|
clonedNode.nodeId.toString(),
|
|
746
|
-
fullPath2(clonedNode)
|
|
727
|
+
`${fullPath2(clonedNode)}`
|
|
747
728
|
);
|
|
748
729
|
|
|
749
730
|
extraInfo.level++;
|
|
@@ -839,7 +820,7 @@ function _extractInterfaces2(typeDefinitionNode: UAObjectType | UAVariableType,
|
|
|
839
820
|
|
|
840
821
|
function _cloneInterface(
|
|
841
822
|
nodeToClone: UAObject | UAVariable | UAMethod | UAObjectType | UAVariableType,
|
|
842
|
-
|
|
823
|
+
_newParent: BaseNode,
|
|
843
824
|
node: UAObject | UAVariable | UAMethod,
|
|
844
825
|
optionalFilter: CloneFilter,
|
|
845
826
|
extraInfo: CloneExtraInfo,
|
|
@@ -884,8 +865,8 @@ function _cloneInterface(
|
|
|
884
865
|
traceLog(
|
|
885
866
|
extraInfo.pad(),
|
|
886
867
|
chalk.magentaBright(" interface ", iface.browseName.toString()),
|
|
887
|
-
|
|
888
|
-
aggregates.map((r) => r.toString({ addressSpace })).join(
|
|
868
|
+
`\n${extraInfo?.pad()}`,
|
|
869
|
+
aggregates.map((r) => r.toString({ addressSpace })).join(`\n${extraInfo?.pad()}`)
|
|
889
870
|
);
|
|
890
871
|
_clone_collection_new(nodeToClone, node, aggregates, false, localFilter, extraInfo, browseNameMap);
|
|
891
872
|
}
|
|
@@ -919,6 +900,42 @@ function __clone_children_references(
|
|
|
919
900
|
_clone_collection_new(nodeToClone, newParent, aggregatesRef, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap);
|
|
920
901
|
}
|
|
921
902
|
|
|
903
|
+
function __clone_interfaces_related_references(
|
|
904
|
+
nodeToClone: UAObject | UAVariable | UAMethod | UAObjectType | UAVariableType,
|
|
905
|
+
newParent: UAObject | UAVariable | UAMethod,
|
|
906
|
+
copyAlsoModellingRules: boolean,
|
|
907
|
+
optionalFilter: CloneFilter,
|
|
908
|
+
extraInfo: CloneExtraInfo,
|
|
909
|
+
browseNameMap: Set<string>
|
|
910
|
+
): void {
|
|
911
|
+
// find all references that derives from the HasInterface
|
|
912
|
+
const hasInterfaceRef = nodeToClone.findReferencesEx("HasInterface", BrowseDirection.Forward);
|
|
913
|
+
if (hasInterfaceRef.length === 0) return;
|
|
914
|
+
for (const ref of hasInterfaceRef) {
|
|
915
|
+
let typeDefinitionNode = ReferenceImpl.resolveReferenceNode(nodeToClone.addressSpace, ref) as UAObjectType | null;
|
|
916
|
+
if (!typeDefinitionNode) {
|
|
917
|
+
continue;
|
|
918
|
+
}
|
|
919
|
+
if (doTrace) traceLog(extraInfo?.pad(), chalk.blueBright(newParent.browseName.toString(), "-----> Exploring interface ", typeDefinitionNode.browseName.toString()));
|
|
920
|
+
while (typeDefinitionNode) {
|
|
921
|
+
// c8 ignore next
|
|
922
|
+
doTrace &&
|
|
923
|
+
traceLog(
|
|
924
|
+
extraInfo?.pad(),
|
|
925
|
+
chalk.blueBright(newParent.browseName.toString(), "-----> Exploring ", typeDefinitionNode.browseName.toString())
|
|
926
|
+
);
|
|
927
|
+
__clone_children_references(
|
|
928
|
+
typeDefinitionNode,
|
|
929
|
+
newParent,
|
|
930
|
+
copyAlsoModellingRules,
|
|
931
|
+
optionalFilter,
|
|
932
|
+
extraInfo,
|
|
933
|
+
browseNameMap
|
|
934
|
+
);
|
|
935
|
+
typeDefinitionNode = typeDefinitionNode.subtypeOfObj;
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
}
|
|
922
939
|
export function _clone_hierarchical_references(
|
|
923
940
|
nodeToClone: UAObject | UAVariable | UAMethod | UAObjectType | UAVariableType,
|
|
924
941
|
newParent: UAObject | UAVariable | UAMethod,
|
|
@@ -929,6 +946,7 @@ export function _clone_hierarchical_references(
|
|
|
929
946
|
) {
|
|
930
947
|
__clone_children_references(nodeToClone, newParent, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap);
|
|
931
948
|
__clone_organizes_references(nodeToClone, newParent, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap);
|
|
949
|
+
// __clone_interfaces_related_references(nodeToClone, newParent, copyAlsoModellingRules, optionalFilter, extraInfo, browseNameMap);
|
|
932
950
|
}
|
|
933
951
|
export function _clone_non_hierarchical_references(
|
|
934
952
|
nodeToClone: UAObject | UAVariable | UAMethod | UAObjectType | UAVariableType,
|
|
@@ -953,9 +971,9 @@ export function _clone_non_hierarchical_references(
|
|
|
953
971
|
|
|
954
972
|
* @private
|
|
955
973
|
*/
|
|
956
|
-
export function _clone<T extends UAObject | UAVariable | UAMethod>(
|
|
974
|
+
export function _clone<T extends UAObject | UAVariable | UAMethod, O>(
|
|
957
975
|
originalNode: T,
|
|
958
|
-
Constructor: new (options:
|
|
976
|
+
Constructor: new (options: O) => T,
|
|
959
977
|
options: CloneOptions,
|
|
960
978
|
optionalFilter: CloneFilter,
|
|
961
979
|
extraInfo: CloneExtraInfo
|
|
@@ -965,9 +983,8 @@ export function _clone<T extends UAObject | UAVariable | UAMethod>(
|
|
|
965
983
|
assert(
|
|
966
984
|
!extraInfo || (extraInfo !== null && typeof extraInfo === "object" && typeof extraInfo.registerClonedObject === "function")
|
|
967
985
|
);
|
|
968
|
-
assert(!(originalNode as any).subtypeOf, "We do not do cloning of Type yet");
|
|
969
986
|
const namespace = options.namespace;
|
|
970
|
-
const constructorOptions
|
|
987
|
+
const constructorOptions = {
|
|
971
988
|
...options,
|
|
972
989
|
addressSpace: namespace.addressSpace,
|
|
973
990
|
browseName: originalNode.browseName,
|
|
@@ -1010,7 +1027,7 @@ export function _clone<T extends UAObject | UAVariable | UAMethod>(
|
|
|
1010
1027
|
|
|
1011
1028
|
assert(constructorOptions.nodeId instanceof NodeId);
|
|
1012
1029
|
|
|
1013
|
-
const clonedNode = new Constructor(constructorOptions);
|
|
1030
|
+
const clonedNode = new Constructor(constructorOptions as unknown as O);
|
|
1014
1031
|
(originalNode.addressSpace as AddressSpacePrivate)._register(clonedNode);
|
|
1015
1032
|
|
|
1016
1033
|
extraInfo.registerClonedObject({
|
|
@@ -1029,7 +1046,7 @@ export function _clone<T extends UAObject | UAVariable | UAMethod>(
|
|
|
1029
1046
|
originalNode,
|
|
1030
1047
|
clonedNode,
|
|
1031
1048
|
options.copyAlsoModellingRules,
|
|
1032
|
-
newFilter
|
|
1049
|
+
newFilter,
|
|
1033
1050
|
extraInfo,
|
|
1034
1051
|
browseNameMap
|
|
1035
1052
|
);
|
|
@@ -1065,7 +1082,6 @@ export function _clone<T extends UAObject | UAVariable | UAMethod>(
|
|
|
1065
1082
|
}
|
|
1066
1083
|
|
|
1067
1084
|
extraInfo.popContext();
|
|
1068
|
-
|
|
1069
1085
|
}
|
|
1070
1086
|
_clone_non_hierarchical_references(
|
|
1071
1087
|
originalNode,
|
|
@@ -1082,11 +1098,10 @@ export function _clone<T extends UAObject | UAVariable | UAMethod>(
|
|
|
1082
1098
|
return clonedNode;
|
|
1083
1099
|
}
|
|
1084
1100
|
|
|
1085
|
-
function _add(_childByNameMap: HierarchicalIndexMap, reference: UAReferenceWithNodeRef)
|
|
1086
|
-
|
|
1087
|
-
assert(reference.node);// const targetNode = ReferenceImpl.resolveReferenceNode(addressSpace, reference);
|
|
1101
|
+
function _add(_childByNameMap: HierarchicalIndexMap, reference: UAReferenceWithNodeRef) {
|
|
1102
|
+
assert(reference.node); // const targetNode = ReferenceImpl.resolveReferenceNode(addressSpace, reference);
|
|
1088
1103
|
const targetNode = reference.node;
|
|
1089
|
-
const hash = targetNode.browseName
|
|
1104
|
+
const hash = targetNode.browseName?.name || "";
|
|
1090
1105
|
const existing = _childByNameMap.get(hash);
|
|
1091
1106
|
if (existing) {
|
|
1092
1107
|
if (Array.isArray(existing)) {
|
|
@@ -1100,18 +1115,24 @@ function _add(_childByNameMap: HierarchicalIndexMap, reference: UAReferenceWithN
|
|
|
1100
1115
|
}
|
|
1101
1116
|
|
|
1102
1117
|
function sameRef(a: UAReference, b: UAReference) {
|
|
1103
|
-
if (a.isForward
|
|
1118
|
+
if (a.isForward !== b.isForward) return false;
|
|
1104
1119
|
if (!sameNodeId(a.nodeId, b.nodeId)) return false;
|
|
1105
1120
|
if (!sameNodeId(a.referenceType, b.referenceType)) return false;
|
|
1106
1121
|
return true;
|
|
1107
1122
|
}
|
|
1108
1123
|
function _remove(_childByNameMap: HierarchicalIndexMap, reference: UAReferenceWithNodeRef) {
|
|
1109
|
-
|
|
1110
1124
|
const target = reference.node;
|
|
1111
1125
|
const hash = target.browseName.name || "";
|
|
1112
1126
|
const existing = _childByNameMap.get(hash);
|
|
1113
1127
|
if (Array.isArray(existing)) {
|
|
1114
|
-
existing.filter(r
|
|
1128
|
+
const remaining = existing.filter((r) => !sameRef(r, reference));
|
|
1129
|
+
if (remaining.length === 0) {
|
|
1130
|
+
_childByNameMap.delete(hash);
|
|
1131
|
+
} else if (remaining.length === 1) {
|
|
1132
|
+
_childByNameMap.set(hash, remaining[0]);
|
|
1133
|
+
} else {
|
|
1134
|
+
_childByNameMap.set(hash, remaining);
|
|
1135
|
+
}
|
|
1115
1136
|
} else {
|
|
1116
1137
|
_childByNameMap.delete(hash);
|
|
1117
1138
|
}
|
|
@@ -1125,9 +1146,11 @@ export function _handle_HierarchicalReference(node: BaseNode, reference: UARefer
|
|
|
1125
1146
|
|
|
1126
1147
|
if (referenceType) {
|
|
1127
1148
|
const HierarchicalReferencesType = addressSpace.findReferenceType("HierarchicalReferences");
|
|
1128
|
-
if (
|
|
1149
|
+
if (!HierarchicalReferencesType) return;
|
|
1150
|
+
|
|
1151
|
+
if (referenceType.isSubtypeOf(HierarchicalReferencesType)) {
|
|
1129
1152
|
ReferenceImpl.resolveReferenceNode(addressSpace, reference);
|
|
1130
|
-
_add(_private._childByNameMap, reference as UAReferenceWithNodeRef)
|
|
1153
|
+
_add(_private._childByNameMap, reference as UAReferenceWithNodeRef);
|
|
1131
1154
|
}
|
|
1132
1155
|
}
|
|
1133
1156
|
}
|
|
@@ -1139,13 +1162,12 @@ export function _get_HierarchicalReference(node: BaseNode): HierarchicalIndexMap
|
|
|
1139
1162
|
if (!_private._childByNameMap) {
|
|
1140
1163
|
_private._childByNameMap = new Map();
|
|
1141
1164
|
const references = node.findReferencesEx("HierarchicalReferences");
|
|
1142
|
-
for (
|
|
1165
|
+
for (const reference of references) {
|
|
1143
1166
|
ReferenceImpl.resolveReferenceNode(addressSpace, reference);
|
|
1144
1167
|
_add(_private._childByNameMap, reference as UAReferenceWithNodeRef);
|
|
1145
1168
|
}
|
|
1146
1169
|
}
|
|
1147
1170
|
return _private._childByNameMap;
|
|
1148
|
-
|
|
1149
1171
|
}
|
|
1150
1172
|
export function _remove_HierarchicalReference(node: BaseNodeImpl, reference: UAReference) {
|
|
1151
1173
|
const _private = BaseNode_getPrivate(node);
|
|
@@ -1155,8 +1177,7 @@ export function _remove_HierarchicalReference(node: BaseNodeImpl, reference: UAR
|
|
|
1155
1177
|
|
|
1156
1178
|
if (referenceType) {
|
|
1157
1179
|
const HierarchicalReferencesType = addressSpace.findReferenceType("HierarchicalReferences");
|
|
1158
|
-
if (referenceType.isSubtypeOf(HierarchicalReferencesType
|
|
1159
|
-
|
|
1180
|
+
if (HierarchicalReferencesType && referenceType.isSubtypeOf(HierarchicalReferencesType)) {
|
|
1160
1181
|
ReferenceImpl.resolveReferenceNode(addressSpace, reference);
|
|
1161
1182
|
_remove(_private._childByNameMap, reference as UAReferenceWithNodeRef);
|
|
1162
1183
|
}
|
|
@@ -1170,32 +1191,37 @@ function _makeReferenceDescription(addressSpace: IAddressSpace, reference: UARef
|
|
|
1170
1191
|
const referenceTypeId = ReferenceImpl.resolveReferenceType(addressSpace, reference).nodeId;
|
|
1171
1192
|
assert(referenceTypeId instanceof NodeId);
|
|
1172
1193
|
|
|
1173
|
-
const obj = ReferenceImpl.resolveReferenceNode(addressSpace, reference)
|
|
1194
|
+
const obj = ReferenceImpl.resolveReferenceNode(addressSpace, reference);
|
|
1174
1195
|
|
|
1175
|
-
let data:
|
|
1196
|
+
let data: ReferenceDescriptionOptions = {};
|
|
1176
1197
|
|
|
1177
1198
|
if (!obj) {
|
|
1178
1199
|
// cannot find reference node
|
|
1179
1200
|
data = {
|
|
1180
1201
|
isForward,
|
|
1181
|
-
nodeId: reference.nodeId,
|
|
1202
|
+
nodeId: reference.nodeId as ExpandedNodeId,
|
|
1182
1203
|
referenceTypeId: resultMask & ResultMask.ReferenceType ? referenceTypeId : null,
|
|
1183
|
-
typeDefinition:
|
|
1204
|
+
typeDefinition: undefined
|
|
1184
1205
|
};
|
|
1185
1206
|
} else {
|
|
1207
|
+
const obj2 = obj;
|
|
1208
|
+
|
|
1209
|
+
const objOrVar = (obj2.nodeClass === NodeClass.Object || obj2.nodeClass === NodeClass.Variable )
|
|
1210
|
+
? (obj2 as UAVariable | UAObject) : null;
|
|
1211
|
+
|
|
1186
1212
|
assert(reference.nodeId, " obj.nodeId");
|
|
1187
1213
|
data = {
|
|
1188
1214
|
browseName: resultMask & ResultMask.BrowseName ? coerceQualifiedName(obj.browseName) : null,
|
|
1189
1215
|
displayName: resultMask & ResultMask.DisplayName ? coerceLocalizedText(obj.displayName[0]) : null,
|
|
1190
1216
|
isForward: resultMask & ResultMask.IsForward ? isForward : false,
|
|
1191
1217
|
nodeClass: resultMask & ResultMask.NodeClass ? obj.nodeClass : NodeClass.Unspecified,
|
|
1192
|
-
nodeId: obj.nodeId,
|
|
1218
|
+
nodeId: obj.nodeId as ExpandedNodeId,
|
|
1193
1219
|
referenceTypeId: resultMask & ResultMask.ReferenceType ? referenceTypeId : null,
|
|
1194
|
-
typeDefinition: resultMask & ResultMask.TypeDefinition ?
|
|
1220
|
+
typeDefinition: resultMask & ResultMask.TypeDefinition ? (objOrVar?.typeDefinition as ExpandedNodeId) : undefined
|
|
1195
1221
|
};
|
|
1196
1222
|
}
|
|
1197
1223
|
if (data.typeDefinition === null) {
|
|
1198
|
-
data.typeDefinition =
|
|
1224
|
+
data.typeDefinition = ExpandedNodeId.nullNodeId as ExpandedNodeId;
|
|
1199
1225
|
}
|
|
1200
1226
|
const referenceDescription = new ReferenceDescription(data);
|
|
1201
1227
|
return referenceDescription;
|
|
@@ -1240,16 +1266,14 @@ export function BaseNode_add_backward_reference(this: BaseNodeImpl, reference: U
|
|
|
1240
1266
|
warningLog(" Warning !", this.browseName.toString());
|
|
1241
1267
|
warningLog(" ", reference.toString(opts));
|
|
1242
1268
|
warningLog(" already found in ===>");
|
|
1243
|
-
warningLog(
|
|
1244
|
-
[..._private._back_referenceIdx.values()].map((c: UAReference) => c.toString(opts)).join("\n")
|
|
1245
|
-
);
|
|
1269
|
+
warningLog([..._private._back_referenceIdx.values()].map((c: UAReference) => c.toString(opts)).join("\n"));
|
|
1246
1270
|
// tslint:disable-next-line:no-console
|
|
1247
1271
|
warningLog("===>");
|
|
1248
1272
|
throw new Error("reference exists already in _back_references");
|
|
1249
1273
|
}
|
|
1250
1274
|
|
|
1251
1275
|
if (!getReferenceType(reference)) {
|
|
1252
|
-
const
|
|
1276
|
+
const _stop_here = 1;
|
|
1253
1277
|
}
|
|
1254
1278
|
// assert(reference._referenceType instanceof ReferenceType);
|
|
1255
1279
|
_private._back_referenceIdx.set(h, reference);
|
|
@@ -30,7 +30,7 @@ export function checkValueRankCompatibility(actualValueRank: number, baseTypeVal
|
|
|
30
30
|
if (valueRank < 0) {
|
|
31
31
|
return `InvalidValueRank(${valueRank})`;
|
|
32
32
|
}
|
|
33
|
-
return
|
|
33
|
+
return `${valueRank}`;
|
|
34
34
|
}
|
|
35
35
|
if (actualValueRank < 0) {
|
|
36
36
|
if (actualValueRank !== Scalar && actualValueRank !== AnyDimension && actualValueRank !== ScalarOrOneDimension) {
|