本文整理汇总了Python中ddapp.timercallback.TimerCallback.singleShot方法的典型用法代码示例。如果您正苦于以下问题:Python TimerCallback.singleShot方法的具体用法?Python TimerCallback.singleShot怎么用?Python TimerCallback.singleShot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ddapp.timercallback.TimerCallback
的用法示例。
在下文中一共展示了TimerCallback.singleShot方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: startApplication
# 需要导入模块: from ddapp.timercallback import TimerCallback [as 别名]
# 或者: from ddapp.timercallback.TimerCallback import singleShot [as 别名]
def startApplication(enableQuitTimer=False):
appInstance = QtGui.QApplication.instance()
if enableQuitTimer:
quitTimer = TimerCallback()
quitTimer.callback = appInstance.quit
quitTimer.singleShot(0.1)
appInstance.exec_()
示例2: startQuitTimer
# 需要导入模块: from ddapp.timercallback import TimerCallback [as 别名]
# 或者: from ddapp.timercallback.TimerCallback import singleShot [as 别名]
def startQuitTimer(timeoutInSeconds):
quitTimer = TimerCallback()
quitTimer.callback = ConsoleApp.quit
quitTimer.singleShot(timeoutInSeconds)
示例3: AffordanceObjectModelManager
# 需要导入模块: from ddapp.timercallback import TimerCallback [as 别名]
# 或者: from ddapp.timercallback.TimerCallback import singleShot [as 别名]
class AffordanceObjectModelManager(object):
def __init__(self, view):
self.collection = lcmobjectcollection.LCMObjectCollection(channel='AFFORDANCE_COLLECTION_COMMAND')
self.collection.connectDescriptionUpdated(self._onDescriptionUpdated)
self.collection.connectDescriptionRemoved(self._onDescriptionRemoved)
self.view = view
self.notifyFrequency = 30 # throttle lcm messages per second sent for affordance updates
self._ignoreChanges = False
self._pendingUpdates = set()
self.timer = TimerCallback()
self.timer.callback = self._notifyPendingUpdates
def getAffordances(self):
return [obj for obj in om.getObjects() if isinstance(obj, affordanceitems.AffordanceItem)]
def getCollisionAffordances(self):
affs = []
for aff in self.getAffordances():
if aff.getProperty('Collision Enabled'):
affs.append(aff)
return affs
def getAffordanceId(self, aff):
return aff.getProperty('uuid')
def newAffordanceFromDescription(self, desc):
if 'uuid' not in desc:
desc['uuid'] = newUUID()
self.collection.updateDescription(desc)
return self.getAffordanceById(desc['uuid'])
def getAffordanceById(self, affordanceId):
for aff in self.getAffordances():
if self.getAffordanceId(aff) == affordanceId:
return aff
def getAffordanceDescription(self, aff):
return aff.getDescription()
def registerAffordance(self, aff, notify=True):
aff.connectRemovedFromObjectModel(self._onAffordanceRemovedFromObjectModel)
aff.properties.connectPropertyChanged(self._onAffordancePropertyChanged)
aff.getChildFrame().connectFrameModified(self._onAffordanceFrameChanged)
if notify:
self.notifyAffordanceUpdate(aff)
def removeAffordance(self, aff):
self.collection.removeDescription(aff.getProperty('uuid'), notify=False)
def notifyAffordanceUpdate(self, aff):
if not isinstance(aff, affordanceitems.AffordanceItem):
return
shouldNotify = not self._pendingUpdates and not self.timer.singleShotTimer.isActive()
self._pendingUpdates.add(aff)
if shouldNotify:
self._notifyPendingUpdates()
def _notifyPendingUpdates(self):
if self._pendingUpdates:
self.timer.singleShot(1.0/self.notifyFrequency)
for aff in self._pendingUpdates:
try:
self.collection.updateDescription(self.getAffordanceDescription(aff), notify=False)
except:
print traceback.format_exc()
self._pendingUpdates.clear()
def _onAffordancePropertyChanged(self, propertySet, propertyName):
if self._ignoreChanges:
return
self.notifyAffordanceUpdate(self.getAffordanceById(propertySet.getProperty('uuid')))
def _onAffordanceFrameChanged(self, frameObj):
if self._ignoreChanges:
return
aff = frameObj.parent()
self.notifyAffordanceUpdate(aff)
def _onAffordanceRemovedFromObjectModel(self, objectModel, aff):
if self._ignoreChanges:
return
self.removeAffordance(aff)
def _loadAffordanceFromDescription(self, desc):
className = desc['classname']
cls = getattr(affordanceitems, className)
aff = cls(desc['Name'], self.view)
om.addToObjectModel(aff, parentObj=om.getOrCreateContainer('affordances'))
vis.addChildFrame(aff)
aff.loadDescription(desc, copyMode=aff.COPY_MODE_ALL)
self.registerAffordance(aff, notify=False)
#.........这里部分代码省略.........