using ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.PlcFamilies;
namespace ZB.MOM.WW.OtOpcUa.Driver.AbLegacy;
///
/// AB Legacy (PCCC) driver configuration. One instance supports N devices (SLC 500 /
/// MicroLogix / PLC-5 / LogixPccc). Per plan decision #41 AbLegacy ships separately from
/// AbCip because PCCC's file-based addressing (N7:0) and Logix's symbolic addressing
/// (Motor1.Speed) pull the abstraction in different directions.
///
public sealed class AbLegacyDriverOptions
{
public IReadOnlyList Devices { get; init; } = [];
public IReadOnlyList Tags { get; init; } = [];
public AbLegacyProbeOptions Probe { get; init; } = new();
public TimeSpan Timeout { get; init; } = TimeSpan.FromSeconds(2);
}
public sealed record AbLegacyDeviceOptions(
string HostAddress,
AbLegacyPlcFamily PlcFamily = AbLegacyPlcFamily.Slc500,
string? DeviceName = null);
///
/// One PCCC-backed OPC UA variable. Address is the canonical PCCC file-address
/// string that parses via .
///
///
/// PR 8 deadband fields:
///
/// - AbsoluteDeadband — when set, suppresses OnDataChange for numeric
/// tags unless |new - prev| >= AbsoluteDeadband.
/// - PercentDeadband — when set, suppresses unless
/// |new - prev| >= |prev * Percent / 100|; prev == 0 always publishes.
///
/// Booleans bypass deadband entirely (every transition publishes); strings + status
/// changes always publish; first-seen always publishes; both set → logical-OR (Kepware
/// semantics).
///
public sealed record AbLegacyTagDefinition(
string Name,
string DeviceHostAddress,
string Address,
AbLegacyDataType DataType,
bool Writable = true,
bool WriteIdempotent = false,
int? ArrayLength = null,
double? AbsoluteDeadband = null,
double? PercentDeadband = null);
public sealed class AbLegacyProbeOptions
{
public bool Enabled { get; init; } = true;
public TimeSpan Interval { get; init; } = TimeSpan.FromSeconds(5);
public TimeSpan Timeout { get; init; } = TimeSpan.FromSeconds(2);
/// Probe address — defaults to S:0 (status file, first word) when null.
public string? ProbeAddress { get; init; } = "S:0";
}