namespace ZB.MOM.WW.OtOpcUa.Driver.AbCip;

/// <summary>
///     Reads the raw Template Object (class 0x6C) blob for a given UDT template instance id
///     off a Logix controller. The default production implementation (see
///     <see cref="LibplctagTemplateReader"/>) uses libplctag's <c>@udt/{id}</c> pseudo-tag.
///     Tests swap in a fake via <see cref="IAbCipTemplateReaderFactory"/>.
/// </summary>
public interface IAbCipTemplateReader : IDisposable
{
    /// <summary>
    ///     Read the raw template bytes for <paramref name="templateInstanceId"/>. Returns the
    ///     full blob the Read Template service produced — the managed <see cref="CipTemplateObjectDecoder"/>
    ///     parses it into an <see cref="AbCipUdtShape"/>.
    /// </summary>
    /// <param name="deviceParams">The device connection parameters.</param>
    /// <param name="templateInstanceId">The template instance ID to read.</param>
    /// <param name="cancellationToken">Token to cancel the operation.</param>
    /// <returns>The raw Template Object blob bytes.</returns>
    Task<byte[]> ReadAsync(
        AbCipTagCreateParams deviceParams,
        uint templateInstanceId,
        CancellationToken cancellationToken);
}

/// <summary>Factory for <see cref="IAbCipTemplateReader"/>.</summary>
public interface IAbCipTemplateReaderFactory
{
    /// <summary>Creates a new template reader instance.</summary>
    /// <returns>A new <see cref="IAbCipTemplateReader"/> instance.</returns>
    IAbCipTemplateReader Create();
}
