Skip to content

backends

backends

Backend implementations for festo-dev-applied-motion axis communication.

Axis

Bases: Protocol

Structural interface for a single controllable axis.

Both EdconAxis (Modbus/festo-edcon backend) and FPosBAxis (FPosBAPI backend) satisfy this protocol structurally — no explicit inheritance required.

All position values are in millimetres (mm). All velocity values are in mm/s.

move

move(position: float, velocity: float, **kwargs) -> bool

Move the axis to position at velocity.

Parameters:

Name Type Description Default
position float

Target position in mm (absolute or relative depending on position_type kwarg).

required
velocity float

Move speed in mm/s.

required
**kwargs

Backend-specific options (e.g. position_type, timeout).

{}

Returns:

Type Description
bool

True if the move completed successfully.

Source code in src/applied_motion/backends/axis_protocol.py
def move(self, position: float, velocity: float, **kwargs) -> bool:
    """Move the axis to *position* at *velocity*.

    Args:
        position: Target position in mm (absolute or relative depending on
            ``position_type`` kwarg).
        velocity: Move speed in mm/s.
        **kwargs: Backend-specific options (e.g. ``position_type``,
            ``timeout``).

    Returns:
        ``True`` if the move completed successfully.
    """
    ...

home

home() -> bool

Run the axis homing/referencing sequence.

Source code in src/applied_motion/backends/axis_protocol.py
def home(self) -> bool:
    """Run the axis homing/referencing sequence."""
    ...

get_current_axis_position

get_current_axis_position() -> float

Return the current axis position in mm.

Returns:

Type Description
float

Current position in mm.

Source code in src/applied_motion/backends/axis_protocol.py
def get_current_axis_position(self) -> float:
    """Return the current axis position in mm.

    Returns:
        Current position in mm.
    """
    ...

is_homed

is_homed() -> bool

Return whether this axis reports a valid homed/reference state.

Returns:

Type Description
bool

True if this axis is homed/referenced; False otherwise.

Source code in src/applied_motion/backends/axis_protocol.py
def is_homed(self) -> bool:
    """Return whether this axis reports a valid homed/reference state.

    Returns:
        ``True`` if this axis is homed/referenced; ``False`` otherwise.
    """
    ...

stopped

stopped() -> bool

Return True when the axis is not currently in motion.

Returns:

Type Description
bool

True if the axis has stopped; False if motion is ongoing.

Source code in src/applied_motion/backends/axis_protocol.py
def stopped(self) -> bool:
    """Return ``True`` when the axis is not currently in motion.

    Returns:
        ``True`` if the axis has stopped; ``False`` if motion is ongoing.
    """
    ...

acknowledge_faults

acknowledge_faults()

Clear errors.

Source code in src/applied_motion/backends/axis_protocol.py
def acknowledge_faults(self):
    """Clear errors."""
    # TODO: This shouldn't be exposed to end-users. This is done automatically for almost every motion task to proceed and is part of an internal interface.
    ...

enable_powerstage

enable_powerstage()

Turn on torque to motor controlling this axis.

Source code in src/applied_motion/backends/axis_protocol.py
def enable_powerstage(self):
    """Turn on torque to motor controlling this axis."""
    # TODO: This shouldn't be exposed to end-users. This is done automatically for almost every motion task to proceed and is part of an internal interface.
    ...

disable_powerstage

disable_powerstage()

Turn off torque to motor controlling this axis.

Source code in src/applied_motion/backends/axis_protocol.py
def disable_powerstage(self):
    """Turn off torque to motor controlling this axis."""
    ...

current_position

current_position()

Return current position.

Source code in src/applied_motion/backends/axis_protocol.py
def current_position(self):
    """Return current position."""
    ...

current_velocity

current_velocity()

Return current velocity.

Source code in src/applied_motion/backends/axis_protocol.py
def current_velocity(self):
    """Return current velocity."""
    ...

jog_task

jog_task(
    jog_positive: bool = True,
    jog_negative: bool = False,
    incremental: bool = False,
    duration: float = 0.0,
) -> bool

Jog the axis according to backend-specific jog semantics.

Parameters:

Name Type Description Default
jog_positive bool

When True, request jog in the positive direction.

True
jog_negative bool

When True, request jog in the negative direction.

False
incremental bool

Backend-specific incremental jog mode flag.

False
duration float

Optional jog duration in seconds. A value of 0 starts the jog and returns immediately.

0.0

Returns:

Type Description
bool

True if the jog command succeeds; False otherwise.

Source code in src/applied_motion/backends/axis_protocol.py
def jog_task(
    self,
    jog_positive: bool = True,
    jog_negative: bool = False,
    incremental: bool = False,
    duration: float = 0.0,
) -> bool:
    """Jog the axis according to backend-specific jog semantics.

    Args:
        jog_positive: When ``True``, request jog in the positive direction.
        jog_negative: When ``True``, request jog in the negative direction.
        incremental: Backend-specific incremental jog mode flag.
        duration: Optional jog duration in seconds. A value of ``0``
            starts the jog and returns immediately.

    Returns:
        ``True`` if the jog command succeeds; ``False`` otherwise.
    """
    # TODO: Implement this functionality using corresponding FPosBAPI command

    ...

ready_for_motion

ready_for_motion() -> bool

Return True when the axis is ready to accept a move command.

Returns:

Type Description
bool

True if the axis is enabled, homed, and fault-free.

Source code in src/applied_motion/backends/axis_protocol.py
def ready_for_motion(self) -> bool:
    """Return ``True`` when the axis is ready to accept a move command.

    Returns:
        ``True`` if the axis is enabled, homed, and fault-free.
    """
    ...

FPosBAxis

FPosBAxis(name: str, index: int, client: FPosBAPIClient)

FPosBAPI-backed representation of a single CECC-X gantry axis.

Wraps MOVE_AXIS, HOME, and ROB_POS FPosBAPI commands behind the same public interface as EdconAxis. All socket communication is performed via the shared client instance which must be owned by the parent Gantry.

Attributes:

Name Type Description
name

Human-readable axis label, e.g. "X".

index

1-based axis number sent to MOV_AXIS (1=X, 2=Y, 3=Z by CECC-X convention).

Initialise the axis proxy.

Parameters:

Name Type Description Default
name str

Human-readable axis label used in log messages and equality checks.

required
index int

1-based axis index for MOVE_AXIS commands. Must match the axis numbering configured in the CECC-X CoDeSys program.

required
client FPosBAPIClient

Shared FPosBAPIClient instance owned by the parent gantry.

required
Source code in src/applied_motion/backends/fposbapi_axis.py
def __init__(self, name: str, index: int, client: FPosBAPIClient) -> None:
    """Initialise the axis proxy.

    Args:
        name: Human-readable axis label used in log messages and equality
            checks.
        index: 1-based axis index for ``MOVE_AXIS`` commands.  Must match
            the axis numbering configured in the CECC-X CoDeSys program.
        client: Shared [`FPosBAPIClient`][applied_motion.backends.fposbapi_client.FPosBAPIClient]
            instance owned by the parent gantry.
    """
    self.name = name
    self.index = index
    self._client = client
    self.min_position: float = -inf
    self.max_position: float = inf
    logger.info("FPosBAxis '%s' (index=%d) created", name, index)

move

move(
    position: float,
    velocity: float,
    timeout: int | None = None,
    **kwargs,
) -> bool

Move this axis to position at velocity.

Sets the global gantry speed (parameter 103) to velocity before issuing the MOVE_AXIS command. The call blocks until the PLC reports SUCCESS.

Parameters:

Name Type Description Default
position float

Target position in mm. Interpreted as absolute by default; pass position_type="relative" in kwargs for a relative displacement.

required
velocity float

Move speed in mm/s. Written to PLC parameter 103 (global speed) before the move.

required
timeout int | None

Optional per-command socket timeout in seconds for the MOVE_AXIS request. None means blocking mode for this request.

None
**kwargs

Optional keyword overrides. Recognised keys:

  • position_type (str): "absolute" (default) or "relative".
{}

Returns:

Type Description
bool

True when both the speed parameter and move commands succeed;

bool

False if the PLC rejects either command.

Raises:

Type Description
~FPosBAPICommunicationError

If a communication or protocol failure occurs.

Source code in src/applied_motion/backends/fposbapi_axis.py
def move(self, position: float, velocity: float, timeout: int | None = None, **kwargs) -> bool:
    """Move this axis to *position* at *velocity*.

    Sets the global gantry speed (parameter 103) to *velocity* before
    issuing the ``MOVE_AXIS`` command.  The call blocks until the PLC
    reports ``SUCCESS``.

    Args:
        position: Target position in mm.  Interpreted as absolute by
            default; pass ``position_type="relative"`` in *kwargs* for a
            relative displacement.
        velocity: Move speed in mm/s.  Written to PLC parameter 103
            (global speed) before the move.
        timeout: Optional per-command socket timeout in seconds for the
            ``MOVE_AXIS`` request.  ``None`` means blocking mode for this
            request.
        **kwargs: Optional keyword overrides.  Recognised keys:

            - ``position_type`` (``str``): ``"absolute"`` (default) or
              ``"relative"``.

    Returns:
        ``True`` when both the speed parameter and move commands succeed;
        ``False`` if the PLC rejects either command.

    Raises:
        ~applied_motion.backends.fposbapi_client.FPosBAPICommunicationError: If a
            communication or protocol failure occurs.
    """
    position_type = kwargs.get("position_type", "absolute")
    rel_flag = 0 if position_type == "absolute" else 1
    logger.debug(
        "FPosBAxis '%s': move position=%s velocity=%s rel_flag=%d",
        self.name,
        position,
        velocity,
        rel_flag,
    )
    if not self._client.try_command("SET_PAR", 103, velocity):
        return False
    result = self._client.try_command("MOVE_AXIS", self.index, rel_flag, position, timeout=timeout)
    if result:
        logger.info(
            "FPosBAxis '%s': move complete (position=%s mm, velocity=%s mm/s)",
            self.name,
            position,
            velocity,
        )
    return result

