def init(self): MiniDiff.MiniDiff.init(self) self.phiDirection = self.getProperty("phi_direction") self.centeringPhiyDirection = -1 self.calib_x = self.getChannelObject("calib_x") self.calib_y = self.getChannelObject("calib_y") self.beam_position_x = self.getChannelObject("beam_position_x") self.beam_position_y = self.getChannelObject("beam_position_y") self.chan_current_phase = self.getChannelObject('current_phase') self.chan_current_phase_index = self.getChannelObject( 'current_phase_index') self.chan_motor_positions = self.getChannelObject('motor_positions') self.chan_motor_states = self.getChannelObject('motor_states') self.chan_scan_number_of_passes = self.getChannelObject( 'scan_number_of_passes') self.chan_scan_range = self.getChannelObject('scan_range') self.chan_scan_exposure_time = self.getChannelObject( 'scan_exposure_time') self.chan_scan_start_angle = self.getChannelObject('scan_start_angle') self.chan_back_light_is_on = self.getChannelObject('back_light_is_on') self.chan_fast_shutter_is_open = self.getChannelObject( 'fast_shutter_is_open') self.chan_last_task_info = self.getChannelObject('last_task_info') self.cmd_get_motor_state = self.getCommandObject('getMotorState') self.cmd_start_set_phase = self.getCommandObject('startSetPhase') self.cmd_start_auto_focus = self.getCommandObject('startAutoFocus') self.cmd_start_scan = self.getCommandObject('startScan') self.collect_phase = 'DataCollection' self.beamlocate_phase = 'BeamLocation' self.transfer_phase = 'Transfer' self.centering_phase = 'Centring' try: phiz_ref = self["centringReferencePosition"].getProperty("phiz") except: phiz_ref = None self.centringPhiy = sample_centring.CentringMotor( self.phiyMotor, direction=self.centeringPhiyDirection) self.centringPhiz = sample_centring.CentringMotor( self.phizMotor, reference_position=phiz_ref) try: self.phase_list = eval(self.getProperty("phaseList")) except: self.phase_list = []
def init(self): self.controller = self.getObjectByRole("controller") MiniDiff.MiniDiff.init(self) self.chiMotor = self.getDeviceByRole('chi') self.zMotor = self.getDeviceByRole('z') self.yMotor = self.getDeviceByRole('y') self.centringPhiz = sample_centring.CentringMotor( self.zMotor) #, reference_position=phiz_ref) self.centringPhiy = sample_centring.CentringMotor(self.yMotor) self.connect(self.zMotor, 'stateChanged', self.phizMotorStateChanged) self.connect(self.zMotor, 'positionChanged', self.phizMotorMoved) self.connect(self.zMotor, "positionChanged", self.emitDiffractometerMoved) self.connect(self.yMotor, 'stateChanged', self.phiyMotorStateChanged) self.connect(self.yMotor, 'positionChanged', self.phiyMotorMoved) self.connect(self.yMotor, "positionChanged", self.emitDiffractometerMoved)
def init(self): """ Descript. : """ GenericDiffractometer.init(self) self.current_phase = GenericDiffractometer.PHASE_CENTRING self.cancel_centring_methods = {} self.current_state_dict = {} self.centring_status = {"valid": False} self.centring_time = 0 #using sample_centring module self.centring_phi = sample_centring.CentringMotor( self.motor_hwobj_dict["phi"], direction=-1, ) self.centring_phiz = sample_centring.CentringMotor( self.motor_hwobj_dict["phiz"], direction=1, units='microns') self.centring_phiy = sample_centring.CentringMotor( self.motor_hwobj_dict["phiy"], direction=1, units='microns', ) self.centring_sampx = sample_centring.CentringMotor( self.motor_hwobj_dict["sampx"], units='microns', ) self.centring_sampy = sample_centring.CentringMotor( self.motor_hwobj_dict["sampy"], units='microns', ) self.update_zoom_calibration()
def init(self): # Internal values ----------------------------------------------------- self.ready_event = gevent.event.Event() self.user_clicked_event = gevent.event.AsyncResult() self.user_confirms_centring = True # Hardware objects ---------------------------------------------------- self.camera_hwobj = self.getObjectByRole("camera") if self.camera_hwobj is not None: self.image_height = self.camera_hwobj.getHeight() self.image_width = self.camera_hwobj.getWidth() else: logging.getLogger("HWR").debug("Diffractometer: " + \ "Camera hwobj is not defined") self.beam_info_hwobj = self.getObjectByRole("beam_info") if self.beam_info_hwobj is not None: self.beam_position = self.beam_info_hwobj.get_beam_position() self.connect(self.beam_info_hwobj, "beamPosChanged", self.beam_position_changed) else: self.beam_position = [self.image_width / 2, self.image_height / 2] logging.getLogger("HWR").warning("Diffractometer: " +\ "BeamInfo hwobj is not defined") self.front_light_swtich = self.getObjectByRole('frontlightswtich') self.back_light_swtich = self.getObjectByRole('backlightswtich') # Channels ----------------------------------------------------------- ss = self.getProperty("used_channels") if ss: try: self.used_channels_list = eval(ss) except: pass # used the default value for channel_name in self.used_channels_list: self.channel_dict[channel_name] = self.getChannelObject( channel_name) if self.channel_dict[channel_name] is None: continue if channel_name == "TransferMode": self.connect(self.channel_dict["TransferMode"], "update", self.transfer_mode_changed) elif channel_name == "CurrentPhase": self.connect(self.channel_dict["CurrentPhase"], "update", self.current_phase_changed) elif channel_name == "HeadType": self.connect(self.channel_dict["HeadType"], "update", self.head_type_changed) elif channel_name == "State": self.connect(self.channel_dict["State"], "update", self.state_changed) # Commands ----------------------------------------------------------- try: self.used_commands_list = eval( self.getProperty("used_commands", "[]")) except: pass # used the default value for command_name in self.used_commands_list: self.command_dict[command_name] = self.getCommandObject( command_name) # Centring motors ---------------------------------------------------- try: self.centring_motors_list = eval( self.getProperty("centring_motors")) except: self.centring_motors_list = GenericDiffractometer.CENTRING_MOTORS_NAME queue_model_objects.CentredPosition.\ set_diffractometer_motor_names(*self.centring_motors_list) for motor_name in self.centring_motors_list: temp_motor_hwobj = self.getObjectByRole(motor_name) if temp_motor_hwobj is not None: logging.getLogger("HWR").debug("Diffractometer: Adding " + \ "%s motor to centring motors" % motor_name) self.motor_hwobj_dict[motor_name] = temp_motor_hwobj self.connect(temp_motor_hwobj, "stateChanged", self.motor_state_changed) self.connect(temp_motor_hwobj, "positionChanged", self.centring_motor_moved) if motor_name == "phi": self.connect(temp_motor_hwobj, "positionChanged", self.emit_diffractometer_moved) elif motor_name == "zoom": self.connect(temp_motor_hwobj, "predefinedPositionChanged", self.zoom_motor_predefined_position_changed) self.connect(temp_motor_hwobj, "stateChanged", self.zoom_motor_state_changed) else: logging.getLogger("HWR").warning("Diffractometer: Motor " + \ "%s listed in the centring motor list, but not initalized" % motor_name) # sample changer ----------------------------------------------------- self.sample_changer = self.getObjectByRole("samplechanger") if self.sample_changer is None: logging.getLogger("HWR").warning( 'Diffractometer: Sample Changer is not defined') else: #By default use sample changer if it's defined and transfer_mode # is set to SAMPLE_CHANGER. # if not defined, set use_sc to True if self.transfer_mode is None or self.transfer_mode == "SAMPLE_CHANGER": self.use_sc = True try: self.use_sample_centring = self.getProperty("sample_centring") if self.use_sample_centring: self.centring_phi=sample_centring.CentringMotor(\ self.motor_hwobj_dict['phi'], direction=-1) self.centring_phiz=sample_centring.CentringMotor(\ self.motor_hwobj_dict['phiz']) self.centring_phiy = sample_centring.CentringMotor( self.motor_hwobj_dict['phiy'], direction=-1) self.centring_sampx = sample_centring.CentringMotor( self.motor_hwobj_dict['sampx']) self.centring_sampy=sample_centring.CentringMotor(\ self.motor_hwobj_dict['sampy']) except: pass # used the default value # Other parameters --------------------------------------------------- try: self.zoom_centre = eval(self.getProperty("zoom_centre")) except: if self.image_width is not None and self.image_height is not None: self.zoom_centre = { 'x': self.image_width / 2, 'y': self.image_height / 2 } self.beam_position = [ self.image_width / 2, self.image_height / 2 ] logging.getLogger("HWR").warning("Diffractometer: Zoom center is " +\ "not defined. Continuing with the middle: %s" % self.zoom_centre) else: self.zoom_centre = {'x': 0, 'y': 0} logging.getLogger("HWR").warning("Diffractometer: " + \ "Neither zoom centre nor camera size is defined") self.reversing_rotation = self.getProperty("reversing_rotation") try: # grid_direction describes how a grid is collected # 'fast' is collection direction and 'slow' describes # move to the next collection line self.grid_direction = eval(self.getProperty("grid_direction")) except: self.grid_direction = { "fast": (0, 1), "slow": (1, 0), "omega_ref": 0 } logging.getLogger("HWR").warning("Diffractometer: Grid " + \ "direction is not defined. Using default.") try: self.phase_list = eval(self.getProperty("phase_list")) except: self.phase_list = [ GenericDiffractometer.PHASE_TRANSFER, GenericDiffractometer.PHASE_CENTRING, GenericDiffractometer.PHASE_COLLECTION, GenericDiffractometer.PHASE_BEAM ] #Compatibility #TODO remove this self.getCentringStatus = self.get_centring_status self.getPositions = self.get_positions self.moveMotors = self.move_motors self.isReady = self.is_ready
def init(self): self.centringMethods={MiniDiff.MANUAL3CLICK_MODE: self.start3ClickCentring,\ MiniDiff.C3D_MODE: self.startAutoCentring } self.cancelCentringMethods={} self.currentCentringProcedure = None self.currentCentringMethod = None self.centringStatus={"valid":False} try: phiz_ref = self["centringReferencePosition"].getProperty("phiz") except: phiz_ref = None self.phiMotor = self.getDeviceByRole('phi') self.phizMotor = self.getDeviceByRole('phiz') self.phiyMotor = self.getObjectByRole("phiy") self.zoomMotor = self.getDeviceByRole('zoom') self.lightMotor = self.getDeviceByRole('light') self.focusMotor = self.getDeviceByRole('focus') self.sampleXMotor = self.getDeviceByRole("sampx") self.sampleYMotor = self.getDeviceByRole("sampy") self.camera = self.getDeviceByRole('camera') self.kappaMotor = self.getDeviceByRole('kappa') self.kappaPhiMotor = self.getDeviceByRole('kappa_phi') self.beam_info = self.getObjectByRole('beam_info') # mh 2013-11-05:why is the channel read directly? disabled for the moment # self.camera.addChannel({ 'type': 'tango', 'name': 'jpegImage' }, "JpegImage") self.centringPhi=sample_centring.CentringMotor(self.phiMotor, direction=-1) self.centringPhiz=sample_centring.CentringMotor(self.phizMotor, reference_position=phiz_ref) self.centringPhiy=sample_centring.CentringMotor(self.phiyMotor) self.centringSamplex=sample_centring.CentringMotor(self.sampleXMotor) self.centringSampley=sample_centring.CentringMotor(self.sampleYMotor) hwr = HardwareRepository.HardwareRepository() sc_prop=self.getProperty("samplechanger") if sc_prop is not None: try: self.sampleChanger=hwr.getHardwareObject(sc_prop) except: pass wl_prop=self.getProperty("wagolight") if wl_prop is not None: try: self.lightWago=hwr.getHardwareObject(wl_prop) except: pass aperture_prop = self.getProperty("aperture") if aperture_prop is not None: try: self.aperture = hwr.getHardwareObject(aperture_prop) except: pass if self.phiMotor is not None: self.connect(self.phiMotor, 'stateChanged', self.phiMotorStateChanged) self.connect(self.phiMotor, "positionChanged", self.emitDiffractometerMoved) else: logging.getLogger("HWR").error('MiniDiff: phi motor is not defined in minidiff equipment %s', str(self.name())) if self.phizMotor is not None: self.connect(self.phizMotor, 'stateChanged', self.phizMotorStateChanged) self.connect(self.phizMotor, 'positionChanged', self.phizMotorMoved) self.connect(self.phizMotor, "positionChanged", self.emitDiffractometerMoved) else: logging.getLogger("HWR").error('MiniDiff: phiz motor is not defined in minidiff equipment %s', str(self.name())) if self.phiyMotor is not None: self.connect(self.phiyMotor, 'stateChanged', self.phiyMotorStateChanged) self.connect(self.phiyMotor, 'positionChanged', self.phiyMotorMoved) self.connect(self.phiyMotor, "positionChanged", self.emitDiffractometerMoved) else: logging.getLogger("HWR").error('MiniDiff: phiy motor is not defined in minidiff equipment %s', str(self.name())) if self.zoomMotor is not None: self.connect(self.zoomMotor, 'predefinedPositionChanged', self.zoomMotorPredefinedPositionChanged) self.connect(self.zoomMotor, 'stateChanged', self.zoomMotorStateChanged) else: logging.getLogger("HWR").error('MiniDiff: zoom motor is not defined in minidiff equipment %s', str(self.name())) if self.sampleXMotor is not None: self.connect(self.sampleXMotor, 'stateChanged', self.sampleXMotorStateChanged) self.connect(self.sampleXMotor, 'positionChanged', self.sampleXMotorMoved) self.connect(self.sampleXMotor, "positionChanged", self.emitDiffractometerMoved) else: logging.getLogger("HWR").error('MiniDiff: sampx motor is not defined in minidiff equipment %s', str(self.name())) if self.sampleYMotor is not None: self.connect(self.sampleYMotor, 'stateChanged', self.sampleYMotorStateChanged) self.connect(self.sampleYMotor, 'positionChanged', self.sampleYMotorMoved) self.connect(self.sampleYMotor, "positionChanged", self.emitDiffractometerMoved) else: logging.getLogger("HWR").error('MiniDiff: sampx motor is not defined in minidiff equipment %s', str(self.name())) if self.camera is None: logging.getLogger("HWR").error('MiniDiff: camera is not defined in minidiff equipment %s', str(self.name())) else: self.imgWidth, self.imgHeight = self.camera.getWidth(), self.camera.getHeight() if self.sampleChanger is None: logging.getLogger("HWR").warning('MiniDiff: sample changer is not defined in minidiff equipment %s', str(self.name())) else: try: self.connect(self.sampleChanger, 'sampleIsLoaded', self.sampleChangerSampleIsLoaded) except: logging.getLogger("HWR").exception('MiniDiff: could not connect to sample changer smart magnet') if self.lightWago is not None: self.connect(self.lightWago, 'wagoStateChanged', self.wagoLightStateChanged) else: logging.getLogger("HWR").warning('MiniDiff: wago light is not defined in minidiff equipment %s', str(self.name())) if self.aperture is not None: self.connect(self.aperture, 'predefinedPositionChanged', self.apertureChanged) self.connect(self.aperture, 'positionReached', self.apertureChanged)
def init(self): self.centringMethods={self.MANUAL3CLICK_MODE: self.start3ClickCentring,\ self.C3D_MODE: self.startAutoCentring } self.cancelCentringMethods = {} self.currentCentringProcedure = None self.currentCentringMethod = None self.centringStatus = {"valid": False} try: phiz_ref = self["centringReferencePosition"].getProperty("phiz") except: phiz_ref = None self.phiMotor = self.getDeviceByRole('phi') self.phizMotor = self.getDeviceByRole('phiz') self.phiyMotor = self.getDeviceByRole("phiy") self.zoomMotor = self.getDeviceByRole('zoom') self.lightMotor = self.getDeviceByRole('light') self.focusMotor = self.getDeviceByRole('focus') self.sampleXMotor = self.getDeviceByRole("sampx") self.sampleYMotor = self.getDeviceByRole("sampy") self.camera = self.getDeviceByRole('camera') try: phiDirection = self.phiMotor.getProperty("direction") if phiDirection == None: phiDirection = 1 except: phiDirection = 1 self.centringPhi = sample_centring.CentringMotor( self.phiMotor, direction=phiDirection) self.centringPhiz = sample_centring.CentringMotor( self.phizMotor, reference_position=phiz_ref) self.centringPhiy = sample_centring.CentringMotor(self.phiyMotor, direction=-1) self.centringSamplex = sample_centring.CentringMotor(self.sampleXMotor) self.centringSampley = sample_centring.CentringMotor(self.sampleYMotor) try: self.md2 = PyTango.DeviceProxy( self.tangoname) #'i11-ma-cx1/ex/md2') except: logging.error("MiniDiffPX2 / Cannot connect to tango device: %s ", self.tangoname) else: self.md2_ready = True # some defaults self.anticipation = 1 self.collect_phaseposition = 'DataCollection' sc_prop = self.getProperty("samplechanger") if sc_prop is not None: try: self.sampleChanger = HardwareRepository.HardwareRepository( ).getHardwareObject(sc_prop) except: pass wl_prop = self.getProperty("wagolight") if wl_prop is not None: try: self.lightWago = HardwareRepository.HardwareRepository( ).getHardwareObject(wl_prop) except: pass aperture_prop = self.getProperty("aperture") if aperture_prop is not None: try: self.aperture = HardwareRepository.HardwareRepository( ).getHardwareObject(aperture_prop) except: pass if self.phiMotor is not None: self.connect(self.phiMotor, 'stateChanged', self.phiMotorStateChanged) self.connect(self.phiMotor, "positionChanged", self.emitDiffractometerMoved) else: logging.getLogger("HWR").error( 'MiniDiff: phi motor is not defined in minidiff equipment %s', str(self.name())) if self.phizMotor is not None: self.connect(self.phizMotor, 'stateChanged', self.phizMotorStateChanged) self.connect(self.phizMotor, 'positionChanged', self.phizMotorMoved) self.connect(self.phizMotor, "positionChanged", self.emitDiffractometerMoved) else: logging.getLogger("HWR").error( 'MiniDiff: phiz motor is not defined in minidiff equipment %s', str(self.name())) if self.phiyMotor is not None: self.connect(self.phiyMotor, 'stateChanged', self.phiyMotorStateChanged) self.connect(self.phiyMotor, 'positionChanged', self.phiyMotorMoved) self.connect(self.phiyMotor, "positionChanged", self.emitDiffractometerMoved) else: logging.getLogger("HWR").error( 'MiniDiff: phiy motor is not defined in minidiff equipment %s', str(self.name())) if self.zoomMotor is not None: self.connect(self.zoomMotor, 'predefinedPositionChanged', self.zoomMotorPredefinedPositionChanged) self.connect(self.zoomMotor, 'stateChanged', self.zoomMotorStateChanged) else: logging.getLogger("HWR").error( 'MiniDiff: zoom motor is not defined in minidiff equipment %s', str(self.name())) if self.sampleXMotor is not None: self.connect(self.sampleXMotor, 'stateChanged', self.sampleXMotorStateChanged) self.connect(self.sampleXMotor, 'positionChanged', self.sampleXMotorMoved) self.connect(self.sampleXMotor, "positionChanged", self.emitDiffractometerMoved) else: logging.getLogger("HWR").error( 'MiniDiff: sampx motor is not defined in minidiff equipment %s', str(self.name())) if self.sampleYMotor is not None: self.connect(self.sampleYMotor, 'stateChanged', self.sampleYMotorStateChanged) self.connect(self.sampleYMotor, 'positionChanged', self.sampleYMotorMoved) self.connect(self.sampleYMotor, "positionChanged", self.emitDiffractometerMoved) else: logging.getLogger("HWR").error( 'MiniDiff: sampy motor is not defined in minidiff equipment %s', str(self.name())) if self.camera is None: logging.getLogger("HWR").error( 'MiniDiff: camera is not defined in minidiff equipment %s', str(self.name())) else: self.imgWidth, self.imgHeight = self.camera.getWidth( ), self.camera.getHeight() if self.sampleChanger is None: logging.getLogger("HWR").warning( 'MiniDiff: sample changer is not defined in minidiff equipment %s', str(self.name())) else: try: self.connect(self.sampleChanger, 'sampleIsLoaded', self.sampleChangerSampleIsLoaded) except: logging.getLogger("HWR").exception( 'MiniDiff: could not connect to sample changer smart magnet' ) if self.lightWago is not None: self.connect(self.lightWago, 'wagoStateChanged', self.wagoLightStateChanged) else: logging.getLogger("HWR").warning( 'MiniDiff: wago light is not defined in minidiff equipment %s', str(self.name())) if self.aperture is not None: self.connect(self.aperture, 'predefinedPositionChanged', self.apertureChanged) self.connect(self.aperture, 'positionReached', self.apertureChanged)