UaModeler
1.3.5.298
|
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.3 and newer in nine simple steps.
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.
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.
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 1.3 Template Set.
As output path (i.e. the folder for storing the generated source files) choose a folder to your liking for which you have read and write access.
Continue with “Next”.
In this step, we enter the setting for the new provider which will be created by UaModeler. Enter “ExampleProject” as Provider Name.
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”.
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.
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”.
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.
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.
With the toolbar buttons you can switch between the model view and the type declaration view.
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”.
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.
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).
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 (Windows): Compile the Generated Method Project Files.