home

home() -> bool

Issue the HOME command, homing all axes together.

The FPosBAPI HOME command references every axis simultaneously — there is no per-axis home. Calling this method on any individual proxy triggers a full multi-axis homing sequence.

.. note:: Gantry.home sends a single HOME command at the gantry level and does not call this method on each proxy individually, avoiding duplicate HOME requests.

Returns:

Type Description
bool

True when the PLC reports the HOME command succeeded; False

bool

if the PLC rejects it.

Raises:

Type Description
~FPosBAPICommunicationError

If a communication or protocol failure occurs.

Source code in src/applied_motion/backends/fposbapi_axis.py
def home(self) -> bool:
    """Issue the ``HOME`` command, homing all axes together.

    The FPosBAPI ``HOME`` command references every axis simultaneously —
    there is no per-axis home.  Calling this method on any individual
    proxy triggers a full multi-axis homing sequence.

    .. note::
        [`Gantry.home`][applied_motion.applied_motion.Gantry.home] sends a single
        ``HOME`` command at the gantry level and does not call this method
        on each proxy individually, avoiding duplicate ``HOME`` requests.

    Returns:
        ``True`` when the PLC reports the HOME command succeeded; ``False``
        if the PLC rejects it.

    Raises:
        ~applied_motion.backends.fposbapi_client.FPosBAPICommunicationError: If a
            communication or protocol failure occurs.
    """
    logger.info("FPosBAxis '%s': issuing HOME command (homes all axes)", self.name)
    return self._client.try_command("HOME", timeout=None)

get_current_axis_position

get_current_axis_position() -> float

Return this axis's current position in mm via ROB_POS.

Sends ROB_POS and extracts this axis's coordinate from the response. Assumes the response layout::

1
msg_id, ROB_POS, x_mm, y_mm, z_mm, 0, NULL, SUCCESS

where the position field for axis n is at fields[n + 1] (1-based field numbering after stripping the leading msg_id and ROB_POS label fields).

Returns:

Type Description
float

Current axis position in mm.

Raises:

Type Description
RuntimeError

If the response cannot be parsed.

~FPosBAPIClientError

If the PLC returns an error response.

Source code in src/applied_motion/backends/fposbapi_axis.py
def get_current_axis_position(self) -> float:
    """Return this axis's current position in mm via ``ROB_POS``.

    Sends ``ROB_POS`` and extracts this axis's coordinate from the
    response.  Assumes the response layout::

        msg_id, ROB_POS, x_mm, y_mm, z_mm, 0, NULL, SUCCESS

    where the position field for axis *n* is at ``fields[n + 1]``
    (1-based field numbering after stripping the leading ``msg_id``
    and ``ROB_POS`` label fields).

    Returns:
        Current axis position in mm.

    Raises:
        RuntimeError: If the response cannot be parsed.
        ~applied_motion.backends.fposbapi_client.FPosBAPIClientError: If the
            PLC returns an error response.
    """
    response = self._client.send_command("ROB_POS")
    fields = [
        f.strip() for f in response[-1].split(",")
    ]  # TODO: Make this a function in the client that is passed in here
    # fields[0] = msg_id, fields[1] = "ROB_POS", fields[2] = X, fields[3] = Y, fields[4] = Z
    position_field_index = self.index + 1
    try:
        value = float(fields[position_field_index])
    except (IndexError, ValueError) as exc:
        logger.exception(
            "FPosBAxis '%s': cannot parse ROB_POS response — %s",
            self.name,
            response,
        )
        raise RuntimeError(
            f"Failed to parse ROB_POS position for axis '{self.name}' "
            f"(field index {position_field_index}): {response!r}"
        ) from exc
    logger.debug("FPosBAxis '%s': current position = %s mm", self.name, value)
    return value

is_homed

is_homed() -> bool

Return whether the gantry has been homed via IS_HOME.

Sends IS_HOME and interprets the response field that follows the echoed command name. The PLC returns 1 when homing is complete and 0 when it is not.

Returns:

Type Description
bool

True if the PLC reports the gantry is homed; False

bool

otherwise.

Raises:

Type Description
~FPosBAPIClientError

If the PLC returns an error response.

RuntimeError

If the response cannot be parsed.

Source code in src/applied_motion/backends/fposbapi_axis.py
def is_homed(self) -> bool:
    """Return whether the gantry has been homed via ``IS_HOME``.

    Sends ``IS_HOME`` and interprets the response field that follows the
    echoed command name.  The PLC returns ``1`` when homing is complete
    and ``0`` when it is not.

    Returns:
        ``True`` if the PLC reports the gantry is homed; ``False``
        otherwise.

    Raises:
        ~applied_motion.backends.fposbapi_client.FPosBAPIClientError: If the
            PLC returns an error response.
        RuntimeError: If the response cannot be parsed.
    """
    response = self._client.send_command("IS_HOME")
    fields = [f.strip() for f in response[-1].split(",")]
    # fields: msg_id, IS_HOME, value, ERR_ID, ERR_TYPE, SUCCESS
    try:
        homed = bool(int(fields[2]))
    except (IndexError, ValueError) as exc:
        raise RuntimeError(f"Failed to parse IS_HOME response for axis '{self.name}': {response!r}") from exc
    logger.debug("FPosBAxis '%s': is_homed=%s", self.name, homed)
    return homed

stopped

stopped() -> bool

Return True; FPosBAPI moves are blocking so motion is always complete on return.

move blocks until the PLC emits a SUCCESS response, meaning by the time Python regains control the axis has stopped. This method always returns True to satisfy the Axis interface.

Returns:

Type Description
bool

Always True.

Source code in src/applied_motion/backends/fposbapi_axis.py
def stopped(self) -> bool:
    """Return ``True``; FPosBAPI moves are blocking so motion is always complete on return.

    [`move`][applied_motion.backends.fposbapi_axis.FPosBAxis.move] blocks until the PLC emits a ``SUCCESS`` response,
    meaning by the time Python regains control the axis has stopped.
    This method always returns ``True`` to satisfy the
    [`Axis`][applied_motion.backends.axis_protocol.Axis] interface.

    Returns:
        Always ``True``.
    """
    return True

acknowledge_faults

acknowledge_faults()

Clear errors.

Source code in src/applied_motion/backends/fposbapi_axis.py
def acknowledge_faults(self):
    """Clear errors."""
    pass

enable_powerstage

enable_powerstage()

Turn on torque to motor controlling this axis.

Source code in src/applied_motion/backends/fposbapi_axis.py
def enable_powerstage(self):
    """Turn on torque to motor controlling this axis."""
    # TODO: Implement this functionality using corresponding FPosBAPI command
    pass

disable_powerstage

disable_powerstage()

Turn off torque to motor controlling this axis.

Source code in src/applied_motion/backends/fposbapi_axis.py
def disable_powerstage(self):
    """Turn off torque to motor controlling this axis."""
    # TODO: Implement this functionality using corresponding FPosBAPI command
    pass

current_position

current_position()

Return current position.

Source code in src/applied_motion/backends/fposbapi_axis.py
def current_position(self):
    """Return current position."""
    # TODO: Implement this functionality using corresponding FPosBAPI command
    pass

current_velocity

current_velocity()

Return current velocity.

Source code in src/applied_motion/backends/fposbapi_axis.py
def current_velocity(self):
    """Return current velocity."""
    pass

jog_task

jog_task(
    jog_positive: bool = True,
    jog_negative: bool = False,
    incremental: bool = False,
    duration: float = 0.0,
) -> bool

Jog axis.

Source code in src/applied_motion/backends/fposbapi_axis.py
def jog_task(
    self,
    jog_positive: bool = True,
    jog_negative: bool = False,
    incremental: bool = False,
    duration: float = 0.0,
) -> bool:
    """Jog axis."""
    # TODO: Implement this functionality using corresponding FPosBAPI command
    return True

ready_for_motion

ready_for_motion() -> bool

Return whether the gantry drives are enabled via IS_ENBL.

Sends IS_ENBL and interprets the response. The PLC returns 1 when drives are enabled and ready to accept motion commands, 0 when they are disabled.

Returns:

Type Description
bool

True if the PLC reports drives are enabled; False

bool

otherwise.

Raises:

Type Description
~FPosBAPIClientError

If the PLC returns an error response.

RuntimeError

If the response cannot be parsed.

Source code in src/applied_motion/backends/fposbapi_axis.py
def ready_for_motion(self) -> bool:
    """Return whether the gantry drives are enabled via ``IS_ENBL``.

    Sends ``IS_ENBL`` and interprets the response.  The PLC returns
    ``1`` when drives are enabled and ready to accept motion commands,
    ``0`` when they are disabled.

    Returns:
        ``True`` if the PLC reports drives are enabled; ``False``
        otherwise.

    Raises:
        ~applied_motion.backends.fposbapi_client.FPosBAPIClientError: If the
            PLC returns an error response.
        RuntimeError: If the response cannot be parsed.
    """
    response = self._client.send_command("IS_ENBL")
    fields = [f.strip() for f in response[-1].split(",")]
    # fields: msg_id, IS_ENBL, value, ERR_ID, ERR_TYPE, SUCCESS
    try:
        enabled = bool(int(fields[2]))
    except (IndexError, ValueError) as exc:
        raise RuntimeError(f"Failed to parse IS_ENBL response for axis '{self.name}': {response!r}") from exc
    logger.debug("FPosBAxis '%s': ready_for_motion=%s", self.name, enabled)
    return enabled

FPosBAPIClient

