12:48, EEST
February 4, 2021
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.
16:18, EEST
April 3, 2012
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”:
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:
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).
Most Users Ever Online: 1919
Currently Online:
29 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: 734
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1523
Posts: 6449
Newest Members:
christamcdowall, redaahern07571, nigelbdhmp, travistimmons, AnnelCib, dalenegettinger, howardkennerley, Thomassnism, biancacraft16, edgardo3518Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1026, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0
Administrators: admin: 1