UaModeler
1.6.7.501
|
This example decribes how to create a new project and generate C source files which can be used with the Unified Automation HP SDK version 1.2 and higher.
This will now be explained in 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.
As output directory (i.e. the folder to store the generated files), choose a folder to your liking for which you have read and write access.
In this step, we enter the setting for the new application which will be created by UaModeler. Enter “Test” as Application Name.
After confirming 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 specify the different information of 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 → ObjectTypes → BaseObjectTypes. 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.
In this example, we will add a method (Multiply) with two input and one output argument, each having the DataType Double.
By pressing the triangle next to “Children”, an input field shows up for adding node declarations. Clicking on “Select NodeClass” adds a new node. Select “Method” to add a new MethodNode. Enter the name “Multiply”.
For adding input and output arguments to a method, click on the green triangle at the right end of the row. Enter the two input arguments and one output argument. Confirm your changes by clicking on the “OK” button.
Right click on the “Objects” folder in the Information Model Window and select “Add Instance” from the context menu.
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 *.c and *.h files located in the output folder.
The file located in the directory called “Generated” shall not be modfied by the user.
Create a solution with the CMake gui. The source is located in the "src" folder in the target directory. Add CMake Variable SDKDIR with the installation path of the hp sdk. The selected output path shall be used as CMake_INSTALL_PREFIX.
Please see the documentation of HP SDK for more details about the usage of CMake.
Add the method implementation in file provider_prefix_myobjecttype_methods.c.
Connect to the server running on port opc.tcp://localhost:4840. Call method at Object → MyObject → Multiply.