node-opcua-address-space 2.98.2 → 2.100.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.
- package/dist/source/loader/load_nodeset2.js +3 -4
- package/dist/source/loader/load_nodeset2.js.map +1 -1
- package/dist/src/base_node_private.d.ts +1 -1
- package/dist/src/base_node_private.js +52 -45
- package/dist/src/base_node_private.js.map +1 -1
- package/dist/src/ua_method_impl.js +1 -1
- package/dist/src/ua_method_impl.js.map +1 -1
- package/dist/src/ua_object_impl.js +2 -2
- package/dist/src/ua_object_impl.js.map +1 -1
- package/dist/src/ua_reference_type_impl.d.ts +1 -1
- package/dist/src/ua_variable_impl.d.ts +2 -2
- package/dist/src/ua_variable_impl.js +37 -21
- package/dist/src/ua_variable_impl.js.map +1 -1
- package/dist/src/ua_variable_type_impl.js +5 -215
- package/dist/src/ua_variable_type_impl.js.map +1 -1
- package/dist/tsconfig_common.tsbuildinfo +1 -1
- package/distHelpers/get_address_space_fixture.js +9 -1
- package/distHelpers/get_address_space_fixture.js.map +1 -1
- package/distHelpers/get_mini_address_space.d.ts +1 -1
- package/distHelpers/get_mini_address_space.js +1 -1
- package/distHelpers/get_mini_address_space.js.map +1 -1
- package/nodesets/mini.Nodeset2.xml +4736 -0
- package/package.json +33 -31
- package/source/loader/load_nodeset2.ts +4 -5
- package/source_nodejs/generate_address_space.ts +60 -0
- package/source_nodejs/index.ts +1 -0
- package/src/base_node_private.ts +111 -59
- package/src/ua_method_impl.ts +3 -3
- package/src/ua_object_impl.ts +5 -5
- package/src/ua_variable_impl.ts +84 -68
- package/src/ua_variable_type_impl.ts +18 -278
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-opcua-address-space",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.100.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,36 +22,36 @@
|
|
|
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.
|
|
25
|
+
"node-opcua-address-space-base": "2.100.0",
|
|
26
26
|
"node-opcua-assert": "2.98.1",
|
|
27
|
-
"node-opcua-basic-types": "2.
|
|
27
|
+
"node-opcua-basic-types": "2.99.0",
|
|
28
28
|
"node-opcua-binary-stream": "2.98.1",
|
|
29
|
-
"node-opcua-client-dynamic-extension-object": "2.
|
|
29
|
+
"node-opcua-client-dynamic-extension-object": "2.99.0",
|
|
30
30
|
"node-opcua-constants": "2.98.1",
|
|
31
31
|
"node-opcua-crypto": "^2.1.2",
|
|
32
|
-
"node-opcua-data-access": "2.
|
|
33
|
-
"node-opcua-data-model": "2.
|
|
34
|
-
"node-opcua-data-value": "2.
|
|
35
|
-
"node-opcua-date-time": "2.
|
|
36
|
-
"node-opcua-debug": "2.
|
|
32
|
+
"node-opcua-data-access": "2.99.0",
|
|
33
|
+
"node-opcua-data-model": "2.99.0",
|
|
34
|
+
"node-opcua-data-value": "2.99.0",
|
|
35
|
+
"node-opcua-date-time": "2.99.0",
|
|
36
|
+
"node-opcua-debug": "2.99.0",
|
|
37
37
|
"node-opcua-enum": "2.98.1",
|
|
38
|
-
"node-opcua-extension-object": "2.
|
|
39
|
-
"node-opcua-factory": "2.
|
|
40
|
-
"node-opcua-nodeid": "2.
|
|
41
|
-
"node-opcua-nodeset-ua": "2.
|
|
42
|
-
"node-opcua-numeric-range": "2.
|
|
43
|
-
"node-opcua-object-registry": "2.
|
|
44
|
-
"node-opcua-pseudo-session": "2.
|
|
45
|
-
"node-opcua-service-browse": "2.
|
|
46
|
-
"node-opcua-service-call": "2.
|
|
47
|
-
"node-opcua-service-history": "2.
|
|
48
|
-
"node-opcua-service-translate-browse-path": "2.
|
|
49
|
-
"node-opcua-service-write": "2.
|
|
38
|
+
"node-opcua-extension-object": "2.99.0",
|
|
39
|
+
"node-opcua-factory": "2.99.0",
|
|
40
|
+
"node-opcua-nodeid": "2.99.0",
|
|
41
|
+
"node-opcua-nodeset-ua": "2.100.0",
|
|
42
|
+
"node-opcua-numeric-range": "2.99.0",
|
|
43
|
+
"node-opcua-object-registry": "2.99.0",
|
|
44
|
+
"node-opcua-pseudo-session": "2.99.0",
|
|
45
|
+
"node-opcua-service-browse": "2.99.0",
|
|
46
|
+
"node-opcua-service-call": "2.99.0",
|
|
47
|
+
"node-opcua-service-history": "2.99.0",
|
|
48
|
+
"node-opcua-service-translate-browse-path": "2.99.0",
|
|
49
|
+
"node-opcua-service-write": "2.99.0",
|
|
50
50
|
"node-opcua-status-code": "2.98.1",
|
|
51
|
-
"node-opcua-types": "2.
|
|
51
|
+
"node-opcua-types": "2.99.0",
|
|
52
52
|
"node-opcua-utils": "2.98.1",
|
|
53
|
-
"node-opcua-variant": "2.
|
|
54
|
-
"node-opcua-xml2json": "2.
|
|
53
|
+
"node-opcua-variant": "2.99.0",
|
|
54
|
+
"node-opcua-xml2json": "2.99.0",
|
|
55
55
|
"semver": "^7.3.8",
|
|
56
56
|
"set-prototype-of": "^1.0.0",
|
|
57
57
|
"thenify": "^3.3.1",
|
|
@@ -60,11 +60,11 @@
|
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"mocha": "^10.2.0",
|
|
62
62
|
"node-opcua-benchmarker": "2.98.1",
|
|
63
|
-
"node-opcua-leak-detector": "2.
|
|
64
|
-
"node-opcua-nodesets": "2.
|
|
65
|
-
"node-opcua-packet-analyzer": "2.
|
|
66
|
-
"node-opcua-service-filter": "2.
|
|
67
|
-
"node-opcua-test-fixtures": "2.
|
|
63
|
+
"node-opcua-leak-detector": "2.99.0",
|
|
64
|
+
"node-opcua-nodesets": "2.99.0",
|
|
65
|
+
"node-opcua-packet-analyzer": "2.99.0",
|
|
66
|
+
"node-opcua-service-filter": "2.100.0",
|
|
67
|
+
"node-opcua-test-fixtures": "2.99.0",
|
|
68
68
|
"should": "^13.2.3",
|
|
69
69
|
"sinon": "^15.0.3",
|
|
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": "
|
|
87
|
+
"gitHead": "e143ff72418bb3db8c0a2cb8d4b7e54a90521a73",
|
|
88
88
|
"files": [
|
|
89
89
|
"dist",
|
|
90
90
|
"distHelpers",
|
|
@@ -93,7 +93,9 @@
|
|
|
93
93
|
"src",
|
|
94
94
|
"nodeJS.d.ts",
|
|
95
95
|
"nodeJS.js",
|
|
96
|
+
"nodesets",
|
|
96
97
|
"testHelpers.js",
|
|
97
|
-
"testHelpers.d.ts"
|
|
98
|
+
"testHelpers.d.ts",
|
|
99
|
+
"source_nodejs"
|
|
98
100
|
]
|
|
99
101
|
}
|
|
@@ -261,9 +261,9 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
|
|
|
261
261
|
// istanbul ignore next
|
|
262
262
|
if (!existingNamespace) {
|
|
263
263
|
errorLog(
|
|
264
|
-
"Please ensure that the required namespace
|
|
264
|
+
"Please ensure that the required namespace",
|
|
265
265
|
requiredModel.modelUri,
|
|
266
|
-
"is loaded
|
|
266
|
+
"is loaded first when loading",
|
|
267
267
|
model.modelUri
|
|
268
268
|
);
|
|
269
269
|
throw new Error("LoadNodeSet : Cannot find namespace for " + requiredModel.modelUri);
|
|
@@ -271,8 +271,7 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
|
|
|
271
271
|
/**
|
|
272
272
|
* from https://reference.opcfoundation.org/Core/docs/Part6/F.2/
|
|
273
273
|
* The version of the model defined in the UANodeSet.
|
|
274
|
-
* This is a human
|
|
275
|
-
*
|
|
274
|
+
* This is a human-readable string and not intended for programmatic comparisons.
|
|
276
275
|
*/
|
|
277
276
|
const isLowerVersion = (existingVersion: string, requiredVersion: string): boolean => {
|
|
278
277
|
const existingSemver = makeSemverCompatible(existingVersion);
|
|
@@ -294,7 +293,7 @@ function makeNodeSetParserEngine(addressSpace: IAddressSpace, options: NodeSetLo
|
|
|
294
293
|
errorLog(
|
|
295
294
|
"Expecting ",
|
|
296
295
|
requiredModel.modelUri,
|
|
297
|
-
" with
|
|
296
|
+
" with publicationDate at least ",
|
|
298
297
|
requiredModel.publicationDate.toUTCString(),
|
|
299
298
|
" but namespace publicationDate is ",
|
|
300
299
|
existingNamespace.publicationDate.toUTCString()
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import { callbackify } from "util";
|
|
3
|
+
|
|
4
|
+
import { checkDebugFlag, make_debugLog, make_errorLog } from "node-opcua-debug";
|
|
5
|
+
import { IAddressSpace } from "node-opcua-address-space-base";
|
|
6
|
+
|
|
7
|
+
import { generateAddressSpaceRaw } from "..";
|
|
8
|
+
import { NodeSetLoaderOptions } from "../source/interfaces/nodeset_loader_options";
|
|
9
|
+
|
|
10
|
+
const doDebug = checkDebugFlag(__filename);
|
|
11
|
+
const debugLog = make_debugLog(__filename);
|
|
12
|
+
const errorLog = make_errorLog(__filename);
|
|
13
|
+
|
|
14
|
+
export async function readNodeSet2XmlFile(xmlFile: string): Promise<string> {
|
|
15
|
+
// istanbul ignore next
|
|
16
|
+
if (!fs.existsSync(xmlFile)) {
|
|
17
|
+
const msg = "[NODE-OPCUA-E02] generateAddressSpace : cannot find nodeset2 xml file at " + xmlFile;
|
|
18
|
+
errorLog(msg);
|
|
19
|
+
throw new Error(msg);
|
|
20
|
+
}
|
|
21
|
+
debugLog(" parsing ", xmlFile);
|
|
22
|
+
const xmlData = await fs.promises.readFile(xmlFile, "utf-8");
|
|
23
|
+
return xmlData;
|
|
24
|
+
}
|
|
25
|
+
export function generateAddressSpace(
|
|
26
|
+
addressSpace: IAddressSpace,
|
|
27
|
+
xmlFiles: string | string[],
|
|
28
|
+
callback: (err?: Error) => void
|
|
29
|
+
): void;
|
|
30
|
+
export function generateAddressSpace(
|
|
31
|
+
addressSpace: IAddressSpace,
|
|
32
|
+
xmlFiles: string | string[],
|
|
33
|
+
options: NodeSetLoaderOptions | undefined,
|
|
34
|
+
callback: (err?: Error) => void
|
|
35
|
+
): void;
|
|
36
|
+
export function generateAddressSpace(
|
|
37
|
+
addressSpace: IAddressSpace,
|
|
38
|
+
xmlFiles: string | string[],
|
|
39
|
+
options?: NodeSetLoaderOptions
|
|
40
|
+
): Promise<void>;
|
|
41
|
+
export function generateAddressSpace(
|
|
42
|
+
... args: any[]
|
|
43
|
+
): any {
|
|
44
|
+
const addressSpace = args[0] as IAddressSpace;
|
|
45
|
+
const xmlFiles = args[1] as string | string[];
|
|
46
|
+
if (args.length === 4) {
|
|
47
|
+
const options = args[2] as NodeSetLoaderOptions | undefined;
|
|
48
|
+
const callback = args[3] as (err?: Error) => void;
|
|
49
|
+
callbackify(generateAddressSpaceRaw)(addressSpace, xmlFiles, readNodeSet2XmlFile, options ||{}, callback!);
|
|
50
|
+
} else {
|
|
51
|
+
const options = {};
|
|
52
|
+
const callback = args[2] as (err?: Error) => void;
|
|
53
|
+
callbackify(generateAddressSpaceRaw)(addressSpace, xmlFiles, readNodeSet2XmlFile, options, callback!);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// tslint:disable:no-var-requires
|
|
58
|
+
// tslint:disable:max-line-length
|
|
59
|
+
const thenify = require("thenify");
|
|
60
|
+
(module.exports as any).generateAddressSpace = thenify.withCallback((module.exports as any).generateAddressSpace);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./generate_address_space";
|
package/src/base_node_private.ts
CHANGED
|
@@ -31,7 +31,8 @@ import {
|
|
|
31
31
|
UAVariableType,
|
|
32
32
|
ISessionContext,
|
|
33
33
|
UAReference,
|
|
34
|
-
CloneOptions
|
|
34
|
+
CloneOptions,
|
|
35
|
+
CloneHelper
|
|
35
36
|
} from "node-opcua-address-space-base";
|
|
36
37
|
import { DataValue } from "node-opcua-data-value";
|
|
37
38
|
import { ObjectTypeIds, VariableTypeIds } from "node-opcua-constants";
|
|
@@ -458,16 +459,6 @@ export function VariableOrVariableType_toString(this: UAVariableType | UAVariabl
|
|
|
458
459
|
}
|
|
459
460
|
}
|
|
460
461
|
|
|
461
|
-
const defaultExtraInfo = {
|
|
462
|
-
level: 0,
|
|
463
|
-
pad(): string {
|
|
464
|
-
return "";
|
|
465
|
-
},
|
|
466
|
-
registerClonedObject(node: BaseNode, node1: BaseNode): void {
|
|
467
|
-
/** */
|
|
468
|
-
}
|
|
469
|
-
};
|
|
470
|
-
|
|
471
462
|
/**
|
|
472
463
|
*
|
|
473
464
|
*
|
|
@@ -589,8 +580,8 @@ function _clone_children_on_template(
|
|
|
589
580
|
nodeId: newParentChild.nodeId
|
|
590
581
|
});
|
|
591
582
|
} else {
|
|
592
|
-
const
|
|
593
|
-
extraInfo.registerClonedObject(
|
|
583
|
+
const clonedGrandChild = grandChild.clone(options, optionalFilter, extraInfo);
|
|
584
|
+
extraInfo.registerClonedObject(clonedGrandChild, grandChild);
|
|
594
585
|
}
|
|
595
586
|
}
|
|
596
587
|
}
|
|
@@ -612,7 +603,7 @@ function _clone_collection_new(
|
|
|
612
603
|
browseNameMap: Set<string>
|
|
613
604
|
): void {
|
|
614
605
|
const namespace = newParent.namespace;
|
|
615
|
-
extraInfo = extraInfo ||
|
|
606
|
+
extraInfo = extraInfo || new CloneHelper();
|
|
616
607
|
const addressSpace = newParent.addressSpace;
|
|
617
608
|
assert(!optionalFilter || (typeof optionalFilter.shouldKeep === "function" && typeof optionalFilter.filterFor === "function"));
|
|
618
609
|
|
|
@@ -664,30 +655,71 @@ function _clone_collection_new(
|
|
|
664
655
|
copyAlsoModellingRules
|
|
665
656
|
};
|
|
666
657
|
|
|
667
|
-
doTrace &&
|
|
668
|
-
traceLog(
|
|
669
|
-
extraInfo.pad(),
|
|
670
|
-
"cloning => ",
|
|
671
|
-
reference.referenceType.toString({ addressSpace }),
|
|
672
|
-
"=>",
|
|
673
|
-
node.browseName.toString(),
|
|
674
|
-
chalk.magentaBright(node.typeDefinitionObj?.browseName.toString())
|
|
675
|
-
);
|
|
676
|
-
|
|
677
|
-
extraInfo.level += 4;
|
|
678
|
-
|
|
679
658
|
const alreadyCloned = extraInfo.getCloned(node);
|
|
680
659
|
if (alreadyCloned) {
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
660
|
+
// instabul ignore next
|
|
661
|
+
doTrace &&
|
|
662
|
+
traceLog(
|
|
663
|
+
extraInfo.pad(),
|
|
664
|
+
"node ",
|
|
665
|
+
node.browseName.toString(),
|
|
666
|
+
node.nodeId.toString(),
|
|
667
|
+
"already cloned as",
|
|
668
|
+
alreadyCloned.nodeId.toString()
|
|
669
|
+
);
|
|
670
|
+
|
|
671
|
+
const hasReference =
|
|
672
|
+
alreadyCloned.findReferencesExAsObject(reference.referenceType, BrowseDirection.Inverse).length > 0;
|
|
673
|
+
if (!hasReference) {
|
|
674
|
+
alreadyCloned.addReference({
|
|
675
|
+
referenceType: reference.referenceType,
|
|
676
|
+
isForward: false,
|
|
677
|
+
nodeId: newParent.nodeId
|
|
678
|
+
});
|
|
679
|
+
} else {
|
|
680
|
+
doTrace &&
|
|
681
|
+
traceLog(
|
|
682
|
+
extraInfo.pad(),
|
|
683
|
+
"reference to node ",
|
|
684
|
+
alreadyCloned.browseName.toString(),
|
|
685
|
+
alreadyCloned.nodeId.toString(),
|
|
686
|
+
" already exists !"
|
|
687
|
+
);
|
|
688
|
+
}
|
|
686
689
|
} else {
|
|
687
|
-
|
|
690
|
+
doTrace &&
|
|
691
|
+
traceLog(
|
|
692
|
+
extraInfo.pad(),
|
|
693
|
+
"cloning => ",
|
|
694
|
+
reference.referenceType.toString({ addressSpace }),
|
|
695
|
+
"=>",
|
|
696
|
+
node.browseName.toString(),
|
|
697
|
+
node.nodeId.toString(),
|
|
698
|
+
chalk.magentaBright(node.typeDefinitionObj?.browseName.toString())
|
|
699
|
+
);
|
|
700
|
+
|
|
701
|
+
extraInfo.level += 1;
|
|
702
|
+
const clonedNode = node.clone(options, optionalFilter, extraInfo);
|
|
703
|
+
assert(extraInfo.getCloned(node));
|
|
688
704
|
|
|
689
|
-
extraInfo.level -=
|
|
690
|
-
|
|
705
|
+
extraInfo.level -= 1;
|
|
706
|
+
|
|
707
|
+
// instabul ignore next
|
|
708
|
+
doTrace &&
|
|
709
|
+
traceLog(
|
|
710
|
+
extraInfo.pad(),
|
|
711
|
+
"cloned => ",
|
|
712
|
+
node.browseName.toString(),
|
|
713
|
+
"",
|
|
714
|
+
extraInfo.pad(),
|
|
715
|
+
" original nodeId",
|
|
716
|
+
node.nodeId.toString(),
|
|
717
|
+
"",
|
|
718
|
+
extraInfo.pad(),
|
|
719
|
+
" cloned nodeId",
|
|
720
|
+
clonedNode.nodeId.toString(),
|
|
721
|
+
""
|
|
722
|
+
);
|
|
691
723
|
|
|
692
724
|
extraInfo.level++;
|
|
693
725
|
_clone_children_on_template(
|
|
@@ -705,7 +737,8 @@ function _clone_collection_new(
|
|
|
705
737
|
extraInfo.level++;
|
|
706
738
|
_cloneInterface(nodeToClone, newParent, node, optionalFilter, extraInfo, browseNameMap);
|
|
707
739
|
extraInfo.level--;
|
|
708
|
-
|
|
740
|
+
// === clone);
|
|
741
|
+
// extraInfo.registerClonedObject(clone, node);
|
|
709
742
|
}
|
|
710
743
|
}
|
|
711
744
|
}
|
|
@@ -846,7 +879,7 @@ function _cloneInterface(
|
|
|
846
879
|
chalk.green("-------------------- now cloning interfaces of ", node.browseName.toString(), node.nodeId.toString())
|
|
847
880
|
);
|
|
848
881
|
|
|
849
|
-
extraInfo = extraInfo ||
|
|
882
|
+
extraInfo = extraInfo || new CloneHelper();
|
|
850
883
|
const addressSpace = node.addressSpace;
|
|
851
884
|
|
|
852
885
|
if (node.nodeClass !== NodeClass.Object && node.nodeClass !== NodeClass.Variable) {
|
|
@@ -940,7 +973,7 @@ export function _clone_non_hierarchical_references(
|
|
|
940
973
|
* @private
|
|
941
974
|
*/
|
|
942
975
|
export function _clone<T extends UAObject | UAVariable | UAMethod>(
|
|
943
|
-
|
|
976
|
+
originalNode: T,
|
|
944
977
|
Constructor: new (options: any) => T,
|
|
945
978
|
options: CloneOptions,
|
|
946
979
|
optionalFilter: CloneFilter,
|
|
@@ -951,21 +984,21 @@ export function _clone<T extends UAObject | UAVariable | UAMethod>(
|
|
|
951
984
|
assert(
|
|
952
985
|
!extraInfo || (extraInfo !== null && typeof extraInfo === "object" && typeof extraInfo.registerClonedObject === "function")
|
|
953
986
|
);
|
|
954
|
-
assert(!(
|
|
955
|
-
assert(!extraInfo.getCloned(
|
|
987
|
+
assert(!(originalNode as any).subtypeOf, "We do not do cloning of Type yet");
|
|
988
|
+
assert(!extraInfo.getCloned(originalNode), "object has already been cloned");
|
|
956
989
|
const namespace = options.namespace;
|
|
957
990
|
const constructorOptions: any = {
|
|
958
991
|
...options,
|
|
959
992
|
addressSpace: namespace.addressSpace,
|
|
960
|
-
browseName:
|
|
961
|
-
description:
|
|
962
|
-
displayName:
|
|
963
|
-
nodeClass:
|
|
993
|
+
browseName: originalNode.browseName,
|
|
994
|
+
description: originalNode.description,
|
|
995
|
+
displayName: originalNode.displayName,
|
|
996
|
+
nodeClass: originalNode.nodeClass
|
|
964
997
|
};
|
|
965
998
|
constructorOptions.references = options.references || [];
|
|
966
999
|
|
|
967
|
-
if (
|
|
968
|
-
const voThis =
|
|
1000
|
+
if (originalNode.nodeClass === NodeClass.Variable || originalNode.nodeClass === NodeClass.Object) {
|
|
1001
|
+
const voThis = originalNode as UAObject | UAVariable;
|
|
969
1002
|
if (voThis.typeDefinition) {
|
|
970
1003
|
constructorOptions.references.push(
|
|
971
1004
|
new ReferenceImpl({
|
|
@@ -978,8 +1011,8 @@ export function _clone<T extends UAObject | UAVariable | UAMethod>(
|
|
|
978
1011
|
}
|
|
979
1012
|
|
|
980
1013
|
if (!constructorOptions.modellingRule) {
|
|
981
|
-
if (
|
|
982
|
-
const modellingRuleNode =
|
|
1014
|
+
if (originalNode.modellingRule && options.copyAlsoModellingRules) {
|
|
1015
|
+
const modellingRuleNode = originalNode.findReferencesAsObject("HasModellingRule", true)[0];
|
|
983
1016
|
assert(modellingRuleNode);
|
|
984
1017
|
constructorOptions.references.push(
|
|
985
1018
|
new ReferenceImpl({
|
|
@@ -997,29 +1030,41 @@ export function _clone<T extends UAObject | UAVariable | UAMethod>(
|
|
|
997
1030
|
|
|
998
1031
|
assert(constructorOptions.nodeId instanceof NodeId);
|
|
999
1032
|
|
|
1000
|
-
const
|
|
1001
|
-
(
|
|
1033
|
+
const clonedNode = new Constructor(constructorOptions);
|
|
1034
|
+
(originalNode.addressSpace as AddressSpacePrivate)._register(clonedNode);
|
|
1035
|
+
extraInfo.registerClonedObject(clonedNode, originalNode);
|
|
1002
1036
|
|
|
1003
1037
|
if (!options.ignoreChildren) {
|
|
1004
1038
|
// clone children and the rest ....
|
|
1005
1039
|
options.copyAlsoModellingRules = options.copyAlsoModellingRules || false;
|
|
1006
1040
|
|
|
1007
|
-
const newFilter = optionalFilter.filterFor(
|
|
1041
|
+
const newFilter = optionalFilter.filterFor(clonedNode);
|
|
1008
1042
|
|
|
1009
1043
|
const browseNameMap = new Set<string>();
|
|
1010
|
-
_clone_hierarchical_references(
|
|
1044
|
+
_clone_hierarchical_references(
|
|
1045
|
+
originalNode,
|
|
1046
|
+
clonedNode,
|
|
1047
|
+
options.copyAlsoModellingRules,
|
|
1048
|
+
newFilter!,
|
|
1049
|
+
extraInfo,
|
|
1050
|
+
browseNameMap
|
|
1051
|
+
);
|
|
1011
1052
|
|
|
1012
|
-
if (
|
|
1013
|
-
let typeDefinitionNode: UAVariableType | UAObjectType | null =
|
|
1053
|
+
if (originalNode.nodeClass === NodeClass.Object || originalNode.nodeClass === NodeClass.Variable) {
|
|
1054
|
+
let typeDefinitionNode: UAVariableType | UAObjectType | null = originalNode.typeDefinitionObj;
|
|
1014
1055
|
while (typeDefinitionNode) {
|
|
1015
1056
|
doTrace &&
|
|
1016
1057
|
traceLog(
|
|
1017
1058
|
extraInfo?.pad(),
|
|
1018
|
-
chalk.blueBright(
|
|
1059
|
+
chalk.blueBright(
|
|
1060
|
+
originalNode.browseName.toString(),
|
|
1061
|
+
"-----> Exploring ",
|
|
1062
|
+
typeDefinitionNode.browseName.toString()
|
|
1063
|
+
)
|
|
1019
1064
|
);
|
|
1020
1065
|
_clone_hierarchical_references(
|
|
1021
1066
|
typeDefinitionNode,
|
|
1022
|
-
|
|
1067
|
+
clonedNode,
|
|
1023
1068
|
options.copyAlsoModellingRules,
|
|
1024
1069
|
newFilter,
|
|
1025
1070
|
extraInfo,
|
|
@@ -1028,12 +1073,19 @@ export function _clone<T extends UAObject | UAVariable | UAMethod>(
|
|
|
1028
1073
|
typeDefinitionNode = typeDefinitionNode.subtypeOfObj;
|
|
1029
1074
|
}
|
|
1030
1075
|
}
|
|
1031
|
-
_clone_non_hierarchical_references(
|
|
1076
|
+
_clone_non_hierarchical_references(
|
|
1077
|
+
originalNode,
|
|
1078
|
+
clonedNode,
|
|
1079
|
+
options.copyAlsoModellingRules,
|
|
1080
|
+
newFilter,
|
|
1081
|
+
extraInfo,
|
|
1082
|
+
browseNameMap
|
|
1083
|
+
);
|
|
1032
1084
|
}
|
|
1033
|
-
|
|
1034
|
-
|
|
1085
|
+
clonedNode.propagate_back_references();
|
|
1086
|
+
clonedNode.install_extra_properties();
|
|
1035
1087
|
|
|
1036
|
-
return
|
|
1088
|
+
return clonedNode;
|
|
1037
1089
|
}
|
|
1038
1090
|
|
|
1039
1091
|
export function _handle_HierarchicalReference(node: BaseNode, reference: UAReference): void {
|
package/src/ua_method_impl.ts
CHANGED
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
ISessionContext,
|
|
30
30
|
UAVariable,
|
|
31
31
|
defaultCloneFilter,
|
|
32
|
-
|
|
32
|
+
makeDefaultCloneExtraInfo
|
|
33
33
|
} from "node-opcua-address-space-base";
|
|
34
34
|
import { SessionContext } from "../source/session_context";
|
|
35
35
|
import { _clone } from "./base_node_private";
|
|
@@ -264,12 +264,12 @@ export class UAMethodImpl extends BaseNodeImpl implements UAMethod {
|
|
|
264
264
|
|
|
265
265
|
_handle_hierarchy_parent(addressSpace, options.references, options);
|
|
266
266
|
|
|
267
|
-
const clonedMethod = _clone
|
|
267
|
+
const clonedMethod = _clone(
|
|
268
268
|
this,
|
|
269
269
|
UAMethodImpl,
|
|
270
270
|
options,
|
|
271
271
|
optionalFilter || defaultCloneFilter,
|
|
272
|
-
extraInfo ||
|
|
272
|
+
extraInfo || makeDefaultCloneExtraInfo()
|
|
273
273
|
) as UAMethodImpl;
|
|
274
274
|
|
|
275
275
|
clonedMethod._asyncExecutionFunction = this._asyncExecutionFunction;
|
package/src/ua_object_impl.ts
CHANGED
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
UAEventType,
|
|
28
28
|
IEventData,
|
|
29
29
|
defaultCloneFilter,
|
|
30
|
-
|
|
30
|
+
makeDefaultCloneExtraInfo,
|
|
31
31
|
EventNotifierFlags
|
|
32
32
|
} from "node-opcua-address-space-base";
|
|
33
33
|
import { make_errorLog } from "node-opcua-debug";
|
|
@@ -91,17 +91,17 @@ export class UAObjectImpl extends BaseNodeImpl implements UAObject {
|
|
|
91
91
|
|
|
92
92
|
public clone(options: CloneOptions, optionalFilter?: CloneFilter, extraInfo?: CloneExtraInfo): UAObject {
|
|
93
93
|
options = {
|
|
94
|
-
...options,
|
|
95
94
|
eventNotifier: this.eventNotifier,
|
|
96
|
-
symbolicName: this.symbolicName || undefined
|
|
95
|
+
symbolicName: this.symbolicName || undefined,
|
|
96
|
+
...options,
|
|
97
97
|
};
|
|
98
98
|
|
|
99
|
-
const cloneObject = _clone
|
|
99
|
+
const cloneObject = _clone(
|
|
100
100
|
this,
|
|
101
101
|
UAObjectImpl,
|
|
102
102
|
options,
|
|
103
103
|
optionalFilter || defaultCloneFilter,
|
|
104
|
-
extraInfo ||
|
|
104
|
+
extraInfo || makeDefaultCloneExtraInfo()
|
|
105
105
|
) as UAObject;
|
|
106
106
|
// xx newObject.propagate_back_references();
|
|
107
107
|
// xx newObject.install_extra_properties();
|