Ejemplo n.º 1
0
    def execute(self, prev_state_name, inputs):
        global last_focus
        ns=DomeOpenState.execute(self, prev_state_name, inputs)
        if ns != '': return ns
            

        try:
            cmd = GXN.Commands()
            
            positions = numpy.arange(14.0, 14.8, 0.1)
            filenames = []
            
            rc_camera.object = "Focus Loop"        
            cmd.gofocus(13)
            rc_camera.shutter = "normal"
            for position in positions:
                cmd.gofocus(position)
                try:
                    expose(15)
                except:
                    return "restart_detector_software"
                filenames.append(rc_camera.filename)
            
            log.info("FN: %s" % str(filenames))
            fpos, fposs, metrics = Focus.rc_focus_check(filenames)
            
            log.info("In the range of: %s" % positions)
            log.info("Metrics: %s" % metrics)
            log.info("Best focus is %f" % fpos)
            last_focus = [datetime.now(), fpos]
            cmd.gofocus(fpos)
            cmd.close()
        except:
            cmd.close()
            return "focus_failed"
        
        return "exposure_handler"