You are here: Core Reference > Coding > Logic > Processed Historic Values in ST Programs (Historic Data Arrays)

Processed Historic Values in ST Programs (Historic Data Arrays)

You can use processed historic data values in your ST programs.

An ST program can be used to retrieve processed historic data from the ClearSCADA database and return the processed values into a historic array.

Historic arrays allow a Logic program to use multiple historic values as inputs. The array acts as a table, with each returned value occupying one row of the table. You can then use your ST program Logic to use the returned values.

NOTE: Historic Arrays can only be used as single dimension tables with one column. Unlike arrays for current data, historic arrays cannot return values that can be used in a matrix.

When you use processed historic values in an ST program, you need to enter a variable for the array in the VAR variables list. The variable has to be defined using the following format:

<name of variable> AT %H(<path of point>.Historic;<name of historic algorithm>; <start of time range>;<frequency of values>) : ARRAY [<number of first value in range>..<number of last value in range>] OF <data type of variable>;

Example:

The following variable is used to return the average historic value for each hour in the day:

HourlyAverage AT %H(AnalogInput.Historic;Average;D-1D;1H) : ARRAY [0..23] OF LREAL;

Where HourlyAverage is the name of the variable. %H is required as this instructs the program to use historic data.

AnalogInput is the name of the point that has the historic data that the ST program is going to use. Historic;Average; indicates that the program will use the values that are stored for the point's Historic.Average tag. D-1D;1H indicates the time period for the historic data—the values for each hour (1H) starting from the beginning of yesterday (D-1D).

ARRAY [0..23] is used to instruct the program that the values will be returned as an array, and that there will be 24 values (0-23 inclusive). OF LREAL; indicates that the values in the array will be long real values.

The historic array returns 24 average values, for example,

A [0] : = 3.5;

A [1] : = 3.9;

A [3] : = 3.6;

A [4] : = 3.6;

A [5] : = 3.2;

A [6] : = 3.7;

and so on.

Each of these values can be used in the ST Program.


ClearSCADA 2015 R2