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


Python Device.add_functions方法代码示例

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


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

示例1: callModule

# 需要导入模块: from device import Device [as 别名]
# 或者: from device.Device import add_functions [as 别名]
 def callModule(self, modulename, board_number, number, function, params = []):
     """
     Call one function: function for module: modulename in board: board_name
     with handler: number (only if the module is pnp, else, the parameter is
     None) with parameteres: params
     """
     try:
         board = self._bb[board_number]
         if board.devices.has_key(number) and (board.devices[number].name == modulename):
             return board.devices[number].call_function(function, params)
         else:
             if modulename in self._openables:
                 if modulename in board.get_openables_loaded():
                     number = board.get_device_handler(modulename)
                 else:
                     board.add_openable_loaded(modulename)
                     dev = Device(board, modulename)
                     number = dev.module_open()
                     dev.add_functions(self._drivers_loaded[modulename])
                     board.add_device(number, dev)
                 return board.devices[number].call_function(function, params)
             else:
                 if self._debug:
                     print 'no open and no openable'
                 return ERROR
     except Exception, err:
         if self._debug:
             print 'error call module', err
         return ERROR
开发者ID:nfurquez,项目名称:LabRobEmb2013,代码行数:31,代码来源:usb4butia.py

示例2: get_modules_list

# 需要导入模块: from device import Device [as 别名]
# 或者: from device.Device import add_functions [as 别名]
    def get_modules_list(self, normal=True):
        """
        Get the list of modules loaded in the board
        """
        self._modules = []
        n_boards = self.get_butia_count()

        if self._debug:
            print '=Listing Devices'

        for i, b in enumerate(self._bb):
            try:
                listi = b.get_listi()
                s = b.get_handler_size()

                if self._debug:
                    print '===board', i

                for m in range(0, s + 1):
                    module_name = listi[b.get_handler_type(m)]
                    if n_boards > 1:
                        complete_name = module_name + '@' + str(i) + ':' +  str(m)
                    else:
                        complete_name = module_name + ':' +  str(m)

                    if self._debug:
                        print '=====module', module_name, (8 - len(module_name)) * ' ', complete_name

                    if not(module_name == 'port'):

                        if normal:
                            self._modules.append(complete_name)
                        else:
                            self._modules.append((str(m), module_name, str(i)))

                        if not(b.devices.has_key(m) and (b.devices[m].name == module_name)):
                            d = Device(b, module_name, m)
                            d.add_functions(self._drivers_loaded[module_name])
                            b.add_device(m, d)

                            if module_name in self._openables:
                                b.add_openable_loaded(module_name)
                    else:
                        if b.devices.has_key(m):
                            b.devices.pop(m)

            except Exception, err:
                if self._debug:
                    print 'error module list', err
开发者ID:nfurquez,项目名称:LabRobEmb2013,代码行数:51,代码来源:usb4butia.py


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