node-opcua-client-dynamic-extension-object 2.178.0 → 2.179.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/convert_data_type_definition_to_structuretype_schema.d.ts +8 -11
- package/dist/convert_data_type_definition_to_structuretype_schema.js +81 -48
- package/dist/convert_data_type_definition_to_structuretype_schema.js.map +1 -1
- package/dist/convert_structuretype_schema_to_structure_definition.d.ts +1 -1
- package/dist/convert_structuretype_schema_to_structure_definition.js +5 -3
- package/dist/convert_structuretype_schema_to_structure_definition.js.map +1 -1
- package/dist/extra_data_type_manager.d.ts +4 -5
- package/dist/extra_data_type_manager.js +15 -16
- package/dist/extra_data_type_manager.js.map +1 -1
- package/dist/get_extension_object_constructor.d.ts +3 -3
- package/dist/get_extension_object_constructor.js +3 -0
- package/dist/get_extension_object_constructor.js.map +1 -1
- package/dist/get_extra_data_type_manager.d.ts +2 -2
- package/dist/get_extra_data_type_manager.js +8 -8
- package/dist/get_extra_data_type_manager.js.map +1 -1
- package/dist/index.d.ts +5 -6
- package/dist/index.js +20 -21
- package/dist/index.js.map +1 -1
- package/dist/populate_data_type_manager.d.ts +2 -2
- package/dist/populate_data_type_manager.js +10 -10
- package/dist/populate_data_type_manager.js.map +1 -1
- package/dist/private/find_encodings.d.ts +2 -2
- package/dist/private/find_encodings.js.map +1 -1
- package/dist/private/populate_data_type_manager_103.d.ts +4 -4
- package/dist/private/populate_data_type_manager_103.js +97 -53
- package/dist/private/populate_data_type_manager_103.js.map +1 -1
- package/dist/private/populate_data_type_manager_104.d.ts +18 -4
- package/dist/private/populate_data_type_manager_104.js +48 -17
- package/dist/private/populate_data_type_manager_104.js.map +1 -1
- package/dist/promote_opaque_structure.d.ts +2 -2
- package/dist/promote_opaque_structure.js.map +1 -1
- package/dist/promote_opaque_structure_in_notification_data.d.ts +2 -2
- package/dist/promote_opaque_structure_in_notification_data.js +0 -2
- package/dist/promote_opaque_structure_in_notification_data.js.map +1 -1
- package/dist/resolve_dynamic_extension_object.d.ts +4 -4
- package/dist/resolve_dynamic_extension_object.js +15 -12
- package/dist/resolve_dynamic_extension_object.js.map +1 -1
- package/package.json +18 -18
- package/source/convert_data_type_definition_to_structuretype_schema.ts +146 -123
- package/source/convert_structuretype_schema_to_structure_definition.ts +9 -9
- package/source/extra_data_type_manager.ts +24 -22
- package/source/get_extension_object_constructor.ts +12 -7
- package/source/get_extra_data_type_manager.ts +21 -24
- package/source/index.ts +8 -8
- package/source/populate_data_type_manager.ts +17 -25
- package/source/private/find_encodings.ts +2 -2
- package/source/private/populate_data_type_manager_103.ts +166 -105
- package/source/private/populate_data_type_manager_104.ts +102 -45
- package/source/promote_opaque_structure.ts +3 -3
- package/source/promote_opaque_structure_in_notification_data.ts +3 -5
- package/source/resolve_dynamic_extension_object.ts +28 -29
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module node-opcua-client-dynamic-extension-object
|
|
3
3
|
*/
|
|
4
|
-
import { format } from "util";
|
|
4
|
+
import { format } from "node:util";
|
|
5
5
|
|
|
6
6
|
import { assert } from "node-opcua-assert";
|
|
7
7
|
import { BrowseDirection, NodeClassMask, ResultMask } from "node-opcua-data-model";
|
|
8
|
-
import { ConstructorFunc, DataTypeFactory, getStandardDataTypeFactory, StructureInfo } from "node-opcua-factory";
|
|
9
|
-
import { NodeId } from "node-opcua-nodeid";
|
|
10
|
-
import { IBasicSessionAsync2 } from "node-opcua-pseudo-session";
|
|
11
|
-
import { AnyConstructorFunc } from "node-opcua-schemas";
|
|
8
|
+
import { type ConstructorFunc, type DataTypeFactory, getStandardDataTypeFactory, type StructureInfo } from "node-opcua-factory";
|
|
9
|
+
import type { NodeId } from "node-opcua-nodeid";
|
|
10
|
+
import type { IBasicSessionAsync2 } from "node-opcua-pseudo-session";
|
|
11
|
+
import type { AnyConstructorFunc } from "node-opcua-schemas";
|
|
12
12
|
|
|
13
13
|
export class ExtraDataTypeManager {
|
|
14
14
|
public namespaceArray: string[] = [];
|
|
@@ -16,10 +16,6 @@ export class ExtraDataTypeManager {
|
|
|
16
16
|
private _session: IBasicSessionAsync2 | null = null;
|
|
17
17
|
private _pendingExtractions: Map<string, Promise<StructureInfo>> = new Map();
|
|
18
18
|
|
|
19
|
-
constructor() {
|
|
20
|
-
/* */
|
|
21
|
-
}
|
|
22
|
-
|
|
23
19
|
public setSession(session: IBasicSessionAsync2): void {
|
|
24
20
|
this._session = session;
|
|
25
21
|
}
|
|
@@ -32,7 +28,7 @@ export class ExtraDataTypeManager {
|
|
|
32
28
|
if (namespaceIndex === 0) {
|
|
33
29
|
return true;
|
|
34
30
|
}
|
|
35
|
-
return !!Object.
|
|
31
|
+
return !!Object.hasOwn(this.dataTypeFactoryMapByNamespace, namespaceIndex);
|
|
36
32
|
}
|
|
37
33
|
|
|
38
34
|
public registerDataTypeFactory(namespaceIndex: number, dataTypeFactory: DataTypeFactory): void {
|
|
@@ -64,13 +60,15 @@ export class ExtraDataTypeManager {
|
|
|
64
60
|
if (standardDataTypeFactory.hasBuiltInType(fieldTypeName)) {
|
|
65
61
|
return standardDataTypeFactory.getBuiltInType(fieldTypeName);
|
|
66
62
|
}
|
|
67
|
-
throw new Error(
|
|
63
|
+
throw new Error(`Cannot find built-in type ${fieldTypeName}`);
|
|
68
64
|
}
|
|
69
65
|
|
|
70
66
|
public getStructureInfoForDataType(dataTypeNodeId: NodeId): StructureInfo | null {
|
|
71
67
|
const dataTypeFactory = this.getDataTypeFactory(dataTypeNodeId.namespace);
|
|
72
68
|
if (!dataTypeFactory) {
|
|
73
|
-
throw new Error(
|
|
69
|
+
throw new Error(
|
|
70
|
+
`cannot find dataFactory for namespace=${dataTypeNodeId.namespace} when requested for ${dataTypeNodeId.toString()}`
|
|
71
|
+
);
|
|
74
72
|
}
|
|
75
73
|
return dataTypeFactory.getStructureInfoForDataType(dataTypeNodeId);
|
|
76
74
|
}
|
|
@@ -85,21 +83,23 @@ export class ExtraDataTypeManager {
|
|
|
85
83
|
}
|
|
86
84
|
|
|
87
85
|
const key = dataTypeNodeId.toString();
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
const pending = this._pendingExtractions.get(key);
|
|
87
|
+
if (pending) {
|
|
88
|
+
return await pending;
|
|
90
89
|
}
|
|
91
90
|
|
|
91
|
+
const session = this._session;
|
|
92
92
|
const promise = (async () => {
|
|
93
93
|
// We'll need to make sure it's accessible and correctly used.
|
|
94
94
|
// For now, let's assume we can import it or move it.
|
|
95
95
|
// Actually, populate_data_type_manager_104.ts exports readDataTypeDefinitionAndBuildType
|
|
96
96
|
const { readDataTypeDefinitionAndBuildType } = require("./private/populate_data_type_manager_104");
|
|
97
97
|
const cache = {}; // local cache for this extraction
|
|
98
|
-
await readDataTypeDefinitionAndBuildType(
|
|
98
|
+
await readDataTypeDefinitionAndBuildType(session, dataTypeNodeId, undefined, this, cache);
|
|
99
99
|
|
|
100
100
|
const info = this.getStructureInfoForDataType(dataTypeNodeId);
|
|
101
101
|
if (!info) {
|
|
102
|
-
throw new Error(
|
|
102
|
+
throw new Error(`Failed to extract data type structure for ${dataTypeNodeId.toString()}`);
|
|
103
103
|
}
|
|
104
104
|
return info;
|
|
105
105
|
})();
|
|
@@ -115,7 +115,9 @@ export class ExtraDataTypeManager {
|
|
|
115
115
|
public getExtensionObjectConstructorFromDataType(dataTypeNodeId: NodeId): AnyConstructorFunc {
|
|
116
116
|
const dataTypeFactory = this.getDataTypeFactory(dataTypeNodeId.namespace);
|
|
117
117
|
if (!dataTypeFactory) {
|
|
118
|
-
throw new Error(
|
|
118
|
+
throw new Error(
|
|
119
|
+
`cannot find dataFactory for namespace=${dataTypeNodeId.namespace} when requested for ${dataTypeNodeId.toString()}`
|
|
120
|
+
);
|
|
119
121
|
}
|
|
120
122
|
// find schema corresponding to dataTypeNodeId in typeDictionary
|
|
121
123
|
const structureInfo = dataTypeFactory.findStructureInfoForDataType(dataTypeNodeId);
|
|
@@ -130,7 +132,7 @@ export class ExtraDataTypeManager {
|
|
|
130
132
|
const structureInfo = await this.getStructureInfoForDataTypeAsync(dataTypeNodeId);
|
|
131
133
|
const Constructor = structureInfo.constructor;
|
|
132
134
|
if (!Constructor) {
|
|
133
|
-
throw new Error(
|
|
135
|
+
throw new Error(`Cannot find Extension Object Constructor for Abstract dataType ${dataTypeNodeId.toString()}`);
|
|
134
136
|
}
|
|
135
137
|
return Constructor;
|
|
136
138
|
}
|
|
@@ -141,7 +143,7 @@ export class ExtraDataTypeManager {
|
|
|
141
143
|
if (!Constructor) {
|
|
142
144
|
throw new Error(
|
|
143
145
|
"getExtensionObjectConstructorFromBinaryEncoding cannot find constructor for binaryEncoding " +
|
|
144
|
-
|
|
146
|
+
binaryEncodingNodeId.toString()
|
|
145
147
|
);
|
|
146
148
|
}
|
|
147
149
|
return Constructor;
|
|
@@ -169,7 +171,7 @@ export class ExtraDataTypeManager {
|
|
|
169
171
|
});
|
|
170
172
|
|
|
171
173
|
if (browseResult.statusCode.isNotGood() || !browseResult.references || browseResult.references.length !== 1) {
|
|
172
|
-
throw new Error(
|
|
174
|
+
throw new Error(`Cannot find DataType for binary encoding ${binaryEncodingNodeId.toString()}`);
|
|
173
175
|
}
|
|
174
176
|
|
|
175
177
|
const dataTypeNodeId = browseResult.references[0].nodeId;
|
|
@@ -177,14 +179,14 @@ export class ExtraDataTypeManager {
|
|
|
177
179
|
|
|
178
180
|
Constructor = dataTypeFactory.getConstructor(binaryEncodingNodeId);
|
|
179
181
|
if (!Constructor) {
|
|
180
|
-
throw new Error(
|
|
182
|
+
throw new Error(`Cannot find constructor for binary encoding ${binaryEncodingNodeId.toString()} after extraction`);
|
|
181
183
|
}
|
|
182
184
|
return Constructor;
|
|
183
185
|
}
|
|
184
186
|
|
|
185
187
|
public toString(): string {
|
|
186
188
|
const l: string[] = [];
|
|
187
|
-
function write(...args: [
|
|
189
|
+
function write(...args: [unknown, ...unknown[]]) {
|
|
188
190
|
l.push(format.apply(format, args));
|
|
189
191
|
}
|
|
190
192
|
write("ExtraDataTypeManager");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { NodeId } from "node-opcua-nodeid";
|
|
3
|
-
import { IBasicSessionAsync2 } from "node-opcua-pseudo-session";
|
|
4
|
-
import { AnyConstructorFunc } from "node-opcua-schemas";
|
|
1
|
+
import { AttributeIds, type QualifiedName } from "node-opcua-data-model";
|
|
2
|
+
import type { NodeId } from "node-opcua-nodeid";
|
|
3
|
+
import type { IBasicSessionAsync2 } from "node-opcua-pseudo-session";
|
|
4
|
+
import type { AnyConstructorFunc } from "node-opcua-schemas";
|
|
5
5
|
//
|
|
6
6
|
import { getExtraDataTypeManager } from "./get_extra_data_type_manager";
|
|
7
7
|
import { readDataTypeDefinitionAndBuildType } from "./private/populate_data_type_manager_104";
|
|
@@ -9,8 +9,10 @@ import { readDataTypeDefinitionAndBuildType } from "./private/populate_data_type
|
|
|
9
9
|
/**
|
|
10
10
|
*
|
|
11
11
|
*/
|
|
12
|
-
export async function getExtensionObjectConstructor(
|
|
13
|
-
|
|
12
|
+
export async function getExtensionObjectConstructor(
|
|
13
|
+
session: IBasicSessionAsync2,
|
|
14
|
+
dataTypeNodeId: NodeId
|
|
15
|
+
): Promise<AnyConstructorFunc> {
|
|
14
16
|
const dataTypeManager = await getExtraDataTypeManager(session);
|
|
15
17
|
|
|
16
18
|
const dataTypeFactory = dataTypeManager.getDataTypeFactory(dataTypeNodeId.namespace);
|
|
@@ -23,7 +25,10 @@ export async function getExtensionObjectConstructor(session: IBasicSessionAsync2
|
|
|
23
25
|
attributeId: AttributeIds.BrowseName
|
|
24
26
|
});
|
|
25
27
|
const browseName = dataValue.value.value as QualifiedName;
|
|
26
|
-
|
|
28
|
+
if (!browseName.name) {
|
|
29
|
+
throw new Error(`Unexpected: BrowseName has no name for nodeId ${dataTypeNodeId.toString()}`);
|
|
30
|
+
}
|
|
31
|
+
await readDataTypeDefinitionAndBuildType(session, dataTypeNodeId, browseName.name, dataTypeManager, {});
|
|
27
32
|
|
|
28
33
|
return await dataTypeManager.getExtensionObjectConstructorFromDataType(dataTypeNodeId);
|
|
29
34
|
}
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import { checkDebugFlag, make_debugLog, make_errorLog } from "node-opcua-debug";
|
|
2
2
|
import { DataTypeFactory, getStandardDataTypeFactory } from "node-opcua-factory";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
clearSessionCache,
|
|
6
|
-
readNamespaceArray
|
|
7
|
-
} from "node-opcua-pseudo-session";
|
|
8
|
-
import { NodeId } from "node-opcua-nodeid";
|
|
3
|
+
import type { NodeId } from "node-opcua-nodeid";
|
|
4
|
+
import { clearSessionCache, type IBasicSessionAsync2, readNamespaceArray } from "node-opcua-pseudo-session";
|
|
9
5
|
//
|
|
10
6
|
import { ExtraDataTypeManager } from "./extra_data_type_manager";
|
|
11
7
|
import { DataTypeExtractStrategy, populateDataTypeManager } from "./populate_data_type_manager";
|
|
12
8
|
|
|
13
|
-
|
|
14
9
|
const doDebug = checkDebugFlag(__filename);
|
|
15
10
|
const debugLog = make_debugLog(__filename);
|
|
16
11
|
const errorLog = make_errorLog(__filename);
|
|
@@ -26,7 +21,6 @@ export interface IBasicSessionAsync2Private extends IBasicSessionAsync2 {
|
|
|
26
21
|
on?: (this: IBasicSessionAsync2Private, event: "session_restored", func: () => void) => void;
|
|
27
22
|
|
|
28
23
|
sessionId?: NodeId;
|
|
29
|
-
|
|
30
24
|
}
|
|
31
25
|
export async function invalidateExtraDataTypeManager(session: IBasicSessionAsync2): Promise<void> {
|
|
32
26
|
const sessionPriv = session as IBasicSessionAsync2Private;
|
|
@@ -38,7 +32,10 @@ export async function invalidateExtraDataTypeManager(session: IBasicSessionAsync
|
|
|
38
32
|
}
|
|
39
33
|
}
|
|
40
34
|
|
|
41
|
-
async function extractDataTypeManagerPrivate(
|
|
35
|
+
async function extractDataTypeManagerPrivate(
|
|
36
|
+
session: IBasicSessionAsync2,
|
|
37
|
+
strategy: DataTypeExtractStrategy
|
|
38
|
+
): Promise<ExtraDataTypeManager> {
|
|
42
39
|
const namespaceArray = await readNamespaceArray(session);
|
|
43
40
|
// c8 ignore next
|
|
44
41
|
if (namespaceArray.length === 0) {
|
|
@@ -64,7 +61,6 @@ async function extractDataTypeManagerPrivate(session: IBasicSessionAsync2, strat
|
|
|
64
61
|
return dataTypeManager;
|
|
65
62
|
}
|
|
66
63
|
|
|
67
|
-
|
|
68
64
|
function getStrategy(session: IBasicSessionAsync2, strategy?: DataTypeExtractStrategy): DataTypeExtractStrategy {
|
|
69
65
|
if (strategy !== undefined) {
|
|
70
66
|
return strategy;
|
|
@@ -76,10 +72,9 @@ function getStrategy(session: IBasicSessionAsync2, strategy?: DataTypeExtractStr
|
|
|
76
72
|
return DataTypeExtractStrategy.Auto;
|
|
77
73
|
}
|
|
78
74
|
|
|
79
|
-
|
|
80
75
|
export function hasBoostedSession(session: IBasicSessionAsync2): boolean {
|
|
81
|
-
const _session: IBasicSessionAsync2Private = session as IBasicSessionAsync2Private;
|
|
82
|
-
return !!_session.$$getSessionForDataTypeExtraction || !!
|
|
76
|
+
const _session: IBasicSessionAsync2Private & ICascadingSession = session as IBasicSessionAsync2Private & ICascadingSession;
|
|
77
|
+
return !!_session.$$getSessionForDataTypeExtraction || !!_session.session;
|
|
83
78
|
}
|
|
84
79
|
export function getSessionForDataTypeManagerExtraction(session: IBasicSessionAsync2): IBasicSessionAsync2 {
|
|
85
80
|
const _session: IBasicSessionAsync2Private = session as IBasicSessionAsync2Private;
|
|
@@ -89,7 +84,7 @@ export function getSessionForDataTypeManagerExtraction(session: IBasicSessionAsy
|
|
|
89
84
|
return session;
|
|
90
85
|
}
|
|
91
86
|
|
|
92
|
-
type ICascadingSession = { session?: IBasicSessionAsync2
|
|
87
|
+
type ICascadingSession = { session?: IBasicSessionAsync2 };
|
|
93
88
|
function followSession(session: IBasicSessionAsync2Private & ICascadingSession): IBasicSessionAsync2Private {
|
|
94
89
|
if (session.session) {
|
|
95
90
|
return followSession(session.session);
|
|
@@ -97,24 +92,28 @@ function followSession(session: IBasicSessionAsync2Private & ICascadingSession):
|
|
|
97
92
|
return session;
|
|
98
93
|
}
|
|
99
94
|
|
|
100
|
-
export async function getExtraDataTypeManager(
|
|
101
|
-
|
|
95
|
+
export async function getExtraDataTypeManager(
|
|
96
|
+
session: IBasicSessionAsync2,
|
|
97
|
+
strategy?: DataTypeExtractStrategy
|
|
98
|
+
): Promise<ExtraDataTypeManager> {
|
|
102
99
|
const sessionPriv: IBasicSessionAsync2Private = followSession(session) as IBasicSessionAsync2Private;
|
|
103
100
|
|
|
104
101
|
if (sessionPriv.$$extraDataTypeManager) {
|
|
105
102
|
return sessionPriv.$$extraDataTypeManager;
|
|
106
103
|
}
|
|
107
104
|
|
|
108
|
-
|
|
105
|
+
const pendingList = sessionPriv.$$extraDataTypeManagerToResolve;
|
|
106
|
+
if (pendingList) {
|
|
109
107
|
doDebug && debugLog("getExtraDataTypeManager is re-entering !");
|
|
110
108
|
return await new Promise<ExtraDataTypeManager>((resolve, reject) => {
|
|
111
|
-
|
|
109
|
+
pendingList.push([resolve, reject]);
|
|
112
110
|
});
|
|
113
111
|
}
|
|
114
|
-
|
|
112
|
+
const newPendingList: [(a: ExtraDataTypeManager) => void, (err: Error) => void][] = [];
|
|
113
|
+
sessionPriv.$$extraDataTypeManagerToResolve = newPendingList;
|
|
115
114
|
|
|
116
115
|
return await new Promise<ExtraDataTypeManager>((_resolve, _reject) => {
|
|
117
|
-
|
|
116
|
+
newPendingList.push([_resolve, _reject]);
|
|
118
117
|
(async () => {
|
|
119
118
|
try {
|
|
120
119
|
strategy = getStrategy(session, strategy);
|
|
@@ -124,16 +123,14 @@ export async function getExtraDataTypeManager(session: IBasicSessionAsync2, stra
|
|
|
124
123
|
const dataTypeManager = await extractDataTypeManagerPrivate(sessionToUse, strategy);
|
|
125
124
|
// note: reconnection will call invalidateExtraDataTypeManager
|
|
126
125
|
// if the session is recreated
|
|
127
|
-
const tmp = sessionPriv.$$extraDataTypeManagerToResolve!;
|
|
128
126
|
sessionPriv.$$extraDataTypeManagerToResolve = undefined;
|
|
129
|
-
for (const [resolve] of
|
|
127
|
+
for (const [resolve] of newPendingList) {
|
|
130
128
|
resolve(dataTypeManager);
|
|
131
129
|
}
|
|
132
130
|
sessionPriv.$$extraDataTypeManager = dataTypeManager;
|
|
133
131
|
} catch (err) {
|
|
134
|
-
const tmp = sessionPriv.$$extraDataTypeManagerToResolve!;
|
|
135
132
|
sessionPriv.$$extraDataTypeManagerToResolve = undefined;
|
|
136
|
-
for (const [_resolve, reject] of
|
|
133
|
+
for (const [_resolve, reject] of newPendingList) {
|
|
137
134
|
reject(err as Error);
|
|
138
135
|
}
|
|
139
136
|
}
|
package/source/index.ts
CHANGED
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
10
10
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
|
11
11
|
* subject to the following conditions:
|
|
12
|
-
*
|
|
12
|
+
*
|
|
13
13
|
* The above copyright notice and this permission notice shall be included in all
|
|
14
14
|
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
15
|
+
*
|
|
16
16
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
17
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
18
18
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
/**
|
|
24
24
|
* @module node-opcua-client-dynamic-extension-object
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
|
|
27
|
+
export * from "./convert_data_type_definition_to_structuretype_schema";
|
|
28
|
+
export * from "./convert_structuretype_schema_to_structure_definition";
|
|
27
29
|
export * from "./extra_data_type_manager";
|
|
28
|
-
export * from "./resolve_dynamic_extension_object";
|
|
29
|
-
export * from "./promote_opaque_structure";
|
|
30
30
|
export * from "./get_extension_object_constructor";
|
|
31
31
|
export * from "./get_extra_data_type_manager";
|
|
32
|
-
export * from "./
|
|
33
|
-
export * from "./
|
|
34
|
-
export * from "./convert_structuretype_schema_to_structure_definition";
|
|
32
|
+
export * from "./populate_data_type_manager";
|
|
33
|
+
export * from "./promote_opaque_structure";
|
|
35
34
|
export * from "./promote_opaque_structure_in_notification_data";
|
|
35
|
+
export * from "./resolve_dynamic_extension_object";
|
|
@@ -1,36 +1,26 @@
|
|
|
1
|
+
import { DataTypeIds, ObjectIds, VariableIds, VariableTypeIds } from "node-opcua-constants";
|
|
1
2
|
import { AttributeIds, BrowseDirection, NodeClassMask, ResultMask } from "node-opcua-data-model";
|
|
3
|
+
import { checkDebugFlag, make_debugLog } from "node-opcua-debug";
|
|
4
|
+
import { DataTypeFactory } from "node-opcua-factory";
|
|
2
5
|
import { resolveNodeId } from "node-opcua-nodeid";
|
|
3
|
-
import {
|
|
4
|
-
IBasicSessionAsync2,
|
|
5
|
-
browseAll,
|
|
6
|
-
readNamespaceArray
|
|
7
|
-
} from "node-opcua-pseudo-session";
|
|
8
|
-
import { DataTypeIds, ObjectIds, VariableIds, VariableTypeIds } from "node-opcua-constants";
|
|
9
|
-
import { DataType } from "node-opcua-variant";
|
|
10
|
-
import { ReferenceDescription } from "node-opcua-types";
|
|
6
|
+
import { type IBasicSessionAsync2, readNamespaceArray } from "node-opcua-pseudo-session";
|
|
11
7
|
import { makeBrowsePath } from "node-opcua-service-translate-browse-path";
|
|
12
8
|
//
|
|
13
|
-
import { ExtraDataTypeManager } from "./extra_data_type_manager";
|
|
9
|
+
import type { ExtraDataTypeManager } from "./extra_data_type_manager";
|
|
14
10
|
import { populateDataTypeManager103 } from "./private/populate_data_type_manager_103";
|
|
15
11
|
import { populateDataTypeManager104 } from "./private/populate_data_type_manager_104";
|
|
16
|
-
import { DataTypeFactory } from "node-opcua-factory";
|
|
17
|
-
import { checkDebugFlag, make_debugLog } from "node-opcua-debug";
|
|
18
|
-
|
|
19
12
|
|
|
20
13
|
const doDebug = checkDebugFlag("populateDataTypeManager");
|
|
21
14
|
const debugLog = make_debugLog("populateDataTypeManager");
|
|
22
15
|
|
|
23
16
|
const ComplexTypes2017 = "http://opcfoundation.org/UA-Profile/Server/ComplexTypes2017";
|
|
24
17
|
|
|
25
|
-
export async function serverImplementsDataTypeDefinition(
|
|
26
|
-
session: IBasicSessionAsync2
|
|
27
|
-
): Promise<boolean> {
|
|
28
|
-
|
|
18
|
+
export async function serverImplementsDataTypeDefinition(session: IBasicSessionAsync2): Promise<boolean> {
|
|
29
19
|
const dataValueServerCapabilities = await session.read({
|
|
30
20
|
nodeId: resolveNodeId(VariableIds.Server_ServerCapabilities_ServerProfileArray),
|
|
31
21
|
attributeId: AttributeIds.Value
|
|
32
22
|
});
|
|
33
|
-
const serverCapabilities = dataValueServerCapabilities.value?.value as string[] ?? [];
|
|
23
|
+
const serverCapabilities = (dataValueServerCapabilities.value?.value as string[]) ?? [];
|
|
34
24
|
|
|
35
25
|
if (serverCapabilities.indexOf(ComplexTypes2017) >= 0) {
|
|
36
26
|
doDebug && debugLog("server implements ComplexTypes2017");
|
|
@@ -76,7 +66,7 @@ export async function serverImplementsDataTypeDefinition(
|
|
|
76
66
|
});
|
|
77
67
|
|
|
78
68
|
const references = browseResult2.references || [];
|
|
79
|
-
const customDataType = references.find(r => r.nodeId.namespace !== 0);
|
|
69
|
+
const customDataType = references.find((r) => r.nodeId.namespace !== 0);
|
|
80
70
|
if (customDataType) {
|
|
81
71
|
const dv = await session.read({ nodeId: customDataType.nodeId, attributeId: AttributeIds.DataTypeDefinition });
|
|
82
72
|
if (dv.statusCode.isGood()) {
|
|
@@ -84,7 +74,7 @@ export async function serverImplementsDataTypeDefinition(
|
|
|
84
74
|
return true;
|
|
85
75
|
}
|
|
86
76
|
} else {
|
|
87
|
-
const standardDataType = references.find(r => r.nodeId.namespace
|
|
77
|
+
const standardDataType = references.find((r) => r.nodeId.namespace === 0);
|
|
88
78
|
if (standardDataType) {
|
|
89
79
|
const dv = await session.read({ nodeId: standardDataType.nodeId, attributeId: AttributeIds.DataTypeDefinition });
|
|
90
80
|
if (dv.statusCode.isGood()) {
|
|
@@ -103,7 +93,7 @@ export async function serverImplementsDataTypeDefinition(
|
|
|
103
93
|
referenceTypeId: resolveNodeId("HasSubtype"),
|
|
104
94
|
resultMask: 63
|
|
105
95
|
});
|
|
106
|
-
const customDataType2 = (browseResult3.references || []).find(r => r.nodeId.namespace !== 0);
|
|
96
|
+
const customDataType2 = (browseResult3.references || []).find((r) => r.nodeId.namespace !== 0);
|
|
107
97
|
if (customDataType2) {
|
|
108
98
|
const dv = await session.read({ nodeId: customDataType2.nodeId, attributeId: AttributeIds.DataTypeDefinition });
|
|
109
99
|
if (dv.statusCode.isGood()) {
|
|
@@ -122,7 +112,7 @@ export enum DataTypeExtractStrategy {
|
|
|
122
112
|
Force104 = 2,
|
|
123
113
|
Both = 3,
|
|
124
114
|
Lazy = 4
|
|
125
|
-
}
|
|
115
|
+
}
|
|
126
116
|
|
|
127
117
|
export async function populateDataTypeManager(
|
|
128
118
|
session: IBasicSessionAsync2,
|
|
@@ -131,7 +121,6 @@ export async function populateDataTypeManager(
|
|
|
131
121
|
): Promise<void> {
|
|
132
122
|
dataTypeManager.setSession(session);
|
|
133
123
|
|
|
134
|
-
|
|
135
124
|
if (strategy === DataTypeExtractStrategy.Lazy) {
|
|
136
125
|
doDebug && debugLog("populateDataTypeManager: Lazy mode");
|
|
137
126
|
const force104 = await serverImplementsDataTypeDefinition(session);
|
|
@@ -165,17 +154,20 @@ export async function populateDataTypeManager(
|
|
|
165
154
|
await populateDataTypeManager104(session, dataTypeManager);
|
|
166
155
|
return;
|
|
167
156
|
}
|
|
168
|
-
doDebug &&
|
|
157
|
+
doDebug &&
|
|
158
|
+
debugLog(
|
|
159
|
+
"populateDataTypeManager: Auto mode - server does not implement 1.04 dictionary - we will be 103 eager and 104 eager"
|
|
160
|
+
);
|
|
169
161
|
// old way for 1.03 and early 1.04 prototype
|
|
170
162
|
await populateDataTypeManager103(session, dataTypeManager);
|
|
171
163
|
await populateDataTypeManager104(session, dataTypeManager);
|
|
172
164
|
return;
|
|
173
165
|
}
|
|
174
|
-
if (strategy
|
|
166
|
+
if (strategy === DataTypeExtractStrategy.Force103 || strategy === DataTypeExtractStrategy.Both) {
|
|
175
167
|
doDebug && debugLog("populateDataTypeManager: Force103 mode - we will be 103 eager");
|
|
176
168
|
await populateDataTypeManager103(session, dataTypeManager);
|
|
177
169
|
}
|
|
178
|
-
if (strategy
|
|
170
|
+
if (strategy === DataTypeExtractStrategy.Force104 || strategy === DataTypeExtractStrategy.Both) {
|
|
179
171
|
doDebug && debugLog("populateDataTypeManager: Force104 mode - we will be 104 eager");
|
|
180
172
|
await populateDataTypeManager104(session, dataTypeManager);
|
|
181
173
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BrowseDirection, makeNodeClassMask, makeResultMask } from "node-opcua-data-model";
|
|
2
2
|
import { NodeId, resolveNodeId } from "node-opcua-nodeid";
|
|
3
|
-
import { BrowseDescriptionLike, browseAll, ISessionForBrowseAll } from "node-opcua-pseudo-session";
|
|
4
|
-
import { DataTypeAndEncodingId } from "node-opcua-schemas";
|
|
3
|
+
import { type BrowseDescriptionLike, browseAll, type ISessionForBrowseAll } from "node-opcua-pseudo-session";
|
|
4
|
+
import type { DataTypeAndEncodingId } from "node-opcua-schemas";
|
|
5
5
|
|
|
6
6
|
export async function _findEncodings(session: ISessionForBrowseAll, dataTypeNodeId: NodeId): Promise<DataTypeAndEncodingId> {
|
|
7
7
|
const nodeToBrowse: BrowseDescriptionLike = {
|