feat(siteruntime): event-driven Attributes.WriteBatchAndWaitAsync (batched DCL write + trigger + existing WaitForAttribute waiter) + compile mirror
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
namespace ZB.MOM.WW.ScadaBridge.Commons.Messages.DataConnection;
|
||||
|
||||
/// <summary>
|
||||
/// Request to write a SET of device tags through the DCL in ONE batch round-trip,
|
||||
/// optionally followed by a trigger-flag write. Composes the adapter's
|
||||
/// <see cref="ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Protocol.IDataConnection.WriteBatchAsync"/>
|
||||
/// (the batch) with a single <c>WriteAsync</c> (the trigger) so the script-facing
|
||||
/// <c>Attributes.WriteBatchAndWaitAsync</c> helper replaces N sequential per-attribute
|
||||
/// writes with one gateway call. The wait half is the EXISTING event-driven
|
||||
/// <c>WaitForAttribute</c> waiter — it is NOT part of this DCL message; failures are
|
||||
/// returned synchronously to the calling Instance Actor.
|
||||
/// </summary>
|
||||
/// <param name="CorrelationId">Per-write correlation id; echoed on the response.</param>
|
||||
/// <param name="ConnectionName">The data connection that owns every tag in the batch (and the trigger).</param>
|
||||
/// <param name="Values">Device tag path → value to write in the single batch round-trip.</param>
|
||||
/// <param name="TriggerTagPath">Optional device tag path of a flag written AFTER the batch succeeds; null to skip.</param>
|
||||
/// <param name="TriggerValue">Value to write to <paramref name="TriggerTagPath"/> (ignored when it is null/empty).</param>
|
||||
/// <param name="Timestamp">When the request was issued (UTC).</param>
|
||||
public record WriteTagBatchRequest(
|
||||
string CorrelationId,
|
||||
string ConnectionName,
|
||||
IReadOnlyDictionary<string, object?> Values, // device tagPath -> value
|
||||
string? TriggerTagPath, // optional flag written AFTER the batch
|
||||
object? TriggerValue,
|
||||
DateTimeOffset Timestamp);
|
||||
|
||||
/// <summary>
|
||||
/// Response for a <see cref="WriteTagBatchRequest"/>. <see cref="Success"/> is true only
|
||||
/// when the whole batch AND the optional trigger committed; otherwise
|
||||
/// <see cref="ErrorMessage"/> describes the first failing leg.
|
||||
/// </summary>
|
||||
/// <param name="CorrelationId">Echoes the request's correlation id.</param>
|
||||
/// <param name="Success">True when the batch (and trigger, if any) all committed.</param>
|
||||
/// <param name="ErrorMessage">Non-null on failure — the aggregated batch error, the trigger error, a timeout, or an adapter exception.</param>
|
||||
/// <param name="Timestamp">When the response was produced (UTC).</param>
|
||||
public record WriteTagBatchResponse(
|
||||
string CorrelationId,
|
||||
bool Success,
|
||||
string? ErrorMessage,
|
||||
DateTimeOffset Timestamp);
|
||||
@@ -0,0 +1,43 @@
|
||||
namespace ZB.MOM.WW.ScadaBridge.Commons.Messages.Instance;
|
||||
|
||||
/// <summary>
|
||||
/// Request to write a SET of data-sourced attributes on one instance to the device in a
|
||||
/// single DCL batch round-trip, optionally followed by a trigger-flag attribute write.
|
||||
/// The Instance Actor resolves each attribute's data binding (connection + device tag
|
||||
/// path), decodes List values, enforces single-connection scope, and forwards one
|
||||
/// <c>WriteTagBatchRequest</c> to the DCL. This is the write half of the script-facing
|
||||
/// <c>Attributes.WriteBatchAndWaitAsync</c> helper; the wait half reuses the existing
|
||||
/// event-driven <c>WaitForAttribute</c> waiter.
|
||||
///
|
||||
/// <para>
|
||||
/// <b>Site-local only.</b> Values are carried codec-ENCODED (strings), so this message
|
||||
/// would serialize — but the helper composing it issues the wait via the in-process
|
||||
/// predicate-capable <c>WaitForAttribute</c> path, so the whole flow stays within one
|
||||
/// site node's actor system (script execution → Instance Actor → DCL).
|
||||
/// </para>
|
||||
/// </summary>
|
||||
/// <param name="CorrelationId">Per-write correlation id; echoed on the response.</param>
|
||||
/// <param name="InstanceName">The instance whose attributes are written.</param>
|
||||
/// <param name="AttributeEncodedValues">Canonical (scope-resolved) attribute name → codec-encoded value.</param>
|
||||
/// <param name="TriggerAttribute">Optional canonical attribute name of a flag written AFTER the batch; null to skip.</param>
|
||||
/// <param name="TriggerEncodedValue">Codec-encoded value for <paramref name="TriggerAttribute"/>.</param>
|
||||
/// <param name="OccurredAtUtc">When the request was issued (UTC).</param>
|
||||
public record WriteAttributeBatchRequest(
|
||||
string CorrelationId,
|
||||
string InstanceName,
|
||||
IReadOnlyDictionary<string, string?> AttributeEncodedValues, // canonical attr name -> codec-encoded value
|
||||
string? TriggerAttribute,
|
||||
string? TriggerEncodedValue,
|
||||
DateTimeOffset OccurredAtUtc);
|
||||
|
||||
/// <summary>
|
||||
/// Reply to a <see cref="WriteAttributeBatchRequest"/>. <see cref="Success"/> is true only
|
||||
/// when the DCL batch (and trigger, if any) all committed.
|
||||
/// </summary>
|
||||
/// <param name="CorrelationId">Echoes the request's correlation id.</param>
|
||||
/// <param name="Success">True when the batch (and trigger, if any) all committed at the device.</param>
|
||||
/// <param name="ErrorMessage">Non-null on failure — an unresolved/non-data-sourced attribute, a multi-connection batch, a list-decode failure, or the DCL error/timeout.</param>
|
||||
public record WriteAttributeBatchResponse(
|
||||
string CorrelationId,
|
||||
bool Success,
|
||||
string? ErrorMessage);
|
||||
Reference in New Issue
Block a user