namespace ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared.Drivers.Pickers;

/// <summary>
/// Pure static helper that converts Modbus register-type + offset + length into
/// the canonical address string used by the Modbus driver (e.g. 4x00001-1).
/// Extracted so unit tests can call it without bUnit.
/// </summary>
public static class ModbusAddressBuilder
{
    public static string Build(string regType, int offset, int length)
    {
        var prefix = regType switch
        {
            "Coil"          => "0x",
            "DiscreteInput" => "1x",
            "Input"         => "3x",
            "Holding"       => "4x",
            _               => "4x",
        };
        return $"{prefix}{offset:00000}-{length}";
    }
}
