Example #1
0
    def _set_position(self, pos, wait=None):
        """
        Move to an absolute position, taking into account backlash.

        When self.backlash is to a negative value the stage will always move
         from low to high values. If necessary, a extra step with length
         self.backlash is set.

        :param pos: New position in mm
        :param wait: wait until stage is finished
        """

        # First do move to extra position if necessary
        if self.backlash:
            position = self.position.magnitude
            # backlash = self.backlash.to('mm').magnitude
            backlash = convert_to('mm', on_dimensionless='ignore')(
                self.backlash).magnitude
            if (backlash < 0 and position > pos) or \
                    (backlash > 0 and position < pos):
                self.log_info('Using backlash')
                self.__set_position(pos + backlash)
                self._wait_until_done()

        # Than move to final position
        self.__set_position(pos)
        if wait:
            self._wait_until_done()
            self.check_position(pos)
Example #2
0
    def test_return_float(self):
        self.assertEqual(
            processors.convert_to(V, return_float=True)(1 * mv), 0.001)

        self.assertRaises(
            ValueError,
            processors.convert_to(V,
                                  return_float=True,
                                  on_incompatible='raise'), Hz)
        self.assertWarns(
            processors.DimensionalityWarning,
            processors.convert_to(V, return_float=True,
                                  on_incompatible='warn'), Hz)
        self.assertEqual(
            processors.convert_to(V,
                                  return_float=True,
                                  on_incompatible='ignore')(Hz), 1)

        self.assertRaises(
            ValueError,
            processors.convert_to(V,
                                  return_float=True,
                                  on_dimensionless='raise'), 1000)
        self.assertWarns(
            processors.DimensionalityWarning,
            processors.convert_to(V,
                                  return_float=True,
                                  on_dimensionless='warn'), 1000)
        self.assertEqual(
            processors.convert_to(V,
                                  return_float=True,
                                  on_dimensionless='ignore')(1000), 1000)
Example #3
0
 def _wait_until_done(self):
     wait_time = convert_to('seconds', on_dimensionless='ignore')(self.wait_time)
     time.sleep(wait_time)
     while not self.motion_done:
         time.sleep(wait_time)
     return True