Determining the 'type' of a Node

Questions regarding the use of the .NET SDK 2.0 for Server or Client development or integration into customer products ...

Moderator: uasdknet

Post Reply
nwhelchel
Sr. Member
Sr. Member
Posts: 14
Joined: 16 Oct 2012, 16:33

Determining the 'type' of a Node

Post by nwhelchel »

Two related questions:

1. How can I determine the 'type' of an instance node?
2. How can I determine if a given instance node is a 'kind-of' a type?


I have been unable to find any documentation that addresses this.

Thanks,
Nathan

Lost+Found
Hero Member
Hero Member
Posts: 20
Joined: 07 Feb 2013, 11:01

Re:Determining the 'type' of a Node

Post by Lost+Found »

Anyone has an answer to that question?

User avatar
Support Team
Hero Member
Hero Member
Posts: 3068
Joined: 18 Mar 2011, 15:09

Re:Determining the 'type' of a Node

Post by Support Team »

Hi,
I'm not sure what you want to know.
InstanceNodes have the public property "TypeDefinitionId". This is the NodeId of the TypeNode in the Type System for Variables and Objects.
There's also a property NodeClass that lets you know if the Node is an Object, Variable,.. etc.

Best Regards,
Unified Automation Support Team
Best regards
Unified Automation Support Team

nwhelchel
Sr. Member
Sr. Member
Posts: 14
Joined: 16 Oct 2012, 16:33

Re: Determining the 'type' of a Node

Post by nwhelchel »

Just to follow up on this, I was attempting to use the Modeler to create a type hierarchy - i.e. generic base types with derived types. I was able to model the hierarchy but I could find no way to easily determine if a given object type was a 'kind-of' base type. This is a basic object-oriented query so I was looking for some method that would allow me to determine this 'kind-of' relationship with regards to the type hierarchy. Just knowing it's type identifier is not what I was looking for.

Regards,
Nathan

User avatar
Support Team
Hero Member
Hero Member
Posts: 3068
Joined: 18 Mar 2011, 15:09

Re: Determining the 'type' of a Node

Post by Support Team »

Hi Nathan,

I assume the statement "but I could find no way to easily determine if a given object type was a 'kind-of' base type" is related to the use of your model in a Client or Server application.

The only way in OPC UA to find out if a type is derived from a "known" base type is to browse the type hierarchy in inverse direction following the HasSubtype reference type, or to be more concrete the SubTypeOf reference in the inverse case. Browsing in the inverse direction is mandatory for the type hierarchy. You need to browse HasSubtype in inverse direction until you find a known "base type".

If you have no special information available inside the server, you can do this browsing also inside the server by using the internal client interface.

Best Regards,
Unified Automation Support Team

nwhelchel
Sr. Member
Sr. Member
Posts: 14
Joined: 16 Oct 2012, 16:33

Re: Determining the 'type' of a Node

Post by nwhelchel »

Yes, that's correct - I created a model in the server and wanted to determine if a given type was part of a particular type hierarchy. So I understand that there is no method already provided, I would have to write my own routine to traverse up the hierarchy. Simple enough.

Thanks,
Nathan

User avatar
Support Team
Hero Member
Hero Member
Posts: 3068
Joined: 18 Mar 2011, 15:09

Re: Determining the 'type' of a Node

Post by Support Team »

Hi Nathan,

If you are inside the server based on the .NET Server SDK, there is also a simplified option available.

You should have a look at ServerManager.TypeManager.IsTypeOf(). It provides exactly what you need.
See also
http://doc.unifiedautomation.com/uasdkd ... nager.html

This works if your types are registered with the TypeManager. This happens automatically if you use UaModeler or the toolkit layer (nodes in memory). If you implement your own custom NodeManager without nodes in memory you need to register the type nodes or you can implement the proposed browse logic.


Best Regards,
Unified Automation Support Team

Post Reply