C++ Based OPC UA Client/Server SDK  1.5.6.361
Tutorial for SDK Level

Most of the server tutorials are using the toolkit level. This tutorial provides a platform independent example for implementing the interfaces of the SDK directly.

The example implements one NodeManager and two IOManangers. One IOManager is part of the NodeManager and handles all attributes with static configuration values. The second IOMananager handles the dynamic Value attributes of Variables in the address space.

The following figure shows the classes used for the management and access of the address space and the static configuration attributes of the nodes in the address space.

Figure 1 Classes for address space and static attribute handling

l2tutorialsdkslasses1.png

The example defines the two interfaces TreeInterface and TreeNodeInterface to separate the generic classes NodeManagerTree and IOManagerTree from product specific implementations of the interface. The NodeManagerTree allows browse access to the nodes in the address space. The class IOManagerTree implements access to the static attributes of the nodes in the address space. This affects all attributes except the value attribute.

The NodeManager and IOManager can be reused for product implementations if it is possible to expose the server address space through the interfaces TreeInterface and TreeNodeInterface. Otherwise the classes NodeManagerTree and IOManagerTree can be used as sample code. The classes are limited to a simple tree based address space with objects and variables. It is not possible to represent a full mesh network of nodes or more enhanced features.

The class MyTree is the sample code specific implementation of the interface TreeInterface. It manages all nodes in the example address space and a shared memory simulation for the variable values.

The class MyTreeNodeBase implements the interface TreeNodeInterface and is the base class for all nodes in the example address space. The class MyTreeNodeWithChildren implements the part of the TreeNodeInterface that handles child nodes. The derived class MyFolder is used in the example to build a folder object tree for the variables.

The class MyTreeVariable is the base class for Variable nodes in the address space and provides functionality for Value attribute handling. The derived class MyDataVariable is used in the example to represent the Variable nodes in the address space.

The following figure shows the classes used for the Value attribute handling and sampling of the Value attribute.

Figure 2 Classes for value attribute handling

l2tutorialsdkslasses2.png

The class MyIOManagerValues is the example specific implementation of the IOManager for the Value attribute handling. It is created by MyTree and uses MyTree to read and write the current values of Variable nodes. The values are provided by a simple shared memory simulation in the class MyTree.

Client Read and Write calls for Value attributes are handled in the MyIOManagerValues by calling read and write on MyTree. The linking to the Variable represented by MyTreeVariable and the IOManager is done by the VariableHandle returned from NodeManager::getVariableHandle(). In this example the NodeManagerTree calls MyTree::getValueVariableHandle() to provide the VariableHandle for the Value attribute. The class MyVariableHandleOffset is used as concrete implementation and contains the information, like offset, that is necessary to access the value in the shared memory simulation. There is one MyVariableHandleOffset object per Variable in the address space. The class MyTreeVariable makes sure that a VariableHandle is created at first use and is reused later on. This is also necessary for the sampling.

For the management of monitored items and the sampling of the Value we need additional classes. The class TreeSampleItem represents a monitored item created by a client in the IOManager. Since several monitored items for one or more sampling intervals can be created, the class TreeSampleGroupItem is used to link the TreeSampleItems for the different sample groups to the Variable represented by the VariableHandle class MyVariableHandleOffset.

The IOManager manages a list of sampling intervals represented by a list of SampleGroup objects. The sampling is executed in the worker thread of the IOManager in the method MyIOManagerValues::run().