using MessagePack;

namespace ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Shared.Contracts;

[MessagePackObject]
public sealed class DiscoverHierarchyRequest
{
    [Key(0)] public long SessionId { get; set; }
}

/// <summary>
///     IPC-shape for a Galaxy object. Proxy maps to/from <c>DriverAttributeInfo</c> (Core.Abstractions).
/// </summary>
[MessagePackObject]
public sealed class GalaxyObjectInfo
{
    [Key(0)] public string ContainedName { get; set; } = string.Empty;
    [Key(1)] public string TagName { get; set; } = string.Empty;
    [Key(2)] public string? ParentContainedName { get; set; }
    [Key(3)] public string TemplateCategory { get; set; } = string.Empty;
    [Key(4)] public GalaxyAttributeInfo[] Attributes { get; set; } = System.Array.Empty<GalaxyAttributeInfo>();
}

[MessagePackObject]
public sealed class GalaxyAttributeInfo
{
    [Key(0)] public string AttributeName { get; set; } = string.Empty;
    [Key(1)] public int MxDataType { get; set; }
    [Key(2)] public bool IsArray { get; set; }
    [Key(3)] public uint? ArrayDim { get; set; }
    [Key(4)] public int SecurityClassification { get; set; }
    [Key(5)] public bool IsHistorized { get; set; }

    /// <summary>
    ///     True when the attribute has an AlarmExtension primitive in the Galaxy repository
    ///     (<c>primitive_definition.primitive_name = 'AlarmExtension'</c>). The generic
    ///     node-manager uses this to enrich the variable's OPC UA node with an
    ///     <c>AlarmConditionState</c> during address-space build. Added in PR 9 as the
    ///     discovery-side foundation for the alarm event wire-up that follows in PR 10+.
    /// </summary>
    [Key(6)] public bool IsAlarm { get; set; }
}

[MessagePackObject]
public sealed class DiscoverHierarchyResponse
{
    [Key(0)] public bool Success { get; set; }
    [Key(1)] public string? Error { get; set; }
    [Key(2)] public GalaxyObjectInfo[] Objects { get; set; } = System.Array.Empty<GalaxyObjectInfo>();
}
