コード例 #1
0
    def test_loading_procedures(self):
        """
        Test moving the sample stage from loading position to both imaging and coating, then back to loading
        """
        stage = self.stage
        focus = self.focus
        # Get the stage to loading position
        f = cryoLoadSample(LOADING)
        f.result()
        test.assert_pos_almost_equal(stage.position.value, self.stage_deactive,
                                     atol=ATOL_LINEAR_POS)
        # Focus should be parked
        test.assert_pos_almost_equal(focus.position.value, self.focus_deactive, atol=ATOL_LINEAR_POS)

        # Get the stage to imaging position
        f = cryoLoadSample(IMAGING)
        f.result()
        test.assert_pos_almost_equal(stage.position.value, self.stage_active, atol=ATOL_LINEAR_POS)

        # Get the stage to coating position
        f = cryoLoadSample(COATING)
        f.result()
        filter_dict = lambda keys, d: {key: d[key] for key in keys}
        test.assert_pos_almost_equal(filter_dict({'x', 'y', 'z'}, stage.position.value),
                                     filter_dict({'x', 'y', 'z'}, self.stage_coating), atol=ATOL_LINEAR_POS)
        test.assert_pos_almost_equal(filter_dict({'rx', 'rz'}, stage.position.value),
                                     filter_dict({'rx', 'rz'}, self.stage_coating), atol=ATOL_LINEAR_POS)

        # Switch back to loading position
        f = cryoLoadSample(LOADING)
        f.result()
        test.assert_pos_almost_equal(stage.position.value, self.stage_deactive, atol=ATOL_LINEAR_POS)
コード例 #2
0
    def test_tilting_procedures(self):
        """
        Test moving the sample stage from imaging position to tilting position and back to imaging
        """
        stage = self.stage
        # Test tilting from imaging
        # Get the stage to imaging position
        f = cryoLoadSample(LOADING)
        f.result()
        f = cryoLoadSample(IMAGING)
        f.result()

        # Tilt the stage on rx only
        f = cryoTiltSample(rx=self.rx_angle)
        f.result()
        test.assert_pos_almost_equal(stage.position.value, {'rx': self.rx_angle, 'rz': 0},
                                     match_all=False,
                                     atol=ATOL_ROTATION_POS)

        # Tilt the stage on rx and rz
        f = cryoTiltSample(rx=self.rx_angle, rz=self.rz_angle)
        f.result()
        test.assert_pos_almost_equal(stage.position.value, {'rx': self.rx_angle, 'rz': self.rz_angle},
                                     match_all=False,
                                     atol=ATOL_ROTATION_POS)

        # Test imaging from tilting
        f = cryoTiltSample(rx=0, rz=0)
        f.result()
        test.assert_pos_almost_equal(stage.position.value, self.stage_active, atol=ATOL_LINEAR_POS)
コード例 #3
0
 def test_cancel_tilting(self):
     """
     Test cryoTiltSample movement cancellation is handled correctly
     """
     stage = self.stage
     f = cryoLoadSample(LOADING)
     f.result()
     f = cryoLoadSample(IMAGING)
     f.result()
     f = cryoTiltSample(rx=self.rx_angle, rz=self.rz_angle)
     time.sleep(2)
     cancelled = f.cancel()
     self.assertTrue(cancelled)
     test.assert_pos_not_almost_equal(stage.position.value, {'rx': self.rx_angle, 'rz': self.rz_angle},
                                      match_all=False,
                                      atol=ATOL_ROTATION_POS)
コード例 #4
0
 def test_invalid_switch_movements(self):
     """
     Test it's not possible to do some disallowed switch movements
     """
     # Test tilting from loading
     f = cryoLoadSample(LOADING)
     f.result()
     with self.assertRaises(ValueError):
         f = cryoTiltSample(rx=self.rx_angle, rz=self.rz_angle)
         f.result()
コード例 #5
0
    def test_cancel_loading(self):
        """
        Test cryoLoadSample movement cancellation is handled correctly
        """
        stage = self.stage
        f = cryoLoadSample(LOADING)
        f.result()
        f = cryoLoadSample(IMAGING)
        time.sleep(2)
        cancelled = f.cancel()
        self.assertTrue(cancelled)
        test.assert_pos_not_almost_equal(stage.position.value, self.stage_deactive,
                                         atol=ATOL_LINEAR_POS)

        stage = self.stage
        f = cryoLoadSample(LOADING)
        f.result()
        f = cryoLoadSample(COATING)
        time.sleep(2)
        cancelled = f.cancel()
        self.assertTrue(cancelled)
        test.assert_pos_not_almost_equal(stage.position.value, self.stage_coating,
                                         atol=ATOL_LINEAR_POS)
コード例 #6
0
    def test_get_current_position(self):
        """
        Test getCurrentPositionLabel function behaves as expected
        """
        stage = self.stage
        # Move to loading position
        f = cryoLoadSample(LOADING)
        f.result()
        pos_label = getCurrentPositionLabel(stage.position.value, stage)
        self.assertEqual(pos_label, LOADING)

        # Move to imaging position and cancel the movement before reaching there
        f = cryoLoadSample(IMAGING)
        time.sleep(2)
        f.cancel()
        pos_label = getCurrentPositionLabel(stage.position.value, stage)
        self.assertEqual(pos_label, LOADING_PATH)

        # Move to imaging position
        f = cryoLoadSample(LOADING)
        f.result()
        f = cryoLoadSample(IMAGING)
        f.result()
        pos_label = getCurrentPositionLabel(stage.position.value, stage)
        self.assertEqual(pos_label, IMAGING)

        # Move to tilting
        f = cryoTiltSample(rx=self.rx_angle, rz=self.rz_angle)
        f.result()
        pos_label = getCurrentPositionLabel(stage.position.value, stage)
        self.assertEqual(pos_label, TILTED)

        # Move to coating position
        f = cryoLoadSample(COATING)
        f.result()
        pos_label = getCurrentPositionLabel(stage.position.value, stage)
        self.assertEqual(pos_label, COATING)

        # Return to loading and cancel before reaching
        f = cryoLoadSample(LOADING)
        time.sleep(4)
        f.cancel()
        pos_label = getCurrentPositionLabel(stage.position.value, stage)
        self.assertEqual(pos_label, LOADING_PATH)