refactor(mtconnect): delete dead parsed fields (R06:T-3)

MTConnectObservation.SampleRate was parsed per observation and never read;
MTConnectTagDefinition.MtType/MtSubType/Units were carried (factory blob DTO,
tags[] DTO, probe inference) and only MtCategory was ever read. Deleted. Stored
configs and TagConfig blobs still carrying mtType/mtSubType/units keep loading
(System.Text.Json skips unmapped members) - pinned by a new test. The AdminUI tag
editor reads those keys straight off the blob and is unaffected.

Refs #743

Claude-Session: https://claude.ai/code/session_01Ub9hGmYLQvn9XETzw7CMsT
This commit is contained in:
Joseph Doherty
2026-10-22 15:42:32 -04:00
parent b548cc46e6
commit 994c0b3b19
7 changed files with 49 additions and 72 deletions
@@ -95,14 +95,11 @@ public sealed class MTConnectDriverOptionsTests
var pos = new MTConnectTagDefinition(
FullName: "dev1_pos",
DriverDataType: ZB.MOM.WW.OtOpcUa.Core.Abstractions.DriverDataType.Float64,
MtCategory: "SAMPLE",
MtType: "POSITION",
Units: "MILLIMETER");
MtCategory: "SAMPLE");
var partCount = new MTConnectTagDefinition(
FullName: "dev1_partcount",
DriverDataType: ZB.MOM.WW.OtOpcUa.Core.Abstractions.DriverDataType.Int64,
MtCategory: "EVENT",
MtType: "PART_COUNT");
MtCategory: "EVENT");
var o = new MTConnectDriverOptions { AgentUri = "http://agent:5000", Tags = [pos, partCount] };
@@ -111,25 +108,47 @@ public sealed class MTConnectDriverOptionsTests
o.Tags[1].ShouldBe(partCount);
}
/// <summary>MTConnectTagDefinition round-trips its positional fields, including MTConnect metadata.</summary>
/// <summary>MTConnectTagDefinition round-trips its positional fields, including the category the write path reads.</summary>
[Fact]
public void TagDefinition_carries_dataItemId_and_mtconnect_metadata()
public void TagDefinition_carries_dataItemId_and_mtconnect_category()
{
var tag = new MTConnectTagDefinition(
FullName: "dtop_2",
DriverDataType: ZB.MOM.WW.OtOpcUa.Core.Abstractions.DriverDataType.Float64,
MtCategory: "SAMPLE",
MtType: "POSITION",
MtSubType: "ACTUAL",
Units: "MILLIMETER");
MtCategory: "SAMPLE");
tag.FullName.ShouldBe("dtop_2");
tag.DriverDataType.ShouldBe(ZB.MOM.WW.OtOpcUa.Core.Abstractions.DriverDataType.Float64);
tag.IsArray.ShouldBeFalse();
tag.ArrayDim.ShouldBe(0);
tag.MtCategory.ShouldBe("SAMPLE");
tag.MtType.ShouldBe("POSITION");
tag.MtSubType.ShouldBe("ACTUAL");
tag.Units.ShouldBe("MILLIMETER");
}
/// <summary>
/// Review 2026-10-21 T-3: mtType / mtSubType / units were deleted from the definition as dead, but a stored
/// config that still carries them — in tags[] or in a raw tag's TagConfig blob — must keep loading.
/// </summary>
[Fact]
public void Stored_configs_carrying_the_deleted_metadata_keys_still_load()
{
const string config = """
{
"agentUri": "http://agent:5000",
"tags": [ { "fullName": "dev1_pos", "driverDataType": "Float64", "mtCategory": "SAMPLE",
"mtType": "POSITION", "mtSubType": "ACTUAL", "units": "MILLIMETER" } ]
}
""";
var options = MTConnectDriver.ParseOptions("mt-t3", config);
options.Tags.ShouldHaveSingleItem().ShouldBe(new MTConnectTagDefinition(
"dev1_pos", ZB.MOM.WW.OtOpcUa.Core.Abstractions.DriverDataType.Float64, MtCategory: "SAMPLE"));
MTConnectTagDefinitionFactory.TryFromTagConfig(
"""{ "dataItemId": "dev1_pos", "dataType": "Float64", "mtCategory": "SAMPLE", "mtType": "POSITION", "mtSubType": "ACTUAL", "units": "MILLIMETER" }""",
out var dataItemId, out var authored)
.ShouldBeTrue();
dataItemId.ShouldBe("dev1_pos");
authored.ShouldNotBeNull().MtCategory.ShouldBe("SAMPLE");
}
}
@@ -502,14 +502,13 @@ public sealed class MTConnectObservationIndexTests
idx.Get("dev1_vibration_ts").StatusCode.ShouldBe(BadNotSupported);
}
/// <summary>The parser carries the observation's own sampleCount / sampleRate attributes.</summary>
/// <summary>The parser carries the observation's own sampleCount (sampleRate is not parsed — T-3: nothing read it).</summary>
[Fact]
public void Parser_carries_time_series_sampleCount_and_sampleRate()
public void Parser_carries_time_series_sampleCount()
{
var obs = ParseFixture(CurrentFixture).Observations.Single(o => o.DataItemId == "dev1_vibration_ts");
obs.SampleCount.ShouldBe(10);
obs.SampleRate.ShouldBe(100.0);
ParseFixture(CurrentFixture).Observations.Single(o => o.DataItemId == "dev1_pos").SampleCount.ShouldBeNull();
}