Пример #1
0
    def perform_run(self,
                    events,
                    record=True,
                    comment='',
                    post=True,
                    **kwargs):
        """
        Perform a single run of the experiment

        Parameters
        ----------
        events: int
            Number of events to include in run

        record: bool, optional
            Whether to record the run

        comment : str, optional
            Comment for ELog

        post: bool, optional
            Whether to post to the experimental ELog or not

        kwargs:
            Used to control the laser shutters. See ``configure_shutters`` for more
            information

        Note
        ----
        This does not configure the laser parameters. Either use ``loop`` or
        ``configure_evr`` and ``configure_sequencer`` to set these parameters
        """
        # Configure the shutters
        self.configure_shutters(**kwargs)
        # time.sleep(3) / a leftover from original script
        # Post information to elog
        if not daq.configured:  # Won't have runnumber without configuration
            daq.configure()
        runnum = daq.__control.runnumber()
        comment = comment or ''
        info = (runnum, events, record, comment, self.delay)
        info.extend(self.shutter_status)
        post_msg = post_template.format(info)
        print(post)
        if post:
            elog.post(post_msg, runnum=runnum)
        # Start recording
        logger.info("Starting DAQ run, -> record=%s", record)
        daq.begin(events=events, record=record)
        time.sleep(2)  # Wait for the DAQ to get spinnign before sending events
        logger.debug("Starting EventSequencer ...")
        sequencer.start()
        # Wait for the DAQ to finish
        logger.info("Waiting or DAQ to complete %s events ...", events)
        daq.wait()
        logger.info("Run complete!")
        daq.end_run()
        logger.debug("Stopping Sequencer ...")
        sequencer.stop()
Пример #2
0
    def perform_run(self, events, record=True, comment='', post=True,
                    **kwargs):
        """
        Perform a single run of the experiment

        Parameters
        ----------
        events: int
            Number of events to include in run

        record: bool, optional
            Whether to record the run

        comment : str, optional
            Comment for ELog

        post: bool, optional
            Whether to post to the experimental ELog or not. Will not post if
            not recording

        kwargs:
            Used to control the laser shutters. See ``configure_shutters`` for more
            information

        Note
        ----
        This does not configure the laser parameters. Either use ``loop`` or
        ``configure_evr`` and ``configure_sequencer`` to set these parameters
        """
        # Configure the shutters
        self.configure_shutters(**kwargs)
        # time.sleep(3) / a leftover from original script
        # Create descriptive message
        comment = comment or ''
        # Start recording
        logger.info("Starting DAQ run, -> record=%s", record)
        daq.begin(events=events, record=record)
        time.sleep(2)  # Wait for the DAQ to get spinnign before sending events
        logger.debug("Starting EventSequencer ...")
        sequencer.start()
        time.sleep(1)
        # Post to ELog if desired
        runnum = daq._control.runnumber()
        info = [runnum, comment, events, self.current_rate, self._delaystr]
        info.extend(self.shutter_status)
        post_msg = post_template.format(*info)
        print(post_msg)
        if post and record:
            elog.post(post_msg, run=runnum)
        # Wait for the DAQ to finish
        logger.info("Waiting or DAQ to complete %s events ...", events)
        daq.wait()
        logger.info("Run complete!")
        daq.end_run()
        logger.debug("Stopping Sequencer ...")
        sequencer.stop()
        # allow short time after sequencer stops
        time.sleep(0.5) 
Пример #3
0
    def perform_run(self, events, record=True, comment='', post=True):
        """
        Perform a single run of the experiment

        Parameters
        ----------
        events: int
            Number of events to include in run

        record: bool, optional
            Whether to record the run

        comment : str, optional
            Comment for ELog

        post: bool, optional
            Whether to post to the experimental ELog or not. Will not post if
            not recording
        """
        # Create descriptive message
        comment = comment or ''
        # Start recording
        logger.info("Starting DAQ run, -> record=%s", record)
        daq.begin(events=events, record=record)
        # Post to ELog if desired
        runnum = daq._control.runnumber()
        info = [runnum, comment, events, self.current_rate]
        post_msg = post_template.format(*info)
        print(post_msg)
        if post and record:
            elog.post(post_msg, run=runnum)
        # Wait for the DAQ to finish
        logger.info("Waiting or DAQ to complete %s events ...", events)
        daq.wait()
        logger.info("Run complete!")
        daq.end_run()
        logger.debug("Stopping Sequencer ...")
Пример #4
0
    def perform_run(self,
                    events,
                    record=True,
                    comment='',
                    post=True,
                    **kwargs):
        """
        Perform a single run of the experiment

        Parameters
        ----------
        events: int
            Number of events to include in run

        record: bool, optional
            Whether to record the run

        comment : str, optional
            Comment for ELog

        post: bool, optional
            Whether to post to the experimental ELog or not. Will not post if
            not recording

        """
        # time.sleep(3) / a leftover from original script
        # Create descriptive message
        comment = comment or ''
        # Start recording
        try:
            logger.info("Starting DAQ run, -> record=%s", record)
            daq.begin(events=events, record=record)
            time.sleep(
                2)  # Wait for the DAQ to get spinnign before sending events
            logger.debug("Starting EventSequencer ...")
            sequencer.start()
            time.sleep(1)
            # Post to ELog if desired
            runnum = daq._control.runnumber()
            info = [runnum, comment, events, self.current_rate]
            post_msg = post_template.format(*info)
            print(post_msg)
            if post and record:
                elog.post(post_msg, run=runnum)
            # Wait for the DAQ to finish
            logger.info("Waiting or DAQ to complete %s events ...", events)
            daq.wait()
            logger.info("Run complete!")
            daq.end_run()
            logger.debug("Stopping Sequencer ...")
            sequencer.stop()
            # allow short time after sequencer stops
            time.sleep(0.5)
        except KeyboardInterrupt:
            logger.warning("Scan interrupted by user request!")
            logger.info("Stopping DAQ ...")
            daq.stop()
        # Return the DAQ to the original state
        finally:
            logger.info("Disconnecting from DAQ ...")
            daq.disconnect()
            logger.info("Closing all laser shutters ...")
            self.configure_shutters(pulse1=False,
                                    pulse2=False,
                                    pulse3=False,
                                    opo=False)
            logger.info("Restarting the EventSequencer ...")
            sequencer.start()