def test_group_creation(self): # group creation mymot1 = get_axis("mymot1") mymot2 = get_axis("mymot2") mygrp = Group(mymot1, mymot2) self.assertTrue(mygrp)
def test_group_creation(self): # group creation mymot1 = get_axis("mymot1") mymot2= get_axis("mymot2") mygrp = Group(mymot1, mymot2) self.assertTrue(mygrp)
def finalize(): mymot1 = get_axis("mymot1") mymot1.stop() mymot2 = get_axis("mymot2") mymot2.stop() # needed to stop threads of Deep module #mymot1.controller.log_level(bliss.common.log.INFO) mymot1.controller.finalize()
def test_group_get_position(self): # group creation mymot1 = get_axis("mymot1") mymot2= get_axis("mymot2") mygrp = Group(mymot1, mymot2) #mymot1.controller.log_level(3) pos_list = mygrp.position() #mymot1.controller.log_level(3) for axis in pos_list: self.assertEqual(axis.position(), pos_list[axis])
def test_group_get_position(self): # group creation mymot1 = get_axis("mymot1") mymot2 = get_axis("mymot2") mygrp = Group(mymot1, mymot2) #mymot1.controller.log_level(3) pos_list = mygrp.position() #mymot1.controller.log_level(3) for axis in pos_list: self.assertEqual(axis.position(), pos_list[axis])
def test_group_move(self): # group creation mymot1 = get_axis("mymot1") mymot2= get_axis("mymot2") mygrp = Group(mymot1, mymot2) pos_list = mygrp.position() pos_list[mymot1] += 0.1 # waits for the end of motions mygrp.move(pos_list) self.assertEqual(mygrp.state(), "READY")
def test_group_move(self): # group creation mymot1 = get_axis("mymot1") mymot2 = get_axis("mymot2") mygrp = Group(mymot1, mymot2) pos_list = mygrp.position() pos_list[mymot1] += 0.1 # waits for the end of motions mygrp.move(pos_list) self.assertEqual(mygrp.state(), "READY")
def test_group_stop(self): # group creation mymot1 = get_axis("mymot1") mymot2= get_axis("mymot2") mygrp = Group(mymot1, mymot2) pos_list = mygrp.position() pos_list[mymot1] -= 0.1 # non blocking call mygrp.move(pos_list, wait=False) # waits for the end of motions mygrp.stop() self.assertEqual(mygrp.state(), "READY")
def test_group_stop(self): # group creation mymot1 = get_axis("mymot1") mymot2 = get_axis("mymot2") mygrp = Group(mymot1, mymot2) pos_list = mygrp.position() pos_list[mymot1] -= 0.1 # non blocking call mygrp.move(pos_list, wait=False) # waits for the end of motions mygrp.stop() self.assertEqual(mygrp.state(), "READY")
def _update_refs(self): for tag, axis_list in self._tagged.iteritems(): for i, axis in enumerate(axis_list): if not isinstance(axis, AxisRef): continue referenced_axis = get_axis(axis.name) self.axes[axis.name] = referenced_axis axis_list[i] = referenced_axis referenced_axis.controller._tagged.setdefault(tag, []).append(referenced_axis)
def init(self): self.motorState = BlissMotor.NOTINITIALIZED self.username = self.motor_name set_backend("beacon") self.motor = get_axis(self.motor_name) self.connect(self.motor, "position", self.positionChanged) self.connect(self.motor, "state", self.updateState) self.connect(self.motor, "move_done", self._move_done)
def test_mulitple_moves(self): mymot1 = get_axis("mymot1") mymot2 = get_axis("mymot2") def task_cyclic(mot): while True: mot.position() gevent.sleep(0.1) #mymot1.controller.log_level(bliss.common.log.INFO) # launch several greenlets mymot1.move(mymot1.position() + 1000, wait=False) gevent.sleep(0.1) mymot2.move(mymot2.position() - 1000, wait=False) task = gevent.spawn(task_cyclic, mymot2) for i in range(10): mymot1.position() mymot2.position() mymot1.stop() self.assertEqual(mymot1.state(), "READY") mymot1.move(mymot1.position() - 1000, wait=False) for i in range(10): mymot1.position() mymot2.position() gevent.sleep(0.1) mymot1.stop() mymot2.stop() self.assertEqual(mymot1.state(), "READY") self.assertEqual(mymot2.state(), "READY") #mymot1.controller.log_level(bliss.common.log.ERROR) task.kill() task.join()
def test_axis_home_search(self): # launch a never ending motion as there is no home signal. # WARINING: check with icepapcms that the concerned axis an home # signal configured (for instance "Lim+") because the default # icepapcms configuration is "None" which will make the test fails. mymot1 = get_axis("mymot1") mymot1.home(wait=False) # give time to motor to start gevent.sleep(0.1) self.assertEqual(mymot1.state(), 'MOVING') # stop the never ending motion mymot1.stop() # wait for the motor stop while mymot1.state() == 'MOVING': gevent.sleep(0.1)
def test_axis_limit_search(self): mymot1 = get_axis("mymot1") # test both search senses for sense in [-1, 1]: # launch a never ending motion as there is no limitswitch mymot1.hw_limit(sense, wait=False) # give time to motor to start gevent.sleep(0.1) self.assertEqual(mymot1.state(), 'MOVING') # stop the never ending motion mymot1.stop() # wait for the motor stop while mymot1.state() == 'MOVING': gevent.sleep(0.1)
def test_sps(): config_xml = """ <config> <controller class="mockup"> <axis name="m0"> <steps_per_unit value="10000"/> <!-- degrees per second --> <velocity value="10"/> <acceleration value="100"/> </axis> <axis name="m1"> <steps_per_unit value="10000"/> <!-- degrees per second --> <velocity value="1"/> <acceleration value="10"/> </axis> <axis name="m2"> <steps_per_unit value="10000"/> <!-- degrees per second --> <velocity value="10"/> <acceleration value="100"/> </axis> </controller> </config>""" load_cfg_fromstring(config_xml) m0 = get_axis("m0") chain = AcquisitionChain() emotion_master = SoftwarePositionTriggerMaster(m0, 5, 10, 7, time=1) c0_dev = TestAcquisitionDevice("c0") c1_dev = TestAcquisitionDevice("c1") chain.add(emotion_master, c0_dev) chain.add(emotion_master, c1_dev) chain._tree.show() session_cnt = Container('sps_test') recorder = ScanRecorder('test_scan', session_cnt) scan = Scan(chain, recorder) scan.prepare() scan.start()
def test_axis_set_velocity(self): mymot1 = get_axis("mymot1") vel = 5 mymot1.velocity(vel) self.assertEqual(mymot1.velocity(), vel)
def test_axis_get_velocity(self): mymot1 = get_axis("mymot1") vel = mymot1.velocity()
def test_axis_stop(self): mymot1 = get_axis("mymot1") mymot1.stop()
def test_axis_get_acctime(self): mymot1 = get_axis("mymot1") acc = mymot1.acctime()
def test_axis_move_backlash(self): mymot1 = get_axis("mymot1") pos = mymot1.position() mymot1.move(pos - 0.1)
def test_axis_set_acctime(self): mymot1 = get_axis("mymot1") acc = 0.250 self.assertEqual(mymot1.acctime(acc), acc)
def test_axis_rmove(self): mymot1 = get_axis("mymot1") mymot1.rmove(0.1)
def test_axis_set_velocity_error(self): mymot1 = get_axis("mymot1") vel = 5000 self.assertRaises(Exception, mymot1.velocity, vel)
def test_axis_get_id(self): mymot1 = get_axis("mymot1") self.assertTrue( re.match( r"[a-f0-9A-F]{4}.[a-f0-9A-F]{4}.[a-f0-9A-F]{4}", mymot1.get_id()))
def test_axis_state(self): mymot1 = get_axis("mymot1") mymot1.state()
def test_axis_get_position(self): mymot1 = get_axis("mymot1") pos = mymot1.position()
def test_axis_move(self): mymot1 = get_axis("mymot1") pos = mymot1.position() mymot1.move(pos + 0.1) # waits for the end of motion
def test_axis_creation(self): mymot1 = get_axis("mymot1") self.assertTrue(mymot1)
def test_axis_set_position(self): mymot1 = get_axis("mymot1") pos = 2.0 # given in mm self.assertEqual(mymot1.position(pos), pos)
def test_axis_get_id(self): mymot1 = get_axis("mymot1") self.assertTrue( re.match(r"[a-f0-9A-F]{4}.[a-f0-9A-F]{4}.[a-f0-9A-F]{4}", mymot1.get_id()))
def test_step_cont(): config_xml = """ <config> <controller class="mockup"> <axis name="m0"> <steps_per_unit value="10000"/> <!-- degrees per second --> <velocity value="10"/> <acceleration value="100"/> </axis> <axis name="m1"> <steps_per_unit value="10000"/> <!-- degrees per second --> <velocity value="1"/> <acceleration value="10"/> </axis> <axis name="m2"> <steps_per_unit value="10000"/> <!-- degrees per second --> <velocity value="10"/> <acceleration value="100"/> </axis> </controller> </config>""" load_cfg_fromstring(config_xml) m0 = get_axis("m0") m1 = get_axis("m1") m2 = get_axis("m2") ascan = AcquisitionChain(parallel_prepare=True) ascan_mot = LinearStepTriggerMaster(11, m0, 10, 20) timer = SoftwareTimerMaster(0.1) ascan.add(ascan_mot, timer) test_acq_dev = TestAcquisitionDevice("timer_test", 2, prepare_once=True, start_once=True) ascan.add(timer, test_acq_dev) test2_acq_dev = TestAcquisitionDevice("timer_test2", 2, prepare_once=True, start_once=True) ascan.add(timer, test2_acq_dev) step_scan = Container('step_scan') scan = Scan(chain) scan.run() chain = AcquisitionChain(parallel_prepare=True) step_master = MeshStepTriggerMaster(m1, -2, 2, 5, m2, -5, 5, 3, backnforth=True) emotion_master = SoftwarePositionTriggerMaster(m0, 5, 10, 7, time=1) chain.add(step_master, emotion_master) chain.add(emotion_master, test_acq_dev) scan = Scan(chain, name='super_zap_image', parent=step_scan) scan.run() print "next scan" chain = AcquisitionChain() emotion_master = SoftwarePositionTriggerMaster(m0, 5, 10, 7) test_acq_dev = TestAcquisitionDevice("super_mario", 0) chain.add(emotion_master, test_acq_dev) scan = Scan(chain, name='soft_zapline', parent=step_scan) scan.run()