Page 1 of 1
Creating nested structured variables
Posted: 05 Aug 2022, 13:43
by Mick Mathers
If I want to create a variable with nested structures, what's the best way to proceed?
Can I use the UaStructureDefinition::addChild() method to add a field that's a structure, or is another approach preferred?
TIA
Mick Mathers
Re: Creating nested structured variables
Posted: 08 Aug 2022, 14:48
by Support Team
Hello Mick,
You should use the addChild() method only. There is no other approach.
https://documentation.unified-automation.com/uasdkcpp/1.7.7/html/classUaStructureDefinition.html#a405947ab03a9aff024f27269be220f9e
We have examples to create custom data structures. Please look for the below methods in the DemoServer.
Code: Select all
void NodeManagerDemo::createTypeNodes()
UaStatus NmBuildingAutomation::createTypeNodes()
https://documentation.unified-automation.com/uasdkcpp/1.7.7/html/L2DemoServer.html#L3DemoServer_5
We also always advise, if the structures are already known at compile time, to generate the code for the structures using the UaModeler.