test(grpc-data): A4 live scenarios part 2 harness — A03 origin failover (same-incarnation stream reset via mapping revision bump, clear-and-re-raise in the gap, RefreshRequired, BadEventIdUnknown, refreshed EventId acks), A06 consumer Primary change across both nodes + second CONSUMER principal fixture-cli-alt, A07 consumer restart refresh-vs-barrier; CLI alarms prints EventType (names RefreshStart/End/Required)

This commit is contained in:
Joseph Doherty
2026-11-25 01:44:58 -05:00
parent c82b8683b0
commit 9ea50c11b2
8 changed files with 365 additions and 12 deletions
@@ -84,6 +84,9 @@ public class AlarmsCommand : CommandBase
outputChannel.Writer.TryWrite($" ConditionNodeId: {e.ConditionNodeId}");
if (e.EventId is { Length: > 0 })
outputChannel.Writer.TryWrite($" EventId: {Convert.ToHexString(e.EventId)}");
// Lets a script tell RefreshStart/End/Required from condition events (e.g. a consumer's RefreshRequired).
if (!string.IsNullOrEmpty(e.EventType))
outputChannel.Writer.TryWrite($" EventType: {DescribeEventType(e.EventType)}");
outputChannel.Writer.TryWrite(string.Empty);
}
catch
@@ -145,4 +148,15 @@ public class AlarmsCommand : CommandBase
}
}
}
/// <summary>Names the well-known refresh event types; any other EventType prints as its NodeId.</summary>
/// <param name="eventType">The EventType NodeId text.</param>
/// <returns><c>RefreshRequiredEventType (i=2789)</c> style text, or the NodeId unchanged.</returns>
internal static string DescribeEventType(string eventType)
{
if (eventType == ObjectTypeIds.RefreshStartEventType.ToString()) return $"RefreshStartEventType ({eventType})";
if (eventType == ObjectTypeIds.RefreshEndEventType.ToString()) return $"RefreshEndEventType ({eventType})";
if (eventType == ObjectTypeIds.RefreshRequiredEventType.ToString()) return $"RefreshRequiredEventType ({eventType})";
return eventType;
}
}
@@ -19,6 +19,7 @@ public sealed class AlarmEventArgs : EventArgs
/// <param name="operatorComment">Operator-supplied comment on acknowledgment transitions.</param>
/// <param name="originalRaiseTimestampUtc">When the alarm originally entered the active state.</param>
/// <param name="alarmCategory">Upstream alarm taxonomy bucket (e.g. Process, Safety, Diagnostics).</param>
/// <param name="eventType">The event's <c>EventType</c> NodeId as text (e.g. <c>i=2789</c> for RefreshRequired), when present.</param>
public AlarmEventArgs(
string sourceName,
string conditionName,
@@ -32,7 +33,8 @@ public sealed class AlarmEventArgs : EventArgs
string? conditionNodeId = null,
string? operatorComment = null,
DateTime? originalRaiseTimestampUtc = null,
string? alarmCategory = null)
string? alarmCategory = null,
string? eventType = null)
{
SourceName = sourceName;
ConditionName = conditionName;
@@ -47,6 +49,7 @@ public sealed class AlarmEventArgs : EventArgs
OperatorComment = operatorComment;
OriginalRaiseTimestampUtc = originalRaiseTimestampUtc;
AlarmCategory = alarmCategory;
EventType = eventType;
}
/// <summary>The name of the source object that raised the alarm.</summary>
@@ -103,4 +106,10 @@ public sealed class AlarmEventArgs : EventArgs
/// <c>Safety</c> / <c>Diagnostics</c>). Null when not surfaced.
/// </summary>
public string? AlarmCategory { get; }
}
/// <summary>
/// The event's <c>EventType</c> NodeId as text (select clause 1), e.g. <c>i=2789</c> for
/// <c>RefreshRequiredEventType</c>. Null when the server did not supply it.
/// </summary>
public string? EventType { get; }
}
@@ -1129,6 +1129,7 @@ public sealed class OpcUaClientService : IOpcUaClientService
var conditionName = fields.Count > 6 ? ValueConverter.ToClrObject(fields[6]) as string ?? string.Empty : string.Empty;
var retain = fields.Count > 7 && ParseBool(ValueConverter.ToClrObject(fields[7]));
var conditionNodeId = fields.Count > 12 ? ValueConverter.ToClrObject(fields[12])?.ToString() : null;
var eventType = fields.Count > 1 ? ValueConverter.ToClrObject(fields[1])?.ToString() : null;
// Try standard OPC UA ActiveState/AckedState fields first
bool? ackedField = fields.Count > 8 && ValueConverter.ToClrObject(fields[8]) != null ? ParseBool(ValueConverter.ToClrObject(fields[8])) : null;
@@ -1142,7 +1143,7 @@ public sealed class OpcUaClientService : IOpcUaClientService
AlarmEvent?.Invoke(this, new AlarmEventArgs(
sourceName, conditionName, severity, message, retain, activeState, ackedState, time,
eventId, conditionNodeId));
eventId, conditionNodeId, eventType: eventType));
}
private static bool ParseBool(object? value)