コード例 #1
0
 def test_move_left(self, motor : Motor) :
     position_before = 0
     velocity_before = 0.0
     motor.move_left(False)
     while True :
         self.assertTrue(motor.moving)
         position = motor.position
         acceleration = motor.acceleration
         velocity = motor.velocity
         self.assertLessEqual(position, position_before)
         self.assertLessEqual(velocity, velocity_before)
         self.assertLess(velocity, 0.0)
         position_before = position
         velocity_before = velocity
         if -velocity == motor.velocity_moving :
             break
         self.assertEqual(acceleration, -motor.acceleration_moving)
     self.assertTrue(motor.moving)
     self.assertEqual(motor.velocity, -motor.velocity_moving)
     motor.stop(False)
     # Expects no overshoot.
     while True :
         acceleration = motor.acceleration
         velocity = motor.velocity
         position = motor.position
         moving = motor.moving
         if moving :
             self.assertLess(velocity, 0.0)
             self.assertEqual(acceleration, motor.acceleration_moving)
         self.assertGreaterEqual(velocity, velocity_before)
         self.assertLessEqual(position, position_before)
         velocity_before = velocity
         position_before = position
         if not moving :
             break
     self.__test_stopped(motor)
コード例 #2
0
 def test_stop_left(self, motor : Motor) :
     motor.move_left(False)
     while motor.velocity > -motor.velocity_moving :
         pass
     motor.stop()
     self.__test_stopped(motor)