ReadHistoryModified
If the server allows write history (data has been modified), ReadHistoryModified retrieve a snapshot of every modification record within that range.
Currently the SDK exposes only the DataValue entity itself (Value / Status / the two timestamps). In the OPC UA modification record,
ModificationInfo(Who made the change / When was it made / Previous value)No properties are provided..
SoCan't Use it for compliance audit traceability—all you can see is "this point was modified and changed to this value"; you can't see who made the change or the original value.
- For normal reading, please use ReadHistory。
- To write or delete history, please see UpdateHistory。
Signature
public IReadOnlyList<DataValue> ReadHistoryModified(
string nodeId,
DateTime start,
DateTime end,
uint maxValues = 0,
bool returnBounds = false);
| Parameters | Type | Default | Note |
|---|---|---|---|
| nodeId | string | — | Target; NodeId null / empty string exception ArgumentNullException |
| start | DateTime | — | Range starts at (UTC) |
| end | DateTime | — | Range Stop (UTC) |
| maxValues | uint | 0 | Maximum number of rows returned per query; 0 = no limit (passed to the server as-is) |
| returnBounds | bool | false | Whether to return the boundary values of the range (passed through to the server as-is) |
Return value and ReadHistory Same type: IReadOnlyList<DataValue>, where each record is a DataValue
(Value / Status / SourceTimestamp / ServerTimestamp).
Edit details such as "who edited it, when it was edited, and what the new type is" for each record are not SDK currently provided; only the entity DataValue itself is displayed.
DataValue The timestamp inThis data entry itself A timestamp is not the "time when a change occurred."
Usage
using System;
using DarraOpcUa_Client;
using var ua = new DarraOpcUa("opc.tcp://localhost:4840");
ua.Connect();
var today = DateTime.UtcNow;
var yesterday = today.AddDays(-1);
var modified = ua.ReadHistoryModified("ns=2;s=Temperature",
start: yesterday, end: today);
foreach (var dv in modified) using (dv)
Console.WriteLine($"{dv.SourceTimestamp:O}: {dv.Value} ({dv.Status})");
Each one is DataValue IDisposable, Must Release. To retrieve the value dv.Value.AsDouble, use, which returns
double?, pass directly to formal parameter double = CS1503 Fails to Compile。
When to Use
- Revision History: Check how many times a point has been modified within the interval, along with a snapshot of its value at each modification (information on "who modified it" and "when it was modified" is not available; see the warning above)
- Cannot be used for compliance audits: Cannot retrieve operator / operation time / previous value
Exception
| Exception | Trigger Conditions |
|---|---|
ArgumentNullException | nodeId null / empty string |
OpcUaException | The server returns a value other than; Good;ex.StatusCode this is the code returned by the server as-is. |
Implementation Constraints
- None
CancellationToken—— Only ReadHistoryStreamAsync Include the cancellation token. - Synchronous Blocking, No variants
Async. - Session-level failures are not automatically retried —— and ReadHistory It's different; it won't automatically reconnect and retry once.
- Do not expose
ModificationInfo; see the warning above. - Do not reveal
ContinuationPoint.
Server Requirements
- We must make history
- The revision history must be preserved (rather than overwritten).
- User credentials must be passed correctly (Username / Certificate Token)