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)
def test_tilting_procedures(self): """ Test moving the sample stage from imaging position to tilting position and back to imaging """ stage = self.stage align = self.aligner # Test tilting from imaging # Get the stage to imaging position cryoSwitchSamplePosition(LOADING).result() cryoSwitchSamplePosition(IMAGING).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}, 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) # align should be in deactive position test.assert_pos_almost_equal(align.position.value, self.align_deactive, atol=ATOL_LINEAR_POS)
def test_invalid_switch_movements(self): """ Test it's not possible to do some disallowed switch movements """ # Test tilting from loading cryoSwitchSamplePosition(LOADING).result() with self.assertRaises(ValueError): f = cryoTiltSample(rx=self.rx_angle, rz=self.rz_angle) f.result()
def test_cancel_tilting(self): """ Test cryoTiltSample movement cancellation is handled correctly """ stage = self.stage cryoSwitchSamplePosition(LOADING).result() cryoSwitchSamplePosition(IMAGING).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)
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)