namespace ZB.MOM.WW.OtOpcUa.Driver.Historian.Gateway.Mapping; /// /// Which gateway events belong to a requested event source (Gitea #882): the source's own events, and the events of /// its attributes. /// /// /// /// The gateway filters a per-source ReadEvents on AVEVA's Source_Object, and reports each row's /// SourceName as Source_ProcessVariable (else Source_Object). An object-level event /// (System.Stop / System.Start) therefore comes back named after the object, DevWinPlatform, /// while an alarm on one of the object's attributes comes back named <Object>.<Attribute>, /// DevWinPlatform.CPULoadAvg, although the gateway returned it for Source_Object = DevWinPlatform. /// Both are the object's events; live, an attribute alarm's condition fires on the same folder as the object's own /// events. /// /// /// The match is on the . boundary, ordinal: DevWinPlatform matches DevWinPlatform and /// DevWinPlatform.CPULoadAvg, never DevWinPlatform2 or DevWinPlatform2.CPULoadAvg. /// /// internal static class EventSourceMatch { /// Whether an event reported with belongs to . /// The requested source; null requests every source. /// The event's reported source name. /// true when the event is the source's own or one of its attributes'. public static bool Matches(string? requested, string? eventSource) { if (requested is null) return true; if (eventSource is null) return false; return eventSource.Length == requested.Length ? string.Equals(eventSource, requested, StringComparison.Ordinal) : eventSource.Length > requested.Length + 1 && eventSource[requested.Length] == '.' && eventSource.StartsWith(requested, StringComparison.Ordinal); } }