Skip to content

gantry_factory

gantry_factory

Factory helpers for building gantry axes and backend state from config.

GantryConstruction dataclass

GantryConstruction(
    axes: AxisMap,
    concurrent_axes: AxisMap | None,
    backend: GantryBackend,
)

Fully built gantry components returned by config factories.

Parameters:

Name Type Description Default
axes AxisMap

Mapping of axis names to constructed axis objects.

required
concurrent_axes AxisMap | None

Optional concurrent movement subset.

required
backend GantryBackend

Backend strategy that owns shared gantry behavior.

required

build_modbus_gantry

build_modbus_gantry(
    config: dict | str | Path, name: str = "gantry_1"
) -> GantryConstruction

Build Modbus gantry axes and backend from config.

Parameters:

Name Type Description Default
config dict | str | Path

Parsed config mapping or JSON file path.

required
name str

Component name to load.

'gantry_1'

Returns:

Type Description
GantryConstruction

Gantry construction bundle for Modbus backend.

Source code in src/applied_motion/gantry_factory.py
def build_modbus_gantry(config: dict | str | Path, name: str = "gantry_1") -> GantryConstruction:
    """Build Modbus gantry axes and backend from config.

    Args:
        config: Parsed config mapping or JSON file path.
        name: Component name to load.

    Returns:
        Gantry construction bundle for Modbus backend.
    """
    gcfg = GantryConfig(SystemConfig(_coerce_config_source(config))(), name)
    return _build_modbus_from_gcfg(gcfg)

build_fposbapi_gantry

build_fposbapi_gantry(
    config: dict | str | Path, name: str = "gantry_1"
) -> GantryConstruction

Build FPosBAPI gantry axes and backend from config.

Parameters:

Name Type Description Default
config dict | str | Path

Parsed config mapping or JSON file path.

required
name str

Component name to load.

'gantry_1'

Returns:

Type Description
GantryConstruction

Gantry construction bundle for FPosBAPI backend.

Source code in src/applied_motion/gantry_factory.py
def build_fposbapi_gantry(config: dict | str | Path, name: str = "gantry_1") -> GantryConstruction:
    """Build FPosBAPI gantry axes and backend from config.

    Args:
        config: Parsed config mapping or JSON file path.
        name: Component name to load.

    Returns:
        Gantry construction bundle for FPosBAPI backend.
    """
    gcfg = GantryConfig(SystemConfig(_coerce_config_source(config))(), name)
    return _build_fposbapi_from_gcfg(gcfg)

build_gantry_from_config

build_gantry_from_config(
    config: dict | str | Path, name: str = "gantry_1"
) -> GantryConstruction

Build gantry components for configured backend.

Parameters:

Name Type Description Default
config dict | str | Path

Parsed config mapping or JSON file path.

required
name str

Component name to load.

'gantry_1'

Returns:

Type Description
GantryConstruction

Gantry construction bundle.

Source code in src/applied_motion/gantry_factory.py
def build_gantry_from_config(config: dict | str | Path, name: str = "gantry_1") -> GantryConstruction:
    """Build gantry components for configured backend.

    Args:
        config: Parsed config mapping or JSON file path.
        name: Component name to load.

    Returns:
        Gantry construction bundle.
    """
    gcfg = GantryConfig(SystemConfig(_coerce_config_source(config))(), name)
    if gcfg.backend == "modbus":
        return _build_modbus_from_gcfg(gcfg)
    return _build_fposbapi_from_gcfg(gcfg)