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: 1027
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: 1919

Currently Online:
56 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Heikki Tahvanainen: 402

hbrackel: 144

rocket science: 88

pramanj: 86

Francesco Zambon: 83

Ibrahim: 78

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

Member Stats:

Guest Posters: 0

Members: 739

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1524

Posts: 6453

Newest Members:

shaylamaggard4, rickyjuarez140, jonathonmcintyre, fannielima, kristiewinkle8, rust, christamcdowall, redaahern07571, nigelbdhmp, travistimmons

Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1027, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0

Administrators: admin: 1