• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python instrument_driver.SingleConnectionInstrumentDriver类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: __init__

 def __init__(self, evt_callback):
     """
     Driver constructor.
     @param evt_callback Driver process event callback.
     """
     #Construct superclass.
     SingleConnectionInstrumentDriver.__init__(self, evt_callback)
开发者ID:r-swilderd,项目名称:mi-instrument,代码行数:7,代码来源:driver.py


示例2: __init__

 def __init__(self, evt_callback, refdes=None):
     """
     Driver constructor.
     @param evt_callback Driver process event callback.
     """
     #Construct superclass.
     SingleConnectionInstrumentDriver.__init__(self, evt_callback, refdes)
     self._slave_protocols = {}
开发者ID:cwingard,项目名称:mi-instrument,代码行数:8,代码来源:driver.py


示例3: __init__

    def __init__(self, evt_callback):
        """
        InstrumentDriver constructor.
        @param evt_callback Driver process event callback.
        """
        SingleConnectionInstrumentDriver.__init__(self, evt_callback)

        # multiple portAgentClient
        self._connection = {}
开发者ID:r-swilderd,项目名称:mi-instrument,代码行数:9,代码来源:driver.py


示例4: __init__

 def __init__(self, evt_callback):
     """
     Driver constructor.
     @param evt_callback Driver process event callback.
     """
     #Construct superclass.
     SingleConnectionInstrumentDriver.__init__(self, evt_callback)
     self._connection_fsm.add_handler(DriverConnectionState.CONNECTED,
         DriverEvent.DISCOVER,
         self._handler_connected_discover)
开发者ID:lukecampbell,项目名称:marine-integrations,代码行数:10,代码来源:driver.py


示例5: __init__

 def __init__(self, evt_callback):
     """
     Driver constructor.
     @param evt_callback Driver process event callback.
     """
     #Construct superclass.
     SingleConnectionInstrumentDriver.__init__(self, evt_callback)
     # replace the driver's discover handler with one that applies the startup values after discovery
     self._connection_fsm.add_handler(DriverConnectionState.CONNECTED, 
                                      DriverEvent.DISCOVER, 
                                      self._handler_connected_discover)
开发者ID:ateranishi,项目名称:marine-integrations,代码行数:11,代码来源:driver.py


示例6: _handler_connected_discover

 def _handler_connected_discover(self, event, *args, **kwargs):
     # Redefine discover handler so that we can apply startup params
     # when we discover. Gotta get into command mode first though.
     log.debug("in _handler_connected_discover")
     result = SingleConnectionInstrumentDriver._handler_connected_protocol_event(self, event, *args, **kwargs)
     self.apply_startup_params()
     return result
开发者ID:lukecampbell,项目名称:marine-integrations,代码行数:7,代码来源:driver.py


示例7: TestUnitInstrumentDriver

class TestUnitInstrumentDriver(IonUnitTestCase):
    """
    Test cases for instrument driver class. Functions in this class provide
    instrument driver unit tests and provide a tutorial on use of
    the driver interface.
    """ 
    def setUp(self):
        self.mock = DotDict()
        self.mock.port_agent = Mock(name='port_agent_client')
        self.mock.callback = Mock(name='callback')

        self.driver = SingleConnectionInstrumentDriver(self.mock.callback)

    def test_test_mode(self):
        """
        Test driver test mode.
        Ensure driver test mode attribute is set properly and verify
        exceptions are thrown when not in test mode.
        """

        # 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)
开发者ID:swarbhanu,项目名称:marine-integrations,代码行数:52,代码来源:test_instrument_driver.py


示例8: setUp

    def setUp(self):
        self.mock = DotDict()
        self.mock.port_agent = Mock(name='port_agent_client')
        self.mock.callback = Mock(name='callback')

        def mock_set(values, startup=True):
            assert isinstance(values, dict)
            return_string = ""
            for key in values.keys():
                return_string += "%s=%s" % (key, values[key]) # inefficient, I know
            return return_string
        
        self.driver = SingleConnectionInstrumentDriver(self.mock.callback)

        # set some values
        self.driver._protocol = InstrumentProtocol(self.mock.callback)
        self.driver.set_resource = mock_set

        self.driver._protocol._param_dict.add("foo", r'foo=(.*)',
                             lambda match : int(match.group(1)),
                             lambda x : str(x),
                             direct_access=True,
                             startup_param=True,
                             default_value=10)
        self.driver._protocol._param_dict.set_default("foo")
        self.driver._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=15)
        self.driver._protocol._param_dict.set_default("bar")
        self.driver._protocol._param_dict.add("baz", r'baz=(.*)',
                             lambda match : int(match.group(1)),
                             lambda x : str(x),
                             direct_access=True,
                             default_value=30)
        self.driver._protocol._param_dict.set_default("baz")
        self.driver._protocol._param_dict.add("bat", r'bat=(.*)',
                             lambda match : int(match.group(1)),
                             lambda x : str(x),
                             startup_param=False,
                             default_value=40)
        self.driver._protocol._param_dict.set_default("bat")
        
        self.driver._protocol._cmd_dict.add("cmd1")
        self.driver._protocol._cmd_dict.add("cmd2")

        self.driver._protocol._driver_dict.add(DriverDictKey.VENDOR_SW_COMPATIBLE,
                                               True)
