using System;

namespace ZB.MOM.WW.OtOpcUa.Driver.Historian.Wonderware.Backend
{
    /// <summary>
    ///     OPC-UA-free representation of a single historical data point. The sidecar serialises
    ///     these onto the named-pipe wire (<c>HistorianSampleDto</c>) for the .NET 10
    ///     <c>WonderwareHistorianClient</c>, which maps quality and value into OPC UA
    ///     <c>DataValue</c> on its side. Raw OPC DA quality byte is preserved so the client
    ///     can reuse the same quality mapper it already uses for live reads.
    /// </summary>
    public sealed class HistorianSample
    {
        /// <summary>Gets or sets the historical data value.</summary>
        public object? Value { get; set; }

        /// <summary>Gets or sets the raw OPC DA quality byte from the historian SDK (low 8 bits of OpcQuality).</summary>
        public byte Quality { get; set; }

        /// <summary>Gets or sets the UTC timestamp of the historical sample.</summary>
        public DateTime TimestampUtc { get; set; }
    }

    /// <summary>
    ///     Result of <see cref="IHistorianDataSource.ReadAggregateAsync"/>. When <see cref="Value"/> is
    ///     null the aggregate is unavailable for that bucket — the client maps to <c>BadNoData</c>.
    /// </summary>
    public sealed class HistorianAggregateSample
    {
        /// <summary>Gets or sets the aggregate value, or null if unavailable.</summary>
        public double? Value { get; set; }
        /// <summary>Gets or sets the UTC timestamp of the aggregate sample.</summary>
        public DateTime TimestampUtc { get; set; }
    }
}
