UaModeler
1.4.3.352
|
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. Hello World Server example delivered with the Unified Automation C++ SDK using CMake in six simple steps.
First, the generated source files must be added to the project. The Hello world server example can be found in [SDK Installation Directory]/examples/server_hello_world. Make sure that the files generated in HowTo (Linux): Create a New Project With a Method are actually in this folder. Open the file [SDK Installation Directory]/examples/server_hello_world/CMakeLists.txt and add the generated *.cpp files starting with “newns_”:
If additional models have been chosen in Step 3: Selecting the Base Models, it is necessary to create the corresponding NodeManagers. Please refer to the documentation of the C++ SDK for more information.
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.
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 and server_hello_worldd in debug version in the folder [SDK Installation Directory]/bin. Just start the application and connect to the server with UaExpert.
To check if the generated code works, just browse to the node MyObject and call the method fktSum.