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:
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.