本文整理汇总了Python中odemis.model.CancellableThreadPoolExecutor.get_next_future方法的典型用法代码示例。如果您正苦于以下问题:Python CancellableThreadPoolExecutor.get_next_future方法的具体用法?Python CancellableThreadPoolExecutor.get_next_future怎么用?Python CancellableThreadPoolExecutor.get_next_future使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类odemis.model.CancellableThreadPoolExecutor
的用法示例。
在下文中一共展示了CancellableThreadPoolExecutor.get_next_future方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AntiBacklashActuator
# 需要导入模块: from odemis.model import CancellableThreadPoolExecutor [as 别名]
# 或者: from odemis.model.CancellableThreadPoolExecutor import get_next_future [as 别名]
#.........这里部分代码省略.........
sub_shift[a] = v
else:
# optimisation: if move goes in the same direction as backlash
# correction, then no need to do the correction
# TODO: only do this if backlash correction has already been applied once?
if v * self._backlash[a] >= 0:
sub_shift[a] = v
else:
with self._shifted_lock:
if self._shifted[a]:
sub_shift[a] = v
else:
sub_shift[a] = v - self._backlash[a]
self._shifted[a] = True
# Do the backlash + move
axes = set(shift.keys())
if not any(self._shifted):
# a tiny bit faster as we don't sleep
self._child.moveRelSync(sub_shift)
else:
# some antibacklash move needed afterwards => update might be worthy
f = self._child.moveRel(sub_shift)
done = False
while not done:
try:
f.result(timeout=0.01)
except futures.TimeoutError:
pass # Keep waiting for end of move
else:
done = True
# Check if there is already a new move to do
nf = self._executor.get_next_future(future)
if nf is not None and axes <= nf._update_axes:
logging.debug("Ending move control early as next move is an update containing %s", axes)
return
# backlash move
self._antiBacklashMove(shift.keys())
def _doMoveAbs(self, future, pos):
sub_pos = {}
for a, v in pos.items():
if a not in self._backlash:
sub_pos[a] = v
else:
shift = v - self.position.value[a]
with self._shifted_lock:
if shift * self._backlash[a] >= 0:
sub_pos[a] = v
self._shifted[a] = False
else:
sub_pos[a] = v - self._backlash[a]
self._shifted[a] = True
# Do the backlash + move
axes = set(pos.keys())
if not any(self._shifted):
# a tiny bit faster as we don't sleep
self._child.moveAbsSync(sub_pos)
else: # some antibacklash move needed afterwards => update might be worthy
f = self._child.moveAbs(sub_pos)
done = False
while not done:
try: