Documentation

c-treeEDGE IoT Database

Previous Topic

Next Topic

OPC UA Installation and Configuration

The OPC (Open Platform Communications) interoperability standard is a machine-to-machine communication protocol for industrial automation. c-treeEDGE supports OPC UA (OPC Unified Architecture). OPC UA (IEC 62541 published between 2010 and 2012) combines all the separate OPC protocols into one specification, which simplifies development.

The OPC server converts the hardware communication protocol used by a Programmable Logic Controller (PLC) into the OPC protocol. Then, data can be accessed by other applications or persisted in a c-tree file by the OPC Plug-in.

The c-treeEDGE OPC plug-in can handle basic OPC information (OPC Server URL, namespace, nodes, and frequency), as configured with the JSON file described below, and automatically persist the data in a ctree file. The raw data can be treated on the edge and then replicated to the server.

Installation / Configuration Procedures

This plug-in feature is enabled by adding the following server configuration in ctsrvr.cfg:

Windows:

PLUGIN ctopc;./opc/ctopc.dll

Linux/Unix:

PLUGIN ctopc;./opc/libctopc.so

The plug-in is loaded at server startup and begins persisting data immediately.

Check CTSTATUS.FCS to see if there was an error starting OPC Plug-in. Don't forget to check to see if OPC Server is running before starting c-tree server.

Configuration File

Information about OPC is defined in the ctopc.json file in the opc folder under the c-treeEDGE server folder. This configuration file is in this 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 c-treeEDGE 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> c-treeEDGE user name.
    • databasePassword: <string> c-treeEDGE user password.
    • targetTables: <array> Array of c-treeEDGE 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 c-treeEDGE 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 c-treeEDGE.

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