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


Python SingleConnectionInstrumentDriver.apply_startup_params方法代码示例

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


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

示例1: TestUnitInstrumentDriver

# 需要导入模块: from mi.core.instrument.instrument_driver import SingleConnectionInstrumentDriver [as 别名]
# 或者: from mi.core.instrument.instrument_driver.SingleConnectionInstrumentDriver import apply_startup_params [as 别名]

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

        # Ensure that we default to test mode off
        self.assertFalse(self.driver._test_mode)

        exception = False
        try:
            self.driver.set_test_mode(False)
            self.driver.test_force_state(state=1)

        except(TestModeException):
            exception = True

        except(Exception):
            # ignore other exceptions
            pass


        self.assertTrue(exception)

        # Now set test mode and try to run again.
        exception = False
        try:
            self.driver.set_test_mode(True)
            self.assertTrue(self.driver._test_mode)
            self.driver.test_force_state(state=1)
        except(TestModeException):
            exception = True

        except(Exception):
            # ignore other exceptions
            pass

        self.assertFalse(exception)

    def test_direct_access_params(self):
        """
        Tests to see how direct access parameters are setup and that they are
        working properly.
        """        
        self.assertTrue(self.driver._protocol._param_dict.get("foo"), 10)
        self.assertTrue(self.driver._protocol._param_dict.get("bar"), 15)
        # use real driver sets here, the direct poke of the param dict is just
        # a test-with-base-class thing
        self.driver._protocol._param_dict.update("bar=20")
        self.assertTrue(self.driver._protocol._param_dict.get("bar"), 20)
        
        # pretend to go into direct access mode,
        running_config = self.driver._protocol.get_cached_config()
        #   make some changes to both, (foo to 100, bar to 200)
        self.driver._protocol._param_dict.update("foo=100")
        self.driver._protocol._param_dict.update("bar=200")        
        # its like we came out of DA mode
        self.driver.restore_direct_access_params(running_config)

        # confirm that the default values were set back appropriately.
        self.assertTrue(self.driver._protocol._param_dict.get("foo"), 10)
        self.assertTrue(self.driver._protocol._param_dict.get("bar"), 200)
        
    def test_get_cached_config(self):
        """
        Verifies that the driver kicks out a cached config. Not connected, but
        thats what it is headed...
        """
        running_config = self.driver.get_cached_config()
        self.assertEquals(running_config["foo"], 10)
        self.assertEquals(running_config["bar"], 15)        
        
    def test_startup_params(self):
        """
        Tests to see that startup parameters are properly set when the
        startup logic goes through.
        """
        self.assertTrue(self.driver._protocol._param_dict.get("foo"), 10)
        self.assertTrue(self.driver._protocol._param_dict.get("bar"), 15)
        # make sure some value isnt the default value
        self.driver._protocol._param_dict.update("bar=20")
        self.assertTrue(self.driver._protocol._param_dict.get("bar"), 20)
        self.driver._protocol._param_dict.update("baz=30")
        self.assertTrue(self.driver._protocol._param_dict.get("baz"), 30)
        
        # pretend to manually adjust a few things:
        self.driver._protocol._param_dict.update("foo=1000")
        self.assertTrue(self.driver._protocol._param_dict.get("foo"), 1000)
        self.driver._protocol._param_dict.update("bar=1500")
        self.assertTrue(self.driver._protocol._param_dict.get("bar"), 1500)
        self.driver._protocol._param_dict.update("baz=2000")
        self.assertTrue(self.driver._protocol._param_dict.get("baz"), 2000)
        
        # pretend to go through the motions of a startup sequence
        self.driver.set_init_params({'foo':100, "bar": 150, "baz": 200})
        self.driver.apply_startup_params()

        # check the values on the other end
        running_config = self.driver._protocol.get_cached_config()
        
        # confirm that the default values were set back appropriately.
        self.assertTrue(self.driver._protocol._param_dict.get("foo"), 100)
        self.assertTrue(self.driver._protocol._param_dict.get("bar"), 150)
        self.assertTrue(self.driver._protocol._param_dict.get("baz"), 2000)
        self.assertTrue(self.driver._protocol._param_dict.get("bat"), 40)
开发者ID:ccenter,项目名称:marine-integrations,代码行数:104,代码来源:test_instrument_driver.py


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