using ZB.MOM.WW.MxGateway.Contracts.Proto; namespace ZB.MOM.WW.MxGateway.Server.Alarms; /// Lifecycle state of the gateway's central alarm monitor. public enum GatewayAlarmMonitorState { /// Alarm monitoring is switched off (MxGateway:Alarms:Enabled is false). Disabled, /// The monitor is opening or re-opening its worker session. Starting, /// The monitor is connected and tracking the active-alarm set. Monitoring, /// The monitor's last lifecycle attempt failed; a restart is pending. Faulted, } /// /// The gateway's always-on alarm broker. A single gateway-owned worker /// session monitors the AVEVA alarm provider; this service caches the /// current active-alarm set and fans it out to any number of clients — /// no client needs to open its own worker session to see alarms. /// public interface IGatewayAlarmService { /// Current monitor lifecycle state. GatewayAlarmMonitorState State { get; } /// Diagnostic message from the most recent fault, or null. string? LastError { get; } /// Process id of the worker backing the monitor, when one is attached. int? WorkerProcessId { get; } /// A point-in-time copy of the current active-alarm set. IReadOnlyList CurrentAlarms { get; } /// /// Attaches to the central alarm feed. The returned stream yields one /// per currently-active alarm, then a /// single snapshot_complete sentinel, then a transition /// for every subsequent change. /// /// Optional alarm-reference prefix scoping the feed. /// Token that ends the subscription. IAsyncEnumerable StreamAsync( string? alarmFilterPrefix, CancellationToken cancellationToken); /// /// Acknowledges an alarm through the monitor's worker session. Never /// throws — transport and monitor-state failures surface in the /// reply's . /// /// The acknowledge request. /// Token to cancel the call. Task AcknowledgeAsync( AcknowledgeAlarmRequest request, CancellationToken cancellationToken); }