Esempio n. 1
0
    def _send_command_with_retry(self,
                                 command,
                                 value=None,
                                 sleep_time=1,
                                 max_retries=MAX_RETRIES):
        """
        Attempt to send a command up to max_retries times.  Protocol state will move to ERROR if we fail to
        receive a response after max_retries attempts.
        @throws InstrumentTimeoutException
        """
        for attempt in xrange(1, max_retries + 1):
            try:
                if value is None:
                    result = self._do_cmd_resp(command,
                                               response_regex=TURBO_RESPONSE,
                                               timeout=TIMEOUT)
                else:
                    result = self._do_cmd_resp(command,
                                               value,
                                               response_regex=TURBO_RESPONSE,
                                               timeout=TIMEOUT)
                return result
            except exceptions.InstrumentTimeoutException:
                log.error('Error sending command: %s, attempt %d', command,
                          attempt)
                time.sleep(sleep_time)

        # set the error reason
        self._param_dict.set_value(Parameter.ERROR_REASON,
                                   'Unable to command the turbo')
        self._driver_event(DriverAsyncEvent.CONFIG_CHANGE)

        self._async_raise_fsm_event(ProtocolEvent.ERROR)
        raise exceptions.InstrumentTimeoutException(
            'Failed to command the turbo: %s' % command)
Esempio n. 2
0
 def _handler_scan_enter(self, *args, **kwargs):
     """
     Enter the scan state.  Configure the RGA, start the first scan and the scheduler.
     @throws InstrumentTimeoutException
     """
     for attempt in range(1, MAX_RETRIES+1):
         try:
             self._handler_scan_configure_rga()
             self._async_raise_fsm_event(ProtocolEvent.TAKE_SCAN)
             self._build_scheduler()
             self._driver_event(DriverAsyncEvent.STATE_CHANGE)
             return
         except exceptions.InstrumentTimeoutException:
             log.error('Failed to configure the RGA - attempt %d', attempt)
     self._async_raise_fsm_event(ProtocolEvent.ERROR)
     error = 'Failed to configure RGA and start scanning.'
     self._param_dict.set_value(Parameter.ERROR_REASON, error)
     self._driver_event(DriverAsyncEvent.CONFIG_CHANGE)
     raise exceptions.InstrumentTimeoutException(error)