using MessagePack;

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

/// <summary>
///     Wire shape for a parsed FOCAS address. Mirrors <c>FocasAddress</c> in the driver
///     package but lives in Shared so the Host (.NET 4.8) can decode without taking a
///     reference to the .NET 10 driver assembly. The Proxy serializes from its own
///     <c>FocasAddress</c>; the Host maps back to its local equivalent.
/// </summary>
[MessagePackObject]
public sealed class FocasAddressDto
{
    /// <summary>0 = Pmc, 1 = Parameter, 2 = Macro. Matches <c>FocasAreaKind</c> enum order.</summary>
    [Key(0)] public int Kind { get; set; }

    /// <summary>PMC letter — null for Parameter / Macro.</summary>
    [Key(1)] public string? PmcLetter { get; set; }

    [Key(2)] public int Number { get; set; }

    /// <summary>Optional bit index (0-7 for PMC, 0-31 for Parameter).</summary>
    [Key(3)] public int? BitIndex { get; set; }
}

/// <summary>
///     0 = Bit, 1 = Byte, 2 = Int16, 3 = Int32, 4 = Float32, 5 = Float64, 6 = String.
///     Matches <c>FocasDataType</c> enum order so both sides can cast <c>(int)</c>.
/// </summary>
public static class FocasDataTypeCode
{
    public const int Bit = 0;
    public const int Byte = 1;
    public const int Int16 = 2;
    public const int Int32 = 3;
    public const int Float32 = 4;
    public const int Float64 = 5;
    public const int String = 6;
}
