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


Python CommandResponseInstrumentProtocol.get_startup_config方法代码示例

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


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

示例1: TestUnitInstrumentProtocol

# 需要导入模块: from mi.core.instrument.instrument_protocol import CommandResponseInstrumentProtocol [as 别名]
# 或者: from mi.core.instrument.instrument_protocol.CommandResponseInstrumentProtocol import get_startup_config [as 别名]

#.........这里部分代码省略.........
        self.protocol._param_dict.add("bar", r'bar=(.*)',
                             lambda match : int(match.group(1)),
                             lambda x : str(x),
                             direct_access=False,
                             startup_param=True,
                             default_value=0)
        self.protocol._param_dict.add("baz", r'baz=(.*)',
                             lambda match : int(match.group(1)),
                             lambda x : str(x),
                             direct_access=True,
                             default_value=20)
        self.protocol._param_dict.add("bat", r'bat=(.*)',
                             lambda match : int(match.group(1)),
                             lambda x : str(x),
                             startup_param=False,
                             default_value=20)
        self.protocol._param_dict.add("qux", r'qux=(.*)',
                             lambda match : int(match.group(1)),
                             lambda x : str(x),
                             startup_param=True)
        self.protocol._param_dict.add("rok", r'rok=(.*)',
                             lambda match : int(match.group(1)),
                             lambda x : str(x))

        # set an additional value for test
        self.protocol._param_dict.update("qux=6666")
        
        # mark init params
        self.assertRaises(InstrumentParameterException,
                          self.protocol.set_init_params, [])
        self.protocol.set_init_params({DriverConfigKey.PARAMETERS: {"foo": 1111, "baz":2222}})
        
        # get new startup config
        self.assertRaises(InstrumentProtocolException, self.protocol.get_startup_config)
        self.protocol.set_init_params({DriverConfigKey.PARAMETERS: {"foo": 1111, "baz":2222, "bat": 11, "qux": 22}})
        result = self.protocol.get_startup_config()
        
        self.assertEquals(len(result), 5)
        self.assertEquals(result["foo"], 1111) # init param
        self.assertEquals(result["bar"], 0)    # init param with default value
        self.assertEquals(result["baz"], 2222) # non-init param, but value specified
        self.assertEquals(result["bat"], 11)   # set param
        self.assertEquals(result["qux"], 22)   # set param
        self.assertIsNone(result.get("rok"))   # defined in paramdict, no config

    def test_apply_startup_params(self):
        """
        Test that the apply startup parameters method exists and throws
        a "not implemented" exception for the base class
        """
        self.assertRaises(NotImplementedException,
                          self.protocol.apply_startup_params)

    def test_scheduler(self):
        """
        Test to see that the scheduler can add and remove jobs properly
        Jobs are just queued for adding unit we call initialize_scheduler
        then the jobs are actually created.
        use an interval job to allow for testing for removal
        """
        job_name = 'test_job'
        startup_config = {
            DriverConfigKey.SCHEDULER: {
                job_name: {
                    DriverSchedulerConfigKey.TRIGGER: {
                        DriverSchedulerConfigKey.TRIGGER_TYPE: TriggerType.INTERVAL,
开发者ID:aplmmilcic,项目名称:mi-instrument,代码行数:70,代码来源:test_instrument_protocol.py

示例2: TestUnitInstrumentProtocol

# 需要导入模块: from mi.core.instrument.instrument_protocol import CommandResponseInstrumentProtocol [as 别名]
# 或者: from mi.core.instrument.instrument_protocol.CommandResponseInstrumentProtocol import get_startup_config [as 别名]

#.........这里部分代码省略.........
                             startup_param=True,
                             default_value=10)
        self.protocol._param_dict.add("bar", r'bar=(.*)',
                             lambda match : int(match.group(1)),
                             lambda x : str(x),
                             direct_access=False,
                             startup_param=True,
                             default_value=0)
        self.protocol._param_dict.add("baz", r'baz=(.*)',
                             lambda match : int(match.group(1)),
                             lambda x : str(x),
                             direct_access=True,
                             default_value=20)
        self.protocol._param_dict.add("bat", r'bat=(.*)',
                             lambda match : int(match.group(1)),
                             lambda x : str(x),
                             startup_param=False,
                             default_value=20)
        self.protocol._param_dict.add("qux", r'qux=(.*)',
                             lambda match : int(match.group(1)),
                             lambda x : str(x),
                             startup_param=True)
        self.protocol._param_dict.add("rok", r'rok=(.*)',
                             lambda match : int(match.group(1)),
                             lambda x : str(x))
        self.protocol._param_dict.update("qux=6666")
        
        # mark init params
        self.assertRaises(InstrumentParameterException,
                          self.protocol.set_init_params, [])
        self.protocol.set_init_params({DriverConfigKey.PARAMETERS: {"foo": 1111, "baz":2222}})
        
        # get new startup config
        self.assertRaises(InstrumentProtocolException, self.protocol.get_startup_config)
        self.protocol.set_init_params({DriverConfigKey.PARAMETERS: {"foo": 1111, "baz":2222, "bat": 11, "qux": 22}})
        result = self.protocol.get_startup_config()
        
        self.assertEquals(len(result), 5)
        self.assertEquals(result["foo"], 1111) # init param
        self.assertEquals(result["bar"], 0)    # init param with default value
        self.assertEquals(result["baz"], 2222) # non-init param, but value specified
        self.assertEquals(result["bat"], 11)   # set param
        self.assertEquals(result["qux"], 22)   # set param
        self.assertIsNone(result.get("rok"))   # defined in paramdict, no config

    def test_apply_startup_params(self):
        """
        Test that the apply startup parameters method exists and throws
        a "not implemented" exception for the base class
        """
        self.assertRaises(NotImplementedException,
                          self.protocol.apply_startup_params)

    def test_scheduler(self):
        """
        Test to see that the scheduler can add and remove jobs properly
        Jobs are just queued for adding unit we call initialize_scheduler
        then the jobs are actually created.
        """
        dt = datetime.datetime.now() + datetime.timedelta(0,1)
        job_name = 'test_job'
        startup_config = {
            DriverConfigKey.SCHEDULER: {
                job_name: {
                    DriverSchedulerConfigKey.TRIGGER: {
                        DriverSchedulerConfigKey.TRIGGER_TYPE: TriggerType.ABSOLUTE,
开发者ID:lukecampbell,项目名称:marine-integrations,代码行数:70,代码来源:test_instrument_protocol.py


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