Skip to main content

History

The read, write, and delete methods of Historical Access (Part 11) are all methods on the session object ua, at the same level as Read / Write.

Subpage Redirect

5 Modes HistoryRead​

PatternAPINote
Raw DataReadHistoryOriginal points within the interval (number limited maxValues )
Modified (includes revision history)ReadHistoryModifiedThe range contains modification records
AtTime A specific point in timeReadHistoryAtTimeInterpolation for a Given Timestamp
Processed AggregationReadHistoryProcessedAggregation (Avg / Min / Max / ...)
Events HistoryReadHistoryEventsHistorical Events (Alarms / Conditions)

Writing and Deleting​

APIUsesReturn
UpdateHistoryInsert / Replace / Update / Remove Historical DataIReadOnlyList<StatusCode>(Item by item)
DeleteHistoryRangeDelete History by Time PeriodStatusCode(Failure does not throw an exception(You must check the return value.)

The other two entry points​

APILocationUses
ReadHistorySafe(nodeId, start, end, maxValues)Safe APIReadHistory The "never throw exceptions" version, which returns (StatusCode Status, IReadOnlyList<DataValue> Values)
ua.ReadHistoryStreamAsync(nodeId, startUtc, endUtc, batchSize, cancellationToken)Streaming History ReadIAsyncEnumerable<DataValue>, rendered as it streams; the only history entry point with a CancellationToken

General Prerequisites​

  • The server must support Historian. The SDK does not rewrite the server's status code — the exact code returned is decided by the server, The most common issue is BadHistoryOperationUnsupported(no Historian on the server). Except for, DeleteHistoryRange Discard any failed historical methods OpcUaException; the status code is ex.StatusCode.
  • The node's AccessLevel HistoryRead bit (0x04, bit 2) / HistoryWrite bit (0x08, bit 3) A bit must be set (using the same set of masks as "Current 0x01 Read" and "Current 0x02 Write").
  • The node's Historizing Attribute(AttributeId.Historizing = 20) indicates whether the server is currently recording a history for that node.
  • The event history also requires the ( EventNotifier AttributeId.EventNotifier = 12) of the event source node. HistoryRead Position (0x02) Set, see ReadHistoryEvents。

Consistent Implementation Restrictions​

  • Only ReadHistory built-in session-level automatic retries(Try again after reconnecting) —— Other historical methods (ReadHistoryModified / AtTime / Processed / Events / UpdateHistory / DeleteHistoryRange) No retries are performed; session-level failures result in an immediate exception or return of an error code.
  • None of them are exposed ContinuationPoint... Retrieve everything in a single call; the business side must slice large ranges on its own.
  • None Async Variants, which blocks the calling thread during synchronization.
  • CancellationToken Only ReadHistoryStreamAsync have。
  • Each item in the list is DataValue IDisposable,Mustusing Release (HistoryEventArgs is not IDisposable, you don't need to release it.)

Next Step​