Main Content

Read Processed Aggregate Data

Historians can include the ability to process raw data in a variety of ways before returning it to you. Examples of such processing include the interpolation of data points, time averaging, and standard deviation calculations. Processing of data can be very useful when there is a large amount of data on the server. Instructing the server to return only a processed data set can greatly reduce the time and volume of data transferred.

You can discover which aggregates are supported by the server by requesting the Aggregates property of a connected HDA client object:

aggTypes = clientObject.Aggregates
aggTypes = 
OPC HDA Aggregate Types:
          Name         ID                                          Description                                        
    -----------------  --  -------------------------------------------------------------------------------------------
    INTERPOLATIVE      1   Retrieve interpolated values.
    TIMEAVERAGE        4   Retrieve the time weighted average data over the resample interval.
    MINIMUMACTUALTIME  7   Retrieve the minimum value in the resample interval and the timestamp of the minimum value.
    MINIMUM            8   Retrieve the minimum value in the resample interval.
    MAXIMUMACTUALTIME  9   Retrieve the maximum value in the resample interval and the timestamp of the maximum value.
    MAXIMUM            10  Retrieve the maximum value in the resample interval.

In the previous example, the server supports six types of aggregate.

You can request processed data using the readProcessed function and passing in the ID of the aggregate required. You can retrieve the property ID using the object and the appropriate aggregate type.

clientObject.Aggregates.TIMEAVERAGE

     4

hdareadProcessed = readProcessed(clientObject, ItemList, clientObject.Aggregates.TIMEAVERAGE, ...
                      AggregateInterval, StartTime, EndTime)
hdareadProcessed = 
1-by-5 OPC HDA Data object:
       ItemID         Value           Start TimeStamp           End TimeStamp                  Quality           
    ------------  --------------  -----------------------  -----------------------  -----------------------------
    Random.Int1    1 int8 value     2010-11-28 13:56:40.666  2010-11-29 13:56:40.666  1 unique quality [Calculated]
    Random.Boolean 1 logical value  2010-11-28 13:56:40.666  2010-11-29 13:56:40.666  1 unique quality [Calculated]

The requested time domain is split into the time intervals you provide as the fourth function argument. The aggregates are calculated over these intervals.

Additionally, you can request that the data be returned as a supported MATLAB® data type. See Native MATLAB Data Types from Read Operations.