Skip to main content

readHistoryProcessed (Aggregation)

HistoryRead Aggregation mode, combined with standard aggregation functions. Given an interval, an aggregation function, and a subinterval width, the server returns the aggregation results for each subinterval.

Preliminary / Supporting
  • To pull all original points, please use ReadRaw.
  • For interpolation at a specific point in time, please use ReadAtTime.
  • Standard Aggregation NodeId Constants in HistoryAggregate Class.

Signature​

public List<OpcUaDataValue> readHistoryProcessed(
String nodeId,
Instant start,
Instant end,
double processingIntervalMs,
String aggregateNodeId);

HistoryAggregate Standard Aggregation Constants​

ConstantsNodeIdMeaning
HistoryAggregate.AVERAGEi=2342Arithmetic Mean
HistoryAggregate.MINIMUMi=2346Minimum Value
HistoryAggregate.MAXIMUMi=2347Maximum value
HistoryAggregate.COUNTi=2352Good Status Points
HistoryAggregate.TOTALi=2348Cumulative Total
HistoryAggregate.STANDARD_DEVIATION_SAMPLEi=11427Sample standard deviation
HistoryAggregate.TIME_AVERAGEi=11285Time-Weighted Average
HistoryAggregate.RANGEi=2353Max − Min
HistoryAggregate.DELTAi=11286End of Interval − Start of Interval

For a complete list, see the OPC UA Aggregate Functions Standard (Part 13 §5.4).

Usage​

Hourly average of the 24-hour temperature​

import java.time.Instant;
import java.time.Duration;

List<OpcUaDataValue> values = ua.readHistoryProcessed(
"ns=2;s=Temperature",
Instant.now().minus(Duration.ofDays(1)),
Instant.now(),
3_600_000.0, /* 1 hour */
HistoryAggregate.AVERAGE);
// Returns 24 values OpcUaDataValue, each representing the average for that hour
try {
for (OpcUaDataValue dv : values) {
if (dv != null) System.out.println(dv.variant());
}
} finally {
for (OpcUaDataValue dv : values) if (dv != null) dv.close();
}

Highest Temperature Each Day of the Week​

List<OpcUaDataValue> maxes = ua.readHistoryProcessed(
"ns=2;s=Temperature",
today.minus(Duration.ofDays(7)),
today,
86_400_000.0, /* 1 day */
HistoryAggregate.MAXIMUM);

Total traffic in one hour​

List<OpcUaDataValue> totals = ua.readHistoryProcessed(
"ns=2;s=FlowRate",
Instant.now().minus(Duration.ofHours(1)),
Instant.now(),
3_600_000.0,
HistoryAggregate.TOTAL);

Performance Advantages​

  • Eliminate the transmission of the origin and the client's secondary calculations
  • The server performs aggregations directly on the historical database, eliminating the need to transfer raw data.
  • Standard Practices for Cross-Day/Cross-Week Reports

Server Requirements​

  • Historian must implement this aggregate function (the supported functions are listed in the ServerCapabilities/AggregateFunctions column on the server).
  • Unsupported aggregations typically return BadHistoryOperationUnsupported or BadNotSupported; Aggregation-specific status codes are not currently available.

Next Step​