CtAPITrend
- Last UpdatedJul 13, 2023
- 2 minute read
Provides an interface into the trend archive from external applications, replacing the old CtAPITrend query. For performance improvements, use the TrnQuery function instead.
To establish the query and return the first record, you call ctFindFirst. Then, to browse the remaining records, you call ctFindNext. To access the data of the current record, ctGetProperty is called for each field of the record.
ctFindFirst is called with the following parameters:
-
hCtapi: handle to a valid Ctapi client instance.
-
szTableName: command string for the Trnquery, see below.
-
szFilter: Not used for Trnquery. Just pass in NULL.
-
hObject: handle to the first record retrieved for the query.
-
dwFlags: Not used for Trnquery. Just pass in 0.
The szTableName is the command string for the query. It contains the parameters for the query.
Syntax
CTAPITrend(sTime,sDate,Period,Length,Mode,Tag)
Note: Arguments needs to be comma-separated. Spaces between arguments are supported but not necessary. We recommend no spaces between arguments as they require more processing and take up more space in the query string.
sTime:
The starting time for the trend. Set the time to an empty string to search the latest trend samples.
sDate:
The date of the trend.
Period:
The period (in seconds) that you want to search (this period can differ from the actual trend period).
The Period argument used in the CTAPITrend() function needs to be 0 (zero) when this function is used as an argument to ctFindFirst() for an EVENT trend query.
Length:
The length of the data table, i.e. the number of rows of samples to be searched.
Mode:
The format mode to be used:
Periodic trends
1 - Search the Date and Time, followed by the tags.
2 - Search the Time only, followed by the tags.
3 - Ignore any invalid or gated values. (This mode is only supported for periodic trends.)
Event trends
1 - Search the Time, Date, and Event Number, followed by the tags.
2 - Search the Time and Event Number, followed by the tags.
Tag:
The trend tag name for the data to be searched.
To simplify the passing of this argument, you could first pass the CTAPITrend() function as a string, then use the string as the szTableName argument (without quotation marks).