node-opcua-client-dynamic-extension-object 2.83.0 → 2.85.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/get_extra_data_type_manager.js +1 -1
- package/dist/get_extra_data_type_manager.js.map +1 -1
- package/dist/populate_data_type_manager.d.ts +1 -1
- package/dist/populate_data_type_manager.js +2 -5
- package/dist/populate_data_type_manager.js.map +1 -1
- package/dist/private/populate_data_type_manager_104.js +45 -33
- package/dist/private/populate_data_type_manager_104.js.map +1 -1
- package/package.json +16 -16
- package/source/get_extra_data_type_manager.ts +1 -1
- package/source/populate_data_type_manager.ts +1 -5
- package/source/private/populate_data_type_manager_104.ts +55 -42
|
@@ -39,7 +39,7 @@ function getExtraDataTypeManager(session) {
|
|
|
39
39
|
const dataTypeFactory1 = new node_opcua_factory_1.DataTypeFactory([(0, node_opcua_factory_1.getStandardDataTypeFactory)()]);
|
|
40
40
|
dataTypeManager.registerDataTypeFactory(namespaceIndex, dataTypeFactory1);
|
|
41
41
|
}
|
|
42
|
-
yield (0, populate_data_type_manager_1.populateDataTypeManager)(session, dataTypeManager
|
|
42
|
+
yield (0, populate_data_type_manager_1.populateDataTypeManager)(session, dataTypeManager);
|
|
43
43
|
}
|
|
44
44
|
// istanbul ignore next
|
|
45
45
|
if (sessionPriv.$$extraDataTypeManager.namespaceArray.length === 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_extra_data_type_manager.js","sourceRoot":"","sources":["../source/get_extra_data_type_manager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uDAAgF;AAChF,2DAAiF;AACjF,yEAA8E;AAC9E,EAAE;AACF,uEAAiE;AACjE,6EAAuE;AAEvE,MAAM,OAAO,GAAG,IAAA,iCAAc,EAAC,UAAU,CAAC,CAAC;AAC3C,MAAM,QAAQ,GAAG,IAAA,gCAAa,EAAC,UAAU,CAAC,CAAC;AAC3C,MAAM,QAAQ,GAAG,IAAA,g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IBasicSession } from "node-opcua-pseudo-session";
|
|
2
2
|
import { ExtraDataTypeManager } from "./extra_data_type_manager";
|
|
3
|
-
export declare function populateDataTypeManager(session: IBasicSession, dataTypeManager: ExtraDataTypeManager
|
|
3
|
+
export declare function populateDataTypeManager(session: IBasicSession, dataTypeManager: ExtraDataTypeManager): Promise<void>;
|
|
@@ -73,7 +73,7 @@ function serverImplementsDataTypeDefinition(session) {
|
|
|
73
73
|
return false;
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
|
-
function populateDataTypeManager(session, dataTypeManager
|
|
76
|
+
function populateDataTypeManager(session, dataTypeManager) {
|
|
77
77
|
return __awaiter(this, void 0, void 0, function* () {
|
|
78
78
|
const force104 = yield serverImplementsDataTypeDefinition(session);
|
|
79
79
|
if (force104) {
|
|
@@ -83,10 +83,7 @@ function populateDataTypeManager(session, dataTypeManager, force) {
|
|
|
83
83
|
}
|
|
84
84
|
// old way for 1.03 and early 1.04 prototype
|
|
85
85
|
yield (0, populate_data_type_manager_103_1.populateDataTypeManager103)(session, dataTypeManager);
|
|
86
|
-
|
|
87
|
-
if (force) {
|
|
88
|
-
yield (0, populate_data_type_manager_104_1.populateDataTypeManager104)(session, dataTypeManager);
|
|
89
|
-
}
|
|
86
|
+
yield (0, populate_data_type_manager_104_1.populateDataTypeManager104)(session, dataTypeManager);
|
|
90
87
|
});
|
|
91
88
|
}
|
|
92
89
|
exports.populateDataTypeManager = populateDataTypeManager;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"populate_data_type_manager.js","sourceRoot":"","sources":["../source/populate_data_type_manager.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,iEAAqF;AACrF,yDAAgE;AAChE,yEAAqE;AACrE,+DAAmD;AAEnD,mEAAqD;AACrD,2DAA8C;AAI9C,6FAAsF;AACtF,6FAAsF;AAEtF,SAAe,kCAAkC,CAAC,OAAsB;;QACpE,0FAA0F;QAC1F,6DAA6D;QAC7D,MAAM,YAAY,GAAG,MAA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E,CAAC,CAAC,CAAC;QACtG,IAAI,OAAO,KAAK,UAAU,CAAC,MAAM,EAAE;YAC/B,OAAO,IAAI,CAAC;YACZ,8DAA8D;YAC9D,UAAU;SACb;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;CAAA;AAED,SAAsB,uBAAuB,CACzC,OAAsB,EACtB,eAAqC;;QAErC,MAAM,QAAQ,GAAG,MAAM,kCAAkC,CAAC,OAAO,CAAC,CAAC;QACnE,IAAI,QAAQ,EAAE;YACV,sCAAsC;YACtC,MAAM,IAAA,2DAA0B,EAAC,OAAO,EAAE,eAAe,CAAC,CAAC;YAC3D,OAAO;SACV;QACD,4CAA4C;QAC5C,MAAM,IAAA,2DAA0B,EAAC,OAAO,EAAE,eAAe,CAAC,CAAC;QAC3D,MAAM,IAAA,2DAA0B,EAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IAC/D,CAAC;CAAA;AAbD,0DAaC"}
|
|
@@ -12,16 +12,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.populateDataTypeManager104 = exports.readDataTypeDefinitionAndBuildType = void 0;
|
|
13
13
|
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
14
14
|
const node_opcua_debug_1 = require("node-opcua-debug");
|
|
15
|
+
const node_opcua_factory_1 = require("node-opcua-factory");
|
|
15
16
|
const node_opcua_nodeid_1 = require("node-opcua-nodeid");
|
|
17
|
+
const node_opcua_pseudo_session_1 = require("node-opcua-pseudo-session");
|
|
16
18
|
const node_opcua_schemas_1 = require("node-opcua-schemas");
|
|
17
19
|
const node_opcua_status_code_1 = require("node-opcua-status-code");
|
|
18
20
|
const node_opcua_types_1 = require("node-opcua-types");
|
|
19
21
|
const convert_data_type_definition_to_structuretype_schema_1 = require("../convert_data_type_definition_to_structuretype_schema");
|
|
20
22
|
const errorLog = (0, node_opcua_debug_1.make_errorLog)(__filename);
|
|
21
23
|
const debugLog = (0, node_opcua_debug_1.make_debugLog)(__filename);
|
|
24
|
+
const warningLog = (0, node_opcua_debug_1.make_warningLog)(__filename);
|
|
22
25
|
function readDataTypeDefinitionAndBuildType(session, dataTypeNodeId, name, dataTypeFactory, cache) {
|
|
23
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
27
|
try {
|
|
28
|
+
if (dataTypeFactory.getStructureInfoForDataType(dataTypeNodeId)) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
25
31
|
const [isAbstractDataValue, dataTypeDefinitionDataValue] = yield session.read([
|
|
26
32
|
{
|
|
27
33
|
attributeId: node_opcua_data_model_1.AttributeIds.IsAbstract,
|
|
@@ -40,8 +46,10 @@ function readDataTypeDefinitionAndBuildType(session, dataTypeNodeId, name, dataT
|
|
|
40
46
|
let dataTypeDefinition = dataTypeDefinitionDataValue.value.value;
|
|
41
47
|
/* istanbul ignore next */
|
|
42
48
|
if (dataTypeDefinitionDataValue.statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
|
|
49
|
+
// may be we are reading a 1.03 server
|
|
43
50
|
if (!isAbstract) {
|
|
44
|
-
|
|
51
|
+
warningLog(" Cannot find dataType Definition ! with nodeId =" + dataTypeNodeId.toString());
|
|
52
|
+
return;
|
|
45
53
|
}
|
|
46
54
|
// it is OK to not have dataTypeDefinition for Abstract type!
|
|
47
55
|
dataTypeDefinition = new node_opcua_types_1.StructureDefinition();
|
|
@@ -111,42 +119,46 @@ class TaskMan {
|
|
|
111
119
|
}
|
|
112
120
|
function applyOnReferenceRecursively(session, nodeId, browseDescriptionTemplate, action) {
|
|
113
121
|
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
-
const
|
|
122
|
+
const taskMananager = new TaskMan();
|
|
115
123
|
let pendingNodesToBrowse = [];
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
for (
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
+
function processBrowseResults(nodesToBrowse, browseResults) {
|
|
125
|
+
var _a;
|
|
126
|
+
for (let i = 0; i < browseResults.length; i++) {
|
|
127
|
+
const result = browseResults[i];
|
|
128
|
+
const nodeToBrowse = nodesToBrowse[i];
|
|
129
|
+
if (result.statusCode === node_opcua_status_code_1.StatusCodes.BadNoContinuationPoints ||
|
|
130
|
+
result.statusCode === node_opcua_status_code_1.StatusCodes.BadContinuationPointInvalid) {
|
|
131
|
+
// not enough continuation points .. we need to rebrowse
|
|
132
|
+
pendingNodesToBrowse.push(nodeToBrowse);
|
|
133
|
+
// taskMananager.registerTask(flushBrowse);
|
|
134
|
+
}
|
|
135
|
+
else if (result.statusCode === node_opcua_status_code_1.StatusCodes.Good) {
|
|
124
136
|
for (const r of result.references || []) {
|
|
125
|
-
taskMan.registerTask(() => __awaiter(this, void 0, void 0, function* () {
|
|
126
|
-
yield action(r);
|
|
127
|
-
}));
|
|
128
137
|
// also explore sub types
|
|
129
138
|
browseSubDataTypeRecursively(r.nodeId);
|
|
139
|
+
taskMananager.registerTask(() => __awaiter(this, void 0, void 0, function* () { return yield action(r); }));
|
|
130
140
|
}
|
|
131
141
|
}
|
|
142
|
+
else {
|
|
143
|
+
errorLog("Unexpected status code", i, (_a = new node_opcua_types_1.BrowseDescription(nodesToBrowse[i] || {})) === null || _a === void 0 ? void 0 : _a.toString(), result.statusCode.toString());
|
|
144
|
+
}
|
|
132
145
|
}
|
|
133
146
|
}
|
|
134
147
|
function flushBrowse() {
|
|
135
148
|
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
-
if (
|
|
137
|
-
const continuationPoints = pendingContinuationPoints;
|
|
138
|
-
pendingContinuationPoints = [];
|
|
139
|
-
taskMan.registerTask(() => __awaiter(this, void 0, void 0, function* () {
|
|
140
|
-
const browseResults = yield session.browseNext(continuationPoints, false);
|
|
141
|
-
processBrowseResult(browseResults);
|
|
142
|
-
}));
|
|
143
|
-
}
|
|
144
|
-
else if (pendingNodesToBrowse.length) {
|
|
149
|
+
if (pendingNodesToBrowse.length) {
|
|
145
150
|
const nodesToBrowse = pendingNodesToBrowse;
|
|
146
151
|
pendingNodesToBrowse = [];
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
152
|
+
taskMananager.registerTask(() => __awaiter(this, void 0, void 0, function* () {
|
|
153
|
+
try {
|
|
154
|
+
// YY console.log(" reading ", nodesToBrowse.length);
|
|
155
|
+
const browseResults = yield (0, node_opcua_pseudo_session_1.browseAll)(session, nodesToBrowse);
|
|
156
|
+
processBrowseResults(nodesToBrowse, browseResults);
|
|
157
|
+
}
|
|
158
|
+
catch (err) {
|
|
159
|
+
errorLog("err", err.message);
|
|
160
|
+
errorLog(nodesToBrowse.toString());
|
|
161
|
+
}
|
|
150
162
|
}));
|
|
151
163
|
}
|
|
152
164
|
});
|
|
@@ -154,12 +166,10 @@ function applyOnReferenceRecursively(session, nodeId, browseDescriptionTemplate,
|
|
|
154
166
|
function browseSubDataTypeRecursively(nodeId) {
|
|
155
167
|
const nodeToBrowse = Object.assign(Object.assign({}, browseDescriptionTemplate), { nodeId });
|
|
156
168
|
pendingNodesToBrowse.push(nodeToBrowse);
|
|
157
|
-
|
|
158
|
-
flushBrowse();
|
|
159
|
-
}));
|
|
169
|
+
taskMananager.registerTask(() => __awaiter(this, void 0, void 0, function* () { return flushBrowse(); }));
|
|
160
170
|
}
|
|
161
171
|
browseSubDataTypeRecursively(nodeId);
|
|
162
|
-
yield
|
|
172
|
+
yield taskMananager.waitForCompletion();
|
|
163
173
|
});
|
|
164
174
|
}
|
|
165
175
|
function populateDataTypeManager104(session, dataTypeManager) {
|
|
@@ -169,14 +179,16 @@ function populateDataTypeManager104(session, dataTypeManager) {
|
|
|
169
179
|
return __awaiter(this, void 0, void 0, function* () {
|
|
170
180
|
const dataTypeNodeId = r.nodeId;
|
|
171
181
|
try {
|
|
172
|
-
const dataTypeFactory = dataTypeManager.getDataTypeFactory(dataTypeNodeId.namespace);
|
|
173
|
-
if (!dataTypeFactory) {
|
|
174
|
-
throw new Error("cannot find dataType Manager for namespace of " + dataTypeNodeId.toString());
|
|
175
|
-
}
|
|
176
182
|
if (dataTypeNodeId.namespace === 0) {
|
|
177
183
|
// already known I guess
|
|
178
184
|
return;
|
|
179
185
|
}
|
|
186
|
+
let dataTypeFactory = dataTypeManager.getDataTypeFactory(dataTypeNodeId.namespace);
|
|
187
|
+
if (!dataTypeFactory) {
|
|
188
|
+
dataTypeFactory = new node_opcua_factory_1.DataTypeFactory([]);
|
|
189
|
+
dataTypeManager.registerDataTypeFactory(dataTypeNodeId.namespace, dataTypeFactory);
|
|
190
|
+
// throw new Error("cannot find dataType Manager for namespace of " + dataTypeNodeId.toString());
|
|
191
|
+
}
|
|
180
192
|
// if not found already
|
|
181
193
|
if (dataTypeFactory.getStructureInfoForDataType(dataTypeNodeId)) {
|
|
182
194
|
// already known !
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"populate_data_type_manager_104.js","sourceRoot":"","sources":["../../source/private/populate_data_type_manager_104.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,iEAAsE;AACtE,
|
|
1
|
+
{"version":3,"file":"populate_data_type_manager_104.js","sourceRoot":"","sources":["../../source/private/populate_data_type_manager_104.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,iEAAsE;AACtE,uDAAiF;AACjF,2DAAqD;AACrD,yDAA0D;AAC1D,yEAA4F;AAC5F,2DAAiH;AACjH,mEAAqD;AACrD,uDAO0B;AAG1B,kIAGiE;AAEjE,MAAM,QAAQ,GAAG,IAAA,gCAAa,EAAC,UAAU,CAAC,CAAC;AAC3C,MAAM,QAAQ,GAAG,IAAA,gCAAa,EAAC,UAAU,CAAC,CAAC;AAC3C,MAAM,UAAU,GAAG,IAAA,kCAAe,EAAC,UAAU,CAAC,CAAC;AAE/C,SAAsB,kCAAkC,CACpD,OAAsB,EACtB,cAAsB,EACtB,IAAY,EACZ,eAAgC,EAChC,KAAiD;;QAEjD,IAAI;YACA,IAAI,eAAe,CAAC,2BAA2B,CAAC,cAAc,CAAC,EAAE;gBAC7D,OAAO;aACV;YAC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AAC,CAAC;oBACnF,IAAI,CAAC,eAAe,EAAE;wBAClB,eAAe,GAAG,IAAI,oCAAe,CAAC,EAAE,CAAC,CAAC;wBAC1C,eAAe,CAAC,uBAAuB,CAAC,cAAc,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;wBACnF,mGAAmG;qBACtG;oBACD,uBAAuB;oBACvB,IAAI,eAAe,CAAC,2BAA2B,CAAC,cAAc,CAAC,EAAE;wBAC7D,kBAAkB;wBAClB,OAAO;qBACV;oBACD,sBAAsB;oBACtB,QAAQ,CAAC,eAAe,EAAE,CAAC,CAAC,UAAU,CAAC,QAAQ,EAAE,EAAE,cAAc,CAAC,QAAQ,EAAE,CAAC,CAAC;oBAC9E,MAAM,kCAAkC,CAAC,OAAO,EAAE,cAAc,EAAE,CAAC,CAAC,UAAU,CAAC,IAAK,EAAE,eAAe,EAAE,KAAK,CAAC,CAAC;iBACjH;gBAAC,OAAO,GAAG,EAAE;oBACV,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;iBACzB;YACL,CAAC;SAAA;QAED,MAAM,YAAY,GAA6B;YAC3C,MAAM,EAAE,0BAAM,CAAC,UAAU;YACzB,eAAe,EAAE,IAAI;YACrB,eAAe,EAAE,uCAAe,CAAC,OAAO;YACxC,aAAa,EAAE,IAAI;YACnB,eAAe,EAAE,IAAA,iCAAa,EAAC,YAAY,CAAC;YAC5C,UAAU,EAAE,IAAI;SACnB,CAAC;QACF,MAAM,2BAA2B,CAAC,OAAO,EAAE,IAAA,iCAAa,EAAC,WAAW,CAAC,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;IACvG,CAAC;CAAA;AAtCD,gEAsCC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-opcua-client-dynamic-extension-object",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.85.0",
|
|
4
4
|
"description": "pure nodejs OPCUA SDK - module client-dynamic-extension-object",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -12,21 +12,21 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"chalk": "4.1.2",
|
|
14
14
|
"node-opcua-assert": "2.77.0",
|
|
15
|
-
"node-opcua-binary-stream": "2.
|
|
15
|
+
"node-opcua-binary-stream": "2.85.0",
|
|
16
16
|
"node-opcua-constants": "2.77.0",
|
|
17
|
-
"node-opcua-data-model": "2.
|
|
18
|
-
"node-opcua-data-value": "2.
|
|
19
|
-
"node-opcua-debug": "2.
|
|
20
|
-
"node-opcua-extension-object": "2.
|
|
21
|
-
"node-opcua-factory": "2.
|
|
22
|
-
"node-opcua-nodeid": "2.
|
|
23
|
-
"node-opcua-pseudo-session": "2.
|
|
24
|
-
"node-opcua-schemas": "2.
|
|
25
|
-
"node-opcua-service-browse": "2.
|
|
26
|
-
"node-opcua-service-translate-browse-path": "2.
|
|
27
|
-
"node-opcua-status-code": "2.
|
|
28
|
-
"node-opcua-types": "2.
|
|
29
|
-
"node-opcua-variant": "2.
|
|
17
|
+
"node-opcua-data-model": "2.85.0",
|
|
18
|
+
"node-opcua-data-value": "2.85.0",
|
|
19
|
+
"node-opcua-debug": "2.85.0",
|
|
20
|
+
"node-opcua-extension-object": "2.85.0",
|
|
21
|
+
"node-opcua-factory": "2.85.0",
|
|
22
|
+
"node-opcua-nodeid": "2.85.0",
|
|
23
|
+
"node-opcua-pseudo-session": "2.85.0",
|
|
24
|
+
"node-opcua-schemas": "2.85.0",
|
|
25
|
+
"node-opcua-service-browse": "2.85.0",
|
|
26
|
+
"node-opcua-service-translate-browse-path": "2.85.0",
|
|
27
|
+
"node-opcua-status-code": "2.85.0",
|
|
28
|
+
"node-opcua-types": "2.85.0",
|
|
29
|
+
"node-opcua-variant": "2.85.0"
|
|
30
30
|
},
|
|
31
31
|
"author": "Etienne Rossignon",
|
|
32
32
|
"license": "MIT",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"internet of things"
|
|
44
44
|
],
|
|
45
45
|
"homepage": "http://node-opcua.github.io/",
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "68498fcf7b20ea9f7bd66e8529c546221daf5d52"
|
|
47
47
|
}
|
|
@@ -33,7 +33,7 @@ export async function getExtraDataTypeManager(session: IBasicSession): Promise<E
|
|
|
33
33
|
const dataTypeFactory1 = new DataTypeFactory([getStandardDataTypeFactory()]);
|
|
34
34
|
dataTypeManager.registerDataTypeFactory(namespaceIndex, dataTypeFactory1);
|
|
35
35
|
}
|
|
36
|
-
await populateDataTypeManager(session, dataTypeManager
|
|
36
|
+
await populateDataTypeManager(session, dataTypeManager);
|
|
37
37
|
}
|
|
38
38
|
// istanbul ignore next
|
|
39
39
|
if (sessionPriv.$$extraDataTypeManager.namespaceArray.length === 0) {
|
|
@@ -74,7 +74,6 @@ async function serverImplementsDataTypeDefinition(session: IBasicSession): Promi
|
|
|
74
74
|
export async function populateDataTypeManager(
|
|
75
75
|
session: IBasicSession,
|
|
76
76
|
dataTypeManager: ExtraDataTypeManager,
|
|
77
|
-
force: boolean
|
|
78
77
|
): Promise<void> {
|
|
79
78
|
const force104 = await serverImplementsDataTypeDefinition(session);
|
|
80
79
|
if (force104) {
|
|
@@ -84,8 +83,5 @@ export async function populateDataTypeManager(
|
|
|
84
83
|
}
|
|
85
84
|
// old way for 1.03 and early 1.04 prototype
|
|
86
85
|
await populateDataTypeManager103(session, dataTypeManager);
|
|
87
|
-
|
|
88
|
-
if (force) {
|
|
89
|
-
await populateDataTypeManager104(session, dataTypeManager);
|
|
90
|
-
}
|
|
86
|
+
await populateDataTypeManager104(session, dataTypeManager);
|
|
91
87
|
}
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { assert } from "node-opcua-assert";
|
|
2
2
|
import { AttributeIds, BrowseDirection } from "node-opcua-data-model";
|
|
3
|
-
import { make_debugLog, make_errorLog } from "node-opcua-debug";
|
|
3
|
+
import { make_debugLog, make_errorLog, make_warningLog } from "node-opcua-debug";
|
|
4
4
|
import { DataTypeFactory } from "node-opcua-factory";
|
|
5
|
-
import { NodeId,
|
|
6
|
-
import { IBasicSession, BrowseDescriptionLike } from "node-opcua-pseudo-session";
|
|
5
|
+
import { NodeId, resolveNodeId } from "node-opcua-nodeid";
|
|
6
|
+
import { IBasicSession, BrowseDescriptionLike, browseAll } from "node-opcua-pseudo-session";
|
|
7
7
|
import { createDynamicObjectConstructor as createDynamicObjectConstructorAndRegister } from "node-opcua-schemas";
|
|
8
8
|
import { StatusCodes } from "node-opcua-status-code";
|
|
9
|
-
import {
|
|
10
|
-
|
|
9
|
+
import {
|
|
10
|
+
ReferenceDescription,
|
|
11
|
+
BrowseResult,
|
|
12
|
+
BrowseDescriptionOptions,
|
|
13
|
+
StructureDefinition,
|
|
14
|
+
DataTypeDefinition,
|
|
15
|
+
BrowseDescription
|
|
16
|
+
} from "node-opcua-types";
|
|
11
17
|
//
|
|
12
18
|
import { ExtraDataTypeManager } from "../extra_data_type_manager";
|
|
13
19
|
import {
|
|
@@ -17,6 +23,7 @@ import {
|
|
|
17
23
|
|
|
18
24
|
const errorLog = make_errorLog(__filename);
|
|
19
25
|
const debugLog = make_debugLog(__filename);
|
|
26
|
+
const warningLog = make_warningLog(__filename);
|
|
20
27
|
|
|
21
28
|
export async function readDataTypeDefinitionAndBuildType(
|
|
22
29
|
session: IBasicSession,
|
|
@@ -24,8 +31,11 @@ export async function readDataTypeDefinitionAndBuildType(
|
|
|
24
31
|
name: string,
|
|
25
32
|
dataTypeFactory: DataTypeFactory,
|
|
26
33
|
cache: { [key: string]: CacheForFieldResolution }
|
|
27
|
-
) {
|
|
34
|
+
): Promise<void> {
|
|
28
35
|
try {
|
|
36
|
+
if (dataTypeFactory.getStructureInfoForDataType(dataTypeNodeId)) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
29
39
|
const [isAbstractDataValue, dataTypeDefinitionDataValue] = await session.read([
|
|
30
40
|
{
|
|
31
41
|
attributeId: AttributeIds.IsAbstract,
|
|
@@ -45,13 +55,15 @@ export async function readDataTypeDefinitionAndBuildType(
|
|
|
45
55
|
let dataTypeDefinition: DataTypeDefinition = dataTypeDefinitionDataValue.value.value as DataTypeDefinition;
|
|
46
56
|
/* istanbul ignore next */
|
|
47
57
|
if (dataTypeDefinitionDataValue.statusCode !== StatusCodes.Good) {
|
|
58
|
+
// may be we are reading a 1.03 server
|
|
48
59
|
if (!isAbstract) {
|
|
49
|
-
|
|
60
|
+
warningLog(" Cannot find dataType Definition ! with nodeId =" + dataTypeNodeId.toString());
|
|
61
|
+
return;
|
|
50
62
|
}
|
|
51
63
|
// it is OK to not have dataTypeDefinition for Abstract type!
|
|
52
64
|
dataTypeDefinition = new StructureDefinition();
|
|
53
65
|
}
|
|
54
|
-
|
|
66
|
+
|
|
55
67
|
const schema = await convertDataTypeDefinitionToStructureTypeSchema(
|
|
56
68
|
session,
|
|
57
69
|
dataTypeNodeId,
|
|
@@ -64,7 +76,6 @@ export async function readDataTypeDefinitionAndBuildType(
|
|
|
64
76
|
if (isAbstract) {
|
|
65
77
|
// cannot construct an abstract structure
|
|
66
78
|
dataTypeFactory.registerAbstractStructure(dataTypeNodeId, name, schema);
|
|
67
|
-
|
|
68
79
|
} else {
|
|
69
80
|
const Constructor = createDynamicObjectConstructorAndRegister(schema, dataTypeFactory);
|
|
70
81
|
}
|
|
@@ -122,42 +133,45 @@ async function applyOnReferenceRecursively(
|
|
|
122
133
|
browseDescriptionTemplate: BrowseDescriptionOptions,
|
|
123
134
|
action: (ref: ReferenceDescription) => Promise<void>
|
|
124
135
|
): Promise<void> {
|
|
125
|
-
const
|
|
136
|
+
const taskMananager = new TaskMan();
|
|
126
137
|
|
|
127
|
-
let pendingNodesToBrowse:
|
|
128
|
-
let pendingContinuationPoints: Buffer[] = [];
|
|
138
|
+
let pendingNodesToBrowse: BrowseDescriptionOptions[] = [];
|
|
129
139
|
|
|
130
|
-
function
|
|
131
|
-
for (
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
140
|
+
function processBrowseResults(nodesToBrowse: BrowseDescriptionOptions[], browseResults: BrowseResult[]) {
|
|
141
|
+
for (let i = 0; i < browseResults.length; i++) {
|
|
142
|
+
const result = browseResults[i];
|
|
143
|
+
const nodeToBrowse = nodesToBrowse[i];
|
|
144
|
+
if (
|
|
145
|
+
result.statusCode === StatusCodes.BadNoContinuationPoints ||
|
|
146
|
+
result.statusCode === StatusCodes.BadContinuationPointInvalid
|
|
147
|
+
) {
|
|
148
|
+
// not enough continuation points .. we need to rebrowse
|
|
149
|
+
pendingNodesToBrowse.push(nodeToBrowse);
|
|
150
|
+
// taskMananager.registerTask(flushBrowse);
|
|
151
|
+
} else if (result.statusCode === StatusCodes.Good) {
|
|
137
152
|
for (const r of result.references || []) {
|
|
138
|
-
taskMan.registerTask(async () => {
|
|
139
|
-
await action(r);
|
|
140
|
-
});
|
|
141
153
|
// also explore sub types
|
|
142
154
|
browseSubDataTypeRecursively(r.nodeId);
|
|
155
|
+
taskMananager.registerTask(async () => await action(r));
|
|
143
156
|
}
|
|
157
|
+
} else {
|
|
158
|
+
errorLog("Unexpected status code", i, new BrowseDescription(nodesToBrowse[i]||{})?.toString(), result.statusCode.toString());
|
|
144
159
|
}
|
|
145
160
|
}
|
|
146
161
|
}
|
|
147
162
|
async function flushBrowse() {
|
|
148
|
-
if (
|
|
149
|
-
const continuationPoints = pendingContinuationPoints;
|
|
150
|
-
pendingContinuationPoints = [];
|
|
151
|
-
taskMan.registerTask(async () => {
|
|
152
|
-
const browseResults = await session.browseNext(continuationPoints, false);
|
|
153
|
-
processBrowseResult(browseResults);
|
|
154
|
-
});
|
|
155
|
-
} else if (pendingNodesToBrowse.length) {
|
|
163
|
+
if (pendingNodesToBrowse.length) {
|
|
156
164
|
const nodesToBrowse = pendingNodesToBrowse;
|
|
157
165
|
pendingNodesToBrowse = [];
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
166
|
+
taskMananager.registerTask(async () => {
|
|
167
|
+
try {
|
|
168
|
+
// YY console.log(" reading ", nodesToBrowse.length);
|
|
169
|
+
const browseResults = await browseAll(session, nodesToBrowse);
|
|
170
|
+
processBrowseResults(nodesToBrowse, browseResults);
|
|
171
|
+
} catch (err) {
|
|
172
|
+
errorLog("err", (err as Error).message);
|
|
173
|
+
errorLog(nodesToBrowse.toString());
|
|
174
|
+
}
|
|
161
175
|
});
|
|
162
176
|
}
|
|
163
177
|
}
|
|
@@ -168,12 +182,10 @@ async function applyOnReferenceRecursively(
|
|
|
168
182
|
nodeId
|
|
169
183
|
};
|
|
170
184
|
pendingNodesToBrowse.push(nodeToBrowse);
|
|
171
|
-
|
|
172
|
-
flushBrowse();
|
|
173
|
-
});
|
|
185
|
+
taskMananager.registerTask(async () => flushBrowse());
|
|
174
186
|
}
|
|
175
187
|
browseSubDataTypeRecursively(nodeId);
|
|
176
|
-
await
|
|
188
|
+
await taskMananager.waitForCompletion();
|
|
177
189
|
}
|
|
178
190
|
export async function populateDataTypeManager104(session: IBasicSession, dataTypeManager: ExtraDataTypeManager): Promise<void> {
|
|
179
191
|
const cache: { [key: string]: CacheForFieldResolution } = {};
|
|
@@ -181,15 +193,16 @@ export async function populateDataTypeManager104(session: IBasicSession, dataTyp
|
|
|
181
193
|
async function withDataType(r: ReferenceDescription): Promise<void> {
|
|
182
194
|
const dataTypeNodeId = r.nodeId;
|
|
183
195
|
try {
|
|
184
|
-
const dataTypeFactory = dataTypeManager.getDataTypeFactory(dataTypeNodeId.namespace);
|
|
185
|
-
if(!dataTypeFactory) {
|
|
186
|
-
throw new Error("cannot find dataType Manager for namespace of " + dataTypeNodeId.toString());
|
|
187
|
-
}
|
|
188
196
|
if (dataTypeNodeId.namespace === 0) {
|
|
189
197
|
// already known I guess
|
|
190
198
|
return;
|
|
191
199
|
}
|
|
192
|
-
|
|
200
|
+
let dataTypeFactory = dataTypeManager.getDataTypeFactory(dataTypeNodeId.namespace);
|
|
201
|
+
if (!dataTypeFactory) {
|
|
202
|
+
dataTypeFactory = new DataTypeFactory([]);
|
|
203
|
+
dataTypeManager.registerDataTypeFactory(dataTypeNodeId.namespace, dataTypeFactory);
|
|
204
|
+
// throw new Error("cannot find dataType Manager for namespace of " + dataTypeNodeId.toString());
|
|
205
|
+
}
|
|
193
206
|
// if not found already
|
|
194
207
|
if (dataTypeFactory.getStructureInfoForDataType(dataTypeNodeId)) {
|
|
195
208
|
// already known !
|