UA Ansi C Server Professional
1.3.2.233
|
There are two main development tasks to implement an OPC UA Server using the SDK.
One is to integrate the SDK and the UA Server into a new or an existing application. The second task is to integrate the data sources into the SDK. This tutorial gives an introduction on how to integrate data sources into the ANSI C UA SDK by implementing a data provider. It doesn't cover everything. The emphasis is on teaching how to quickly create a new Data Provider with new address space and new IO data.
Please read the Introduction section before working through this tutorial.
Contents:
Before we start we have to take a look at the SDK source structure.
Folder | Description |
---|---|
uaserverc | Main UA Server source folder containing the generic server sources. |
uaserverc/tools | Folder containing some helper 'classes' like container (TurboList, TurboStack, etc.). |
uaserverc/providers | Folder containing all data providers. |
uaserverc/providers/server | Folder containing the Server Provider which implements the Server address space defined by the OPC UA Specification. |
uaserverc/providers/sample | Folder containing a simple sample provider with demo values. |
uaserverc/providers/xyz | Folder containing your vendor specific XYZ provider. |
If you want to create your first data provider it's the easiest way to just copy the sample provider and rename the files. A basic provider should contain these files:
File | Description |
---|---|
uaprovider_xyz.h | Contains provider function definitions. Normally only UaProvider_XYZ_Initialize for initializing your provider. |
uaprovider_xyz.c | Implements the provider initialization and cleanup. |
xyz_read.c | Implements the read service of the provider interface. |
xyz_write.c | Implements the write service of the provider interface. |
xyz_subscription.c | Implements the subscription functionality described in Provider Subscription Mechanism |
uaserver_helper.h | Contains generic helper functions for using the provider callback interface. |
Every provider has to implement a Initialize function with the following signature. This is the main entry point to setup all other functions a provider may provide.
This is called when loading the provider and has the following purposes:
This is called from the Server SDK before the provider is unloaded to give the provider the chance to cleanup it's resources.
Providers can also be compiled as Dynamic Link Libraries (aka shared objects). In this case you have to provide an exported Dll function InitializeProvider which calls the UaProvider_XYZ_InitializeProvider function. All other functions will be accessed through the Provider Interface Table and do not need to be exported. You can use the define UAPROVIDER_STATIC to check if providers are linked statically or dynamically. See Start up code for UA Stack and UA Server to see how to load dynamic and static providers.