Beispiel #1
0
    def _get_cycle_time(self, params):
        #
        # enter main menu
        #
        self._fsm.on_event(BarsProtocolEvent.ENTER_MAIN_MENU)
        self._assert_state(BarsProtocolState.MAIN_MENU)

        #
        # enter change param menu
        #
        self._fsm.on_event(BarsProtocolEvent.ENTER_CHANGE_PARAMS, params)
        self._assert_state(BarsProtocolState.CHANGE_PARAMS_MENU)

        #
        # save the menu to retrieve info below
        #
        menu = self._promptbuf

        #
        # exit change param menu
        #
        self._fsm.on_event(BarsProtocolEvent.EXIT_CHANGE_PARAMS)
        self._assert_state(BarsProtocolState.MAIN_MENU)

        #
        # return to COLLECTING_DATA
        #
        self._fsm.on_event(BarsProtocolEvent.RESTART_DATA_COLLECTION)
        self._assert_state(BarsProtocolState.COLLECTING_DATA)

        #
        # scan menu for requested value
        #
        seconds = None
        mo = re.search(CYCLE_TIME_PATTERN, menu)
        if mo is not None:
            cycle_time_str = mo.group(1)
            log.debug("scanned cycle_time_str='%s'" % str(cycle_time_str))
            seconds = bars.get_cycle_time_seconds(cycle_time_str)

        if seconds is None:
            raise InstrumentProtocolException(
                    msg="Unexpected: string could not be matched: %s" % menu)

        return seconds
Beispiel #2
0
    def get(self, params, *args, **kwargs):

        # TODO it only handles [(BarsChannel.INSTRUMENT,
        # BarsParameter.TIME_BETWEEN_BURSTS)]

        if log.isEnabledFor(logging.DEBUG):
            log.debug("params=%s args=%s kwargs=%s" %
                      (str(params), str(args), str(kwargs)))

        self._assert_state(DriverState.AUTOSAMPLE)

        assert isinstance(params, list)
        cp = (BarsChannel.INSTRUMENT, BarsParameter.TIME_BETWEEN_BURSTS)
        assert params == [cp]

        log.debug("breaking data streaming to enter main menu")
        self.bars_client.enter_main_menu()

        log.debug("select 2 to get system parameter menu")
        self.bars_client.send('2')
        self.bars_client.expect_generic_prompt()

        buffer = self.bars_client.get_last_buffer()
        log.debug("BUFFER='%s'" % repr(buffer))
        string = bars.get_cycle_time(buffer)
        log.debug("VALUE='%s'" % string)
        seconds = bars.get_cycle_time_seconds(string)
        if seconds is None:
            raise InstrumentProtocolException(
                    msg="Unexpected: string could not be matched: %s" % string)

        log.debug("send 3 to return to main menu")
        self.bars_client.send('3')
        self.bars_client.expect_generic_prompt()

        buffer = self.bars_client.get_last_buffer()
        log.debug("BUFFER='%s'" % repr(buffer))

        log.debug("resume data streaming")
        self.bars_client.send('1')

        result = {cp: seconds}
        return result
Beispiel #3
0
    def get(self, params, *args, **kwargs):

        # TODO only handles (INSTRUMENT, TIME_BETWEEN_BURSTS) for the moment

        if log.isEnabledFor(logging.DEBUG):
            log.debug("params=%s args=%s kwargs=%s" %
                      (str(params), str(args), str(kwargs)))

        assert isinstance(params, list)
        assert len(params) == 1

        channel, param = cp = params[0]

        assert channel == BarsChannel.INSTRUMENT
        assert param == BarsParameter.TIME_BETWEEN_BURSTS

        #
        # enter main menu
        #
        self._fsm.on_event(BarsProtocolEvent.ENTER_MAIN_MENU)
        self._assert_state(BarsProtocolState.MAIN_MENU)

        #
        # enter change param menu
        #
        self._fsm.on_event(BarsProtocolEvent.ENTER_CHANGE_PARAMS, params)
        self._assert_state(BarsProtocolState.CHANGE_PARAMS_MENU)

        #
        # save the menu to retrieve info below
        #
        menu = self._promptbuf

        #
        # exit change param menu
        #
        self._fsm.on_event(BarsProtocolEvent.EXIT_CHANGE_PARAMS)
        self._assert_state(BarsProtocolState.MAIN_MENU)

        #
        # return to COLLECTING_DATA
        #
        self._fsm.on_event(BarsProtocolEvent.RESTART_DATA_COLLECTION)
        self._assert_state(BarsProtocolState.COLLECTING_DATA)

        #
        # scan menu for requested value
        #
        seconds = None
        mo = re.search(CYCLE_TIME_PATTERN, menu)
        if mo is not None:
            cycle_time_str = mo.group(1)
            log.debug("scanned cycle_time_str='%s'" % str(cycle_time_str))
            seconds = bars.get_cycle_time_seconds(cycle_time_str)

        if seconds is None:
            raise InstrumentProtocolException(
                    msg="Unexpected: string could not be matched: %s" % string)

        result = {cp: seconds}
        return result