namespace ZB.MOM.WW.OtOpcUa.Core.Abstractions;
///
/// Optional companion to : the driver says when the standing state of a set of its
/// conditions has been established โ the initial replay, refresh, poll or walk that covers them has
/// completed and every alarm event it produced has already been raised (plan
/// 2026-11-23-grpc-data-connections-history-alarms ยง5.1, F1/F2/G1/G5).
///
///
///
/// An ordered callback, never a (F2). Raise
/// synchronously, on the same thread and callback path as
/// , after the last alarm event the completed read covers. The
/// host marshals both onto the same actor mailbox, so the "known" mark it derives is applied after every
/// projection the driver emitted before raising it. A task continuation could overtake queued transitions.
///
///
/// Carry what it covers (G1). lists the driver
/// ConditionIds (= the condition's RawPath, the routing key of the alarm event) whose state the
/// completed read established โ never "the whole driver". An unreachable device's conditions are simply
/// left out and stay unknown.
///
///
/// Raise on every completed read or cycle, not only the first. Repeats are no-ops downstream; they are
/// what makes conditions known again after a reconnect or a deploy that adds conditions.
///
///
/// Suppression gate (G5). Obey exactly the gate obeys: raise
/// only while an alarm subscription is live. A refresh / poll / sentinel that completes while events are
/// suppressed raises nothing; the first signal after (re)subscribe follows the post-subscribe replay.
///
///
/// A source that cannot signal at all (an OPC UA upstream without ConditionRefresh) raises the event
/// once with set: the host then applies its
/// per-driver-type backstop timer to those conditions instead. No other shipped source should use it.
///
///
/// Withdrawing (#926). A source that signalled and then LOSES events for those conditions (an OPC UA
/// event-queue overflow, a publish gap) raises the event with
/// set: the host takes "known" back from them (Uncertain on a consumer) until the source signals again or a
/// transition re-establishes one. Same ordering rule: after every alarm event raised before it. Only a source
/// that SIGNALLED withdraws: conditions that became known through the
/// backstop are not withdrawn by a later loss (the OPC UA client has no refresh bracket there, and its loss
/// detection never re-arms the backstop) โ that residual is the backstop's own.
///
///
public interface IAlarmInitialStateSignal
{
/// The standing state of has been delivered.
event EventHandler? InitialAlarmStateDelivered;
}
/// Payload of .
public sealed class AlarmInitialStateEventArgs : EventArgs
{
/// Creates the payload.
/// The driver condition ids (RawPaths) whose state the completed read established.
///
/// when the source can never signal for these conditions (no refresh upstream);
/// the host's backstop timer applies instead of an immediate mark.
///
///
/// (#926) when the source can no longer vouch for these conditions' state (it lost events
/// after establishing them): the host withdraws "known". Exclusive with .
///
public AlarmInitialStateEventArgs(IReadOnlyList conditionIds, bool unsignalable = false, bool withdrawn = false)
{
ArgumentNullException.ThrowIfNull(conditionIds);
if (unsignalable && withdrawn)
throw new ArgumentException("A signal is either unsignalable or a withdrawal, not both.", nameof(withdrawn));
ConditionIds = conditionIds;
Unsignalable = unsignalable;
Withdrawn = withdrawn;
}
/// The driver condition ids (= RawPaths) the completed read covers. Never "everything".
public IReadOnlyList ConditionIds { get; }
///
/// The source reports InitialStateUnsignalable for these conditions: no real signal will ever come,
/// so the per-driver-type backstop timer (OpcUaClient only) decides when they become known.
///
public bool Unsignalable { get; }
///
/// #926: the source lost events for these conditions after establishing them, so their state is no longer
/// known. The host withdraws "known" (never starting a backstop) until the next real signal.
///
public bool Withdrawn { get; }
}