feat(mtconnect): authoring DataType warning + loud ignored-DeviceName warning (#613 slice)

Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe
This commit is contained in:
Joseph Doherty
2026-10-08 06:51:40 -04:00
parent 3baa332d6b
commit b78c7ff9db
6 changed files with 162 additions and 2 deletions
@@ -3232,6 +3232,29 @@ public sealed class MTConnectDriver
// ---- v3 tag binding: RawPath ↔ dataItemId, and the definitions the index coerces against ----
/// <summary>
/// Names the distinct, non-blank <see cref="RawTagEntry.DeviceName"/> values when there are two or
/// more, else <c>null</c> (#613). The driver never routes by that field — one instance owns one
/// Agent client — so differing values mean the author expects a split the driver silently does
/// not perform. A single value is NOT reported: it is the <c>/raw</c> Device's own name, which
/// routinely differs from the Agent's device name and would make the warning noise.
/// </summary>
/// <param name="rawTags">The authored raw tags.</param>
/// <returns>A comma-joined, sorted list of the distinct names, or <c>null</c> when fewer than two.</returns>
internal static string? DescribeIgnoredDeviceNames(IReadOnlyList<RawTagEntry> rawTags)
{
var names = new SortedSet<string>(StringComparer.Ordinal);
foreach (var entry in rawTags)
{
if (entry is not null && !string.IsNullOrWhiteSpace(entry.DeviceName))
{
names.Add(entry.DeviceName.Trim());
}
}
return names.Count >= 2 ? string.Join(", ", names) : null;
}
/// <summary>
/// Derives the driver's tag tables from an options document — the <c>RawPath → dataItemId</c>
/// translation the data plane runs through, its reverse, and the definition set the
@@ -3295,6 +3318,13 @@ public sealed class MTConnectDriver
BuildWriteTargets(only, probeModel, options.DeviceName));
}
if (DescribeIgnoredDeviceNames(options.RawTags) is { } ignoredDevices)
{
_logger.LogWarning(
"MTConnect driver {DriverInstanceId}: raw tags carry differing DeviceName values ({DeviceNames}), but RawTagEntry.DeviceName is not used for routing — every tag is served from the one Agent connection scoped by the driver-level DeviceName ({ConfiguredDevice}). Author one MTConnect driver instance per Agent device if they must be kept apart.",
_driverInstanceId, ignoredDevices, options.DeviceName ?? "<whole Agent>");
}
var declared = IndexProbeDataItems(probeModel);
var idByRawPath = new Dictionary<string, string>(options.RawTags.Count, StringComparer.Ordinal);
var rawPathsById = new Dictionary<string, List<string>>(StringComparer.Ordinal);