using ZB.MOM.WW.ScadaBridge.Commons.Types.Enums;

namespace ZB.MOM.WW.ScadaBridge.Commons.Types.Alarms;

/// <summary>Builds <see cref="AlarmConditionState"/> values for the supported alarm kinds.</summary>
public static class AlarmConditionStateFactory
{
    /// <summary>
    /// Computed alarms have no native ack/shelve/suppress lifecycle: they are
    /// auto-acked, never shelved or suppressed, not confirmable, and their
    /// severity is the configured priority. Active mirrors the alarm State.
    /// </summary>
    /// <param name="state">The current alarm state used to derive the Active flag.</param>
    /// <param name="priority">Configured priority mapped to the Severity field (0–1000).</param>
    /// <returns>An <see cref="AlarmConditionState"/> reflecting the computed alarm's lifecycle (auto-acked, unshelved, not suppressed).</returns>
    public static AlarmConditionState ForComputed(AlarmState state, int priority) =>
        new(Active: state == AlarmState.Active, Acknowledged: true, Confirmed: null,
            Shelve: AlarmShelveState.Unshelved, Suppressed: false, Severity: priority);
}