开发者ID:JeffRoy,项目名称:marine-integrations,代码行数:50,代码来源:test_instrument_driver.py


示例9: TestUnitInstrumentDriver

class TestUnitInstrumentDriver(MiUnitTestCase):
    """
    Test cases for instrument driver class. Functions in this class provide
    instrument driver unit tests and provide a tutorial on use of
    the driver interface.
    """ 
    def setUp(self):
        self.mock = DotDict()
        self.mock.port_agent = Mock(name='port_agent_client')
        self.mock.callback = Mock(name='callback')

        def mock_set(values):
            assert isinstance(values, dict)
            return_string = ""
            for key in values.keys():
                return_string += "%s=%s" % (key, values[key]) # inefficient, I know
            return return_string
        
        self.driver = SingleConnectionInstrumentDriver(self.mock.callback)

        # set some values
        self.driver._protocol = InstrumentProtocol(self.mock.callback)
        self.driver.set_resource = mock_set

        self.driver._protocol._param_dict.add("foo", r'foo=(.*)',
                             lambda match : int(match.group(1)),
                             lambda x : str(x),
                             direct_access=True,
                             startup_param=True,
                             default_value=10)
        self.driver._protocol._param_dict.set_default("foo")
        self.driver._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=15)
        self.driver._protocol._param_dict.set_default("bar")
        self.driver._protocol._param_dict.add("baz", r'baz=(.*)',
                             lambda match : int(match.group(1)),
                             lambda x : str(x),
                             direct_access=True,
                             default_value=30)
        self.driver._protocol._param_dict.set_default("baz")
        self.driver._protocol._param_dict.add("bat", r'bat=(.*)',
                             lambda match : int(match.group(1)),
                             lambda x : str(x),
                             startup_param=False,
                             default_value=40)
        self.driver._protocol._param_dict.set_default("bat")

                
    def test_test_mode(self):
        """
        Test driver test mode.
        Ensure driver test mode attribute is set properly and verify
        exceptions are thrown when not in test mode.
        """

        # 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
#.........这里部分代码省略.........
开发者ID:lytlej,项目名称:marine-integrations,代码行数:101,代码来源:test_instrument_driver.py


示例10: __init__

 def __init__(self, evt_callback):
     """Instrument-specific enums
     @param evt_callback The callback function to use for events
     """
     SingleConnectionInstrumentDriver.__init__(self, evt_callback)
开发者ID:newbrough,项目名称:marine-integrations,代码行数:5,代码来源:driver.py


示例11: __init__

 def __init__(self, evt_callback):
     SingleConnectionInstrumentDriver.__init__(self, evt_callback)
开发者ID:r-swilderd,项目名称:mi-instrument,代码行数:2,代码来源:driver.py


示例12: _handler_connected_discover

 def _handler_connected_discover(self, event, *args, **kwargs):
     # Redefine discover handler so that we can apply startup params after we discover. 
     # For this instrument the driver puts the instrument into command mode during discover.
     result = SingleConnectionInstrumentDriver._handler_connected_protocol_event(self, event, *args, **kwargs)
     self.apply_startup_params()
     return result
开发者ID:ateranishi,项目名称:marine-integrations,代码行数:6,代码来源:driver.py


示例13: setUp

    def setUp(self):
        self.mock = DotDict()
        self.mock.port_agent = Mock(name='port_agent_client')
        self.mock.callback = Mock(name='callback')

        self.driver = SingleConnectionInstrumentDriver(self.mock.callback)
开发者ID:swarbhanu,项目名称:marine-integrations,代码行数:6,代码来源:test_instrument_driver.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python instrument_fsm.InstrumentFSM类代码示例发布时间:2022-05-27
下一篇:
Python utils._函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap