def get_default_prefix(sample_data, generic_name): if isinstance(sample_data, dict): sample = qmo.Sample() sample.code = sample_data.get("code", "") sample.name = sample_data.get("sampleName", "").replace(":", "-") sample.location = sample_data.get("location", "").split(":") sample.lims_id = sample_data.get("limsID", -1) sample.crystals[0].protein_acronym = sample_data.get("proteinAcronym", "") else: sample = sample_data return blcontrol.beamline.session.get_default_prefix(sample, generic_name)
def __init__(self, *args): BaseWidget.__init__(self, *args) # Internal variables ------------------------------------------------ self.sample = queue_model_objects.Sample() self.crystal = self.sample.crystals[0] self.sample_mib = DataModelInputBinder(self.sample) self.crystal_mib = DataModelInputBinder(self.crystal) # Signals ------------------------------------------------------------ # Slots -------------------------------------------------------------- self.define_slot("populate_sample_details", ({})) # Graphic elements ---------------------------------------------------- _info_widget = QtImport.QWidget(self) self.crystal_widget = QtImport.load_ui_file("crystal_widget_layout.ui") self.sample_info_widget = QtImport.load_ui_file( "sample_info_widget_layout.ui") # self.ispyb_sample_info_widget = ISPyBSampleInfoWidget(self) # Layout -------------------------------------------------------------- _info_widget_hlayout = QtImport.QHBoxLayout(_info_widget) _info_widget_hlayout.addWidget(self.sample_info_widget) _info_widget_hlayout.addWidget(self.crystal_widget) _info_widget_hlayout.addStretch(0) _info_widget_hlayout.setSpacing(0) _info_widget_hlayout.setContentsMargins(2, 2, 2, 2) _main_hlayout = QtImport.QVBoxLayout(self) _main_hlayout.addWidget(_info_widget) # _main_hlayout.addWidget(self.ispyb_sample_info_widget) _main_hlayout.addStretch(0) _main_hlayout.setSpacing(0) _main_hlayout.setContentsMargins(2, 2, 2, 2) # SizePolicies -------------------------------------------------------- # Qt signal/slot connections ------------------------------------------ # Other --------------------------------------------------------------- self.crystal_mib.bind_value_update( "space_group", self.crystal_widget.space_group_value_label, str, None) self.crystal_mib.bind_value_update( "protein_acronym", self.crystal_widget.protein_acronym_value_label, str, None, ) self.crystal_mib.bind_value_update("cell_a", self.crystal_widget.a_value_label, str, None) self.crystal_mib.bind_value_update( "cell_alpha", self.crystal_widget.alpha_value_label, str, None) self.crystal_mib.bind_value_update("cell_b", self.crystal_widget.b_value_label, str, None) self.crystal_mib.bind_value_update( "cell_beta", self.crystal_widget.beta_value_label, str, None) self.crystal_mib.bind_value_update("cell_c", self.crystal_widget.c_value_label, str, None) self.crystal_mib.bind_value_update( "cell_gamma", self.crystal_widget.gamma_value_label, str, None) self.sample_mib.bind_value_update( "name", self.sample_info_widget.name_value_label, str, None) self.sample_mib.bind_value_update( "code", self.sample_info_widget.data_matrix_value_label, str, None) self.sample_mib.bind_value_update( "holder_length", self.sample_info_widget.holder_length_value_label, str, None, ) self.sample_mib.bind_value_update( "lims_sample_location", self.sample_info_widget.sample_location_value_label, str, None, ) self.sample_mib.bind_value_update( "lims_container_location", self.sample_info_widget.basket_location_value_label, str, None, )
def pre_execute(self, data_model): self._failed = False """ if self.beam_focusing_hwobj.get_focus_mode() != "imaging": self._error_msg = "Beamline is not in Imaging mode" self.emit("collectFailed", self._error_msg) logging.getLogger("GUI").error("Imaging: Error during acquisition (%s)" % self._error_msg) self.ready_event.set() self._collecting = False self._failed = True return """ self.emit("progressInit", ("Image acquisition", 100, False)) self._collect_frame = 0 self.printed_warnings = [] self.printed_errors = [] self.ff_ssim = None self.config_dict = {} path_template = data_model.acquisitions[0].path_template acq_params = data_model.acquisitions[0].acquisition_parameters im_params = data_model.xray_imaging_parameters self._number_of_images = acq_params.num_images if im_params.detector_distance is not None: logging.getLogger("GUI").warning( "Imaging: Setting detector distance to %d mm" % int(im_params.detector_distance)) delta = (im_params.detector_distance - self.reference_distance) * self.reference_angle for motor in self.beam_focusing_hwobj.get_focus_motors(): if motor["motorName"] == "P14DetHor1": target = motor["focusingModes"]["Imaging"] + delta tine.set("/P14/P14DetTrans/P14detHor1", "Move.START", target) elif motor["motorName"] == "P14DetHor2": target = motor["focusingModes"]["Imaging"] + delta tine.set("/P14/P14DetTrans/P14detHor2", "Move.START", target) #TODO add later wait time.sleep(3) HWR.beamline.detector.distance.set_value( im_params.detector_distance, timeout=30) logging.getLogger("GUI").info("Imaging: Detector distance set") self.cmd_collect_detector("pco") self.cmd_collect_directory(str(path_template.directory)) self.cmd_collect_template(str(path_template.get_image_file_name())) self.cmd_collect_scan_type("xrimg") self.cmd_collect_exposure_time(acq_params.exp_time) self.cmd_collect_num_images(acq_params.num_images) self.cmd_collect_start_angle(acq_params.osc_start) self.cmd_collect_range(acq_params.osc_range) self.cmd_collect_in_queue(acq_params.in_queue != False) shutter_name = HWR.beamline.detector.get_shutter_name() self.cmd_collect_shutter(shutter_name) self.cmd_collect_ff_num_images(im_params.ff_num_images) self.cmd_collect_ff_offset([ im_params.sample_offset_a, im_params.sample_offset_b, im_params.sample_offset_c, ]) self.cmd_collect_ff_pre(im_params.ff_pre) self.cmd_collect_ff_post(im_params.ff_post) if acq_params.osc_range == 0: self.cmd_camera_trigger(False) else: self.cmd_camera_trigger(True) self.cmd_camera_live_view(im_params.ff_apply) self.cmd_camera_write_data(im_params.camera_write_data) self.cmd_camera_ff_ssim(im_params.ff_ssim_enabled) self.set_osc_start(acq_params.osc_start) self.current_dc_parameters = qmo.to_collect_dict( data_model, HWR.beamline.session, qmo.Sample())[0] self.current_dc_parameters["status"] = "Running" self.current_dc_parameters["comments"] = "" self.motor_positions = HWR.beamline.diffractometer.get_positions() self.take_crystal_snapshots() self.store_data_collection_in_lims()
def pre_execute(self, data_model): """ Pre execute method :param data_model: :return: """ self._failed = False """ if self.beam_focusing_hwobj.get_focus_mode() != "imaging": self._error_msg = "Beamline is not in Imaging mode" self.emit("collectFailed", self._error_msg) logging.getLogger("GUI").error("Imaging: Error during acquisition (%s)" % self._error_msg) self.ready_event.set() self._collecting = False self._failed = True return """ self.emit("progressInit", ("Image acquisition", 100, False)) self._collect_frame = 0 self.printed_warnings = [] self.printed_errors = [] self.ff_ssim = None self.config_dict = {} path_template = data_model.acquisitions[0].path_template acq_params = data_model.acquisitions[0].acquisition_parameters im_params = data_model.xray_imaging_parameters self._number_of_images = acq_params.num_images if im_params.detector_distance: delta = im_params.detector_distance - self.detector_hwobj.get_distance() if abs(delta) > 0.0001: tine.set( "/P14/P14DetTrans/ComHorTrans", "IncrementMove.START", -0.003482 * delta, ) self.detector_hwobj.set_distance( im_params.detector_distance, wait=True, timeout=30 ) self.cmd_collect_detector("pco") self.cmd_collect_directory(str(path_template.directory)) self.cmd_collect_template(str(path_template.get_image_file_name())) self.cmd_collect_scan_type("xrimg") self.cmd_collect_exposure_time(acq_params.exp_time) self.cmd_collect_num_images(acq_params.num_images) self.cmd_collect_start_angle(acq_params.osc_start) self.cmd_collect_range(acq_params.osc_range) self.cmd_collect_in_queue(acq_params.in_queue != False) shutter_name = self.detector_hwobj.get_shutter_name() self.cmd_collect_shutter(shutter_name) self.cmd_collect_ff_num_images(im_params.ff_num_images) self.cmd_collect_ff_offset( [ im_params.sample_offset_a, im_params.sample_offset_b, im_params.sample_offset_c, ] ) self.cmd_collect_ff_pre(im_params.ff_pre) self.cmd_collect_ff_post(im_params.ff_post) if acq_params.osc_range == 0: self.cmd_camera_trigger(False) else: self.cmd_camera_trigger(True) self.cmd_camera_live_view(im_params.ff_apply) self.cmd_camera_write_data(im_params.camera_write_data) self.cmd_camera_ff_ssim(im_params.ff_ssim_enabled) self.set_osc_start(acq_params.osc_start) self.current_dc_parameters = qmo.to_collect_dict( data_model, self.session_hwobj, qmo.Sample() )[0] self.current_dc_parameters["status"] = "Running" self.current_dc_parameters["comments"] = "" self.store_data_collection_in_lims()