OPC UA provides a powerful information modelling functions, which allows you to define standardized information in syntax and semantic. There a lot of collaboration between OPC Foundation and other standardizdation organization active, which aims to create a domain specific information model. An overview of the current collaboration can found here.
With version 2.04 the ctrlX OPC UA Server supports to load your own or standardized OPC UA Information Models on the ctrlX and thus represents your data as you required in the OPC UA Addressspace. To fill your OPC UA Information Models with data from ctrlX Data Layer you have to do a mapping for the corresponding data.
This how-to shows you the steps to generate and load the required files for ctrlX OPC UA Server out of your OPC UA NodeSets files containing your OPC UA Information Models.
Getting an OPC UA Information Model
The most common ways to get an OPC UA Information Model is creating your own one by using a Modelling Tool like UaModeler or use one or more standardized OPC UA Information Model. Normally, you combine your own Information Model with your instance data and reference this to nodes of one or more standardized OPC UA Information Models.
Standardized OPC UA Information Model
There are a lot of OPC UA Information Model either as part of the OPC UA specification or as a separate OPC UA Companion specification, e.g. the PLCopen or the MachineTool. The nodes of such OPC UA Information Models are described in OPC UA NodeSets which can be found here. Based on that OPC UA NodeSets XML you can generate a bin-files, which can be used in our ctrlX OPC UA Server. This is described in the next section.
UA-Nodesets on GitHub OPC Foundation
UaModeler
The UaModeler allows you to simple create your own OPC UA Information Model as also extend an existing OPC UA Information Models with your own nodes, e.g. instances from ObjectTypes and VariableTypes of provided standard. After your OPC UA Information Model is ready just export it to OPC UA NodeSet XML as shown below. Based on that OPC UA NodeSets XML you can generate a bin-files, which can be used in our ctrlX OPC UA Server. This is described in the next section.
UaModeler: Creating your own OPC UA Information Model and export it to OPC UA NodeSet XML.
Load OPC UA Information Models to ctrlX CORE
Before loading the OPC UA Information Models to ctrlX Core we have to convert the OPC UA NodeSets XML files to the binary files required for the ctrlX OPC UA Server. Therefore we provide the XML2Bin Package (xml2binPackage.zip) in the App Data. This enables the easy conversion of OPC UA NodeSets XML files into binary files. These binary files can then be loaded into the ctrlX OPC UA Server to provide the information models described in the NodeSet XML files.
The XML2Bin Package you find as xml2binPackage.zip in the OPC UA Server App Data under "opcuaserver/companion-config/tools". Please download this package:
Download the XML2Bin Package from App Data.
To accomplish the XML2Bin, follow these steps: Download the XML2Bin Package from App Data.
First three steps to accomplish the XML2Bin Package
Extract all files from the xml2binPackage into a single folder
Add all of your OPC UA NodeSet XML files (e.g., Opc.Ua.Di.NodeSet2.xml) to this folder.
Run the xml2binExtended.bat script from the command line, passing the OPC UA NodeSet XML files as arguments. The order of dependency needs to be taken into account. This means that the first nodeset should only depend on the standard OPC UA NodeSet (Opc.Ua.NodeSet2.xml). The subsequent nodesets should only depend on nodesets that come before it in the sequence (to the left of it). The order of the Dependency of the Information Models has to be take in account.In addition to the binary files, text files are also generated. These text files contain the results of the generation process for the corresponding binary files.
Copy the generated binary files to the ctrlX App Data folder opcuaserver/companion-config/. Result of xml2bin process. Copy the bin-files to ctrlX App Data.
Restart the ctrlX OPC UA Server. Step 5: Restart OPC UA Server over ctrlX Web Interface.
After restart you can inspect the loaded and not loaded bin-files over the Data Layer addresses "opcuaserver/companion-model/loaded-bin-files" and "opcuaserver/companion-model/-not-loaded-bin-files". This functionality is available at Version 2.6 of the ctrlX OPC UA Server. Inspect the loaded bin-files on ctrlX OPC UA Server in Data Layer.
If all bin-files are correctly loaded you can already browse the OPC UA Addressspace of your newly added OPC UA Information models. But for all Variables to will get a "Null" Value. Therefore you have proceed with the mapping described in the next section.
See the loaded OPC UA Information Model in the ctrlX OPC UA Server Addressspace.
Map data from Data Layer on OPC UA Information Models
After loading the OPC UA Information Models you can start to map the data from Data Layer to Variables and Methods Nodes of the OPC UA Information Models. Therefore you have to create a mapping via the Data Layer address "opcuaserver/companion-model/mappings". This can be done over the ctrlX OPC UA Server or directly in Data Layer over ctrlX Web Interface (Settings->Data Layer).
Follow this steps to create a mapping:
Call "create" on the Data Layer address "opcuaserver/companion-model/mappings"
Define a name for your mapping (in example "umati"). Also activate "typeSafety" if required. This checks for every mapping entry in the table that target and source node have the same datatype. Next fill out the mapping table. Every entry in the table contain the "sourceUaNodeId" and the "targetUaNodeId". In "sourceUaNodeId" you write the OPC UA NodeId of a Data Layer node which provides the data for the target node. In "targetUaNodeId" you write the OPC UA NodeId of a node from before loaded OPC UA Information Model. Please use "sourceUaNodeId" and "targetUaNodeId" the string formatting as defined here.
(UaExpert only) To create one or more entry in the mapping table please press "..." on "mappingTable" and again "..." on "$$S:comm.opcua.server.companion.NodeIdMapping Array[0]"
(UaExpert only) Then extend the array size to wished size.
(UaExpert only) Fill out the table with wished parameters.
Press create on the dialog and the corresponding mappingTable will be created. You can still modify the table under the Data Layer Address "opcuaserver/companion-model/mappings/<definedMappingName>".
Mapping Data Layer nodes to OPC UA Nodes. Left side using UaExpert over ctlX OPC UA Server. Right side using Data Layer over the Data Layer Editor.
The result
After finishing the mapping you can immediately read, write and subscribe the values or call the methods via the ctrlX OPC UA Server. You can still adapt you mapping via the Data Layer Address "opcuaserver/companion-model/mappings/<definedMappingName>".
The result of the mapping.
App Data
The mapping table will be saved in App Data under "opcuaserver/companion-config/mappings" of the ctrlX OPC UA Server. As the binary files of the OPC UA Information models also saved in the App Data you can easily transfer this between different controls using the ctrlX CORE mechanism.
Mapping Table are saved in App Data as json and can port easly to other controls.
... View more