FPosBAPIClient(
    ip: str, port: int = 1234, timeout: float | None = None
)

Thread-safe TCP socket client for the Festo FPosBAPI ASCII protocol.

Connects to the CECC-X PLC on ip:port and wraps the request/response cycle in send_command. A threading.Lock serialises all socket I/O so multiple FPosBAxis objects sharing the same client do not interleave their frames.

Attributes:

Name Type Description
ip

IPv4 address of the CECC-X TCP server.

port

TCP port of the FPosBAPI server (default 1234).

Connect to the FPosBAPI server.

Parameters:

Name Type Description Default
ip str

IPv4 address of the CECC-X PLC.

required
port int

TCP port the FPosBAPI server is listening on. Defaults to 1234.

1234
timeout float | None

Socket timeout in seconds. Applied to both connect and recv operations. None (default) means blocking with no timeout.

None

Raises:

Type Description
OSError

If the TCP connection cannot be established within timeout seconds.

Source code in src/applied_motion/backends/fposbapi_client.py
def __init__(self, ip: str, port: int = 1234, timeout: float | None = None) -> None:
    """Connect to the FPosBAPI server.

    Args:
        ip: IPv4 address of the CECC-X PLC.
        port: TCP port the FPosBAPI server is listening on.  Defaults to
            ``1234``.
        timeout: Socket timeout in seconds.  Applied to both ``connect``
            and ``recv`` operations.  ``None`` (default) means blocking
            with no timeout.

    Raises:
        OSError: If the TCP connection cannot be established within
            *timeout* seconds.
    """
    self.ip = ip
    self.port = port
    self._timeout = timeout
    self._lock = threading.Lock()
    self._msg_id = 0
    self._sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    self._keepalive_idle = 15_000
    self._keepalive_interval = 5_000
    self._keepalive_count = 10
    logger.info("FPosBAPIClient attempting to connect to %s:%d", ip, port)
    self._connect()
    logger.info("FPosBAPIClient connected to %s:%d", ip, port)

send_command

send_command(
    command: str,
    *params,
    timeout: float | None | _Unset = _UNSET,
) -> list[str]

Send a command to the FPosBAPI server and return all response lines.

Acquires the internal lock, increments the message ID, formats the ASCII request frame, sends it, then reads lines via _collect_response until the terminal (non-ACK) line arrives. The terminal (last) line is validated for correct MSG_ID echo, CMD echo, and SUCCESS status before returning.

Parameters:

Name Type Description Default
command str

FPosBAPI command string, e.g. "ENABLE", "MOVE_AXIS".

required
*params

Zero or more positional parameters appended to the frame.

()
timeout float | None | _Unset

Per-call socket timeout in seconds. Pass None for blocking mode (no timeout), e.g. for long-running motion commands. Omit to use the client's configured defaults.

_UNSET

Returns:

Type Description
list[str]

All response lines received before the empty terminator, in arrival

list[str]

order. The last element is always the terminal status line echoing

list[str]

the command and carrying SUCCESS.

Raises:

Type Description
FPosBAPIClientError

If the server returns an error status, the echoed MSG_ID or command name does not match what was sent, the response is empty, or the connection is closed.

Source code in src/applied_motion/backends/fposbapi_client.py
def send_command(self, command: str, *params, timeout: float | None | _Unset = _UNSET) -> list[str]:
    """Send a command to the FPosBAPI server and return all response lines.

    Acquires the internal lock, increments the message ID, formats the
    ASCII request frame, sends it, then reads lines via
    `_collect_response` until the terminal (non-``ACK``) line
    arrives.  The terminal (last) line is validated for correct MSG_ID
    echo, CMD echo, and ``SUCCESS`` status before returning.

    Args:
        command: FPosBAPI command string, e.g. ``"ENABLE"``, ``"MOVE_AXIS"``.
        *params: Zero or more positional parameters appended to the frame.
        timeout: Per-call socket timeout in seconds.  Pass ``None`` for
            blocking mode (no timeout), e.g. for long-running motion
            commands.  Omit to use the client's configured defaults.

    Returns:
        All response lines received before the empty terminator, in arrival
        order.  The last element is always the terminal status line echoing
        the command and carrying ``SUCCESS``.

    Raises:
        FPosBAPIClientError: If the server returns an error status, the
            echoed MSG_ID or command name does not match what was sent, the
            response is empty, or the connection is closed.
    """
    with self._lock:
        if not isinstance(timeout, _Unset):
            self._sock.settimeout(timeout)
        msg_id = self._next_id()
        raw = self._build_frame(msg_id, command, params)
        logger.debug("FPosBAPIClient tx: %s", raw.strip())
        self._send_frame(raw, command, timeout)
        try:
            lines = self._collect_response()
        finally:
            if not isinstance(timeout, _Unset):
                self._sock.settimeout(self._timeout)
        logger.debug("FPosBAPIClient rx: %s", ", ".join(lines))
        self._validate_terminal(lines, msg_id, command)
    return lines

try_command

try_command(
    command: str,
    *params,
    timeout: float | None | _Unset = _UNSET,
) -> bool

Send a command; raise on communication failure, return bool for PLC result.

Parameters:

Name Type Description Default
command str

FPosBAPI command string, e.g. "HOME", "MOVE_AXIS".

required
*params

Zero or more positional parameters.

()
timeout float | None | _Unset

Per-call socket timeout forwarded to send_command. Pass None for blocking mode on long-running motion commands.

_UNSET

Returns:

Type Description
bool

True when the PLC reports SUCCESS; False when the PLC

bool

returns a valid but non-SUCCESS response.

Raises:

Type Description
FPosBAPICommunicationError

If a transport or protocol-level failure occurs.

Source code in src/applied_motion/backends/fposbapi_client.py
def try_command(self, command: str, *params, timeout: float | None | _Unset = _UNSET) -> bool:
    """Send a command; raise on communication failure, return bool for PLC result.

    Args:
        command: FPosBAPI command string, e.g. ``"HOME"``, ``"MOVE_AXIS"``.
        *params: Zero or more positional parameters.
        timeout: Per-call socket timeout forwarded to [`send_command`][applied_motion.backends.fposbapi_client.FPosBAPIClient.send_command].
            Pass ``None`` for blocking mode on long-running motion commands.

    Returns:
        ``True`` when the PLC reports ``SUCCESS``; ``False`` when the PLC
        returns a valid but non-SUCCESS response.

    Raises:
        FPosBAPICommunicationError: If a transport or protocol-level failure occurs.
    """
    try:
        self.send_command(command, *params, timeout=timeout)
        return True
    except FPosBAPICommandError:
        logger.warning("FPosBAPIClient: command %r rejected by PLC", command)
        return False

get_veab

get_veab() -> int

Get the pressure set value of the VEAB.

Source code in src/applied_motion/backends/fposbapi_client.py
def get_veab(self) -> int:
    """Get the pressure set value of the VEAB."""
    # TODO: This __REALLY__ needs to be contingent on the config and how it is passed in
    # TODO: The ideal would be a PressureControl() class that shares the intantiated gantry and can take it in as input parameter. All of these classes would benefit from that bc of necessary shared socket on CECC-X

    lines = self.send_command("GET_VEAB")
    terminal = lines[-1]
    fields = [f.strip() for f in terminal.split(",")]

    return int(fields[2])

set_veab

set_veab(set_value: int) -> None

Set the pressure value of the VEAB.

Source code in src/applied_motion/backends/fposbapi_client.py
def set_veab(self, set_value: int) -> None:
    """Set the pressure value of the VEAB."""
    self.send_command("SET_VEAB", set_value)

list_commands

list_commands() -> list[str]

Query the server for its supported command set via CMD_LIST.

Sends CMD_LIST and parses the response to extract the command names the connected FPosBAPI server advertises. The set varies between firmware versions, so callers can use this to feature-detect before issuing optional commands (e.g. IS_HOME, SYS_STATUS).

Response layout assumed::

1
MSG_ID, CMD_LIST, CMD_1, CMD_2, ..., CMD_N, ERR_ID, ERR_TYPE, ERR_MSG

The first two fields (MSG_ID and CMD_LIST) and the last three (error fields ending with SUCCESS) are stripped; the remaining fields are returned as a list of command name strings.

Returns:

Type Description
list[str]

List of command name strings advertised by the server,

list[str]

e.g. ["ENABLE", "DISABLE", "HOME", "MOVE_AXIS", ...].

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

Source code in src/applied_motion/backends/fposbapi_client.py
def list_commands(self) -> list[str]:
    """Query the server for its supported command set via ``CMD_LIST``.

    Sends ``CMD_LIST`` and parses the response to extract the command
    names the connected FPosBAPI server advertises.  The set varies
    between firmware versions, so callers can use this to feature-detect
    before issuing optional commands (e.g. ``IS_HOME``, ``SYS_STATUS``).

    Response layout assumed::

        MSG_ID, CMD_LIST, CMD_1, CMD_2, ..., CMD_N, ERR_ID, ERR_TYPE, ERR_MSG

    The first two fields (``MSG_ID`` and ``CMD_LIST``) and the last
    three (error fields ending with ``SUCCESS``) are stripped; the
    remaining fields are returned as a list of command name strings.

    Returns:
        List of command name strings advertised by the server,
        e.g. ``["ENABLE", "DISABLE", "HOME", "MOVE_AXIS", ...]``.

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
    """
    lines = self.send_command("CMD_LIST")
    # The server sends one bare command name per intermediate line.
    # lines[0] is the ACK, lines[1:-1] are the bare command names,
    # lines[-1] is the terminal SUCCESS line.
    commands = [line.strip() for line in lines[1:-1] if line.strip()]
    logger.debug("FPosBAPIClient: CMD_LIST returned %d command(s): %s", len(commands), commands)
    return commands

