def test_align_switch_procedures(self): """ Test moving the sample stage from loading position to both imaging, alignment and coating, then back to loading """ align = self.aligner # Get the stage to loading position f = cryoSwitchAlignPosition(LOADING) f.result() test.assert_pos_almost_equal(align.position.value, self.align_deactive, atol=ATOL_LINEAR_POS) # Get the stage to imaging position f = cryoSwitchAlignPosition(IMAGING) f.result() test.assert_pos_almost_equal(align.position.value, self.align_active, atol=ATOL_LINEAR_POS) # Get the stage to imaging position f = cryoSwitchAlignPosition(ALIGNMENT) f.result() test.assert_pos_almost_equal(align.position.value, self.align_alignment, atol=ATOL_LINEAR_POS)
def test_smaract_stage_fallback_movement(self): """ Test behaviour of smaract 5dof stage when the linear axes are near the maximum range """ # 1. Move to imaging position cryoSwitchSamplePosition(IMAGING).result() # 2. Move the stage linear axes to their max range + move rx from 0 cryoSwitchAlignPosition(LOADING).result() self.stage.moveAbs({'x': self.stage.axes['x'].range[1], 'y': self.stage.axes['y'].range[1], 'z': self.stage.axes['z'].range[1], 'rx': 0.15}).result() # 3. Move to loading where the ordered submoves would start from rx/rx, resulting in an invalid move # exception if it's not handled cryoSwitchSamplePosition(LOADING).result() test.assert_pos_almost_equal(self.stage.position.value, self.stage_deactive, atol=ATOL_LINEAR_POS)
def test_get_current_aligner_position(self): """ Test getCurrentPositionLabel function behaves as expected """ aligner = self.aligner # at start the aligner wouldn't be in one of the predefined positions pos_label = getCurrentAlignerPositionLabel(aligner.position.value, aligner) self.assertTrue(pos_label in (LOADING_PATH, UNKNOWN)) # Move to loading position self.test_move_aligner_to_target(LOADING) # Move to imaging position and cancel the movement before reaching there f = cryoSwitchAlignPosition(IMAGING) time.sleep(5) f.cancel() pos_label = getCurrentAlignerPositionLabel(aligner.position.value, aligner) self.assertEqual(pos_label, LOADING_PATH) # simulate moving to unknown position by moving in opposite to deactive-active line unknown_pos = copy.copy(self.align_active) unknown_pos['y'] += 0.005 unknown_pos['z'] += 0.005 self.aligner.moveAbs(unknown_pos).result() pos_label = getCurrentAlignerPositionLabel(aligner.position.value, aligner) self.assertEqual(pos_label, UNKNOWN) # moving to either imaging/alignment positions shouldn't be allowed with self.assertRaises(ValueError): f = cryoSwitchAlignPosition(IMAGING) f.result() with self.assertRaises(ValueError): f = cryoSwitchAlignPosition(ALIGNMENT) f.result() # Move to alignment position cryoSwitchAlignPosition(LOADING).result() self.test_move_aligner_to_target(ALIGNMENT) # from alignment to loading cryoSwitchAlignPosition(LOADING).result() # Move to imaging position self.test_move_aligner_to_target(IMAGING)
def test_move_aligner_to_target(self, target): f = cryoSwitchAlignPosition(target) f.result() pos_label = getCurrentAlignerPositionLabel(self.aligner.position.value, self.aligner) self.assertEqual(pos_label, target)