using MessagePack;

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

/// <summary>
///     IPC-shape for a tag value snapshot. Per decision #13: value + StatusCode + source + server timestamps.
/// </summary>
[MessagePackObject]
public sealed class GalaxyDataValue
{
    [Key(0)] public string TagReference { get; set; } = string.Empty;
    [Key(1)] public byte[]? ValueBytes { get; set; }
    [Key(2)] public int ValueMessagePackType { get; set; }
    [Key(3)] public uint StatusCode { get; set; }
    [Key(4)] public long SourceTimestampUtcUnixMs { get; set; }
    [Key(5)] public long ServerTimestampUtcUnixMs { get; set; }
}

[MessagePackObject]
public sealed class ReadValuesRequest
{
    [Key(0)] public long SessionId { get; set; }
    [Key(1)] public string[] TagReferences { get; set; } = System.Array.Empty<string>();
}

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

[MessagePackObject]
public sealed class WriteValuesRequest
{
    [Key(0)] public long SessionId { get; set; }
    [Key(1)] public GalaxyDataValue[] Writes { get; set; } = System.Array.Empty<GalaxyDataValue>();
}

[MessagePackObject]
public sealed class WriteValueResult
{
    [Key(0)] public string TagReference { get; set; } = string.Empty;
    [Key(1)] public uint StatusCode { get; set; }
    [Key(2)] public string? Error { get; set; }
}

[MessagePackObject]
public sealed class WriteValuesResponse
{
    [Key(0)] public WriteValueResult[] Results { get; set; } = System.Array.Empty<WriteValueResult>();
}
