node-opcua-client-dynamic-extension-object 2.64.1 → 2.66.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 +12 -12
- package/dist/convert_data_type_definition_to_structuretype_schema.js +331 -327
- package/dist/convert_data_type_definition_to_structuretype_schema.js.map +1 -1
- package/dist/extra_data_type_manager.d.ts +16 -16
- package/dist/extra_data_type_manager.js +75 -75
- package/dist/get_extension_object_constructor.d.ts +7 -7
- package/dist/get_extension_object_constructor.js +37 -37
- package/dist/get_extra_data_type_manager.d.ts +3 -3
- package/dist/get_extra_data_type_manager.js +51 -51
- package/dist/index.d.ts +11 -11
- package/dist/index.js +27 -23
- package/dist/index.js.map +1 -1
- package/dist/populate_data_type_manager.d.ts +3 -3
- package/dist/populate_data_type_manager.js +25 -25
- package/dist/private/find_encodings.d.ts +4 -4
- package/dist/private/find_encodings.js +55 -55
- package/dist/private/populate_data_type_manager_103.d.ts +9 -9
- package/dist/private/populate_data_type_manager_103.js +601 -601
- package/dist/private/populate_data_type_manager_104.d.ts +9 -9
- package/dist/private/populate_data_type_manager_104.js +145 -145
- package/dist/promote_opaque_structure.d.ts +6 -6
- package/dist/promote_opaque_structure.js +41 -41
- package/dist/resolve_dynamic_extension_object.d.ts +4 -4
- package/dist/resolve_dynamic_extension_object.js +105 -105
- package/package.json +19 -19
- package/source/convert_data_type_definition_to_structuretype_schema.ts +31 -14
- package/dist/client_dynamic_extension_object.d.ts +0 -25
- package/dist/client_dynamic_extension_object.js +0 -1058
- package/dist/client_dynamic_extension_object.js.map +0 -1
- package/dist/convert_data_type_definition_to_structure_type_schema.d.ts +0 -1
- package/dist/convert_data_type_definition_to_structure_type_schema.js +0 -3
- package/dist/convert_data_type_definition_to_structure_type_schema.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { DataTypeFactory } from "node-opcua-factory";
|
|
2
|
-
import { NodeId } from "node-opcua-nodeid";
|
|
3
|
-
import { IBasicSession } from "node-opcua-pseudo-session";
|
|
4
|
-
import { ExtraDataTypeManager } from "../extra_data_type_manager";
|
|
5
|
-
import { CacheForFieldResolution } from "../convert_data_type_definition_to_structuretype_schema";
|
|
6
|
-
export declare function readDataTypeDefinitionAndBuildType(session: IBasicSession, dataTypeNodeId: NodeId, name: string, dataTypeFactory: DataTypeFactory, cache: {
|
|
7
|
-
[key: string]: CacheForFieldResolution;
|
|
8
|
-
}): Promise<void>;
|
|
9
|
-
export declare function populateDataTypeManager104(session: IBasicSession, dataTypeManager: ExtraDataTypeManager): Promise<void>;
|
|
1
|
+
import { DataTypeFactory } from "node-opcua-factory";
|
|
2
|
+
import { NodeId } from "node-opcua-nodeid";
|
|
3
|
+
import { IBasicSession } from "node-opcua-pseudo-session";
|
|
4
|
+
import { ExtraDataTypeManager } from "../extra_data_type_manager";
|
|
5
|
+
import { CacheForFieldResolution } from "../convert_data_type_definition_to_structuretype_schema";
|
|
6
|
+
export declare function readDataTypeDefinitionAndBuildType(session: IBasicSession, dataTypeNodeId: NodeId, name: string, dataTypeFactory: DataTypeFactory, cache: {
|
|
7
|
+
[key: string]: CacheForFieldResolution;
|
|
8
|
+
}): Promise<void>;
|
|
9
|
+
export declare function populateDataTypeManager104(session: IBasicSession, dataTypeManager: ExtraDataTypeManager): Promise<void>;
|
|
@@ -1,146 +1,146 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.populateDataTypeManager104 = exports.readDataTypeDefinitionAndBuildType = void 0;
|
|
13
|
-
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
14
|
-
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
15
|
-
const node_opcua_nodeid_1 = require("node-opcua-nodeid");
|
|
16
|
-
const node_opcua_schemas_1 = require("node-opcua-schemas");
|
|
17
|
-
const node_opcua_status_code_1 = require("node-opcua-status-code");
|
|
18
|
-
const convert_data_type_definition_to_structuretype_schema_1 = require("../convert_data_type_definition_to_structuretype_schema");
|
|
19
|
-
const node_opcua_debug_1 = require("node-opcua-debug");
|
|
20
|
-
const errorLog = (0, node_opcua_debug_1.make_errorLog)(__filename);
|
|
21
|
-
const debugLog = (0, node_opcua_debug_1.make_debugLog)(__filename);
|
|
22
|
-
function readDataTypeDefinitionAndBuildType(session, dataTypeNodeId, name, dataTypeFactory, cache) {
|
|
23
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
try {
|
|
25
|
-
const dataTypeDefinitionDataValue = yield session.read({
|
|
26
|
-
attributeId: node_opcua_data_model_1.AttributeIds.DataTypeDefinition,
|
|
27
|
-
nodeId: dataTypeNodeId
|
|
28
|
-
});
|
|
29
|
-
/* istanbul ignore next */
|
|
30
|
-
if (dataTypeDefinitionDataValue.statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
|
|
31
|
-
throw new Error(" Cannot find dataType Definition ! with nodeId =" + dataTypeNodeId.toString());
|
|
32
|
-
}
|
|
33
|
-
const dataTypeDefinition = dataTypeDefinitionDataValue.value.value;
|
|
34
|
-
const schema = yield (0, convert_data_type_definition_to_structuretype_schema_1.convertDataTypeDefinitionToStructureTypeSchema)(session, dataTypeNodeId, name, dataTypeDefinition, dataTypeFactory, cache);
|
|
35
|
-
(0, node_opcua_schemas_1.createDynamicObjectConstructor)(schema, dataTypeFactory);
|
|
36
|
-
}
|
|
37
|
-
catch (err) {
|
|
38
|
-
errorLog("Error", err);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
exports.readDataTypeDefinitionAndBuildType = readDataTypeDefinitionAndBuildType;
|
|
43
|
-
function populateDataTypeManager104(session, dataTypeManager) {
|
|
44
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
const cache = {};
|
|
46
|
-
function withDataType(dataTypeNodeId, r) {
|
|
47
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
try {
|
|
49
|
-
const dataTypeFactory = dataTypeManager.getDataTypeFactory(dataTypeNodeId.namespace);
|
|
50
|
-
if (dataTypeNodeId.namespace === 0) {
|
|
51
|
-
// already known I guess
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
// if not found already
|
|
55
|
-
if (dataTypeFactory.getConstructorForDataType(dataTypeNodeId)) {
|
|
56
|
-
// already known !
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
// extract it formally
|
|
60
|
-
debugLog(" DataType => ", r.browseName.toString(), dataTypeNodeId.toString());
|
|
61
|
-
yield readDataTypeDefinitionAndBuildType(session, dataTypeNodeId, r.browseName.name, dataTypeFactory, cache);
|
|
62
|
-
(0, node_opcua_assert_1.assert)(dataTypeFactory.getConstructorForDataType(dataTypeNodeId));
|
|
63
|
-
}
|
|
64
|
-
catch (err) {
|
|
65
|
-
errorLog("err=", err);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
function performAction(done) {
|
|
70
|
-
let pendingNodesToBrowse = [];
|
|
71
|
-
let pendingContinuationPoints = [];
|
|
72
|
-
function triggerFutureBrowse() {
|
|
73
|
-
if (pendingNodesToBrowse.length + pendingContinuationPoints.length === 1) {
|
|
74
|
-
fencedAction(() => __awaiter(this, void 0, void 0, function* () {
|
|
75
|
-
flushBrowse();
|
|
76
|
-
}));
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
let busyCount = 0;
|
|
80
|
-
function processBrowseResult(browseResults) {
|
|
81
|
-
for (const result of browseResults) {
|
|
82
|
-
if (result.statusCode === node_opcua_status_code_1.StatusCodes.Good) {
|
|
83
|
-
if (result.continuationPoint) {
|
|
84
|
-
pendingContinuationPoints.push(result.continuationPoint);
|
|
85
|
-
triggerFutureBrowse();
|
|
86
|
-
}
|
|
87
|
-
for (const r of result.references || []) {
|
|
88
|
-
const dataTypeNodeId = r.nodeId;
|
|
89
|
-
fencedAction(() => __awaiter(this, void 0, void 0, function* () {
|
|
90
|
-
yield withDataType(dataTypeNodeId, r);
|
|
91
|
-
}));
|
|
92
|
-
// also explore sub types
|
|
93
|
-
browseSubDataTypeRecursively(dataTypeNodeId);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
function fencedAction(lambda) {
|
|
99
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
-
busyCount += 1;
|
|
101
|
-
yield lambda();
|
|
102
|
-
busyCount -= 1;
|
|
103
|
-
flushBrowse();
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
function flushBrowse() {
|
|
107
|
-
(0, node_opcua_assert_1.assert)(busyCount >= 0);
|
|
108
|
-
if (pendingContinuationPoints.length) {
|
|
109
|
-
const continuationPoints = pendingContinuationPoints;
|
|
110
|
-
pendingContinuationPoints = [];
|
|
111
|
-
fencedAction(() => __awaiter(this, void 0, void 0, function* () {
|
|
112
|
-
const browseResults = yield session.browseNext(continuationPoints, false);
|
|
113
|
-
processBrowseResult(browseResults);
|
|
114
|
-
}));
|
|
115
|
-
}
|
|
116
|
-
else if (pendingNodesToBrowse.length) {
|
|
117
|
-
const nodesToBrowse = pendingNodesToBrowse;
|
|
118
|
-
pendingNodesToBrowse = [];
|
|
119
|
-
fencedAction(() => __awaiter(this, void 0, void 0, function* () {
|
|
120
|
-
const browseResults = yield session.browse(nodesToBrowse);
|
|
121
|
-
processBrowseResult(browseResults);
|
|
122
|
-
}));
|
|
123
|
-
}
|
|
124
|
-
else if (pendingContinuationPoints.length + pendingNodesToBrowse.length === 0 && busyCount === 0) {
|
|
125
|
-
done();
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
function browseSubDataTypeRecursively(nodeId) {
|
|
129
|
-
const nodeToBrowse = {
|
|
130
|
-
nodeId,
|
|
131
|
-
includeSubtypes: true,
|
|
132
|
-
browseDirection: node_opcua_data_model_1.BrowseDirection.Forward,
|
|
133
|
-
nodeClassMask: 0xff,
|
|
134
|
-
referenceTypeId: (0, node_opcua_nodeid_1.resolveNodeId)("HasSubtype"),
|
|
135
|
-
resultMask: 0xff
|
|
136
|
-
};
|
|
137
|
-
pendingNodesToBrowse.push(nodeToBrowse);
|
|
138
|
-
triggerFutureBrowse();
|
|
139
|
-
}
|
|
140
|
-
browseSubDataTypeRecursively((0, node_opcua_nodeid_1.resolveNodeId)("Structure"));
|
|
141
|
-
}
|
|
142
|
-
yield new Promise((resolve) => performAction(resolve));
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
exports.populateDataTypeManager104 = populateDataTypeManager104;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.populateDataTypeManager104 = exports.readDataTypeDefinitionAndBuildType = void 0;
|
|
13
|
+
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
14
|
+
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
15
|
+
const node_opcua_nodeid_1 = require("node-opcua-nodeid");
|
|
16
|
+
const node_opcua_schemas_1 = require("node-opcua-schemas");
|
|
17
|
+
const node_opcua_status_code_1 = require("node-opcua-status-code");
|
|
18
|
+
const convert_data_type_definition_to_structuretype_schema_1 = require("../convert_data_type_definition_to_structuretype_schema");
|
|
19
|
+
const node_opcua_debug_1 = require("node-opcua-debug");
|
|
20
|
+
const errorLog = (0, node_opcua_debug_1.make_errorLog)(__filename);
|
|
21
|
+
const debugLog = (0, node_opcua_debug_1.make_debugLog)(__filename);
|
|
22
|
+
function readDataTypeDefinitionAndBuildType(session, dataTypeNodeId, name, dataTypeFactory, cache) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
try {
|
|
25
|
+
const dataTypeDefinitionDataValue = yield session.read({
|
|
26
|
+
attributeId: node_opcua_data_model_1.AttributeIds.DataTypeDefinition,
|
|
27
|
+
nodeId: dataTypeNodeId
|
|
28
|
+
});
|
|
29
|
+
/* istanbul ignore next */
|
|
30
|
+
if (dataTypeDefinitionDataValue.statusCode !== node_opcua_status_code_1.StatusCodes.Good) {
|
|
31
|
+
throw new Error(" Cannot find dataType Definition ! with nodeId =" + dataTypeNodeId.toString());
|
|
32
|
+
}
|
|
33
|
+
const dataTypeDefinition = dataTypeDefinitionDataValue.value.value;
|
|
34
|
+
const schema = yield (0, convert_data_type_definition_to_structuretype_schema_1.convertDataTypeDefinitionToStructureTypeSchema)(session, dataTypeNodeId, name, dataTypeDefinition, dataTypeFactory, cache);
|
|
35
|
+
(0, node_opcua_schemas_1.createDynamicObjectConstructor)(schema, dataTypeFactory);
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
errorLog("Error", err);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
exports.readDataTypeDefinitionAndBuildType = readDataTypeDefinitionAndBuildType;
|
|
43
|
+
function populateDataTypeManager104(session, dataTypeManager) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
const cache = {};
|
|
46
|
+
function withDataType(dataTypeNodeId, r) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
try {
|
|
49
|
+
const dataTypeFactory = dataTypeManager.getDataTypeFactory(dataTypeNodeId.namespace);
|
|
50
|
+
if (dataTypeNodeId.namespace === 0) {
|
|
51
|
+
// already known I guess
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
// if not found already
|
|
55
|
+
if (dataTypeFactory.getConstructorForDataType(dataTypeNodeId)) {
|
|
56
|
+
// already known !
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
// extract it formally
|
|
60
|
+
debugLog(" DataType => ", r.browseName.toString(), dataTypeNodeId.toString());
|
|
61
|
+
yield readDataTypeDefinitionAndBuildType(session, dataTypeNodeId, r.browseName.name, dataTypeFactory, cache);
|
|
62
|
+
(0, node_opcua_assert_1.assert)(dataTypeFactory.getConstructorForDataType(dataTypeNodeId));
|
|
63
|
+
}
|
|
64
|
+
catch (err) {
|
|
65
|
+
errorLog("err=", err);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function performAction(done) {
|
|
70
|
+
let pendingNodesToBrowse = [];
|
|
71
|
+
let pendingContinuationPoints = [];
|
|
72
|
+
function triggerFutureBrowse() {
|
|
73
|
+
if (pendingNodesToBrowse.length + pendingContinuationPoints.length === 1) {
|
|
74
|
+
fencedAction(() => __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
flushBrowse();
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
let busyCount = 0;
|
|
80
|
+
function processBrowseResult(browseResults) {
|
|
81
|
+
for (const result of browseResults) {
|
|
82
|
+
if (result.statusCode === node_opcua_status_code_1.StatusCodes.Good) {
|
|
83
|
+
if (result.continuationPoint) {
|
|
84
|
+
pendingContinuationPoints.push(result.continuationPoint);
|
|
85
|
+
triggerFutureBrowse();
|
|
86
|
+
}
|
|
87
|
+
for (const r of result.references || []) {
|
|
88
|
+
const dataTypeNodeId = r.nodeId;
|
|
89
|
+
fencedAction(() => __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
yield withDataType(dataTypeNodeId, r);
|
|
91
|
+
}));
|
|
92
|
+
// also explore sub types
|
|
93
|
+
browseSubDataTypeRecursively(dataTypeNodeId);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function fencedAction(lambda) {
|
|
99
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
busyCount += 1;
|
|
101
|
+
yield lambda();
|
|
102
|
+
busyCount -= 1;
|
|
103
|
+
flushBrowse();
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
function flushBrowse() {
|
|
107
|
+
(0, node_opcua_assert_1.assert)(busyCount >= 0);
|
|
108
|
+
if (pendingContinuationPoints.length) {
|
|
109
|
+
const continuationPoints = pendingContinuationPoints;
|
|
110
|
+
pendingContinuationPoints = [];
|
|
111
|
+
fencedAction(() => __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
const browseResults = yield session.browseNext(continuationPoints, false);
|
|
113
|
+
processBrowseResult(browseResults);
|
|
114
|
+
}));
|
|
115
|
+
}
|
|
116
|
+
else if (pendingNodesToBrowse.length) {
|
|
117
|
+
const nodesToBrowse = pendingNodesToBrowse;
|
|
118
|
+
pendingNodesToBrowse = [];
|
|
119
|
+
fencedAction(() => __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
const browseResults = yield session.browse(nodesToBrowse);
|
|
121
|
+
processBrowseResult(browseResults);
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
else if (pendingContinuationPoints.length + pendingNodesToBrowse.length === 0 && busyCount === 0) {
|
|
125
|
+
done();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function browseSubDataTypeRecursively(nodeId) {
|
|
129
|
+
const nodeToBrowse = {
|
|
130
|
+
nodeId,
|
|
131
|
+
includeSubtypes: true,
|
|
132
|
+
browseDirection: node_opcua_data_model_1.BrowseDirection.Forward,
|
|
133
|
+
nodeClassMask: 0xff,
|
|
134
|
+
referenceTypeId: (0, node_opcua_nodeid_1.resolveNodeId)("HasSubtype"),
|
|
135
|
+
resultMask: 0xff
|
|
136
|
+
};
|
|
137
|
+
pendingNodesToBrowse.push(nodeToBrowse);
|
|
138
|
+
triggerFutureBrowse();
|
|
139
|
+
}
|
|
140
|
+
browseSubDataTypeRecursively((0, node_opcua_nodeid_1.resolveNodeId)("Structure"));
|
|
141
|
+
}
|
|
142
|
+
yield new Promise((resolve) => performAction(resolve));
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
exports.populateDataTypeManager104 = populateDataTypeManager104;
|
|
146
146
|
//# sourceMappingURL=populate_data_type_manager_104.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IBasicSession } from "node-opcua-pseudo-session";
|
|
2
|
-
import { Variant } from "node-opcua-variant";
|
|
3
|
-
export interface PseudoDataValue {
|
|
4
|
-
value: Variant;
|
|
5
|
-
}
|
|
6
|
-
export declare function promoteOpaqueStructure(session: IBasicSession, dataValues: PseudoDataValue[]): Promise<void>;
|
|
1
|
+
import { IBasicSession } from "node-opcua-pseudo-session";
|
|
2
|
+
import { Variant } from "node-opcua-variant";
|
|
3
|
+
export interface PseudoDataValue {
|
|
4
|
+
value: Variant;
|
|
5
|
+
}
|
|
6
|
+
export declare function promoteOpaqueStructure(session: IBasicSession, dataValues: PseudoDataValue[]): Promise<void>;
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.promoteOpaqueStructure = void 0;
|
|
13
|
-
const node_opcua_extension_object_1 = require("node-opcua-extension-object");
|
|
14
|
-
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
15
|
-
//
|
|
16
|
-
const get_extra_data_type_manager_1 = require("./get_extra_data_type_manager");
|
|
17
|
-
const resolve_dynamic_extension_object_1 = require("./resolve_dynamic_extension_object");
|
|
18
|
-
;
|
|
19
|
-
function promoteOpaqueStructure(session, dataValues) {
|
|
20
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
// count number of Opaque Structures
|
|
22
|
-
const dataValuesToFix = dataValues.filter((dataValue) => dataValue.value && dataValue.value.dataType === node_opcua_variant_1.DataType.ExtensionObject &&
|
|
23
|
-
((dataValue.value.arrayType === node_opcua_variant_1.VariantArrayType.Scalar
|
|
24
|
-
&& dataValue.value.value instanceof node_opcua_extension_object_1.OpaqueStructure)
|
|
25
|
-
||
|
|
26
|
-
(dataValue.value.arrayType !== node_opcua_variant_1.VariantArrayType.Scalar
|
|
27
|
-
&& dataValue.value.value && dataValue.value.value.length >= 0
|
|
28
|
-
&& dataValue.value.value[0] instanceof node_opcua_extension_object_1.OpaqueStructure)));
|
|
29
|
-
if (dataValuesToFix.length === 0) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
// construct dataTypeManager if not already present
|
|
33
|
-
const extraDataTypeManager = yield (0, get_extra_data_type_manager_1.getExtraDataTypeManager)(session);
|
|
34
|
-
const promises = dataValuesToFix.map((dataValue) => __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
return yield (0, resolve_dynamic_extension_object_1.resolveDynamicExtensionObject)(session, dataValue.value, extraDataTypeManager);
|
|
36
|
-
}));
|
|
37
|
-
// https://medium.com/swlh/dealing-with-multiple-promises-in-javascript-41d6c21f20ff
|
|
38
|
-
yield Promise.all(promises.map(p => p.catch(e => e)));
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
exports.promoteOpaqueStructure = promoteOpaqueStructure;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.promoteOpaqueStructure = void 0;
|
|
13
|
+
const node_opcua_extension_object_1 = require("node-opcua-extension-object");
|
|
14
|
+
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
15
|
+
//
|
|
16
|
+
const get_extra_data_type_manager_1 = require("./get_extra_data_type_manager");
|
|
17
|
+
const resolve_dynamic_extension_object_1 = require("./resolve_dynamic_extension_object");
|
|
18
|
+
;
|
|
19
|
+
function promoteOpaqueStructure(session, dataValues) {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
// count number of Opaque Structures
|
|
22
|
+
const dataValuesToFix = dataValues.filter((dataValue) => dataValue.value && dataValue.value.dataType === node_opcua_variant_1.DataType.ExtensionObject &&
|
|
23
|
+
((dataValue.value.arrayType === node_opcua_variant_1.VariantArrayType.Scalar
|
|
24
|
+
&& dataValue.value.value instanceof node_opcua_extension_object_1.OpaqueStructure)
|
|
25
|
+
||
|
|
26
|
+
(dataValue.value.arrayType !== node_opcua_variant_1.VariantArrayType.Scalar
|
|
27
|
+
&& dataValue.value.value && dataValue.value.value.length >= 0
|
|
28
|
+
&& dataValue.value.value[0] instanceof node_opcua_extension_object_1.OpaqueStructure)));
|
|
29
|
+
if (dataValuesToFix.length === 0) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
// construct dataTypeManager if not already present
|
|
33
|
+
const extraDataTypeManager = yield (0, get_extra_data_type_manager_1.getExtraDataTypeManager)(session);
|
|
34
|
+
const promises = dataValuesToFix.map((dataValue) => __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
return yield (0, resolve_dynamic_extension_object_1.resolveDynamicExtensionObject)(session, dataValue.value, extraDataTypeManager);
|
|
36
|
+
}));
|
|
37
|
+
// https://medium.com/swlh/dealing-with-multiple-promises-in-javascript-41d6c21f20ff
|
|
38
|
+
yield Promise.all(promises.map(p => p.catch(e => e)));
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
exports.promoteOpaqueStructure = promoteOpaqueStructure;
|
|
42
42
|
//# sourceMappingURL=promote_opaque_structure.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Variant } from "node-opcua-variant";
|
|
2
|
-
import { ExtraDataTypeManager } from "./extra_data_type_manager";
|
|
3
|
-
import { IBasicSession } from "node-opcua-pseudo-session";
|
|
4
|
-
export declare function resolveDynamicExtensionObject(session: IBasicSession, variant: Variant, dataTypeManager: ExtraDataTypeManager): Promise<void>;
|
|
1
|
+
import { Variant } from "node-opcua-variant";
|
|
2
|
+
import { ExtraDataTypeManager } from "./extra_data_type_manager";
|
|
3
|
+
import { IBasicSession } from "node-opcua-pseudo-session";
|
|
4
|
+
export declare function resolveDynamicExtensionObject(session: IBasicSession, variant: Variant, dataTypeManager: ExtraDataTypeManager): Promise<void>;
|
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.resolveDynamicExtensionObject = void 0;
|
|
13
|
-
const node_opcua_binary_stream_1 = require("node-opcua-binary-stream");
|
|
14
|
-
const node_opcua_extension_object_1 = require("node-opcua-extension-object");
|
|
15
|
-
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
16
|
-
const node_opcua_debug_1 = require("node-opcua-debug");
|
|
17
|
-
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
18
|
-
const node_opcua_status_code_1 = require("node-opcua-status-code");
|
|
19
|
-
const populate_data_type_manager_104_1 = require("./private/populate_data_type_manager_104");
|
|
20
|
-
const warningLog = (0, node_opcua_debug_1.make_warningLog)(__filename);
|
|
21
|
-
function getOrExtractConstructor(session, binaryEncodingNodeId, dataTypeManager) {
|
|
22
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
const dataTypeFactory = dataTypeManager.getDataTypeFactoryForNamespace(binaryEncodingNodeId.namespace);
|
|
24
|
-
const Constructor = dataTypeFactory.getConstructor(binaryEncodingNodeId);
|
|
25
|
-
if (Constructor) {
|
|
26
|
-
return Constructor;
|
|
27
|
-
}
|
|
28
|
-
if (binaryEncodingNodeId.namespace === 0) {
|
|
29
|
-
throw new Error("Internal Error");
|
|
30
|
-
}
|
|
31
|
-
// need to extract it
|
|
32
|
-
const browseResult = yield session.browse({
|
|
33
|
-
nodeId: binaryEncodingNodeId,
|
|
34
|
-
referenceTypeId: "HasEncoding",
|
|
35
|
-
browseDirection: node_opcua_data_model_1.BrowseDirection.Inverse,
|
|
36
|
-
includeSubtypes: false,
|
|
37
|
-
nodeClassMask: node_opcua_data_model_1.NodeClassMask.DataType,
|
|
38
|
-
resultMask: node_opcua_data_model_1.ResultMask.BrowseName
|
|
39
|
-
});
|
|
40
|
-
if (browseResult.statusCode !== node_opcua_status_code_1.StatusCodes.Good || browseResult.references.length !== 1) {
|
|
41
|
-
throw new Error("browse failed");
|
|
42
|
-
}
|
|
43
|
-
const r = browseResult.references[0];
|
|
44
|
-
const dataTypeNodeId = r.nodeId;
|
|
45
|
-
if (dataTypeFactory.getConstructorForDataType(dataTypeNodeId)) {
|
|
46
|
-
throw new Error("Internal Error: we are not expecting this dataType to be processed already");
|
|
47
|
-
}
|
|
48
|
-
yield (0, populate_data_type_manager_104_1.readDataTypeDefinitionAndBuildType)(session, dataTypeNodeId, r.browseName.name, dataTypeFactory, {});
|
|
49
|
-
return dataTypeFactory.getConstructorForDataType(dataTypeNodeId);
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
function resolveDynamicExtensionObjectV(session, opaque, dataTypeManager) {
|
|
53
|
-
var _a, _b;
|
|
54
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
try {
|
|
56
|
-
const Constructor = yield getOrExtractConstructor(session, opaque.nodeId, dataTypeManager);
|
|
57
|
-
const object = new Constructor();
|
|
58
|
-
const stream = new node_opcua_binary_stream_1.BinaryStream(opaque.buffer);
|
|
59
|
-
try {
|
|
60
|
-
object.decode(stream);
|
|
61
|
-
return object;
|
|
62
|
-
}
|
|
63
|
-
catch (err) {
|
|
64
|
-
warningLog("Constructor = ", Constructor.name);
|
|
65
|
-
warningLog("opaqueStructure = ", (_a = opaque === null || opaque === void 0 ? void 0 : opaque.nodeId) === null || _a === void 0 ? void 0 : _a.toString());
|
|
66
|
-
warningLog("opaqueStructure = ", "0x" + ((_b = opaque === null || opaque === void 0 ? void 0 : opaque.buffer) === null || _b === void 0 ? void 0 : _b.toString("hex")));
|
|
67
|
-
warningLog((0, node_opcua_debug_1.hexDump)(opaque.buffer));
|
|
68
|
-
warningLog("resolveDynamicExtensionObjectV err = ", err);
|
|
69
|
-
// try again for debugging
|
|
70
|
-
object.decode(stream);
|
|
71
|
-
return opaque;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
catch (err) {
|
|
75
|
-
warningLog("err", err);
|
|
76
|
-
warningLog("opaqueStructure = ", opaque.nodeId.toString());
|
|
77
|
-
warningLog("opaqueStructure = ", "0x" + opaque.buffer.toString("hex"));
|
|
78
|
-
warningLog((0, node_opcua_debug_1.hexDump)(opaque.buffer));
|
|
79
|
-
warningLog(dataTypeManager.toString());
|
|
80
|
-
throw err;
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
function resolveDynamicExtensionObject(session, variant, dataTypeManager) {
|
|
85
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
-
if (variant.dataType !== node_opcua_variant_1.DataType.ExtensionObject) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
if (variant.arrayType !== node_opcua_variant_1.VariantArrayType.Scalar) {
|
|
90
|
-
if (variant.value instanceof Array) {
|
|
91
|
-
for (let i = 0; i < variant.value.length; i++) {
|
|
92
|
-
if (variant.value[i] instanceof node_opcua_extension_object_1.OpaqueStructure) {
|
|
93
|
-
variant.value[i] = yield resolveDynamicExtensionObjectV(session, variant.value[i], dataTypeManager);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
if (!(variant.value instanceof node_opcua_extension_object_1.OpaqueStructure)) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
variant.value = yield resolveDynamicExtensionObjectV(session, variant.value, dataTypeManager);
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
exports.resolveDynamicExtensionObject = resolveDynamicExtensionObject;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.resolveDynamicExtensionObject = void 0;
|
|
13
|
+
const node_opcua_binary_stream_1 = require("node-opcua-binary-stream");
|
|
14
|
+
const node_opcua_extension_object_1 = require("node-opcua-extension-object");
|
|
15
|
+
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
16
|
+
const node_opcua_debug_1 = require("node-opcua-debug");
|
|
17
|
+
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
18
|
+
const node_opcua_status_code_1 = require("node-opcua-status-code");
|
|
19
|
+
const populate_data_type_manager_104_1 = require("./private/populate_data_type_manager_104");
|
|
20
|
+
const warningLog = (0, node_opcua_debug_1.make_warningLog)(__filename);
|
|
21
|
+
function getOrExtractConstructor(session, binaryEncodingNodeId, dataTypeManager) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const dataTypeFactory = dataTypeManager.getDataTypeFactoryForNamespace(binaryEncodingNodeId.namespace);
|
|
24
|
+
const Constructor = dataTypeFactory.getConstructor(binaryEncodingNodeId);
|
|
25
|
+
if (Constructor) {
|
|
26
|
+
return Constructor;
|
|
27
|
+
}
|
|
28
|
+
if (binaryEncodingNodeId.namespace === 0) {
|
|
29
|
+
throw new Error("Internal Error");
|
|
30
|
+
}
|
|
31
|
+
// need to extract it
|
|
32
|
+
const browseResult = yield session.browse({
|
|
33
|
+
nodeId: binaryEncodingNodeId,
|
|
34
|
+
referenceTypeId: "HasEncoding",
|
|
35
|
+
browseDirection: node_opcua_data_model_1.BrowseDirection.Inverse,
|
|
36
|
+
includeSubtypes: false,
|
|
37
|
+
nodeClassMask: node_opcua_data_model_1.NodeClassMask.DataType,
|
|
38
|
+
resultMask: node_opcua_data_model_1.ResultMask.BrowseName
|
|
39
|
+
});
|
|
40
|
+
if (browseResult.statusCode !== node_opcua_status_code_1.StatusCodes.Good || browseResult.references.length !== 1) {
|
|
41
|
+
throw new Error("browse failed");
|
|
42
|
+
}
|
|
43
|
+
const r = browseResult.references[0];
|
|
44
|
+
const dataTypeNodeId = r.nodeId;
|
|
45
|
+
if (dataTypeFactory.getConstructorForDataType(dataTypeNodeId)) {
|
|
46
|
+
throw new Error("Internal Error: we are not expecting this dataType to be processed already");
|
|
47
|
+
}
|
|
48
|
+
yield (0, populate_data_type_manager_104_1.readDataTypeDefinitionAndBuildType)(session, dataTypeNodeId, r.browseName.name, dataTypeFactory, {});
|
|
49
|
+
return dataTypeFactory.getConstructorForDataType(dataTypeNodeId);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function resolveDynamicExtensionObjectV(session, opaque, dataTypeManager) {
|
|
53
|
+
var _a, _b;
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
try {
|
|
56
|
+
const Constructor = yield getOrExtractConstructor(session, opaque.nodeId, dataTypeManager);
|
|
57
|
+
const object = new Constructor();
|
|
58
|
+
const stream = new node_opcua_binary_stream_1.BinaryStream(opaque.buffer);
|
|
59
|
+
try {
|
|
60
|
+
object.decode(stream);
|
|
61
|
+
return object;
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
warningLog("Constructor = ", Constructor.name);
|
|
65
|
+
warningLog("opaqueStructure = ", (_a = opaque === null || opaque === void 0 ? void 0 : opaque.nodeId) === null || _a === void 0 ? void 0 : _a.toString());
|
|
66
|
+
warningLog("opaqueStructure = ", "0x" + ((_b = opaque === null || opaque === void 0 ? void 0 : opaque.buffer) === null || _b === void 0 ? void 0 : _b.toString("hex")));
|
|
67
|
+
warningLog((0, node_opcua_debug_1.hexDump)(opaque.buffer));
|
|
68
|
+
warningLog("resolveDynamicExtensionObjectV err = ", err);
|
|
69
|
+
// try again for debugging
|
|
70
|
+
object.decode(stream);
|
|
71
|
+
return opaque;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
warningLog("err", err);
|
|
76
|
+
warningLog("opaqueStructure = ", opaque.nodeId.toString());
|
|
77
|
+
warningLog("opaqueStructure = ", "0x" + opaque.buffer.toString("hex"));
|
|
78
|
+
warningLog((0, node_opcua_debug_1.hexDump)(opaque.buffer));
|
|
79
|
+
warningLog(dataTypeManager.toString());
|
|
80
|
+
throw err;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function resolveDynamicExtensionObject(session, variant, dataTypeManager) {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
if (variant.dataType !== node_opcua_variant_1.DataType.ExtensionObject) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (variant.arrayType !== node_opcua_variant_1.VariantArrayType.Scalar) {
|
|
90
|
+
if (variant.value instanceof Array) {
|
|
91
|
+
for (let i = 0; i < variant.value.length; i++) {
|
|
92
|
+
if (variant.value[i] instanceof node_opcua_extension_object_1.OpaqueStructure) {
|
|
93
|
+
variant.value[i] = yield resolveDynamicExtensionObjectV(session, variant.value[i], dataTypeManager);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (!(variant.value instanceof node_opcua_extension_object_1.OpaqueStructure)) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
variant.value = yield resolveDynamicExtensionObjectV(session, variant.value, dataTypeManager);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
exports.resolveDynamicExtensionObject = resolveDynamicExtensionObject;
|
|
106
106
|
//# sourceMappingURL=resolve_dynamic_extension_object.js.map
|