The "Trend API Example" demonstrates how the
VisuTrendStorageAccess library provides function blocks for reading trend data. This document illustrates how to use the library.
The sample project demonstrates how trend data can be read by means of the
VisuTrendStorageAccess library. In this example, trend data is saved by the trend recording manager and then read as ST code by the
In addition to querying historical data, active messaging is also possible when saving new data. The trend data can then be exported (example: CSV file) for later processing by other applications, for example by using the IIoT Libraries SL from the CODESYS Store.
In the sample project "TrendStorage API Example.project", four tasks are defined.
ITrendStorageWriterListener interface is used for active messaging of new data. For this purpose,
TrendStorageWriterListener function block implements the
ITrendStorageWriterListener interface and is
registered for the
TrendStorageReader function block. If new data has been saved, then the
is called with the start and end time stamps and the number of saved data records.
TrendStorageReader and the
Read method are used for searching for data records.
eError2 := instTrendStorageReader.Read( liTimstampFrom := liTimstampFrom2, liTimstampTo := liTimstampTo2, itfTrendStorageReaderConsumer := instTrendStorageReaderConsumer);
ValueRead methods are then called automatically for each value.
In the example, the
TrendStorageReaderConsumer function block implements the
interface and writes the values to the controller console in CSV format. If the size of the returned data would
block the database too long, then
ETrendStorageReaderErrors.AdditionalReadCallRequired is returned as error code
and the read process must be continued at a later time by calling the
ContinueReading method with the same parameters.
Description of the visualization
The simulated signals are displayed in a trend element in the upper area of the visualization.
DataWrittenmethod are displayed in "New Data" (see Figure 2).
The start time stamp is displayed in the upper field and the end time stamp in the lower field.
The "Compute timestamps" button converts the specified data into the corresponding time stamp (reverse function:
"Compute date/time"). Then the search can be started by clicking the "Read Trend Storage" button.
Clicking "Stop Reading" will cancel the read process. If the "Detailed output" button is active, then the data
is printed to the controller console (do not start CODESYS Control Win V3 via SysTray).
Otherwise, the number of data records is displayed in the "count rows" field.
|System requirements and restrictions||Info|
|Programming System||CODESYS Development System Version 126.96.36.199 or higher|
|Runtime System||CODESYS Control Version 188.8.131.52|