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
how to add optional property to existing Objects on server by Client SDK?
February 20, 2020
10:25, EET
Avatar
c70015@gmail.com
Member
Members
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?
Thanks.

February 20, 2020
12:58, EET
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 982
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi,

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, EET
Avatar
c70015@gmail.com
Member
Members
Forum Posts: 6
Member Since:
January 7, 2020
sp_UserOfflineSmall Offline

Thanks . It works. ^^

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
25 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

ibrahim: 75

rocket science: 75

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

TimK: 41

Member Stats:

Guest Posters: 0

Members: 708

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1465

Posts: 6252

Newest Members:

christi10l, ahamad1, Flores Frederick, ellenmoss, harriettscherer, shanonhumphreys, KupimotoblokfuB, tamhollander5, paulinafcf, bridgette18l

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

Administrators: admin: 1