当前位置: 首页>>代码示例>>Python>>正文


Python ProtocolParameterDict.get_all方法代码示例

本文整理汇总了Python中mi.core.instrument.protocol_param_dict.ProtocolParameterDict.get_all方法的典型用法代码示例。如果您正苦于以下问题:Python ProtocolParameterDict.get_all方法的具体用法?Python ProtocolParameterDict.get_all怎么用?Python ProtocolParameterDict.get_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mi.core.instrument.protocol_param_dict.ProtocolParameterDict的用法示例。


在下文中一共展示了ProtocolParameterDict.get_all方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Protocol

# 需要导入模块: from mi.core.instrument.protocol_param_dict import ProtocolParameterDict [as 别名]
# 或者: from mi.core.instrument.protocol_param_dict.ProtocolParameterDict import get_all [as 别名]

#.........这里部分代码省略.........

        self._linebuf[connection] = ''
        self._promptbuf[connection] = ''
        self._do_cmd_direct(command, connection=connection)
        return self._get_response(response_regex=regex, connection=connection)

    def _update_params(self, *args, **kwargs):
        """
        Update the parameter dictionary.
        """
        # see if we passed in a list of parameters to query
        # if not, use the whole parameter list
        parameters = kwargs.get('params')
        if parameters is None or WorkhorseParameter.ALL in parameters:
            parameters = self._param_dict.get_keys()
        # filter out the engineering parameters and ALL
        parameters = [p for p in parameters if not WorkhorseEngineeringParameter.has(p) and p != WorkhorseParameter.ALL]

        # Get old param dict config.
        old_config = self._param_dict.get_config()

        if parameters:
            # MASTER
            master_params = [p for p in parameters if '_5th' not in p]
            if master_params:
                resp = self._get_params(master_params, SlaveProtocol.FOURBEAM)
                self._param_dict.update_many(resp)

            # SLAVE
            slave_params = [p.replace('_5th', '') for p in parameters if '_5th' in p]
            if slave_params:
                resp = self._get_params(slave_params, SlaveProtocol.FIFTHBEAM)
                self._param_dict2.update_many(resp)
                for key, value in self._param_dict2.get_all().iteritems():
                    self._param_dict.set_value(key, value)

        new_config = self._param_dict.get_config()

        # Check if there is any changes. Ignore TT
        if not dict_equal(new_config, old_config, ['TT']) or kwargs.get('force'):
            self._driver_event(DriverAsyncEvent.CONFIG_CHANGE)

    def _execute_set_params(self, commands, connection):
        if commands:
            # we are going to send the concatenation of all our set commands
            self._linebuf[connection] = ''
            self._do_cmd_direct(''.join(commands), connection=connection)
            # we'll need to build a regular expression to retrieve all of the responses
            # including any possible errors
            if len(commands) == 1:
                regex = re.compile(r'(%s.*?)\r\n>' % commands[-1].strip(), re.DOTALL)
            else:
                regex = re.compile(r'(%s.*?%s.*?)\r\n>' % (commands[0].strip(), commands[-1].strip()), re.DOTALL)
            response = self._get_response(response_regex=regex, connection=connection)
            self._parse_set_response(response[0], None)

    def _set_params(self, *args, **kwargs):
        """
        Issue commands to the instrument to set various parameters
        """
        self._verify_not_readonly(*args, **kwargs)
        params = args[0]
        changed = []

        old_config = self._param_dict.get_config()
开发者ID:r-swilderd,项目名称:mi-instrument,代码行数:69,代码来源:driver.py


注:本文中的mi.core.instrument.protocol_param_dict.ProtocolParameterDict.get_all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。