JavaScript is off. Many parts of this site require JavaScript to function properly.

Collecting Data Through the Canary API

10:23 AM


Bringing data into a historian and then later attempting to access that data and move it to another system can sometimes be a challenge.  The Canary Logger is designed to connect to your data sources through an OPC server and then delivers data to several clients through web services.

However, if you would like to do more or connect in other manners, we have made it easy by offering a very easy to use API.

Canary Sender API

Overview
The purpose of the “Store & Forward” application is to send data from remote locations to a secondary machine that will then push the data into the Canary Enterprise Historian. The application consists of two web services that communicate with each other through a specified port. The names of the two services are the “Sender Service” and the “Receiver Service”.

Sender Service
The “Sender Service” is a .NET WCF application. An application will use this service to send data to the Historian to be stored. Best practice is to place the “Sender Service” on the machine with the logging application. This service will buffer data that is passed into it and forward it to a specified “Receiver Service” when the connection is available. There are fail safes in place to protect the data when connections are lost. The data will not be removed from the buffer until it receives a response from the “Receiver Service” confirming that it can release the data.
Any web service compatible client can communicate with the service using the http protocol. The default port that the “Sender Service” uses is port 55251. A different port can be specified in the “Sender Service” SAF_SenderService.exe.config file if necessary. In addition, a .NET WCF application running on the same machine as the “Sender Service” can communicate with the service using the net.pipe protocol.
An html page that shows the “Sender Service” status can be viewed on the “Sender Service” local machine’s browser at http://localhost:55251/saf/sender/status. This page will display the number of clients hooked up to the “Sender Service” and information specific to each session. Information includes the session id, logging status, initial “Receiver Service” connection time, number of tags being logged, number of tvqs in buffer, number of properties in buffer, number of annotations in buffer, number of errors, and the last error message that occurred.

Receiver Service
The “Receiver Service” is used by the “Sender Service” to put data into the Canary Enterprise Historian. A client application cannot use the “Receiver Service” directly.
The “Receiver Service” must be located on a machine that also has the Canary Enterprise Historian software installed on it. This is necessary because the “Receiver Service” pushes data into the Historian through a local interface. When data has been successfully stored in the Historian a response will be sent back to the “Sender Service” to clear the data from the “Sender Service” buffer.
The default port that the “Receiver Service” uses is port 55254 for http and 55256 for net.tcp. A different port can be specified in the “Receiver Service” SAF_ReceiverService.exe.config file if necessary. The “Sender Service” always uses the net.tcp to communicate with the “Receiver Service”.
An html page that shows the “Receiver Service” status can be viewed on the “Receiver Service” local machine’s browser at http://localhost:55254/saf/receiver/status. This page will display the number of clients hooked up to the “Receiver Service” and information specific to each session. Information includes the session id, initial “Sender Service” connection time, number of tags being logged, number of tvqs that have been written to the historian, number of properties that have been written to the historian, number of annotations that have been written historian, number of errors, and the last error message that occurred.

Helper Class
A .NET helper class has been created for the “Store & Forward” application. The purpose of the helper class is to provide an additional interface for .NET applications that can simplify use of the “Store & Forward” technology. It can help simplify the connection process and provides a variety of overloads for each of the interface methods.

Transform Equation
Transform equations can be used to transform values as they are being logged. Each tag can be configured with its own transform equation string. The transform calculations use a library called NCalc to parse the equation string provided where the keyword “Value” is replaced with the passed in tvq value and the calculation is then executed. As an example, the transform equation string “Value * 1000” will multiply each value for the specified tag by 1000.

Time Extension
Time extension is used to extend the time for the last value of a tag if the tag is still logging but a new value has not been stored for an extended amount of time. If a time extension for a tag is set to 15 seconds and the last value has not changed in the last 15 seconds the value will be updated with a current timestamp. If a tag value is then stored with a timestamp that occurred before the extended timestamp but after the timestamp at the start of the last value, the extended value will be modified to reflect the corrected timestamp.

Buffer Files
Default buffer files will be placed on the “Sender Service” machine in the path “ProgramData/Canary Labs/Logger/StoreAndForward/SenderService/{historian}/{client id}” where the {historian} and {client id} are the historian and client ids that get passed to the “Sender Service” when the session is initialized through the GetSessionId method request. Buffer files get cleaned up automatically, but the paths to the files will be left intact.

Error Logs

An error log containing all “Sender Service” and “Receiver Service” errors will be created on each machine. The default error log file path will be “ProgramData/Canary Labs/Logger/StoreAndForward/{service}/{service}.log” where {service} will be either “SenderService” or “ReceiverService”.

No comments:

Post a Comment

arrow_upward