enable

enable() -> None

Enable the gantry drives via ENABLE.

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

Source code in src/applied_motion/backends/fposbapi_client.py
def enable(self) -> None:
    """Enable the gantry drives via ``ENABLE``.

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
    """
    self.send_command("ENABLE")
    logger.info("FPosBAPIClient: drives enabled")

disable

disable() -> None

Disable the gantry drives via DISABLE.

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

Source code in src/applied_motion/backends/fposbapi_client.py
def disable(self) -> None:
    """Disable the gantry drives via ``DISABLE``.

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
    """
    self.send_command("DISABLE")
    logger.info("FPosBAPIClient: drives disabled")

home

home() -> None

Home all axes via HOME.

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

Source code in src/applied_motion/backends/fposbapi_client.py
def home(self) -> None:
    """Home all axes via ``HOME``.

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
    """
    self.send_command("HOME")
    logger.info("FPosBAPIClient: homing complete")

move_pos

move_pos(
    pos_id: int,
    tool_id: int = 0,
    retract_z: int = 0,
    slow_app: int = 0,
) -> None

Execute a motion sequence to a stored position via MOVE_POS.

Parameters:

Name Type Description Default
pos_id int

Position record ID (1-100).

required
tool_id int

Tool index to apply. 0 selects no tool.

0
retract_z int

1 to retract Z before moving, 0 to skip.

0
slow_app int

1 to slow approach the target position, 0 for full speed.

0

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

Source code in src/applied_motion/backends/fposbapi_client.py
def move_pos(
    self,
    pos_id: int,
    tool_id: int = 0,
    retract_z: int = 0,
    slow_app: int = 0,
) -> None:
    """Execute a motion sequence to a stored position via ``MOVE_POS``.

    Args:
        pos_id: Position record ID (1-100).
        tool_id: Tool index to apply.  ``0`` selects no tool.
        retract_z: ``1`` to retract Z before moving, ``0`` to skip.
        slow_app: ``1`` to slow approach the target position, ``0`` for
            full speed.

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
    """
    self.send_command("MOVE_POS", pos_id, tool_id, retract_z, slow_app)
    logger.info("FPosBAPIClient: MOVE_POS complete (pos_id=%d, tool_id=%d)", pos_id, tool_id)

move_loc

move_loc(
    a1: float,
    a2: float,
    a3: float,
    tool_id: int = 0,
    move_typ: int = 0,
    retract_z: int = 0,
    slow_app: int = 0,
) -> None

Execute a coordinated 3-axis move to explicit coordinates via MOVE_LOC.

Parameters:

Name Type Description Default
a1 float

Target X-axis position in mm.

required
a2 float

Target Y-axis position in mm.

required
a3 float

Target Z-axis position in mm.

required
tool_id int

Tool offset to apply. 0 selects no tool.

0
move_typ int

0 for absolute, 1 for relative.

0
retract_z int

1 to retract Z before moving, 0 to skip.

0
slow_app int

1 to slow approach the target position, 0 for full speed.

0

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

Source code in src/applied_motion/backends/fposbapi_client.py
def move_loc(
    self,
    a1: float,
    a2: float,
    a3: float,
    tool_id: int = 0,
    move_typ: int = 0,
    retract_z: int = 0,
    slow_app: int = 0,
) -> None:
    """Execute a coordinated 3-axis move to explicit coordinates via ``MOVE_LOC``.

    Args:
        a1: Target X-axis position in mm.
        a2: Target Y-axis position in mm.
        a3: Target Z-axis position in mm.
        tool_id: Tool offset to apply.  ``0`` selects no tool.
        move_typ: ``0`` for absolute, ``1`` for relative.
        retract_z: ``1`` to retract Z before moving, ``0`` to skip.
        slow_app: ``1`` to slow approach the target position, ``0`` for
            full speed.

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
    """
    self.send_command("MOVE_LOC", a1, a2, a3, tool_id, move_typ, retract_z, slow_app)
    logger.info("FPosBAPIClient: MOVE_LOC complete (a1=%s, a2=%s, a3=%s mm)", a1, a2, a3)

move_path

move_path() -> None

Execute the programmed motion path via MOVE_PATH.

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

Source code in src/applied_motion/backends/fposbapi_client.py
def move_path(self) -> None:
    """Execute the programmed motion path via ``MOVE_PATH``.

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
    """
    # TODO: Needs WRITE_PATH?
    self.send_command("MOVE_PATH")
    logger.info("FPosBAPIClient: MOVE_PATH complete")

halt

halt() -> None

Halt the current motion via HALT.

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

Source code in src/applied_motion/backends/fposbapi_client.py
def halt(self) -> None:
    """Halt the current motion via ``HALT``.

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
    """
    self.send_command("HALT")
    logger.info("FPosBAPIClient: HALT issued")

resume

resume() -> None

Resume a halted motion via RESUME.

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

Source code in src/applied_motion/backends/fposbapi_client.py
def resume(self) -> None:
    """Resume a halted motion via ``RESUME``.

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
    """
    self.send_command("RESUME")
    logger.info("FPosBAPIClient: RESUME issued")

abort

abort() -> None

Abort the current motion via ABORT.

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

Source code in src/applied_motion/backends/fposbapi_client.py
def abort(self) -> None:
    """Abort the current motion via ``ABORT``.

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
    """
    self.send_command("ABORT")
    logger.info("FPosBAPIClient: ABORT issued")

reset_err

reset_err() -> None

Reset the active error via RESET_ERR.

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

Source code in src/applied_motion/backends/fposbapi_client.py
def reset_err(self) -> None:
    """Reset the active error via ``RESET_ERR``.

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
    """
    self.send_command("RESET_ERR")
    logger.info("FPosBAPIClient: error reset")

open_valve

open_valve(
    v1_time: int = 0,
    v2_time: int = 0,
    v3_time: int = 0,
    v4_time: int = 0,
    v5_time: int = 0,
    v6_time: int = 0,
    v7_time: int = 0,
    v8_time: int = 0,
) -> None

Open one or more valves for the specified durations via OPEN_VALVE.

Parameters:

Name Type Description Default
v1_time int

Valve 1 open duration in ms. 0 keeps the valve closed.

0
v2_time int

Valve 2 open duration in ms.

0
v3_time int

Valve 3 open duration in ms.

0
v4_time int

Valve 4 open duration in ms.

0
v5_time int

Valve 5 open duration in ms.

0
v6_time int

Valve 6 open duration in ms.

0
v7_time int

Valve 7 open duration in ms.

0
v8_time int

Valve 8 open duration in ms.

0

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

Source code in src/applied_motion/backends/fposbapi_client.py
def open_valve(
    self,
    v1_time: int = 0,
    v2_time: int = 0,
    v3_time: int = 0,
    v4_time: int = 0,
    v5_time: int = 0,
    v6_time: int = 0,
    v7_time: int = 0,
    v8_time: int = 0,
) -> None:
    """Open one or more valves for the specified durations via ``OPEN_VALVE``.

    Args:
        v1_time: Valve 1 open duration in ms.  ``0`` keeps the valve closed.
        v2_time: Valve 2 open duration in ms.
        v3_time: Valve 3 open duration in ms.
        v4_time: Valve 4 open duration in ms.
        v5_time: Valve 5 open duration in ms.
        v6_time: Valve 6 open duration in ms.
        v7_time: Valve 7 open duration in ms.
        v8_time: Valve 8 open duration in ms.

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
    """
    self.send_command(
        "OPEN_VALVE",
        v1_time,
        v2_time,
        v3_time,
        v4_time,
        v5_time,
        v6_time,
        v7_time,
        v8_time,
    )
    logger.info("FPosBAPIClient: OPEN_VALVE complete")

read_pos

read_pos(pos_id: int) -> tuple[float, float, float]

Read the stored absolute position for pos_id via READ_POS.

Response layout::

1
MSG_ID, READ_POS, POS_ID, ABS_A1, ABS_A2, ABS_A3, 0, NULL, SUCCESS

Parameters:

Name Type Description Default
pos_id int

Position record ID (1-100).

required

Returns:

Type Description
tuple[float, float, float]

Tuple of (abs_a1, abs_a2, abs_a3) in mm.

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

RuntimeError

If the response cannot be parsed.

Source code in src/applied_motion/backends/fposbapi_client.py
def read_pos(self, pos_id: int) -> tuple[float, float, float]:
    """Read the stored absolute position for *pos_id* via ``READ_POS``.

    Response layout::

        MSG_ID, READ_POS, POS_ID, ABS_A1, ABS_A2, ABS_A3, 0, NULL, SUCCESS

    Args:
        pos_id: Position record ID (1-100).

    Returns:
        Tuple of ``(abs_a1, abs_a2, abs_a3)`` in mm.

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
        RuntimeError: If the response cannot be parsed.
    """
    lines = self.send_command("READ_POS", pos_id)
    fields = [f.strip() for f in lines[-1].split(",")]
    # fields: msg_id, READ_POS, pos_id, abs_a1, abs_a2, abs_a3, 0, NULL, SUCCESS
    try:
        result = float(fields[3]), float(fields[4]), float(fields[5])
    except (IndexError, ValueError) as exc:
        raise RuntimeError(f"Failed to parse READ_POS response for pos_id={pos_id}: {lines!r}") from exc
    logger.debug("FPosBAPIClient: READ_POS pos_id=%d → %s", pos_id, result)
    return result

teach_pos

teach_pos(pos_id: int, tool_id: int = 1) -> None

Save the current axis positions to pos_id via TEACH_POS.

Parameters:

Name Type Description Default
pos_id int

Position record ID to write (1-100).

required
tool_id int

Tool offset to associate with this position.

1

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

