node-opcua-modeler 2.67.1 → 2.69.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/displayNodeElement.d.ts +2 -1
- package/dist/displayNodeElement.js +60 -37
- package/dist/displayNodeElement.js.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/promoteToMandatory.d.ts +1 -1
- package/dist/promoteToMandatory.js +7 -15
- package/dist/promoteToMandatory.js.map +1 -1
- package/distNodeJS/index.js +5 -1
- package/distNodeJS/index.js.map +1 -1
- package/package.json +19 -18
- package/source/displayNodeElement.ts +82 -37
- package/source/promoteToMandatory.ts +10 -17
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BaseNode } from "node-opcua-address-space";
|
|
2
2
|
export interface DisplayNodeOptions {
|
|
3
|
-
format
|
|
3
|
+
format?: "cli" | "markdown";
|
|
4
|
+
recursive?: boolean;
|
|
4
5
|
}
|
|
5
6
|
export declare function displayNodeElement(node: BaseNode, options?: DisplayNodeOptions): string;
|
|
@@ -31,7 +31,34 @@ const hasSubtypeNodeId = (0, node_opcua_nodeid_1.resolveNodeId)("HasSubtype");
|
|
|
31
31
|
function encodeXML(s) {
|
|
32
32
|
return s.replace("&", "&").replace("<", "<").replace(">", ">");
|
|
33
33
|
}
|
|
34
|
-
function
|
|
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
|
+
// eslint-disable-next-line complexity
|
|
61
|
+
function dumpReference(data, ref, options) {
|
|
35
62
|
(0, node_opcua_address_space_1.resolveReferenceNode)(data.node.addressSpace, ref);
|
|
36
63
|
if (!ref.isForward) {
|
|
37
64
|
return;
|
|
@@ -49,10 +76,8 @@ function dumpReference(data, ref, filter) {
|
|
|
49
76
|
const dir = ref.isForward ? " " : " ";
|
|
50
77
|
const refNode = ref.node;
|
|
51
78
|
const refType = (0, node_opcua_address_space_1.resolveReferenceType)(data.node.addressSpace, ref);
|
|
52
|
-
if (filter) {
|
|
53
|
-
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
79
|
+
if (options && options.filter && refType.browseName.name !== options.filter) {
|
|
80
|
+
return;
|
|
56
81
|
}
|
|
57
82
|
const key = ref.nodeId.toString() + ref.referenceType.toString();
|
|
58
83
|
if (data.alreadyDumped[key]) {
|
|
@@ -64,32 +89,16 @@ function dumpReference(data, ref, filter) {
|
|
|
64
89
|
let dataType = "";
|
|
65
90
|
if (refNode.nodeClass === node_opcua_data_model_1.NodeClass.Variable) {
|
|
66
91
|
const v = refNode;
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
else if (v.isEnumeration() && val !== null) {
|
|
72
|
-
const enumValue = v.readEnumValue();
|
|
73
|
-
value = enumValue.value + " (" + enumValue.name + ")";
|
|
74
|
-
}
|
|
75
|
-
else if (val instanceof Date) {
|
|
76
|
-
value = val ? val.toUTCString() : "";
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
value = val ? val.toString() : "null";
|
|
80
|
-
}
|
|
81
|
-
const actualDataType = node_opcua_variant_1.DataType[v.readValue().value.dataType];
|
|
82
|
-
const basicDataType = node_opcua_variant_1.DataType[v.dataTypeObj.basicDataType];
|
|
83
|
-
dataType = v.dataTypeObj.browseName.toString();
|
|
84
|
-
if (basicDataType !== dataType) {
|
|
85
|
-
dataType = dataType + "(" + basicDataType + ")";
|
|
86
|
-
}
|
|
92
|
+
const t = _dumpReferenceVariable(v, value, dataType);
|
|
93
|
+
value = t.value;
|
|
94
|
+
dataType = t.dataType;
|
|
87
95
|
// findBasicDataType(v.dataTypeObj);
|
|
88
96
|
}
|
|
97
|
+
const prefix = options.prefix ? options.prefix + "." : "";
|
|
89
98
|
const row = [
|
|
90
|
-
refType.browseName.toString() + dir + symbol(refNode.nodeClass),
|
|
99
|
+
"".padEnd(prefix.length) + refType.browseName.toString() + dir + symbol(refNode.nodeClass),
|
|
91
100
|
refNode.nodeId.toString(),
|
|
92
|
-
encodeXML(refNode.browseName.toString()),
|
|
101
|
+
encodeXML(prefix + refNode.browseName.toString()),
|
|
93
102
|
modelingRule,
|
|
94
103
|
refNode.typeDefinitionObj ? refNode.typeDefinitionObj.browseName.toString() : "",
|
|
95
104
|
dataType,
|
|
@@ -101,38 +110,52 @@ function dumpReference(data, ref, filter) {
|
|
|
101
110
|
name: refNode.browseName.name,
|
|
102
111
|
type: dataType
|
|
103
112
|
});
|
|
113
|
+
// now push all children if there are any
|
|
114
|
+
if (options.recursive) {
|
|
115
|
+
const subReferences = refNode.findReferencesEx("HasChild", node_opcua_data_model_1.BrowseDirection.Forward);
|
|
116
|
+
if (subReferences.length) {
|
|
117
|
+
// xx console.log("refNode ", refNode.nodeId.toString(), refNode.toString());
|
|
118
|
+
const rowMidHeader = [encodeXML(prefix + refNode.browseName.toString()), "", "", "", "", "", ""];
|
|
119
|
+
data.table.push(rowMidHeader);
|
|
120
|
+
for (const subReference of subReferences) {
|
|
121
|
+
dumpReference(data, subReference, Object.assign(Object.assign({}, options), { prefix: prefix + refNode.browseName.toString(), recursive: false, filter: undefined }));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
104
125
|
data.alreadyDumped[key] = 1;
|
|
105
126
|
}
|
|
106
|
-
function dumpReferences(data, _references) {
|
|
127
|
+
function dumpReferences(data, _references, options) {
|
|
107
128
|
// xx for (const ref of references) {
|
|
108
129
|
// xx dumpReference(ref, "HasSubtype");
|
|
109
130
|
// xx }
|
|
110
131
|
for (const ref of _references) {
|
|
111
|
-
dumpReference(data, ref, "HasTypeDefinition");
|
|
132
|
+
dumpReference(data, ref, { filter: "HasTypeDefinition" });
|
|
112
133
|
}
|
|
113
134
|
for (const ref of _references) {
|
|
114
|
-
dumpReference(data, ref, "HasEncoding");
|
|
135
|
+
dumpReference(data, ref, { filter: "HasEncoding" });
|
|
115
136
|
}
|
|
116
137
|
for (const ref of _references) {
|
|
117
|
-
dumpReference(data, ref, "HasComponent");
|
|
138
|
+
dumpReference(data, ref, Object.assign(Object.assign({}, options), { filter: "HasComponent" }));
|
|
118
139
|
}
|
|
119
140
|
for (const ref of _references) {
|
|
120
|
-
dumpReference(data, ref, "HasProperty");
|
|
141
|
+
dumpReference(data, ref, Object.assign(Object.assign({}, options), { filter: "HasProperty" }));
|
|
121
142
|
}
|
|
122
143
|
for (const ref of _references) {
|
|
123
|
-
dumpReference(data, ref, "Organizes");
|
|
144
|
+
dumpReference(data, ref, Object.assign(Object.assign({}, options), { filter: "Organizes" }));
|
|
124
145
|
}
|
|
125
146
|
for (const ref of _references) {
|
|
126
|
-
dumpReference(data, ref, "HasInterface");
|
|
147
|
+
dumpReference(data, ref, { filter: "HasInterface" });
|
|
127
148
|
}
|
|
128
149
|
for (const ref of _references) {
|
|
129
|
-
dumpReference(data, ref,
|
|
150
|
+
dumpReference(data, ref, {});
|
|
130
151
|
}
|
|
152
|
+
/// subElements = [];
|
|
131
153
|
}
|
|
132
154
|
function shortDescription(d) {
|
|
133
155
|
return d.split(/\.|\n/)[0];
|
|
134
156
|
}
|
|
135
157
|
function displayNodeElement(node, options) {
|
|
158
|
+
const recursive = options && options.recursive !== undefined ? !!options.recursive : true;
|
|
136
159
|
const head = ["ReferenceType", "NodeId", "BrowseName", "ModellingRule", "TypeDefinition", "DataType", "Value"];
|
|
137
160
|
function createTable() {
|
|
138
161
|
const table = new tableHelper_1.TableHelper(head);
|
|
@@ -151,7 +174,7 @@ function displayNodeElement(node, options) {
|
|
|
151
174
|
const descriptions = [];
|
|
152
175
|
const references = node.allReferences();
|
|
153
176
|
const data = { table, node, alreadyDumped, descriptions };
|
|
154
|
-
dumpReferences(data, references);
|
|
177
|
+
dumpReferences(data, references, { recursive });
|
|
155
178
|
function toText(table) {
|
|
156
179
|
if (options && options.format === "markdown") {
|
|
157
180
|
return table.toMarkdownTable();
|
|
@@ -177,7 +200,7 @@ function displayNodeElement(node, options) {
|
|
|
177
200
|
data.table = createTable();
|
|
178
201
|
data.table.push([subtypeOf.browseName.toString() + ":", "--", "--", "--"]);
|
|
179
202
|
const references2 = subtypeOf.allReferences();
|
|
180
|
-
dumpReferences(data, references2);
|
|
203
|
+
dumpReferences(data, references2, { recursive: false });
|
|
181
204
|
str.push("<details>");
|
|
182
205
|
str.push("<summary>Base type: " + subtypeOf.browseName.toString() + "</summary>");
|
|
183
206
|
str.push("");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"displayNodeElement.js","sourceRoot":"","sources":["../source/displayNodeElement.ts"],"names":[],"mappings":";;;AAAA,uEAQkC;AAClC,
|
|
1
|
+
{"version":3,"file":"displayNodeElement.js","sourceRoot":"","sources":["../source/displayNodeElement.ts"],"names":[],"mappings":";;;AAAA,uEAQkC;AAClC,iEAAmE;AACnE,yDAA0D;AAE1D,2DAA8C;AAE9C,+CAA4C;AAE5C,MAAM,CAAC,GAAG,Y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IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,QAAQ,EAAE,GAAG,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;YAC3E,MAAM,WAAW,GAAG,SAAS,CAAC,aAAa,EAAE,CAAC;YAE9C,cAAc,CAAC,IAAI,EAAE,WAAW,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;YAExD,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACtB,GAAG,CAAC,IAAI,CAAC,sBAAsB,GAAG,SAAS,CAAC,UAAU,CAAC,QAAQ,EAAE,GAAG,YAAY,CAAC,CAAC;YAClF,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACb,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;YAC7B,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACb,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YAExB,SAAS,GAAI,SAA0B,CAAC,YAAY,CAAC;SACxD;KACJ;IACD,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5C,CAAC;AA3ED,gDA2EC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"
|
|
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,gDAA8B;AAE9B,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"}
|
|
@@ -5,4 +5,4 @@ export declare function getChildInTypeOrBaseType(node: UAObjectType | UAVariable
|
|
|
5
5
|
reference: UAReference;
|
|
6
6
|
};
|
|
7
7
|
export declare function promoteToMandatory(node: UAObjectType | UAVariableType, propertyName: string, namespaceIndex: number): UAConcrete;
|
|
8
|
-
export declare function promoteChild(node: UAObjectType | UAVariableType, propertyName: string, namespaceIndex: number, modellingRule
|
|
8
|
+
export declare function promoteChild(node: UAObjectType | UAVariableType, propertyName: string, namespaceIndex: number, modellingRule?: ModellingRuleType): UAConcrete;
|
|
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.promoteChild = exports.promoteToMandatory = exports.getChildInTypeOrBaseType = void 0;
|
|
4
4
|
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
5
5
|
const node_opcua_service_translate_browse_path_1 = require("node-opcua-service-translate-browse-path");
|
|
6
|
+
const node_opcua_debug_1 = require("node-opcua-debug");
|
|
6
7
|
const displayNodeElement_1 = require("./displayNodeElement");
|
|
8
|
+
const warningLog = (0, node_opcua_debug_1.make_warningLog)("promoteToMandatory");
|
|
7
9
|
// find the reference that links node1 to node2
|
|
8
10
|
function findReferenceToNode(node1, node2) {
|
|
9
11
|
const references = node1.allReferences();
|
|
@@ -60,21 +62,9 @@ function promoteToMandatory(node, propertyName, namespaceIndex) {
|
|
|
60
62
|
// check mandatory
|
|
61
63
|
/* istanbul ignore next */
|
|
62
64
|
if (propInSuperType.modellingRule === "Mandatory") {
|
|
63
|
-
|
|
64
|
-
console.log("Warning property " + propertyName + " is already Mandatory in super type");
|
|
65
|
-
return propInSuperType;
|
|
65
|
+
warningLog("property " + propertyName + " is already Mandatory in super type");
|
|
66
66
|
}
|
|
67
|
-
|
|
68
|
-
isForward: false,
|
|
69
|
-
nodeId: node.nodeId,
|
|
70
|
-
referenceType: reference.referenceType
|
|
71
|
-
};
|
|
72
|
-
const newProp = propInSuperType.clone({
|
|
73
|
-
namespace: node.namespace,
|
|
74
|
-
modellingRule: "Mandatory",
|
|
75
|
-
references: [newRef]
|
|
76
|
-
});
|
|
77
|
-
return newProp;
|
|
67
|
+
return promoteChild(node, propertyName, namespaceIndex, "Mandatory");
|
|
78
68
|
}
|
|
79
69
|
exports.promoteToMandatory = promoteToMandatory;
|
|
80
70
|
function promoteChild(node, propertyName, namespaceIndex, modellingRule) {
|
|
@@ -90,7 +80,9 @@ function promoteChild(node, propertyName, namespaceIndex, modellingRule) {
|
|
|
90
80
|
const newProp = propInSuperType.clone({
|
|
91
81
|
namespace: node.namespace,
|
|
92
82
|
modellingRule,
|
|
93
|
-
references: [Object.assign({}, newRef)]
|
|
83
|
+
references: [Object.assign({}, newRef)],
|
|
84
|
+
copyAlsoModellingRules: true,
|
|
85
|
+
ignoreChildren: false
|
|
94
86
|
});
|
|
95
87
|
return newProp;
|
|
96
88
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promoteToMandatory.js","sourceRoot":"","sources":["../source/promoteToMandatory.ts"],"names":[],"mappings":";;;AAYA,iEAAkD;AAClD,uGAA0E;
|
|
1
|
+
{"version":3,"file":"promoteToMandatory.js","sourceRoot":"","sources":["../source/promoteToMandatory.ts"],"names":[],"mappings":";;;AAYA,iEAAkD;AAClD,uGAA0E;AAC1E,uDAAmD;AAEnD,6DAA0D;AAE1D,MAAM,UAAU,GAAG,IAAA,kCAAe,EAAC,oBAAoB,CAAC,CAAC;AAMzD,+CAA+C;AAC/C,SAAS,mBAAmB,CAAC,KAAe,EAAE,KAAe;IACzD,MAAM,UAAU,GAAG,KAAK,CAAC,aAAa,EAAE,CAAC;IACzC,MAAM,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,SAAsB,EAAE,EAAE;QACnD,OAAO,SAAS,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;IACnE,CAAC,CAAC,CAAC;IACH,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC5B,0BAA0B;IAC1B,IAAI,CAAC,GAAG,EAAE;QACN,sBAAsB;QACtB,IACI,KAAK,CAAC,SAAS,KAAK,iCAAS,CAAC,UAAU;YACxC,KAAK,CAAC,SAAS,KAAK,iCAAS,CAAC,aAAa;YAC3C,KAAK,CAAC,SAAS,KAAK,iCAAS,CAAC,YAAY,EAC5C;YACE,MAAM,MAAM,GAAG,KAAe,CAAC;Y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KAAK,CAAC;QAClD,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,aAAa;QACb,UAAU,EAAE,mBAAM,MAAM,EAAG;QAC3B,sBAAsB,EAAE,IAAI;QAC5B,cAAc,EAAE,KAAK;KACxB,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACnB,CAAC;AA1BD,oCA0BC"}
|
package/distNodeJS/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/distNodeJS/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source_nodejs/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source_nodejs/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,gDAA8B;AAC9B,gEAA8C;AAC9C,qCAAmB;AACnB,0DAAsE;AAA7D,8GAAA,oBAAoB,OAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-opcua-modeler",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.69.0",
|
|
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,28 @@
|
|
|
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.
|
|
16
|
+
"cli-table3": "^0.6.2",
|
|
17
|
+
"csv-parse": "5.1.0",
|
|
18
|
+
"node-opcua-address-space": "2.69.0",
|
|
19
19
|
"node-opcua-assert": "2.66.0",
|
|
20
|
-
"node-opcua-basic-types": "2.
|
|
21
|
-
"node-opcua-client-dynamic-extension-object": "2.
|
|
20
|
+
"node-opcua-basic-types": "2.69.0",
|
|
21
|
+
"node-opcua-client-dynamic-extension-object": "2.69.0",
|
|
22
22
|
"node-opcua-constants": "2.67.0",
|
|
23
|
-
"node-opcua-data-model": "2.
|
|
24
|
-
"node-opcua-
|
|
25
|
-
"node-opcua-
|
|
23
|
+
"node-opcua-data-model": "2.69.0",
|
|
24
|
+
"node-opcua-debug": "2.69.0",
|
|
25
|
+
"node-opcua-factory": "2.69.0",
|
|
26
|
+
"node-opcua-nodeid": "2.69.0",
|
|
26
27
|
"node-opcua-nodesets": "2.66.0",
|
|
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.
|
|
28
|
+
"node-opcua-numeric-range": "2.69.0",
|
|
29
|
+
"node-opcua-schemas": "2.69.0",
|
|
30
|
+
"node-opcua-service-translate-browse-path": "2.69.0",
|
|
31
|
+
"node-opcua-status-code": "2.69.0",
|
|
32
|
+
"node-opcua-types": "2.69.0",
|
|
33
|
+
"node-opcua-variant": "2.69.0",
|
|
34
|
+
"node-opcua-xml2json": "2.69.0"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
|
-
"node-opcua-leak-detector": "2.
|
|
37
|
+
"node-opcua-leak-detector": "2.69.0",
|
|
37
38
|
"should": "^13.2.3"
|
|
38
39
|
},
|
|
39
40
|
"repository": {
|
|
@@ -49,5 +50,5 @@
|
|
|
49
50
|
"internet of things"
|
|
50
51
|
],
|
|
51
52
|
"homepage": "http://node-opcua.github.io/",
|
|
52
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "6c88d05e8c82ce4bc9c8af9f0a8eb6136f31d2ce"
|
|
53
54
|
}
|
|
@@ -7,9 +7,11 @@ import {
|
|
|
7
7
|
resolveReferenceType,
|
|
8
8
|
UAVariableType
|
|
9
9
|
} from "node-opcua-address-space";
|
|
10
|
-
import { NodeClass } from "node-opcua-data-model";
|
|
10
|
+
import { BrowseDirection, NodeClass } from "node-opcua-data-model";
|
|
11
11
|
import { NodeId, resolveNodeId } from "node-opcua-nodeid";
|
|
12
|
+
import { UserNameIdentityToken } from "node-opcua-types";
|
|
12
13
|
import { DataType } from "node-opcua-variant";
|
|
14
|
+
import { option } from "yargs";
|
|
13
15
|
import { TableHelper } from "./tableHelper";
|
|
14
16
|
|
|
15
17
|
const a = "ⓂⓄⓋⓥⓇ❗⟵ ⟶⟷";
|
|
@@ -36,7 +38,8 @@ function symbol(nodeClass: NodeClass) {
|
|
|
36
38
|
const hasSubtypeNodeId = resolveNodeId("HasSubtype");
|
|
37
39
|
|
|
38
40
|
export interface DisplayNodeOptions {
|
|
39
|
-
format
|
|
41
|
+
format?: "cli" | "markdown";
|
|
42
|
+
recursive?: boolean; // default true
|
|
40
43
|
}
|
|
41
44
|
function encodeXML(s: string) {
|
|
42
45
|
return s.replace("&", "&").replace("<", "<").replace(">", ">");
|
|
@@ -46,13 +49,46 @@ interface Data {
|
|
|
46
49
|
node: BaseNode;
|
|
47
50
|
alreadyDumped: Record<string, any>;
|
|
48
51
|
descriptions: Description[];
|
|
52
|
+
subElements?: any[];
|
|
49
53
|
}
|
|
50
54
|
interface Description {
|
|
51
55
|
description: string;
|
|
52
56
|
name: string;
|
|
53
57
|
type: string;
|
|
54
58
|
}
|
|
55
|
-
|
|
59
|
+
|
|
60
|
+
interface DumpReferenceOptions {
|
|
61
|
+
recursive?: boolean;
|
|
62
|
+
filter?: string;
|
|
63
|
+
prefix?: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function _dumpReferenceVariable(v: UAVariable, value: any, dataType: string): { value: any; dataType: string } {
|
|
67
|
+
const val = v.readValue().value.value;
|
|
68
|
+
if (v.dataType.isEmpty()) {
|
|
69
|
+
return { value, dataType };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (v.isExtensionObject()) {
|
|
73
|
+
// don't do anything
|
|
74
|
+
} else if (v.isEnumeration() && val !== null) {
|
|
75
|
+
const enumValue = v.readEnumValue();
|
|
76
|
+
value = enumValue.value + " (" + enumValue.name + ")";
|
|
77
|
+
} else if (val instanceof Date) {
|
|
78
|
+
value = val ? val.toUTCString() : "";
|
|
79
|
+
} else {
|
|
80
|
+
value = val ? val.toString() : "null";
|
|
81
|
+
}
|
|
82
|
+
const actualDataType = DataType[v.readValue().value.dataType];
|
|
83
|
+
const basicDataType = DataType[v.dataTypeObj.basicDataType];
|
|
84
|
+
dataType = v.dataTypeObj.browseName.toString();
|
|
85
|
+
if (basicDataType !== dataType) {
|
|
86
|
+
dataType = dataType + "(" + basicDataType + ")";
|
|
87
|
+
}
|
|
88
|
+
return { value, dataType };
|
|
89
|
+
}
|
|
90
|
+
// eslint-disable-next-line complexity
|
|
91
|
+
function dumpReference(data: Data, ref: UAReference, options: DumpReferenceOptions) {
|
|
56
92
|
resolveReferenceNode(data.node.addressSpace, ref);
|
|
57
93
|
if (!ref.isForward) {
|
|
58
94
|
return;
|
|
@@ -71,10 +107,8 @@ function dumpReference(data: Data, ref: UAReference, filter?: string) {
|
|
|
71
107
|
const refNode = ref.node!;
|
|
72
108
|
|
|
73
109
|
const refType = resolveReferenceType(data.node.addressSpace, ref);
|
|
74
|
-
if (filter) {
|
|
75
|
-
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
110
|
+
if (options && options.filter && refType.browseName.name !== options.filter) {
|
|
111
|
+
return;
|
|
78
112
|
}
|
|
79
113
|
const key = ref.nodeId.toString() + ref.referenceType.toString();
|
|
80
114
|
if (data.alreadyDumped[key]) {
|
|
@@ -87,31 +121,17 @@ function dumpReference(data: Data, ref: UAReference, filter?: string) {
|
|
|
87
121
|
let dataType = "";
|
|
88
122
|
if (refNode.nodeClass === NodeClass.Variable) {
|
|
89
123
|
const v = refNode as UAVariable;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
// don't do anything
|
|
94
|
-
} else if (v.isEnumeration() && val !== null) {
|
|
95
|
-
const enumValue = v.readEnumValue();
|
|
96
|
-
value = enumValue.value + " (" + enumValue.name + ")";
|
|
97
|
-
} else if (val instanceof Date) {
|
|
98
|
-
value = val ? val.toUTCString() : "";
|
|
99
|
-
} else {
|
|
100
|
-
value = val ? val.toString() : "null";
|
|
101
|
-
}
|
|
102
|
-
const actualDataType = DataType[v.readValue().value.dataType];
|
|
103
|
-
const basicDataType = DataType[v.dataTypeObj.basicDataType];
|
|
104
|
-
dataType = v.dataTypeObj.browseName.toString();
|
|
105
|
-
if (basicDataType !== dataType) {
|
|
106
|
-
dataType = dataType + "(" + basicDataType + ")";
|
|
107
|
-
}
|
|
124
|
+
const t = _dumpReferenceVariable(v, value, dataType);
|
|
125
|
+
value = t.value;
|
|
126
|
+
dataType = t.dataType;
|
|
108
127
|
// findBasicDataType(v.dataTypeObj);
|
|
109
128
|
}
|
|
110
129
|
|
|
130
|
+
const prefix = options.prefix ? options.prefix + "." : "";
|
|
111
131
|
const row = [
|
|
112
|
-
refType.browseName.toString() + dir + symbol(refNode.nodeClass),
|
|
132
|
+
"".padEnd(prefix.length) + refType.browseName.toString() + dir + symbol(refNode.nodeClass),
|
|
113
133
|
refNode.nodeId.toString(),
|
|
114
|
-
encodeXML(refNode.browseName.toString()),
|
|
134
|
+
encodeXML(prefix + refNode.browseName.toString()),
|
|
115
135
|
modelingRule,
|
|
116
136
|
(refNode as any).typeDefinitionObj ? (refNode as any).typeDefinitionObj.browseName.toString() : "",
|
|
117
137
|
dataType,
|
|
@@ -125,39 +145,62 @@ function dumpReference(data: Data, ref: UAReference, filter?: string) {
|
|
|
125
145
|
name: refNode.browseName.name!,
|
|
126
146
|
type: dataType
|
|
127
147
|
});
|
|
148
|
+
|
|
149
|
+
// now push all children if there are any
|
|
150
|
+
if (options.recursive) {
|
|
151
|
+
const subReferences = refNode.findReferencesEx("HasChild", BrowseDirection.Forward);
|
|
152
|
+
if (subReferences.length) {
|
|
153
|
+
// xx console.log("refNode ", refNode.nodeId.toString(), refNode.toString());
|
|
154
|
+
|
|
155
|
+
const rowMidHeader = [encodeXML(prefix + refNode.browseName.toString()), "", "", "", "", "", ""];
|
|
156
|
+
data.table.push(rowMidHeader);
|
|
157
|
+
for (const subReference of subReferences) {
|
|
158
|
+
dumpReference(data, subReference, {
|
|
159
|
+
...options,
|
|
160
|
+
prefix: prefix + refNode.browseName.toString(),
|
|
161
|
+
recursive: false,
|
|
162
|
+
filter: undefined
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
128
167
|
data.alreadyDumped[key] = 1;
|
|
129
168
|
}
|
|
130
|
-
|
|
169
|
+
|
|
170
|
+
function dumpReferences(data: Data, _references: UAReference[], options: DumpReferenceOptions) {
|
|
131
171
|
// xx for (const ref of references) {
|
|
132
172
|
// xx dumpReference(ref, "HasSubtype");
|
|
133
173
|
// xx }
|
|
134
174
|
for (const ref of _references) {
|
|
135
|
-
dumpReference(data, ref, "HasTypeDefinition");
|
|
175
|
+
dumpReference(data, ref, { filter: "HasTypeDefinition" });
|
|
136
176
|
}
|
|
137
177
|
for (const ref of _references) {
|
|
138
|
-
dumpReference(data, ref, "HasEncoding");
|
|
178
|
+
dumpReference(data, ref, { filter: "HasEncoding" });
|
|
139
179
|
}
|
|
140
180
|
for (const ref of _references) {
|
|
141
|
-
dumpReference(data, ref, "HasComponent");
|
|
181
|
+
dumpReference(data, ref, { ...options, filter: "HasComponent" });
|
|
142
182
|
}
|
|
143
183
|
for (const ref of _references) {
|
|
144
|
-
dumpReference(data, ref, "HasProperty");
|
|
184
|
+
dumpReference(data, ref, { ...options, filter: "HasProperty" });
|
|
145
185
|
}
|
|
146
186
|
for (const ref of _references) {
|
|
147
|
-
dumpReference(data, ref, "Organizes");
|
|
187
|
+
dumpReference(data, ref, { ...options, filter: "Organizes" });
|
|
148
188
|
}
|
|
149
189
|
for (const ref of _references) {
|
|
150
|
-
dumpReference(data, ref, "HasInterface");
|
|
190
|
+
dumpReference(data, ref, { filter: "HasInterface" });
|
|
151
191
|
}
|
|
152
192
|
for (const ref of _references) {
|
|
153
|
-
dumpReference(data, ref,
|
|
193
|
+
dumpReference(data, ref, {});
|
|
154
194
|
}
|
|
195
|
+
/// subElements = [];
|
|
155
196
|
}
|
|
156
197
|
|
|
157
198
|
function shortDescription(d: string) {
|
|
158
199
|
return d.split(/\.|\n/)[0];
|
|
159
200
|
}
|
|
160
201
|
export function displayNodeElement(node: BaseNode, options?: DisplayNodeOptions): string {
|
|
202
|
+
const recursive = options && options.recursive !== undefined ? !!options.recursive : true;
|
|
203
|
+
|
|
161
204
|
const head: string[] = ["ReferenceType", "NodeId", "BrowseName", "ModellingRule", "TypeDefinition", "DataType", "Value"];
|
|
162
205
|
|
|
163
206
|
function createTable() {
|
|
@@ -184,7 +227,8 @@ export function displayNodeElement(node: BaseNode, options?: DisplayNodeOptions)
|
|
|
184
227
|
const references = node.allReferences();
|
|
185
228
|
|
|
186
229
|
const data = { table, node, alreadyDumped, descriptions };
|
|
187
|
-
|
|
230
|
+
|
|
231
|
+
dumpReferences(data, references, { recursive });
|
|
188
232
|
|
|
189
233
|
function toText(table: TableHelper) {
|
|
190
234
|
if (options && options.format === "markdown") {
|
|
@@ -215,7 +259,8 @@ export function displayNodeElement(node: BaseNode, options?: DisplayNodeOptions)
|
|
|
215
259
|
data.table = createTable();
|
|
216
260
|
data.table.push([subtypeOf.browseName.toString() + ":", "--", "--", "--"]);
|
|
217
261
|
const references2 = subtypeOf.allReferences();
|
|
218
|
-
|
|
262
|
+
|
|
263
|
+
dumpReferences(data, references2, { recursive: false });
|
|
219
264
|
|
|
220
265
|
str.push("<details>");
|
|
221
266
|
str.push("<summary>Base type: " + subtypeOf.browseName.toString() + "</summary>");
|
|
@@ -8,13 +8,16 @@ import {
|
|
|
8
8
|
UAReferenceType,
|
|
9
9
|
UAVariable,
|
|
10
10
|
UAVariableType,
|
|
11
|
-
ModellingRuleType
|
|
11
|
+
ModellingRuleType
|
|
12
12
|
} from "node-opcua-address-space";
|
|
13
13
|
import { NodeClass } from "node-opcua-data-model";
|
|
14
14
|
import { makeBrowsePath } from "node-opcua-service-translate-browse-path";
|
|
15
|
+
import { make_warningLog } from "node-opcua-debug";
|
|
15
16
|
|
|
16
17
|
import { displayNodeElement } from "./displayNodeElement";
|
|
17
18
|
|
|
19
|
+
const warningLog = make_warningLog("promoteToMandatory");
|
|
20
|
+
|
|
18
21
|
type UAType = UAObjectType | UAVariableType | UAReferenceType | UADataType;
|
|
19
22
|
|
|
20
23
|
export type UAConcrete = UAVariable | UAObject | UAMethod;
|
|
@@ -91,30 +94,18 @@ export function promoteToMandatory(node: UAObjectType | UAVariableType, property
|
|
|
91
94
|
// check mandatory
|
|
92
95
|
/* istanbul ignore next */
|
|
93
96
|
if (propInSuperType.modellingRule === "Mandatory") {
|
|
94
|
-
|
|
95
|
-
console.log("Warning property " + propertyName + " is already Mandatory in super type");
|
|
96
|
-
return propInSuperType;
|
|
97
|
+
warningLog("property " + propertyName + " is already Mandatory in super type");
|
|
97
98
|
}
|
|
98
99
|
|
|
99
|
-
|
|
100
|
-
isForward: false,
|
|
101
|
-
nodeId: node.nodeId,
|
|
102
|
-
referenceType: reference.referenceType
|
|
103
|
-
};
|
|
100
|
+
return promoteChild(node, propertyName, namespaceIndex, "Mandatory");
|
|
104
101
|
|
|
105
|
-
const newProp = (propInSuperType as UAConcrete).clone({
|
|
106
|
-
namespace: node.namespace,
|
|
107
|
-
modellingRule: "Mandatory",
|
|
108
|
-
references: [newRef]
|
|
109
|
-
});
|
|
110
|
-
return newProp;
|
|
111
102
|
}
|
|
112
103
|
|
|
113
104
|
export function promoteChild(
|
|
114
105
|
node: UAObjectType | UAVariableType,
|
|
115
106
|
propertyName: string,
|
|
116
107
|
namespaceIndex: number,
|
|
117
|
-
modellingRule
|
|
108
|
+
modellingRule?: ModellingRuleType
|
|
118
109
|
): UAConcrete {
|
|
119
110
|
const { propInSuperType, reference } = getChildInTypeOrBaseType(node, propertyName, namespaceIndex);
|
|
120
111
|
|
|
@@ -131,7 +122,9 @@ export function promoteChild(
|
|
|
131
122
|
const newProp = (propInSuperType as UAConcrete).clone({
|
|
132
123
|
namespace: node.namespace,
|
|
133
124
|
modellingRule,
|
|
134
|
-
references: [{...newRef}]
|
|
125
|
+
references: [{ ...newRef }],
|
|
126
|
+
copyAlsoModellingRules: true,
|
|
127
|
+
ignoreChildren: false
|
|
135
128
|
});
|
|
136
129
|
return newProp;
|
|
137
130
|
}
|