This guide will outline typical steps needed to use DataHub to transfer data from an OPC-UA server to Factbird. The OPC-UA server used in this guide is Kepware.
Run the setup.
Download latest Cogent DataHub™ from the website.
Version used in this guide was: CogentDataHubFull_x64-11.0.4-260116-Windows.exe
Note this will install DataHub under the current user. If running in production, change this later to run it as a Windows service.
Install the components needed for the specific use case. For this guide we only need:
- OPC UA (Unified Architecture)
- MQTT Client
Installing as a Service
After the setup has been completed and verified, DataHub can changed to run as a Windows service instead of the current user.
Start the Service Manager in the Cogent folder on the start menu.
Configuration:
General settings:
Sending data when only the timestamp changes a required by Factbird.
- uncheck this property: “Do not send insignificant changes”
OPC UA:
- add a new OPC UA connection.
- set the Endpoint URL to the OPC UA server address.
- set security as required. Typically use Basic256Sha256, SignAndEncrypt.
Press “Connection Test”. This will fail the first time:
- accept the certificate sent from the OPC UA server to DataHub.
In the OPC UA server accept the client connection. In Kepware select “OPC UA Configuration” option on the Windows taskbar. Select the “Trusted Clients” tab:
Trust the connection from Cogent_DataHub:
Test again and the connection should be OK:
Factbird requires to received data even if it does not change.
- set “Read Method” to: Synchronous Cache Read.
- consider setting “Data Domain Name” to something that identifies the data making it simpler to identify the data source.
Use “Configure Nodes” to select the nodes that are to be collected. These are simulation tags in Kepware:
Live data is now visible in the “View Data”:
MQTT Client:
- add new MQTT Client connection to Factbird:
Connection:
- set Host Name/IP to the address supplied by Factbird.
- set Port to: 8883
Authentication:
- mark: “Use SSL”
- import the client certificate provided by Factbird.
Note: that the file contains the certificate and the private key. If the certificate and private key by mistake was supplied as 2 individual files, they need to be combined. Open the files in a text editor and copy the contents to a single file.
- set “Client ID” to the id provided by Factbird.
- select “Send all messages to this topic:”
- set topic to: “plc/input/<client id> where <client id> is the id provided by Factbird.
Message Contents:
- set “Quality of Service” to: At least Once (1).
- set “Retain messages on broker” to: not selected
- set “Message format” to “Advanced”.
Click “Edit” to open the advanced editor.
Click “Import” and select a template file with this content:
|
<?xml version="1.0" encoding="utf-8"?> <AdvancedFormatTemplate xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Name>FactBirdPub AWS</Name> <Parser> <Name>FactBirdPub</Name> <ReceiveProcessingScript>app.ProcessJson();</ReceiveProcessingScript> <EnableReceiveProcessor>false</EnableReceiveProcessor> <EnableSendDocument>false</EnableSendDocument> <IsEnabled>true</IsEnabled> <IsDefaultPublisher>true</IsDefaultPublisher> <PublishFormats> <JsonPublishFormat> <Name>FactBird</Name> <Text><% var JTimestamp = DateTime.UtcNow.ToJsonTime(); %> { "values": [ <% var point; var i; for (i = 0; i < points.Length; i++) { point = points[i]; v__output.Append(i == 0 ? "" : ",");%>{ "id": "<%= point.BaseName %>", "v": <%= point.JsonValue %>, "t": <%= point.JsonTimestamp %>, "q": <%= (int)point.Quality >= 192? "true":"false" %> } <% } %>], "timestamp": <%= JTimestamp %> }</Text> <IsMultiPoint>true</IsMultiPoint> <IsDefaultPublishFormat>true</IsDefaultPublishFormat> </JsonPublishFormat> </PublishFormats> </Parser> </AdvancedFormatTemplate> |
Apply the new Template. The “Publish” tab should now contain the script.
Select the tags that is to be transferred to Factbird.
Debugging:
Use “View Data” to see data being collected from the OPC UA Server.
Use “Event Log” to identify errors and problems.
Remember to press “Apply” to commit changes. Sometime a restart of DataHub is also required.
Event Data:
To use automatic stop cause assignment and other function where Factbird is to react to data changes, a separate connection needs to be created.
OPC UA configuration:
Configuration is identical to the input data configuration except:
- set “Read Method” to: Subscription (default value).
MQTT Configuration:
Configuration is identical to the input data configuration except:
- set topic to: “plc/event/<client id> where <client id> is the id provided by Factbird.
Note: a separate certificate and separate client id is used for this connection. Each connection needs to be separate.