node-opcua-address-space 2.137.0 → 2.138.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_addin.d.ts +1 -1
- package/dist/source/ua_addin.js +6 -6
- package/dist/source/ua_addin.js.map +1 -1
- package/dist/source/ua_interface.d.ts +1 -0
- package/dist/source/ua_interface.js +13 -3
- package/dist/source/ua_interface.js.map +1 -1
- package/dist/src/_instantiate_helpers.js +1 -1
- package/dist/src/_instantiate_helpers.js.map +1 -1
- package/dist/src/namespace_impl.d.ts +1 -9
- package/dist/src/namespace_impl.js +16 -9
- package/dist/src/namespace_impl.js.map +1 -1
- package/dist/src/nodeid_manager.js +16 -13
- package/dist/src/nodeid_manager.js.map +1 -1
- package/dist/src/private_namespace.js +1 -1
- package/dist/src/private_namespace.js.map +1 -1
- package/dist/src/ua_object_type_impl.d.ts +1 -0
- package/dist/src/ua_object_type_impl.js +2 -0
- package/dist/src/ua_object_type_impl.js.map +1 -1
- package/dist/src/ua_reference_type_impl.d.ts +1 -1
- package/dist/tsconfig_common.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/source/ua_addin.ts +8 -7
- package/source/ua_interface.ts +14 -3
- package/src/_instantiate_helpers.ts +1 -1
- package/src/namespace_impl.ts +21 -10
- package/src/nodeid_manager.ts +26 -20
- package/src/private_namespace.ts +2 -1
- package/src/ua_object_type_impl.ts +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-opcua-address-space",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.138.1",
|
|
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,11 +22,11 @@
|
|
|
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.138.0",
|
|
26
26
|
"node-opcua-assert": "2.120.0",
|
|
27
27
|
"node-opcua-basic-types": "2.134.0",
|
|
28
28
|
"node-opcua-binary-stream": "2.133.0",
|
|
29
|
-
"node-opcua-client-dynamic-extension-object": "2.
|
|
29
|
+
"node-opcua-client-dynamic-extension-object": "2.138.0",
|
|
30
30
|
"node-opcua-constants": "2.125.0",
|
|
31
31
|
"node-opcua-crypto": "4.12.0",
|
|
32
32
|
"node-opcua-data-access": "2.137.0",
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"node-opcua-extension-object": "2.137.0",
|
|
39
39
|
"node-opcua-factory": "2.137.0",
|
|
40
40
|
"node-opcua-nodeid": "2.133.0",
|
|
41
|
-
"node-opcua-nodeset-ua": "2.
|
|
41
|
+
"node-opcua-nodeset-ua": "2.138.0",
|
|
42
42
|
"node-opcua-numeric-range": "2.137.0",
|
|
43
43
|
"node-opcua-object-registry": "2.133.0",
|
|
44
|
-
"node-opcua-pseudo-session": "2.
|
|
44
|
+
"node-opcua-pseudo-session": "2.138.0",
|
|
45
45
|
"node-opcua-service-browse": "2.137.0",
|
|
46
46
|
"node-opcua-service-call": "2.137.0",
|
|
47
47
|
"node-opcua-service-history": "2.137.0",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"node-opcua-leak-detector": "2.133.0",
|
|
63
63
|
"node-opcua-nodesets": "2.137.0",
|
|
64
64
|
"node-opcua-packet-analyzer": "2.137.0",
|
|
65
|
-
"node-opcua-service-filter": "2.
|
|
65
|
+
"node-opcua-service-filter": "2.138.0",
|
|
66
66
|
"node-opcua-test-fixtures": "2.137.0",
|
|
67
67
|
"source-map-support": "^0.5.21"
|
|
68
68
|
},
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"internet of things"
|
|
82
82
|
],
|
|
83
83
|
"homepage": "http://node-opcua.github.io/",
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "9a9b6ac2281306c90fc0ef55e93c8b773f9edcd2",
|
|
85
85
|
"files": [
|
|
86
86
|
"dist",
|
|
87
87
|
"distHelpers",
|
package/source/ua_addin.ts
CHANGED
|
@@ -24,18 +24,19 @@ export function instantiateAddIn(objectType: UAObjectType, options: InstantiateA
|
|
|
24
24
|
browseName: browseName,
|
|
25
25
|
modellingRule: options.modellingRule,
|
|
26
26
|
copyAlsoModellingRules: options.copyAlsoModellingRules,
|
|
27
|
+
addInOf: options.addInOf
|
|
27
28
|
});
|
|
28
|
-
options.addInOf.addReference({
|
|
29
|
-
referenceType: "HasAddIn",
|
|
30
|
-
nodeId: addIn.nodeId
|
|
31
|
-
})
|
|
32
29
|
return addIn;
|
|
33
30
|
}
|
|
34
31
|
|
|
35
|
-
export function addDefaultInstanceBrowseName(objectType: UAObjectType, defaultBrowseName: string)
|
|
32
|
+
export function addDefaultInstanceBrowseName(objectType: UAObjectType, defaultBrowseName: QualifiedName | string)
|
|
36
33
|
: UAVariableT<QualifiedName, DataType.QualifiedName> {
|
|
37
34
|
|
|
38
35
|
const namespace1 = objectType.namespace;
|
|
36
|
+
if (typeof defaultBrowseName === "string") {
|
|
37
|
+
defaultBrowseName = coerceQualifiedName({ name: defaultBrowseName, namespaceIndex: namespace1.index });
|
|
38
|
+
}
|
|
39
|
+
|
|
39
40
|
const uaVaraible = namespace1.addVariable({
|
|
40
41
|
browseName: coerceQualifiedName({ name: "DefaultInstanceBrowseName", namespaceIndex: 0 }),
|
|
41
42
|
propertyOf: objectType,
|
|
@@ -43,9 +44,9 @@ export function addDefaultInstanceBrowseName(objectType: UAObjectType, defaultBr
|
|
|
43
44
|
dataType: DataType.QualifiedName,
|
|
44
45
|
value: {
|
|
45
46
|
dataType: DataType.QualifiedName,
|
|
46
|
-
value:
|
|
47
|
+
value: defaultBrowseName
|
|
47
48
|
},
|
|
48
|
-
modellingRule: null
|
|
49
|
+
modellingRule: null // DefaultInstanceBrowseName must have no ModellingRule
|
|
49
50
|
});
|
|
50
51
|
return uaVaraible as UAVariableT<QualifiedName, DataType.QualifiedName>;
|
|
51
52
|
|
package/source/ua_interface.ts
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
import { UAObject, UAObjectType, UAVariable, UAVariableType } from "node-opcua-address-space-base";
|
|
4
4
|
import { BrowseDirection } from "node-opcua-data-model";
|
|
5
|
+
import { initialize_properties_and_components } from "../src/_instantiate_helpers";
|
|
5
6
|
|
|
6
|
-
export function
|
|
7
|
+
export function implementInterfaceBad(uaNode: UAObject | UAObjectType | UAVariable | UAVariableType, interfaceType: UAObjectType) {
|
|
7
8
|
|
|
8
9
|
const addressSpace = uaNode.addressSpace;
|
|
9
10
|
const tmp = interfaceType.instantiate({
|
|
10
|
-
browseName:
|
|
11
|
+
browseName: uaNode.browseName,
|
|
11
12
|
copyAlsoModellingRules: true,
|
|
12
13
|
copyAlsoAllOptionals: true,
|
|
13
14
|
modellingRule: "Mandatory"
|
|
@@ -33,6 +34,16 @@ export function implementInterface(uaNode: UAObject | UAObjectType | UAVariable
|
|
|
33
34
|
});
|
|
34
35
|
}
|
|
35
36
|
addressSpace.deleteNode(tmp);
|
|
36
|
-
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function implementInterface(uaNode: UAObject | UAObjectType | UAVariable | UAVariableType, interfaceType: UAObjectType) {
|
|
40
|
+
|
|
41
|
+
const addressSpace = uaNode.addressSpace;
|
|
42
|
+
const topMost = addressSpace.findObjectType("BaseInterfaceType")!;
|
|
43
|
+
initialize_properties_and_components(uaNode as any, topMost, interfaceType, true, true, []);
|
|
44
|
+
uaNode.addReference({
|
|
45
|
+
nodeId: interfaceType,
|
|
46
|
+
referenceType: "HasInterface"
|
|
47
|
+
});
|
|
37
48
|
|
|
38
49
|
}
|
|
@@ -71,7 +71,7 @@ function _initialize_properties_and_components<B extends UAObject | UAVariable |
|
|
|
71
71
|
doTrace &&
|
|
72
72
|
traceLog(
|
|
73
73
|
chalk.cyan(extraInfo.pad(), "cloning relevant member of typeDefinition class"),
|
|
74
|
-
typeDefinitionNode.browseName.toString()
|
|
74
|
+
typeDefinitionNode.browseName.toString()+ "\n optionals" + (JSON.stringify(optionalsMap))
|
|
75
75
|
);
|
|
76
76
|
|
|
77
77
|
_clone_hierarchical_references(typeDefinitionNode, instance, copyAlsoModellingRules, filter, extraInfo, browseNameMap);
|
package/src/namespace_impl.ts
CHANGED
|
@@ -799,16 +799,8 @@ export class NamespaceImpl implements NamespacePrivate {
|
|
|
799
799
|
}
|
|
800
800
|
|
|
801
801
|
// ---------------------------------------------------------------------------------------------------
|
|
802
|
-
/**
|
|
803
|
-
|
|
804
|
-
* @param options
|
|
805
|
-
* @param options.browseName {String}
|
|
806
|
-
* @param options.definition {String}
|
|
807
|
-
* @param [options.valuePrecision {Double |null} =null]
|
|
808
|
-
* @param options.dataType {NodeId} // todo :check
|
|
809
|
-
* @param options.value
|
|
810
|
-
* @param options.componentOf
|
|
811
|
-
* @return {UAVariable}
|
|
802
|
+
/**
|
|
803
|
+
*
|
|
812
804
|
*/
|
|
813
805
|
public addDataItem<T, DT extends DataType>(options: AddDataItemOptions): UADataItem<T, DT> {
|
|
814
806
|
const addressSpace = this.addressSpace;
|
|
@@ -2134,12 +2126,28 @@ function _handle_event_hierarchy_parent(
|
|
|
2134
2126
|
}
|
|
2135
2127
|
|
|
2136
2128
|
export function _handle_hierarchy_parent(addressSpace: AddressSpacePrivate, references: AddReferenceOpts[], options: any): void {
|
|
2129
|
+
options.addInOf = _coerce_parent(addressSpace, options.addInOf, addressSpace._coerceNode);
|
|
2137
2130
|
options.componentOf = _coerce_parent(addressSpace, options.componentOf, addressSpace._coerceNode);
|
|
2138
2131
|
options.propertyOf = _coerce_parent(addressSpace, options.propertyOf, addressSpace._coerceNode);
|
|
2139
2132
|
options.organizedBy = _coerce_parent(addressSpace, options.organizedBy, addressSpace._coerceFolder);
|
|
2140
2133
|
options.encodingOf = _coerce_parent(addressSpace, options.encodingOf, addressSpace._coerceNode);
|
|
2141
2134
|
|
|
2135
|
+
if (options.addInOf) {
|
|
2136
|
+
assert(!options.componentOf);
|
|
2137
|
+
assert(!options.propertyOf);
|
|
2138
|
+
assert(!options.organizedBy);
|
|
2139
|
+
assert(options.addInOf.nodeClass === NodeClass.Object || options.addInOf.nodeClass === NodeClass.ObjectType,
|
|
2140
|
+
"addInOf must be of nodeClass Object or ObjectType"
|
|
2141
|
+
);
|
|
2142
|
+
references.push({
|
|
2143
|
+
isForward: false,
|
|
2144
|
+
nodeId: options.addInOf.nodeId,
|
|
2145
|
+
referenceType: "HasAddIn"
|
|
2146
|
+
});
|
|
2147
|
+
}
|
|
2148
|
+
|
|
2142
2149
|
if (options.componentOf) {
|
|
2150
|
+
assert(!options.addInOf);
|
|
2143
2151
|
assert(!options.propertyOf);
|
|
2144
2152
|
assert(!options.organizedBy);
|
|
2145
2153
|
assert(addressSpace.rootFolder.objects, "addressSpace must have a rootFolder.objects folder");
|
|
@@ -2155,6 +2163,7 @@ export function _handle_hierarchy_parent(addressSpace: AddressSpacePrivate, refe
|
|
|
2155
2163
|
}
|
|
2156
2164
|
|
|
2157
2165
|
if (options.propertyOf) {
|
|
2166
|
+
assert(!options.addInOf);
|
|
2158
2167
|
assert(!options.componentOf);
|
|
2159
2168
|
assert(!options.organizedBy);
|
|
2160
2169
|
assert(
|
|
@@ -2169,6 +2178,7 @@ export function _handle_hierarchy_parent(addressSpace: AddressSpacePrivate, refe
|
|
|
2169
2178
|
}
|
|
2170
2179
|
|
|
2171
2180
|
if (options.organizedBy) {
|
|
2181
|
+
assert(!options.addInOf);
|
|
2172
2182
|
assert(!options.propertyOf);
|
|
2173
2183
|
assert(!options.componentOf);
|
|
2174
2184
|
references.push({
|
|
@@ -2177,6 +2187,7 @@ export function _handle_hierarchy_parent(addressSpace: AddressSpacePrivate, refe
|
|
|
2177
2187
|
referenceType: "Organizes"
|
|
2178
2188
|
});
|
|
2179
2189
|
}
|
|
2190
|
+
|
|
2180
2191
|
if (options.encodingOf) {
|
|
2181
2192
|
// parent must be a DataType
|
|
2182
2193
|
assert(options.encodingOf.nodeClass === NodeClass.DataType, "encodingOf must be toward a DataType");
|
package/src/nodeid_manager.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { makeNodeId, NodeId, NodeIdLike, NodeIdType, resolveNodeId, sameNodeId }
|
|
|
6
6
|
import { make_debugLog, make_warningLog } from "node-opcua-debug";
|
|
7
7
|
import { BaseNode, UAReference, UAReferenceType } from "node-opcua-address-space-base";
|
|
8
8
|
import { getReferenceType } from "./base_node_impl";
|
|
9
|
+
import { resolveReferenceNode, resolveReferenceType } from "./reference_impl";
|
|
9
10
|
|
|
10
11
|
const debugLog = make_debugLog(__filename);
|
|
11
12
|
const warningLog = make_warningLog(__filename);
|
|
@@ -19,24 +20,29 @@ function isValidNodeClass(nodeClass: NodeClass) {
|
|
|
19
20
|
|
|
20
21
|
const regExp1 = /^(s|i|b|g)=/;
|
|
21
22
|
const regExp2 = /^ns=[0-9]+;(s|i|b|g)=/;
|
|
22
|
-
const hasPropertyRefId = resolveNodeId("HasProperty");
|
|
23
|
-
const hasComponentRefId = resolveNodeId("HasComponent");
|
|
24
|
-
const hasOrderedComponentRefId = resolveNodeId("HasOrderedComponent");
|
|
25
23
|
const hasEncoding = resolveNodeId("HasEncoding");
|
|
26
24
|
|
|
27
25
|
type Suffix = string;
|
|
28
26
|
|
|
29
|
-
function
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
|
|
27
|
+
function _filterAggregates(addressSpace: AddressSpacePartial, references: UAReference[]): [NodeId, Suffix] | null {
|
|
28
|
+
|
|
29
|
+
const aggregatesRefType = addressSpace.findNode(resolveNodeId("Aggregates")) as UAReferenceType;
|
|
30
|
+
const hasEncodinRefType = addressSpace.findNode(resolveNodeId("HasEncoding")) as UAReferenceType;
|
|
31
|
+
|
|
32
|
+
const checkAggregate = (
|
|
33
|
+
reference: UAReference,
|
|
34
|
+
): boolean => {
|
|
35
|
+
if (reference.isForward) return false;
|
|
36
|
+
const r = resolveReferenceType(addressSpace, reference);
|
|
37
|
+
if (!r) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
return r.isSubtypeOf(aggregatesRefType) || r.isSubtypeOf(hasEncodinRefType)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const candidates = references.filter(checkAggregate);
|
|
44
|
+
|
|
45
|
+
assert(candidates.length <= 1, "a node shall not have more than one parent (link to a parent with a reference derived from 'Aggregates')");
|
|
40
46
|
if (candidates.length === 0) {
|
|
41
47
|
return null;
|
|
42
48
|
}
|
|
@@ -60,7 +66,7 @@ function _findParentNodeId(addressSpace: AddressSpacePartial, options: Construct
|
|
|
60
66
|
(ref as any).referenceType = (ref as any)._referenceType.nodeId;
|
|
61
67
|
}
|
|
62
68
|
// find HasComponent, or has Property reverse
|
|
63
|
-
return
|
|
69
|
+
return _filterAggregates(addressSpace, options.references);
|
|
64
70
|
}
|
|
65
71
|
|
|
66
72
|
function prepareName(browseName: QualifiedName): string {
|
|
@@ -83,7 +89,7 @@ export type NodeEntry = [string, number, NodeClass];
|
|
|
83
89
|
export type NodeEntry1 = [string, number, string /*"Object" | "Variable" etc...*/];
|
|
84
90
|
|
|
85
91
|
export class NodeIdManager {
|
|
86
|
-
private _cacheSymbolicName: { [key: string]: [number,NodeClass] } = {};
|
|
92
|
+
private _cacheSymbolicName: { [key: string]: [number, NodeClass] } = {};
|
|
87
93
|
private _cacheSymbolicNameRev: Set<number> = new Set<number>();
|
|
88
94
|
|
|
89
95
|
private _internal_id_counter: number;
|
|
@@ -174,11 +180,11 @@ export class NodeIdManager {
|
|
|
174
180
|
}
|
|
175
181
|
return this._constructNodeId(options);
|
|
176
182
|
}
|
|
177
|
-
|
|
183
|
+
|
|
178
184
|
private _constructNodeId(options: ConstructNodeIdOptions): NodeId {
|
|
179
185
|
|
|
180
186
|
let nodeId = options.nodeId;
|
|
181
|
-
|
|
187
|
+
|
|
182
188
|
if (!nodeId) {
|
|
183
189
|
const parentInfo = this.findParentNodeId(options);
|
|
184
190
|
if (parentInfo) {
|
|
@@ -190,7 +196,7 @@ export class NodeIdManager {
|
|
|
190
196
|
const childName = parentNodeId.value + NamespaceOptions.nodeIdNameSeparator + name;
|
|
191
197
|
nodeId = new NodeId(NodeId.NodeIdType.STRING, childName, parentNodeId.namespace);
|
|
192
198
|
return nodeId;
|
|
193
|
-
}
|
|
199
|
+
}
|
|
194
200
|
}
|
|
195
201
|
} else if (typeof nodeId === "string") {
|
|
196
202
|
if (this.namespaceIndex !== 0) {
|
|
@@ -218,7 +224,7 @@ export class NodeIdManager {
|
|
|
218
224
|
}
|
|
219
225
|
|
|
220
226
|
private _isInCache(nodeId: NodeId): boolean {
|
|
221
|
-
if(
|
|
227
|
+
if (nodeId.namespace !== this.namespaceIndex || nodeId.identifierType !== NodeIdType.NUMERIC) return false;
|
|
222
228
|
return this._cacheSymbolicNameRev.has(nodeId.value as number) ? true : false;
|
|
223
229
|
}
|
|
224
230
|
}
|
package/src/private_namespace.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
3
|
import { Namespace } from "../source/namespace";
|
|
4
|
+
import { NamespacePrivate } from "./namespace_private";
|
|
4
5
|
import { NodeEntry1, NodeIdManager } from "./nodeid_manager";
|
|
5
6
|
|
|
6
7
|
export function getNodeIdManager(ns: Namespace): NodeIdManager {
|
|
@@ -9,7 +10,7 @@ export function getNodeIdManager(ns: Namespace): NodeIdManager {
|
|
|
9
10
|
}
|
|
10
11
|
export function setSymbols(ns: Namespace, symbols: NodeEntry1[]) {
|
|
11
12
|
const nodeIdManager = getNodeIdManager(ns);
|
|
12
|
-
(ns
|
|
13
|
+
(ns as any).registerSymbolicNames = true;
|
|
13
14
|
nodeIdManager.setSymbols(symbols);
|
|
14
15
|
}
|
|
15
16
|
export function getSymbols(ns: Namespace): NodeEntry1[] {
|
|
@@ -82,8 +82,9 @@ export class UAObjectTypeImpl extends BaseNodeImpl implements UAObjectType {
|
|
|
82
82
|
* @param options
|
|
83
83
|
* @param options.browseName
|
|
84
84
|
* @param [options.description]
|
|
85
|
-
* @param [options.organizedBy] the parent Folder holding this object
|
|
85
|
+
* @param [options.organizedBy] the parent Folder holding this object
|
|
86
86
|
* @param [options.componentOf] the parent Object holding this object
|
|
87
|
+
* @param [options.addInOf]
|
|
87
88
|
* @param [options.notifierOf]
|
|
88
89
|
* @param [options.eventSourceOf]
|
|
89
90
|
* @param [options.optionals = [] name of the optional child to create
|
|
@@ -132,6 +133,7 @@ export class UAObjectTypeImpl extends BaseNodeImpl implements UAObjectType {
|
|
|
132
133
|
eventSourceOf: options.eventSourceOf,
|
|
133
134
|
notifierOf: options.notifierOf,
|
|
134
135
|
organizedBy: options.organizedBy,
|
|
136
|
+
addInOf: options.addInOf,
|
|
135
137
|
references,
|
|
136
138
|
|
|
137
139
|
typeDefinition: this.nodeId,
|