Giter Site home page Giter Site logo

bubdm / ua-modelcompiler Goto Github PK

View Code? Open in Web Editor NEW

This project forked from opcfoundation/ua-modelcompiler

0.0 0.0 0.0 19.55 MB

ModelCompiler converts XML files into C# and ANSI C

License: MIT License

Batchfile 1.33% C# 94.55% C 3.86% C++ 0.08% Dockerfile 0.06% Shell 0.12%

ua-modelcompiler's Introduction

Model Compiler

The OPC Foundation Model Compiler will generate 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 datatypes;
  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.

Tutorial by Stefan Profanter here.

About this Repository

This repository contains sub-modules for the Nodeset files, which are independently tracked. Please clone this repository as shown:

git clone https://github.com/OPCFoundation/UA-ModelCompiler --recursive

This repository is not updated directly. All changes are first made in a member-only version that can be found here.

The version in the member-only repository includes content that is only available to OPC Foundation members such as draft versions of the specifications. When a new version of the OPC UA specification is released, the member-only content is removed and copied to the public reposotory.

In many cases, updates to the UA-ModelCompiler will require updates to UA-.NETStandard codebase. This means a complete release of the UA-ModelCompiler will need to wait for a update to UA-.NETStandard NuGet packages. The member only version links to a member only fork of UA-.NETStandard allows the changes to be viewed before they are merged with the public baseline.

The public repository is updated as frequently as the OPC UA Specification (once every 3-5 months). When a release starts, all issues reported on the public repository will be reviewed and, if appropricate, incorporated into the member-only codebase. This includes any pull requests.

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. If a user chooses the version that links directly to the UA-.NETStandard submodule then the license the UA-.NETStandard dual license applies.

Docker Build

The compiled version of this model compiler is available in DockerHub as sailavid/ua-modelcompiler. TODO: Change URL to use official OPCF Docker container!

If you like to build your own container, just use the provided Dockerfile in this repo.

We assume you have your myModel.xml and myModel.csv on your host system in $HOME/myModel. If not change the path in the next command.

The Docker container uses the model compiler executable as entry point. This means that any parameter you pass to the docker run command will be directly passed to the model compiler executable.

This is an examplary call to docker run:

docker run \
  --mount type=bind,source=$HOME/myModel,target=/model \
  sailavid/ua-modelcompiler -- \
   -console -d2 /model/myModel.xml -cg /model/myModel.csv -o2 /model/Published/my_model

Note that here we are binding $HOME/myModel to the path /model inside the container.

You need to make sure that the output directory already exists before running this command.

The expected output is:

Trying file: /model/OpcUaDiModel.xml
Trying file: ./Design/OpcUaDiModel.xml
Trying file: /model/OpcUaDiModel.csv
Trying file: ./Design/OpcUaDiModel.csv

Note, there's no final success message.

To use the PublishModel.sh script you can also override the entrypoint. The PublishModel script is a wrapper around the model compiler executable and is handling directory creation and copying the original model files.

docker run \
  --mount type=bind,source=$HOME/myModel,target=/model \
  --entrypoint "/app/PublishModel.sh" \
  sailavid/ua-modelcompiler \
   /model/myModel my_model /model/Published

The expected output is:

Building Model for 'my_model'
/app/Opc.Ua.ModelCompiler.exe -console -d2 /model/myModel.xml -cg /model/myModel.csv -o2 /model/Published/my_model
Trying file: /model/OpcUaDiModel.xml
Trying file: ./Design/OpcUaDiModel.xml
Trying file: /model/OpcUaDiModel.csv
Trying file: ./Design/OpcUaDiModel.csv
Copying Model files to /model/Published/my_model

Example Generation

The following process will demonstrate how to generate code using the supplied nodeset files:

  1. Clone the repository and then build the source in Visual Studio 2015, in Release mode.
  2. Open a Command prompt and then launch the BuildStandardTypes.bat
  3. After the script completes, navigate to the .\Published folder to view the output.
  4. Optionally, modify the BAT file and specify the location of your UA Stack(s) to automatically copy the generated files.

XML Files

Model Design example

An excerpt of the Model Design file is shown here:

?xml version="1.0" encoding="utf-8" ?>
<opc:ModelDesign
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:opc="http://opcfoundation.org/UA/ModelDesign.xsd"
  xmlns:ua="http://opcfoundation.org/UA/"
  xmlns="http://opcfoundation.org/UA/"
  xmlns:uax="http://opcfoundation.org/UA/2008/02/Types.xsd"
  TargetNamespace="http://opcfoundation.org/UA/"
  TargetNamespaceVersion="1.02"
>
  <opc:Namespaces>
    <opc:Namespace Name="OpcUa" Prefix="Opc.Ua" InternalPrefix="Opc.Ua.Server" XmlNamespace="http://opcfoundation.org/UA/2008/02/Types.xsd">http://opcfoundation.org/UA/</opc:Namespace>
  </opc:Namespaces>

  <opc:Property SymbolicName="NodeVersion" DataType="ua:String" PartNo="3">
    <opc:Description>The version number of the node (used to indicate changes to references of the owning node).</opc:Description>
  </opc:Property>

  <opc:Property SymbolicName="ViewVersion" DataType="ua:UInt32" PartNo="3">
    <opc:Description>The version number of the view.</opc:Description>
  </opc:Property>

Other Repositories

This ModelCompiler is used to generate the content of the Nodeset GitHub repository.

This ModelCompiler is used to generate the content of the .NET Samples GitHub repository.

ua-modelcompiler's People

Contributors

alinmoldovean avatar benjamin1988 avatar benkinooby avatar fbarresi avatar mpostol avatar mregen avatar nathanpocock avatar opcfoundation-org avatar pro avatar randy-armstrong avatar randy-armstrong-alias avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.