Data Logging
Below are instructions for creating logging sessions from both an OPC UA data feed as well as an MQTT Broker.
This lab is designed for you to connect to existing data sources hosted by Canary in our AWS instance 'datagen.canarylabs.online' and will require an internet connection to log data.
Should you wish to re-create the data generation environment we are hosting, you may do so by following the 'Installing Local Data Feeds' instructions, otherwise, bypass this step.
Installing Local Data Feeds - Optional Not Advised
It is best to follow along with the course and connect to the AWS data sources we are demonstrating. However, if you cannot access the AWS machine or really need a local instance of data generation, follow this section guides. If not, skip to the next section.
If installing your entire demo on a single server, you will need the following components included. Also, ensure you have selected 'Mosquitto MQTT Server' from the tab '3rd Party Components'.
The attached zip folder 'Bootcamp - Data Logging' will provide a series of files that will be useful in the configuration process. Each of these files will need placed in specific directories within C:\ProgramData\Canary Labs\ as well as other locations.
Data Generation Service
The Canary Data Generator application can run the 'PumpsAndTowers.dgf' as a service. This will use the application 'CanaryDataGenerator.exe' to produce a simulated data stream that is published to the local Mosquitto MQTT Server.
Step One
The three files included in the Bootcamp - Data Logging.zip file will need placed in the C:\ProgramData\Canary Labs\ Data Generation folder.
Step Two
Configure the file
C:\Program Files\Canary\Collectors\Data Generator\DataGeneration.config
to point to
C:\ProgramData\Canary Labs\ Data Generation\PumpsAndTowers.dgf
<Settings>
<Historian>localhost</Historian>
<ClientName>DataGeneration</ClientName>
<ClientCount>0</ClientCount>
<PacketSize>32000</PacketSize>
<FileName>C:\ProgramData\Canary Labs\Data Generation\PumpsAndTowers.dgf</FileName>
</Settings>
Step Three
Create a Windows Service targeting
C:\Program Files\Canary\Collectors\Data Generator\SAF_DataGenerationService.exe
and name it 'CanaryDataGen'.
Step Four
Ensure the correct configuration of the file...
C:\ProgramData\Canary Labs\ Data Generation\SAF_DataGenerationTarget.MQTT.xml
Pay specific attention to the port configuration. If using 8883 rather than 1883 in your instance, add credentials for Username and Password. Changing this to 8883 will require you to modify steps below when connecting to the MQTT server.
<?xml version="1.0" encoding="utf-8"?>
<TargetSettingsBase xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:q1="SAF_DataGenerationCore.LogTargets.MQTT" xsi:type="q1:Settings" xmlns="SAF_DataGenerationCore.LogTargets">
<q1:Host>localhost</q1:Host>
<q1:Port>1883</q1:Port>
<q1:ClientId>2a52999ee9bf445c9c7376c27ad4183a</q1:ClientId>
<q1:Username />
<q1:Password />
<q1:GroupId>CanaryDataGeneration</q1:GroupId>
<q1:NodeId>Node1</q1:NodeId>
<q1:DeviceId>Device1</q1:DeviceId>
<q1:SSL_Protocol>0</q1:SSL_Protocol>
<q1:QOS_Level>0</q1:QOS_Level>
<q1:UseTagAliases>false</q1:UseTagAliases>
<q1:UseCompression>false</q1:UseCompression>
</TargetSettingsBase>
Step Five
Run the newly created CanaryDataGen service.
KepServer
The included files 'TRAVIS.csv' and 'HAYS.csv' can be imported into KepServer to duplicate the simulation locally if you prefer. You will need to ensure they are imported under Simulation Examples.Functions on your KepServer. Doing so will keep the OPC Node ID consistent with our documentation.
Logging Data via OPC UA
We will create two different OPC UA logging sessions, each targeting a different Canary DataSet. If you are already confident in all of the steps below you can simply import the included OCF files into the ProgramData\Canary Labs\OPC Collector directory. However, it is encouraged that you
Logging Session #1 - Travis Water District
Select OPC UA Collector tile
Click 'Configuration' from bottom tab menu
Create 'New Session'
Set Name to = Travis
Historian = localhost
Set DataSet to = Travis
OPC Server Host name = opc.tcp://datagen.canarylabs.online:49320
Port = (in URL)
Security = false
Create Pumps group
Rename Group 1 to = Pumps
Browse the OPC Server > Simulation Examples > Functions > Travis
Filter ‘Pump’ and add all tags
Create Towers group
Create New Group and set name to = Towers
Change Sample Interval to 00:00:30
Browse the OPC Server > Simulation Examples > Functions > Travis
Filter ‘Tower’ and add all tags
Begin Logging
- Apply all changes
- Select lower tab 'Status'
- Enable logging by clicking the 'Play' button on the 'Travis' panel
Verify data is flowing from the OPC Collector to the Sender service. By selecting the Sender tile in the Canary Admin application you should see the newly created session Localhost/Travis. The state should be 'Active' and you should have 51 tags logging with Store/Sec and Send/Sec values changing. The TVQs column should be at 0. If the TVQs column is growing it means you are buffering data in Sender and not moving data into the Canary Historian you targeted in the logging session configuration. Double-check your configuration.
Logging Session #2 – Hays Water District
Create 'New Session'
Set Name to = Hays
Historian = localhost
Set DataSet to = Hays
OPC Server Host name = opc.tcp://datagen.canarylabs.online:49320
Port = (in URL)
Security = false
Create Pumps group
Rename Group 1 to = Pumps
Add metadata tag properties by clicking the 'TAG PROPERTIES' button in the top right corner. Some tag properties like 'Description' and 'Eng Units' are in the dropdown box and can be selected and then added by clicking the 'ADD' button. Others will need typed exactly as they are listed. Ensure you follow the same order as they appear below before clicking 'APPLY'. Tag Properties should be in the following order and maintain case sensitivity:
Description
Eng Units
Model
Horsepower
Tank Height
Download CSV file ‘Hays Logging Configuration’
Open in Excel and select the 'Hays Pumps' sheet. Copy the contents to your clipboard without including the header row by selecting the entire table except row 1. Do not select the entire rows, only the columns and rows that have data within them.
In OPC configuration select ‘Paste New’
Click 'APPLY' to save your changes.
Create Towers Group
Create New Group and name = Towers
Use the sheet ‘Hays Towers’ in your open CSV file to import the logging configuration as you just did above.
In OPC configuration select ‘Paste New’
Click 'APPLY' to save your changes.
Begin Logging
- Apply all changes
- Select lower tab 'Status'
- Enable logging by clicking the 'Play' button on the 'Hays' panel
Again, verify data is flowing for this newly created logging session through the Sender and into the Canary Historian you have targeted.
Logging Data Via MQTT
We will create two different MQTT logging sessions, each targeting a different Canary DataSet. If you are already confident in all of the steps below you can simply import the included MQTTCollector.sqlite file into the C:\ProgramData\Canary Labs\Desktop\Bootcamp - Data Logging\ProgramData_Canary\Logger\StoreAndForward\MQTTCollector directory.
MQTT Collector – Comal WD
- Open Canary Admin application
- Select MQTT Collector tile
- Click 'Configuration' from the lower tab menu
Group Configuration
Create new Connection Group by selecting the '+' icon and edit the following Group fields:
- Set Name to = Comal WD
- MQTT Client ID = generate random ID using 'generate' icon to the right of dialogue box
- Primary Application = true
- Request Device Births = true
Server Configuration
Note, if you are using your own local instance rather than the Canary AWS MQTT server you will use port 1883 and leave username and password blank. If you are using 8883 locally enter the appropriate username and password rather than the ones we have provided.
Select the default Servers that was created 'tcp://localhost:1883' from the left and edit the following Server fields:
- URI = tcp://datagen.canarylabs.online:8883/
- Username = Bootcamp
- Password = SirYesSir!
- Reconnect Interval = 00:01:00
- Keep Alive = 30
- Clean Session = true
- Enable SSL/TLS = true
- Self signed certificate = true
- Client certificate = false
Subscriptions Configuration
Select the default Subscriptions that was created 'spBv1.0/#' from the left and edit the following Subscription fields:
- Topic = spBv1.0/#
- QOS = At Most Once (QoS = 0)
- Enabled = true
- Dataset Prefix = Comal
- Tags Per DataSet = 25000
- Remove tag name prefix = 3
- Automatically Log All Tags = true
- Sync historian tags with births = false
Sender Sessions
Select the default 'localhost' Sender Sessions that was created from the left and edit the following fields:
- Historian = localhost
- Enabled = true
- External Property Storage = false
Filters
Create a filter:
- Select the '+' icon beside 'Filters'
- Expression = ^Comal
- Exclude = false
Begin Logging
- Apply all changes
- Select lower tab 'Status'
- Enable session
- Select lower tab 'Configuration'
- Select 'Tags' and confirm results
You can verify data is being logged by looking at the Sender tab in the Canary Admin. You will see the session and will also be able to see data values updating in the Canary Historian tile.
MQTT Collector – Guadalupe WD
- Open Canary Admin application
- Select MQTT Collector tile
- Click 'Configuration' from the lower tab menu
Group Configuration
Create new Connection Group by selecting the '+' icon and edit the following Group fields:
- Set Name to = Guadalupe WD
- MQTT Client ID = generate random ID using 'generate' icon to the right of dialogue box
- Primary Application = true
- Request Device Births = true
Server Configuration
Note, if you are using your own local instance rather than the Canary AWS MQTT server you will use port 1883 and leave username and password blank.If you are using 8883 locally enter the appropriate username and password rather than the ones we have provided.
Select the default Servers that was created 'tcp://localhost:1883' from the left and edit the following Server fields:
- URI = tcp://datagen.canarylabs.online:8883/
- Username = Bootcamp
- Password = SirYesSir!
- Reconnect Interval = 00:01:00
- Keep Alive = 30
- Clean Session = true
- Enable SSL/TLS = true
- Self signed certificate = true
- Client certificate = false
Subscriptions Configuration
Select the default Subscriptions that was created 'spBv1.0/#' from the left and edit the following Subscription fields:
- Topic = spBv1.0/#
- QOS = At Most Once (QoS = 0)
- Enabled = true
- Dataset Prefix = Guadalupe
- Tags Per DataSet = 25000
- Remove tag name prefix = 3
- Automatically Log All Tags = true
- Sync historian tags with births = false
Sender Sessions
Select the default 'localhost' Sender Sessions that was created from the left and edit the following fields:
- Historian = localhost
- Enabled = true
- External Property Storage = false
Filters
Create a filter:
- Select the '+' icon beside 'Filters'
- Expression = ^Guadalupe
- Exclude = false
Begin Logging
- Apply all changes
- Select lower tab 'Status'
- Enable session
- Select lower tab 'Configuration'
- Select 'Tags' and confirm results
You can verify data is being logged by looking at the Sender tab in the Canary Admin. You will see the session and will also be able to see data values updating in the Canary Historian tile.
3 replies
-
Tried starting this exercise today. License good, install good, but getting an error saying "Oops, an error occurred while browsing nodes on the opc server host: opc.tcp://datagen.canarylabs.online:49320, port: 0. Check connection settings."
Is there an issue with the Kepserver or is it an issue on my side? -
Hi,
Just tested now and ok on my side. check your firewall settings or other active device between your canary server and the cloud hosted key server.