c5b33aa123
Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe
41 lines
1.8 KiB
C#
41 lines
1.8 KiB
C#
using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Driver.Historian.Conformance;
|
|
|
|
/// <summary>Shared fixture data of the conformance suite. <see cref="T0"/> is deliberately NOT millisecond- or microsecond-aligned.</summary>
|
|
public static class ConformanceData
|
|
{
|
|
/// <summary>Base time: 2026-10-09 08:00:00.1234567 UTC (sub-millisecond ticks on purpose).</summary>
|
|
public static readonly DateTime T0 = new DateTime(2026, 10, 9, 8, 0, 0, DateTimeKind.Utc).AddTicks(1_234_567);
|
|
|
|
/// <summary>Good.</summary>
|
|
public const uint Good = 0x00000000u;
|
|
/// <summary>Bad (generic).</summary>
|
|
public const uint Bad = 0x80000000u;
|
|
/// <summary>BadNoCommunication.</summary>
|
|
public const uint BadNoCommunication = 0x80310000u;
|
|
/// <summary>Uncertain (generic).</summary>
|
|
public const uint Uncertain = 0x40000000u;
|
|
|
|
/// <summary>T0 + <paramref name="seconds"/> seconds.</summary>
|
|
public static DateTime At(double seconds) => T0.AddTicks((long)(seconds * TimeSpan.TicksPerSecond));
|
|
|
|
/// <summary>The fixture tag A: +0=10, +10=20, +20=Bad(30), +30=40, +40=50 (Double).</summary>
|
|
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));
|
|
}
|
|
|
|
/// <summary>A settable clock for a data source's "now".</summary>
|
|
public sealed class ConformanceClock(DateTimeOffset now) : TimeProvider
|
|
{
|
|
/// <summary>The current instant.</summary>
|
|
public DateTimeOffset Now { get; set; } = now;
|
|
|
|
/// <inheritdoc/>
|
|
public override DateTimeOffset GetUtcNow() => Now;
|
|
}
|