Category Hierarchy

我正在尝试弄清楚如何获得一个远程库的实例,而不仅仅是一个Remote对象的实例。

在我的示例中,我有一个在RobotRemoteServer上运行的名为BoardIO的远程库(实际上在另一块板上是远程的)。

from robotremoteserver import RobotRemoteServer

class BoardIO(object):

    def __init__(self):
        self.base = getBase()

    def write(self, value):
        self.base.write(value)

    def read(self):
        return self.base.read()

if __name__ == '__main__':
    RobotRemoteServer(BoardIO(), host=sys.argv[1], port=sys.argv[2])

在我的本地机器上,我有另一个库,它将部分使用远程BoardIO库的功能。使用BuiltIn().get_library_instance,我现在想访问我的远程库的实例。例如,BoardIO.write函数可以有一个包装函数,如下所示:

def write_wrapper(self, value):
        board = BuiltIn().get_library_instance('mylib')
        board.write(value)

如果在robot文件中导入远程函数,如下所示

*** Settings ***
Library             Remote  http://${IP}:${PORT}    WITH NAME   mylib

然后,BuiltIn().get_library_instance('mylib')返回一个Remote对象的实例,而不是BoardIO的实例。

我想要做的事情是

*** Settings ***
Library             Remote  http://${IP}:${PORT}
Library             BoardIO

这样我才能做BuiltIn().get_library_instance('BoardIO')。但这并不起作用,因为找不到库BoardIO。

也许有人遇到了类似的问题,可以帮助我解决这个问题?

转载请注明出处:http://www.shandongyidao.com/article/20230526/2358879.html