using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
namespace ZB.MOM.WW.OtOpcUa.Driver.Historian.Conformance;
/// Shared fixture data of the conformance suite. is deliberately NOT millisecond- or microsecond-aligned.
public static class ConformanceData
{
/// Base time: 2026-10-09 08:00:00.1234567 UTC (sub-millisecond ticks on purpose).
public static readonly DateTime T0 = new DateTime(2026, 10, 9, 8, 0, 0, DateTimeKind.Utc).AddTicks(1_234_567);
/// Good.
public const uint Good = 0x00000000u;
/// Bad (generic).
public const uint Bad = 0x80000000u;
/// BadNoCommunication.
public const uint BadNoCommunication = 0x80310000u;
/// Uncertain (generic).
public const uint Uncertain = 0x40000000u;
/// T0 + seconds.
public static DateTime At(double seconds) => T0.AddTicks((long)(seconds * TimeSpan.TicksPerSecond));
/// The fixture tag A: +0=10, +10=20, +20=Bad(30), +30=40, +40=50 (Double).
public static Task SeedAAsync(IConformanceBackend b, string name = "A") => b.SeedAsync(name,
(At(0), HistorianValue.FromDouble(10), Good),
(At(10), HistorianValue.FromDouble(20), Good),
(At(20), HistorianValue.FromDouble(30), Bad),
(At(30), HistorianValue.FromDouble(40), Good),
(At(40), HistorianValue.FromDouble(50), Good));
}
/// A settable clock for a data source's "now".
public sealed class ConformanceClock(DateTimeOffset now) : TimeProvider
{
/// The current instant.
public DateTimeOffset Now { get; set; } = now;
///
public override DateTimeOffset GetUtcNow() => Now;
}