Exemple #1
0
def tomography_btn_logic(self, instance):
    '''
    Additional Click-logic of the tomography-page is contained here.
    '''

    # lists of different button-logic-elements
    btns_motor = [self.ids['tomo_btn_mot_sel_' + str(m)].uid for m in range(3)]
    btns_pos = [self.ids['tomography_btn_set_pos_start'].uid,self.ids['tomography_btn_set_pos_end'].uid]
    btns_stepTime = [self.ids['tomo_btn_steps'].uid,self.ids['tomo_btn_time'].uid]
    btns_setpos = [self.ids['tomo_btn_set_' + str(m)].uid for m in range(4)]

    # logic-selector-------------------
    # change selected motor
    if instance.uid in btns_motor:
        fg.config['tomo']['motor'] = fg.config['motor']['motor_dict'][btns_motor.index(instance.uid)]

    # set start/end-position for tomo-stack
    elif instance.uid in btns_pos:
        motor_letter = {"DRVX":'x',"DRVY":'y',"DRVZ":'z'}[fg.config['tomo']['motor']]
        if btns_pos.index(instance.uid) == 0: 
            fg.config['tomo']['posSTART'] = fg.config['motor']['calibration_'+ motor_letter +'_pos']
        else: 
            fg.config['tomo']['posEND'] = fg.config['motor']['calibration_'+ motor_letter + '_pos']
        
        # update total distance on change of start and end
        fg.config['tomo']['total_dist'] = fg.config['tomo']['posEND'] - fg.config['tomo']['posSTART']
        
    # select whether time or step-number shall be changed
    elif instance.uid in btns_stepTime:
        #if self.ids['tomo_toggleGroup_stepTime'].current_active == 0:
        fg.config['tomo']['steptime_active'] = btns_stepTime.index(instance.uid)

    # change value of step-number or time per step
    elif instance.uid in btns_setpos:
        if fg.config['tomo']['steptime_active'] == 0:
            # update step value
            update_val = int(instance.value)
            fg.config['tomo']['steps'] += update_val 
            
            # update distance per step
            fg.config['tomo']['stepsize'] = int(fg.config['tomo']['total_dist'] / fg.config['tomo']['steps'])
        else: 
            update_val = int(instance.value)/10
            fg.config['tomo']['steptime'] = round(fg.config['tomo']['steptime'] + update_val,1)
        
    # (de-)activate TOMO-measurement (as individual option to each measurement)
    elif instance.uid == self.ids['btn_imaging_technique_tomography'].uid:
        fg.config['experiment']['tomo_active'] = False if instance.fl_active else True
        logger.debug('Tomo_mode active? {}.'.format(fg.config['experiment']['tomo_active']))
        toolbox.change_activation_status(instance)
    
    # update labels
    tomography_update_labels(self)
Exemple #2
0
def autofocus_callback(self, instance, key, *rargs):
    '''
        Tests whether autofocus is already running or anything else is blocking. If not: blocks all measurements (and further autofocus-calls) and resets autofocus-count if scheduled.
        To block running autofocus, click "AF now" as implemented in Toolbox.run_autofocus-function.
    '''
    # skip if AF already running
    if fg.config['experiment']['autofocus_busy']:
        pass
    else:
        # wait 1s before checking again
        while fg.config['experiment']['imaging_active']:
            Clock.schedule_once(
                partial(toolbox.run_autofocus, self, instance, key), 1)
        logger.debug('Autofocus started.')
        fg.config['experiment']['autofocus_busy'] = True
        autofocus_routine(self)
        fg.config['experiment']['autofocus_busy'] = False
        logger.debug('Autofocus finished.')
        if instance.uid == self.ids['btn_autofocus_now'].uid:
            autofocus_afterclean(self=self,
                                 instance=instance,
                                 camdict='cam_af')
            toolbox.change_activation_status(instance)
Exemple #3
0
 def btn_function_preview(self, instance):
     if not instance.fl_active:
         print(instance.fl_active)
     toolbox.camera_preview_change_status(self, instance)
     toolbox.change_activation_status(instance)
Exemple #4
0
 def autofocus(self, instance):
     toolbox.change_activation_status(instance)
     toolbox.autofocus(self, instance)