@vitormnm/node-red-simple-opcua 1.2.0 → 1.2.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/package.json
CHANGED
|
@@ -40,7 +40,7 @@ class OpcUaAddressSpaceBuilder {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
rebuild(treeConfig) {
|
|
43
|
-
|
|
43
|
+
|
|
44
44
|
this.sync(treeConfig, { fullReset: true });
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -52,7 +52,7 @@ class OpcUaAddressSpaceBuilder {
|
|
|
52
52
|
const settings = options || {};
|
|
53
53
|
const desiredEntries = this.collectDesiredEntries(treeConfig);
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
|
|
57
57
|
if (settings.fullReset) {
|
|
58
58
|
this.clearDynamicNodes();
|
|
@@ -282,11 +282,11 @@ class OpcUaAddressSpaceBuilder {
|
|
|
282
282
|
// create duplicate nodes on top of the ones the lib already created.
|
|
283
283
|
// Only extra children defined directly on the instance (not inherited) are added here.
|
|
284
284
|
const instanceOnlyConfig = {
|
|
285
|
-
folders:
|
|
286
|
-
objects:
|
|
287
|
-
variables:
|
|
288
|
-
methods:
|
|
289
|
-
alarms:
|
|
285
|
+
folders: Array.isArray(instanceConfig.folders) ? instanceConfig.folders : [],
|
|
286
|
+
objects: Array.isArray(instanceConfig.objects) ? instanceConfig.objects : [],
|
|
287
|
+
variables: Array.isArray(instanceConfig.variables) ? instanceConfig.variables : [],
|
|
288
|
+
methods: Array.isArray(instanceConfig.methods) ? instanceConfig.methods : [],
|
|
289
|
+
alarms: Array.isArray(instanceConfig.alarms) ? instanceConfig.alarms : [],
|
|
290
290
|
objectsTypes: Array.isArray(instanceConfig.objectsTypes) ? instanceConfig.objectsTypes : []
|
|
291
291
|
};
|
|
292
292
|
this.collectBranchChildren(desiredEntries, instanceOnlyConfig, path, "componentOf", objectTypeConfigs, Object.assign({}, options, {
|
|
@@ -514,7 +514,7 @@ class OpcUaAddressSpaceBuilder {
|
|
|
514
514
|
createNode(definition) {
|
|
515
515
|
const parentNode = this.resolveParentNode(definition.parentPath);
|
|
516
516
|
|
|
517
|
-
|
|
517
|
+
|
|
518
518
|
|
|
519
519
|
if (definition.kind === "folder") {
|
|
520
520
|
this.addFolder(parentNode, definition.config, definition.parentPath, definition.relationship, definition.path);
|
|
@@ -706,10 +706,10 @@ class OpcUaAddressSpaceBuilder {
|
|
|
706
706
|
// Extract the type's nodeId value prefix (e.g. "Motor_type2") and the
|
|
707
707
|
// instance's nodeId value prefix (e.g. "server1.newObjectType") so we can
|
|
708
708
|
// rewrite every child nodeId from the type to the instance on-the-fly.
|
|
709
|
-
const typeNodeId
|
|
710
|
-
const instanceNodeId
|
|
711
|
-
const typePrefix
|
|
712
|
-
const instancePrefix
|
|
709
|
+
const typeNodeId = typeEntry.config.nodeId || "";
|
|
710
|
+
const instanceNodeId = instanceConfig.nodeId || "";
|
|
711
|
+
const typePrefix = this.extractNodeIdStringValue(typeNodeId);
|
|
712
|
+
const instancePrefix = this.extractNodeIdStringValue(instanceNodeId);
|
|
713
713
|
|
|
714
714
|
this.createInheritedBranchChildren(typeEntry.config, instanceNode, instancePath, typePrefix, instancePrefix);
|
|
715
715
|
}
|
|
@@ -730,9 +730,9 @@ class OpcUaAddressSpaceBuilder {
|
|
|
730
730
|
|
|
731
731
|
createInheritedBranchChildren(typeConfig, parentOpcNode, parentPath, typePrefix, instancePrefix) {
|
|
732
732
|
const variables = Array.isArray(typeConfig.variables) ? typeConfig.variables : [];
|
|
733
|
-
const methods
|
|
734
|
-
const folders
|
|
735
|
-
const objects
|
|
733
|
+
const methods = Array.isArray(typeConfig.methods) ? typeConfig.methods : [];
|
|
734
|
+
const folders = Array.isArray(typeConfig.folders) ? typeConfig.folders : [];
|
|
735
|
+
const objects = Array.isArray(typeConfig.objects) ? typeConfig.objects : [];
|
|
736
736
|
|
|
737
737
|
variables.forEach((varConfig) => {
|
|
738
738
|
const childPath = this.buildPath(parentPath, varConfig.name);
|
|
@@ -775,7 +775,7 @@ class OpcUaAddressSpaceBuilder {
|
|
|
775
775
|
});
|
|
776
776
|
}
|
|
777
777
|
|
|
778
|
-
|
|
778
|
+
addAlarm(parentNode, alarmConfig, parentPath, relationship, pathOverride) {
|
|
779
779
|
|
|
780
780
|
|
|
781
781
|
|
|
@@ -1031,11 +1031,12 @@ class OpcUaAddressSpaceBuilder {
|
|
|
1031
1031
|
const namespace = this.getNamespaceForConfig(methodConfig);
|
|
1032
1032
|
const methodName = methodConfig.name;
|
|
1033
1033
|
const path = pathOverride || this.buildPath(parentPath, methodName);
|
|
1034
|
+
const nodeId = this.resolveNodeId(methodConfig, path, namespace)
|
|
1034
1035
|
const methodNode = namespace.addMethod(parentNode, {
|
|
1035
1036
|
browseName: methodConfig.displayName || methodName,
|
|
1036
1037
|
displayName: methodConfig.displayName || methodName,
|
|
1037
1038
|
description: { text: methodConfig.description || "" },
|
|
1038
|
-
nodeId:
|
|
1039
|
+
nodeId: nodeId,
|
|
1039
1040
|
modellingRule: this.isObjectTypePath(parentPath) ? "Mandatory" : undefined,
|
|
1040
1041
|
inputArguments: methodConfig.inputs.map((arg) => ({
|
|
1041
1042
|
name: arg.name,
|
|
@@ -1054,8 +1055,14 @@ class OpcUaAddressSpaceBuilder {
|
|
|
1054
1055
|
|
|
1055
1056
|
this.registry.emitMethodCall({
|
|
1056
1057
|
methodName: methodConfig.name,
|
|
1058
|
+
nodeId: nodeId,
|
|
1057
1059
|
callId,
|
|
1058
1060
|
inputArguments,
|
|
1061
|
+
outputArguments: methodConfig.outputs.map((arg) => ({
|
|
1062
|
+
name: arg.name,
|
|
1063
|
+
description: { text: arg.description || "" },
|
|
1064
|
+
dataType: DATA_TYPE_MAP[arg.type]
|
|
1065
|
+
})),
|
|
1059
1066
|
serverName: this.serverName
|
|
1060
1067
|
});
|
|
1061
1068
|
|
|
@@ -6,7 +6,7 @@ module.exports = function (RED) {
|
|
|
6
6
|
RED.httpAdmin.get("/opcua-server-io/servers", RED.auth.needsPermission("flows.read"), function (req, res) {
|
|
7
7
|
try {
|
|
8
8
|
res.json(registry.listActiveServers());
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
} catch (error) {
|
|
11
11
|
res.status(500).json({ error: error.message });
|
|
12
12
|
}
|
|
@@ -65,7 +65,7 @@ module.exports = function (RED) {
|
|
|
65
65
|
await handleEvent(node, msg, send);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
if (node.mode === "activeAlarms") {
|
|
69
69
|
await handleActiveAlarms(node, msg, send);
|
|
70
70
|
}
|
|
71
71
|
|
|
@@ -132,10 +132,12 @@ module.exports = function (RED) {
|
|
|
132
132
|
});
|
|
133
133
|
|
|
134
134
|
node.send({
|
|
135
|
+
topic : msg.data.nodeId,
|
|
135
136
|
payload: msg.data.inputArguments,
|
|
136
137
|
opcua: {
|
|
137
138
|
server: msg.data.serverName,
|
|
138
|
-
method: msg.data.methodName
|
|
139
|
+
method: msg.data.methodName,
|
|
140
|
+
data: msg.data
|
|
139
141
|
},
|
|
140
142
|
_callId: msg.data.callId
|
|
141
143
|
});
|
|
@@ -160,10 +162,12 @@ module.exports = function (RED) {
|
|
|
160
162
|
});
|
|
161
163
|
|
|
162
164
|
node.send({
|
|
165
|
+
topic: msg.data.nodeId,
|
|
163
166
|
payload: msg.data.inputArguments,
|
|
164
167
|
opcua: {
|
|
165
168
|
server: msg.data.serverName,
|
|
166
|
-
method: msg.data.methodName
|
|
169
|
+
method: msg.data.methodName,
|
|
170
|
+
data: msg.data
|
|
167
171
|
},
|
|
168
172
|
_callId: msg.data.callId
|
|
169
173
|
});
|
|
@@ -238,7 +242,7 @@ module.exports = function (RED) {
|
|
|
238
242
|
}, { waitForServer: true, timeoutMs: 5000 });
|
|
239
243
|
}
|
|
240
244
|
|
|
241
|
-
|
|
245
|
+
async function handleActiveAlarms(node, msg) {
|
|
242
246
|
|
|
243
247
|
// let serverName = null
|
|
244
248
|
// if (msg.opcua.server === undefined) {
|