Hi
I would like to know how to get the root node from a defined namespace?
Actually I know the namespace ID and my session is well connected.
My goal is to browse all the hierarchy from the root node.
Tanks in advance for your answers.
How have the root node in a session?
Moderator: uasdknet
- Support Team
- Hero Member
- Posts: 3068
- Joined: 18 Mar 2011, 15:09
Re: How have the root node in a session?
Hi,
Namespaces do not need to have specific root nodes.
Some companion specifications define entry points (like the Devices folder in http://opcfoundation.org/UA/DI/). If such an entry point is well known to a client, the client can use them as "root node for the namespace".
In general a client needs to browse recursivly through the address space starting at the RootFolder (ObjectIds.RootFolder) if a specific namespace should be explored.
Best regards
Support Team
Namespaces do not need to have specific root nodes.
Some companion specifications define entry points (like the Devices folder in http://opcfoundation.org/UA/DI/). If such an entry point is well known to a client, the client can use them as "root node for the namespace".
In general a client needs to browse recursivly through the address space starting at the RootFolder (ObjectIds.RootFolder) if a specific namespace should be explored.
Best regards
Support Team
-
- Jr. Member
- Posts: 3
- Joined: 16 Sep 2015, 14:54
Re: How have the root node in a session?
Hi
tanks for your answer.
But i don't know how to browse recursivly with the RootFolder. Have you a example code?
Is not it difficult to browse through several namespace?
tanks
Best regards
Lionel
tanks for your answer.
But i don't know how to browse recursivly with the RootFolder. Have you a example code?
Is not it difficult to browse through several namespace?
tanks
Best regards
Lionel
- Support Team
- Hero Member
- Posts: 3068
- Joined: 18 Mar 2011, 15:09
Re: How have the root node in a session?
Hi,
Best regards
Support Team
Code: Select all
static void BrowseRec(Session session, NodeId nodeId, SortedList<NodeId, NodeId> browsedNodes)
{
var Browse = new Action<List<ReferenceDescription>>(a =>
{
foreach (ReferenceDescription refernce in a)
{
NodeId targetNodeId = refernce.NodeId.ToNodeId(session.NamespaceUris);
if (!browsedNodes.ContainsKey(targetNodeId))
{
browsedNodes.Add(targetNodeId, targetNodeId);
BrowseRec(session, targetNodeId, browsedNodes);
}
}
});
byte[] continuationPoint;
List<ReferenceDescription> results = session.Browse(nodeId, out continuationPoint);
Browse(results);
while (continuationPoint != null)
{
results = session.BrowseNext(ref continuationPoint);
Browse(results);
}
}
Support Team
-
- Full Member
- Posts: 7
- Joined: 19 Jul 2018, 10:30
Re: How have the root node in a session?
Hi there,Support Team wrote: ↑05 Oct 2015, 11:12Hi,
Best regardsCode: Select all
static void BrowseRec(Session session, NodeId nodeId, SortedList<NodeId, NodeId> browsedNodes) { var Browse = new Action<List<ReferenceDescription>>(a => { foreach (ReferenceDescription refernce in a) { NodeId targetNodeId = refernce.NodeId.ToNodeId(session.NamespaceUris); if (!browsedNodes.ContainsKey(targetNodeId)) { browsedNodes.Add(targetNodeId, targetNodeId); BrowseRec(session, targetNodeId, browsedNodes); } } }); byte[] continuationPoint; List<ReferenceDescription> results = session.Browse(nodeId, out continuationPoint); Browse(results); while (continuationPoint != null) { results = session.BrowseNext(ref continuationPoint); Browse(results); } }
Support Team
I know that's old topic, but algorithm you provided should be still valid or at least the idea of recursive calling Browse method.
I have tried out this function but unfortunately it throws BadSessionIdInvalid exception. Before raising this exception it can browse for approx. 30 nodes in average. I think that exception is related to session timeout, I tried to extend value in OperationTimeout property of RequestSettings object without any success.
Do you have any ideas what could help me to overcome this limit, what to set up properly, or something similar.
Thanks in advance.
- Support Team
- Hero Member
- Posts: 3068
- Joined: 18 Mar 2011, 15:09
Re: How have the root node in a session?
Hello,
In most scenarios the default values for the Session and operation timeouts are good, so you should not change them before analysing the trace file of your client. You should also create a wireshark capture and analyse which service call is causing the exception / returning the ServiceFault message.
In most scenarios the default values for the Session and operation timeouts are good, so you should not change them before analysing the trace file of your client. You should also create a wireshark capture and analyse which service call is causing the exception / returning the ServiceFault message.
Best regards
Unified Automation Support Team
Unified Automation Support Team