using System;
using ZB.MOM.WW.MxGateway.Contracts.Proto;
namespace ZB.MOM.WW.MxGateway.Worker.MxAccess;
///
/// Raised by every time the active
/// alarm source switches between the primary (alarmmgr) consumer and the
/// standby (subtag) consumer. The worker translates this into the proto
/// family OnAlarmProviderModeChanged so connected gateway clients
/// can surface the degraded/recovered state.
///
///
///
/// Plain class with constructor-assigned get-only properties — not a
/// record or init-only type — because the worker
/// multi-targets .NET Framework 4.8, which lacks
/// System.Runtime.CompilerServices.IsExternalInit (CS0518).
///
///
public sealed class AlarmProviderModeChange : EventArgs
{
///
/// Initializes the change event payload.
///
/// The provider mode now active after the switch.
/// Human-readable reason for the switch.
///
/// The COM HRESULT that triggered a failover, or 0 for a clean
/// failback / no associated HRESULT.
///
/// The UTC instant the switch occurred.
public AlarmProviderModeChange(AlarmProviderMode mode, string reason, int hResult, DateTime atUtc)
{
Mode = mode;
Reason = reason ?? string.Empty;
HResult = hResult;
AtUtc = atUtc;
}
///
/// The provider mode now active after the switch.
///
public AlarmProviderMode Mode { get; }
///
/// Human-readable reason for the switch (e.g. the failing COM call, or
/// "recovered" for a failback).
///
public string Reason { get; }
///
/// The COM HRESULT that triggered a failover, or 0 when none applies.
///
public int HResult { get; }
///
/// The UTC instant the switch occurred.
///
public DateTime AtUtc { get; }
}