Skip to content

gantry_backend

gantry_backend

Backend abstractions for gantry-level behavior.

This module centralizes backend-specific operations that are not purely per-axis concerns (for example a single HOME command for all FPosB axes).

ControllerDiagnostics

Bases: TypedDict

Controller diagnostics payload returned by gantry backends.

GantryBackend

Bases: Protocol

Protocol for backend-specific gantry actions.

A backend may own shared resources (for example a TCP client) and can expose backend capabilities such as PLC teaching commands.

client property

client: FPosBAPIClient | None

Return the shared FPosBAPI client if this backend uses one.

backend_identity

backend_identity() -> tuple[
    type[object], tuple[str, int] | None
]

Return stable backend identity fields used for equality/hash.

Source code in src/applied_motion/backends/gantry_backend.py
def backend_identity(self) -> tuple[type[object], tuple[str, int] | None]:
    """Return stable backend identity fields used for equality/hash."""
    ...

controller_diagnostics

controller_diagnostics() -> ControllerDiagnostics | None

Return controller diagnostics for status reporting, if available.

Source code in src/applied_motion/backends/gantry_backend.py
def controller_diagnostics(self) -> ControllerDiagnostics | None:
    """Return controller diagnostics for status reporting, if available."""
    ...

home

home(axes: dict[str, Axis]) -> None

Home all axes represented by axes.

Source code in src/applied_motion/backends/gantry_backend.py
def home(self, axes: dict[str, Axis]) -> None:
    """Home all axes represented by *axes*."""
    ...

close

close() -> None

Release backend-owned resources.

Source code in src/applied_motion/backends/gantry_backend.py
def close(self) -> None:
    """Release backend-owned resources."""
    ...

supports_teach

supports_teach() -> bool

Return whether TEACH_POS / TEACH_TRAY operations are supported.

Source code in src/applied_motion/backends/gantry_backend.py
def supports_teach(self) -> bool:
    """Return whether TEACH_POS / TEACH_TRAY operations are supported."""
    ...

teach_pos

teach_pos(pos_id: int) -> None

Commit current location into PLC position slot pos_id.

Source code in src/applied_motion/backends/gantry_backend.py
def teach_pos(self, pos_id: int) -> None:
    """Commit current location into PLC position slot *pos_id*."""
    ...

teach_tray

teach_tray(tray_id: int, tray_pos: int) -> None

Commit current location into PLC tray slot (tray_id, tray_pos).

Source code in src/applied_motion/backends/gantry_backend.py
def teach_tray(self, tray_id: int, tray_pos: int) -> None:
    """Commit current location into PLC tray slot (*tray_id*, *tray_pos*)."""
    ...

list_commands

list_commands() -> list[str]

Return backend command list when available.

Source code in src/applied_motion/backends/gantry_backend.py
def list_commands(self) -> list[str]:
    """Return backend command list when available."""
    ...

ModbusGantryBackend

Gantry backend for direct Modbus axes.

This backend owns no shared resources and uses per-axis operations only.

client property

client: FPosBAPIClient | None

Modbus backend has no shared FPosBAPI client.

backend_identity

backend_identity() -> tuple[
    type[object], tuple[str, int] | None
]

Return Modbus backend identity.

Source code in src/applied_motion/backends/gantry_backend.py
def backend_identity(self) -> tuple[type[object], tuple[str, int] | None]:
    """Return Modbus backend identity."""
    return type(self), None

controller_diagnostics

controller_diagnostics() -> ControllerDiagnostics | None

Modbus backend has no shared controller diagnostics.

Source code in src/applied_motion/backends/gantry_backend.py
def controller_diagnostics(self) -> ControllerDiagnostics | None:
    """Modbus backend has no shared controller diagnostics."""
    return None

home

home(axes: dict[str, Axis]) -> None

Home each axis sequentially.

Source code in src/applied_motion/backends/gantry_backend.py
def home(self, axes: dict[str, Axis]) -> None:
    """Home each axis sequentially."""
    for axis in axes.values():
        axis.home()

close

close() -> None

Close backend resources.

Modbus backend currently has no shared resources to close.

Source code in src/applied_motion/backends/gantry_backend.py
def close(self) -> None:
    """Close backend resources.

    Modbus backend currently has no shared resources to close.
    """

supports_teach

supports_teach() -> bool

Return whether teaching commands are supported.

Source code in src/applied_motion/backends/gantry_backend.py
def supports_teach(self) -> bool:
    """Return whether teaching commands are supported."""
    return False

teach_pos

teach_pos(pos_id: int) -> None

Raise for unsupported teaching operations.

