UaModeler  1.2.0.214
 All Pages
HowTo (Linux): Compile the generated method project files

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 Ansi C SDK in six simple steps.

NOTE: There are three different files called CMakeLists.txt involved in the following HowTo. Pay attention to the respective folders given in the text.

Step 1: Adding the generated provider to CMakeLists.txt

First of all you have to add the CMake option of the newly generated provider into the CMakeLists.txt file of the Ansi C SDK in (<Installation Directory>/sdk/src/CMakeLists.txt).

In addition to that, add the include directories of the generated provider into the file <Installation Directory>/sdk/src/uaserver/uaserverc/CMakeLists.txt of the server module as shown below.

Step 2: Adding the generated provider into the server application’s CMakeLists.txt

In the previous step, the generated provider is only added into the server’s main library, but you also have to add the provider into the server application’s CMakeLists.txt (<Installation Directory>/src/applications/uaserverc/linux/CMakeLists.txt) and set the include directory path to the generated code.

Step 3: Implementing the example method of the generated provider

Now, we implement the method in the generated file <Installation Directory>/sdk/src/uaserver/uaserverc/providers/exampleproject/uaprovider_exampleproject_call.c as shown in the screen shot below.

Step 4: Adding code to the server applications source file

Then, locate the source file of the application (<Installation Directory>/sdk/src/applications/uaserverc/linux/uaserver.c) and include the generated provider.

For enabling the server to start-up the provider, it has to be added to the server’s provider list.

Step 5: Compiling and running the server application

After completing the previous steps, you can compile the whole project with the delivered script buildSdk.sh.

If everything went well, you can find the applications uaserverc and uaservercd in the folder <Installation Directory>/sdk/bin.

When starting up the server, you can see that the generated provider is loaded and initialized.

Step 6: Connect to the server application via UaExpert

The last step is to check if the generated provider and its method is correctly implemented. Just connect to the server with Unified Automation’s UaExpert, browse to your generated object type (Root → Types → ObjectTypes → BaseObjectType → MyObjectType) and call the method.