def run_once(self):
        from optical_image_analyzer import image_analyzer
        from CAServer import casput, casget
        from numpy import rot90

        img = image_analyzer.get_image()
        debug('image received: image counter %r, image dimensions %r' %
              (image_analyzer.imageCounter, img.shape))
        if self.orientation == 'horizontal2' or self.orientation == 'horizontal' or self.orientation == 'on-axis-h':
            img = rot90(img, 3, axes=(1, 2))

        res_dic = self.is_frozen(img)
        debug('res_dic = %r' % res_dic)
        is_frozen_flag = res_dic['flag']
        casput(self.prefix + ".MEAN_TOP", round(res_dic['mean_top'], 2))
        casput(self.prefix + ".MEAN_BOTTOM", round(res_dic['mean_bottom'], 2))
        casput(self.prefix + ".MEAN_MIDDLE", round(res_dic['mean_middle'], 2))
        casput(self.prefix + ".MEAN", round(res_dic['mean_value'], 2))
        casput(self.prefix + ".RBV", round(res_dic['mean_value'], 2))
        casput(self.prefix + ".warning",
               res_dic['mean_value'] >= self.warning_threshold)
        casput(self.prefix + ".STDEV", round(res_dic['stdev'], 2))
        self.intervention_enabled = casget(self.prefix +
                                           '.INTERVENTION_ENABLED')
        casput(self.prefix + ".VAL", is_frozen_flag)
        if is_frozen_flag and temperature.value < self.frozen_threshold_temperature:
            print('freezing detected')
            """Intervention"""
            if self.intervention_enabled:
                self.retract_intervention()
            else:
                print('Intervention was disabled')
 def run(self):
     from time import time,sleep
     from CAServer import casget,casput
     from SAXS_WAXS_control import SAXS_WAXS_control
     from temperature_controller import temperature_controller
     casput(self.CAS_prefix+'.ENABLED', self.intervention_enabled)
     casput(self.CAS_prefix+'.RUNNING', self.deice_enabled)
     try:
         print('current temperature %r' % temperature_controller.value)
         info('current temperature %r' % temperature_controller.value)
     except:
         warn('could not get temperature')
     last_image_file = ""
     while self.deice_enabled:
         try:
             self.intervention_enabled = casget(self.CAS_prefix+'.ENABLED')
         except:
             error('Failed to get CA %r' % (self.CAS_prefix+'.ENABLED'))
             self.intervention_enabled = False
         self.running_timestamp = time()
         if self.current_image_file != last_image_file:
             last_image_file = self.current_image_file
             if self.sample_frozen(self.current_image_file) and not self.aux_deicing and self.intervention_enabled and (temperature_controller.value < -5.0) :
                 self.aux_deicing = True
             elif self.sample_frozen(self.current_image_file) and SAXS_WAXS_control.inserted and self.retract_deicing and (temperature_controller.value < -5.0):
                 SAXS_WAXS_control.retracted = True
                 sleep(self.retracted_time)
                 SAXS_WAXS_control.inserted = True
             else:
                 pass
         else: sleep(0.25)
    def run_once(self):
        from optical_image_analyzer import image_analyzer
        from CAServer import casput, casget
        from freeze_intervention import freeze_intervention
        from numpy import rot90


        if self.bckg_change_flag_down and temperature.value < 1.0:
            #self.set_background()
            debug('circular buffer zeroed')
            self.circular_buffer = []
            self.bckg_change_flag_down = False
            self.bckg_change_flag_up = True

        if self.bckg_change_flag_up and temperature.value > 3.0:
            self.bckg_change_flag_down = True
            self.bckg_change_flag_up = False

        img = image_analyzer.get_image()
        debug('image received: image counter %r, image dimensions %r' %(image_analyzer.imageCounter, img.shape))
        if self.orientation == 'horizontal2' or self.orientation == 'horizontal' or self.orientation == 'on-axis-h':
            img = rot90(img,3,axes=(1,2))


        res_dic = self.is_frozen(img)
        debug('res_dic = %r' %res_dic)
        is_frozen_flag = res_dic['flag']
        casput(self.CAS_prefix+".MEAN_TOP",res_dic['mean_top'])
        casput(self.CAS_prefix+".MEAN_BOTTOM",res_dic['mean_bottom'])
        casput(self.CAS_prefix+".MEAN_MIDDLE",res_dic['mean_middle'])
        casput(self.CAS_prefix+".MEAN",res_dic['mean_value'])
        casput(self.CAS_prefix+".RBV",res_dic['mean_value'])
        casput(self.CAS_prefix+".STDEV",res_dic['stdev'])
        self.intervention_enabled = casget(self.CAS_prefix+'.ENABLED')
        casput(self.CAS_prefix+".VAL",is_frozen_flag)
        if is_frozen_flag and temperature.value < self.frozen_threshold_temperature:
            print('freezing detected')
            """Intervention"""
            if self.intervention_enabled:
                self.retract_intervention()
            else:
                print('Intervention was disabled')
示例#4
0
 def get_queue_halted(self):
     """Is the execution queue in the IOC currently halteded?"""
     from CAServer import casget
     return casget(self.prefix + ".SPMG") <= 1  # 0:Stop,1:Pause,2:Move,3:Go