Skip to content

commands

Command-group definitions for the fluid-control CLI.

This module turns the imperative methods on FluidControlSession into a composable [CommandGroup][fluid_control.cli.compose.core.CommandGroup]. The resulting group can be run standalone by fluid_control.cli.cli or mounted as a child of a super-CLI's root group (e.g. a liquid-handling system exposing this component under pipettor).

Gantry / mount-arm motion commands are collected into their own child group so that, when composed, they appear under a gantry namespace (e.g. gantry home).

build_gantry_group(session)

Build the gantry command group bound to a session's mount arm.

Parameters:

Name Type Description Default
session FluidControlSession

The FluidControlSession whose gantry and mount arm the commands operate on.

required

Returns:

Type Description
CommandGroup

A [CommandGroup][fluid_control.cli.compose.core.CommandGroup] named gantry

CommandGroup

containing motion and powerstage commands.

Source code in src/fluid_control/cli/commands.py
def build_gantry_group(session: FluidControlSession) -> CommandGroup:
    """
    Build the ``gantry`` command group bound to a session's mount arm.

    Args:
        session: The [`FluidControlSession`][fluid_control.cli.session.FluidControlSession]
            whose gantry and mount arm the commands operate on.

    Returns:
        A [`CommandGroup`][fluid_control.cli.compose.core.CommandGroup] named ``gantry``
        containing motion and powerstage commands.

    """
    group = CommandGroup("gantry", help="Mount-arm / gantry motion commands")
    group.add_command(
        Command("move", functools.partial(_cmd_move, session), "move <axis> <position_mm> [velocity]", "Move axis")
    )
    group.add_command(
        Command("raise", functools.partial(_cmd_raise, session), "raise <delta_mm> [velocity]", "Raise mount arm")
    )
    group.add_command(
        Command("lower", functools.partial(_cmd_lower, session), "lower <delta_mm> [velocity]", "Lower mount arm")
    )
    group.add_command(Command("where", functools.partial(_cmd_where, session), "where", "Print axis positions"))
    group.add_command(Command("home", functools.partial(_cmd_home, session), "home", "Home all axes"))
    group.add_command(Command("enable", functools.partial(_cmd_enable, session), "enable", "Enable powerstage"))
    group.add_command(Command("disable", functools.partial(_cmd_disable, session), "disable", "Disable powerstage"))
    return group

build_group(session)

Build the composable command group for a fluid-control session.

Registers the fluid-control verbs (valve, direct, dispense, aspirate, mix, pressure, classes, channels, status) and tip verbs (pickup, eject) as leaf commands, and mounts the gantry motion commands under a gantry child namespace when a gantry is configured on session.

Parameters:

Name Type Description Default
session FluidControlSession

The FluidControlSession to expose as a command group.

required

Returns:

Type Description
CommandGroup

A [CommandGroup][fluid_control.cli.compose.core.CommandGroup] named fluid

CommandGroup

that can be run standalone or mounted into a super-CLI's root group.

Source code in src/fluid_control/cli/commands.py
def build_group(session: FluidControlSession) -> CommandGroup:
    """
    Build the composable command group for a fluid-control session.

    Registers the fluid-control verbs (valve, direct, dispense, aspirate, mix,
    pressure, classes, channels, status) and tip verbs (pickup, eject) as leaf
    commands, and mounts the gantry motion commands under a ``gantry`` child
    namespace when a gantry is configured on *session*.

    Args:
        session: The [`FluidControlSession`][fluid_control.cli.session.FluidControlSession] to
            expose as a command group.

    Returns:
        A [`CommandGroup`][fluid_control.cli.compose.core.CommandGroup] named ``fluid``
        that can be run standalone or mounted into a super-CLI's root group.

    """
    group = CommandGroup("fluid", help="Festo fluid-control commands")
    group.add_command(
        Command("valve", functools.partial(_cmd_valve, session), "valve <ch> <ms> [pressure]", "Open one valve timed")
    )
    group.add_command(
        Command(
            "direct",
            functools.partial(_cmd_direct, session),
            "direct <ch:ms ...> pressure=<mbar>",
            "Multi-channel raw command",
        )
    )
    group.add_command(
        Command(
            "dispense",
            functools.partial(_cmd_dispense, session),
            "dispense <ch> <vol_uL> <liquid_class>",
            "Dispense volume",
            completions=session.get_liquid_classes,
        )
    )
    group.add_command(
        Command(
            "aspirate",
            functools.partial(_cmd_aspirate, session),
            "aspirate <ch> <vol_uL> <liquid_class>",
            "Aspirate volume (Pipettor)",
            completions=session.get_liquid_classes,
        )
    )
    group.add_command(
        Command(
            "mix",
            functools.partial(_cmd_mix, session),
            "mix <ch> <vol_uL> <liquid_class> <cycles>",
            "Aspirate/dispense mix cycles",
            completions=session.get_liquid_classes,
        )
    )
    group.add_command(
        Command("pressure", functools.partial(_cmd_pressure, session), "pressure <mbar>", "Set output pressure")
    )
    group.add_command(Command("classes", functools.partial(_cmd_classes, session), "classes", "List liquid classes"))
    group.add_command(Command("channels", functools.partial(_cmd_channels, session), "channels", "List valve channels"))
    group.add_command(Command("status", functools.partial(_cmd_status, session), "status", "Show status"))
    group.add_command(
        Command(
            "loglevel",
            functools.partial(_cmd_loglevel, session),
            "loglevel [OFF|DEBUG|INFO|WARNING|ERROR|CRITICAL]",
            "Show or change current log level",
        )
    )
    group.add_command(
        Command(
            "applied-motion",
            functools.partial(_cmd_applied_motion, session),
            "applied-motion",
            "Launch the applied-motion teach-in CLI",
        )
    )
    group.add_command(Command("pickup", functools.partial(_cmd_pickup, session), "pickup <duration_s>", "Pick up tips"))
    group.add_command(Command("eject", functools.partial(_cmd_eject, session), "eject", "Eject tips"))

    if session.gantry is not None:
        group.add_child(build_gantry_group(session), name="gantry")

    return group