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
Sample server code
August 28, 2023
12:48, EEST
Avatar
mgrenier
Member
Members
Forum Posts: 13
Member Since:
February 4, 2021
sp_UserOfflineSmall Offline

Hello,

I follow the useful sample code to create dynamically instance of a node in the server address space.
I can’t find the way to add programmatically a property in the server (in this sample or in this forum).

Could you help me?
For example, how to add a property (nodeClass:variable, dataType: string…) in the myLevel node ?

Thank you.

August 28, 2023
16:18, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 983
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi,

Generally we recommend using the createInstance of NodeManagerUaNode, but for Property it is a bit special since SDK handles them separately thus there is no direct PropertyType class (compared to the other codegenerated ones where SDK does have a class based on the OPC UA type).

You can either use the “pre-codegen style”:

CacheProperty property1 = new CacheProperty(this, new NodeId(getNamespaceIndex(), "ExtraProperty1"),
new QualifiedName(getNamespaceIndex(), "ExtraProperty1"), LocalizedText.english("ExtraProperty1"));
myLevel.addProperty(property1);

or the createInstance works as well, but you must use NodeId based version of that:

UaProperty property2 = (UaProperty) createInstance(Identifiers.PropertyType, "ExtraProperty2");
myLevel.addProperty(property2);

The lines assume run within com.prosysopc.ua.samples.server.MyNodeManager.createAddressSpace() i.e. no exception handling etc. and they refer the MyLevel UaNode constructed earlier in the method.

For other reference types you would use UaNode.addReference methods (it can also be used for adding Property as that is just ReferenceTypeIdentifiers.HasProperty).

August 31, 2023
12:44, EEST
Avatar
mgrenier
Member
Members
Forum Posts: 13
Member Since:
February 4, 2021
sp_UserOfflineSmall Offline

Hi,

Thank you. it is exactly what I need.
Thank you again for your quick detail answer .

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
13 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

fred: 41

Member Stats:

Guest Posters: 0

Members: 683

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