feat(opcua): HistoryReadEvents projects EventType, ConditionName, SourceNode; honours the where-clause (lmxopcua#746)

HistoryReadEvents projected only EventId / SourceName / Time / ReceiveTime /
Message / Severity: a select clause asking for EventType, ConditionName or
SourceNode (what most generic alarm viewers ask for) got nulls, and the
event filter's where-clause (an OfType) was ignored.

- HistoricalEvent gains optional EventTypeName, ConditionName and AlarmId.
  SqlServer, QuestDB and Gateway event reads fill them from what their
  alarm writers already store (AlarmTypeName / AlarmName / AlarmId; the
  gateway event Type and its AlarmName / AlarmId properties).
- The node manager maps the type name to its Part 9 event type (unknown or
  non-event => AlarmConditionType), projects ConditionName, and resolves
  SourceNode to the materialised condition the alarm id names (the live
  events' SourceNode), else null.
- The where-clause is evaluated per event with the SDK content filter
  through an IFilterTarget (OfType via the type tree; other operators
  against the projected fields), after the page's cursor is taken, so
  paging is unchanged.

Tested in the node manager, over a real client session (the Client.CLI has
no `historyread --events` mode yet; filed as a follow-up), and by alarm
writer -> event read round trips on SqlServer and QuestDB.

Rebased from the unpushed remed/lane-H2 branch (originally authored 2026-10-22
in session_01Ub9hGmYLQvn9XETzw7CMsT) onto current master.

Claude-Session: https://claude.ai/code/session_01GT67AEHd2Acv1YPwGfXEoV
This commit is contained in:
Joseph Doherty
2026-10-22 17:45:38 -04:00
parent 096a3d5b3c
commit 29665c1872
13 changed files with 503 additions and 31 deletions
@@ -133,8 +133,9 @@ public sealed class NodeManagerHistoryReadEventsTests : IDisposable
await host.DisposeAsync();
}
/// <summary>An unsupported select operand (BrowsePath ["EventType"]) projects to Variant.Null — a field
/// the server can't supply is null (spec-conformant) — while supported siblings still project.</summary>
/// <summary>An unsupported select operand (BrowsePath ["LocalTime"]) projects to Variant.Null — a field
/// the server can't supply is null (spec-conformant) — while supported siblings still project. (EventType used to
/// be such a field; it is projected now — see NodeManagerHistoryReadEventsProjectionTests.)</summary>
[Fact]
public async Task Events_unsupported_select_field_projects_null()
{
@@ -156,8 +157,8 @@ public sealed class NodeManagerHistoryReadEventsTests : IDisposable
StartTime = DateTime.UtcNow.AddHours(-1),
EndTime = DateTime.UtcNow,
NumValuesPerNode = 10,
// EventType is a real BaseEventType field we cannot supply from a HistoricalEvent; EventId is.
Filter = SelectFilter("EventType", "EventId"),
// LocalTime is a real BaseEventType field we cannot supply from a HistoricalEvent; EventId is.
Filter = SelectFilter("LocalTime", "EventId"),
};
var (results, errors) = InvokeHistoryRead(server, nm, details, notifierNodeId);
@@ -166,7 +167,7 @@ public sealed class NodeManagerHistoryReadEventsTests : IDisposable
var history = (HistoryEvent)ExtensionObject.ToEncodeable(results[0].HistoryData);
var fields = history.Events[0].EventFields;
fields.Count.ShouldBe(2);
// EventType ⇒ Variant.Null.
// LocalTime ⇒ Variant.Null.
fields[0].Value.ShouldBeNull();
// EventId still projects to a ByteString.
fields[1].Value.ShouldBeOfType<byte[]>().ShouldBe(System.Text.Encoding.UTF8.GetBytes("evt-1"));