UaModeler
1.2.0.214
|
The generated code itself is identical for Windows and Linux; hence code that was generated under Windows can be used in a Linux SDK and vice versa. The integration of the generated code into your application strongly depends on the build environment you are using, e.g. Visual Studio, Eclipse, CMake, etc. This example will describe how to integrate the generated code into the delivered CMake files of the Unified Automation C++ SDK 1.3.2 in 6 simple steps:
First, the generated source files must be added to the project. Make sure that the generated files are located in your application source folder. Open the related CMake file (here CMakeLists.txt in the folder sdk/examples/server_hello_world) and add the new *.cpp files starting with “newns_”:
The generated header files must be included in the file servermain.cpp as shown below:
Now, we create an instance of the NewNs::NodeManagerNewNamespace in the server startup and add it to the Server’s Nodemanager:
In the start method of the server (servermain.cpp) the object must be instantiated and the node is added to the objects folder. After this step, the new object will be browseable and accessible in the server’s address space.
At last, the method has to be implemented in the file newns_myobjecttype.cpp.
To compile the project server_hello_world with the generated *.cpp and *.h files, just use the delivered buildExamples.sh script. You can also compile it in 64Bit mode using the script buildExamples64.sh.
If the compilation succeeded, you should find compiled application server_hello_world in release version or server_hello_worldd in debug version in the folder sdk/bin. Just start the application and connect to the server with Unified Automations UaExpert.
To check if the generated code works, just browse to the node MyObject and call the method fktSum.