Ejemplo n.º 1
0
def mount_sample_clean_up(sample):
    from mxcube3.routes import signals

    sc = blcontrol.beamline.sample_changer

    res = None

    try:
        msg = "[SC] mounting %s" % sample["location"]
        logging.getLogger("MX3.HWR").info(msg)

        signals.sc_load(sample["location"])

        sid = get_current_sample().get("sampleID", False)
        current_queue = qutils.queue_to_dict()

        set_sample_to_be_mounted(sample["sampleID"])

        if sample["location"] != "Manual":
            if not sc.get_loaded_sample():
                res = sc.load(sample["sampleID"], wait=True)
            elif sc.get_loaded_sample().get_address() != sample["location"]:
                res = sc.load(sample["sampleID"], wait=True)

            if res is None:
                res = True

            if (res and mxcube.CENTRING_METHOD == CENTRING_METHOD.LOOP
                    and blcontrol.beamline.diffractometer.in_kappa_mode()):
                msg = "Starting autoloop centring ..."
                logging.getLogger("MX3.HWR").info(msg)
                C3D_MODE = blcontrol.beamline.diffractometer.C3D_MODE
                blcontrol.beamline.diffractometer.start_centring_method(
                    C3D_MODE)
            elif not sc.get_loaded_sample():
                set_current_sample(None)
        else:
            set_current_sample(sample["sampleID"])
            res = True

    except Exception as ex:
        logging.getLogger("MX3.HWR").exception(
            "[SC] sample could not be mounted")

        raise RuntimeError(str(ex))
    else:
        # Clean up if the new sample was mounted or the current sample was
        # unmounted and the new one, for some reason, failed to mount
        if res or (not res and not sc.get_loaded_sample()):
            blcontrol.beamline.sample_view.clear_all()

            # We remove the current sample from the queue, if we are moving
            # from one sample to another and the current sample is in the queue
            if sid and current_queue[sid]:
                node_id = current_queue[sid]["queueID"]
                qutils.set_enabled_entry(node_id, False)
    finally:
        signals.sc_load_ready(sample["location"])

    return res
Ejemplo n.º 2
0
def mount_sample_clean_up(sample):
    from mxcube3.routes import signals

    sc = blcontrol.sample_changer

    res = None

    try:
        msg = "[SC] mounting %s" % sample["location"]
        logging.getLogger("MX3.HWR").info(msg)

        signals.sc_load(sample["location"])

        sid = get_current_sample().get("sampleID", False)
        current_queue = qutils.queue_to_dict()

        set_sample_to_be_mounted(sample["sampleID"])

        if sample["location"] != "Manual":
            if not sc.getLoadedSample():
                res = sc.load(sample["sampleID"], wait=True)
            elif sc.getLoadedSample().getAddress() != sample["location"]:
                res = sc.load(sample["sampleID"], wait=True)
            if res is None:
                res = True
            if res and mxcube.CENTRING_METHOD == CENTRING_METHOD.LOOP:
                msg = "Starting autoloop centring ..."
                logging.getLogger("MX3.HWR").info(msg)
                C3D_MODE = blcontrol.diffractometer.C3D_MODE
                blcontrol.diffractometer.startCentringMethod(C3D_MODE)
            elif not sc.getLoadedSample():
                set_current_sample(None)
        else:
            set_current_sample(sample["sampleID"])
            res = True

    except Exception as ex:
        logging.getLogger("MX3.HWR").exception("[SC] sample could not be mounted")

        raise RuntimeError(str(ex))
    else:
        # Clean up if the new sample was mounted or the current sample was
        # unmounted and the new one, for some reason, failed to mount
        if res or (not res and not sc.getLoadedSample()):
            blcontrol.shapes.clear_all()

            # We remove the current sample from the queue, if we are moving
            # from one sample to another and the current sample is in the queue
            if sid and current_queue[sid]:
                node_id = current_queue[sid]["queueID"]
                qutils.set_enabled_entry(node_id, False)
    finally:
        signals.sc_load_ready(sample["location"])

    return res
Ejemplo n.º 3
0
def unmount_sample_clean_up(sample):
    from mxcube3.routes import signals

    try:
        signals.sc_unload(sample["location"])

        if not sample["location"] == "Manual":
            blcontrol.beamline.sample_changer.unload(sample["location"],
                                                     wait=False)
        else:
            set_current_sample(None)
            signals.sc_load_ready(sample["location"])

        msg = "[SC] unmounted %s" % sample["location"]
        logging.getLogger("MX3.HWR").info(msg)
    except Exception:
        msg = "[SC] sample could not be mounted"
        logging.getLogger("MX3.HWR").exception(msg)
        raise
    else:
        blcontrol.beamline.queue_model.mounted_sample = ""
        blcontrol.beamline.sample_view.clear_all()
Ejemplo n.º 4
0
def unmount_sample_clean_up(sample):
    from mxcube3.routes import signals

    try:
        signals.sc_unload(sample["location"])

        if not sample["location"] == "Manual":
            blcontrol.sample_changer.unload(sample["sampleID"], wait=False)
        else:
            set_current_sample(None)

        msg = "[SC] unmounted %s" % sample["location"]
        logging.getLogger("MX3.HWR").info(msg)
    except Exception:
        msg = "[SC] sample could not be mounted"
        logging.getLogger("MX3.HWR").exception(msg)
        raise
    else:
        blcontrol.queue.mounted_sample = ""
        set_current_sample(None)
        blcontrol.shapes.clear_all()
    finally:
        signals.sc_load_ready(sample["location"])