예제 #1
0
파일: npmc.py 프로젝트: effting/odemis
    def _doMoveRel(self, future, pos):
        """
        Blocking and cancellable relative move
        future (Future): the future it handles
        _pos (dict str -> float): axis name -> relative target position
        raise:
            ValueError: if the target position is
            TMCLError: if the controller reported an error
            CancelledError: if cancelled before the end of the move
        """
        with future._moving_lock:
            end = 0  # expected end
            moving_axes = set()
            for an, v in pos.items():
                aid = self._axis_map[an]
                moving_axes.add(aid)
                self.MoveRelPos(aid, v * self._axis_conv_factor[aid])
                # compute expected end
                # convert to mm units
                dur = driver.estimateMoveDuration(
                    abs(v) * self._axis_conv_factor[aid], self._speed[an],
                    self._accel[an])

                end = max(time.time() + dur, end)

            self._waitEndMove(future, moving_axes, end)
        self.checkError()
        logging.debug("move successfully completed")
예제 #2
0
파일: npmc.py 프로젝트: effting/odemis
    def _doMoveAbs(self, future, pos):
        """
        Blocking and cancellable absolute move
        future (Future): the future it handles
        _pos (dict str -> float): axis name -> absolute target position
        raise:
            TMCLError: if the controller reported an error
            CancelledError: if cancelled before the end of the move
        """
        with future._moving_lock:
            end = 0  # expected end
            old_pos = self._applyInversion(self.position.value)
            moving_axes = set()
            for an, v in pos.items():
                aid = self._axis_map[an]
                moving_axes.add(aid)
                self.MoveAbsPos(aid, v * self._axis_conv_factor[aid])
                d = abs(v - old_pos[an])
                # convert displacement unit to mm
                dur = driver.estimateMoveDuration(
                    d * self._axis_conv_factor[aid], self._speed[an],
                    self._accel[an])
                end = max(time.time() + dur, end)

            self._waitEndMove(future, moving_axes, end)
        self.checkError()
        logging.debug("move successfully completed")
예제 #3
0
파일: npmc.py 프로젝트: pieleric/odemis
    def _doMoveAbs(self, future, pos):
        """
        Blocking and cancellable absolute move
        future (Future): the future it handles
        _pos (dict str -> float): axis name -> absolute target position
        raise:
            TMCLError: if the controller reported an error
            CancelledError: if cancelled before the end of the move
        """
        with future._moving_lock:
            end = 0  # expected end
            old_pos = self._applyInversion(self.position.value)
            moving_axes = set()
            for an, v in pos.items():
                aid = self._axis_map[an]
                moving_axes.add(aid)
                self.MoveAbsPos(aid, v * self._axis_conv_factor[aid])
                d = abs(v - old_pos[an])
                # convert displacement unit to mm
                dur = driver.estimateMoveDuration(d * self._axis_conv_factor[aid],
                                                  self._speed[an],
                                                  self._accel[an])
                end = max(time.time() + dur, end)

            self._waitEndMove(future, moving_axes, end)
        self.checkError()
        logging.debug("move successfully completed")
예제 #4
0
파일: npmc.py 프로젝트: pieleric/odemis
    def _doMoveRel(self, future, pos):
        """
        Blocking and cancellable relative move
        future (Future): the future it handles
        _pos (dict str -> float): axis name -> relative target position
        raise:
            ValueError: if the target position is
            TMCLError: if the controller reported an error
            CancelledError: if cancelled before the end of the move
        """
        with future._moving_lock:
            end = 0  # expected end
            moving_axes = set()
            for an, v in pos.items():
                aid = self._axis_map[an]
                moving_axes.add(aid)
                self.MoveRelPos(aid, v * self._axis_conv_factor[aid])
                # compute expected end
                # convert to mm units
                dur = driver.estimateMoveDuration(abs(v) * self._axis_conv_factor[aid],
                                self._speed[an],
                                self._accel[an])
                    
                end = max(time.time() + dur, end)

            self._waitEndMove(future, moving_axes, end)
        self.checkError()
        logging.debug("move successfully completed")
예제 #5
0
파일: zstack.py 프로젝트: effting/odemis
    def _estimate_step_duration(self):
        """
        return (float > 0): estimated time (in s) that it takes to move the focus
          by one step.
        """
        speed = None
        if model.hasVA(self.focus, "speed"):
            speed = self.focus.speed.value.get('z', None)
        if speed is None:
            speed = 10e-6  # m/s, pessimistic

        return driver.estimateMoveDuration(abs(self.zstep.value), speed, 0.01)
