當前位置: 首頁>>代碼示例>>Python>>正文


Python CancellableThreadPoolExecutor.get_next_future方法代碼示例

本文整理匯總了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:
開發者ID:pieleric,項目名稱:odemis-old,代碼行數:70,代碼來源:actuator.py


注:本文中的odemis.model.CancellableThreadPoolExecutor.get_next_future方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。