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.
Function | Description |
---|---|
AnnotationCount | Retrieve the number of Annotations in the interval. |
Average | Retrieve the average value of the data over the interval. |
Count | Retrieve the number of raw values over the interval. |
Delta | Retrieve the difference between the Start
and End values in the interval. |
DeltaBounds | Retrieve the difference between the
StartBound and
EndBound values in the interval. |
DurationBad | Retrieve the total duration of time in the interval during which the data is bad. |
DurationGood | Retrieve the total duration of time in the interval during which the data is good. |
DurationInStateNonZero | Retrieve the time a Boolean or numeric was in a nonzero state using Simple Bounding Values. |
DurationInStateZero | Retrieve the time a Boolean or numeric was in a zero state using Simple Bounding Values. |
End | Retrieve the value at the end of the interval using Interpolated Bounding Values. |
EndBound | Retrieve the value at the end of the interval using Simple Bounding Values. |
Interpolative | At the beginning of each interval, retrieve the calculated value from the data points on either side of the requested timestamp. |
Maximum | Retrieve the maximum raw value in the interval with the timestamp of the start of the interval. |
Maximum2 | Retrieve the maximum value in the interval including the Simple Bounding Values. |
MaximumActualTime | Retrieve the maximum value in the interval and the timestamp of the maximum value. |
MaximumActualTime2 | Retrieve the maximum value with the actual timestamp including the Simple Bounding Values. |
Minimum | Retrieve the minimum raw value in the interval with the timestamp of the start of the interval. |
Minimum2 | Retrieve the minimum value in the interval including the Simple Bounding Values. |
MinimumActualTime | Retrieve the minimum value in the interval and the timestamp of the minimum value. |
MinimumActualTime2 | Retrieve the minimum value with the actual timestamp including the Simple Bounding Values. |
NumberOfTransitions | Retrieve the number of changes between zero and nonzero that a Boolean or Numeric value experienced in the interval. |
PercentBad | Retrieve the percent of data (0 to 100) in the interval which has bad StatusCode. |
PercentGood | Retrieve the percent of data (0 to 100) in the interval which has good StatusCode. |
Range | Retrieve the difference between the Minimum
and Maximum values over the interval. |
Range2 | Retrieve the difference between the Minimum2
and Maximum2 values over the interval. |
StandardDeviationPopulation | Retrieve the standard deviation for the interval for a complete population (n) which includes Simple Bounding Values. |
StandardDeviationSample | Retrieve the standard deviation for the interval for a sample of the population (n-1). |
Start | Retrieve the value at the beginning of the interval using Interpolated Bounding Values. |
StartBound | Retrieve the value at the beginning of the interval using Simple Bounding Values. |
TimeAverage | Retrieve the time weighted average data over the interval using Interpolated Bounding Values. |
TimeAverage2 | Retrieve the time weighted average data over the interval using Simple Bounding Values. |
Total | Retrieve the total (time integral) of the data over the interval using Interpolated Bounding Values. |
Total2 | Retrieve the total (time integral) of the data over the interval using Simple Bounding Values. |
VariancePopulation | Retrieve the variance for the interval as calculated by the
StandardDeviationPopulation which includes
Simple Bounding Values. |
VarianceSample | Retrieve the variance for the interval as calculated by the
StandardDeviationSample . |
WorstQuality | Retrieve the worst StatusCode of data in the interval. |
WorstQuality2 | Retrieve the worst StatusCode of data in the interval including the Simple Bounding Values. |