OPCFoundation / UA-.NET-Legacy

OPC Foundation Unified Architecture .NET Reference Implementations
332 stars 296 forks source link

browse more than 20k tags takes long using UA COM Server Wrapper application #192

Open isaacrimi opened 4 years ago

isaacrimi commented 4 years ago

Hello, I came across the following issue : I ran the UA Com Server Wrapper Sample and created a wrapper using a com server that has more than 20k tags under one branch. When I connected to the wrapper with an OPC UA Client and tried to browse that branch, the request generally times out. When it doesn’t, it took at least 2 minutes to complete and the branch is shown as empty. Why does it take that much time to browse? Is there a way to optimize it?

SoftwareDave commented 4 years ago

I've noticed it's slow too - I haven't had time yet to figure out where that comes from - but to get around it, we browse the entire model when our client app loads, so it looks like it's part of initialization - from then on, it's not too bad. Not a great workaround...

On Tue, Jul 21, 2020 at 8:53 AM isaacrimi notifications@github.com wrote:

Hello, I came across the following issue : I ran the UA Com Server Wrapper Sample and created a wrapper using a com server that has more than 20k tags under one branch. When I connected to the wrapper with an OPC UA Client and tried to browse that branch, the request generally times out. When it doesn’t, it took at least 2 minutes to complete and the branch is shown as empty. Why does it take that much time to browse? Is there a way to optimize it?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/OPCFoundation/UA-.NET-Legacy/issues/192, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGQGJ2AGOQAPT32BXADBQ3R4W2XBANCNFSM4PDXV2HQ .

isaacrimi commented 4 years ago

Hi, Thanks for the reply, I wanna ask how did you manage to browse the entire model?

SoftwareDave commented 4 years ago

Since the model is a tree-like object, with parent nodes and child nodes... recursion is used. at least that's the way I did it. Every time you get a new node, you have to get all the children... the method calls itself (recursion).

Starting with the parent node root object, and for namespaces > 1 (I don't want the UA nodes, I want me model's nodes, which are namespaces > 1) I used something similar to: Node childNode = Session.NodeCache.Find(expandedNodeId) as Node; and if it meets my criteria, I add this childNode to an ongoing List: foundNodes.Add(childNode);

This childNode may have children of its own... if the childNode is null (meaning this parent has no children), then the recursive method returns...

What's also good about this (besides getting the model into your own list), it also puts it in the OPC/UA library's NodeCache. Every search for a node after this is fast fast fast...

One thing I've learned in a lifetime of software - I count the recursion layers - I used a static int to count how "deep" it goes. On a normal 21st century PC or laptop, it's not a problem.

The NetMaster utilities, one of those many sample clients, probably has an example of how to recursively get a set of all child nodes for a given parent node.

If recursion sounds strange, complicated, new, etc. to you - there are probably lots of simple recursive C# method examples on the interweb. Take a look at those, and likely the pieces of the puzzle will fall into place.

I hope this helps... -Dave

On Mon, Jul 27, 2020 at 8:25 AM isaacrimi notifications@github.com wrote:

Hi, Thanks for the reply, I wanna ask how did you manage to browse the entire model?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/OPCFoundation/UA-.NET-Legacy/issues/192#issuecomment-664463711, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGQGJ7R6SPR33DAPMYA5Y3R5WL6RANCNFSM4PDXV2HQ .

isaacrimi commented 4 years ago

Can you please just show a sample of how to browse recursively? how could i store the browsed items?