mikakaraila / node-red-contrib-opcua

A Node-RED node to communicate OPC UA. Uses node-opcua library.
Other
212 stars 196 forks source link

Cannot properly set browseName for a folder in the server node #731

Open jhooney opened 1 week ago

jhooney commented 1 week ago

I am trying to create a folder with a browseName that is different from its nodeId to match the structure of a server that I have running on a plc (running on codesys on the RIO from Opto22). There seems to be two intended ways to set a browseName of a node, either send a message in the form a:

{
    payload: { "opcuaCommand": "addFolder" },
    topic: "ns=4;s=Sub_Folder1;browseName=Sub1"
}

or b:

var msg2 = {
    payload: { "opcuaCommand": "addFolder" },
    topic: "ns=4;s=Sub_Folder2;b=Sub2"
}

The behavior I am looking for is that the NodeID becomes ns=4;s=<folder-name> and the browseName becomes the browseName component. If I use method a the nodeId becomes ns=4;s=Sub_Folder1, but the node's browseName does not change, and if I use method b the nodeId becomes ns=4;s=Sub_Folder2;b=Sub2, but the browseName does change successfully. Here is what each folder looks like when viewed in UaExpert: image image

Both methods get close to the functionality I'm looking for but seem to not fully implement a browseName. I'm not sure if this is a bug, or if there is another way to set browseName that I am missing. Seems like it is probably a simple fix, if I get some free time I'll try to submit a PR but pretty booked up for awhile.

Here is a flow I made to demonstrate: setFolderBrowseNameFlow.json

mikakaraila commented 1 week ago

In my code there is format example, but I will study why it does not set browseName correctly... your test case looks OK.

// format is msg.topic="ns=1;s=Main.Test;browseName=Test"

mikakaraila commented 1 week ago

Small change and seems to work: image

jhooney commented 1 week ago

Interesting, it seems that browseName can be set when namespace = 1 but not when namespace = 4. I did a little more testing, looks like it also fails when namespace is 2 or 3.

mikakaraila commented 1 week ago

Thanks, I will look and make a fix...