namespace ZB.MOM.WW.OtOpcUa.Driver.TwinCAT;
///
/// TwinCAT ADS driver configuration. One instance supports N targets (each identified by
/// an AMS Net ID + port). Compiles + runs without a local AMS router but every wire call
/// fails with BadCommunicationError until a router is reachable.
///
public sealed class TwinCATDriverOptions
{
public IReadOnlyList Devices { get; init; } = [];
public IReadOnlyList Tags { get; init; } = [];
public TwinCATProbeOptions Probe { get; init; } = new();
public TimeSpan Timeout { get; init; } = TimeSpan.FromSeconds(2);
///
/// When true (default), SubscribeAsync registers native ADS notifications
/// via AddDeviceNotificationExAsync — the PLC pushes changes on its own cycle
/// rather than the driver polling. Strictly better for latency + CPU when the target
/// supports it (TC2 + TC3 PLC runtimes always do; some soft-PLC / third-party ADS
/// implementations may not). When false, the driver falls through to the shared
/// — same semantics as the other
/// libplctag-backed drivers. Set false for deployments where the AMS router has
/// notification limits you can't raise.
///
public bool UseNativeNotifications { get; init; } = true;
///
/// When true, DiscoverAsync walks each device's symbol table via the
/// TwinCAT SymbolLoaderFactory (flat mode) + surfaces controller-resident
/// globals / program locals under a Discovered/ sub-folder. Pre-declared tags
/// from always emit regardless. Default false to preserve
/// the strict-config path for deployments where only declared tags should appear.
///
public bool EnableControllerBrowse { get; init; }
}
///
/// One TwinCAT target. must parse via
/// ; misconfigured devices fail driver initialisation.
///
public sealed record TwinCATDeviceOptions(
string HostAddress,
string? DeviceName = null);
///
/// One TwinCAT-backed OPC UA variable. is the full TwinCAT
/// symbolic name (e.g. MAIN.bStart, GVL.Counter, Motor1.Status.Running).
///
public sealed record TwinCATTagDefinition(
string Name,
string DeviceHostAddress,
string SymbolPath,
TwinCATDataType DataType,
bool Writable = true,
bool WriteIdempotent = false);
public sealed class TwinCATProbeOptions
{
public bool Enabled { get; init; } = true;
public TimeSpan Interval { get; init; } = TimeSpan.FromSeconds(5);
public TimeSpan Timeout { get; init; } = TimeSpan.FromSeconds(2);
}