UaModeler
1.6.5.472
|
This example decribes how to create a new project and generate C# source files which can be used with the Unified Automation .NET Client SDK version 3.0 and higher.
This will now be explained in eleven 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.
To generate code for a client application the information model must match the regarding information model of the server.
If the model of the server addressspace is available, e.g. because the server vendor is distributing it, then you should add this model in the “Choose Base Models” page of the wizard and browse to the model file to import. In most times a server vendor will provide the model in a NodeSet2 XML format that is defined by the OPC Foundation.
If the model to import has dependencies to other models, these dependent models need to be imported as well.
You need to specify suitable values for Organization and Namespace for the selected model.
At the “New Model” page you can click at “No new model” and “Finish” wizard.
If the model is not available, then you need to create the model yourself.
Enter suitable values in the “New Model” page and “Finish” the wizard.
Please see Step 4: Completing the Wizard With “New Model”.
For structured DataTypes you need to make sure that the structure fields are correct and the DataTypeId and the Encoding NodeIds are matching the IDs on server side.
You can do the modelling as described in Step 5: Add a Structured Data Type.
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. You need to select the imported model by right clicking on the model node and clicking at “Generate Namespace”.
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 *.cs files located in the output folder (as set in Step 2: Selecting a Template).
There is a generated Visual Studio solution that can be opened with Visual Studio 2017 or later. You can modify the file Program.cs analog to Step 6: Read a Variable Having a Structured Data Type.