using ZB.MOM.WW.ScadaBridge.Commons.Messages.Streaming;

namespace ZB.MOM.WW.ScadaBridge.Commons.Messages.Instance;

/// <summary>
/// Request for the Instance Actor's CURRENT alarm-condition snapshot, backing the
/// script-facing <c>Alarms.CurrentAsync()</c> accessor (MES alarm-status API §5.2).
///
/// <para>
/// A dedicated message rather than a reuse of <c>DebugSnapshotRequest</c>: the script
/// accessor needs only the alarm rows, and the debug snapshot additionally materialises
/// every attribute value on every call. Same local Ask path as
/// <see cref="GetAttributeRequest"/> — the script runs against its own Instance Actor, so
/// there is no cross-cluster hop.
/// </para>
/// </summary>
/// <param name="CorrelationId">Application-level correlation id echoed on the response.</param>
/// <param name="InstanceUniqueName">Unique name of the instance whose alarms are requested.</param>
/// <param name="Timestamp">When the request was issued (UTC).</param>
public record GetAlarmSnapshotRequest(
    string CorrelationId,
    string InstanceUniqueName,
    DateTimeOffset Timestamp);

/// <summary>
/// The Instance Actor's reply to a <see cref="GetAlarmSnapshotRequest"/> — the same
/// enriched alarm rows the Debug View snapshot carries (computed alarms, mirrored native
/// conditions, and configured-but-quiet native binding placeholders), projected to
/// <c>ScriptAlarm</c> by the accessor rather than by the actor so the message stays a
/// plain mirror of the internal state.
/// </summary>
/// <param name="CorrelationId">Correlation id from the originating request.</param>
/// <param name="InstanceUniqueName">Unique name of the instance the snapshot belongs to.</param>
/// <param name="Alarms">The instance's current alarm rows.</param>
/// <param name="Timestamp">When the snapshot was taken (UTC).</param>
public record GetAlarmSnapshotResponse(
    string CorrelationId,
    string InstanceUniqueName,
    IReadOnlyList<AlarmStateChanged> Alarms,
    DateTimeOffset Timestamp);
