UaModeler  1.6.5.472
HowTo (Linux): Create a New Project With a Method

This example decribes how to create a new project and generate source files which can be used with the Unified Automation ANSI C SDK version 1.6.0 and newer in nine simple steps.

Step 1: Creating a New Project

To create a new project, choose “File → New Project” from the menu bar. The “New Project” wizard will appear. Fill in a project name and a file name to your liking. For additional information on an input field, right click on its label and choose “What’s This?” from the context menu.

Project Name
This is the name of the project you will generate the source files for.
Location
This is the location where the project and project related files will be stored (IMPORTANT: These files are NOT the generated source files *.c and *.h)
File Name
This is the name of the project file.

By default, the project will be generated in the user’s home directory. Feel free to chose a different directory for which you have read and write access.

wizard_lin1.png

Step 2: Selecting a Template

After confirming the General Project Settings by pressing the button “Next”, the “Generate Code” dialog appears. Here you specify the Code Template Set and the Output Directory for the generated code. At “Template Set”, choose the kind of code to be generated, i.e. the SDK you intend to use the code with. For this example, choose the ANSI C Server Template Set matching the SDK version you are using.

wizard_linc2.png

For being able to continue with HowTo (Linux): Compile the Generated Method Project Files set the output path (i.e. the folder for storing the generated source files) to [SDK Installation Directory]/examples/server_gettingstarted/exampleproject, because we will integrate the generated code into Getting Started Lesson 1 later.

Continue with “Next”.

Step 3: Setting Project Settings

In this step, we enter the setting for the new provider which will be created by UaModeler. Enter “ExampleProject” as Provider Name.

Note
The UaModeler will append automatically the word “Provider” at the end of the name. Therefore the name of the provider in this example will be “exampleprojectProvider”.
Provider Name
This is the name of your new provider.
Support Alarms and Events
This option allows the creation of helper function for Alarms and Events. This contains getters and setters for event fields and a function to setup the event hierarchy. See Alarm & Events for more details.
wizard_linc3.png

Step 4: Selecting the Base Models

After confirming the Project Settings with “Next” the “Choose Base Model” dialog appears. Here you specify the different Base Models. The first NodeSet is the mandatory root namespace of the server. All other suggested models are optional. You can add your own model by clicking the button “Find another model”.

wizard_linc4.png

Step 5: Completing the Wizard With “New Model”

The last step of the wizard guides you to the “New Model” page. Here you have to specify some information for your new model. Please fill out all fields as shown below.

Model Name
This is the name of your new model.
File Name
This is the name of the ua file of your new model.
Location:
This is the location where the model and its ua files will be stored.
Namespace URI:
This is used to differ the node’s namespaces.
wizard_linc5.png

Step 6: Adding a New Object Type

In the Information Model Window on the left pane of the UaModeler browse down to Types → ObjectType → BaseObjectType. The new object will be derived from BaseObjectTypes. Right click on BaseObjectTypes and select “Add New Type”.

wizard_linc6.png

The type definition document will show up in the middle of the UaModeler window. Expand the input fields at “Type” and fill in a name for the new object (here “MyObjectType”). All other information can be added later. Confirm by clicking on the “OK” button.

wizard_linc7.png

You can see the newly created node (MyObjectType) in the Information Model Window below “BaseObjectType”. Select it to display its content in the main window.

In this example, we will add three components to the Object Type, two variables of data type Int32 (var1 and var2) and one method (fktSum).

Click on “Select NodeClass” to add a new node and fill in the required information as shown in the screenshot below. To add a TypeDefinition or a DataType which is not already listed in the respective drop-down menu, choose “<Add another node …>” to open a browse window. Confirm your changes by clicking on the “OK” button.

wizard_linc8.png

With the toolbar buttons you can switch between the model view and the type declaration view.

wizard_linc10.png

Step 7: Adding Method Arguments

After having created the method, you can add input and output arguments. To switch back to the type definition view

By pressing the triangle next to “Children”, an input field shows up for adding node declarations. You can add input and output arguments, give them a name, and select the data type of each argument. Add two input arguments and one output argument as shown in the screenshot below and confirm with “OK”.

wizard_linc9.png

Step 8: Select the Model for Generating Code

When the design is completed you can generate the code for your model. It is possible to design multiple models in a project (each stored in a different file), but code generation is only performed for those that are marked as “Generate Namespace”, indicated by a blue gear-wheel symbol. The new model is pre-selected. You can select or deselect “Generate Namespace” by right clicking on the model node.

Note
It is not possible to generate code for the base UA Model (stored in Opc.Ua.NodeSet.ua) since it is already included in the server SDKs.
wizard_linc12.png

Step 9: Generating Code

For generating the source files, press the “Compile” button (the blue gear-wheel) in the menu bar. When the compilation is finished you will find your generated *.h and *.c files located in the output folder (as set in Step 2: Selecting a Template).

wizard_linc11.png
Note
The names and total number of generated files may differ depending on the template set.

Congratulations—your design was turned into source code. Now you are able to integrate your created code into your server application. Just follow the steps in the section HowTo (Linux): Compile the Generated Method Project Files.