099238894c
- OpcUaPublishActor: deferred alarm states, qualities and condition marks replay as one arrival-ordered list (a withdrawal followed by a re-establishing transition ended unknown); marks held per (realm, condition) so withdrawals are bounded by the condition set - OpcUaClientDriver: signal/withdraw re-check the registration under _alarmStateLock; removals take the lock - DriverHostActor: a withdrawal under a raised F5 diagnostic updates its count - docs: Unsignalable/backstop residual; AlarmInitialStatePublished must stay in-process - tests: arrival-order replay (+ mirror), backstop positive control, F5 count
91 lines
5.5 KiB
C#
91 lines
5.5 KiB
C#
namespace ZB.MOM.WW.OtOpcUa.Core.Abstractions;
|
|
|
|
/// <summary>
|
|
/// Optional companion to <see cref="IAlarmSource"/>: the driver says when the standing state of a set of its
|
|
/// conditions has been <b>established</b> — the initial replay, refresh, poll or walk that covers them has
|
|
/// completed and every alarm event it produced has already been raised (plan
|
|
/// <c>2026-11-23-grpc-data-connections-history-alarms</c> §5.1, F1/F2/G1/G5).
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// <b>An ordered callback, never a <see cref="System.Threading.Tasks.Task"/> (F2).</b> Raise
|
|
/// <see cref="InitialAlarmStateDelivered"/> synchronously, on the same thread and callback path as
|
|
/// <see cref="IAlarmSource.OnAlarmEvent"/>, <b>after</b> 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.
|
|
/// </para>
|
|
/// <para>
|
|
/// <b>Carry what it covers (G1).</b> <see cref="AlarmInitialStateEventArgs.ConditionIds"/> lists the driver
|
|
/// <c>ConditionId</c>s (= 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.
|
|
/// </para>
|
|
/// <para>
|
|
/// <b>Raise on every completed read or cycle</b>, 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.
|
|
/// </para>
|
|
/// <para>
|
|
/// <b>Suppression gate (G5).</b> Obey exactly the gate <see cref="IAlarmSource.OnAlarmEvent"/> 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.
|
|
/// </para>
|
|
/// <para>
|
|
/// <b>A source that cannot signal at all</b> (an OPC UA upstream without ConditionRefresh) raises the event
|
|
/// once with <see cref="AlarmInitialStateEventArgs.Unsignalable"/> set: the host then applies its
|
|
/// per-driver-type backstop timer to those conditions instead. No other shipped source should use it.
|
|
/// </para>
|
|
/// <para>
|
|
/// <b>Withdrawing (#926).</b> A source that signalled and then LOSES events for those conditions (an OPC UA
|
|
/// event-queue overflow, a publish gap) raises the event with <see cref="AlarmInitialStateEventArgs.Withdrawn"/>
|
|
/// 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 <see cref="AlarmInitialStateEventArgs.Unsignalable"/>
|
|
/// 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.
|
|
/// </para>
|
|
/// </remarks>
|
|
public interface IAlarmInitialStateSignal
|
|
{
|
|
/// <summary>The standing state of <see cref="AlarmInitialStateEventArgs.ConditionIds"/> has been delivered.</summary>
|
|
event EventHandler<AlarmInitialStateEventArgs>? InitialAlarmStateDelivered;
|
|
}
|
|
|
|
/// <summary>Payload of <see cref="IAlarmInitialStateSignal.InitialAlarmStateDelivered"/>.</summary>
|
|
public sealed class AlarmInitialStateEventArgs : EventArgs
|
|
{
|
|
/// <summary>Creates the payload.</summary>
|
|
/// <param name="conditionIds">The driver condition ids (RawPaths) whose state the completed read established.</param>
|
|
/// <param name="unsignalable">
|
|
/// <see langword="true"/> when the source can never signal for these conditions (no refresh upstream);
|
|
/// the host's backstop timer applies instead of an immediate mark.
|
|
/// </param>
|
|
/// <param name="withdrawn">
|
|
/// <see langword="true"/> (#926) when the source can no longer vouch for these conditions' state (it lost events
|
|
/// after establishing them): the host withdraws "known". Exclusive with <paramref name="unsignalable"/>.
|
|
/// </param>
|
|
public AlarmInitialStateEventArgs(IReadOnlyList<string> 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;
|
|
}
|
|
|
|
/// <summary>The driver condition ids (= RawPaths) the completed read covers. Never "everything".</summary>
|
|
public IReadOnlyList<string> ConditionIds { get; }
|
|
|
|
/// <summary>
|
|
/// The source reports <c>InitialStateUnsignalable</c> for these conditions: no real signal will ever come,
|
|
/// so the per-driver-type backstop timer (OpcUaClient only) decides when they become known.
|
|
/// </summary>
|
|
public bool Unsignalable { get; }
|
|
|
|
/// <summary>
|
|
/// #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.
|
|
/// </summary>
|
|
public bool Withdrawn { get; }
|
|
}
|