using ZB.MOM.WW.OtOpcUa.Configuration.Enums;
namespace ZB.MOM.WW.OtOpcUa.Configuration.Entities;
/// Physical OPC UA server node within a .
public sealed class ClusterNode
{
/// Stable per-machine logical ID, e.g. "LINE3-OPCUA-A".
public required string NodeId { get; set; }
public required string ClusterId { get; set; }
public required RedundancyRole RedundancyRole { get; set; }
/// Machine hostname / IP.
public required string Host { get; set; }
public int OpcUaPort { get; set; } = 4840;
public int DashboardPort { get; set; } = 8081;
///
/// OPC UA ApplicationUri — MUST be unique per node per OPC UA spec. Clients pin trust here.
/// Fleet-wide unique index enforces no two nodes share a value (decision #86).
/// Stored explicitly, NOT derived from at runtime — silent rewrite on
/// hostname change would break all client trust.
///
public required string ApplicationUri { get; set; }
/// Primary = 200, Secondary = 150 by default.
public byte ServiceLevelBase { get; set; } = 200;
///
/// Per-node override JSON keyed by DriverInstanceId, merged onto cluster-level DriverConfig
/// at apply time. Minimal by intent (decision #81). Nullable when no overrides exist.
///
public string? DriverConfigOverridesJson { get; set; }
public bool Enabled { get; set; } = true;
public DateTime? LastSeenAt { get; set; }
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public required string CreatedBy { get; set; }
// Navigation
public ServerCluster? Cluster { get; set; }
public ICollection Credentials { get; set; } = [];
public ClusterNodeGenerationState? GenerationState { get; set; }
}