Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
Browsing Address Space of OPC UA Server
July 4, 2014
8:10, EEST
Avatar
shailendra.jain
New Member
Members
Forum Posts: 1
Member Since:
July 4, 2014
sp_UserOfflineSmall Offline

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

July 4, 2014
9:11, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1026
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

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.

July 9, 2014
22:30, EEST
Avatar
hbrackel
Member
Members
Forum Posts: 144
Member Since:
February 21, 2014
sp_UserOfflineSmall Offline

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?)

July 24, 2014
17:52, EEST
Avatar
OndrejBlazek
Member
Members
Forum Posts: 19
Member Since:
July 22, 2014
sp_UserOfflineSmall Offline

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.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 1919

Currently Online:
21 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Heikki Tahvanainen: 402

hbrackel: 144

rocket science: 88

pramanj: 86

Francesco Zambon: 83

Ibrahim: 78

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

Member Stats:

Guest Posters: 0

Members: 731

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1529

Posts: 6471

Newest Members:

inilarythikibia, rickykennion, PromotionToold, HypromeImpupe, toneylapham544, rondawolinski7, Marypof5711, roycedelargie91, kourtneyquisenbe, ellis87832073466

Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1032, Jimmy Ni: 26, Matti Siponen: 349, Lusetti: 0

Administrators: admin: 1