OpcUaCanOpen
CANopen OPC-UA server
OpcUa CanOpenServer


Introduction

OpcUaCanOpenServer is a program interface between CanOpen devices and any SCADA system having OpcUa client.
The server has been developed by using Unified Automation (UA) C++ toolkit.
The server creates the address space and hardware connection objects based on XML configuration file.
XSD technology is used to check syntax of XML configuration file.

main.jpg

Installation

The installation rpm package is used to install all needed files

Usage

The general form to start server is
./OpcUaCanOpenServer "configuration file name".xml.
If the XML file name is omit the default configuration file name is used (OPCUACANopenServer.xml)
./OpcUaCanOpenServer -cs
This form is used to create the OPC server certificate. The post script of rpm uses this form.
Also during start up it is possible to point out the log file
./OpcUaCanOpenServer "configuration file name.xml" -l "log file name".log
the relative and absolute path can be used<br>
The OpcUaCanOpenServer address space have the "TraceLevel" item. This Item defines what kind of CANOpen message will be store.

In order to start store the following value can be written in this item:

  • 0, No Trace
  • 1, Pdo Messages
  • 2, Sdo Messages
  • 4, Segmented Sdo Messages
  • 8, NG Messages
  • 16, Emergency Messages

This is bit code it mains that in case value = 3 the Pdo And Sdo message will be put in log file

General Concepts

  • Configuration file
  • Define all object types in the system
  • Create UaObject type
  • Create AddressSpace
  • CanOpen object Structure
  • Connection to hardware interface objects
  • Interface to Canbus Driver

XML configuration file

The OpcUaCanOpen server is configured based on the XML file.
The description of this file can be found Config File . The parser of XML file has been prepared using the "Code Sythis" xsd utility. This utility can create the parser classes based on XSD file which can be easily used to create internal object structure to further processing.
The name of XSD file for this server is CANOpenServerConfig.xsd.

Create Address Space

OpcUa toolkit proposes to create the address space by overwriting the function afterStartup of NodeManager class.
The Address space is a set of UaNode which must have unique node id. The creation was done in two steps:

  • create the set of types of canopen object as UaNode structure. All canopen object has a numeric value which is defined in BuildingAutomationTypesId.h file The node id is created from numeric value of canopen function code.
  • create the set of UaNode based on XML configuration file. Each UaVariable and UaObject has a corresponding object from conopen structure. which is created using createInterfaceEntry(UserDataBase* parent, int code, ::xml_schema::type* conf , UaNode* pAS) function from CanBusInterface class.

There are two generic class:

  • UaControlDeviceGeneric - using to create set of UaNodes ( object and variable ) based on XML configuration and type information
  • UaCaontrolDeviceItem - crating of UaVariable and canopen object using createInterfaceEntry

CanOpen object Structure

There are two types of objects representing the the can bus system

  • CanBusObject and CanNodeOBject inherit property and method from CanObject class. These object is to exchange data with can can system.
  • The objects which execute the canopen protocol inherit properties and methods from CanOpenObject class

All objects have a standard constructor with parameters:

  • UserDataBase *parent is a link to the top level object. For example for CanPDOItem it is CanPDOObject. This pointer allows to create the structure of can system.
  • ::xsd::cxx::tree::type *conf is a configuration data for creating object.
  • UaNode *pAS is a link to the UaVariable to set data if needed

Also any CanObject must have connectCode(OpcUa_UInt32 code,UaNode *blink). This function connects a function code with UaVariable if this object have to take care about it.

canopen.jpg


Connection to hardware interface objects

The class CanBusInterface is a broker class which has only on function createInterfaceEntry(UserDataBase* parent, int code, ::xml_schema::type* conf , UaNode* pAS).
This function based on function code create the proper canopen class.
if the broker has no information about which class has to be created it call cannectCode function of parent to take care about this link. The createInterfaceEntr returns the pointer on object which has the standard interface functions:

  • sendDeviceMessage and getDeviceMessage for CanObject. Using this function UaControlDeviseGeneric object can execute command and send/receive data from can bus.
  • read and write for CanOpenObject. These function are used by UaCantrolDeviceItem to send or receive data. Usually read function execute getDeviceMessage from the parent object to get can message and extract value and save it to UaVariable. The write function packs value to can message and send


CanOpen readout


The main structure of of CanOpen readout system is shown below.

readout.jpg

Can interface component is hardware dependent class. The server downloads it during startup depend on hardware using at the system.
It is possible to use different can cards and driver in one system br<> The Can object sends can messages or send rtr message via interface class and receive date from callback class.