Esempio n. 1
0
def get_motion_lock() -> ThreadedAsyncLock:
    """
    Get the single motion lock.

    :return: a threaded async lock
    """
    return ThreadedAsyncLock()
Esempio n. 2
0
async def post_home_robot(
        robot_home_target: control.RobotHomeTarget,
        hardware: ThreadManager = Depends(get_hardware),
        motion_lock: ThreadedAsyncLock = Depends(get_motion_lock)) \
        -> V1BasicResponse:
    """Home the robot or one of the pipettes"""
    try:
        async with motion_lock.forbid():
            mount = robot_home_target.mount
            target = robot_home_target.target

            home = hardware.home  # type: ignore
            home_plunger = hardware.home_plunger  # type: ignore

            if target == control.HomeTarget.pipette and mount:
                await home([Axis.by_mount(Mount[mount.upper()])])
                await home_plunger(Mount[mount.upper()])
                message = f"Pipette on {mount} homed successfully"
            elif target == control.HomeTarget.robot:
                await home()
                message = "Homing robot."
            else:
                raise V1HandlerError(message=f"{target} is invalid",
                                     status_code=status.HTTP_400_BAD_REQUEST)

            return V1BasicResponse(message=message)
    except ThreadedAsyncForbidden as e:
        raise V1HandlerError(status_code=status.HTTP_403_FORBIDDEN,
                             message=str(e))
Esempio n. 3
0
async def post_move_robot(
        robot_move_target: control.RobotMoveTarget,
        hardware: ThreadManager = Depends(get_hardware),
        motion_lock: ThreadedAsyncLock = Depends(get_motion_lock))\
        -> V1BasicResponse:
    """Move the robot"""
    try:
        async with motion_lock.forbid():
            pos = await _do_move(hardware=hardware,
                                 robot_move_target=robot_move_target)
            return V1BasicResponse(
                message=f"Move complete. New position: {pos}")
    except ThreadedAsyncForbidden as e:
        raise V1HandlerError(status_code=status.HTTP_403_FORBIDDEN,
                             message=str(e))
Esempio n. 4
0
def protocol_runner(mock_protocol, loop, hardware):
    return ProtocolRunner(protocol=mock_protocol,
                          loop=loop,
                          hardware=hardware,
                          motion_lock=ThreadedAsyncLock())
Esempio n. 5
0
def session_manager(hardware) -> SessionManager:
    return SessionManager(hardware=hardware,
                          motion_lock=ThreadedAsyncLock(),
                          protocol_manager=ProtocolManager())
Esempio n. 6
0
def main_router(loop, virtual_smoothie_env, hardware):
    router = MainRouter(hardware=hardware, loop=loop, lock=ThreadedAsyncLock())
    router.wait_until = partial(wait_until,
                                notifications=router.notifications,
                                loop=loop)
    yield router