fix(modbus): equipment tags carry unitId; ResolveHost keys per-unit via the resolver (CONV-4)
This commit is contained in:
@@ -140,10 +140,19 @@ public sealed class ModbusDriver
|
||||
WriteHealth(new DriverHealth(DriverState.Degraded, current.LastSuccessfulRead, ex.Message));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Resolve a reference to the per-slave host key (<c>host:port/unitN</c>) that keys its
|
||||
/// per-host resilience (bulkhead / circuit breaker). CONV-4: routes through
|
||||
/// <see cref="EquipmentTagRefResolver{TDef}"/> so an equipment-tag reference (raw TagConfig
|
||||
/// JSON) keys its OWN authored unit — via the tag's optional <c>unitId</c> or the driver
|
||||
/// default — rather than the single-slave fallback. The resolver caches parses, so this adds
|
||||
/// no per-call cost after first use.
|
||||
/// </summary>
|
||||
/// <param name="fullReference">The tag reference (authored name or equipment-tag JSON).</param>
|
||||
/// <returns>The per-slave host key.</returns>
|
||||
public string ResolveHost(string fullReference)
|
||||
{
|
||||
if (_tagsByName.TryGetValue(fullReference, out var tag))
|
||||
if (_resolver.TryResolve(fullReference, out var tag))
|
||||
return BuildSlaveHostName(ResolveUnitId(tag));
|
||||
// Unknown reference — fall back to driver-instance host (single-slave behaviour).
|
||||
return HostName;
|
||||
|
||||
Reference in New Issue
Block a user