using ZB.MOM.WW.OtOpcUa.Core.Abstractions;

namespace ZB.MOM.WW.OtOpcUa.Core.VirtualTags;

/// <summary>
///     Operator-authored virtual-tag configuration row. Phase 7 Stream E (config DB
///     schema) materializes these from the <c>VirtualTag</c> + <c>Script</c> tables on
///     publish; the engine ingests a list of them at load time.
/// </summary>
/// <param name="Path">
///     UNS tag path — <c>Enterprise/Site/Area/Line/Equipment/TagName</c>. Used both as
///     the engine's internal id and the OPC UA browse path.
/// </param>
/// <param name="DataType">
///     Expected return type. The evaluator coerces the script's return value to this
///     type before publishing; mismatch surfaces as <c>BadTypeMismatch</c> quality on
///     the tag.
/// </param>
/// <param name="ScriptSource">Roslyn C# script source. Must compile under <c>ScriptSandbox</c>.</param>
/// <param name="ChangeTriggered">
///     True if any input tag's change (value / status / timestamp delta) should trigger
///     re-evaluation. Operator picks per tag — usually true for inputs that change at
///     protocol rates.
/// </param>
/// <param name="TimerInterval">
///     Optional periodic re-evaluation cadence. Null = timer-driven disabled. Both can
///     be enabled simultaneously; independent scheduling paths both end at
///     <see cref="VirtualTagEngine"/>'s <c>EvaluateInternalAsync</c>.
/// </param>
/// <param name="Historize">
///     When true, every evaluation result is forwarded to the configured
///     <see cref="IHistoryWriter"/>. Operator-set per tag; the Admin UI exposes as a
///     checkbox.
/// </param>
public sealed record VirtualTagDefinition(
    string Path,
    DriverDataType DataType,
    string ScriptSource,
    bool ChangeTriggered = true,
    TimeSpan? TimerInterval = null,
    bool Historize = false);
