node-opcua-modeler 2.62.5 → 2.63.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/generate_markdown_doc.js +8 -0
- package/dist/generate_markdown_doc.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/to_graphivz.d.ts +13 -0
- package/dist/to_graphivz.js +236 -0
- package/dist/to_graphivz.js.map +1 -0
- package/package.json +21 -21
- package/source/generate_markdown_doc.ts +17 -0
- package/source/index.ts +2 -0
- package/source/to_graphivz.ts +270 -0
- package/.mocharc.js +0 -13
|
@@ -15,6 +15,7 @@ const node_opcua_types_1 = require("node-opcua-types");
|
|
|
15
15
|
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
16
16
|
const displayNodeElement_1 = require("./displayNodeElement");
|
|
17
17
|
const tableHelper_1 = require("./tableHelper");
|
|
18
|
+
const to_graphivz_1 = require("./to_graphivz");
|
|
18
19
|
class Writer {
|
|
19
20
|
constructor() {
|
|
20
21
|
this.stream = [];
|
|
@@ -112,6 +113,8 @@ function buildDocumentation(namespace, writer) {
|
|
|
112
113
|
for (const objectType of namespacePriv._objectTypeIterator()) {
|
|
113
114
|
writer.writeLine("\n\n### " + objectType.browseName.name.toString());
|
|
114
115
|
writer.writeLine(d(objectType));
|
|
116
|
+
writer.writeLine(graphVizToPlantUml((0, to_graphivz_1.dumpClassHierachry)(objectType, { showBaseType: true, depth: 2 })));
|
|
117
|
+
writer.writeLine(graphVizToPlantUml((0, to_graphivz_1.opcuaToDot)(objectType)));
|
|
115
118
|
// enumerate components
|
|
116
119
|
writer.writeLine((0, displayNodeElement_1.displayNodeElement)(objectType, { format: "markdown" }));
|
|
117
120
|
for (const comp of objectType.getComponents()) {
|
|
@@ -133,6 +136,8 @@ function buildDocumentation(namespace, writer) {
|
|
|
133
136
|
writer.writeLine("\n\n### " + variableType.browseName.name.toString());
|
|
134
137
|
writer.writeLine(d(variableType));
|
|
135
138
|
writer.writeLine("");
|
|
139
|
+
writer.writeLine(graphVizToPlantUml((0, to_graphivz_1.dumpClassHierachry)(variableType, { showBaseType: true, depth: 2 })));
|
|
140
|
+
writer.writeLine(graphVizToPlantUml((0, to_graphivz_1.opcuaToDot)(variableType)));
|
|
136
141
|
// enumerate components
|
|
137
142
|
writer.writeLine((0, displayNodeElement_1.displayNodeElement)(variableType, { format: "markdown" }));
|
|
138
143
|
for (const reference of variableType.allReferences()) {
|
|
@@ -145,4 +150,7 @@ function buildDocumentation(namespace, writer) {
|
|
|
145
150
|
});
|
|
146
151
|
}
|
|
147
152
|
exports.buildDocumentation = buildDocumentation;
|
|
153
|
+
function graphVizToPlantUml(arg0) {
|
|
154
|
+
throw new Error("Function not implemented.");
|
|
155
|
+
}
|
|
148
156
|
//# sourceMappingURL=generate_markdown_doc.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate_markdown_doc.js","sourceRoot":"","sources":["../source/generate_markdown_doc.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,mEAAsD;AACtD,uDAA2G;AAC3G,2DAA8C;
|
|
1
|
+
{"version":3,"file":"generate_markdown_doc.js","sourceRoot":"","sources":["../source/generate_markdown_doc.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,mEAAsD;AACtD,uDAA2G;AAC3G,2DAA8C;AAE9C,6DAA0D;AAC1D,+CAA4C;AAC5C,+CAA+D;AAiB/D,MAAM,MAAM;IAER;QADiB,WAAM,GAAa,EAAE,CAAC;QAEnC,WAAW;IACf,CAAC;IACM,SAAS,CAAC,GAAW;QACxB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;IACM,QAAQ;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;CACJ;AAED,SAAsB,0BAA0B,CAAC,SAAoB;;QACjE,MAAM,MAAM,G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AAC,IAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;gBAC9D,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;gBACrB,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;aAC1B;SACJ;IACL,CAAC;CAAA;AAjFD,gDAiFC;AACD,SAAS,kBAAkB,CAAC,IAAY;IACpC,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;AACjD,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from "./build_model_inner";
|
|
|
6
6
|
export * from "./addExtensionObjectDataType";
|
|
7
7
|
export * from "./symbol";
|
|
8
8
|
export * from "./to_cvs";
|
|
9
|
+
export * from "./to_graphivz";
|
|
9
10
|
export * from "./generate_markdown_doc";
|
|
10
11
|
export * from "node-opcua-address-space";
|
|
11
12
|
export * from "node-opcua-nodesets";
|
package/dist/index.js
CHANGED
|
@@ -19,6 +19,7 @@ __exportStar(require("./build_model_inner"), exports);
|
|
|
19
19
|
__exportStar(require("./addExtensionObjectDataType"), exports);
|
|
20
20
|
__exportStar(require("./symbol"), exports);
|
|
21
21
|
__exportStar(require("./to_cvs"), exports);
|
|
22
|
+
__exportStar(require("./to_graphivz"), exports);
|
|
22
23
|
__exportStar(require("./generate_markdown_doc"), exports);
|
|
23
24
|
//
|
|
24
25
|
__exportStar(require("node-opcua-address-space"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,0CAAwB;AACxB,uDAAqC;AACrC,uDAAqC;AACrC,yDAAuC;AACvC,sDAAoC;AACpC,+DAA6C;AAC7C,2CAAyB;AACzB,2CAAyB;AACzB,0DAAwC;AACxC,EAAE;AACF,2DAAyC;AACzC,sDAAoC;AACpC,qDAAmC;AACnC,oDAAkC;AAClC,wDAAsC;AACtC,oDAAkC;AAClC,2DAAyC;AACzC,yDAAuC;AACvC,yDAAuC;AACvC,uDAAqC;AACrC,oDAAkC;AAClC,2EAAyD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,0CAAwB;AACxB,uDAAqC;AACrC,uDAAqC;AACrC,yDAAuC;AACvC,sDAAoC;AACpC,+DAA6C;AAC7C,2CAAyB;AACzB,2CAAyB;AACzB,gDAA8B;AAC9B,0DAAwC;AACxC,EAAE;AACF,2DAAyC;AACzC,sDAAoC;AACpC,qDAAmC;AACnC,oDAAkC;AAClC,wDAAsC;AACtC,oDAAkC;AAClC,2DAAyC;AACzC,yDAAuC;AACvC,yDAAuC;AACvC,uDAAqC;AACrC,oDAAkC;AAClC,2EAAyD;AAEzD,6DAAwI;AAA/H,iHAAA,SAAS,OAAA;AAAE,mHAAA,WAAW,OAAA;AAAE,wHAAA,gBAAgB,OAAA;AAAE,mHAAA,WAAW,OAAA;AAAE,uHAAA,eAAe,OAAA;AAAE,qHAAA,aAAa,OAAA;AAAE,iHAAA,SAAS,OAAA;AAEzG,qDAM0B;AALtB,sHAAA,kBAAkB,OAAA;AAClB,kHAAA,cAAc,OAAA;AAEd,uHAAA,mBAAmB,OAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { UAReferenceType, UADataType, UAObjectType, UAVariableType } from "node-opcua-address-space";
|
|
2
|
+
interface Options {
|
|
3
|
+
naked: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function opcuaToDot(node: UAObjectType | UAVariableType, options?: Options): string;
|
|
6
|
+
export declare function dumpClassHierachry(typeNode: UAObjectType | UAVariableType | UADataType | UAReferenceType, options?: {
|
|
7
|
+
naked?: boolean;
|
|
8
|
+
depth?: number;
|
|
9
|
+
showBaseType?: boolean;
|
|
10
|
+
showSubType?: boolean;
|
|
11
|
+
}): string;
|
|
12
|
+
export declare function dumpTypeDiagram(namespace: any): string;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dumpTypeDiagram = exports.dumpClassHierachry = exports.opcuaToDot = void 0;
|
|
4
|
+
const node_opcua_constants_1 = require("node-opcua-constants");
|
|
5
|
+
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
6
|
+
function innerText(node) {
|
|
7
|
+
var _a, _b;
|
|
8
|
+
const browseName = node.browseName.name;
|
|
9
|
+
const typeDefinition = (_b = (_a = node.typeDefinitionObj) === null || _a === void 0 ? void 0 : _a.browseName) === null || _b === void 0 ? void 0 : _b.name;
|
|
10
|
+
if (typeDefinition) {
|
|
11
|
+
return `[ label =< <FONT point-size="8" ><I>${typeDefinition}</I></FONT><BR/>${browseName} >]`;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
return `[label =< ${browseName} >]`;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function arrowHeadAttribute(reference) {
|
|
18
|
+
switch (reference.referenceType.value) {
|
|
19
|
+
case node_opcua_constants_1.ReferenceTypeIds.HasTypeDefinition:
|
|
20
|
+
return "normalnormal";
|
|
21
|
+
case node_opcua_constants_1.ReferenceTypeIds.HasComponent:
|
|
22
|
+
return "noneteetree";
|
|
23
|
+
case node_opcua_constants_1.ReferenceTypeIds.HasProperty:
|
|
24
|
+
return "nonetee";
|
|
25
|
+
case node_opcua_constants_1.ReferenceTypeIds.HasSubtype:
|
|
26
|
+
return "onormalonormal";
|
|
27
|
+
case node_opcua_constants_1.ReferenceTypeIds.HasModellingRule:
|
|
28
|
+
return "none";
|
|
29
|
+
default:
|
|
30
|
+
return "normal";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function arrowHead(reference) {
|
|
34
|
+
return `[arrowhead = ${arrowHeadAttribute(reference)}]`;
|
|
35
|
+
}
|
|
36
|
+
const regularShapes = {
|
|
37
|
+
ObjectType: '[shape=rectangle, style="filled" fillcolor="#e8edf7;0.75:#d2def0" gradientangle=275]',
|
|
38
|
+
VariableType: '[shape=rectangle, style="rounded,filled" fillcolor="#e8edf7;0.75:#d2def0" gradientangle=275]',
|
|
39
|
+
Object: ' [shape=rectangle, style="rounded,filled" fillcolor="#e8edf7"]',
|
|
40
|
+
Variable: '[shape=rectangle, style="filled,rounded" fillcolor="#e8edf7"]',
|
|
41
|
+
Method: '[shape=circle, style="filled" fillcolor="#e8edf7"]'
|
|
42
|
+
};
|
|
43
|
+
const regularShapesOptionals = {
|
|
44
|
+
ObjectType: '[shape=rectangle, style="filled,dashed" fillcolor="#e8edf7;0.75:#d2def0" gradientangle=275]',
|
|
45
|
+
VariableType: '[shape=rectangle, style="rounded,filled,dashed" fillcolor="#e8edf7;0.75:#d2def0" gradientangle=275]',
|
|
46
|
+
Object: ' [shape=rectangle, style="rounded,filled,dashed" fillcolor="#e8edf7"]',
|
|
47
|
+
Variable: '[shape=rectangle, style="filled,rounded,dashed" fillcolor="#e8edf7"]',
|
|
48
|
+
Method: '[shape=circle, style="filled,dashed" fillcolor="#e8edf7"]'
|
|
49
|
+
};
|
|
50
|
+
class NodeRegistry {
|
|
51
|
+
constructor() {
|
|
52
|
+
this.m = {};
|
|
53
|
+
this.invisibleNodes = [];
|
|
54
|
+
}
|
|
55
|
+
add(node) {
|
|
56
|
+
const nodeClass = node_opcua_data_model_1.NodeClass[node.nodeClass];
|
|
57
|
+
this.m[nodeClass] = this.m[nodeClass] || [];
|
|
58
|
+
this.m[nodeClass].push(node);
|
|
59
|
+
}
|
|
60
|
+
addInvisibleNode(name) {
|
|
61
|
+
this.invisibleNodes.push(name);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function dumpNodeByNodeClass(str, nodeRegistry) {
|
|
65
|
+
for (const [className, listNode] of Object.entries(nodeRegistry.m)) {
|
|
66
|
+
if (listNode.length === 0) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
str.push(` ## -> ${className}`);
|
|
70
|
+
const mandatoryNodes = listNode.filter((node) => !node.modellingRule || node.modellingRule.match(/Mandatory/));
|
|
71
|
+
const optionalNodes = listNode.filter((node) => node.modellingRule && node.modellingRule.match(/Optional/));
|
|
72
|
+
if (mandatoryNodes.length > 0) {
|
|
73
|
+
str.push(` node [];`);
|
|
74
|
+
const decoration = regularShapes[className];
|
|
75
|
+
str.push(` node ${decoration};`);
|
|
76
|
+
for (const node of mandatoryNodes) {
|
|
77
|
+
str.push(` ${node.browseName.name} ${innerText(node)}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (optionalNodes.length > 0) {
|
|
81
|
+
const decoration2 = regularShapesOptionals[className];
|
|
82
|
+
str.push(` node [];`);
|
|
83
|
+
str.push(` node ${decoration2};`);
|
|
84
|
+
for (const node of listNode) {
|
|
85
|
+
str.push(` ${node.browseName.name} ${innerText(node)}`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (nodeRegistry.invisibleNodes.length) {
|
|
90
|
+
str.push(" # invisible nodes");
|
|
91
|
+
str.push(" node []");
|
|
92
|
+
str.push(" node [width=0,height=0,shape=point,style=invis];");
|
|
93
|
+
str.push(` ${nodeRegistry.invisibleNodes.join("\n ")};`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function opcuaToDot(node, options) {
|
|
97
|
+
options = options || { naked: false };
|
|
98
|
+
const nodeRegistry = new NodeRegistry();
|
|
99
|
+
nodeRegistry.add(node);
|
|
100
|
+
const str = [];
|
|
101
|
+
const str2 = [];
|
|
102
|
+
str.push("digraph G {");
|
|
103
|
+
if (!options.naked) {
|
|
104
|
+
str.push(" rankdir=TB;");
|
|
105
|
+
str.push(" nodesep=0.5;");
|
|
106
|
+
str.push(" node [];");
|
|
107
|
+
}
|
|
108
|
+
// eslint-disable-next-line max-statements
|
|
109
|
+
function typeMemberAndSubTypeMember(str, node, parent, offset, prefix, joinWithCaller) {
|
|
110
|
+
let innerDepth = 0;
|
|
111
|
+
const browseName = (parent || node).browseName.name.toString();
|
|
112
|
+
const r = [];
|
|
113
|
+
const r2 = [];
|
|
114
|
+
const references = node.findReferencesEx("Aggregates", node_opcua_data_model_1.BrowseDirection.Forward);
|
|
115
|
+
const folderElements = node.findReferencesEx("Organizes", node_opcua_data_model_1.BrowseDirection.Forward);
|
|
116
|
+
const childReferences = [...references, ...folderElements];
|
|
117
|
+
for (let i = 0; i < childReferences.length; i++) {
|
|
118
|
+
const isLast = i === childReferences.length - 1;
|
|
119
|
+
innerDepth++;
|
|
120
|
+
const reference = childReferences[i];
|
|
121
|
+
const childNode = reference.node;
|
|
122
|
+
const childName = childNode.browseName.name.toString();
|
|
123
|
+
nodeRegistry.add(childNode);
|
|
124
|
+
const edgeAttributes = arrowHead(reference);
|
|
125
|
+
const breakNode = `${prefix}${i + offset}`;
|
|
126
|
+
r2.push(breakNode);
|
|
127
|
+
nodeRegistry.addInvisibleNode(breakNode);
|
|
128
|
+
const horizontalPart = `{ rank=same ${breakNode} -> ${childName} ${edgeAttributes} }`;
|
|
129
|
+
r.push(horizontalPart);
|
|
130
|
+
// push children on same level
|
|
131
|
+
const [depth] = typeMemberAndSubTypeMember(str, childNode, null, 0, `${prefix}${i + offset}_`, false);
|
|
132
|
+
for (let d = 0; d < depth; d++) {
|
|
133
|
+
offset++;
|
|
134
|
+
if (!isLast) {
|
|
135
|
+
const breakNode = `${prefix}${i + offset}`;
|
|
136
|
+
r2.push(breakNode);
|
|
137
|
+
nodeRegistry.addInvisibleNode(breakNode);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
innerDepth += depth;
|
|
141
|
+
}
|
|
142
|
+
if (node.nodeClass == node_opcua_data_model_1.NodeClass.ObjectType || node.nodeClass === node_opcua_data_model_1.NodeClass.VariableType) {
|
|
143
|
+
if (node.subtypeOfObj && node.subtypeOfObj.nodeId.namespace === node.nodeId.namespace) {
|
|
144
|
+
const [depth, rr2] = typeMemberAndSubTypeMember(str, node.subtypeOfObj, node, r.length, prefix, true);
|
|
145
|
+
innerDepth += depth;
|
|
146
|
+
r2.push(...rr2);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (r.length) {
|
|
150
|
+
str.push(...r.map((x) => " " + x));
|
|
151
|
+
}
|
|
152
|
+
if (!joinWithCaller) {
|
|
153
|
+
if (r2.length) {
|
|
154
|
+
str.push(` ${browseName} -> ${r2.join(" -> ")} [arrowhead=none];`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return [innerDepth, r2];
|
|
158
|
+
}
|
|
159
|
+
typeMemberAndSubTypeMember(str2, node, null, 0, "r", false);
|
|
160
|
+
if (!options.naked) {
|
|
161
|
+
dumpNodeByNodeClass(str, nodeRegistry);
|
|
162
|
+
}
|
|
163
|
+
str.push(...str2);
|
|
164
|
+
str.push("}");
|
|
165
|
+
//
|
|
166
|
+
const dot = str.join("\n");
|
|
167
|
+
return dot;
|
|
168
|
+
}
|
|
169
|
+
exports.opcuaToDot = opcuaToDot;
|
|
170
|
+
function dumpClassHierachry(typeNode, options) {
|
|
171
|
+
options = options || { naked: false, showBaseType: true, showSubType: true };
|
|
172
|
+
const level = options.depth || 50;
|
|
173
|
+
const str = [];
|
|
174
|
+
const nodeRegistry = new NodeRegistry();
|
|
175
|
+
nodeRegistry.add(typeNode);
|
|
176
|
+
str.push("digraph G {");
|
|
177
|
+
if (!options.naked) {
|
|
178
|
+
// str.push(" splines=ortho;");
|
|
179
|
+
str.push(" rankdir=BT;");
|
|
180
|
+
str.push(" nodesep=0.5;");
|
|
181
|
+
str.push(" node [];");
|
|
182
|
+
}
|
|
183
|
+
function dumpSubtypes(str, typeNode, level) {
|
|
184
|
+
const parentName = typeNode.browseName.name.toString();
|
|
185
|
+
const references = typeNode.findReferencesEx("HasSubtype", node_opcua_data_model_1.BrowseDirection.Forward);
|
|
186
|
+
for (let i = 0; i < references.length; i++) {
|
|
187
|
+
const reference = references[i];
|
|
188
|
+
const childNode = reference.node;
|
|
189
|
+
const nodeClass = node_opcua_data_model_1.NodeClass[childNode.nodeClass];
|
|
190
|
+
const childName = childNode.browseName.name.toString();
|
|
191
|
+
nodeRegistry.add(typeNode);
|
|
192
|
+
const edgeAttributes = arrowHead(reference);
|
|
193
|
+
str.push(` ${childName} -> ${parentName} ${edgeAttributes};`);
|
|
194
|
+
if (level > 0) {
|
|
195
|
+
dumpSubtypes(str, childNode, level - 1);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/** */
|
|
200
|
+
const str2 = [];
|
|
201
|
+
if (options.showSubType) {
|
|
202
|
+
dumpSubtypes(str2, typeNode, level);
|
|
203
|
+
}
|
|
204
|
+
if (!options.naked) {
|
|
205
|
+
dumpNodeByNodeClass(str, nodeRegistry);
|
|
206
|
+
}
|
|
207
|
+
str.push(...str2);
|
|
208
|
+
str.push("}");
|
|
209
|
+
return str.join("\n");
|
|
210
|
+
}
|
|
211
|
+
exports.dumpClassHierachry = dumpClassHierachry;
|
|
212
|
+
function graphVizToPlantUml(str) {
|
|
213
|
+
const ttt = "```";
|
|
214
|
+
return `${ttt}plantuml\n@startuml\n${str.join("\n")}\n@enduml\n${ttt}`;
|
|
215
|
+
}
|
|
216
|
+
function dumpTypeDiagram(namespace) {
|
|
217
|
+
const objectTypes = [...namespace._objectTypeIterator()];
|
|
218
|
+
const variableTypes = [...namespace._variableTypeIterator()];
|
|
219
|
+
const dataTypes = [...namespace._dataTypeIterator()];
|
|
220
|
+
const referenceTypes = [...namespace._referenceTypeIterator()];
|
|
221
|
+
const addressSpace = namespace.addressSpace;
|
|
222
|
+
const str = [];
|
|
223
|
+
for (const type of [...objectTypes, ...variableTypes]) {
|
|
224
|
+
const d = opcuaToDot(type);
|
|
225
|
+
str.push(graphVizToPlantUml([d]));
|
|
226
|
+
const d2 = dumpClassHierachry(type);
|
|
227
|
+
str.push(graphVizToPlantUml([d2]));
|
|
228
|
+
}
|
|
229
|
+
for (const dataType of dataTypes) {
|
|
230
|
+
const d = opcuaToDot(dataType);
|
|
231
|
+
str.push(graphVizToPlantUml([d]));
|
|
232
|
+
}
|
|
233
|
+
return str.join("\n");
|
|
234
|
+
}
|
|
235
|
+
exports.dumpTypeDiagram = dumpTypeDiagram;
|
|
236
|
+
//# sourceMappingURL=to_graphivz.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to_graphivz.js","sourceRoot":"","sources":["../source/to_graphivz.ts"],"names":[],"mappings":";;;AAWA,+DAAwD;AACxD,iEAAmE;AAEnE,SAAS,SAAS,CAAC,IAA2B;;IAC1C,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;IACxC,MAAM,cAAc,GAAG,MAAA,MAAA,IAAI,CAAC,iBAAiB,0CAAE,UAAU,0CAAE,IAAI,CAAC;IAEhE,IAAI,cAAc,EAAE;QAChB,OAAO,uCAAuC,cAAc,mBAAmB,UAAU,KAAK,CAAC;KAClG;SAAM;QACH,OAAO,aAAa,UAAU,KAAK,CAAC;KACvC;AACL,CAAC;AACD,SAAS,kBAAkB,CAAC,SAAsB;IAC9C,QAAQ,SAAS,CAAC,aAAa,CAAC,KAAK,EAAE;QACnC,KAAK,uCAAgB,CAAC,iBAAiB;YACnC,OAAO,cAAc,CAAC;QAC1B,KAAK,uCAAgB,CAAC,YAAY;YAC9B,OAAO,aAAa,CAAC;QACzB,KAAK,uCAAgB,CAAC,WAAW;YAC7B,OAAO,SAAS,CAAC;QACrB,KAAK,uCAAgB,CAAC,UAAU;YAC5B,OAAO,gBAAgB,CAAC;QAC5B,KAAK,uCAAgB,CAAC,gBAAgB;YAClC,OAAO,MAAM,CAAC;QAClB;YACI,OAAO,QAAQ,CAAC;KACvB;AACL,CAAC;AACD,SAAS,SAAS,CAAC,SAAsB;IACrC,OAAO,gBAAgB,kBAAkB,CAAC,SAAS,CAAC,GAAG,CAAC;AAC5D,CAAC;AAED,MAAM,aAAa,GAA2B;IAC1C,UAAU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,iBAAiB,EAAE,CAAC,CAAC;IACrD,MAAM,cAAc,GAAG,CAAC,GAAG,SAAS,CAAC,sBAAsB,EAAE,CAAC,CAAC;IAC/D,MAAM,YAAY,GAAG,SAAS,CAAC,YAAY,CAAC;IAE5C,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,MAAM,IAAI,IAAI,CAAC,GAAG,WAAW,EAAE,GAAG,aAAa,CAAC,EAAE;QACnD,MAAM,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;QAC3B,GAAG,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAElC,MAAM,EAAE,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;QACpC,GAAG,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;KACtC;IACD,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;QAC9B,MAAM,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC/B,GAAG,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KACrC;IACD,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AApBD,0CAoBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-opcua-modeler",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.63.1",
|
|
4
4
|
"description": "pure nodejs OPCUA SDK - module - model",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -13,27 +13,27 @@
|
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"chalk": "4.1.2",
|
|
16
|
-
"cli-table3": "^0.6.
|
|
17
|
-
"csv-parse": "5.0.
|
|
18
|
-
"node-opcua-address-space": "2.
|
|
19
|
-
"node-opcua-assert": "2.
|
|
20
|
-
"node-opcua-basic-types": "2.
|
|
21
|
-
"node-opcua-client-dynamic-extension-object": "2.
|
|
22
|
-
"node-opcua-constants": "2.
|
|
23
|
-
"node-opcua-data-model": "2.
|
|
24
|
-
"node-opcua-factory": "2.
|
|
25
|
-
"node-opcua-nodeid": "2.
|
|
26
|
-
"node-opcua-nodesets": "2.
|
|
27
|
-
"node-opcua-numeric-range": "2.
|
|
28
|
-
"node-opcua-schemas": "2.
|
|
29
|
-
"node-opcua-service-translate-browse-path": "2.
|
|
30
|
-
"node-opcua-status-code": "2.
|
|
31
|
-
"node-opcua-types": "2.
|
|
32
|
-
"node-opcua-variant": "2.
|
|
33
|
-
"node-opcua-xml2json": "2.
|
|
16
|
+
"cli-table3": "^0.6.1",
|
|
17
|
+
"csv-parse": "5.0.4",
|
|
18
|
+
"node-opcua-address-space": "2.63.1",
|
|
19
|
+
"node-opcua-assert": "2.63.0",
|
|
20
|
+
"node-opcua-basic-types": "2.63.1",
|
|
21
|
+
"node-opcua-client-dynamic-extension-object": "2.63.1",
|
|
22
|
+
"node-opcua-constants": "2.62.7",
|
|
23
|
+
"node-opcua-data-model": "2.63.1",
|
|
24
|
+
"node-opcua-factory": "2.63.1",
|
|
25
|
+
"node-opcua-nodeid": "2.63.1",
|
|
26
|
+
"node-opcua-nodesets": "2.63.0",
|
|
27
|
+
"node-opcua-numeric-range": "2.63.1",
|
|
28
|
+
"node-opcua-schemas": "2.63.1",
|
|
29
|
+
"node-opcua-service-translate-browse-path": "2.63.1",
|
|
30
|
+
"node-opcua-status-code": "2.63.1",
|
|
31
|
+
"node-opcua-types": "2.63.1",
|
|
32
|
+
"node-opcua-variant": "2.63.1",
|
|
33
|
+
"node-opcua-xml2json": "2.63.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"node-opcua-leak-detector": "2.
|
|
36
|
+
"node-opcua-leak-detector": "2.63.1",
|
|
37
37
|
"should": "^13.2.3"
|
|
38
38
|
},
|
|
39
39
|
"repository": {
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"internet of things"
|
|
50
50
|
],
|
|
51
51
|
"homepage": "http://node-opcua.github.io/",
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "d37385314fce703c1cc197104c592df03b2663fb"
|
|
53
53
|
}
|
|
@@ -3,8 +3,10 @@ import { BaseNode, Namespace, UADataType, UAObjectType, UAReferenceType, UAVaria
|
|
|
3
3
|
import { coerceUInt32 } from "node-opcua-basic-types";
|
|
4
4
|
import { DataTypeDefinition, EnumDefinition, StructureDefinition, StructureField } from "node-opcua-types";
|
|
5
5
|
import { DataType } from "node-opcua-variant";
|
|
6
|
+
import { object } from "underscore";
|
|
6
7
|
import { displayNodeElement } from "./displayNodeElement";
|
|
7
8
|
import { TableHelper } from "./tableHelper";
|
|
9
|
+
import { dumpClassHierachry, opcuaToDot } from "./to_graphivz";
|
|
8
10
|
|
|
9
11
|
interface NamespacePriv2 {
|
|
10
12
|
nodeIterator(): IterableIterator<BaseNode>;
|
|
@@ -123,6 +125,11 @@ export async function buildDocumentation(namespace: Namespace, writer: IWriter):
|
|
|
123
125
|
for (const objectType of namespacePriv._objectTypeIterator()) {
|
|
124
126
|
writer.writeLine("\n\n### " + objectType.browseName.name!.toString());
|
|
125
127
|
writer.writeLine(d(objectType));
|
|
128
|
+
|
|
129
|
+
writer.writeLine(graphVizToPlantUml(dumpClassHierachry(objectType, {showBaseType: true, depth: 2})));
|
|
130
|
+
|
|
131
|
+
writer.writeLine(graphVizToPlantUml(opcuaToDot(objectType)));
|
|
132
|
+
|
|
126
133
|
// enumerate components
|
|
127
134
|
writer.writeLine(displayNodeElement(objectType, { format: "markdown" }));
|
|
128
135
|
|
|
@@ -145,6 +152,12 @@ export async function buildDocumentation(namespace: Namespace, writer: IWriter):
|
|
|
145
152
|
writer.writeLine("\n\n### " + variableType.browseName.name!.toString());
|
|
146
153
|
writer.writeLine(d(variableType));
|
|
147
154
|
writer.writeLine("");
|
|
155
|
+
|
|
156
|
+
writer.writeLine(graphVizToPlantUml(dumpClassHierachry(variableType, {showBaseType: true, depth: 2})));
|
|
157
|
+
|
|
158
|
+
writer.writeLine(graphVizToPlantUml(opcuaToDot(variableType)));
|
|
159
|
+
|
|
160
|
+
|
|
148
161
|
// enumerate components
|
|
149
162
|
writer.writeLine(displayNodeElement(variableType, { format: "markdown" }));
|
|
150
163
|
for (const reference of variableType.allReferences()) {
|
|
@@ -155,3 +168,7 @@ export async function buildDocumentation(namespace: Namespace, writer: IWriter):
|
|
|
155
168
|
}
|
|
156
169
|
}
|
|
157
170
|
}
|
|
171
|
+
function graphVizToPlantUml(arg0: string): any {
|
|
172
|
+
throw new Error("Function not implemented.");
|
|
173
|
+
}
|
|
174
|
+
|
package/source/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from "./build_model_inner";
|
|
|
6
6
|
export * from "./addExtensionObjectDataType";
|
|
7
7
|
export * from "./symbol";
|
|
8
8
|
export * from "./to_cvs";
|
|
9
|
+
export * from "./to_graphivz";
|
|
9
10
|
export * from "./generate_markdown_doc";
|
|
10
11
|
//
|
|
11
12
|
export * from "node-opcua-address-space";
|
|
@@ -20,6 +21,7 @@ export * from "node-opcua-basic-types";
|
|
|
20
21
|
export * from "node-opcua-constants";
|
|
21
22
|
export * from "node-opcua-assert";
|
|
22
23
|
export * from "node-opcua-service-translate-browse-path";
|
|
24
|
+
|
|
23
25
|
export { MethodIds, DataTypeIds, ReferenceTypeIds, VariableIds, VariableTypeIds, ObjectTypeIds, ObjectIds } from "node-opcua-constants";
|
|
24
26
|
|
|
25
27
|
export {
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BaseNode,
|
|
3
|
+
UAReference,
|
|
4
|
+
UAObject,
|
|
5
|
+
UAVariable,
|
|
6
|
+
UAReferenceType,
|
|
7
|
+
UADataType,
|
|
8
|
+
UAObjectType,
|
|
9
|
+
UAVariableType,
|
|
10
|
+
UAMethod
|
|
11
|
+
} from "node-opcua-address-space";
|
|
12
|
+
import { ReferenceTypeIds } from "node-opcua-constants";
|
|
13
|
+
import { BrowseDirection, NodeClass } from "node-opcua-data-model";
|
|
14
|
+
|
|
15
|
+
function innerText(node: UAObject | UAVariable) {
|
|
16
|
+
const browseName = node.browseName.name;
|
|
17
|
+
const typeDefinition = node.typeDefinitionObj?.browseName?.name;
|
|
18
|
+
|
|
19
|
+
if (typeDefinition) {
|
|
20
|
+
return `[ label =< <FONT point-size="8" ><I>${typeDefinition}</I></FONT><BR/>${browseName} >]`;
|
|
21
|
+
} else {
|
|
22
|
+
return `[label =< ${browseName} >]`;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function arrowHeadAttribute(reference: UAReference): string {
|
|
26
|
+
switch (reference.referenceType.value) {
|
|
27
|
+
case ReferenceTypeIds.HasTypeDefinition:
|
|
28
|
+
return "normalnormal";
|
|
29
|
+
case ReferenceTypeIds.HasComponent:
|
|
30
|
+
return "noneteetree";
|
|
31
|
+
case ReferenceTypeIds.HasProperty:
|
|
32
|
+
return "nonetee";
|
|
33
|
+
case ReferenceTypeIds.HasSubtype:
|
|
34
|
+
return "onormalonormal";
|
|
35
|
+
case ReferenceTypeIds.HasModellingRule:
|
|
36
|
+
return "none";
|
|
37
|
+
default:
|
|
38
|
+
return "normal";
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function arrowHead(reference: UAReference): string {
|
|
42
|
+
return `[arrowhead = ${arrowHeadAttribute(reference)}]`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const regularShapes: Record<string, string> = {
|
|
46
|
+
ObjectType: '[shape=rectangle, style="filled" fillcolor="#e8edf7;0.75:#d2def0" gradientangle=275]',
|
|
47
|
+
VariableType: '[shape=rectangle, style="rounded,filled" fillcolor="#e8edf7;0.75:#d2def0" gradientangle=275]',
|
|
48
|
+
Object: ' [shape=rectangle, style="rounded,filled" fillcolor="#e8edf7"]',
|
|
49
|
+
Variable: '[shape=rectangle, style="filled,rounded" fillcolor="#e8edf7"]',
|
|
50
|
+
Method: '[shape=circle, style="filled" fillcolor="#e8edf7"]'
|
|
51
|
+
};
|
|
52
|
+
const regularShapesOptionals: Record<string, string> = {
|
|
53
|
+
ObjectType: '[shape=rectangle, style="filled,dashed" fillcolor="#e8edf7;0.75:#d2def0" gradientangle=275]',
|
|
54
|
+
VariableType: '[shape=rectangle, style="rounded,filled,dashed" fillcolor="#e8edf7;0.75:#d2def0" gradientangle=275]',
|
|
55
|
+
Object: ' [shape=rectangle, style="rounded,filled,dashed" fillcolor="#e8edf7"]',
|
|
56
|
+
Variable: '[shape=rectangle, style="filled,rounded,dashed" fillcolor="#e8edf7"]',
|
|
57
|
+
Method: '[shape=circle, style="filled,dashed" fillcolor="#e8edf7"]'
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
interface Options {
|
|
61
|
+
naked: boolean;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
class NodeRegistry {
|
|
65
|
+
m: Record<string, BaseNode[]> = {};
|
|
66
|
+
invisibleNodes: string[] = [];
|
|
67
|
+
add(node: BaseNode) {
|
|
68
|
+
const nodeClass = NodeClass[node.nodeClass];
|
|
69
|
+
this.m[nodeClass] = this.m[nodeClass] || [];
|
|
70
|
+
this.m[nodeClass].push(node);
|
|
71
|
+
}
|
|
72
|
+
addInvisibleNode(name: string) {
|
|
73
|
+
this.invisibleNodes.push(name);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function dumpNodeByNodeClass(str: string[], nodeRegistry: NodeRegistry) {
|
|
77
|
+
for (const [className, listNode] of Object.entries(nodeRegistry.m)) {
|
|
78
|
+
if (listNode.length === 0) {
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
str.push(` ## -> ${className}`);
|
|
82
|
+
|
|
83
|
+
const mandatoryNodes = listNode.filter((node) => !node.modellingRule || node.modellingRule.match(/Mandatory/));
|
|
84
|
+
const optionalNodes = listNode.filter((node) => node.modellingRule && node.modellingRule.match(/Optional/));
|
|
85
|
+
if (mandatoryNodes.length > 0) {
|
|
86
|
+
str.push(` node [];`);
|
|
87
|
+
const decoration = regularShapes[className] as string;
|
|
88
|
+
str.push(` node ${decoration};`);
|
|
89
|
+
for (const node of mandatoryNodes) {
|
|
90
|
+
str.push(` ${node.browseName.name} ${innerText(node as UAVariable | UAObject)}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (optionalNodes.length > 0) {
|
|
94
|
+
const decoration2 = regularShapesOptionals[className] as string;
|
|
95
|
+
str.push(` node [];`);
|
|
96
|
+
str.push(` node ${decoration2};`);
|
|
97
|
+
for (const node of listNode) {
|
|
98
|
+
str.push(` ${node.browseName.name} ${innerText(node as UAVariable | UAObject)}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (nodeRegistry.invisibleNodes.length) {
|
|
103
|
+
str.push(" # invisible nodes");
|
|
104
|
+
str.push(" node []");
|
|
105
|
+
str.push(" node [width=0,height=0,shape=point,style=invis];");
|
|
106
|
+
str.push(` ${nodeRegistry.invisibleNodes.join("\n ")};`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
export function opcuaToDot(node: UAObjectType | UAVariableType, options?: Options): string {
|
|
110
|
+
options = options || { naked: false };
|
|
111
|
+
const nodeRegistry = new NodeRegistry();
|
|
112
|
+
nodeRegistry.add(node);
|
|
113
|
+
|
|
114
|
+
const str: string[] = [];
|
|
115
|
+
const str2: string[] = [];
|
|
116
|
+
str.push("digraph G {");
|
|
117
|
+
if (!options.naked) {
|
|
118
|
+
str.push(" rankdir=TB;");
|
|
119
|
+
str.push(" nodesep=0.5;");
|
|
120
|
+
str.push(" node [];");
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// eslint-disable-next-line max-statements
|
|
124
|
+
function typeMemberAndSubTypeMember(
|
|
125
|
+
str: string[],
|
|
126
|
+
node: UAObjectType | UAVariableType | UAMethod | UAVariable | UAObject,
|
|
127
|
+
parent: UAObjectType | UAVariableType | UAMethod | UAVariable | UAObject | null,
|
|
128
|
+
offset: number,
|
|
129
|
+
prefix: string,
|
|
130
|
+
joinWithCaller: boolean
|
|
131
|
+
): [number, string[]] {
|
|
132
|
+
let innerDepth = 0;
|
|
133
|
+
const browseName = (parent || node).browseName.name!.toString();
|
|
134
|
+
const r: string[] = [];
|
|
135
|
+
const r2: string[] = [];
|
|
136
|
+
const references = node.findReferencesEx("Aggregates", BrowseDirection.Forward);
|
|
137
|
+
const folderElements = node.findReferencesEx("Organizes", BrowseDirection.Forward);
|
|
138
|
+
const childReferences = [...references, ...folderElements];
|
|
139
|
+
for (let i = 0; i < childReferences.length; i++) {
|
|
140
|
+
const isLast = i === childReferences.length - 1;
|
|
141
|
+
innerDepth++;
|
|
142
|
+
const reference = childReferences[i];
|
|
143
|
+
|
|
144
|
+
const childNode = reference.node! as UAVariable | UAObject | UAMethod;
|
|
145
|
+
const childName = childNode.browseName.name!.toString();
|
|
146
|
+
nodeRegistry.add(childNode);
|
|
147
|
+
const edgeAttributes = arrowHead(reference);
|
|
148
|
+
|
|
149
|
+
const breakNode = `${prefix}${i + offset}`;
|
|
150
|
+
r2.push(breakNode);
|
|
151
|
+
nodeRegistry.addInvisibleNode(breakNode);
|
|
152
|
+
const horizontalPart = `{ rank=same ${breakNode} -> ${childName} ${edgeAttributes} }`;
|
|
153
|
+
r.push(horizontalPart);
|
|
154
|
+
|
|
155
|
+
// push children on same level
|
|
156
|
+
const [depth] = typeMemberAndSubTypeMember(str, childNode, null, 0, `${prefix}${i + offset}_`, false);
|
|
157
|
+
for (let d = 0; d < depth; d++) {
|
|
158
|
+
offset++;
|
|
159
|
+
if (!isLast) {
|
|
160
|
+
const breakNode = `${prefix}${i + offset}`;
|
|
161
|
+
r2.push(breakNode);
|
|
162
|
+
nodeRegistry.addInvisibleNode(breakNode);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
innerDepth += depth;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (node.nodeClass == NodeClass.ObjectType || node.nodeClass === NodeClass.VariableType) {
|
|
169
|
+
if (node.subtypeOfObj && node.subtypeOfObj.nodeId.namespace === node.nodeId.namespace) {
|
|
170
|
+
const [depth, rr2] = typeMemberAndSubTypeMember(str, node.subtypeOfObj, node, r.length, prefix, true);
|
|
171
|
+
innerDepth += depth;
|
|
172
|
+
r2.push(...rr2);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (r.length) {
|
|
176
|
+
str.push(...r.map((x) => " " + x));
|
|
177
|
+
}
|
|
178
|
+
if (!joinWithCaller) {
|
|
179
|
+
if (r2.length) {
|
|
180
|
+
str.push(` ${browseName} -> ${r2.join(" -> ")} [arrowhead=none];`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return [innerDepth, r2];
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
typeMemberAndSubTypeMember(str2, node, null, 0, "r", false);
|
|
188
|
+
|
|
189
|
+
if (!options.naked) {
|
|
190
|
+
dumpNodeByNodeClass(str, nodeRegistry);
|
|
191
|
+
}
|
|
192
|
+
str.push(...str2);
|
|
193
|
+
str.push("}");
|
|
194
|
+
|
|
195
|
+
//
|
|
196
|
+
const dot = str.join("\n");
|
|
197
|
+
return dot;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export function dumpClassHierachry(
|
|
201
|
+
typeNode: UAObjectType | UAVariableType | UADataType | UAReferenceType,
|
|
202
|
+
options?: { naked?: boolean; depth?: number; showBaseType?: boolean; showSubType?: boolean }
|
|
203
|
+
) {
|
|
204
|
+
options = options || { naked: false, showBaseType: true, showSubType: true };
|
|
205
|
+
const level = options.depth || 50;
|
|
206
|
+
|
|
207
|
+
const str: string[] = [];
|
|
208
|
+
const nodeRegistry = new NodeRegistry();
|
|
209
|
+
nodeRegistry.add(typeNode);
|
|
210
|
+
str.push("digraph G {");
|
|
211
|
+
if (!options.naked) {
|
|
212
|
+
// str.push(" splines=ortho;");
|
|
213
|
+
str.push(" rankdir=BT;");
|
|
214
|
+
str.push(" nodesep=0.5;");
|
|
215
|
+
str.push(" node [];");
|
|
216
|
+
}
|
|
217
|
+
function dumpSubtypes(str: string[], typeNode: BaseNode, level: number) {
|
|
218
|
+
const parentName = typeNode.browseName.name!.toString();
|
|
219
|
+
const references = typeNode.findReferencesEx("HasSubtype", BrowseDirection.Forward);
|
|
220
|
+
for (let i = 0; i < references.length; i++) {
|
|
221
|
+
const reference = references[i];
|
|
222
|
+
const childNode = reference.node! as UAVariable | UAObject | UAMethod;
|
|
223
|
+
const nodeClass = NodeClass[childNode.nodeClass];
|
|
224
|
+
const childName = childNode.browseName.name!.toString();
|
|
225
|
+
nodeRegistry.add(typeNode);
|
|
226
|
+
const edgeAttributes = arrowHead(reference);
|
|
227
|
+
str.push(` ${childName} -> ${parentName} ${edgeAttributes};`);
|
|
228
|
+
|
|
229
|
+
if (level > 0) {
|
|
230
|
+
dumpSubtypes(str, childNode, level - 1);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
/** */
|
|
235
|
+
const str2: string[] = [];
|
|
236
|
+
if (options.showSubType) {
|
|
237
|
+
dumpSubtypes(str2, typeNode, level);
|
|
238
|
+
}
|
|
239
|
+
if (!options.naked) {
|
|
240
|
+
dumpNodeByNodeClass(str, nodeRegistry);
|
|
241
|
+
}
|
|
242
|
+
str.push(...str2);
|
|
243
|
+
str.push("}");
|
|
244
|
+
return str.join("\n");
|
|
245
|
+
}
|
|
246
|
+
function graphVizToPlantUml(str: string[]): string {
|
|
247
|
+
const ttt = "```";
|
|
248
|
+
return `${ttt}plantuml\n@startuml\n${str.join("\n")}\n@enduml\n${ttt}`;
|
|
249
|
+
}
|
|
250
|
+
export function dumpTypeDiagram(namespace: any) {
|
|
251
|
+
const objectTypes = [...namespace._objectTypeIterator()];
|
|
252
|
+
const variableTypes = [...namespace._variableTypeIterator()];
|
|
253
|
+
const dataTypes = [...namespace._dataTypeIterator()];
|
|
254
|
+
const referenceTypes = [...namespace._referenceTypeIterator()];
|
|
255
|
+
const addressSpace = namespace.addressSpace;
|
|
256
|
+
|
|
257
|
+
const str: string[] = [];
|
|
258
|
+
for (const type of [...objectTypes, ...variableTypes]) {
|
|
259
|
+
const d = opcuaToDot(type);
|
|
260
|
+
str.push(graphVizToPlantUml([d]));
|
|
261
|
+
|
|
262
|
+
const d2 = dumpClassHierachry(type);
|
|
263
|
+
str.push(graphVizToPlantUml([d2]));
|
|
264
|
+
}
|
|
265
|
+
for (const dataType of dataTypes) {
|
|
266
|
+
const d = opcuaToDot(dataType);
|
|
267
|
+
str.push(graphVizToPlantUml([d]));
|
|
268
|
+
}
|
|
269
|
+
return str.join("\n");
|
|
270
|
+
}
|
package/.mocharc.js
DELETED