示例#1
0
    def test_move(self):
        """
        Note: with C-867 open-looped (SMOController), speed is very imprecise,  
        so test failure might not indicate software bug.
        """
        ctrl = pigcs.Controller(self.accesser, *self.config_ctrl)
        speed = max(ctrl.min_speed, ctrl.max_speed / 10)
        self.assertGreater(ctrl.max_speed, 100e-6, "Maximum speed is expected to be more than 100μm/s")
        ctrl.setSpeed(1, speed)
        distance = -ctrl.moveRel(1, -speed / 2) # should take 0.5s
        self.assertGreater(distance, 0)
        self.assertTrue(ctrl.isMoving(set([1])))
        self.assertEqual(ctrl.GetErrorNum(), 0)
        status = ctrl.GetStatus()
        ts = time.time()
        while ctrl.isMoving(set([1])):
            time.sleep(0.01)
        dur = time.time() - ts
        logging.debug("Took %f s to stop", dur)
        # Closed loop can take a long time to stop (actually, up to 10s in the worse cases)
        self.assertLess(dur, 1.5)

        # now the same thing but with a stop
        distance = -ctrl.moveRel(1, -speed) # should take one second
        time.sleep(0.01) # wait a bit that it's surely running
        self.assertGreater(distance, 0)
        ctrl.stopMotion()

        ts = time.time()
        while ctrl.isMoving(set([1])):
            time.sleep(0.01)
        dur = time.time() - ts
        logging.debug("Took %f s to stop", dur)
        # Closed loop can take a long time to stop (actually, up to 10s in the worse cases)
        self.assertLess(dur, 0.2)
示例#2
0
    def test_timeout(self):
        ctrl = pigcs.Controller(self.accesser, *self.config_ctrl)

        self.assertIn("Physik Instrumente", ctrl.GetIdentification())
        self.assertTrue(ctrl.IsReady())
        ctrl._sendOrderCommand("\x24")  # known to fail
        # the next command is going to have to use recovery from timeout
        self.assertTrue(ctrl.IsReady())
        self.assertEqual(0, ctrl.GetErrorNum())
示例#3
0
    def test_timeout(self):
        ctrl = pigcs.Controller(self.accesser, *self.config_ctrl)

        self.assertIn("Physik Instrumente", ctrl.GetIdentification())
        self.assertTrue(ctrl.IsReady())
        with self.assertRaises(pigcs.PIGCSError):
            ctrl._sendOrderCommand("\x24") # known to fail
            # the next command is going to fail, and report the error from the previous command
            ctrl.IsReady()
        self.assertTrue(ctrl.IsReady()) # all should be fine again
        self.assertEqual(0, ctrl.GetErrorNum())