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_move_update_position(self): """ Test to make sure the system updates the position as it moves """ pos1 = {'x': 0, 'y': 0, 'z': 0, 'rx': 0, 'rz': 0} pos2 = {'x': 2e-3, 'y': 2e-3, 'z': 2e-3, 'rx': 3e-4, 'rz': -1e-4} self.dev.moveAbs(pos1).result() time.sleep(0.1) f = self.dev.moveAbs(pos2) # wait and see if the position updated midway through the move. Should take 3 s in sim time.sleep(1.0) test.assert_pos_not_almost_equal(self.dev.position.value, pos1, **COMP_ARGS) test.assert_pos_not_almost_equal(self.dev.position.value, pos2, **COMP_ARGS) f.result()
def test_move_cancel(self): # Test cancellation by cancelling the future self.dev.moveAbs({'x': 0, 'y': 0, 'z': 0, 'rx': 0, 'rz': 0}).result() new_pos = {'x': 0.003, 'y': 0, 'z': 0.0007, 'rx': 0.001, 'rz': 0.002} f = self.dev.moveAbs(new_pos) time.sleep(0.01) f.cancel() difference = new_pos['x'] - self.dev.position.value['x'] self.assertNotEqual(round(difference, 4), 0) # Test cancellation by stopping self.dev.moveAbs({'x': 0, 'y': 0, 'z': 0, 'rx': 0, 'rz': 0}).result() new_pos = {'x': 0.003, 'y': 0, 'z': 0.0007, 'rx': 0.01, 'rz': 0.0001} f = self.dev.moveAbs(new_pos) time.sleep(0.1) self.dev.stop() test.assert_pos_not_almost_equal(self.dev.position.value, new_pos, **COMP_ARGS)
def test_cancel_loading(self): """ Test cryoSwitchSamplePosition movement cancellation is handled correctly """ stage = self.stage cryoSwitchSamplePosition(LOADING).result() f = cryoSwitchSamplePosition(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 cryoSwitchSamplePosition(LOADING).result() f = cryoSwitchSamplePosition(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)
def test_stage_point_select_mode_overlay(self): """ Test behavior of StagePointSelectOverlay """ cnvs = miccanvas.DblMicroscopeCanvas(self.panel) self.add_control(cnvs, wx.EXPAND, proportion=1, clear=True) tab_mod = self.create_simple_tab_model() # create a dummy stage to attach to the view stage = TMCLController(name="test", role="test", port="/dev/fake3", axes=["x", "y"], ustepsize=[1e-6, 1e-6], rng=[[-3e-3, 3e-3], [-3e-3, 3e-3]], refproc="Standard") # Add a tiled area view to the tab model logging.debug(stage.position.value) fview = FeatureOverviewView("fakeview", stage=stage) tab_mod.views.value.append(fview) tab_mod.focussedView.value = fview cnvs.setView(fview, tab_mod) slol = wol.StagePointSelectOverlay(cnvs) slol.active.value = True cnvs.add_world_overlay(slol) initial_pos = copy.deepcopy(stage.position.value) # simulate double click by passing the mouse event to on_dbl_click evt = wx.MouseEvent() evt.x = 10 evt.y = 10 slol.on_dbl_click(evt) test.gui_loop(1) # stage should have been moved from initial position assert_pos_not_almost_equal(stage.position.value, initial_pos) logging.debug(stage.position.value) test.gui_loop()