Source code in src/applied_motion/backends/fposbapi_client.py
def teach_pos(self, pos_id: int, tool_id: int = 1) -> None:
    """Save the current axis positions to *pos_id* via ``TEACH_POS``.

    Args:
        pos_id: Position record ID to write (1-100).
        tool_id: Tool offset to associate with this position.

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
    """
    self.send_command("TEACH_POS", pos_id, tool_id)
    logger.info("FPosBAPIClient: TEACH_POS complete (pos_id=%d)", pos_id)

write_pos

write_pos(
    pos_id: int, abs_a1: float, abs_a2: float, abs_a3: float
) -> None

Write absolute axis coordinates to pos_id via WRITE_POS.

Parameters:

Name Type Description Default
pos_id int

Position record ID to write (1-100).

required
abs_a1 float

Absolute X-axis position in mm.

required
abs_a2 float

Absolute Y-axis position in mm.

required
abs_a3 float

Absolute Z-axis position in mm.

required

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

Source code in src/applied_motion/backends/fposbapi_client.py
def write_pos(
    self,
    pos_id: int,
    abs_a1: float,
    abs_a2: float,
    abs_a3: float,
) -> None:
    """Write absolute axis coordinates to *pos_id* via ``WRITE_POS``.

    Args:
        pos_id: Position record ID to write (1-100).
        abs_a1: Absolute X-axis position in mm.
        abs_a2: Absolute Y-axis position in mm.
        abs_a3: Absolute Z-axis position in mm.

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
    """
    self.send_command("WRITE_POS", pos_id, abs_a1, abs_a2, abs_a3)
    logger.info(
        "FPosBAPIClient: WRITE_POS complete (pos_id=%d, a1=%s, a2=%s, a3=%s mm)",
        pos_id,
        abs_a1,
        abs_a2,
        abs_a3,
    )

mod_pos

mod_pos(
    pos_id: int, rel_a1: float, rel_a2: float, rel_a3: float
) -> None

Modify a stored position by relative offsets via MOD_POS.

Parameters:

Name Type Description Default
pos_id int

Position record ID to modify (1-100).

required
rel_a1 float

Relative X-axis offset in mm.

required
rel_a2 float

Relative Y-axis offset in mm.

required
rel_a3 float

Relative Z-axis offset in mm.

required

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

Source code in src/applied_motion/backends/fposbapi_client.py
def mod_pos(
    self,
    pos_id: int,
    rel_a1: float,
    rel_a2: float,
    rel_a3: float,
) -> None:
    """Modify a stored position by relative offsets via ``MOD_POS``.

    Args:
        pos_id: Position record ID to modify (1-100).
        rel_a1: Relative X-axis offset in mm.
        rel_a2: Relative Y-axis offset in mm.
        rel_a3: Relative Z-axis offset in mm.

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
    """
    self.send_command("MOD_POS", pos_id, rel_a1, rel_a2, rel_a3)
    logger.info("FPosBAPIClient: MOD_POS complete (pos_id=%d)", pos_id)

write_path

write_path(
    pa_pos_id: int,
    abs_a1: float,
    abs_a2: float,
    abs_a3: float,
) -> None

Write one waypoint along the motion path via WRITE_PATH.

Parameters:

Name Type Description Default
pa_pos_id int

Path position index (1-10).

required
abs_a1 float

Absolute X-axis position in mm.

required
abs_a2 float

Absolute Y-axis position in mm.

required
abs_a3 float

Absolute Z-axis position in mm.

required

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

Source code in src/applied_motion/backends/fposbapi_client.py
def write_path(
    self,
    pa_pos_id: int,
    abs_a1: float,
    abs_a2: float,
    abs_a3: float,
) -> None:
    """Write one waypoint along the motion path via ``WRITE_PATH``.

    Args:
        pa_pos_id: Path position index (1-10).
        abs_a1: Absolute X-axis position in mm.
        abs_a2: Absolute Y-axis position in mm.
        abs_a3: Absolute Z-axis position in mm.

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
    """
    self.send_command("WRITE_PATH", pa_pos_id, abs_a1, abs_a2, abs_a3)
    logger.info("FPosBAPIClient: WRITE_PATH complete (pa_pos_id=%d)", pa_pos_id)

read_path

read_path(pa_pos_id: int) -> tuple[float, float, float]

Read one waypoint from the motion path via READ_PATH.

Parameters:

Name Type Description Default
pa_pos_id int

Path position index (1-10).

required

Returns:

Type Description
tuple[float, float, float]

Tuple of (abs_a1, abs_a2, abs_a3) in mm.

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

RuntimeError

If the response cannot be parsed.

Source code in src/applied_motion/backends/fposbapi_client.py
def read_path(self, pa_pos_id: int) -> tuple[float, float, float]:
    """Read one waypoint from the motion path via ``READ_PATH``.

    Args:
        pa_pos_id: Path position index (1-10).

    Returns:
        Tuple of ``(abs_a1, abs_a2, abs_a3)`` in mm.

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
        RuntimeError: If the response cannot be parsed.
    """
    lines = self.send_command("READ_PATH", pa_pos_id)
    fields = [f.strip() for f in lines[-1].split(",")]
    # fields: msg_id, READ_PATH, pa_pos_id, abs_a1, abs_a2, abs_a3, 0, NULL, SUCCESS
    try:
        result = float(fields[3]), float(fields[4]), float(fields[5])
    except (IndexError, ValueError) as exc:
        raise RuntimeError(f"Failed to parse READ_PATH response for pa_pos_id={pa_pos_id}: {lines!r}") from exc
    logger.debug("FPosBAPIClient: READ_PATH pa_pos_id=%d → %s", pa_pos_id, result)
    return result

sys_status

sys_status() -> str

Return the system status string via SYS_STATUS.

Response layout::

1
MSG_ID, SYS_STATUS, STATUS, 0, NULL, SUCCESS

Returns:

Type Description
str

Status string reported by the PLC (e.g. "IDLE").

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

RuntimeError

If the response cannot be parsed.

Source code in src/applied_motion/backends/fposbapi_client.py
def sys_status(self) -> str:
    """Return the system status string via ``SYS_STATUS``.

    Response layout::

        MSG_ID, SYS_STATUS, STATUS, 0, NULL, SUCCESS

    Returns:
        Status string reported by the PLC (e.g. ``"IDLE"``).

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
        RuntimeError: If the response cannot be parsed.
    """
    lines = self.send_command("SYS_STATUS")
    fields = [f.strip() for f in lines[-1].split(",")]
    # fields: msg_id, SYS_STATUS, status, 0, NULL, SUCCESS
    try:
        status = fields[2]
    except IndexError as exc:
        raise RuntimeError(f"Failed to parse SYS_STATUS response: {lines!r}") from exc
    logger.debug("FPosBAPIClient: SYS_STATUS → %r", status)
    return status

is_error

is_error() -> bool

Return whether the gantry is in an error state via IS_ERROR.

Response layout::

1
MSG_ID, IS_ERROR, FLAG, 0, NULL, SUCCESS

Returns:

Type Description
bool

True if the PLC reports an active error; False otherwise.

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

RuntimeError

If the response cannot be parsed.

Source code in src/applied_motion/backends/fposbapi_client.py
def is_error(self) -> bool:
    """Return whether the gantry is in an error state via ``IS_ERROR``.

    Response layout::

        MSG_ID, IS_ERROR, FLAG, 0, NULL, SUCCESS

    Returns:
        ``True`` if the PLC reports an active error; ``False`` otherwise.

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
        RuntimeError: If the response cannot be parsed.
    """
    lines = self.send_command("IS_ERROR")
    fields = [f.strip() for f in lines[-1].split(",")]
    # fields: msg_id, IS_ERROR, flag, 0, NULL, SUCCESS
    try:
        result = bool(int(fields[2]))
    except (IndexError, ValueError) as exc:
        raise RuntimeError(f"Failed to parse IS_ERROR response: {lines!r}") from exc
    logger.debug("FPosBAPIClient: IS_ERROR → %s", result)
    return result

fpb_error

fpb_error() -> str

Return the fieldbus error state via FPB_ERROR.

Response layout::

1
MSG_ID, FPB_ERROR, STATUS, 0, NULL, SUCCESS

Returns:

Type Description
str

Raw status string from the terminal response field.

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

Source code in src/applied_motion/backends/fposbapi_client.py
def fpb_error(self) -> str:
    """Return the fieldbus error state via ``FPB_ERROR``.

    Response layout::

        MSG_ID, FPB_ERROR, STATUS, 0, NULL, SUCCESS

    Returns:
        Raw status string from the terminal response field.

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
    """
    lines = self.send_command("FPB_ERROR")
    fields = [f.strip() for f in lines[-1].split(",")]
    status = fields[2] if len(fields) > 2 else ""
    logger.debug("FPosBAPIClient: FPB_ERROR → %r", status)
    return status

read_err

read_err() -> str

Return the current error description via READ_ERR.

Returns:

Type Description
str

The raw terminal response line from the server.

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

Source code in src/applied_motion/backends/fposbapi_client.py
def read_err(self) -> str:
    """Return the current error description via ``READ_ERR``.

    Returns:
        The raw terminal response line from the server.

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
    """
    lines = self.send_command("READ_ERR")
    logger.debug("FPosBAPIClient: READ_ERR → %r", lines[-1])
    return lines[-1]

err_log

err_log() -> list[str]

Return the error log entries via ERR_LOG.

The server may return multiple intermediate lines before the terminal SUCCESS line. All non-terminal lines are returned as the log.

Returns:

Type Description
list[str]

List of error log strings (all lines except the terminal status).

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

