8:10, EEST
July 4, 2014
Hi Everyone,
I am trying to create a list of all branches node(Folder Type) as well as list of all leaves(tags) of address space of opc ua simulation server.
while traversing forward from root node, lots of confusion is there to identify the type of node wether it is a branch or a leaf.
could anybody help me on same.
shailendra Jain
9:11, EEST
December 21, 2011
In OPC UA, the division between branches and leaves is not the same as in OPC DA.
The best is probably to make a division between Objects and Variables instead. You can make the difference by looking at the NodeClass attribute. Or with the Java SDK, you can identify the UaNode objects, whether they are UaObject or UaVariable instances.
22:30, EEST
February 21, 2014
shailendra.jain said
Hi Everyone,
I am trying to create a list of all branches node(Folder Type) as well as list of all leaves(tags) of address space of opc ua simulation server.
while traversing forward from root node, lots of confusion is there to identify the type of node wether it is a branch or a leaf.
could anybody help me on same.
shailendra Jain
Another idea might be to look at the references of a node. Any node which has forward references of HasComponent or HasProperty type (or subtypes thereof) to other nodes, could probably be called a branch node. The most appropriate approach probably depends on what you would like to do the with folder or leave nodes once you identified them (e.g. are leave nodes expected to be DataVariables?)
17:52, EEST
July 22, 2014
I did a very similar thing in my code, so I thought I would share (a slightly modified version of) what I did:
private int recurseAddressSpace(AddressSpace as, String nodePath, NodeId thisNode)
{
int entryCount = 0;
try
{
//
// Get a list of all the node Reference Descriptions at this level
//
List ref = as.browse(thisNode);
entryCount=ref.size();
for(ReferenceDescription item : ref)
{
//
// Only Evaluate Nodes That Are Of Class Object (Typically Folders) Or Variable (Typically Leaf Signals)
//
if(item.getNodeClass().toString().equals(“Object”))
{
//
// Node Is Of Object Class Which Means It Is A Folder
//
try
{
if(nodePath.equals(“”))
{
//
// If this is a root level entry then call this function recursively without any node Path
//
recurseAddressSpace(as, cleanName(item.getBrowseName().toString()), as.getNode(item.getNodeId()).getNodeId(), opcTags, verbose);
}
else
{
//
// If this is not a root level entry then call this function recursively providing the current node Path as an input
//
recurseAddressSpace(as, nodePath+”.”+cleanName(item.getBrowseName().toString()), as.getNode(item.getNodeId()).getNodeId(), opcTags, verbose);
}
}
catch(Exception y)
{
}
}
if(item.getNodeClass().toString().equals(“Variable”))
{
//
// Node Is Of Variable Type Which Means It Is A Leaf Signal
//
try
{
//
// This check is optional – it verifies that the leaf node has an readable Value attribute
// (This was necessary for my implementation because the vendor OPC Server disabled tags when the corresponding equipment was not available
// but did not remove them from the address space until the OPC Server was rebooted. By checking if a value could be read from the attribute
// I was able to filter out the OPC tags that were still in the address space but disabled)
//
String dataVal = super.readAttribute(as.getNode(item.getNodeId()).getNodeId(), Attributes.Value).getValue().toString();
if(nodePath.equals(“”))
{
System.out.println(“Leaf: “+item.getBrowseName().toString();
}
else
{
System.out.println(“Leaf: “+nodePath+”.”+cleanName(item.getBrowseName().toString());
}
}
catch(Exception e)
{
if(nodePath.equals(“”))
{
System.out.println(“Leaf: “+item.getBrowseName().toString()+” without an accessible Value attribute”);
}
else
{
System.out.println(“Leaf: “+nodePath+”.”+cleanName(item.getBrowseName().toString()+” without an accessible Value attribute”);
}
}
}
}
catch(Exception x)
{
System.out.println(“Error: “+x.toString());
}
return entryCount;
}
//
// This function removes the namespace prefix from the BrowseName
//
private String cleanName(String dirtyName)
{
return dirtyName.substring(dirtyName.indexOf(“:”)+1);
}
Usage:
recurseAddressSpace(as, “”, thisNode)
Where as is your address space (i.e. client.getAddressSpace()) and thisNode is the root node.
Most Users Ever Online: 1919
Currently Online:
17 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 144
rocket science: 86
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 732
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1508
Posts: 6396
Newest Members:
elainesever, powhephenry, mamiecaldwell5, Lamasom, scsneed, berrybulcock, icerdraizomma, athenasummy5, vtaletbhcx, HaroldaDobModerators: Jouni Aro: 1019, Pyry: 1, Petri: 0, Bjarne Boström: 1016, Jimmy Ni: 26, Matti Siponen: 340, Lusetti: 0
Administrators: admin: 1