Source code in src/applied_motion/backends/gantry_backend.py
def teach_pos(self, pos_id: int) -> None:
    """Raise for unsupported teaching operations."""
    raise NotImplementedError("teach_pos is only available for FPosBAPI backend")

teach_tray

teach_tray(tray_id: int, tray_pos: int) -> None

Raise for unsupported teaching operations.

Source code in src/applied_motion/backends/gantry_backend.py
def teach_tray(self, tray_id: int, tray_pos: int) -> None:
    """Raise for unsupported teaching operations."""
    raise NotImplementedError("teach_tray is only available for FPosBAPI backend")

list_commands

list_commands() -> list[str]

Return an empty command list for unsupported operation.

Source code in src/applied_motion/backends/gantry_backend.py
def list_commands(self) -> list[str]:
    """Return an empty command list for unsupported operation."""
    return []

FPosBAPIGantryBackend

FPosBAPIGantryBackend(
    client: FPosBAPIClient, owns_client: bool = True
)

Gantry backend for PLC-controlled FPosBAPI systems.

Store the shared client.

Parameters:

Name Type Description Default
client FPosBAPIClient

Shared PLC TCP client.

required
owns_client bool

When True, close closes client.

True
Source code in src/applied_motion/backends/gantry_backend.py
def __init__(self, client: FPosBAPIClient, owns_client: bool = True) -> None:
    """Store the shared client.

    Args:
        client: Shared PLC TCP client.
        owns_client: When ``True``, [`close`][applied_motion.backends.gantry_backend.FPosBAPIGantryBackend.close] closes *client*.
    """
    self._client = client
    self._owns_client = owns_client
    self._closed = False

client property

client: FPosBAPIClient | None

Return the shared FPosBAPI client.

backend_identity

backend_identity() -> tuple[
    type[object], tuple[str, int] | None
]

Return FPosBAPI backend identity including endpoint.

Source code in src/applied_motion/backends/gantry_backend.py
def backend_identity(self) -> tuple[type[object], tuple[str, int] | None]:
    """Return FPosBAPI backend identity including endpoint."""
    return type(self), (self._client.ip, self._client.port)

controller_diagnostics

controller_diagnostics() -> ControllerDiagnostics | None

Return controller diagnostics from shared client.

Source code in src/applied_motion/backends/gantry_backend.py
def controller_diagnostics(self) -> ControllerDiagnostics | None:
    """Return controller diagnostics from shared client."""
    try:
        return {
            "sys_status": self._client.sys_status(),
            "is_error": self._client.is_error(),
            "fpb_error": self._client.fpb_error(),
            "read_err": self._client.read_err(),
            "error": None,
        }
    except Exception as exc:
        return {
            "sys_status": None,
            "is_error": None,
            "fpb_error": None,
            "read_err": None,
            "error": f"{type(exc).__name__}: {exc}",
        }

home

home(axes: dict[str, Axis]) -> None

Home all axes through one PLC HOME command.

Source code in src/applied_motion/backends/gantry_backend.py
def home(self, axes: dict[str, Axis]) -> None:
    """Home all axes through one PLC HOME command."""
    self._client.send_command("HOME")

close

close() -> None

Close owned shared client exactly once.

Source code in src/applied_motion/backends/gantry_backend.py
def close(self) -> None:
    """Close owned shared client exactly once."""
    if self._closed or not self._owns_client:
        return
    self._client.close()
    self._closed = True

supports_teach

supports_teach() -> bool

Return whether teaching commands are supported.

Source code in src/applied_motion/backends/gantry_backend.py
def supports_teach(self) -> bool:
    """Return whether teaching commands are supported."""
    return True

teach_pos

teach_pos(pos_id: int) -> None

Delegate TEACH_POS to shared client.

Source code in src/applied_motion/backends/gantry_backend.py
def teach_pos(self, pos_id: int) -> None:
    """Delegate TEACH_POS to shared client."""
    self._client.teach_pos(pos_id=pos_id)

teach_tray

teach_tray(tray_id: int, tray_pos: int) -> None

Delegate TEACH_TRAY to shared client.

Source code in src/applied_motion/backends/gantry_backend.py
def teach_tray(self, tray_id: int, tray_pos: int) -> None:
    """Delegate TEACH_TRAY to shared client."""
    self._client.teach_tray(tray_id=tray_id, tray_pos=tray_pos)

list_commands

list_commands() -> list[str]

Return command list from the shared client.

Source code in src/applied_motion/backends/gantry_backend.py
def list_commands(self) -> list[str]:
    """Return command list from the shared client."""
    return self._client.list_commands()