5 Aggregate specific usage of Services
5.4 Aggregate details
5.4.2 Common characteristics
5.4.2.1 Description
Subclause 5.4.2 deals with Aggregate characteristics and behaviour that are common to all Aggregates.
5.4.2.2 Generating intervals
To read Historical Aggregates, OPC clients shall specify three time parameters:
 startTime (Start)
 endTime (End)
 ProcessingInterval (Int) The OPC Server shall use these three parameters to generate a sequence of time intervals and then calculate an Aggregate for each interval. Subclause 5.4.2.2 specifies, given the three parameters, which time intervals are generated. Table 12 provides information on the intervals for each Start and End time combination. The range is defined to be End  Start.
All Aggregates return a timestamp of the start of the interval unless otherwise noted for the particular Aggregate.
Table 12 – History Aggregate interval information
Start/End Time  Interval  Resulting intervals 

Start = End  Int = Anything  No intervals. Returns a Bad_InvalidArgument StatusCode, regardless of whether there is data at the specified time or not. 
Start < End  Int = 0 or Int ≥ Range  One interval, starting at Start and ending at End. Includes Start, excludes End, i.e., [Start, End). 
Start < End  Int ≠ 0, Int < Range, Int divides Range evenly.  Range/Int intervals. Intervals are [Start, Start + Int), [Start + Int, Start + 2 x Int),…, [End  Int, End). 
Start < End  Int ≠ 0, Int < Range, Int does not divide Range evenly.  (Range/Int( intervals. Intervals are [Start, Start + Int), [Start + Int, Start + 2 x Int),…, [Start + ( (Range/Int(  1) x Int, Start + (Range/Int( x Int), [Start + (Range/Int( x Int, End). In other words, the last interval contains the “rest” that remains in the range after taking away (Range/Int( intervals of size Int. 
Start > End  Int = 0 or Int ≥ Range  One interval, starting at Start and ending at End. Includes Start, excludes End, i.e.,[Start, End). a 
Start > End  Int ≠ 0, Int < Range, Int divides Range evenly.  Range/Int intervals. Intervals are [Start, Start Int), [Start– Int, Start – 2 x Int),…, [End + Int, End). a 
Start > End  Int ≠ 0, Int < Range, Int does not divide Range evenly.  (Range/Int( intervals. Intervals are [Start, Start  Int), [Start –Int,Start  2 x Int),…, [Start – ( (Range/Int(  1) x Int , Start  (Range/Int( x Int), [Start  (Range/Int( x Int , End). In other words, the last interval contains the “rest” that remains in the range after taking away (Range/Int( intervals of size Int starting at Start. a 
a In this case time is running backwards on the intervals. 
The calculation of all Aggregates when time flows backwards is the same as when time flows forwards with the exception that the ‘early time’ is excluded from the interval and the ‘late time’ is included. In most cases this means the value will be the same except the timestamps are shifted by one ProcessingInterval. E.g. when time flows forward the value at T = n is the same as the value at T = n + 1 when time flows backward.
Note that when determining Aggregates with MonitoredItem, the interval is simply the ProcessingInterval parameter as defined in the AggregateFilter structure. See OPC 100004 for more details.
5.4.2.3 Data types
Table 13 outlines the valid DataType for each Aggregate. Some Aggregates are intended for numeric data types – i.e. integers or real/floating point numbers. Dates, strings, arrays, etc. are not supported. Other Aggregates are intended for digital data types – i.e. Boolean or enumerations. In addition some Aggregates may return results with a different DataType than those used to calculate the Aggregate . Table 13 also outlines the data type returned for each Aggregate .
Table 13 – Standard History Aggregate Data Type information
BrowseName  Valid Data Type  Result Data Type 

Interpolation Aggregate  
Interpolative  Numeric  Raw Data Type 
Data Averaging Aggregates  
Average  Numeric  Double 
TimeAverage  Numeric  Double 
TimeAverage2  Numeric  Double 
Total  Numeric  Double 
Total2  Numeric  Double 
Data Variation Aggregates  
Minimum  Numeric  Raw data type 
Maximum  Numeric  Raw data type 
MinimumActualTime  Numeric  Raw data type 
MaximumActualTime  Numeric  Raw data type 
Range  Numeric  Raw data type 
Minimum2  Numeric  Raw data type 
Maximum2  Numeric  Raw data type 
MinimumActualTime2  Numeric  Raw data type 
MaximumActualTime2  Numeric  Raw data type 
Range2  Numeric  Raw data type 
Counting Aggregates  
AnnotationCount  All  Integer 
Count  All  Integer 
DurationInStateZero  Numeric or Boolean  Duration 
DurationInStateNonZero  Numeric or Boolean  Duration 
NumberOfTransitions  Numeric or Boolean  Integer 
Time Aggregates  
Start  All  Raw data type 
End  All  Raw data type 
Delta  Numeric  Raw data type 
StartBound  All  Raw data type 
EndBound  All  Raw data type 
DeltaBounds  Numeric  Raw data type 
Data Quality Aggregates  
DurationGood  All  Duration 
DurationBad  All  Duration 
PercentGood  All  Double 
PercentBad  All  Double 
WorstQuality  All  StatusCode 
WorstQuality2  All  StatusCode 
Statistical Aggregates  
StandardDeviationSample  Numeric  Double 
VarianceSample  Numeric  Double 
StandardDeviationPopulation  Numeric  Double 
VariancePopulation  Numeric  Double 
5.4.2.4 Time calculation issues
The following issues may come up when calculating Aggregates that include time as part of the calculation.

All Aggregate calculations include the startTime but exclude the endTime. However, it is sometimes necessary to return an Interpolated End Bound as the value for an Interval with a timestamp that is in the Interval. Servers are expected to use the time immediately before endTime where the time resolution of the Server determines the exact value (do not confuse this with hardware or operating system time resolution). For example, if the endTime is 12:01:00, the time resolution is 1 second, then the EffectiveEndTime is 12:00:59. If the Server time resolution is 1 millisecond the EffectiveEndTime is 12:00:59.999. If time is flowing backwards, Servers are expected to use the time immediately after endTime where the time resolution of the Server determines the exact value.

If there is one data point in the Interval and it falls on the StartTime the time duration used in calculations is one unit of the time resolution of the Server.