UaModeler
1.3.1.264
|
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 Hello World Server example delivered with the Unified Automation C++ SDK in six simple steps.
The Hello World Server example delivered with the C++ SDK used in this HowTo can be accessed via Start Menu (Examples → UA Hello World Server Project).
First, the source and header files generated in HowTo (Windows): Create a New Project With a Method have to be added to the Visual Studio project. Right click on the project and select Add → Existing Item. Then add all files starting with the prefix “newns_”.
The generated header files must be included in the file servermain.cpp. Add the marked lines:
Now, we create an instance of the NewNs::NodeManagerNewNamespace in the server startup and add it to the Server’s Nodemanager. Add the marked code to servermain.cpp:
In the start method of the server 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.
Add the following code to servermain.cpp:
At last, the method has to be implemented in the file newns_myobjecttype.cpp.
Now compile the project. It is also possible to compile it in 64Bit mode if all third-party files (like OpenSSL and LibXml2) are in 64Bit as well.
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 <Installation Directory>\UaSdkCppxyz\bin. Just start the application and connect to the server with Unified Automation’s UaExpert.
To check if the generated code works, browse to the node MyObject and call the method fktSum.