namespace ZB.MOM.WW.OtOpcUa.Configuration.Entities;

/// <summary>
///     v3: a device under a <see cref="DriverInstance"/>. Now UNIVERSAL — every driver has ≥1 device
///     (single-endpoint drivers get an auto-created default device). Endpoint/connection settings live
///     in <see cref="DeviceConfig"/> (the Kepware channel/device split: <c>DriverConfig</c> keeps
///     protocol/channel-level settings; <c>DeviceConfig</c> carries host/endpoint + per-device
///     settings). The device name is a RawPath segment.
/// </summary>
public sealed class Device
{
    /// <summary>
    /// Gets or sets the unique database row identifier for the device.
    /// </summary>
    public Guid DeviceRowId { get; set; }

    /// <summary>
    /// Gets or sets the device identifier.
    /// </summary>
    public required string DeviceId { get; set; }

    /// <summary>Logical FK to <see cref="DriverInstance.DriverInstanceId"/>.</summary>
    public required string DriverInstanceId { get; set; }

    /// <summary>
    /// Gets or sets the device name.
    /// </summary>
    public required string Name { get; set; }

    /// <summary>
    /// Gets or sets a value indicating whether the device is enabled.
    /// </summary>
    public bool Enabled { get; set; } = true;

    /// <summary>Schemaless per-driver-type device config (host, port, unit ID, slot, etc.).</summary>
    public required string DeviceConfig { get; set; }

    /// <summary>Optimistic concurrency token for last-write-wins detection in the v2 live-edit model.</summary>
    public byte[] RowVersion { get; set; } = Array.Empty<byte>();
}
