fix(historian): #690 Gateway raw/AtTime Bad rows carry no value (a stored NULL was value 0)

This commit is contained in:
Joseph Doherty
2026-10-12 16:08:54 -04:00
parent 1f5d310071
commit 39552e15b9
6 changed files with 68 additions and 4 deletions
@@ -32,6 +32,31 @@ public sealed class SampleMapperTests
Assert.Equal(0x80000000u, SampleMapper.ToSnapshot(s).StatusCode);
}
[Theory] // #690: histsdk puts a value on every row, so a NULL row arrives as 0 / "" with a Bad quality
[InlineData(0u, 1u)] // the live NULL row: opc_quality 0, AVEVA quality 1
[InlineData(24u, 0u)] // any Bad OPC quality (out of service)
public void A_Bad_numeric_row_carries_no_value(uint opc, uint quality)
{
var s = new HistorianSample { Tag = "T", NumericValue = 0, OpcQuality = opc, Quality = quality, Timestamp = Ts(2026, 1, 1, 0, 0, 0) };
var snap = SampleMapper.ToSnapshot(s);
Assert.True(snap.StatusCode >= 0x80000000u);
Assert.Null(snap.Value);
}
[Fact] // #690: a string tag's NULL row arrives as "" + Bad
public void A_Bad_string_row_carries_no_value()
{
var s = new HistorianSample { Tag = "T", StringValue = "", OpcQuality = 0, Quality = 1, Timestamp = Ts(2026, 1, 1, 0, 0, 0) };
Assert.Null(SampleMapper.ToSnapshot(s).Value);
}
[Fact] // #690: an Uncertain row keeps its value (only Bad means "no value")
public void An_Uncertain_row_keeps_its_value()
{
var s = new HistorianSample { Tag = "T", NumericValue = 3, OpcQuality = 64, Timestamp = Ts(2026, 1, 1, 0, 0, 0) };
Assert.Equal(3d, SampleMapper.ToSnapshot(s).Value);
}
[Fact]
public void Aggregate_null_value_is_BadNoData()
{