Main Content

OPC UA Aggregate Functions

Introduction

OPC UA servers can return historical data as an aggregate of some function performed on the data history at particular periods. When you request processed data using the readProcessed function, you specify an Aggregate to use, and an Aggregate Interval of time over which to perform that Aggregate function. The server then performs the Aggregate function on each period of Aggregate Interval defined, returning one value associated with all the data in that interval. For example, the "Maximum" Aggregate Function returns the maximum value in the Aggregate Interval; the Range Aggregate Function returns the difference between the highest and lowest value in the aggregate interval.

OPC UA Aggregates are represented in MATLAB® by a character vector defining the Aggregate Function, or by the opc.ua.AggregateFnId enumeration class. For example, to specify that a readProcessed operation use the Maximum Aggregate Function, you can use either of the following syntaxes:

readProcessed(UaClient,NodeList,'Maximum',...)
readProcessed(UaClient,NodeList,opc.ua.AggregateFnId.Maximum,...)

Available Aggregate Functions on an OPC UA Server

When an OPC UA Client is connected to an OPC UA server, the client’s AggregateFunctions property stores a list of aggregate functions supported by that server. Servers need not implement every Aggregate Function defined by the OPC UA Standard, but must publish the Aggregate Functions that are supported by that server. Use the AggregateFunctions property to ensure that the aggregate function you need is supported by the server. Note, however, that the server might not implement that function for all Variable nodes on the server. If you attempt to retrieve processed data from the server, you might get an "Unsupported Aggregate Function" error, even if the aggregate function is reported as being supported by the server.

OPC UA Standard Aggregate Functions

The following functions are defined by the OPC Foundation.

FunctionDescription
AnnotationCountRetrieve the number of Annotations in the interval.
AverageRetrieve the average value of the data over the interval.
CountRetrieve the number of raw values over the interval.
DeltaRetrieve the difference between the Start and End values in the interval.
DeltaBoundsRetrieve the difference between the StartBound and EndBound values in the interval.
DurationBadRetrieve the total duration of time in the interval during which the data is bad.
DurationGoodRetrieve the total duration of time in the interval during which the data is good.
DurationInStateNonZeroRetrieve the time a Boolean or numeric was in a nonzero state using Simple Bounding Values.
DurationInStateZeroRetrieve the time a Boolean or numeric was in a zero state using Simple Bounding Values.
EndRetrieve the value at the end of the interval using Interpolated Bounding Values.
EndBoundRetrieve the value at the end of the interval using Simple Bounding Values.
InterpolativeAt the beginning of each interval, retrieve the calculated value from the data points on either side of the requested timestamp.
MaximumRetrieve the maximum raw value in the interval with the timestamp of the start of the interval.
Maximum2Retrieve the maximum value in the interval including the Simple Bounding Values.
MaximumActualTimeRetrieve the maximum value in the interval and the timestamp of the maximum value.
MaximumActualTime2Retrieve the maximum value with the actual timestamp including the Simple Bounding Values.
MinimumRetrieve the minimum raw value in the interval with the timestamp of the start of the interval.
Minimum2Retrieve the minimum value in the interval including the Simple Bounding Values.
MinimumActualTimeRetrieve the minimum value in the interval and the timestamp of the minimum value.
MinimumActualTime2Retrieve the minimum value with the actual timestamp including the Simple Bounding Values.
NumberOfTransitionsRetrieve the number of changes between zero and nonzero that a Boolean or Numeric value experienced in the interval.
PercentBadRetrieve the percent of data (0 to 100) in the interval which has bad StatusCode.
PercentGoodRetrieve the percent of data (0 to 100) in the interval which has good StatusCode.
RangeRetrieve the difference between the Minimum and Maximum values over the interval.
Range2Retrieve the difference between the Minimum2 and Maximum2 values over the interval.
StandardDeviationPopulationRetrieve the standard deviation for the interval for a complete population (n) which includes Simple Bounding Values.
StandardDeviationSampleRetrieve the standard deviation for the interval for a sample of the population (n-1).
StartRetrieve the value at the beginning of the interval using Interpolated Bounding Values.
StartBoundRetrieve the value at the beginning of the interval using Simple Bounding Values.
TimeAverageRetrieve the time weighted average data over the interval using Interpolated Bounding Values.
TimeAverage2Retrieve the time weighted average data over the interval using Simple Bounding Values.
TotalRetrieve the total (time integral) of the data over the interval using Interpolated Bounding Values.
Total2Retrieve the total (time integral) of the data over the interval using Simple Bounding Values.
VariancePopulationRetrieve the variance for the interval as calculated by the StandardDeviationPopulation which includes Simple Bounding Values.
VarianceSampleRetrieve the variance for the interval as calculated by the StandardDeviationSample.
WorstQualityRetrieve the worst StatusCode of data in the interval.
WorstQuality2Retrieve the worst StatusCode of data in the interval including the Simple Bounding Values.