node-opcua-modeler 2.64.0 → 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/MyModel.NodeSet2.xml +125 -0
- package/dist/addExtensionObjectDataType.d.ts +21 -21
- package/dist/addExtensionObjectDataType.js +130 -130
- package/dist/buildModel.d.ts +16 -0
- package/dist/buildModel.js +91 -0
- package/dist/buildModel.js.map +1 -0
- package/dist/build_model_inner.d.ts +17 -17
- package/dist/build_model_inner.js +40 -40
- package/dist/display.d.ts +2 -0
- package/dist/display.js +96 -0
- package/dist/display.js.map +1 -0
- package/dist/displayNodeElement.d.ts +5 -5
- package/dist/displayNodeElement.js +191 -191
- package/dist/dump_state_machine_to_graphviz.d.ts +6 -6
- package/dist/dump_state_machine_to_graphviz.js +119 -119
- package/dist/generate_markdown_doc.d.ts +6 -6
- package/dist/generate_markdown_doc.js +266 -266
- package/dist/index.d.ts +24 -24
- package/dist/index.js +48 -48
- package/dist/promoteToMandatory.d.ts +8 -8
- package/dist/promoteToMandatory.js +97 -97
- package/dist/setNamespaceMetaData.d.ts +1 -1
- package/dist/setNamespaceMetaData.js +5 -5
- package/dist/symbol.d.ts +1 -1
- package/dist/symbol.js +2 -2
- package/dist/tableHelper.d.ts +9 -9
- package/dist/tableHelper.js +60 -60
- package/dist/to_cvs.d.ts +2 -2
- package/dist/to_cvs.js +11 -11
- package/dist/to_graphivz.d.ts +14 -14
- package/dist/to_graphivz.js +294 -294
- package/dist/types.d.ts +1 -1
- package/dist/types.js +2 -2
- package/distNodeJS/build_documentation_to_file.d.ts +2 -2
- package/distNodeJS/build_documentation_to_file.js +26 -26
- package/distNodeJS/build_model.d.ts +7 -7
- package/distNodeJS/build_model.js +21 -21
- package/distNodeJS/index.d.ts +5 -5
- package/distNodeJS/index.js +19 -19
- package/distNodeJS/symbol_cvs.d.ts +3 -3
- package/distNodeJS/symbol_cvs.js +63 -63
- package/package.json +52 -53
|
@@ -1,267 +1,267 @@
|
|
|
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.buildDocumentation = exports.buildDocumentationToString = void 0;
|
|
13
|
-
const node_opcua_basic_types_1 = require("node-opcua-basic-types");
|
|
14
|
-
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
15
|
-
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
16
|
-
const displayNodeElement_1 = require("./displayNodeElement");
|
|
17
|
-
const tableHelper_1 = require("./tableHelper");
|
|
18
|
-
const to_graphivz_1 = require("./to_graphivz");
|
|
19
|
-
class Writer {
|
|
20
|
-
constructor() {
|
|
21
|
-
this.stream = [];
|
|
22
|
-
/* empty */
|
|
23
|
-
}
|
|
24
|
-
writeLine(str) {
|
|
25
|
-
this.stream.push(str);
|
|
26
|
-
}
|
|
27
|
-
toString() {
|
|
28
|
-
return this.stream.join("\n");
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
function buildDocumentationToString(namespace) {
|
|
32
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
-
const writer = new Writer();
|
|
34
|
-
yield buildDocumentation(namespace, writer);
|
|
35
|
-
return writer.toString();
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
exports.buildDocumentationToString = buildDocumentationToString;
|
|
39
|
-
const toDataTypeStr = (p) => {
|
|
40
|
-
if (p.nodeClass === node_opcua_data_model_1.NodeClass.Variable) {
|
|
41
|
-
const v = p;
|
|
42
|
-
const arr = v.valueRank == 1 ? "[]" : "";
|
|
43
|
-
const brn = toDataTypeStr(p.dataTypeObj);
|
|
44
|
-
return brn + arr;
|
|
45
|
-
}
|
|
46
|
-
if (p.nodeClass === node_opcua_data_model_1.NodeClass.DataType) {
|
|
47
|
-
const dataType = p;
|
|
48
|
-
const brn = dataType.browseName.toString();
|
|
49
|
-
return brn;
|
|
50
|
-
}
|
|
51
|
-
return "";
|
|
52
|
-
};
|
|
53
|
-
function dataTypeEnumerationToMarkdown(dataType) {
|
|
54
|
-
const addressSpace = dataType.addressSpace;
|
|
55
|
-
const writer = new Writer();
|
|
56
|
-
writer.writeLine("");
|
|
57
|
-
if (dataType.description) {
|
|
58
|
-
writer.writeLine(dataType.description.text || "");
|
|
59
|
-
}
|
|
60
|
-
writer.writeLine(`\nThe fields of the ${dataType.browseName.name} DataType are defined in the following table:`);
|
|
61
|
-
writer.writeLine("");
|
|
62
|
-
const definition = dataType.getEnumDefinition();
|
|
63
|
-
writer.writeLine("\nBasic Type: " + node_opcua_variant_1.DataType[node_opcua_variant_1.DataType.Int32]);
|
|
64
|
-
writer.writeLine("");
|
|
65
|
-
const table = new tableHelper_1.TableHelper(["Name", "Value", "Description"]);
|
|
66
|
-
for (const f of definition.fields || []) {
|
|
67
|
-
table.push([f.name, (0, node_opcua_basic_types_1.coerceUInt32)(f.value[1]), f.description.text || ""]);
|
|
68
|
-
}
|
|
69
|
-
writer.writeLine(table.toMarkdownTable());
|
|
70
|
-
const str = dumpTypeRepresentation(dataType);
|
|
71
|
-
writer.writeLine(str);
|
|
72
|
-
return writer.toString();
|
|
73
|
-
}
|
|
74
|
-
function dumpTypeRepresentation(uaType) {
|
|
75
|
-
var _a;
|
|
76
|
-
const className = node_opcua_data_model_1.NodeClass[uaType.nodeClass];
|
|
77
|
-
const writer = new Writer();
|
|
78
|
-
writer.writeLine("\n");
|
|
79
|
-
writer.writeLine(`\nThe representation of the ${uaType.browseName.name} ${className} in the address space is shown in the following table:`);
|
|
80
|
-
const table = new tableHelper_1.TableHelper(["Name", "Attribute"]);
|
|
81
|
-
table.push(["NodeId", uaType.nodeId.toString()]);
|
|
82
|
-
table.push(["NamespaceUri", uaType.addressSpace.getNamespaceUri(uaType.nodeId.namespace)]);
|
|
83
|
-
table.push(["BrowseName", uaType.browseName.name.toString()]);
|
|
84
|
-
table.push(["NodeClass", node_opcua_data_model_1.NodeClass[uaType.nodeClass]]);
|
|
85
|
-
if (uaType.nodeClass === node_opcua_data_model_1.NodeClass.ReferenceType) {
|
|
86
|
-
table.push(["InverseName", uaType.inverseName.text]);
|
|
87
|
-
// table.push(["IsSymmetric", (uaType as UAReferenceType).isSymetric ? "Yes" : "No"]);
|
|
88
|
-
}
|
|
89
|
-
table.push(["IsAbstract", uaType.isAbstract ? "Yes" : "No"]);
|
|
90
|
-
table.push(["SubtypeOf", uaType.subtypeOfObj ? uaType.subtypeOfObj.browseName.toString() : ""]);
|
|
91
|
-
writer.writeLine("");
|
|
92
|
-
writer.writeLine(table.toMarkdownTable());
|
|
93
|
-
writer.writeLine("");
|
|
94
|
-
// forward refereces
|
|
95
|
-
{
|
|
96
|
-
const properties = uaType.findReferencesExAsObject("HasProperty");
|
|
97
|
-
const table = new tableHelper_1.TableHelper(["Reference", "NodeClass", "BrowseName", "DataType", "TypeDefinition", "ModellingRule"]);
|
|
98
|
-
if (uaType.subtypeOfObj) {
|
|
99
|
-
const referenceName = "HasSubType";
|
|
100
|
-
const p = uaType.subtypeOfObj;
|
|
101
|
-
const nodeClass = node_opcua_data_model_1.NodeClass[p.nodeClass];
|
|
102
|
-
const browseName = p.browseName.toString();
|
|
103
|
-
const dataTypeStr = toDataTypeStr(p);
|
|
104
|
-
const modellingRule = p.modellingRule || "";
|
|
105
|
-
const typeDefinitionName = "";
|
|
106
|
-
table.push([referenceName, nodeClass, browseName, dataTypeStr, typeDefinitionName, modellingRule]);
|
|
107
|
-
}
|
|
108
|
-
if (properties.length > 0) {
|
|
109
|
-
writer.writeLine(`\nThe reference of the ${uaType.browseName.name} ${className} is shown in the following table:`);
|
|
110
|
-
writer.writeLine("");
|
|
111
|
-
for (const p of properties) {
|
|
112
|
-
const referenceName = "HasProperty";
|
|
113
|
-
const nodeClass = node_opcua_data_model_1.NodeClass[p.nodeClass];
|
|
114
|
-
const browseName = p.browseName.toString();
|
|
115
|
-
const dataTypeStr = toDataTypeStr(p);
|
|
116
|
-
const typeDefinitionName = (_a = p.typeDefinitionObj) === null || _a === void 0 ? void 0 : _a.browseName.toString();
|
|
117
|
-
const modellingRule = p.modellingRule || "";
|
|
118
|
-
table.push([referenceName, nodeClass, browseName, dataTypeStr, typeDefinitionName, modellingRule]);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
writer.writeLine("");
|
|
122
|
-
writer.writeLine(table.toMarkdownTable());
|
|
123
|
-
writer.writeLine("");
|
|
124
|
-
}
|
|
125
|
-
return writer.toString();
|
|
126
|
-
}
|
|
127
|
-
function dataTypeStructureToMarkdown(dataType) {
|
|
128
|
-
const addressSpace = dataType.addressSpace;
|
|
129
|
-
const writer = new Writer();
|
|
130
|
-
writer.writeLine("");
|
|
131
|
-
if (dataType.description) {
|
|
132
|
-
writer.writeLine(dataType.description.text || "");
|
|
133
|
-
}
|
|
134
|
-
const definition = dataType.getStructureDefinition();
|
|
135
|
-
writer.writeLine("\nBasic Type: " + node_opcua_variant_1.DataType[dataType.basicDataType]);
|
|
136
|
-
writer.writeLine("");
|
|
137
|
-
writer.writeLine(`The fields of the ${dataType.browseName.name} DataType are defined in the following table:`);
|
|
138
|
-
const c = (f) => {
|
|
139
|
-
var _a;
|
|
140
|
-
let dataTypeString = addressSpace.findDataType(f.dataType).browseName.toString();
|
|
141
|
-
if (f.valueRank === 1) {
|
|
142
|
-
dataTypeString += "[]";
|
|
143
|
-
}
|
|
144
|
-
else if (f.valueRank >= 2) {
|
|
145
|
-
dataTypeString += "[" + ((_a = f.arrayDimensions) === null || _a === void 0 ? void 0 : _a.map((d) => "" + d).join(" ")) + "]";
|
|
146
|
-
}
|
|
147
|
-
// f.maxStringLength ? f.maxStringLength : "",
|
|
148
|
-
// f.arrayDimensions ? f.arrayDimensions : "",
|
|
149
|
-
return dataTypeString;
|
|
150
|
-
};
|
|
151
|
-
const table = new tableHelper_1.TableHelper(["Name", "Type", "Description"]);
|
|
152
|
-
table.push([dataType.browseName.name, "Structure"]);
|
|
153
|
-
for (const f of definition.fields || []) {
|
|
154
|
-
table.push([" " + f.name, c(f), (f.description.text || "").replace(/\n/g, "<br>")]);
|
|
155
|
-
}
|
|
156
|
-
writer.writeLine(table.toMarkdownTable());
|
|
157
|
-
const str = dumpTypeRepresentation(dataType);
|
|
158
|
-
writer.writeLine(str);
|
|
159
|
-
return writer.toString();
|
|
160
|
-
}
|
|
161
|
-
function dataTypeToMarkdown(dataType) {
|
|
162
|
-
if (dataType.isEnumeration()) {
|
|
163
|
-
return dataTypeEnumerationToMarkdown(dataType);
|
|
164
|
-
}
|
|
165
|
-
else if (dataType.isStructure()) {
|
|
166
|
-
return dataTypeStructureToMarkdown(dataType);
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
const writer = new Writer();
|
|
170
|
-
writer.writeLine("");
|
|
171
|
-
if (dataType.description) {
|
|
172
|
-
writer.writeLine(dataType.description.text || "");
|
|
173
|
-
}
|
|
174
|
-
writer.writeLine("\nBasic Type: " + node_opcua_variant_1.DataType[dataType.basicDataType]);
|
|
175
|
-
writer.writeLine("");
|
|
176
|
-
return writer.toString();
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
function dumpReferenceType(referenceType) {
|
|
180
|
-
const writer = new Writer();
|
|
181
|
-
const str = dumpTypeRepresentation(referenceType);
|
|
182
|
-
writer.writeLine(str);
|
|
183
|
-
return writer.toString();
|
|
184
|
-
}
|
|
185
|
-
function buildDocumentation(namespace, writer) {
|
|
186
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
-
const addressSpace = namespace.addressSpace;
|
|
188
|
-
const namespaceUri = namespace.namespaceUri;
|
|
189
|
-
// -------- Documentation
|
|
190
|
-
const nsIndex = addressSpace.getNamespaceIndex(namespaceUri);
|
|
191
|
-
writer.writeLine("");
|
|
192
|
-
writer.writeLine("# Namespace " + namespaceUri);
|
|
193
|
-
writer.writeLine("");
|
|
194
|
-
const namespacePriv = namespace;
|
|
195
|
-
// -------------- writeReferences
|
|
196
|
-
if (namespacePriv._referenceTypeCount() > 0) {
|
|
197
|
-
writer.writeLine("");
|
|
198
|
-
writer.writeLine("## References ");
|
|
199
|
-
writer.writeLine("");
|
|
200
|
-
for (const referenceType of namespacePriv._referenceTypeIterator()) {
|
|
201
|
-
writer.writeLine("\n\n### reference " + referenceType.browseName.name);
|
|
202
|
-
dumpReferenceType(referenceType);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
function d(node) {
|
|
206
|
-
return node.description ? node.description.text.toString() : "";
|
|
207
|
-
}
|
|
208
|
-
// -------------- writeDataType
|
|
209
|
-
if (namespacePriv._dataTypeCount() > 0) {
|
|
210
|
-
writer.writeLine("");
|
|
211
|
-
writer.writeLine("## DataTypes");
|
|
212
|
-
writer.writeLine("");
|
|
213
|
-
for (const dataType of namespacePriv._dataTypeIterator()) {
|
|
214
|
-
writer.writeLine("\n\n### " + dataType.browseName.name.toString());
|
|
215
|
-
writer.writeLine("");
|
|
216
|
-
writer.writeLine(dataTypeToMarkdown(dataType));
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
// -------------- writeObjectType
|
|
220
|
-
if (namespacePriv._objectTypeCount() > 0) {
|
|
221
|
-
writer.writeLine("");
|
|
222
|
-
writer.writeLine("## ObjectTypes");
|
|
223
|
-
writer.writeLine("");
|
|
224
|
-
for (const objectType of namespacePriv._objectTypeIterator()) {
|
|
225
|
-
writer.writeLine("\n\n### " + objectType.browseName.name.toString());
|
|
226
|
-
writer.writeLine(d(objectType));
|
|
227
|
-
writer.writeLine((0, to_graphivz_1.graphVizToPlantUml)((0, to_graphivz_1.dumpClassHierachry)(objectType, { showBaseType: true, depth: 2 })));
|
|
228
|
-
writer.writeLine((0, to_graphivz_1.graphVizToPlantUml)((0, to_graphivz_1.opcuaToDot)(objectType)));
|
|
229
|
-
// enumerate components
|
|
230
|
-
writer.writeLine((0, displayNodeElement_1.displayNodeElement)(objectType, { format: "markdown" }));
|
|
231
|
-
for (const comp of objectType.getComponents()) {
|
|
232
|
-
writer.writeLine("\n\n#### " + comp.browseName.name.toString());
|
|
233
|
-
writer.writeLine("");
|
|
234
|
-
writer.writeLine(d(comp));
|
|
235
|
-
}
|
|
236
|
-
for (const comp of objectType.getProperties()) {
|
|
237
|
-
writer.writeLine("\n\n#### " + comp.browseName.name.toString());
|
|
238
|
-
writer.writeLine("");
|
|
239
|
-
writer.writeLine(d(comp));
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
// -------------- writeVariableType
|
|
244
|
-
if (namespacePriv._variableTypeCount() > 0) {
|
|
245
|
-
writer.writeLine("");
|
|
246
|
-
writer.writeLine("## VariableTypes");
|
|
247
|
-
writer.writeLine("");
|
|
248
|
-
for (const variableType of namespacePriv._variableTypeIterator()) {
|
|
249
|
-
writer.writeLine("\n\n### " + variableType.browseName.name.toString());
|
|
250
|
-
writer.writeLine(d(variableType));
|
|
251
|
-
writer.writeLine("");
|
|
252
|
-
writer.writeLine((0, to_graphivz_1.graphVizToPlantUml)((0, to_graphivz_1.dumpClassHierachry)(variableType, { showBaseType: true, depth: 2 })));
|
|
253
|
-
writer.writeLine((0, to_graphivz_1.graphVizToPlantUml)((0, to_graphivz_1.opcuaToDot)(variableType)));
|
|
254
|
-
// enumerate components
|
|
255
|
-
writer.writeLine((0, displayNodeElement_1.displayNodeElement)(variableType, { format: "markdown" }));
|
|
256
|
-
for (const reference of variableType.allReferences()) {
|
|
257
|
-
const n = reference.node;
|
|
258
|
-
writer.writeLine("\n\n#### " + n.browseName.name.toString());
|
|
259
|
-
writer.writeLine("");
|
|
260
|
-
writer.writeLine(d(n));
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
exports.buildDocumentation = buildDocumentation;
|
|
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.buildDocumentation = exports.buildDocumentationToString = void 0;
|
|
13
|
+
const node_opcua_basic_types_1 = require("node-opcua-basic-types");
|
|
14
|
+
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
15
|
+
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
16
|
+
const displayNodeElement_1 = require("./displayNodeElement");
|
|
17
|
+
const tableHelper_1 = require("./tableHelper");
|
|
18
|
+
const to_graphivz_1 = require("./to_graphivz");
|
|
19
|
+
class Writer {
|
|
20
|
+
constructor() {
|
|
21
|
+
this.stream = [];
|
|
22
|
+
/* empty */
|
|
23
|
+
}
|
|
24
|
+
writeLine(str) {
|
|
25
|
+
this.stream.push(str);
|
|
26
|
+
}
|
|
27
|
+
toString() {
|
|
28
|
+
return this.stream.join("\n");
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function buildDocumentationToString(namespace) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const writer = new Writer();
|
|
34
|
+
yield buildDocumentation(namespace, writer);
|
|
35
|
+
return writer.toString();
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
exports.buildDocumentationToString = buildDocumentationToString;
|
|
39
|
+
const toDataTypeStr = (p) => {
|
|
40
|
+
if (p.nodeClass === node_opcua_data_model_1.NodeClass.Variable) {
|
|
41
|
+
const v = p;
|
|
42
|
+
const arr = v.valueRank == 1 ? "[]" : "";
|
|
43
|
+
const brn = toDataTypeStr(p.dataTypeObj);
|
|
44
|
+
return brn + arr;
|
|
45
|
+
}
|
|
46
|
+
if (p.nodeClass === node_opcua_data_model_1.NodeClass.DataType) {
|
|
47
|
+
const dataType = p;
|
|
48
|
+
const brn = dataType.browseName.toString();
|
|
49
|
+
return brn;
|
|
50
|
+
}
|
|
51
|
+
return "";
|
|
52
|
+
};
|
|
53
|
+
function dataTypeEnumerationToMarkdown(dataType) {
|
|
54
|
+
const addressSpace = dataType.addressSpace;
|
|
55
|
+
const writer = new Writer();
|
|
56
|
+
writer.writeLine("");
|
|
57
|
+
if (dataType.description) {
|
|
58
|
+
writer.writeLine(dataType.description.text || "");
|
|
59
|
+
}
|
|
60
|
+
writer.writeLine(`\nThe fields of the ${dataType.browseName.name} DataType are defined in the following table:`);
|
|
61
|
+
writer.writeLine("");
|
|
62
|
+
const definition = dataType.getEnumDefinition();
|
|
63
|
+
writer.writeLine("\nBasic Type: " + node_opcua_variant_1.DataType[node_opcua_variant_1.DataType.Int32]);
|
|
64
|
+
writer.writeLine("");
|
|
65
|
+
const table = new tableHelper_1.TableHelper(["Name", "Value", "Description"]);
|
|
66
|
+
for (const f of definition.fields || []) {
|
|
67
|
+
table.push([f.name, (0, node_opcua_basic_types_1.coerceUInt32)(f.value[1]), f.description.text || ""]);
|
|
68
|
+
}
|
|
69
|
+
writer.writeLine(table.toMarkdownTable());
|
|
70
|
+
const str = dumpTypeRepresentation(dataType);
|
|
71
|
+
writer.writeLine(str);
|
|
72
|
+
return writer.toString();
|
|
73
|
+
}
|
|
74
|
+
function dumpTypeRepresentation(uaType) {
|
|
75
|
+
var _a;
|
|
76
|
+
const className = node_opcua_data_model_1.NodeClass[uaType.nodeClass];
|
|
77
|
+
const writer = new Writer();
|
|
78
|
+
writer.writeLine("\n");
|
|
79
|
+
writer.writeLine(`\nThe representation of the ${uaType.browseName.name} ${className} in the address space is shown in the following table:`);
|
|
80
|
+
const table = new tableHelper_1.TableHelper(["Name", "Attribute"]);
|
|
81
|
+
table.push(["NodeId", uaType.nodeId.toString()]);
|
|
82
|
+
table.push(["NamespaceUri", uaType.addressSpace.getNamespaceUri(uaType.nodeId.namespace)]);
|
|
83
|
+
table.push(["BrowseName", uaType.browseName.name.toString()]);
|
|
84
|
+
table.push(["NodeClass", node_opcua_data_model_1.NodeClass[uaType.nodeClass]]);
|
|
85
|
+
if (uaType.nodeClass === node_opcua_data_model_1.NodeClass.ReferenceType) {
|
|
86
|
+
table.push(["InverseName", uaType.inverseName.text]);
|
|
87
|
+
// table.push(["IsSymmetric", (uaType as UAReferenceType).isSymetric ? "Yes" : "No"]);
|
|
88
|
+
}
|
|
89
|
+
table.push(["IsAbstract", uaType.isAbstract ? "Yes" : "No"]);
|
|
90
|
+
table.push(["SubtypeOf", uaType.subtypeOfObj ? uaType.subtypeOfObj.browseName.toString() : ""]);
|
|
91
|
+
writer.writeLine("");
|
|
92
|
+
writer.writeLine(table.toMarkdownTable());
|
|
93
|
+
writer.writeLine("");
|
|
94
|
+
// forward refereces
|
|
95
|
+
{
|
|
96
|
+
const properties = uaType.findReferencesExAsObject("HasProperty");
|
|
97
|
+
const table = new tableHelper_1.TableHelper(["Reference", "NodeClass", "BrowseName", "DataType", "TypeDefinition", "ModellingRule"]);
|
|
98
|
+
if (uaType.subtypeOfObj) {
|
|
99
|
+
const referenceName = "HasSubType";
|
|
100
|
+
const p = uaType.subtypeOfObj;
|
|
101
|
+
const nodeClass = node_opcua_data_model_1.NodeClass[p.nodeClass];
|
|
102
|
+
const browseName = p.browseName.toString();
|
|
103
|
+
const dataTypeStr = toDataTypeStr(p);
|
|
104
|
+
const modellingRule = p.modellingRule || "";
|
|
105
|
+
const typeDefinitionName = "";
|
|
106
|
+
table.push([referenceName, nodeClass, browseName, dataTypeStr, typeDefinitionName, modellingRule]);
|
|
107
|
+
}
|
|
108
|
+
if (properties.length > 0) {
|
|
109
|
+
writer.writeLine(`\nThe reference of the ${uaType.browseName.name} ${className} is shown in the following table:`);
|
|
110
|
+
writer.writeLine("");
|
|
111
|
+
for (const p of properties) {
|
|
112
|
+
const referenceName = "HasProperty";
|
|
113
|
+
const nodeClass = node_opcua_data_model_1.NodeClass[p.nodeClass];
|
|
114
|
+
const browseName = p.browseName.toString();
|
|
115
|
+
const dataTypeStr = toDataTypeStr(p);
|
|
116
|
+
const typeDefinitionName = (_a = p.typeDefinitionObj) === null || _a === void 0 ? void 0 : _a.browseName.toString();
|
|
117
|
+
const modellingRule = p.modellingRule || "";
|
|
118
|
+
table.push([referenceName, nodeClass, browseName, dataTypeStr, typeDefinitionName, modellingRule]);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
writer.writeLine("");
|
|
122
|
+
writer.writeLine(table.toMarkdownTable());
|
|
123
|
+
writer.writeLine("");
|
|
124
|
+
}
|
|
125
|
+
return writer.toString();
|
|
126
|
+
}
|
|
127
|
+
function dataTypeStructureToMarkdown(dataType) {
|
|
128
|
+
const addressSpace = dataType.addressSpace;
|
|
129
|
+
const writer = new Writer();
|
|
130
|
+
writer.writeLine("");
|
|
131
|
+
if (dataType.description) {
|
|
132
|
+
writer.writeLine(dataType.description.text || "");
|
|
133
|
+
}
|
|
134
|
+
const definition = dataType.getStructureDefinition();
|
|
135
|
+
writer.writeLine("\nBasic Type: " + node_opcua_variant_1.DataType[dataType.basicDataType]);
|
|
136
|
+
writer.writeLine("");
|
|
137
|
+
writer.writeLine(`The fields of the ${dataType.browseName.name} DataType are defined in the following table:`);
|
|
138
|
+
const c = (f) => {
|
|
139
|
+
var _a;
|
|
140
|
+
let dataTypeString = addressSpace.findDataType(f.dataType).browseName.toString();
|
|
141
|
+
if (f.valueRank === 1) {
|
|
142
|
+
dataTypeString += "[]";
|
|
143
|
+
}
|
|
144
|
+
else if (f.valueRank >= 2) {
|
|
145
|
+
dataTypeString += "[" + ((_a = f.arrayDimensions) === null || _a === void 0 ? void 0 : _a.map((d) => "" + d).join(" ")) + "]";
|
|
146
|
+
}
|
|
147
|
+
// f.maxStringLength ? f.maxStringLength : "",
|
|
148
|
+
// f.arrayDimensions ? f.arrayDimensions : "",
|
|
149
|
+
return dataTypeString;
|
|
150
|
+
};
|
|
151
|
+
const table = new tableHelper_1.TableHelper(["Name", "Type", "Description"]);
|
|
152
|
+
table.push([dataType.browseName.name, "Structure"]);
|
|
153
|
+
for (const f of definition.fields || []) {
|
|
154
|
+
table.push([" " + f.name, c(f), (f.description.text || "").replace(/\n/g, "<br>")]);
|
|
155
|
+
}
|
|
156
|
+
writer.writeLine(table.toMarkdownTable());
|
|
157
|
+
const str = dumpTypeRepresentation(dataType);
|
|
158
|
+
writer.writeLine(str);
|
|
159
|
+
return writer.toString();
|
|
160
|
+
}
|
|
161
|
+
function dataTypeToMarkdown(dataType) {
|
|
162
|
+
if (dataType.isEnumeration()) {
|
|
163
|
+
return dataTypeEnumerationToMarkdown(dataType);
|
|
164
|
+
}
|
|
165
|
+
else if (dataType.isStructure()) {
|
|
166
|
+
return dataTypeStructureToMarkdown(dataType);
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
const writer = new Writer();
|
|
170
|
+
writer.writeLine("");
|
|
171
|
+
if (dataType.description) {
|
|
172
|
+
writer.writeLine(dataType.description.text || "");
|
|
173
|
+
}
|
|
174
|
+
writer.writeLine("\nBasic Type: " + node_opcua_variant_1.DataType[dataType.basicDataType]);
|
|
175
|
+
writer.writeLine("");
|
|
176
|
+
return writer.toString();
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function dumpReferenceType(referenceType) {
|
|
180
|
+
const writer = new Writer();
|
|
181
|
+
const str = dumpTypeRepresentation(referenceType);
|
|
182
|
+
writer.writeLine(str);
|
|
183
|
+
return writer.toString();
|
|
184
|
+
}
|
|
185
|
+
function buildDocumentation(namespace, writer) {
|
|
186
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
+
const addressSpace = namespace.addressSpace;
|
|
188
|
+
const namespaceUri = namespace.namespaceUri;
|
|
189
|
+
// -------- Documentation
|
|
190
|
+
const nsIndex = addressSpace.getNamespaceIndex(namespaceUri);
|
|
191
|
+
writer.writeLine("");
|
|
192
|
+
writer.writeLine("# Namespace " + namespaceUri);
|
|
193
|
+
writer.writeLine("");
|
|
194
|
+
const namespacePriv = namespace;
|
|
195
|
+
// -------------- writeReferences
|
|
196
|
+
if (namespacePriv._referenceTypeCount() > 0) {
|
|
197
|
+
writer.writeLine("");
|
|
198
|
+
writer.writeLine("## References ");
|
|
199
|
+
writer.writeLine("");
|
|
200
|
+
for (const referenceType of namespacePriv._referenceTypeIterator()) {
|
|
201
|
+
writer.writeLine("\n\n### reference " + referenceType.browseName.name);
|
|
202
|
+
dumpReferenceType(referenceType);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
function d(node) {
|
|
206
|
+
return node.description ? node.description.text.toString() : "";
|
|
207
|
+
}
|
|
208
|
+
// -------------- writeDataType
|
|
209
|
+
if (namespacePriv._dataTypeCount() > 0) {
|
|
210
|
+
writer.writeLine("");
|
|
211
|
+
writer.writeLine("## DataTypes");
|
|
212
|
+
writer.writeLine("");
|
|
213
|
+
for (const dataType of namespacePriv._dataTypeIterator()) {
|
|
214
|
+
writer.writeLine("\n\n### " + dataType.browseName.name.toString());
|
|
215
|
+
writer.writeLine("");
|
|
216
|
+
writer.writeLine(dataTypeToMarkdown(dataType));
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
// -------------- writeObjectType
|
|
220
|
+
if (namespacePriv._objectTypeCount() > 0) {
|
|
221
|
+
writer.writeLine("");
|
|
222
|
+
writer.writeLine("## ObjectTypes");
|
|
223
|
+
writer.writeLine("");
|
|
224
|
+
for (const objectType of namespacePriv._objectTypeIterator()) {
|
|
225
|
+
writer.writeLine("\n\n### " + objectType.browseName.name.toString());
|
|
226
|
+
writer.writeLine(d(objectType));
|
|
227
|
+
writer.writeLine((0, to_graphivz_1.graphVizToPlantUml)((0, to_graphivz_1.dumpClassHierachry)(objectType, { showBaseType: true, depth: 2 })));
|
|
228
|
+
writer.writeLine((0, to_graphivz_1.graphVizToPlantUml)((0, to_graphivz_1.opcuaToDot)(objectType)));
|
|
229
|
+
// enumerate components
|
|
230
|
+
writer.writeLine((0, displayNodeElement_1.displayNodeElement)(objectType, { format: "markdown" }));
|
|
231
|
+
for (const comp of objectType.getComponents()) {
|
|
232
|
+
writer.writeLine("\n\n#### " + comp.browseName.name.toString());
|
|
233
|
+
writer.writeLine("");
|
|
234
|
+
writer.writeLine(d(comp));
|
|
235
|
+
}
|
|
236
|
+
for (const comp of objectType.getProperties()) {
|
|
237
|
+
writer.writeLine("\n\n#### " + comp.browseName.name.toString());
|
|
238
|
+
writer.writeLine("");
|
|
239
|
+
writer.writeLine(d(comp));
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
// -------------- writeVariableType
|
|
244
|
+
if (namespacePriv._variableTypeCount() > 0) {
|
|
245
|
+
writer.writeLine("");
|
|
246
|
+
writer.writeLine("## VariableTypes");
|
|
247
|
+
writer.writeLine("");
|
|
248
|
+
for (const variableType of namespacePriv._variableTypeIterator()) {
|
|
249
|
+
writer.writeLine("\n\n### " + variableType.browseName.name.toString());
|
|
250
|
+
writer.writeLine(d(variableType));
|
|
251
|
+
writer.writeLine("");
|
|
252
|
+
writer.writeLine((0, to_graphivz_1.graphVizToPlantUml)((0, to_graphivz_1.dumpClassHierachry)(variableType, { showBaseType: true, depth: 2 })));
|
|
253
|
+
writer.writeLine((0, to_graphivz_1.graphVizToPlantUml)((0, to_graphivz_1.opcuaToDot)(variableType)));
|
|
254
|
+
// enumerate components
|
|
255
|
+
writer.writeLine((0, displayNodeElement_1.displayNodeElement)(variableType, { format: "markdown" }));
|
|
256
|
+
for (const reference of variableType.allReferences()) {
|
|
257
|
+
const n = reference.node;
|
|
258
|
+
writer.writeLine("\n\n#### " + n.browseName.name.toString());
|
|
259
|
+
writer.writeLine("");
|
|
260
|
+
writer.writeLine(d(n));
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
exports.buildDocumentation = buildDocumentation;
|
|
267
267
|
//# sourceMappingURL=generate_markdown_doc.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
export * from "./types";
|
|
2
|
-
export * from "./displayNodeElement";
|
|
3
|
-
export * from "./promoteToMandatory";
|
|
4
|
-
export * from "./setNamespaceMetaData";
|
|
5
|
-
export * from "./build_model_inner";
|
|
6
|
-
export * from "./addExtensionObjectDataType";
|
|
7
|
-
export * from "./symbol";
|
|
8
|
-
export * from "./to_cvs";
|
|
9
|
-
export * from "./to_graphivz";
|
|
10
|
-
export * from "./generate_markdown_doc";
|
|
11
|
-
export * from "node-opcua-address-space";
|
|
12
|
-
export * from "node-opcua-nodesets";
|
|
13
|
-
export * from "node-opcua-variant";
|
|
14
|
-
export * from "node-opcua-assert";
|
|
15
|
-
export * from "node-opcua-data-model";
|
|
16
|
-
export * from "node-opcua-nodeid";
|
|
17
|
-
export * from "node-opcua-numeric-range";
|
|
18
|
-
export * from "node-opcua-status-code";
|
|
19
|
-
export * from "node-opcua-basic-types";
|
|
20
|
-
export * from "node-opcua-constants";
|
|
21
|
-
export * from "node-opcua-assert";
|
|
22
|
-
export * from "node-opcua-service-translate-browse-path";
|
|
23
|
-
export { MethodIds, DataTypeIds, ReferenceTypeIds, VariableIds, VariableTypeIds, ObjectTypeIds, ObjectIds } from "node-opcua-constants";
|
|
24
|
-
export { DataTypeDefinition, EnumDefinition, EnumDefinitionOptions, StructureDefinition, StructureDefinitionOptions } from "node-opcua-types";
|
|
1
|
+
export * from "./types";
|
|
2
|
+
export * from "./displayNodeElement";
|
|
3
|
+
export * from "./promoteToMandatory";
|
|
4
|
+
export * from "./setNamespaceMetaData";
|
|
5
|
+
export * from "./build_model_inner";
|
|
6
|
+
export * from "./addExtensionObjectDataType";
|
|
7
|
+
export * from "./symbol";
|
|
8
|
+
export * from "./to_cvs";
|
|
9
|
+
export * from "./to_graphivz";
|
|
10
|
+
export * from "./generate_markdown_doc";
|
|
11
|
+
export * from "node-opcua-address-space";
|
|
12
|
+
export * from "node-opcua-nodesets";
|
|
13
|
+
export * from "node-opcua-variant";
|
|
14
|
+
export * from "node-opcua-assert";
|
|
15
|
+
export * from "node-opcua-data-model";
|
|
16
|
+
export * from "node-opcua-nodeid";
|
|
17
|
+
export * from "node-opcua-numeric-range";
|
|
18
|
+
export * from "node-opcua-status-code";
|
|
19
|
+
export * from "node-opcua-basic-types";
|
|
20
|
+
export * from "node-opcua-constants";
|
|
21
|
+
export * from "node-opcua-assert";
|
|
22
|
+
export * from "node-opcua-service-translate-browse-path";
|
|
23
|
+
export { MethodIds, DataTypeIds, ReferenceTypeIds, VariableIds, VariableTypeIds, ObjectTypeIds, ObjectIds } from "node-opcua-constants";
|
|
24
|
+
export { DataTypeDefinition, EnumDefinition, EnumDefinitionOptions, StructureDefinition, StructureDefinitionOptions } from "node-opcua-types";
|