Documentation

FairCom EDGE IoT Database

Previous Topic

Next Topic

Tutorial for OPC UA Installation and Configuration

Enabling the OPC UA Plug-in

The OPC UA plug-in is enabled by adding the following server configuration in ctsrvr.cfg in the server/config folder:

Windows:

PLUGIN ctopc;./opc/ctopc.dll

Linux/Unix:

PLUGIN ctopc;./opc/libctopc.so

The plug-in is loaded at server startup, connects to an OPC server, and begins persisting data.

Check CTSTATUS.FCS to see if there was an error starting OPC Plug-in.

Before starting the FairCom EDGE database, make sure the OPC server is running; otherwise, the plug-in will not be able to connect to it.

Configuring the OPC UA Plug-in

The OPC UA plug-in is configured using the ctopc.json file in the opc folder under the FairCom EDGE server folder. This configuration file is in JSON format:

{

"opcClientDllPath": "./opc/ctOPCClient.dll",

"databases": [

{

"databaseName": "ctreeSQL",

"sqlDatabase": true,

"authFileName": "authFile.set",

"databaseUser": "ADMIN",

"databasePassword": "ADMIN",

"targetTables": [

{

"targetTableName": "OPCtable1",

"purgeHistoryUnit": "day",

"purgeHistoryPeriod": 60,

"opcServerUrl": "opc.tcp://localhost:4840",

"opcServerAuthFileName": "opcAuthFile.set",

"opcServerUser": "",

"opcServerPas": "",

"opcDataCollectionIntervalSeconds": 10,

"targetFields": [

{

"targetFieldName": "node1",

"opcNamespace": 1,

"opcNodeName": "the.answer"

}

]

}

]

}

]

}

Where:

  • opcClientDllPath: <string> Path to ctOPCClient.dll
  • databases: <array> Array of FairCom EDGE database connections.
    • databaseName: <string> Database name
    • sqlDatabase: <boolean> Indicates if table should be included in SQL. Possible values are: true or false. If you are using a SQL API, set the value to true.
    • authFileName: <string> c-tree Secure authentication file (.set)
    • databaseUser: <string> FairCom EDGE user name.
    • databasePassword: <string> FairCom EDGE user password.
    • targetTables: <array> Array of FairCom EDGE tables where data will be persisted.
      • targetTableName: <string> Table name for persisted data.
      • purgeHistoryUnit: <string> Time unit for purging data.
        Supported values: "none", "minute", "hour", "day", "month", "year"
      • purgeHistoryPeriod: <numeric>Time value for purging data.
      • opcServerUrl: <string> OPC server URL used to connect to your OPC server.
      • opcServerAuthFileName: <string> OPC Secure authentication file (.set)
      • opcServerUser: <string> OPC User Name
      • opcServerPas: <string> OPC User password
      • opcDataCollectionIntervalSeconds: <numeric> Interval value in seconds between reads. A value of 0 (zero) means that data will be persisted each time data is changed.
      • targetFields: <array> Array of FairCom EDGE field names to map.

      targetFieldName: <string> Field name.

      opcNamespace: <numeric> OPC namespace name.

      opcNodeName: <string> or <numeric> OPC node name.

Example:

{

"databases": [

{

"databaseName": "ctreeSQL",

"sqlDatabase": true,

"databaseUser": "ADMIN",

"databasePassword": "ADMIN",

"targetTables": [

{

"targetTableName": "OPCtable1",

"purgeHistoryUnit": "day",

"purgeHistoryPeriod": 60,

"opcServerUrl": "opc.tcp://localhost:4840",

"opcDataCollectionIntervalSeconds": 10,

"targetFields": [

{

"targetFieldName": "node1",

"opcNamespace": 1,

"opcNodeName": "the.answer"

} ]

},

{

"targetTableName": "OPCtable2",

"purgeHistoryUnit": "month",

"purgeHistoryPeriod": 2,

"opcServerUrl": "opc.tcp://localhost:4840",

"opcDataCollectionIntervalSeconds": 15,

"targetFields": [

{

"targetFieldName": "node2",

"opcNamespace": 1,

"opcNodeName": 51034

},

{

"targetFieldName": "node3",

"opcNamespace": 0,

"opcNodeName": 119

} ]

} ]

} ]

}

OPC Test Server

A test directory is provided under the opc directory in the Raspbian, and Linux, and Windows x86/x64 versions of the package. This test directory contains an example of the OPC server and OPC client. It is an open-source implementation for Windows 64, Linux 64, and Raspberry Pi (it can be downloaded at https://open62541.org/). No setting is needed. Just execute server_ctt before starting FairCom EDGE.

Raspbian Example

For example, in the Raspbian version, execute ./server_ctt & in the following folder:

server/opc/test/open62541_v0.3.0/Raspbian.ARM.32bit

Windows Example

In Windows, double-click the following file:

\server\opc\test\open62541_v0.3.0\Windows.x86.64bit\server_ctt.exe

OPC Client Implementation Example

In the same folder indicated in the examples above, is a program called client. It is an OPC Client implementation example that connects to server_ctt, reads some data, and changes a node value (node “the.answer”). To run it, execute it as described above for server_ctt.

TOCIndex