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
Access to namespaceUri of generated VariableTypeNode implementations from within the generated class
September 3, 2015
20:45, EEST
Avatar
hbrackel
Member
Members
Forum Posts: 135
Member Since:
February 21, 2014
sp_UserOfflineSmall Offline

I generated VariableTypeNode implementations from a nodeset.xml file. For some custom code (static factory method) which I want to add to the generated class I need to access the namespaceUri (actually the namespaceIndex) of the type definition. This information can be seen in the @TypeDefinitionId() annotation of the class.

Is there any way to access this information in code within that class?

Thanks,
Hans-Uwe

September 4, 2015
7:40, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 983
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi,

You can use the com.prosysopc.ua.AnnotationUtils.readTypeDefinitionId(Class) static method. It is the same which NodeManagerUaNode.createInstance uses internally, if you use createInstance methods which take Class parameter.

Just in case the factory method you are talking would be used to instantiated the said class (without NodeManagerUaNode.createInstance/NodeBuilder):
The generated nodes should not be instantiated manually, only through createInstance methods or using NodeBuilder class directly (which the createInstance methods do internally). The reason is that usually the type contains other nodes (e.g. Property nodes or in case of Object nodes also InstanceDeclarations); calling just the constructor of the generated node only does create the top level node and nothing else (this is why it is generated as protected). The NodeBuilder looks the type information from the server’s typespace and instantiates all the nodes and creates correct References between them + e.g. the HasTypeDefinition reference which points to the type. In addition the NodeBuilder sets the Attributes of the newly created node and does call the afterCreate method.

– Bjarne

September 4, 2015
13:04, EEST
Avatar
hbrackel
Member
Members
Forum Posts: 135
Member Since:
February 21, 2014
sp_UserOfflineSmall Offline

Hi,

thanks for your solution. This works great.

The static factory method internally uses the NodeBuilder to create the node instances. The factory adds and sets custom non-OPC UA properties of the Variable nodes, as I wanted to avoid public setter methods for those properties. It also automates the configuration of optional properties based on some input parameters (e.g. the presence of an engineering unit string)

Many thanks,
Hans-Uwe

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
9 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

rocket science: 77

Ibrahim: 76

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

TimK: 41

Member Stats:

Guest Posters: 0

Members: 682

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1467

Posts: 6261

Newest Members:

digitechroshni, LouieWreve, Kickbiche, karrimacvitie5, graciela2073, sagarchau, elviralangwell4, Donnavek, Eddiefauth, DonaldPooma

Moderators: Jouni Aro: 1010, Otso Palonen: 32, Tuomas Hiltunen: 5, Pyry: 1, Petri: 0, Bjarne Boström: 983, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 26, Teppo Uimonen: 21, Markus Johansson: 42, Niklas Nurminen: 0, Matti Siponen: 321, Lusetti: 0, Ari-Pekka Soikkeli: 5

Administrators: admin: 1