예제 #6
0
파일: zstack.py 프로젝트: pieleric/odemis
    def initAcquisition(self):
        """
        Called before acquisition begins.
        Returns: (float) estimate of time per step
        """
        logging.info("Z stack acquisition started with %d levels", self.numberofAcquisitions.value)

        # Move the focus to the start z position
        logging.debug("Preparing Z Stack acquisition. Moving focus to start position")
        self.old_pos = self.focus.position.value
        self.focus.moveAbs({'z': self.zstart.value}).result()
        speed = self.focus.speed.value['z']
        return driver.estimateMoveDuration(abs(self.zstep.value), speed, 0.01)
예제 #7
0
    def initAcquisition(self):
        """
        Called before acquisition begins.
        Returns: (float) estimate of time per step
        """
        logging.info("Z stack acquisition started with %d levels",
                     self.numberofAcquisitions.value)

        # Move the focus to the start z position
        logging.debug(
            "Preparing Z Stack acquisition. Moving focus to start position")
        self.old_pos = self.focus.position.value
        self.focus.moveAbs({'z': self.zstart.value}).result()
        speed = self.focus.speed.value['z']
        return driver.estimateMoveDuration(abs(self.zstep.value), speed, 0.01)
예제 #8
0
파일: zstack.py 프로젝트: pieleric/odemis
    def _update_exp_dur(self, _=None):
        """
        Called when VA that affects the expected duration is changed
        """
        nsteps = self.numberofAcquisitions.value
        speed = self.focus.speed.value['z']
        step_time = driver.estimateMoveDuration(abs(self.zstep.value), speed, 0.01)
        ss = self._get_acq_streams()

        sacqt = acq.estimateTime(ss)
        logging.debug("Estimating %g s acquisition for %d streams", sacqt, len(ss))

        dur = sacqt * nsteps + step_time * (nsteps - 1)
        # Use _set_value as it's read only
        self.expectedDuration._set_value(math.ceil(dur), force_write=True)
예제 #9
0
파일: npmc.py 프로젝트: pieleric/odemis
 def _doMove(self, axis, new_pos):
     # Check that the position is within the range.
     if new_pos >= self._range[0] and new_pos <= self._range[1]:
         self._target_pos[axis] = new_pos
         self._start_pos = copy.copy(self._pos)
         d = self._target_pos[axis] - self._start_pos[axis]
         dur = driver.estimateMoveDuration(abs(d), self._speed[axis], self._accel[axis])
         self._current_move_start = time.time()
         self._current_move_finish = time.time() + dur
     else:
         if new_pos > self._range[1]:
             self._addError(axis * 100 + 4)  # Error - detected positive limit
             self._pos[axis] = self._range[1]
         elif new_pos < self._range[0]:
             self._addError(axis * 100 + 5)  # error - detected negative limit
             self._pos[axis] = self._range[0]
예제 #10
0
    def _update_exp_dur(self, _=None):
        """
        Called when VA that affects the expected duration is changed
        """
        nsteps = self.numberofAcquisitions.value
        speed = self.focus.speed.value['z']
        step_time = driver.estimateMoveDuration(abs(self.zstep.value), speed,
                                                0.01)
        ss = self._get_acq_streams()

        sacqt = acq.estimateTime(ss)
        logging.debug("Estimating %g s acquisition for %d streams", sacqt,
                      len(ss))

        dur = sacqt * nsteps + step_time * (nsteps - 1)
        # Use _set_value as it's read only
        self.expectedDuration._set_value(math.ceil(dur), force_write=True)
예제 #11
0
 def _doMove(self, axis, new_pos):
     # Check that the position is within the range.
     if self._range[0] <= new_pos <= self._range[1]:
         self._target_pos[axis] = new_pos
         self._start_pos = copy.copy(self._pos)
         d = self._target_pos[axis] - self._start_pos[axis]
         dur = driver.estimateMoveDuration(abs(d), self._speed[axis],
                                           self._accel[axis])
         self._current_move_start = time.time()
         self._current_move_finish = time.time() + dur
     else:
         if new_pos > self._range[1]:
             self._addError(axis * 100 +
                            4)  # Error - detected positive limit
             self._pos[axis] = self._range[1]
         elif new_pos < self._range[0]:
             self._addError(axis * 100 +
                            5)  # error - detected negative limit
             self._pos[axis] = self._range[0]