def _create_task(self,  sample, shape):
        """Creates tasks based on selected grids

        :param sample: selected sample object
        :type sample: SampleQueueItem
        :param shape: selected shape
        :type shape: Qt4_GraphicsLib.GraphicsItem
        """
        tasks = []
        selected_grid = self.get_selected_grid()

        mesh_dc = self._create_dc_from_grid(sample, selected_grid)

        exp_type = str(self._advanced_methods_widget.method_combo.currentText())
        if exp_type == "MeshScan":
            tasks.append(mesh_dc)
        elif exp_type == "XrayCentering":
            xray_centering = queue_model_objects.XrayCentering(mesh_dc)
            tasks.append(xray_centering)
        else:
            logging.getLogger("GUI").\
                warning("Method %s does not exist in queue_model_objects" % exp_type)
        mesh_dc.run_processing_parallel = exp_type

        return tasks
Esempio n. 2
0
    def _create_task(self,  sample, shape):
        """Creates tasks based on selected grids

        :param sample: selected sample object
        :type sample: SampleQueueItem
        :param shape: selected shape
        :type shape: Qt4_GraphicsLib.GraphicsItem
        """
        tasks = []
        selected_grids = self.get_selected_grids() 

        if len(selected_grids) == 0:
            selected_grids.append(self._graphics_manager_hwobj.\
                update_auto_grid()) 

        for grid in selected_grids:
            grid.set_snapshot(self._graphics_manager_hwobj.\
                  get_scene_snapshot(grid))

            grid_properties = grid.get_properties()

            acq = self._create_acq(sample)
            acq.acquisition_parameters.centred_position = \
                grid.get_centred_position()
            acq.acquisition_parameters.mesh_range = \
                [grid_properties["dx_mm"], grid_properties["dy_mm"]]
            acq.acquisition_parameters.num_lines = \
                grid_properties["num_lines"]
            acq.acquisition_parameters.num_images = \
                grid_properties["num_lines"] * \
                grid_properties["num_images_per_line"]
            grid.set_osc_range(acq.acquisition_parameters.osc_range)

            processing_parameters = deepcopy(self._processing_parameters)

            dc = queue_model_objects.DataCollection([acq],
                                     sample.crystals[0],
                                     processing_parameters)

            dc.set_name(acq.path_template.get_prefix())
            dc.set_number(acq.path_template.run_number)
            dc.set_experiment_type(EXPERIMENT_TYPE.MESH)
            dc.set_requires_centring(False)
            dc.grid = grid

            exp_type = str(self._advanced_methods_widget.\
                method_combo.currentText())
            if exp_type == "MeshScan":
                dc.run_processing_parallel = "MeshScan"
                tasks.append(dc)
            elif exp_type == "XrayCentering":
                xray_centering = queue_model_objects.XrayCentering(\
                   dc, sample.crystals[0])
                dc.run_processing_parallel = "XrayCentering"
                tasks.append(xray_centering)
            self._path_template.run_number += 1

            return tasks
Esempio n. 3
0
    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