Avatar
Please consider registering
guest
sp_LogInOut Log Insp_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 RSSsp_TopicIcon
Auto-generated structure component child variables
September 29, 2025
17:04, EEST
Avatar
hbrackel
Member
Members
Forum Posts: 146
Member Since:
February 21, 2014
sp_UserOfflineSmall Offline

Hello,

I am generating code from a nodeset containing custom structured dataTypes. When instantiating a (BaseDataVariableType) variable of such custom dataType, the instance in the addressSpace has children for every non-optional structure component. Is there a way to prevent this behaviour and just have the bare basevariable w/o children?

NB: SDK 5.3.0
The Instances are “loaded” from a nodeset as well. I double checked and the instances nodeset does not contain any child variables.
The generated code doesn’t contain the child variables either, so I assume that they are created by the server code when loading the nodeset.

Many thanks

PS: I think we discussed this topic some time ago, but I could not find the post…

September 30, 2025
14:47, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1067
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi,

Is this more of a “curiosity question” or related to some problem (I would like more details)?

This is not directly related to Codegen, it is a feature of the instantiation system. There are some limits, but currently SDK will automatically create sub-nodes (if they do not already exist) that represent the Structure fields and it will synchronize values between them and the main node. Currently there is no intended way to disable this (as we have not had issues with it that I can remember).

The sub-nodes helps clients that do not understand custom structures, it is the ‘third approach’ explained in https://reference.opcfoundatio…..docs/A.4.3, and basically SDK takes care of the disadvantage part since it already syncs the data, though we cannot synchronize fields representing arrays further down to individual elements (and some CPU time goes of course as well).

I guess a workaround would be to edit generated code to not call super.afterCreate() in .afterCreate() (this prevents it going to BaseVariableTypeNode eventually, that does the sub-nodes), though the generated super is responsible for recursively passing down the call to components which wouldn’t happen (though maybe not an issue here). Though it would be somewhat painful to edit the files. We could maybe add a flag to disable this if there is some issue?

P.S.
Note that there are some limitations when this feature activates, currently the InstanceDeclarationHierarchy must already have the Variable/VariableType ValueRank as Scalar and the DataType must be of a Structure type (setting these afterwards doesn’t help, though afterCall could be called manually). In addition, we intentionally do skip all Optional fields, because it is possible to model a Structure type whose Optional field refers to the same Structure type itself (think like linked list nodes pointing to the next one). Or there could be a Chain A->(field)B->C->A that causes the same issue. For non-optional fields this cannot be the case as the Binary Encodings always require a default instance for “null fields” that are structures (so one would never be able to binary encode such type that would refer to itself somehow via non-optional fields).

October 1, 2025
10:12, EEST
Avatar
hbrackel
Member
Members
Forum Posts: 146
Member Since:
February 21, 2014
sp_UserOfflineSmall Offline

Thank you very much for the explanation.

This is not a curiosity question Smile. It is a little bit of an annoyance for my use case (as there are many of those variables), because a) I explicitly just need the “main” variable without child nodes, b) if the child nodes were there, the optional nodes should be present as well, as otherwise the user doesn’t get the complete view of the data, and c) the variable itself is readonly, but the children are writable.

My chosen workaround is to remove the children immediately after the server started. As the design of the addressSpace is still not finalized, code is generated frequently and modifications to generated classes would possibly be overwritten accidentally.

I was wondering whether I would overlook a configuration switch (codegen) or variable (instantation system) by which this auto-instantiation could be controlled.

Many thanks again,
Hans-Uwe

October 1, 2025
16:42, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1067
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

We can build a flag to disable the creation of those sub-nodes as a short term solution. I sent a beta via email.

Forum Timezone: Europe/Helsinki
Most Users Ever Online: 1919
Currently Online:
Guest(s) 62
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 144
rocket science: 100
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 773
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1558
Posts: 6567
Newest Members:
willardmackellar, vnedrenie_koPi, shaylaholton205, PhilesiaGen, rosaurathiel524, Arthurobext, stefanmacneil3, ralni, illuminationscanada, PhillipGit
Moderators: Jouni Aro: 1039, Pyry: 1, Petri: 1, Bjarne Boström: 1054, Jimmy Ni: 26, Matti Siponen: 359, Lusetti: 0
Administrators: admin: 1