namespace ZB.MOM.WW.ScadaBridge.Commons.Entities.Instances;

public class InstanceConnectionBinding
{
    /// <summary>Auto-incremented primary key.</summary>
    public int Id { get; set; }
    /// <summary>Foreign key to the owning instance.</summary>
    public int InstanceId { get; set; }
    /// <summary>Name of the attribute on the instance that this binding maps to a data connection tag.</summary>
    public string AttributeName { get; set; }
    /// <summary>Foreign key to the data connection that provides values for this attribute.</summary>
    public int DataConnectionId { get; set; }

    /// <summary>
    /// Optional per-instance override of the OPC UA node identifier (or other
    /// protocol address) for this attribute. When non-null, this value replaces
    /// the template's <c>DataSourceReference</c> during flattening. When null,
    /// the template default is used.
    /// </summary>
    public string? DataSourceReferenceOverride { get; set; }

    /// <summary>
    /// Creates a binding for the specified attribute name.
    /// </summary>
    /// <param name="attributeName">Name of the attribute being bound to a data connection.</param>
    public InstanceConnectionBinding(string attributeName)
    {
        AttributeName = attributeName ?? throw new ArgumentNullException(nameof(attributeName));
    }
}
