本文整理汇总了Python中papywizard.plugins.abstractHardwarePlugin.AbstractHardwarePlugin.establishConnection方法的典型用法代码示例。如果您正苦于以下问题:Python AbstractHardwarePlugin.establishConnection方法的具体用法?Python AbstractHardwarePlugin.establishConnection怎么用?Python AbstractHardwarePlugin.establishConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类papywizard.plugins.abstractHardwarePlugin.AbstractHardwarePlugin
的用法示例。
在下文中一共展示了AbstractHardwarePlugin.establishConnection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: establishConnection
# 需要导入模块: from papywizard.plugins.abstractHardwarePlugin import AbstractHardwarePlugin [as 别名]
# 或者: from papywizard.plugins.abstractHardwarePlugin.AbstractHardwarePlugin import establishConnection [as 别名]
def establishConnection(self): # Move to hardware?
""" Establish the connection.
The SIN-11 device used to control the Pixorb axis needs to be
initialised before any command can be sent to the axis controllers.
"""
AbstractHardwarePlugin.establishConnection(self)
Logger().trace("AbstractPixOrbHardware.establishConnection()")
if not AbstractPixOrbHardware.__initSIN11:
try:
answer = ""
self._driver.empty()
# Ask the SIN-11 to scan online controllers
self._driver.write('&') # Add '\n' if ethernet driver?
self._driver.setTimeout(SIN11_INIT_TIMEOUT) # Sin-11 takes several seconds to answer
c = ''
while c != '\r':
c = self._driver.read(1)
if c in ('#', '?'):
self._driver.read(2) # Read last CRLF
Logger().debug("AbstractPixOrbHardware.establishConnection(): SIN-11 '&' answer=%s" % answer)
raise HardwareError("Can't init SIN-11")
else:
answer += c
answer = answer.strip() # Remove final CRLF
Logger().debug("AbstractPixOrbHardware.establishConnection(): SIN-11 '&' answer=%s" % answer)
AbstractPixOrbHardware.__initSIN11 = True
self._driver.setTimeout(ConfigManager().getFloat('Plugins/HARDWARE_COM_TIMEOUT'))
except:
self._connected = False
raise