C++ Based OPC UA Client/Server/PubSub SDK
Tutorial Server for IEC 61131-3 (PLCopen) Information Model

The OPC UA Information Model for IEC 61131-3 defines a mapping from the software model and data types used for PLC programming to an OPC UA representation.

One example is the mapping of function block declarations to OPC UA object types and of function block instances to OPC UA objects. The input, output and local variables of function blocks are mapped to OPC UA variables.

The SDK provides the two necessary information models OPC Devices (OPC DI) and OPC UA Information Model for IEC 61131-3 (PLCOpen). They are part of the UaModels library.

This example is using the empty server from Lesson 1: Setting up a Basic OPC UA Server Console Application as starting point.

The nodes are created in the class NodeManagerBoilerDemo. Some of the variables are also simulated in this class. The nodes are representing two boilers using the same structure that is used in the PLCopen boiler demo used in trade shows and OPC UA presentations.

The example specific node manager and the two node managers OpcUaDi::NodeManagerDevices for OPC DI and OpcUaPlc::NodeManagerPLCopen for the PLCopen model are created in the file servermain.cpp after creating the server object and before starting the server.

// Create and initialize server object
OpcServer* pServer = new OpcServer;
pServer->setServerConfig(sConfigFileName, szAppPath);
// ++++++ Additional code begin +++++++++++++++++++++++++
NodeManagerBoilerDemo* pNM = new NodeManagerBoilerDemo;
// ++++++ Additional code end +++++++++++++++++++++++++
// Start server object
ret = pServer->start();

In addition we need the following includes in servermain.cpp.

#include "opcuadi_nodemanagerdevices.h"
#include "opcuaplc_nodemanagerplcopen.h"
#include "nodemanagerboilerdemo.h"

The nodes are created in NodeManagerBoilerDemo::afterStartUp().

It creates:

  • The function block types
  • The PLCopen configuration object
  • The PLCopen resource object
  • A PLCopen program
  • Two PLCopen function block instances representing two boiler instances
  • The boiler function blocks have contained function blocks representing the structure of the boiler

The simulation is executed in NodeManagerBoilerDemo::run().