821763a09d
- I-1: an Empty sample is always Bad. The writer stores a non-Bad NaN/Inf as Empty+BadOutOfRange and any other non-Bad Empty as BadNoData; the updater refuses a non-Bad Empty with BadInvalidArgument; reads clamp a legacy non-Bad Empty row to BadNoData (Raw and AtTime). - Tag/source names over 400 chars are refused, never truncated: writer per-tag failure, updater BadInvalidArgument, reads not-found, events none. - HistorianInfoBits masks the historian bits before setting one. - AtTime past now, stepped from the last sample => UncertainDataSubNormal. - Bootstrapper: logger, 5 s negative cache, ClearPool + Warning when sp_releaseapplock fails. - Provider builds its shared state lazily (an invalid Schema no longer throws at Resolve); Kinds is a FrozenSet; Gateway reuses the recorder's DefaultSupportedKinds. - Cleanup: SqlHistorianDataTypes in its own file (updater dup removed), dead Invalidate and unused status consts deleted, named severity masks, alarm writer brace. Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe
46 lines
2.2 KiB
C#
46 lines
2.2 KiB
C#
using Shouldly;
|
|
using Xunit;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Driver.Historian.SqlServer.Tests;
|
|
|
|
/// <summary>The pinned SDK is the oracle for the info-bit constants (StatusCodeParityTests covers the named codes).</summary>
|
|
public sealed class StatusCodeOracleTests
|
|
{
|
|
[Fact]
|
|
public void Calculated_bits_match_the_SDK()
|
|
{
|
|
var sdk = new Opc.Ua.StatusCode(Opc.Ua.StatusCodes.Good).SetAggregateBits(Opc.Ua.AggregateBits.Calculated);
|
|
sdk.Code.ShouldBe(HistorianInfoBits.WithCalculated(SqlHistorianStatusCodes.Good));
|
|
((uint)Opc.Ua.AggregateBits.Calculated).ShouldBe(HistorianInfoBits.HistorianCalculated);
|
|
}
|
|
|
|
[Fact]
|
|
public void Interpolated_bits_match_the_SDK()
|
|
{
|
|
var sdk = new Opc.Ua.StatusCode(Opc.Ua.StatusCodes.Good).SetAggregateBits(Opc.Ua.AggregateBits.Interpolated);
|
|
sdk.Code.ShouldBe(HistorianInfoBits.WithInterpolated(SqlHistorianStatusCodes.Good));
|
|
((uint)Opc.Ua.AggregateBits.Interpolated).ShouldBe(HistorianInfoBits.HistorianInterpolated);
|
|
}
|
|
|
|
/// <summary>
|
|
/// A stored status that already carries a historian bit (a sample written via HistoryUpdate with the Calculated
|
|
/// bit, say) must come back with ONE historian bit, never both: the existing pair is masked off first. The SDK
|
|
/// agrees — <c>SetAggregateBits</c> replaces, it does not OR.
|
|
/// </summary>
|
|
[Fact]
|
|
public void Setting_one_historian_bit_clears_the_other()
|
|
{
|
|
var calculatedUncertain = SqlHistorianStatusCodes.UncertainDataSubNormal | 0x400u | HistorianInfoBits.HistorianCalculated;
|
|
var interpolated = HistorianInfoBits.WithInterpolated(calculatedUncertain);
|
|
interpolated.ShouldBe(SqlHistorianStatusCodes.UncertainDataSubNormal | 0x400u | HistorianInfoBits.HistorianInterpolated);
|
|
new Opc.Ua.StatusCode(interpolated).AggregateBits.ShouldBe(Opc.Ua.AggregateBits.Interpolated);
|
|
|
|
var interpolatedGood = 0x400u | HistorianInfoBits.HistorianInterpolated;
|
|
HistorianInfoBits.WithCalculated(interpolatedGood).ShouldBe(0x400u | HistorianInfoBits.HistorianCalculated);
|
|
}
|
|
|
|
[Fact]
|
|
public void Info_type_is_data_value() =>
|
|
HistorianInfoBits.InfoTypeDataValue.ShouldBe(0x400u);
|
|
}
|