Exemple #1
0
    def create_task(self, sample, shape):
        (tasks, sc) = ([], None)
       
        try: 
            sample_is_mounted = self._beamline_setup_hwobj.sample_changer_hwobj.\
                                getLoadedSample().getCoords() == sample.location

        except AttributeError:
            sample_is_mounted = False

        dm = self._beamline_setup_hwobj.diffractometer_hwobj
        fully_automatic = (not dm.user_confirms_centring)

        free_pin_mode = sample.free_pin_mode
        temp_tasks = self._create_task(sample, shape)

        if (not fully_automatic):
            if ((not free_pin_mode) and (not sample_is_mounted) or (not shape)):
                # No centred positions selected, or selected sample not
                # mounted create sample centring task.

                # Check if the tasks requires centring, assumes that all
                # the "sub tasks" has the same centring requirements.
                if temp_tasks[0].requires_centring():
                    sc = queue_model_objects.SampleCentring('sample-centring')
                    tasks.append(sc)

        for task in temp_tasks:
            if sc:
                sc.add_task(task)
            tasks.append(task)

        return tasks
Exemple #2
0
def add_centring(id):
    '''
    Add a centring task to the sample with id: <id>, integer.
    Args: id, current id of the sample where add the method
            id: int (parsed to int anyway)
    Return: command sent successfully? http status response, 200 ok,
        409 something bad happened. Plus:
       data ={ "CentringId": newId}
    '''
    params = request.get_json()
    logging.getLogger('HWR').info(
        '[QUEUE] centring add requested with data: ' + str(params))

    cent_node = qmo.SampleCentring()
    cent_entry = qe.SampleCentringQueueEntry()
    cent_entry.set_data_model(cent_node)
    cent_entry.set_queue_controller(qm)
    node = mxcube.queue.get_node(int(id))
    entry = mxcube.queue.queue_hwobj.get_entry_with_model(node)
    entry._set_background_color = qutils.PMock()

    new_node = mxcube.queue.add_child_at_id(
        int(id), cent_node)  # add_child does not return id!
    entry.enqueue(cent_entry)

    logging.getLogger('HWR').info('[QUEUE] centring added to sample')

    resp = jsonify({'QueueId': new_node, 'Type': 'Centring', 'Params': params})
    resp.status_code = 200
    return resp
    def create_task(self, sample, shape):
        (tasks, sc) = ([], None)

        try:
            sample_is_mounted = self._beamline_setup_hwobj.sample_changer_hwobj.\
                                getLoadedSample().getCoords() == sample.location

        except AttributeError:
            sample_is_mounted = False

        dm = self._beamline_setup_hwobj.diffractometer_hwobj
        fully_automatic = (not dm.user_confirms_centring)

        free_pin_mode = sample.free_pin_mode
        temp_tasks = self._create_task(sample, shape)

        sample_is_mounted = True

        if (not fully_automatic):
            if ((not free_pin_mode) and (not sample_is_mounted)
                    or (not shape)):
                # No centred positions selected, or selected sample not
                # mounted create sample centring task.

                # Check if the tasks requires centring, assumes that all
                # the "sub tasks" has the same centring requirements.
                if temp_tasks[0].requires_centring():
                    kappa = None
                    kappa_phi = None
                    task_label = "Centring"
                    if isinstance(temp_tasks[0],
                                  queue_model_objects.DataCollection):
                        kappa = temp_tasks[0].acquisitions[
                            0].acquisition_parameters.kappa
                        kappa_phi = temp_tasks[0].acquisitions[
                            0].acquisition_parameters.kappa_phi
                        if kappa is not None and \
                           kappa_phi is not None:
                            task_label = "Centring (kappa=%0.1f,phi=%0.1f)" %\
                                         (kappa, kappa_phi)
                    elif isinstance(temp_tasks[0],
                                    queue_model_objects.Characterisation):
                        kappa = temp_tasks[0].reference_image_collection.\
                               acquisitions[0].acquisition_parameters.kappa
                        kappa_phi = temp_tasks[0].reference_image_collection.\
                               acquisitions[0].acquisition_parameters.kappa_phi
                        if kappa and kappa_phi:
                            task_label = "Centring (kappa=%0.1f,phi=%0.1f)"  % \
                                         (kappa, kappa_phi)
                    sc = queue_model_objects.SampleCentring(
                        task_label, kappa, kappa_phi)
                    tasks.append(sc)

        for task in temp_tasks:
            if sc:
                sc.add_task(task)
            tasks.append(task)

        return tasks
    def create_task(self, sample, shape):
        (tasks, sc) = ([], None)

        dm = self._beamline_setup_hwobj.diffractometer_hwobj

        sample_is_mounted = False
        if self._in_plate_mode:
            try:
                sample_is_mounted = self._beamline_setup_hwobj.plate_manipulator_hwobj.\
                   getLoadedSample().getCoords() == sample.location
            except:
                sample_is_mounted = False
        else:
            try:
                sample_is_mounted = self._beamline_setup_hwobj.sample_changer_hwobj.\
                   getLoadedSample().getCoords() == sample.location

            except AttributeError:
                sample_is_mounted = False

        fully_automatic = (not dm.user_confirms_centring)

        free_pin_mode = sample.free_pin_mode
        temp_tasks = self._create_task(sample, shape)

        if len(temp_tasks) == 0:
            return

        if ((not free_pin_mode) and (not sample_is_mounted) or (not shape)):
            # No centred positions selected, or selected sample not
            # mounted create sample centring task.

            # Check if the tasks requires centring, assumes that all
            # the "sub tasks" has the same centring requirements.
            if temp_tasks[0].requires_centring():
                if self._tree_brick.dc_tree_widget.centring_method == \
                   queue_model_enumerables.CENTRING_METHOD.MANUAL:

                    #Manual 3 click centering
                    acq_par = None
                    kappa = None
                    kappa_phi = None
                    task_label = "Manual centring"

                    if isinstance(temp_tasks[0],
                                  queue_model_objects.DataCollection):
                        acq_par = temp_tasks[0].acquisitions[0].\
                          acquisition_parameters
                    elif isinstance(temp_tasks[0],
                                    queue_model_objects.Characterisation):
                        acq_par =  temp_tasks[0].reference_image_collection.\
                           acquisitions[0].acquisition_parameters

                    if acq_par:
                        kappa = acq_par.kappa
                        kappa_phi = acq_par.kappa_phi
                        if kappa is not None and kappa_phi is not None:
                            task_label = "Manual centring (kappa=%0.1f,phi=%0.1f)" % \
                              (kappa, kappa_phi)

                    sc = queue_model_objects.SampleCentring(
                        task_label, kappa, kappa_phi)
                elif self._tree_brick.dc_tree_widget.centring_method == \
                   queue_model_enumerables.CENTRING_METHOD.LOOP:

                    #Optical automatic centering with user confirmation
                    sc = queue_model_objects.OpticalCentring(
                        user_confirms=True)
                elif self._tree_brick.dc_tree_widget.centring_method == \
                   queue_model_enumerables.CENTRING_METHOD.FULLY_AUTOMATIC:

                    #Optical automatic centering without user confirmation
                    sc = queue_model_objects.OpticalCentring()
                elif self._tree_brick.dc_tree_widget.centring_method == \
                   queue_model_enumerables.CENTRING_METHOD.XRAY:

                    #Xray centering
                    mesh_dc = self._create_dc_from_grid(sample)
                    mesh_dc.run_processing_parallel = "XrayCentering"
                    sc = queue_model_objects.XrayCentering(mesh_dc)
                if sc:
                    tasks.append(sc)

        for task in temp_tasks:
            if sc:
                sc.add_task(task)
            tasks.append(task)

        return tasks