Cicode Programming Reference > Cicode Function Categories > Trend Functions Introduction > TrnEventGetTableMS


Stores event trend data and time data (including milliseconds) for a specified trend tag. The event trend data is stored in an event table, and the time stamp in time tables. Data is stored at the specified Period, working backwards from the starting point specified by EventNo. If Period differs from the trend period configured in the Trend Tags database, the values to be stored are calculated from the trend data. Values are either averaged or interpolated.

This function is a blocking function. It blocks the calling Cicode task until the operation is complete.


TrnEventGetTableMS(Tag, EventNo, Period, Length, Table, TimeTable, Mode, MSTimeTable [, ClusterName] )


The trend tag enclosed in quotation marks "" (can be prefixed by the name of the cluster that is ClusterName.Tag).


The starting event number for entries in the trend table.


The time difference between tabulated trend values (in seconds). For example, if you set this period to 30 seconds, CitectSCADA will get the last trend value (sampled at the end of the trend section), then get the trend value that was sampled 30 seconds before that, and so on until it reaches the start time of the trend section.

If this period is different to the trend's sampling period, the trend values will be averaged or interpolated. Set to 0 (zero) to default to the actual trend period.


The number of trend values to store in the trend table, from 1 to the maximum number of items in the table.


The Cicode array in which the trend data is stored. You can enter the name of an array here (see the example).


The table of integer values in which the time stamp is stored.


The Display Mode parameters allow you to enter a single integer to specify the display options for a trend (for a maximum of eight trends).

To calculate the integer that you should enter for a particular trend, select the options you wish to use from those listed below, adding their associated numbers together. The resulting integer is the DisplayMode parameter for that trend.

Invalid/Gated trend options:

0 - Convert invalid/gated trend samples to zero.

1 - Leave invalid/gated trend samples as they are.

Ordering trend sample options:

0 - Order returned trend samples from oldest to newest.

2 - Order returned trend samples from newest to oldest.

Condense method options:

0 - Set the condense method to use the mean of the samples.

4 - Set the condense method to use the minimum of the samples.

8 - Set the condense method to use the maximum of the samples.

Stretch method options:

0 - Set the stretch method to step.

128 - Set the stretch method to use a ratio.

256 - Set the stretch method to use raw samples.

Gap Fill Constant option:

n - the number of missed samples that the user wants to gap fill) x 4096.

Note: Options listed in each group are mutually exclusive. The default value for each Display Mode is 258 (0 + 2 + 256).


The table of integer values in which the millisecond component of the time stamp is stored.


The name of the cluster in which the trend tag resides. This is optional if you have one cluster or are resolving the trend via the current cluster context. The argument is enclosed in quotation marks "".

Return Value

The actual number of samples read. The return value is 0 if an error is detected. You can call the IsError() function to get the actual error code.

Related Functions

TrnEventSetTableMS TrnGetEvent, TrnEventGetTable

See Also

Trend Functions