1

I'm currently working on open62541. I created one object XML file. now I want to add the file to server and try to run server. when server runs the XML file contain objects should be show on opcua-client application.

James Z
  • 12,209
  • 10
  • 24
  • 44

1 Answers1

0

In 3 steps:

  1. you need a nodeset.xml file
  2. use cmake command to generate source code from it
  3. call a function in your executable

1

I do not know what kind of "XML" file you have. I would assume you have a valid nodeset.xml file. if you do not know how to do it,you can try read this: https://opcua.rocks/custom-information-models/ personally i suggest to use a GUI tool for that (e.g. free opc ua modeler)

2

Then you should use following custom CMake commands provides by open62541

# Generate types and namespace for DI
ua_generate_nodeset_and_datatypes(
    NAME "di" # the name you want
    FILE_CSV "${UA_NODESET_DIR}/DI/OpcUaDiModel.csv"
    FILE_BSD "${UA_NODESET_DIR}/DI/Opc.Ua.Di.Types.bsd"
    NAMESPACE_MAP "2:http://opcfoundation.org/UA/DI/"
    FILE_NS "${UA_NODESET_DIR}/DI/Opc.Ua.Di.NodeSet2.xml"
)

after build, you would find bunches of ua_xxxx_generated.c and ua_xxxx——generated.h file under build/src_generated folder. Then in your programm code just include these headers and call

3

namespace_xxx_nodeset_generated(server)

please refer to https://github.com/open62541/open62541/tree/master/examples/nodeset and http://www.open62541.org/doc/master/nodeset_compiler.html There are rich example and codes for that

TTZ
  • 1