Source code in src/applied_motion/backends/fposbapi_client.py
def err_log(self) -> list[str]:
    """Return the error log entries via ``ERR_LOG``.

    The server may return multiple intermediate lines before the terminal
    SUCCESS line.  All non-terminal lines are returned as the log.

    Returns:
        List of error log strings (all lines except the terminal status).

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
    """
    lines = self.send_command("ERR_LOG")
    log = lines[:-1]  # strip terminal SUCCESS line
    logger.debug("FPosBAPIClient: ERR_LOG returned %d line(s)", len(log))
    return log

com_log

com_log() -> list[str]

Return the communication log entries via COM_LOG.

The server may return multiple intermediate lines before the terminal SUCCESS line. All non-terminal lines are returned as the log.

Returns:

Type Description
list[str]

List of communication log strings (all lines except the terminal status).

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

Source code in src/applied_motion/backends/fposbapi_client.py
def com_log(self) -> list[str]:
    """Return the communication log entries via ``COM_LOG``.

    The server may return multiple intermediate lines before the terminal
    SUCCESS line.  All non-terminal lines are returned as the log.

    Returns:
        List of communication log strings (all lines except the terminal status).

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
    """
    lines = self.send_command("COM_LOG")
    log = lines[:-1]  # strip terminal SUCCESS line
    logger.debug("FPosBAPIClient: COM_LOG returned %d line(s)", len(log))
    return log

err_desc

err_desc() -> str

Return the error description via ERR_DESC.

Returns:

Type Description
str

Raw terminal response line from the server.

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

Source code in src/applied_motion/backends/fposbapi_client.py
def err_desc(self) -> str:
    """Return the error description via ``ERR_DESC``.

    Returns:
        Raw terminal response line from the server.

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
    """
    lines = self.send_command("ERR_DESC")
    logger.debug("FPosBAPIClient: ERR_DESC → %r", lines[-1])
    return lines[-1]

get_io

get_io(io_id: int) -> float

Return the value of an I/O channel via GET_IO.

Response layout::

1
MSG_ID, GET_IO, IO_ID, VALUE, 0, NULL, SUCCESS

Parameters:

Name Type Description Default
io_id int

I/O channel ID.

required

Returns:

Type Description
float

Current value of the I/O channel.

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

RuntimeError

If the response cannot be parsed.

Source code in src/applied_motion/backends/fposbapi_client.py
def get_io(self, io_id: int) -> float:
    """Return the value of an I/O channel via ``GET_IO``.

    Response layout::

        MSG_ID, GET_IO, IO_ID, VALUE, 0, NULL, SUCCESS

    Args:
        io_id: I/O channel ID.

    Returns:
        Current value of the I/O channel.

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
        RuntimeError: If the response cannot be parsed.
    """
    lines = self.send_command("GET_IO", io_id)
    fields = [f.strip() for f in lines[-1].split(",")]
    # fields: msg_id, GET_IO, io_id, value, 0, NULL, SUCCESS
    try:
        value = float(fields[3])
    except (IndexError, ValueError) as exc:
        raise RuntimeError(f"Failed to parse GET_IO response for io_id={io_id}: {lines!r}") from exc
    logger.debug("FPosBAPIClient: GET_IO io_id=%d → %s", io_id, value)
    return value

set_io

set_io(io_id: int, value: float) -> None

Set the value of an I/O channel via SET_IO.

Parameters:

Name Type Description Default
io_id int

I/O channel ID.

required
value float

Value to write to the I/O channel.

required

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

Source code in src/applied_motion/backends/fposbapi_client.py
def set_io(self, io_id: int, value: float) -> None:
    """Set the value of an I/O channel via ``SET_IO``.

    Args:
        io_id: I/O channel ID.
        value: Value to write to the I/O channel.

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
    """
    self.send_command("SET_IO", io_id, value)
    logger.info("FPosBAPIClient: SET_IO io_id=%d value=%s", io_id, value)

get_par

get_par(par_id: int) -> list[float]

Return parameter values for par_id via GET_PAR.

The FPosBAPI server returns up to four value fields per parameter (e.g. tray parameters include column count, column offset, row count, and row offset). Fields that are absent or non-numeric are omitted from the returned list.

Response layout::

1
MSG_ID, GET_PAR, PAR_ID, VALUE, VALUE, VALUE, VALUE, 0, NULL, SUCCESS

Parameters:

Name Type Description Default
par_id int

Parameter ID (see API Rev 5 Parameter ID sheet).

required

Returns:

Type Description
list[float]

List of up to four float values for the requested parameter.

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

Source code in src/applied_motion/backends/fposbapi_client.py
def get_par(self, par_id: int) -> list[float]:
    """Return parameter values for *par_id* via ``GET_PAR``.

    The FPosBAPI server returns up to four value fields per parameter
    (e.g. tray parameters include column count, column offset, row count,
    and row offset).  Fields that are absent or non-numeric are omitted
    from the returned list.

    Response layout::

        MSG_ID, GET_PAR, PAR_ID, VALUE, VALUE, VALUE, VALUE, 0, NULL, SUCCESS

    Args:
        par_id: Parameter ID (see API Rev 5 Parameter ID sheet).

    Returns:
        List of up to four float values for the requested parameter.

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
    """
    lines = self.send_command("GET_PAR", par_id)
    fields = [f.strip() for f in lines[-1].split(",")]
    # fields: msg_id, GET_PAR, par_id, v1, v2, v3, v4, 0, NULL, SUCCESS
    # Value fields are at indices 3-6; trailing error triplet at -3 to -1.
    value_fields = fields[3:-3]
    values: list[float] = []
    for f in value_fields:
        try:
            values.append(float(f))
        except ValueError:
            break
    logger.debug("FPosBAPIClient: GET_PAR par_id=%d → %s", par_id, values)
    return values

set_par

set_par(par_id: int, *values: float) -> None

Write one or more values to parameter par_id via SET_PAR.

Parameters:

Name Type Description Default
par_id int

Parameter ID (see API Rev 5 Parameter ID sheet).

required
*values float

Up to four values to write to the parameter.

()

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

Source code in src/applied_motion/backends/fposbapi_client.py
def set_par(self, par_id: int, *values: float) -> None:
    """Write one or more values to parameter *par_id* via ``SET_PAR``.

    Args:
        par_id: Parameter ID (see API Rev 5 Parameter ID sheet).
        *values: Up to four values to write to the parameter.

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
    """
    self.send_command("SET_PAR", par_id, *values)
    logger.info("FPosBAPIClient: SET_PAR par_id=%d values=%s", par_id, values)

teach_tray

teach_tray(
    tray_id: int, tray_pos: int, tool_id: int = 0
) -> None

Save the current axis positions as a tray position via TEACH_TRAY.

Parameters:

Name Type Description Default
tray_id int

Tray ID (1-20).

required
tray_pos int

Position within the tray to teach.

required
tool_id int

Tool offset to associate with this position.

0

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

Source code in src/applied_motion/backends/fposbapi_client.py
def teach_tray(self, tray_id: int, tray_pos: int, tool_id: int = 0) -> None:
    """Save the current axis positions as a tray position via ``TEACH_TRAY``.

    Args:
        tray_id: Tray ID (1-20).
        tray_pos: Position within the tray to teach.
        tool_id: Tool offset to associate with this position.

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
    """
    self.send_command("TEACH_TRAY", tray_id, tray_pos, tool_id)
    logger.info("FPosBAPIClient: TEACH_TRAY complete (tray_id=%d, tray_pos=%d)", tray_id, tray_pos)

write_tray

write_tray(
    tray_id: int,
    tray_pos: int,
    abs_a1: float,
    abs_a2: float,
    abs_a3: float,
) -> None

Write absolute coordinates to a tray position via WRITE_TRAY.

Parameters:

Name Type Description Default
tray_id int

Tray ID (1-20).

required
tray_pos int

Position index within the tray.

required
abs_a1 float

Absolute X-axis position in mm.

required
abs_a2 float

Absolute Y-axis position in mm.

required
abs_a3 float

Absolute Z-axis position in mm.

required

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

Source code in src/applied_motion/backends/fposbapi_client.py
def write_tray(
    self,
    tray_id: int,
    tray_pos: int,
    abs_a1: float,
    abs_a2: float,
    abs_a3: float,
) -> None:
    """Write absolute coordinates to a tray position via ``WRITE_TRAY``.

    Args:
        tray_id: Tray ID (1-20).
        tray_pos: Position index within the tray.
        abs_a1: Absolute X-axis position in mm.
        abs_a2: Absolute Y-axis position in mm.
        abs_a3: Absolute Z-axis position in mm.

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
    """
    self.send_command("WRITE_TRAY", tray_id, tray_pos, abs_a1, abs_a2, abs_a3)
    logger.info("FPosBAPIClient: WRITE_TRAY complete (tray_id=%d, tray_pos=%d)", tray_id, tray_pos)

read_tray

read_tray(
    tray_id: int, tray_pos: int
) -> tuple[float, float, float]

Read the stored coordinates of a tray position via READ_TRAY.

Response layout::

1
MSG_ID, READ_TRAY, TRAY_ID, TRAY_POS, ABS_A1, ABS_A2, ABS_A3, 0, NULL, SUCCESS

Parameters:

Name Type Description Default
tray_id int

Tray ID (1-20).

required
tray_pos int

Position index within the tray.

required

Returns:

Type Description
tuple[float, float, float]

Tuple of (abs_a1, abs_a2, abs_a3) in mm.

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

RuntimeError

If the response cannot be parsed.

