node-opcua-client-dynamic-extension-object 2.63.1 → 2.64.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/client_dynamic_extension_object.d.ts +25 -0
- package/dist/client_dynamic_extension_object.js +1058 -0
- package/dist/client_dynamic_extension_object.js.map +1 -0
- package/dist/convert_data_type_definition_to_structure_type_schema.d.ts +1 -0
- package/dist/convert_data_type_definition_to_structure_type_schema.js +3 -0
- package/dist/convert_data_type_definition_to_structure_type_schema.js.map +1 -0
- package/dist/convert_data_type_definition_to_structuretype_schema.d.ts +12 -12
- package/dist/convert_data_type_definition_to_structuretype_schema.js +327 -305
- 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 +23 -23
- 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_103.js.map +1 -1
- 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 +18 -18
- package/source/convert_data_type_definition_to_structuretype_schema.ts +51 -23
- package/source/private/populate_data_type_manager_103.ts +2 -1
|
@@ -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
|
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.64.1",
|
|
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",
|
|
@@ -11,22 +11,22 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"chalk": "4.1.2",
|
|
14
|
-
"node-opcua-assert": "2.
|
|
15
|
-
"node-opcua-binary-stream": "2.
|
|
16
|
-
"node-opcua-constants": "2.
|
|
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.
|
|
14
|
+
"node-opcua-assert": "2.64.1",
|
|
15
|
+
"node-opcua-binary-stream": "2.64.1",
|
|
16
|
+
"node-opcua-constants": "2.64.1",
|
|
17
|
+
"node-opcua-data-model": "2.64.1",
|
|
18
|
+
"node-opcua-data-value": "2.64.1",
|
|
19
|
+
"node-opcua-debug": "2.64.1",
|
|
20
|
+
"node-opcua-extension-object": "2.64.1",
|
|
21
|
+
"node-opcua-factory": "2.64.1",
|
|
22
|
+
"node-opcua-nodeid": "2.64.1",
|
|
23
|
+
"node-opcua-pseudo-session": "2.64.1",
|
|
24
|
+
"node-opcua-schemas": "2.64.1",
|
|
25
|
+
"node-opcua-service-browse": "2.64.1",
|
|
26
|
+
"node-opcua-service-translate-browse-path": "2.64.1",
|
|
27
|
+
"node-opcua-status-code": "2.64.1",
|
|
28
|
+
"node-opcua-types": "2.64.1",
|
|
29
|
+
"node-opcua-variant": "2.64.1"
|
|
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": "b65b8738603cd475d7d99a2b20b0ae9d32b4110c"
|
|
47
47
|
}
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
import { NodeId, makeExpandedNodeId, resolveNodeId } from "node-opcua-nodeid";
|
|
15
15
|
import { browseAll, BrowseDescriptionLike, IBasicSession } from "node-opcua-pseudo-session";
|
|
16
16
|
import { StatusCodes } from "node-opcua-status-code";
|
|
17
|
-
import { EnumDefinition, DataTypeDefinition, StructureDefinition, StructureType } from "node-opcua-types";
|
|
17
|
+
import { EnumDefinition, DataTypeDefinition, StructureDefinition, StructureType, StructureField } from "node-opcua-types";
|
|
18
18
|
import { ExtensionObject } from "node-opcua-extension-object";
|
|
19
19
|
//
|
|
20
20
|
import { _findEncodings } from "./private/find_encodings";
|
|
@@ -276,6 +276,7 @@ async function _setupEncodings(
|
|
|
276
276
|
return schema;
|
|
277
277
|
}
|
|
278
278
|
|
|
279
|
+
// eslint-disable-next-line max-statements
|
|
279
280
|
export async function convertDataTypeDefinitionToStructureTypeSchema(
|
|
280
281
|
session: IBasicSession,
|
|
281
282
|
dataTypeNodeId: NodeId,
|
|
@@ -307,10 +308,29 @@ export async function convertDataTypeDefinitionToStructureTypeSchema(
|
|
|
307
308
|
|
|
308
309
|
const bitFields: { name: string; length?: number }[] | undefined = isUnion ? undefined : [];
|
|
309
310
|
|
|
311
|
+
const postActions: ((schema: StructuredTypeSchema ) => void)[] = [];
|
|
312
|
+
|
|
310
313
|
for (const fieldD of definition.fields!) {
|
|
314
|
+
|
|
315
|
+
let field: FieldInterfaceOptions | undefined;
|
|
316
|
+
({ field, switchBit, switchValue } = createField(fieldD, switchBit, bitFields, isUnion, switchValue));
|
|
317
|
+
|
|
318
|
+
if (fieldD.dataType.value === dataTypeNodeId.value && fieldD.dataType.namespace === dataTypeNodeId.namespace ) {
|
|
319
|
+
// this is a structure with a field of the same type
|
|
320
|
+
// push an empty placeholder that we will fill later
|
|
321
|
+
const fieldTypeName = await readBrowseName(session, dataTypeNodeId);
|
|
322
|
+
field.fieldType= fieldTypeName!,
|
|
323
|
+
field.category = FieldCategory.complex;
|
|
324
|
+
fields.push(field);
|
|
325
|
+
const capturedField = field;
|
|
326
|
+
postActions.push( (schema: StructuredTypeSchema )=> {
|
|
327
|
+
capturedField.schema = schema;
|
|
328
|
+
});
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
311
331
|
const rt = (await resolveFieldType(session, fieldD.dataType, dataTypeFactory, cache))!;
|
|
312
332
|
if (!rt) {
|
|
313
|
-
|
|
333
|
+
errorLog(
|
|
314
334
|
"convertDataTypeDefinitionToStructureTypeSchema cannot handle field",
|
|
315
335
|
fieldD.name,
|
|
316
336
|
"in",
|
|
@@ -321,27 +341,7 @@ export async function convertDataTypeDefinitionToStructureTypeSchema(
|
|
|
321
341
|
}
|
|
322
342
|
const { schema, category, fieldTypeName } = rt;
|
|
323
343
|
|
|
324
|
-
|
|
325
|
-
fieldType: fieldTypeName!,
|
|
326
|
-
name: fieldD.name!,
|
|
327
|
-
schema
|
|
328
|
-
};
|
|
329
|
-
|
|
330
|
-
if (fieldD.isOptional) {
|
|
331
|
-
field.switchBit = switchBit++;
|
|
332
|
-
bitFields?.push({ name: fieldD.name! + "Specified", length: 1 });
|
|
333
|
-
}
|
|
334
|
-
if (isUnion) {
|
|
335
|
-
field.switchValue = switchValue;
|
|
336
|
-
switchValue += 1;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
assert(fieldD.valueRank === -1 || fieldD.valueRank === 1 || fieldD.valueRank === 0);
|
|
340
|
-
if (fieldD.valueRank === 1) {
|
|
341
|
-
field.isArray = true;
|
|
342
|
-
} else {
|
|
343
|
-
field.isArray = false;
|
|
344
|
-
}
|
|
344
|
+
field.fieldType= fieldTypeName!,
|
|
345
345
|
field.category = category;
|
|
346
346
|
field.schema = schema;
|
|
347
347
|
fields.push(field);
|
|
@@ -358,7 +358,35 @@ export async function convertDataTypeDefinitionToStructureTypeSchema(
|
|
|
358
358
|
name
|
|
359
359
|
});
|
|
360
360
|
const structuredTypeSchema = await _setupEncodings(session, dataTypeNodeId, os);
|
|
361
|
+
|
|
362
|
+
postActions.forEach((action)=>action(structuredTypeSchema));
|
|
363
|
+
|
|
361
364
|
return structuredTypeSchema;
|
|
362
365
|
}
|
|
363
366
|
throw new Error("Not Implemented");
|
|
367
|
+
|
|
368
|
+
function createField(fieldD: StructureField, switchBit: number, bitFields: { name: string; length?: number | undefined; }[] | undefined, isUnion: boolean, switchValue: number) {
|
|
369
|
+
const field: FieldInterfaceOptions = {
|
|
370
|
+
fieldType: "",
|
|
371
|
+
name: fieldD.name!,
|
|
372
|
+
schema: null
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
if (fieldD.isOptional) {
|
|
376
|
+
field.switchBit = switchBit++;
|
|
377
|
+
bitFields?.push({ name: fieldD.name! + "Specified", length: 1 });
|
|
378
|
+
}
|
|
379
|
+
if (isUnion) {
|
|
380
|
+
field.switchValue = switchValue;
|
|
381
|
+
switchValue += 1;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
assert(fieldD.valueRank === -1 || fieldD.valueRank === 1 || fieldD.valueRank === 0);
|
|
385
|
+
if (fieldD.valueRank === 1) {
|
|
386
|
+
field.isArray = true;
|
|
387
|
+
} else {
|
|
388
|
+
field.isArray = false;
|
|
389
|
+
}
|
|
390
|
+
return { field, switchBit, switchValue };
|
|
391
|
+
}
|
|
364
392
|
}
|
|
@@ -198,6 +198,7 @@ function sortStructure(dataTypeDefinitions: DataTypeDefinitions) {
|
|
|
198
198
|
if (_visited[hash]) {
|
|
199
199
|
return;
|
|
200
200
|
}
|
|
201
|
+
_visited[hash] = d;
|
|
201
202
|
const bbb = _map[d.dataTypeDefinition.baseDataType.toString()];
|
|
202
203
|
if (bbb) {
|
|
203
204
|
_visit(bbb);
|
|
@@ -210,7 +211,7 @@ function sortStructure(dataTypeDefinitions: DataTypeDefinitions) {
|
|
|
210
211
|
}
|
|
211
212
|
_visit(ddd);
|
|
212
213
|
}
|
|
213
|
-
|
|
214
|
+
|
|
214
215
|
dataTypeDefinitionsSorted.push(d);
|
|
215
216
|
}
|
|
216
217
|
for (const d of dataTypeDefinitions) {
|