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
NodeBuilder: NodeId creation strategy
August 29, 2023
15:47, EEST
Avatar
Francesco Zambon
Member
Members
Forum Posts: 83
Member Since:
December 20, 2021
sp_UserOfflineSmall Offline

Good morning,

I have a question regarding the creation of object nodes via the method:
com.prosysopc.ua.server.instantiation.NodeBuilder.build()

I noticed that the NodeId of the child nodes of the object are of type String.

Would it be possible to change the NodeId to Numeric?

Thank you.

Best regards,
Francesco

August 30, 2023
9:48, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1028
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi,

Yes, but care should be taken not to make NodeIds of existing nodes. The String-NodeIds are a bit safer in this regard as it can represent hierarchical paths thus there is less chance of conflicts (UUIDs would be best, but they are not very human-readable). SDK doesn’t handle conflicts well i.e. createInstance/NodeBuilder is not transactional. If it fails halfway in the process then half the nodes are already added and rolling this back manually can be .. a bit of a pain.

Anyway, probably easiest is to override com.prosysopc.ua.server.NodeManagerUaNode.createNodeId(UaNode parent, QualifiedName of_the_child_node) by subtyping NodeManagerUaNode. There are also other createNodeId versions, but this is the one NodeBuilder calls, but if you wish to only have numeric ids you could override all of them. Note that SDK also uses these internally when making e.g. subnodes below structure datatype’d nodes.

If you need more control e.g. that the numeric should be based on specific InstanceDeclaration of a type etc. it is more complicated, but technically doable by making an UaNodeBuilderConfiguration (given in NodeBuilder constructor) that returns InstantiationStrategy that ignore the NodeId part of InstantiationStrategy.createInstance(InstantiationParameters) (or basically meaning you make new InstantiationParameters with the nodeid you want to have).

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 1919

Currently Online:
28 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: 727

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1525

Posts: 6456

Newest Members:

ernestoportus31, martin123, rickie5305, shaylamaggard4, rickyjuarez140, jonathonmcintyre, fannielima, kristiewinkle8, rust, christamcdowall

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

Administrators: admin: 1