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

/// <summary>
///     FOCAS driver configuration. One instance supports N CNC devices. Per plan decision #144
///     each device gets its own <c>(DriverInstanceId, HostAddress)</c> bulkhead key at the
///     Phase 6.1 resilience layer.
/// </summary>
public sealed class FocasDriverOptions
{
    public IReadOnlyList<FocasDeviceOptions> Devices { get; init; } = [];
    public IReadOnlyList<FocasTagDefinition> Tags { get; init; } = [];
    public FocasProbeOptions Probe { get; init; } = new();
    public TimeSpan Timeout { get; init; } = TimeSpan.FromSeconds(2);
}

/// <summary>
///     One CNC the driver talks to. <paramref name="Series"/> enables per-series
///     address validation at <see cref="FocasDriver.InitializeAsync"/>; leave as
///     <see cref="FocasCncSeries.Unknown"/> to skip validation (legacy behaviour).
/// </summary>
public sealed record FocasDeviceOptions(
    string HostAddress,
    string? DeviceName = null,
    FocasCncSeries Series = FocasCncSeries.Unknown);

/// <summary>
///     One FOCAS-backed OPC UA variable. <paramref name="Address"/> is the canonical FOCAS
///     address string that parses via <see cref="FocasAddress.TryParse"/> —
///     <c>X0.0</c> / <c>R100</c> / <c>PARAM:1815/0</c> / <c>MACRO:500</c>.
/// </summary>
public sealed record FocasTagDefinition(
    string Name,
    string DeviceHostAddress,
    string Address,
    FocasDataType DataType,
    bool Writable = true,
    bool WriteIdempotent = false);

public sealed class FocasProbeOptions
{
    public bool Enabled { get; init; } = true;
    public TimeSpan Interval { get; init; } = TimeSpan.FromSeconds(5);
    public TimeSpan Timeout { get; init; } = TimeSpan.FromSeconds(2);
}
