OPC UA Companion Specification for Animals - A Tutorial
The full tutorial for this repository can be found here: https://opcua.rocks/custom-information-models/
A sample OPC UA Server using this CS can be found here: https://github.com/Pro/opcua-animal-server
How to initialize
First you need to clone and initialize this git repository:
git clone https://github.com/Pro/opcua-animal-cs cd opcua-animal-cs git submodule update --init --recursive
Build the model
There are three possibilities to build your model:
- Linux: Docker Container
- Linux: Command line
- Windows: Command line
The recommended and easiest way is the first one using docker.
Linux: Docker Container
To build this
Model.xml file using docker, you can use my prepared docker container.
It is based on the official UA-ModelCompiler source code.
There's currently an open pull-request (https://github.com/OPCFoundation/UA-ModelCompiler/pull/36) to add the necessary docker files to the official repository. In the meantime you can use my docker container:
You can also build the container on your own using the Dockerfile from the base repository: (https://github.com/Pro/UA-ModelCompiler/tree/feature/docker)
- Make sure you have docker installed
- Then run the model compiler:
docker run \ --mount type=bind,source=$(pwd),target=/model/src \ --entrypoint "/app/PublishModel.sh" \ sailavid/ua-modelcompiler \ /model/src/animalModel animal /model/src/Published
- This will create the resulting files in the
Publishedfolder inside the root of the repository.
Linux: Command Line
On linux you need to install the mono package and build the model compiler using msbuild.
- execute the
init_compiler.shscript, this will prepare everything for you.
build_model.shwhich will call the model compiler binary from previous step
On Windows you need to have at least the Visual Studio Community edition, which is free.
Open Visual Studio and then open the .sln Project in the
Building this in Debug mode should create the executables in
Otherwise you can also use the Visual Studio Command Line Prompt:
cd model_compiler nuget.exe install -OutputDirectory packages ModelCompiler/packages.config msbuild "ModelCompiler Solution.sln" /p:TargetFrameworkVersion="v4.5"
Then you can use
build_model.bat to compile the NodeSet2.xml from the Model.xml file.