Skip to content

mpostol/UA-ModelCompiler

 
 

Repository files navigation

Model Design Compiler

Table of Contents

Executive Summary

The repository has been forked from OPCFoundation/UA-ModelCompiler and will be synchronized with the origin repository occasionally.

The main goal of this repository is to improve:

  • portability - the ability of software to be transferred from one machine or system to another
  • reusability - the ability of software to be used by other software products provided on the multivendor market

It will be accomplished by

  • GUI layer separation
  • NuGet package for the main compiler body
  • Docker image generation for the CLI application
  • ASP.NET GUI for the main compiler body
  • generic code generator provided as a plug-in

Additionally, it should enable

The OPC Foundation Model Compiler generates C# and ANSI C source code from XML files which include the UA Services, data-types, error codes, etc.; and numerous CSV files that contain NodeIds, error codes, and attributes, etc.

The input format for the tool is a file that conforms to the schema defined in UA Model Design.xsd.

The output of the tool includes:

  1. A NodeSet which conforms to the schema defined in Part 6 Annex F;
  2. An XSD and BSD (defined in Part 3 Annex C) that describes any data types;
  3. Class and constant definitions suitable for use with the .NET sample libraries;
  4. Other data files used to load an information model into a Server built with the .NET sample libraries;
  5. A CSV file which contains numeric identifiers.

The UA Model Design.xsd has more information about the schema itself.

The .NET sample libraries has a sample Model Design file that illustrate how to create a user defined model.

This batch file is used to regenerate the files used in the sample after changes.

The tool only produces ANSI C output for the stack.

All of the standard outputs are published in the Nodeset GitHub repository

Developers should never need to build the standard outputs themselves.

About this Repository

NOTE: In this repository, the default branch has been changed to main. The master branch is preserved for synchronization with the origin only. Further versioning will be implemented using new tags instead of branches. New branches are created only for development purposes.

License Model

The ModelCompiler code is MIT license, however, it links to the UA-.NETStandard NuGet packages which is covered under the OPC Foundation Redistributables licence.

How to compile an Example

An example model is located in the directory Tests\DemoModel. The following process will demonstrate how to generate code using the supplied ModelDesign file:

  1. Clone the repository to the selected location.
  2. Build the source in Visual Studio 2022, in Debug mode.
  3. Open a Command prompt in the mentioned above directory.
  4. Launch the BuildModel.bat without parameters.
  5. After the script completes, navigate to the Tests\DemoModel\generated directory where the output of the compiler is located

Optionally, instead of using the binaries created by Visual Studio, you may provide a path to existing binaries as the first parameter of the BuildModel.bat. The compiler binaries may be downloaded from the recent release.

Other Repositories

This ModelCompiler is used to generate the content of the UA-Nodeset GitHub repository. The NuGet package is used by the OOI Address Space Model Designer (OOI ASMD)

Partnership program

I am a researcher and University associate who is passionate about applying knowledge and experience in building a Machine to Machine (M2M) meaningful interoperability based on OPC UA. Let's build it with you and for you. To join our effort and create an organizational context I have launched an open-access Object-Oriented Internet Partnership Program. Hence, maintenance of this repository and further development of the OPC UA Information Model Domain-Specific Language will be carried out under a broader concept described in the following article

Object-Oriented Internet Partnership Program

Consider joining. Visit the section How to be involved to get more. I hope that thanks to this partnership program we will establish long-term mutually beneficial cooperation. Your participation is needed to make sure that the work will continue as expected. As a rule of thumb, the work priority is derived from community feedback.

I strongly encourage community participation and contribution to this project. First, please fork the repository and commit your changes there. Once happy with your changes you can generate a pull request.

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

CLI Syntax of the Model Compiler Tool

Command Description
compile Takes an OPC UA ModelDesign file and generates a NodeSet andcode for the .NETStandard stack.
stack Generates code for the core model (not used for vendordefined models)
units Generates the OPC UA Engineering Units CSV from the official UNECE table of units.
update-headers Updates all files in the output directory with the OPC Foundation MIT license header.
help Display more information on a specific command.
version Display version information.

compile

Takes an OPC UA ModelDesign file and generates a NodeSet andcode for the .NETStandard stack.

Short Name Long Name Description
-g CSVfileGenrate --cg=CSVfileGenrate Creates the identifier file if it does not exist (used instead of the -c option).
-i --id (Default: 0) The first identifier to use when assigning new ids to nodes.
-s --useAllowSubtypes When subtypes are allowed for a field, C# code with the class name from the model is created instead of ExtensionObject. No effect when subtypes are not allowed.
-m --mv The version of the model to produce.
--pd The publication date of the model to produce.
--rc Indicates that a release candidate nodeset is being generated.
-d ModelDesign --d2=ModelDesign Required. The path to the ModelDesign files which contain the UA information model.
-c CSVfile The path to the CSV file which contains the unique identifiers for the types defined in the UA information model.
-o output --o2=output The output directory for the generated files.
-e --exclude Comma separated list of ReleaseStatus values to exclude from output.
-v --spec (Default: v104) Selects the specification version the source text is compliant with. The values: v103, v104, or v105 are supported.

Stack

Generates code for the core model (not used for vendordefined models)

Short Name Long Name Description
-n --dotnet Generates the .NET stack code for the core model (not used for vendor defined models). The path to use when generating .NET stack code.
-a --ansic Generates the ANSI C stack code for the core model (not used for vendor defined models). The path to use when generating ANSI C stack code.
-d ModelDesign --d2=ModelDesign Required. The path to the ModelDesign files which contain the UA information model.
-c CSVfile The path to the CSV file which contains the unique identifiers for the types defined in the UA information model.
-o output --o2=output The output directory for the generated files.
-e --exclude Comma separated list of ReleaseStatus values to exclude from output.
-v --spec Selects the specification version the source text is compliant with. The values v103, v104, or v105 are supported. (Default: v104)

Units

Generates the OPC UA Engineering Units CSV from the official UNECE table of units.

Short Name Long Name Description
--annex1 Required. The path to the UNECE Annex 1 CSV file.
--annex2 Required. The path to the UNECE Annex 2/3 CSV file.
--output Required. The units output directory.

update-headers

Updates all files in the output directory with the OPC Foundation MIT license header.

Short Name Long Name Description
--input Required. The path folders to search for files to update.
--pattern Required. The file pattern to use when selecting files.
--license Required. The types of license supported MIT, MITXML, or NONE.
--silent Suppresses any exceptions.

See Also

Join me at LinkedIn