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.
5 Modes HistoryRead
Writing and Deleting
| API | Uses | Return |
|---|
| UpdateHistory | Insert / Replace / Update / Remove Historical Data | IReadOnlyList<StatusCode>(Item by item) |
| DeleteHistoryRange | Delete History by Time Period | StatusCode(Failure does not throw an exception(You must check the return value.) |
The other two entry points
| API | Location | Uses |
|---|
ReadHistorySafe(nodeId, start, end, maxValues) | Safe API | ReadHistory The "never throw exceptions" version, which returns (StatusCode Status, IReadOnlyList<DataValue> Values) |
ua.ReadHistoryStreamAsync(nodeId, startUtc, endUtc, batchSize, cancellationToken) | Streaming History Read | IAsyncEnumerable<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