Source code in src/applied_motion/backends/fposbapi_client.py
def read_tray(self, tray_id: int, tray_pos: int) -> tuple[float, float, float]:
    """Read the stored coordinates of a tray position via ``READ_TRAY``.

    Response layout::

        MSG_ID, READ_TRAY, TRAY_ID, TRAY_POS, ABS_A1, ABS_A2, ABS_A3, 0, NULL, SUCCESS

    Args:
        tray_id: Tray ID (1-20).
        tray_pos: Position index within the tray.

    Returns:
        Tuple of ``(abs_a1, abs_a2, abs_a3)`` in mm.

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
        RuntimeError: If the response cannot be parsed.
    """
    lines = self.send_command("READ_TRAY", tray_id, tray_pos)
    fields = [f.strip() for f in lines[-1].split(",")]
    # fields: msg_id, READ_TRAY, tray_id, tray_pos, abs_a1, abs_a2, abs_a3, 0, NULL, SUCCESS
    try:
        result = float(fields[4]), float(fields[5]), float(fields[6])
    except (IndexError, ValueError) as exc:
        raise RuntimeError(
            f"Failed to parse READ_TRAY response for tray_id={tray_id}, tray_pos={tray_pos}: {lines!r}"
        ) from exc
    logger.debug("FPosBAPIClient: READ_TRAY tray_id=%d tray_pos=%d → %s", tray_id, tray_pos, result)
    return result

mod_tray

mod_tray(
    tray_id: int,
    tray_pos: int,
    rel_a1: float,
    rel_a2: float,
    rel_a3: float,
) -> None

Modify a stored tray position by relative offsets via MOD_TRAY.

Parameters:

Name Type Description Default
tray_id int

Tray ID (1-20).

required
tray_pos int

Position index within the tray.

required
rel_a1 float

Relative X-axis offset in mm.

required
rel_a2 float

Relative Y-axis offset in mm.

required
rel_a3 float

Relative Z-axis offset in mm.

required

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

Source code in src/applied_motion/backends/fposbapi_client.py
def mod_tray(
    self,
    tray_id: int,
    tray_pos: int,
    rel_a1: float,
    rel_a2: float,
    rel_a3: float,
) -> None:
    """Modify a stored tray position by relative offsets via ``MOD_TRAY``.

    Args:
        tray_id: Tray ID (1-20).
        tray_pos: Position index within the tray.
        rel_a1: Relative X-axis offset in mm.
        rel_a2: Relative Y-axis offset in mm.
        rel_a3: Relative Z-axis offset in mm.

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
    """
    self.send_command("MOD_TRAY", tray_id, tray_pos, rel_a1, rel_a2, rel_a3)
    logger.info("FPosBAPIClient: MOD_TRAY complete (tray_id=%d, tray_pos=%d)", tray_id, tray_pos)

move_tray

move_tray(
    tray_id: int,
    tray_col: int,
    tray_row: int,
    tool_id: int = 0,
    retract_z: int = 0,
    slow_app: int = 0,
) -> None

Move the gantry to a tray location via MOVE_TRAY.

Parameters:

Name Type Description Default
tray_id int

Tray ID (1-20).

required
tray_col int

Target column within the tray.

required
tray_row int

Target row within the tray.

required
tool_id int

Tool offset to apply. 0 selects no tool.

0
retract_z int

1 to retract Z before moving, 0 to skip.

0
slow_app int

1 to slow approach the target position, 0 for full speed.

0

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

Source code in src/applied_motion/backends/fposbapi_client.py
def move_tray(
    self,
    tray_id: int,
    tray_col: int,
    tray_row: int,
    tool_id: int = 0,
    retract_z: int = 0,
    slow_app: int = 0,
) -> None:
    """Move the gantry to a tray location via ``MOVE_TRAY``.

    Args:
        tray_id: Tray ID (1-20).
        tray_col: Target column within the tray.
        tray_row: Target row within the tray.
        tool_id: Tool offset to apply.  ``0`` selects no tool.
        retract_z: ``1`` to retract Z before moving, ``0`` to skip.
        slow_app: ``1`` to slow approach the target position, ``0`` for
            full speed.

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
    """
    self.send_command("MOVE_TRAY", tray_id, tray_col, tray_row, tool_id, retract_z, slow_app)
    logger.info(
        "FPosBAPIClient: MOVE_TRAY complete (tray_id=%d, col=%d, row=%d)",
        tray_id,
        tray_col,
        tray_row,
    )

init_sys

init_sys() -> None

Initialize system parameters via INIT_SYS.

Raises:

Type Description
FPosBAPIClientError

If the server returns an error response or the connection is lost.

Source code in src/applied_motion/backends/fposbapi_client.py
def init_sys(self) -> None:
    """Initialize system parameters via ``INIT_SYS``.

    Raises:
        FPosBAPIClientError: If the server returns an error response or
            the connection is lost.
    """
    self.send_command("INIT_SYS")
    logger.info("FPosBAPIClient: system initialized")

close

close() -> None

Close the underlying TCP socket.

Safe to call more than once; subsequent calls are no-ops because the OS will already have released the socket descriptor.

Source code in src/applied_motion/backends/fposbapi_client.py
def close(self) -> None:
    """Close the underlying TCP socket.

    Safe to call more than once; subsequent calls are no-ops because the
    OS will already have released the socket descriptor.
    """
    self._sock.close()
    logger.info("FPosBAPIClient disconnected from %s:%d", self.ip, self.port)

FPosBAPIClientError

Bases: Exception

Raised when the FPosBAPI server returns an error response or the connection is lost.

EdconAxis

EdconAxis(
    name: str,
    ip: str,
    run_referencing: bool = False,
    max_position: float = inf,
    min_position: float = -inf,
)

Bases: MotionHandler

Modbus TCP axis: direct festo-edcon MotionHandler connection to one drive.

Wraps low-level Modbus communication and position/velocity unit conversion behind a millimetre-based public API. All position values accepted and returned by the public methods use millimetres (mm) as their unit.

Attributes:

Name Type Description
name

Human-readable label for this axis (e.g. "X").

ip

IPv4 address of the drive's Modbus TCP endpoint.

com

Active ComModbus connection.

max_speed float

Maximum achievable speed in drive velocity units.

max_position float

Maximum achievable position in mm.

min_position float

Minimum achievable position in mm.

Initialise the axis and establish a Modbus connection.

Creates the ComModbus connection, initialises the parent MotionHandler, reads the software-limit PNUs, and optionally triggers homing.

Parameters:

Name Type Description Default
name str

Human-readable axis label used in log messages and equality checks. Axis labels are unique within a gantry.

required
ip str

IPv4 address of the Festo drive's Modbus TCP interface.

required
run_referencing bool

When True, perform a homing (referencing) sequence during construction. Defaults to False.

False
max_position float

Optional max position limitation, if the drive is restricted more than the internal SW limit position check. This avoids an issue where traversing toward the actual endstop is interrupted because the interia of the motion causes the drive to overshoot the limit position, throwing an error and interrupting the power stage on state.

inf
min_position float

Optional min position limitation, if the drive is restricted more than the internal SW limit position check. This avoids an issue where traversing toward the actual endstop is interrupted because the interia of the motion causes the drive to overshoot the limit position, throwing an error and interrupting the power stage on state.

-inf
Source code in src/applied_motion/backends/edcon_axis.py
def __init__(
    self,
    name: str,
    ip: str,
    run_referencing: bool = False,
    max_position: float = inf,
    min_position: float = -inf,
) -> None:
    """Initialise the axis and establish a Modbus connection.

    Creates the `ComModbus` connection,
    initialises the parent `MotionHandler`,
    reads the software-limit PNUs, and optionally triggers homing.

    Args:
        name: Human-readable axis label used in log messages and equality
            checks.  Axis labels are unique within a gantry.
        ip: IPv4 address of the Festo drive's Modbus TCP interface.
        run_referencing: When ``True``, perform a homing (referencing)
            sequence during construction.  Defaults to ``False``.
        max_position: Optional max position limitation, if the drive is restricted
            more than the internal SW limit position check. This avoids an issue where
            traversing toward the actual endstop is interrupted because the interia of
            the motion causes the drive to overshoot the limit position, throwing an error
            and interrupting the power stage on state.
        min_position: Optional min position limitation, if the drive is restricted
            more than the internal SW limit position check. This avoids an issue where
            traversing toward the actual endstop is interrupted because the interia of
            the motion causes the drive to overshoot the limit position, throwing an error
            and interrupting the power stage on state.
    """
    self.name = name
    self.ip = ip
    self.com = ComModbus(self.ip)
    super().__init__(self.com)
    self.acknowledge_faults()

    self.acknowledge_faults()
    # self.home()
    logger.info("Axis '%s': initialized", self.name)
    self.configure_software_limit_switch(True)
    logger.info("Axis '%s': software limit switch configured", self.name)

    self._neg_sw_limit: int = self.com.read_pnu(834)
    self._pos_sw_limit: int = self.com.read_pnu(835)

    self._min_vel: int = self.com.read_pnu(11212)
    self._max_vel: int = self.com.read_pnu(11213)
    self._pos_scale_exp: int = self.com.read_pnu(11724)
    self._vel_scale_exp: int = self.com.read_pnu(11725)
    self.input_pos_unit = {"distance": {"unit": "m", "power": 1, "power_of_ten": -3}}
    self.input_vel_unit = {
        "distance": {"unit": "m", "power": 1, "power_of_ten": -3},
        "time": {"unit": "s", "power": -1, "power_of_ten": 1},
    }
    self.max_position = -1 + min(
        max_position,
        self._valid_position(self._pos_sw_limit, self.input_pos_unit, invert=True),
    )  # TODO: Fix overshooting following error in drive control
    self.min_position = 1 + max(
        min_position,
        self._valid_position(self._neg_sw_limit, self.input_pos_unit, invert=True),
    )  # TODO: Fix overshooting following error in drive control
    self.max_velocity = self._valid_velocity(
        self._max_vel, self.input_vel_unit, invert=True
    )  # TODO: Get these from config, compare with SW limits and take most restrictive superset
    self.min_velocity = self._valid_velocity(
        self._min_vel, self.input_vel_unit, invert=True
    )  # TODO: Get these from config, compare with SW limits and take most restrictive superset

    logger.info(
        "Axis '%s': SW limits loaded — neg=%s, pos=%s (drive units)",
        self.name,
        self._neg_sw_limit,
        self._pos_sw_limit,
    )
    logger.info(
        "Axis '%s': SW limits loaded — neg=%s, pos=%s (standard units)",
        self.name,
        self.min_position,
        self.max_position,
    )

    if self.fault_present():
        logger.warning("Axis '%s': fault present on init", self.name)
    logger.debug("Axis '%s' fault string: %s", self.name, self.fault_string())
    logger.debug("Axis '%s' current fault code: %s", self.name, self.current_fault_code())
    self.acknowledge_faults()
    self.enable_powerstage()

    if run_referencing:
        logger.info("Axis '%s': referencing requested during initialization", self.name)
        self.home()

