namespace ZB.MOM.WW.ScadaBridge.Commons.Messages.Instance; /// /// Request to wait, event-driven, until an attribute reaches a value (or any /// value satisfying a predicate), bounded by a timeout — the backing protocol for /// the script-facing Attributes.WaitAsync helper. /// /// /// Site-local only. The optional is a non-serializable /// in-process delegate, so this message MUST flow only within a single site node's /// actor system (script execution → Instance Actor). It is never sent across the /// site↔central gRPC boundary. The value-equality form () /// would serialize, but the routed/inbound variant is deliberately out of scope here. /// /// /// Per-wait correlation id; keys the waiter registry and the timeout self-message. /// The instance this wait targets. /// The attribute to watch — already scope-resolved by the accessor. /// /// The codec-encoded target value (AttributeValueCodec.Encode(target)). A /// match compares the codec-encoded form of the current value against this string. /// When both this and are null the wait matches on ANY change. /// /// /// Site-local predicate tested against the raw (decoded) current value. Mutually /// exclusive with — null when the encoded target is used. /// /// How long to wait before self-evicting with a timeout reply. /// When the request was issued (UTC). /// /// Quality-gated ("Good"-only) mode (spec §4.2): when , a /// match additionally requires the attribute quality to be exactly /// "Good" () — a value that /// reaches the target / satisfies the predicate at Bad/Uncertain quality is NOT a /// match and the waiter stays pending until the value satisfies the test at Good /// quality (or times out). Defaults to (quality-agnostic: /// the match tests the value only). Trailing/defaulted so existing positional /// constructions compile unchanged. /// public record WaitForAttributeRequest( string CorrelationId, string InstanceName, string AttributeName, string? TargetValueEncoded, Func? Predicate, TimeSpan Timeout, DateTimeOffset OccurredAtUtc, bool RequireGoodQuality = false); /// /// Reply to a . Exactly one of /// / is set on the happy paths; /// is populated on the failure paths (per-instance /// waiter cap exceeded, or the match predicate threw). /// /// Echoes the request's correlation id. /// True when the attribute reached the target/predicate within the timeout. /// The matched value (null on timeout / error). /// /// The attribute quality at match time; on the non-match /// paths (timeout / error / cap-exceeded), matching the nullable /// convention. /// /// True when the timeout fired before a match. /// /// Non-null only when the wait failed/refused — the per-instance waiter cap was /// exceeded, or the match predicate threw ("Wait predicate threw: …"). /// public record WaitForAttributeResponse( string CorrelationId, bool Matched, object? Value, string? Quality, bool TimedOut, string? ErrorMessage = null); /// /// Internal self-message scheduled by the Instance Actor to fire a waiter's /// timeout. Site-local only; never crosses a cluster boundary. /// /// The waiter whose timeout fired. public record WaitForAttributeTimeout(string CorrelationId);