node-opcua-modeler 2.96.0 → 2.98.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/addExtensionObjectDataType.d.ts +21 -21
- package/dist/addExtensionObjectDataType.js +132 -132
- package/dist/build_model_inner.d.ts +17 -17
- package/dist/build_model_inner.js +42 -42
- package/dist/displayNodeElement.d.ts +6 -6
- package/dist/displayNodeElement.js +220 -220
- package/dist/generate_markdown_doc.d.ts +41 -41
- package/dist/generate_markdown_doc.js +314 -314
- package/dist/index.d.ts +24 -24
- package/dist/index.js +52 -52
- package/dist/promoteToMandatory.d.ts +8 -8
- package/dist/promoteToMandatory.js +89 -89
- 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/types.d.ts +1 -1
- package/dist/types.js +2 -2
- package/distNodeJS/build_documentation_to_file.d.ts +3 -3
- 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 +23 -23
- package/distNodeJS/symbol_cvs.d.ts +3 -3
- package/distNodeJS/symbol_cvs.js +63 -63
- package/package.json +28 -21
- package/MyModelIds.csv +0 -151
- package/examples/make_model.ts +0 -153
- package/source_nodejs/build_documentation_to_file.ts +0 -13
- package/source_nodejs/build_model.ts +0 -12
- package/source_nodejs/index.ts +0 -5
- package/source_nodejs/symbol_cvs.ts +0 -50
- package/tsconfig_common.json +0 -66
- package/tsconfig_nodejs.json +0 -25
|
@@ -1,221 +1,221 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.displayNodeElement = void 0;
|
|
4
|
-
const node_opcua_address_space_1 = require("node-opcua-address-space");
|
|
5
|
-
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
6
|
-
const node_opcua_nodeid_1 = require("node-opcua-nodeid");
|
|
7
|
-
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
8
|
-
const tableHelper_1 = require("./tableHelper");
|
|
9
|
-
const a = "ⓂⓄⓋⓥⓇ❗⟵ ⟶⟷";
|
|
10
|
-
function symbol(nodeClass) {
|
|
11
|
-
switch (nodeClass) {
|
|
12
|
-
case node_opcua_data_model_1.NodeClass.DataType:
|
|
13
|
-
return "Ⓓ";
|
|
14
|
-
case node_opcua_data_model_1.NodeClass.ObjectType:
|
|
15
|
-
return "ⓄT";
|
|
16
|
-
case node_opcua_data_model_1.NodeClass.VariableType:
|
|
17
|
-
return "ⓋT";
|
|
18
|
-
case node_opcua_data_model_1.NodeClass.Method:
|
|
19
|
-
return "Ⓜ";
|
|
20
|
-
case node_opcua_data_model_1.NodeClass.Object:
|
|
21
|
-
return "Ⓞ";
|
|
22
|
-
case node_opcua_data_model_1.NodeClass.Variable:
|
|
23
|
-
return "Ⓥ";
|
|
24
|
-
case node_opcua_data_model_1.NodeClass.View:
|
|
25
|
-
return "⦖";
|
|
26
|
-
default:
|
|
27
|
-
return "?";
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
const hasSubtypeNodeId = (0, node_opcua_nodeid_1.resolveNodeId)("HasSubtype");
|
|
31
|
-
function encodeXML(s) {
|
|
32
|
-
return s.replace("&", "&").replace("<", "<").replace(">", ">");
|
|
33
|
-
}
|
|
34
|
-
function _dumpReferenceVariable(v, value, dataType) {
|
|
35
|
-
const val = v.readValue().value.value;
|
|
36
|
-
if (v.dataType.isEmpty()) {
|
|
37
|
-
return { value, dataType };
|
|
38
|
-
}
|
|
39
|
-
if (v.isExtensionObject()) {
|
|
40
|
-
// don't do anything
|
|
41
|
-
}
|
|
42
|
-
else if (v.isEnumeration() && val !== null) {
|
|
43
|
-
const enumValue = v.readEnumValue();
|
|
44
|
-
value = enumValue.value + " (" + enumValue.name + ")";
|
|
45
|
-
}
|
|
46
|
-
else if (val instanceof Date) {
|
|
47
|
-
value = val ? val.toUTCString() : "";
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
value = val ? val.toString() : "null";
|
|
51
|
-
}
|
|
52
|
-
const actualDataType = node_opcua_variant_1.DataType[v.readValue().value.dataType];
|
|
53
|
-
const basicDataType = node_opcua_variant_1.DataType[v.dataTypeObj.basicDataType];
|
|
54
|
-
dataType = v.dataTypeObj.browseName.toString();
|
|
55
|
-
if (basicDataType !== dataType) {
|
|
56
|
-
dataType = dataType + "(" + basicDataType + ")";
|
|
57
|
-
}
|
|
58
|
-
return { value, dataType };
|
|
59
|
-
}
|
|
60
|
-
function getTypeDefinitionAsText(node) {
|
|
61
|
-
if (node.nodeClass === node_opcua_data_model_1.NodeClass.Object || node.nodeClass === node_opcua_data_model_1.NodeClass.Variable)
|
|
62
|
-
return node.typeDefinitionObj.browseName.toString() || "";
|
|
63
|
-
return "";
|
|
64
|
-
}
|
|
65
|
-
// eslint-disable-next-line complexity
|
|
66
|
-
function dumpReference(data, ref, options) {
|
|
67
|
-
(0, node_opcua_address_space_1.resolveReferenceNode)(data.node.addressSpace, ref);
|
|
68
|
-
if (!ref.isForward) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
if (node_opcua_nodeid_1.NodeId.sameNodeId(ref.referenceType, hasSubtypeNodeId)) {
|
|
72
|
-
return; // ignore forward HasSubtype
|
|
73
|
-
}
|
|
74
|
-
// ignore subtype references
|
|
75
|
-
/* istanbul ignore next */
|
|
76
|
-
if (!ref.node) {
|
|
77
|
-
// tslint:disable-next-line: no-console
|
|
78
|
-
console.log(" Halt ", ref.toString({ addressSpace: data.node.addressSpace }));
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
const dir = ref.isForward ? " " : " ";
|
|
82
|
-
const refNode = ref.node;
|
|
83
|
-
const refType = (0, node_opcua_address_space_1.resolveReferenceType)(data.node.addressSpace, ref);
|
|
84
|
-
if (options && options.filter && refType.browseName.name !== options.filter) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
const key = ref.nodeId.toString() + ref.referenceType.toString();
|
|
88
|
-
if (data.alreadyDumped[key]) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
// xx const r = refNode.findReferencesAsObject("HasModellingRule", true);
|
|
92
|
-
const modelingRule = refNode.modellingRule || ""; // r[0] ? r[0].browseName.toString() : "/";
|
|
93
|
-
let value = "";
|
|
94
|
-
let dataType = "";
|
|
95
|
-
if (refNode.nodeClass === node_opcua_data_model_1.NodeClass.Variable) {
|
|
96
|
-
const v = refNode;
|
|
97
|
-
const t = _dumpReferenceVariable(v, value, dataType);
|
|
98
|
-
value = t.value;
|
|
99
|
-
dataType = t.dataType;
|
|
100
|
-
// findBasicDataType(v.dataTypeObj);
|
|
101
|
-
}
|
|
102
|
-
const prefix = options.prefix ? options.prefix + "." : "";
|
|
103
|
-
const row = [
|
|
104
|
-
"".padEnd(prefix.length) + refType.browseName.toString() + dir + symbol(refNode.nodeClass),
|
|
105
|
-
refNode.nodeId.toString(),
|
|
106
|
-
encodeXML(prefix + refNode.browseName.toString()),
|
|
107
|
-
modelingRule,
|
|
108
|
-
getTypeDefinitionAsText(refNode),
|
|
109
|
-
dataType,
|
|
110
|
-
value
|
|
111
|
-
];
|
|
112
|
-
data.table.push(row);
|
|
113
|
-
data.descriptions.push({
|
|
114
|
-
description: refNode.description ? refNode.description.text || "" : "",
|
|
115
|
-
name: refNode.browseName.name,
|
|
116
|
-
type: dataType
|
|
117
|
-
});
|
|
118
|
-
// now push all children if there are any
|
|
119
|
-
if (options.recursive) {
|
|
120
|
-
const subReferences = refNode.findReferencesEx("HasChild", node_opcua_data_model_1.BrowseDirection.Forward);
|
|
121
|
-
if (subReferences.length) {
|
|
122
|
-
// xx console.log("refNode ", refNode.nodeId.toString(), refNode.toString());
|
|
123
|
-
const rowMidHeader = [encodeXML(prefix + refNode.browseName.toString()), "", "", "", "", "", ""];
|
|
124
|
-
data.table.push(rowMidHeader);
|
|
125
|
-
for (const subReference of subReferences) {
|
|
126
|
-
dumpReference(data, subReference, Object.assign(Object.assign({}, options), { prefix: prefix + refNode.browseName.toString(), recursive: false, filter: undefined }));
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
data.alreadyDumped[key] = 1;
|
|
131
|
-
}
|
|
132
|
-
function dumpReferences(data, _references, options) {
|
|
133
|
-
// xx for (const ref of references) {
|
|
134
|
-
// xx dumpReference(ref, "HasSubtype");
|
|
135
|
-
// xx }
|
|
136
|
-
for (const ref of _references) {
|
|
137
|
-
dumpReference(data, ref, { filter: "HasTypeDefinition" });
|
|
138
|
-
}
|
|
139
|
-
for (const ref of _references) {
|
|
140
|
-
dumpReference(data, ref, { filter: "HasEncoding" });
|
|
141
|
-
}
|
|
142
|
-
for (const ref of _references) {
|
|
143
|
-
dumpReference(data, ref, Object.assign(Object.assign({}, options), { filter: "HasComponent" }));
|
|
144
|
-
}
|
|
145
|
-
for (const ref of _references) {
|
|
146
|
-
dumpReference(data, ref, Object.assign(Object.assign({}, options), { filter: "HasProperty" }));
|
|
147
|
-
}
|
|
148
|
-
for (const ref of _references) {
|
|
149
|
-
dumpReference(data, ref, Object.assign(Object.assign({}, options), { filter: "Organizes" }));
|
|
150
|
-
}
|
|
151
|
-
for (const ref of _references) {
|
|
152
|
-
dumpReference(data, ref, { filter: "HasInterface" });
|
|
153
|
-
}
|
|
154
|
-
for (const ref of _references) {
|
|
155
|
-
dumpReference(data, ref, {});
|
|
156
|
-
}
|
|
157
|
-
/// subElements = [];
|
|
158
|
-
}
|
|
159
|
-
function shortDescription(d) {
|
|
160
|
-
return d.split(/\.|\n/)[0];
|
|
161
|
-
}
|
|
162
|
-
function displayNodeElement(node, options) {
|
|
163
|
-
const recursive = options && options.recursive !== undefined ? !!options.recursive : true;
|
|
164
|
-
const head = ["ReferenceType", "NodeId", "BrowseName", "ModellingRule", "TypeDefinition", "DataType", "Value"];
|
|
165
|
-
function createTable() {
|
|
166
|
-
const table = new tableHelper_1.TableHelper(head);
|
|
167
|
-
table.push(["BrowseName: ", { colSpan: 6, content: node.browseName.toString() }]);
|
|
168
|
-
const superType = node.subtypeOfObj;
|
|
169
|
-
if (superType) {
|
|
170
|
-
table.push(["Base", superType.browseName.toString(), { colSpan: 6, content: node.browseName.toString() }]);
|
|
171
|
-
}
|
|
172
|
-
if (node.description) {
|
|
173
|
-
table.push(["Description", { colspan: 6, content: shortDescription(node.description.text || "") }]);
|
|
174
|
-
}
|
|
175
|
-
return table;
|
|
176
|
-
}
|
|
177
|
-
const table = createTable();
|
|
178
|
-
const alreadyDumped = {};
|
|
179
|
-
const descriptions = [];
|
|
180
|
-
const references = node.allReferences();
|
|
181
|
-
const data = { table, node, alreadyDumped, descriptions };
|
|
182
|
-
dumpReferences(data, references, { recursive });
|
|
183
|
-
function toText(table) {
|
|
184
|
-
if (options && options.format === "markdown") {
|
|
185
|
-
return table.toMarkdownTable();
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
return table.toString();
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
const str = [];
|
|
192
|
-
const tables = [];
|
|
193
|
-
tables.push(table);
|
|
194
|
-
if (node.description) {
|
|
195
|
-
str.push(node.description.text || "");
|
|
196
|
-
str.push("");
|
|
197
|
-
}
|
|
198
|
-
str.push(toText(table));
|
|
199
|
-
const str2 = [];
|
|
200
|
-
// add property from base object/variable type
|
|
201
|
-
if (node.nodeClass === node_opcua_data_model_1.NodeClass.ObjectType || node.nodeClass === node_opcua_data_model_1.NodeClass.VariableType) {
|
|
202
|
-
const curNode = node;
|
|
203
|
-
let subtypeOf = curNode.subtypeOfObj;
|
|
204
|
-
while (subtypeOf) {
|
|
205
|
-
data.table = createTable();
|
|
206
|
-
data.table.push([subtypeOf.browseName.toString() + ":", "--", "--", "--"]);
|
|
207
|
-
const references2 = subtypeOf.allReferences();
|
|
208
|
-
dumpReferences(data, references2, { recursive: false });
|
|
209
|
-
str.push("<details>");
|
|
210
|
-
str.push("<summary>Base type: " + subtypeOf.browseName.toString() + "</summary>");
|
|
211
|
-
str.push("");
|
|
212
|
-
str.push(toText(data.table));
|
|
213
|
-
str.push("");
|
|
214
|
-
str2.push("</details>");
|
|
215
|
-
subtypeOf = subtypeOf.subtypeOfObj;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
return str.join("\n") + str2.join("\n");
|
|
219
|
-
}
|
|
220
|
-
exports.displayNodeElement = displayNodeElement;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.displayNodeElement = void 0;
|
|
4
|
+
const node_opcua_address_space_1 = require("node-opcua-address-space");
|
|
5
|
+
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
6
|
+
const node_opcua_nodeid_1 = require("node-opcua-nodeid");
|
|
7
|
+
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
8
|
+
const tableHelper_1 = require("./tableHelper");
|
|
9
|
+
const a = "ⓂⓄⓋⓥⓇ❗⟵ ⟶⟷";
|
|
10
|
+
function symbol(nodeClass) {
|
|
11
|
+
switch (nodeClass) {
|
|
12
|
+
case node_opcua_data_model_1.NodeClass.DataType:
|
|
13
|
+
return "Ⓓ";
|
|
14
|
+
case node_opcua_data_model_1.NodeClass.ObjectType:
|
|
15
|
+
return "ⓄT";
|
|
16
|
+
case node_opcua_data_model_1.NodeClass.VariableType:
|
|
17
|
+
return "ⓋT";
|
|
18
|
+
case node_opcua_data_model_1.NodeClass.Method:
|
|
19
|
+
return "Ⓜ";
|
|
20
|
+
case node_opcua_data_model_1.NodeClass.Object:
|
|
21
|
+
return "Ⓞ";
|
|
22
|
+
case node_opcua_data_model_1.NodeClass.Variable:
|
|
23
|
+
return "Ⓥ";
|
|
24
|
+
case node_opcua_data_model_1.NodeClass.View:
|
|
25
|
+
return "⦖";
|
|
26
|
+
default:
|
|
27
|
+
return "?";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const hasSubtypeNodeId = (0, node_opcua_nodeid_1.resolveNodeId)("HasSubtype");
|
|
31
|
+
function encodeXML(s) {
|
|
32
|
+
return s.replace("&", "&").replace("<", "<").replace(">", ">");
|
|
33
|
+
}
|
|
34
|
+
function _dumpReferenceVariable(v, value, dataType) {
|
|
35
|
+
const val = v.readValue().value.value;
|
|
36
|
+
if (v.dataType.isEmpty()) {
|
|
37
|
+
return { value, dataType };
|
|
38
|
+
}
|
|
39
|
+
if (v.isExtensionObject()) {
|
|
40
|
+
// don't do anything
|
|
41
|
+
}
|
|
42
|
+
else if (v.isEnumeration() && val !== null) {
|
|
43
|
+
const enumValue = v.readEnumValue();
|
|
44
|
+
value = enumValue.value + " (" + enumValue.name + ")";
|
|
45
|
+
}
|
|
46
|
+
else if (val instanceof Date) {
|
|
47
|
+
value = val ? val.toUTCString() : "";
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
value = val ? val.toString() : "null";
|
|
51
|
+
}
|
|
52
|
+
const actualDataType = node_opcua_variant_1.DataType[v.readValue().value.dataType];
|
|
53
|
+
const basicDataType = node_opcua_variant_1.DataType[v.dataTypeObj.basicDataType];
|
|
54
|
+
dataType = v.dataTypeObj.browseName.toString();
|
|
55
|
+
if (basicDataType !== dataType) {
|
|
56
|
+
dataType = dataType + "(" + basicDataType + ")";
|
|
57
|
+
}
|
|
58
|
+
return { value, dataType };
|
|
59
|
+
}
|
|
60
|
+
function getTypeDefinitionAsText(node) {
|
|
61
|
+
if (node.nodeClass === node_opcua_data_model_1.NodeClass.Object || node.nodeClass === node_opcua_data_model_1.NodeClass.Variable)
|
|
62
|
+
return node.typeDefinitionObj.browseName.toString() || "";
|
|
63
|
+
return "";
|
|
64
|
+
}
|
|
65
|
+
// eslint-disable-next-line complexity
|
|
66
|
+
function dumpReference(data, ref, options) {
|
|
67
|
+
(0, node_opcua_address_space_1.resolveReferenceNode)(data.node.addressSpace, ref);
|
|
68
|
+
if (!ref.isForward) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (node_opcua_nodeid_1.NodeId.sameNodeId(ref.referenceType, hasSubtypeNodeId)) {
|
|
72
|
+
return; // ignore forward HasSubtype
|
|
73
|
+
}
|
|
74
|
+
// ignore subtype references
|
|
75
|
+
/* istanbul ignore next */
|
|
76
|
+
if (!ref.node) {
|
|
77
|
+
// tslint:disable-next-line: no-console
|
|
78
|
+
console.log(" Halt ", ref.toString({ addressSpace: data.node.addressSpace }));
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const dir = ref.isForward ? " " : " ";
|
|
82
|
+
const refNode = ref.node;
|
|
83
|
+
const refType = (0, node_opcua_address_space_1.resolveReferenceType)(data.node.addressSpace, ref);
|
|
84
|
+
if (options && options.filter && refType.browseName.name !== options.filter) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const key = ref.nodeId.toString() + ref.referenceType.toString();
|
|
88
|
+
if (data.alreadyDumped[key]) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
// xx const r = refNode.findReferencesAsObject("HasModellingRule", true);
|
|
92
|
+
const modelingRule = refNode.modellingRule || ""; // r[0] ? r[0].browseName.toString() : "/";
|
|
93
|
+
let value = "";
|
|
94
|
+
let dataType = "";
|
|
95
|
+
if (refNode.nodeClass === node_opcua_data_model_1.NodeClass.Variable) {
|
|
96
|
+
const v = refNode;
|
|
97
|
+
const t = _dumpReferenceVariable(v, value, dataType);
|
|
98
|
+
value = t.value;
|
|
99
|
+
dataType = t.dataType;
|
|
100
|
+
// findBasicDataType(v.dataTypeObj);
|
|
101
|
+
}
|
|
102
|
+
const prefix = options.prefix ? options.prefix + "." : "";
|
|
103
|
+
const row = [
|
|
104
|
+
"".padEnd(prefix.length) + refType.browseName.toString() + dir + symbol(refNode.nodeClass),
|
|
105
|
+
refNode.nodeId.toString(),
|
|
106
|
+
encodeXML(prefix + refNode.browseName.toString()),
|
|
107
|
+
modelingRule,
|
|
108
|
+
getTypeDefinitionAsText(refNode),
|
|
109
|
+
dataType,
|
|
110
|
+
value
|
|
111
|
+
];
|
|
112
|
+
data.table.push(row);
|
|
113
|
+
data.descriptions.push({
|
|
114
|
+
description: refNode.description ? refNode.description.text || "" : "",
|
|
115
|
+
name: refNode.browseName.name,
|
|
116
|
+
type: dataType
|
|
117
|
+
});
|
|
118
|
+
// now push all children if there are any
|
|
119
|
+
if (options.recursive) {
|
|
120
|
+
const subReferences = refNode.findReferencesEx("HasChild", node_opcua_data_model_1.BrowseDirection.Forward);
|
|
121
|
+
if (subReferences.length) {
|
|
122
|
+
// xx console.log("refNode ", refNode.nodeId.toString(), refNode.toString());
|
|
123
|
+
const rowMidHeader = [encodeXML(prefix + refNode.browseName.toString()), "", "", "", "", "", ""];
|
|
124
|
+
data.table.push(rowMidHeader);
|
|
125
|
+
for (const subReference of subReferences) {
|
|
126
|
+
dumpReference(data, subReference, Object.assign(Object.assign({}, options), { prefix: prefix + refNode.browseName.toString(), recursive: false, filter: undefined }));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
data.alreadyDumped[key] = 1;
|
|
131
|
+
}
|
|
132
|
+
function dumpReferences(data, _references, options) {
|
|
133
|
+
// xx for (const ref of references) {
|
|
134
|
+
// xx dumpReference(ref, "HasSubtype");
|
|
135
|
+
// xx }
|
|
136
|
+
for (const ref of _references) {
|
|
137
|
+
dumpReference(data, ref, { filter: "HasTypeDefinition" });
|
|
138
|
+
}
|
|
139
|
+
for (const ref of _references) {
|
|
140
|
+
dumpReference(data, ref, { filter: "HasEncoding" });
|
|
141
|
+
}
|
|
142
|
+
for (const ref of _references) {
|
|
143
|
+
dumpReference(data, ref, Object.assign(Object.assign({}, options), { filter: "HasComponent" }));
|
|
144
|
+
}
|
|
145
|
+
for (const ref of _references) {
|
|
146
|
+
dumpReference(data, ref, Object.assign(Object.assign({}, options), { filter: "HasProperty" }));
|
|
147
|
+
}
|
|
148
|
+
for (const ref of _references) {
|
|
149
|
+
dumpReference(data, ref, Object.assign(Object.assign({}, options), { filter: "Organizes" }));
|
|
150
|
+
}
|
|
151
|
+
for (const ref of _references) {
|
|
152
|
+
dumpReference(data, ref, { filter: "HasInterface" });
|
|
153
|
+
}
|
|
154
|
+
for (const ref of _references) {
|
|
155
|
+
dumpReference(data, ref, {});
|
|
156
|
+
}
|
|
157
|
+
/// subElements = [];
|
|
158
|
+
}
|
|
159
|
+
function shortDescription(d) {
|
|
160
|
+
return d.split(/\.|\n/)[0];
|
|
161
|
+
}
|
|
162
|
+
function displayNodeElement(node, options) {
|
|
163
|
+
const recursive = options && options.recursive !== undefined ? !!options.recursive : true;
|
|
164
|
+
const head = ["ReferenceType", "NodeId", "BrowseName", "ModellingRule", "TypeDefinition", "DataType", "Value"];
|
|
165
|
+
function createTable() {
|
|
166
|
+
const table = new tableHelper_1.TableHelper(head);
|
|
167
|
+
table.push(["BrowseName: ", { colSpan: 6, content: node.browseName.toString() }]);
|
|
168
|
+
const superType = node.subtypeOfObj;
|
|
169
|
+
if (superType) {
|
|
170
|
+
table.push(["Base", superType.browseName.toString(), { colSpan: 6, content: node.browseName.toString() }]);
|
|
171
|
+
}
|
|
172
|
+
if (node.description) {
|
|
173
|
+
table.push(["Description", { colspan: 6, content: shortDescription(node.description.text || "") }]);
|
|
174
|
+
}
|
|
175
|
+
return table;
|
|
176
|
+
}
|
|
177
|
+
const table = createTable();
|
|
178
|
+
const alreadyDumped = {};
|
|
179
|
+
const descriptions = [];
|
|
180
|
+
const references = node.allReferences();
|
|
181
|
+
const data = { table, node, alreadyDumped, descriptions };
|
|
182
|
+
dumpReferences(data, references, { recursive });
|
|
183
|
+
function toText(table) {
|
|
184
|
+
if (options && options.format === "markdown") {
|
|
185
|
+
return table.toMarkdownTable();
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
return table.toString();
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
const str = [];
|
|
192
|
+
const tables = [];
|
|
193
|
+
tables.push(table);
|
|
194
|
+
if (node.description) {
|
|
195
|
+
str.push(node.description.text || "");
|
|
196
|
+
str.push("");
|
|
197
|
+
}
|
|
198
|
+
str.push(toText(table));
|
|
199
|
+
const str2 = [];
|
|
200
|
+
// add property from base object/variable type
|
|
201
|
+
if (node.nodeClass === node_opcua_data_model_1.NodeClass.ObjectType || node.nodeClass === node_opcua_data_model_1.NodeClass.VariableType) {
|
|
202
|
+
const curNode = node;
|
|
203
|
+
let subtypeOf = curNode.subtypeOfObj;
|
|
204
|
+
while (subtypeOf) {
|
|
205
|
+
data.table = createTable();
|
|
206
|
+
data.table.push([subtypeOf.browseName.toString() + ":", "--", "--", "--"]);
|
|
207
|
+
const references2 = subtypeOf.allReferences();
|
|
208
|
+
dumpReferences(data, references2, { recursive: false });
|
|
209
|
+
str.push("<details>");
|
|
210
|
+
str.push("<summary>Base type: " + subtypeOf.browseName.toString() + "</summary>");
|
|
211
|
+
str.push("");
|
|
212
|
+
str.push(toText(data.table));
|
|
213
|
+
str.push("");
|
|
214
|
+
str2.push("</details>");
|
|
215
|
+
subtypeOf = subtypeOf.subtypeOfObj;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return str.join("\n") + str2.join("\n");
|
|
219
|
+
}
|
|
220
|
+
exports.displayNodeElement = displayNodeElement;
|
|
221
221
|
//# sourceMappingURL=displayNodeElement.js.map
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { BaseNode, INamespace, UADataType, UAObjectType, UAReferenceType, UAVariableType } from "node-opcua-address-space";
|
|
2
|
-
export interface IWriter {
|
|
3
|
-
writeLine(_str: string): void;
|
|
4
|
-
}
|
|
5
|
-
export declare class Writer implements IWriter {
|
|
6
|
-
private readonly stream;
|
|
7
|
-
constructor();
|
|
8
|
-
writeLine(str: string): void;
|
|
9
|
-
toString(): string;
|
|
10
|
-
}
|
|
11
|
-
export interface BuildDocumentationOptions {
|
|
12
|
-
node?: BaseNode;
|
|
13
|
-
dumpGraphics?: (writer: IWriter, type: UAObjectType | UAVariableType) => void;
|
|
14
|
-
}
|
|
15
|
-
export declare function buildDocumentationToString(namespace: INamespace, options?: BuildDocumentationOptions): Promise<string>;
|
|
16
|
-
export declare function extractTypes(namespace: INamespace, options?: BuildDocumentationOptions): {
|
|
17
|
-
dataTypes: UADataType[];
|
|
18
|
-
variableTypes: UAVariableType[];
|
|
19
|
-
objectTypes: UAObjectType[];
|
|
20
|
-
referenceTypes: UAReferenceType[];
|
|
21
|
-
dataTypeNode?: undefined;
|
|
22
|
-
} | {
|
|
23
|
-
dataTypes: UADataType[];
|
|
24
|
-
variableTypes: never[];
|
|
25
|
-
objectTypes: never[];
|
|
26
|
-
dataTypeNode: never[];
|
|
27
|
-
referenceTypes: never[];
|
|
28
|
-
} | {
|
|
29
|
-
dataTypes: never[];
|
|
30
|
-
variableTypes: never[];
|
|
31
|
-
objectTypes: UAObjectType[];
|
|
32
|
-
dataTypeNode: never[];
|
|
33
|
-
referenceTypes: never[];
|
|
34
|
-
} | {
|
|
35
|
-
dataTypes: never[];
|
|
36
|
-
variableTypes: UAVariableType[];
|
|
37
|
-
objectTypes: never[];
|
|
38
|
-
dataTypeNode: never[];
|
|
39
|
-
referenceTypes: never[];
|
|
40
|
-
};
|
|
41
|
-
export declare function buildDocumentation(namespace: INamespace, writer: IWriter, options?: BuildDocumentationOptions): Promise<void>;
|
|
1
|
+
import { BaseNode, INamespace, UADataType, UAObjectType, UAReferenceType, UAVariableType } from "node-opcua-address-space";
|
|
2
|
+
export interface IWriter {
|
|
3
|
+
writeLine(_str: string): void;
|
|
4
|
+
}
|
|
5
|
+
export declare class Writer implements IWriter {
|
|
6
|
+
private readonly stream;
|
|
7
|
+
constructor();
|
|
8
|
+
writeLine(str: string): void;
|
|
9
|
+
toString(): string;
|
|
10
|
+
}
|
|
11
|
+
export interface BuildDocumentationOptions {
|
|
12
|
+
node?: BaseNode;
|
|
13
|
+
dumpGraphics?: (writer: IWriter, type: UAObjectType | UAVariableType) => void;
|
|
14
|
+
}
|
|
15
|
+
export declare function buildDocumentationToString(namespace: INamespace, options?: BuildDocumentationOptions): Promise<string>;
|
|
16
|
+
export declare function extractTypes(namespace: INamespace, options?: BuildDocumentationOptions): {
|
|
17
|
+
dataTypes: UADataType[];
|
|
18
|
+
variableTypes: UAVariableType[];
|
|
19
|
+
objectTypes: UAObjectType[];
|
|
20
|
+
referenceTypes: UAReferenceType[];
|
|
21
|
+
dataTypeNode?: undefined;
|
|
22
|
+
} | {
|
|
23
|
+
dataTypes: UADataType[];
|
|
24
|
+
variableTypes: never[];
|
|
25
|
+
objectTypes: never[];
|
|
26
|
+
dataTypeNode: never[];
|
|
27
|
+
referenceTypes: never[];
|
|
28
|
+
} | {
|
|
29
|
+
dataTypes: never[];
|
|
30
|
+
variableTypes: never[];
|
|
31
|
+
objectTypes: UAObjectType[];
|
|
32
|
+
dataTypeNode: never[];
|
|
33
|
+
referenceTypes: never[];
|
|
34
|
+
} | {
|
|
35
|
+
dataTypes: never[];
|
|
36
|
+
variableTypes: UAVariableType[];
|
|
37
|
+
objectTypes: never[];
|
|
38
|
+
dataTypeNode: never[];
|
|
39
|
+
referenceTypes: never[];
|
|
40
|
+
};
|
|
41
|
+
export declare function buildDocumentation(namespace: INamespace, writer: IWriter, options?: BuildDocumentationOptions): Promise<void>;
|