max_speed property

max_speed: float

Return largest allowed speed magnitude for this axis in mm/s.

This derives from configured signed velocity bounds and returns absolute maximum magnitude, independent of direction.

Returns:

Type Description
float

Maximum absolute velocity limit in mm/s.

home

home() -> bool

Home the axis by running a referencing task.

Acknowledges any faults, enables the power stage, and then executes a blocking referencing task to establish the axis zero point.

Source code in src/applied_motion/backends/edcon_axis.py
def home(self) -> bool:
    """Home the axis by running a referencing task.

    Acknowledges any faults, enables the power stage, and then
    executes a blocking referencing task to establish the axis zero
    point.
    """
    logger.info("Axis '%s': starting homing sequence", self.name)
    self.acknowledge_faults()
    self.enable_powerstage()
    res = self.referencing_task(nonblocking=False)

    logger.info("Axis '%s': homing result=%s", self.name, res)
    logger.info("Axis '%s': homing complete", self.name)
    return res

is_homed

is_homed() -> bool

Checks whether drive has been homed and has a valid frame of reference.

Thin wrapper for interface consistency around MotionHandler.referenced().

Source code in src/applied_motion/backends/edcon_axis.py
def is_homed(self) -> bool:
    """Checks whether drive has been homed and has a valid frame of reference.

    Thin wrapper for interface consistency around `MotionHandler.referenced()`.

    """
    return self.referenced()

current_position

current_position()

Transparent wrapper around MotionHandler.current_position.

TODO: is this necessary?

Returns the raw position value in the drive's internal unit system (drive units, whose scale is determined by PNU 11724 and varies by firmware/configuration — typically 0.001 mm per unit). Use get_current_axis_position when you need the position in a consistent, human-readable unit (mm).

Source code in src/applied_motion/backends/edcon_axis.py
def current_position(self):
    """Transparent wrapper around ``MotionHandler.current_position``.

    # TODO: is this necessary?

    Returns the raw position value in the drive's **internal unit system**
    (drive units, whose scale is determined by PNU 11724 and varies by
    firmware/configuration — typically 0.001 mm per unit).  Use
    [`get_current_axis_position`][applied_motion.backends.edcon_axis.EdconAxis.get_current_axis_position] when you need the position in a
    consistent, human-readable unit (mm).
    """
    logger.warning(
        "Axis '%s': current_position() returns a raw drive-unit value — "
        "unit depends on drive configuration (PNU 11724). "
        "Call get_current_axis_position() for a consistent mm value.",
        self.name,
    )
    return super().current_position()

get_current_axis_position

get_current_axis_position() -> float

Return the current axis position in the library's canonical output unit (mm).

Reads the raw drive-unit position from MotionHandler.current_position, then converts it to mm via _valid_position with invert=True. The drive's own PNU-reported position-unit scale is used for the conversion, so the result is always consistent regardless of how the drive was configured.

Internal methods (_check_overshoot, unit converters) continue to use super().current_position() directly so their drive-unit arithmetic is unaffected.

Source code in src/applied_motion/backends/edcon_axis.py
def get_current_axis_position(self) -> float:
    """Return the current axis position in the library's canonical output unit (mm).

    Reads the raw drive-unit position from ``MotionHandler.current_position``,
    then converts it to mm via `_valid_position` with ``invert=True``.
    The drive's own PNU-reported position-unit scale is used for the
    conversion, so the result is always consistent regardless of how the
    drive was configured.

    Internal methods (`_check_overshoot`, unit converters) continue to
    use ``super().current_position()`` directly so their drive-unit arithmetic
    is unaffected.
    """
    _mm_unit = {"distance": {"unit": "m", "power": 1, "power_of_ten": -3}}
    return self._valid_position(super().current_position(), _mm_unit, invert=True)

move

move(
    position: int | float,
    velocity: int | float,
    timeout: int | None = None,
    **kwargs,
) -> bool

Move the axis to a specified position with a given velocity.

Parameters:

Name Type Description Default
position int | float

Target position in millimetres (mm). Converted internally to drive units before the motion command is issued.

required
velocity int | float

Move velocity in mm/s. Converted internally to drive units.

required
timeout int | None

Optional time limit in seconds for the move. When provided, the motion is launched in a background thread and a stop command is issued if the thread has not finished by the deadline. When None (default), the call blocks until motion completes.

None
**kwargs

Optional keyword overrides. Recognised keys:

  • position_type (str): "absolute" for an absolute target position or "relative" for a relative displacement. When omitted the move is treated as absolute.
{}

Returns:

Type Description
bool

True if the motion task succeeded, False otherwise.

Source code in src/applied_motion/backends/edcon_axis.py
def move(self, position: int | float, velocity: int | float, timeout: int | None = None, **kwargs) -> bool:
    """Move the axis to a specified position with a given velocity.

    Args:
        position: Target position in millimetres (mm).  Converted internally
            to drive units before the motion command is issued.
        velocity: Move velocity in mm/s.  Converted internally to drive units.
        timeout: Optional time limit in seconds for the move.  When provided,
            the motion is launched in a background thread and a stop command
            is issued if the thread has not finished by the deadline.  When
            ``None`` (default), the call blocks until motion completes.
        **kwargs: Optional keyword overrides.  Recognised keys:

            - ``position_type`` (``str``): ``"absolute"`` for an absolute
              target position or ``"relative"`` for a relative displacement.
              When omitted the move is treated as **absolute**.

    Returns:
        ``True`` if the motion task succeeded, ``False`` otherwise.
    """
    # TODO: check valid move parameters against internal set values
    # e.g. Position limit, velocity limit, acceleration limit, etc.
    # if not valid, raise exception
    pos_type = kwargs.get("position_type", "absolute")
    logger.debug(
        "Axis '%s': entering move — raw position=%s  raw velocity=%s raw timeout=%s raw position_type=%s",
        self.name,
        position,
        velocity,
        timeout,
        pos_type,
    )
    positioning_type = pos_type == "absolute"

    clamped_position = self._clamped_target(position, positioning_type)
    logger.debug("Axis '%s': processing move — clamped_position=%s", self.name, clamped_position)
    try:
        validated_position = int(self._valid_position(clamped_position, self.input_pos_unit))
    except Exception:
        logger.exception("Axis '%s': failed to validate position", self.name)
        validated_position = -5  # TODO: This seems bad and wrong

    try:
        validated_velocity = int(self._valid_velocity(velocity, self.input_vel_unit))
    except Exception:
        logger.exception("Axis '%s': failed to validate velocity", self.name)
        validated_velocity = 5  # TODO: This seems bad and wrong
    logger.debug(
        "Axis '%s': processing move — validated_position=%s  validated_velocity=%s",
        self.name,
        validated_position,
        validated_velocity,
    )
    # self.configure_continuous_update(True) # continous update so that new position tasks can be started while still in motion
    #
    # TODO: Check faults and abort if critical fault encountered

    # self.acknowledge_faults()

    logger.debug(
        "Axis '%s': fault_string=%s  fault_code=%s", self.name, self.fault_string(), self.current_fault_code()
    )
    validated_position = self._check_overshoot(validated_position, absolute=positioning_type)
    logger.debug(
        "Axis '%s': clamped_position=%s  validated_velocity=%s", self.name, validated_position, validated_velocity
    )
    # Skip if already at target (absolute) or zero delta (relative).
    at_target = (
        abs(validated_position - int(super().current_position())) == 0
        if positioning_type
        else abs(validated_position) == 0
    )
    if at_target:
        logger.info("Axis '%s': already at target drive position %s, skipping move", self.name, validated_position)
        return True
    result: bool = False
    # TODO: Check powerstage enabled, attempt enable if not
    # TODO:
    # TODO: Check for CRITICAL error stages,
    # TODO: ack faults,
    # TODO: then move.
    # TODO: Incorporate jog mode into this function?
    self.acknowledge_faults()
    self.enable_powerstage()
    if timeout is None:
        result = self.position_task(
            validated_position,
            validated_velocity,
            absolute=positioning_type,
            nonblocking=False,
        )
    else:
        _result_box: list[bool] = []
        move_thread = Thread(
            target=lambda: _result_box.append(
                self.position_task(
                    validated_position,
                    validated_velocity,
                    absolute=positioning_type,
                    nonblocking=False,
                )
            )
        )
        move_thread.start()
        move_thread.join(timeout=timeout)
        if move_thread.is_alive():
            logger.warning("Axis '%s': move timed out after %ss — sending stop motion task", self.name, timeout)
            self.stop_motion_task()
            # Wait for the thread to actually exit before returning; 50 ms is not enough.
            move_thread.join(timeout=timeout)
            if move_thread.is_alive():
                logger.error(
                    f"Axis '%s': position_task thread still alive {timeout}s after stop command", self.name
                )
        else:
            result = _result_box[0] if _result_box else False  # TODO: AllTrue?

    logger.info("Axis '%s': motion task complete, result=%s", self.name, result)
    return result