Handling multiple xml files

Questions regarding the use of the C++ SDK for Server or Client development or integration into customer products ...

Moderator: uasdkcpp

Post Reply
kursatb
Jr. Member
Jr. Member
Posts: 4
Joined: 20 Sep 2023, 09:52

Handling multiple xml files

Post by kursatb »

I have a UAModeler project that contains 2 models. It looks like this:

Models:
- Opc.Ua.NodeSet2.ua
- Model1 (This has some types)
- Model2 (This one depends on model1)

Objects:
- Instance of Model2
- Server

So when I export the model2.xml and build an adress space with C++ SDK based on that everything looks fine when I connect with a client.
What confuses me is the Model1. I can export that as an xml separately and Model2.xml mentions Model1.xsd.

Do I need to load the Model1.xml file somehow to the server or does the model2.xml file contain everything I need?
Top

User avatar
Support Team
Hero Member
Hero Member
Posts: 3072
Joined: 18 Mar 2011, 15:09

Re: Handling multiple xml files

Post by Support Team »

Hi,

this is indeed confusing. The dependent models (in a chain of inherited parent - child relation) must be loaded into the server in the correct order, in order to resolve the dependencies correctly.

Only explanation is, that your "instance" in model2 is just using built-in types that were already present within namespace "0" (OPC Foundation Namespace), hence no need to model1.
Best regards
Unified Automation Support Team

kursatb
Jr. Member
Jr. Member
Posts: 4
Joined: 20 Sep 2023, 09:52

Re: Handling multiple xml files

Post by kursatb »

Thanks for the reply. Does that mean I need to load the Opc.Ua.NodeSet2.xml too?

This what I have currently:

UaNodeSetXmlParserUaNode* xmlParser= new UaNodeSetXmlParserUaNode(model2FilePath, nodeManagerNodeSetForModel2, nodeFactory, NULL ):
server->addModule(xmlParser);

I can see the address space just fine when I do this. How do I load the other xmls? I assume I would have to use separate nodeManagers but I'm not interacting with anything in the baseModel.

User avatar
Support Team
Hero Member
Hero Member
Posts: 3072
Joined: 18 Mar 2011, 15:09

Re: Handling multiple xml files

Post by Support Team »

Hi,

the nammespace "0" (OPC Foundation) is already built-into the SDK, but the additional models (with companion specific types or with your custom types) must be loaded in correct order. The instances are typically created in code/by the device, e.g. loaded with a self-made very easy list format (instance x of type A with accessrights R) from a configuration file, or even created on the fly by the device's internal configuration.

Loading XML in NodeSet2 format is not the preferred method to load/configure instances. The SDK has different ways to create the nodes, including the UaModeler code generator tool accompaning the SDK, see documentation for details.
Best regards
Unified Automation Support Team

kursatb
Jr. Member
Jr. Member
Posts: 4
Joined: 20 Sep 2023, 09:52

Re: Handling multiple xml files

Post by kursatb »

Support Team wrote:
29 Sep 2023, 12:59
Loading XML in NodeSet2 format is not the preferred method to load/configure instances. The SDK has different ways to create the nodes, including the UaModeler code generator tool accompaning the SDK, see documentation for details.
I don't want to use the generated code, so only option left is using xml2bin?

User avatar
Support Team
Hero Member
Hero Member
Posts: 3072
Joined: 18 Mar 2011, 15:09

Re: Handling multiple xml files

Post by Support Team »

Hi,

C++ SDK has no XML2Bin! The XML2bin is only available in HighPerf SDK (optimized for embedded device use case with limited resources)

The NodesSet2 format can be used to load additional types at startup (typically few hundred). However loading instances (which typically are many tousands) at startup, you can create/define your own mechanizm (e.g. flat list CSV file) to have a very simple and fast tagfile, maybe directly/consistently generated from your engineering tool (e.g. PLC typically use own simple format for the instances), because engineering knows hardware configuration and PLC programm. However prefered way is creating types and register them at the stack encoder at compile time, because it will be much faster and smaler, and you don't need to parse XML at runtime (including handling of all syntax variants you may have in XML).
Best regards
Unified Automation Support Team

tommys
Sr. Member
Sr. Member
Posts: 15
Joined: 03 Oct 2023, 16:42

Re: Handling multiple xml files

Post by tommys »

However prefered way is creating types and register them at the stack encoder at compile time, because it will be much faster and smaler, and you don't need to parse XML at runtime (including handling of all syntax variants you may have in XML).
I too will use multiple nodeset files and would therefore like to use them as efficiently as possible. I've looked in the server_cpp_demo code but still cannot fully understand the above quote.
EDIT: But now, after having read the documentation: "Use generated code from UaModeler" https://documentation.unified-automation.com/uasdkcpp/1.8.1/html/L2ServerSdkServerAddressSpace.html, I understand that I should use UaModeler to generate C++ code from our information model and simply just use the generated code, then I don't have to handle XML nodeset files in our C++ server code.

/Tommy

Post Reply