Skip to main content

History Model (History)

OPC UA's historical access and aggregation query mechanism lets clients read time-series data and events stored in the server-side Historian.

Server Capabilities

The server must support Historian (historical archives) to return historical data; otherwise, it will return a uniform response BadHistoryOperationUnsupported.

Further Reading

HistoryRead 5 Modes​

OPC UA breaks "reading history" down into 5 requests with different meanings:

ReadRawModified — All data points within the time interval​

Most commonly used. Given a [startTime, endTime] range, return all data points (including timestamps, values, and status).

Time:    0s   1s   2s   3s   4s   5s
Value: 10 12 15 18 17 20
↑ ↑
start end

Return: 12, 15, 18, 17, 20 (5 points)

ReadAtTime — Interpolation at a specified time point​

Given a set of discrete time points, the server returns the value at that time using algorithms such as "previous/next/linear interpolation." This is suitable for "time series alignment":

Request times: 0.5s, 1.5s, 2.5s
Returned: between 10 and 12, between 12 and 15, between 15 and 18 (decided by the Server-side interpolation rules)

ReadProcessed — Aggregation​

Given a range, an aggregate function, and subranges, the server returns the aggregate results for each subrange.

Currently available SDK aggregate functions:

  • Average — Arithmetic mean of the values in the interval
  • Minimum / Maximum — Minimum / Maximum in the Interval
  • Count — Number of data points with a "Good" status within the interval
  • Total — Sum of values within an interval (algebraic sum)
  • StandardDeviationSample — Sample standard deviation
  • TimeAverage — Time-Weighted Average
  • Range — Within the range (Max − Min)
  • Delta — End of Interval − Start of Interval

Example: "Check the hourly maximum temperatures over the past 24 hours":

  • start = 0h yesterday, end = 0h today
  • aggregate = Maximum
  • processingInterval = (3600000 ms 1 hour)
  • → Returns 24 values

ReadEvents — Event History​

The server can log event history, and the client can pull historical events by time range:

var events = ua.ReadHistoryEvents(
"i=2253",
start: now.AddDays(-1),
end: now,
maxEvents: 0);

Each event includes Severity / Message / SourceName / Time /EventType. Filtering by Severity is performed by the caller.

ReadModified — Includes revision history​

If the server allows HistoryUpdate a revision history, this mode can retrieve "modified versions." The revision metadata stored on the server is not currently exposed; only the values, status, and timestamps of each record are revealed. This is intended for regulatory audit scenarios.

HistoryUpdate​

ua.UpdateHistory(nodeId, HistoryUpdateType.Insert,  values);  // Insert
ua.UpdateHistory(nodeId, HistoryUpdateType.Replace, values); // Replace
ua.UpdateHistory(nodeId, HistoryUpdateType.Update, values); // Insert or Replace
ua.UpdateHistory(nodeId, HistoryUpdateType.Remove, values); // Press SourceTimestamp Delete
ua.DeleteHistoryRange(nodeId, start, end); // Delete by Time Period

Annotations for historical points and deletion by event are not currently available.

HistoryUpdate Disabled by default

Most production servers have this feature disabled by default HistoryUpdate; an administrator must explicitly enable it.

Node's "Historizing" Attribute​

The Historizing (20) Attribute of a Variable node indicates whether the node is currently recording history. true = recording; false = not recording (in which case ReadHistory may return null).

If a node does not have sufficient access permissions, the server will deny the request HistoryRead.

Performance Notes​

  • The history read operation does not currently support resuming a read; use maxValues to control the number of records returned per request (0 = unlimited; the upper limit is determined by the server).
  • For large ranges, be sure to add maxValues or use ReadHistoryProcessed aggregation.