Please consider registering

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
how to add optional property to existing Objects on server by Client SDK?
February 20, 2020
10:25, EEST
Forum Posts: 6
Member Since:
January 7, 2020
sp_UserOfflineSmall Offline

Hi all,
I would like to know how to add optional property to existing Objects on server by Client SDK?
For example .
There is a AAAObjectType has 3 properties, A1 is Mandatory and others B2, C3 are optional.
when I create the AAAObject , it only has A1 property at the first time.
Can I add B2 or C3 property by Client SDK? How to do it?

February 20, 2020
12:58, EEST
Bjarne Boström
Forum Posts: 523
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline


Is the AAAObject created by the server or the client?

Is the server made with our Java SDK or something else? Does it support AddNodes/AddReferences calls? (Our SDK by default has that feature turned off, since you will need to build some user authorization system to limit it to e.g. “Administrators”, otherwise anyone connecting to the server could e.g. delete any node).

Do you absolutely need to do it via the client? It is possible, assuming the server is made to support it, but it is a bit of … a pain to do. This area of the SDK could be improved a lot (however, usually clients do not add nodes). However for nodes that do not have a sub-structure of nodes it is relatively easy. And by “support it” I mean the server needs to persist that node to that sense that when the server application is restarted the node is not lost (as this is usually not the desired outcome). Additionally normally just the node is not enough, you will need to link it to some backend functionality as well.

In it’s basic form it looks like be:

NodeId parentNodeId = … // Put NodeId for the AAAObject
NodeId newNodeId = … // NodeId to be used for the Property
QualifiedName browseName = … // Must match the Property name your want to add (IMPORTANT! NamespaceIndex must be correct!)

VariableAttributes nodeAttributes = new VariableAttributes(); // NOTE! you will need to init it’s fields
client.getAddressSpace().addNode(parentNodeId, ReferenceTypeIdentifiers.HasProperty, newNodeId, browseName,
NodeClass.Variable, nodeAttributes, VariableTypeIdentifiers.PropertyType); //NOTE! has to be this overload or one taking in AddNodesItem

Initializing all fields of the VariableAttributes might be some work, also they do need to match 1:1 for the property you are going to make. Best is if you can AddressSpace.getNode that InstanceDeclaration node for the Property from the TypeDefinition of AAAObjectType, then call UaNode.getAttributes().clone and change anything if needed and use that instead of trying to do them manually. That should ensure it is correct.

I’ll probably need to continue for the server part, but that should be enough if the server is not done with our SDK, but would supports AddNodes calls. Our Java SDK does have some handles you can listen in the server side so I’ll continue on that if that were made with our SDK.

February 24, 2020
7:54, EEST
Forum Posts: 6
Member Since:
January 7, 2020
sp_UserOfflineSmall Offline

Thanks . It works. ^^

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 267

Currently Online:
9 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 100

pramanj: 86

ibrahim: 70

kapsl: 57

gjevremovic: 49

TimK: 41

Fransua33: 39

fred: 37

Rainer Versteeg: 32

Thomas Reuther: 26

Member Stats:

Guest Posters: 0

Members: 1058

Moderators: 14

Admins: 1

Forum Stats:

Groups: 3

Forums: 14

Topics: 981

Posts: 4145

Newest Members:

mats989, Sebastien Petitrenaud, sting2005, Ron Hoppe, Seb, p.devito, g.ilengo, MohamedLazrek, brittr83165991, martintinsley9

Moderators: Jouni Aro: 846, Otso Palonen: 32, Tuomas Hiltunen: 5, janimakela: 0, Pyry: 1, Terho: 0, Petri: 0, Bjarne Boström: 523, Heikki Tahvanainen: 402, Jukka Asikainen: 1, Teppo Uimonen: 20, Markus Johansson: 18, Matti Siponen: 31, Lusetti: 0

Administrators: admin: 0