def test_set_trajectory(self): mypar = bliss.get_axis("mypar") mymot = bliss.get_axis("mymot") par_list = range(100) pos_list = range(100) mypar.set_parameter(par_list) mypar.set_trajectory(mymot, pos_list)
def test_set_trajectory_wrongrange(self): mypar = bliss.get_axis("mypar") mymot = bliss.get_axis("mymot") par_list = range(100) pos_list = range(10) mypar.set_parameter(par_list) self.assertRaises(ValueError, mypar.set_trajectory, mymot, pos_list)
def test_hardware_axes_preparation(self): # If motors are moving, the power can not be switched on # therefore hide exception mymot = bliss.get_axis("mymot") mymot2 = bliss.get_axis("mymot2") #mymot.controller.log_level(bliss.common.log.INFO) mymot.controller.stop(mymot) mymot2.controller.stop(mymot2) #mymot.controller.log_level(bliss.common.log.ERROR) # NOTE MP: 2015Mar17: the current eMotion doesn't call the # controller stop() if it doesn't know that a motion is taking # place on the hardware. Therefore bypass eMotion while mymot.state() == 'MOVING': gevent.sleep(0.1) while mymot2.state() == 'MOVING': gevent.sleep(0.1) # the IcePAP will move, therefore put it close to the # target position to avoid long wait mymot.dial(0) mymot.position(0) mymot2.dial(0) mymot2.position(0)
def test_axes_creation(self): #log.level(log.INFO) mymot = bliss.get_axis("mot0") #log.level(log.ERROR) self.assertTrue(mymot) mymot2 = bliss.get_axis("mot1") self.assertTrue(mymot2)
def test_group_creation(self): # group creation mymot = bliss.get_axis("mymot") mymot2= bliss.get_axis("mymot2") mygrp = bliss.Group(mymot, mymot2) self.assertTrue(mygrp)
def testRealAxisIsRightObject(self): s1f = bliss.get_axis('s1f') m0 = bliss.get_axis('m0') s1ho = bliss.get_axis("s1ho") controller = s1ho.controller self.assertEquals(s1f.controller, m0.controller) self.assertEquals(s1f, controller.axes['s1f'])
def test_static_move(self): roby = bliss.get_axis("roby") robz = bliss.get_axis("robz") p0 = self.grp.position() self.grp.rmove({ robz: 0, roby: 1}) self.assertEquals(self.grp.position()[robz], p0[robz]) self.assertEquals(self.grp.position()[roby], p0[roby]+1)
def test_group_move(self): robz = bliss.get_axis("robz") robz_pos = robz.position() roby = bliss.get_axis("roby") roby_pos = roby.position() self.assertEqual(self.grp.state(), "READY") target_robz = robz_pos + 50 target_roby = roby_pos + 50 self.grp.move( robz, target_robz, roby, target_roby, wait=False) self.assertEqual(self.grp.state(), "MOVING") self.assertEqual(robz.state(), "MOVING") self.assertEqual(roby.state(), "MOVING") self.grp.wait_move() self.assertEqual(robz.state(), "READY") self.assertEqual(roby.state(), "READY") self.assertEqual(self.grp.state(), "READY")
def testVelocity(self): a1 = bliss.get_axis("a1") self.assertEquals(a1.velocity(1), 1) config_velocity = a1.config.get("velocity", int) self.assertEquals(a1.velocity(config_velocity), config_velocity) a2 = bliss.get_axis("a2") config_velocity = a2.config.get("velocity", int) self.assertEquals(a2.velocity(config_velocity), config_velocity)
def test_load_trajectory(self): mypar = bliss.get_axis("mypar") mymot = bliss.get_axis("mymot") par_list = range(100) pos_list = [x * 10 for x in range(100)] mypar.set_parameter(par_list) mypar.set_trajectory(mymot, pos_list) mypar.load()
def test_get_encoder(self): enc = bliss.get_encoder("m0enc") self.assertTrue(enc) self.assertEquals(enc.steps_per_unit, 50) m0 = bliss.get_axis("m0") self.assertEquals(m0.encoder, enc) m1 = bliss.get_axis("m1") self.assertEquals(m1.encoder, None)
def test_load_trajectory(self): mypar = bliss.get_axis("mypar") mymot = bliss.get_axis("mymot") par_list = range(100) pos_list = [ x *10 for x in range(100) ] mypar.set_parameter(par_list) mypar.set_trajectory(mymot, pos_list) mypar.load()
def test_get_parameter_acctime(self): mypar = bliss.get_axis("mypar") mymot = bliss.get_axis("mymot") par_list = range(100) pos_list = range(100) mypar.set_parameter(par_list) mypar.set_trajectory(mymot, pos_list) mypar.load() acc = mypar.acctime()
def test_stop(self): roby = bliss.get_axis("roby") robz = bliss.get_axis("robz") self.assertEqual(robz.state(), "READY") self.grp.move({robz: 0, roby: 0}, wait=False) self.assertEqual(self.grp.state(), "MOVING") self.grp.stop() self.assertEqual(self.grp.state(), "READY") self.assertEqual(robz.state(), "READY") self.assertEqual(roby.state(), "READY")
def test_get_parameter_velocity(self): mypar = bliss.get_axis("mypar") mymot = bliss.get_axis("mymot") par_list = range(100) pos_list = range(100) mypar.set_parameter(par_list) mypar.set_trajectory(mymot, pos_list) mypar.load() vel = mypar.velocity()
def testMovePseudo(self): m1 = bliss.get_axis("m1") m0 = bliss.get_axis("m0") p1 = m1.position() p0 = m0.position() m1.rmove(2) self.assertEquals(p1 + 2, m1.position()) self.assertEquals(m0.position(), p0 + 1) m1.rmove(-2) self.assertEquals(p0, m0.position()) self.assertEquals(m1.position(), p1)
def testMoveReal(self): m1 = bliss.get_axis("m1") m0 = bliss.get_axis("m0") p1 = m1.position() p0 = m0.position() m0.rmove(1) self.assertEquals(p0 + 1, m0.position()) self.assertEquals(m1.position(), p1 + 2) m0.rmove(-1) self.assertEquals(p0, m0.position()) self.assertEquals(m1.position(), p1)
def test_ctrlc(self): roby = bliss.get_axis("roby") robz = bliss.get_axis("robz") self.assertEqual(robz.state(), "READY") self.grp.rmove({robz: -10, roby: -10}, wait=False) time.sleep(0.01) self.grp._Group__move_task.kill(KeyboardInterrupt, block=False) self.assertRaises(KeyboardInterrupt, self.grp.wait_move) self.assertEqual(self.grp.state(), "READY") self.assertEqual(robz.state(), "READY") self.assertEqual(roby.state(), "READY")
def test_set_parameter_acctime(self): mypar = bliss.get_axis("mypar") mymot = bliss.get_axis("mymot") par_list = range(100) pos_list = range(100) mypar.set_parameter(par_list) mypar.set_trajectory(mymot, pos_list) mypar.load() acc = 0.250 self.assertEqual(mypar.acctime(acc), acc)
def testPseudoAxisMove(self): s1b = bliss.get_axis("s1b") s1f = bliss.get_axis("s1f") s1hg = bliss.get_axis("s1hg") s1f.move(0) s1b.move(0) hgap = 0.5 s1hg.move(hgap) self.assertAlmostEquals(hgap, s1hg.position(), places=6)
def test_group_get_position(self): # group creation mymot = bliss.get_axis("mymot") mymot2= bliss.get_axis("mymot2") mygrp = bliss.Group(mymot, mymot2) #mymot.controller.log_level(3) pos_list = mygrp.position() #mymot.controller.log_level(3) for axis in pos_list: self.assertEqual(axis.position(), pos_list[axis])
def testPosition(self): a1 = bliss.get_axis("a1") a2 = bliss.get_axis("a2") self.assertAlmostEqual(a2.position(), 0.2, places=5) for a in (a1, a2): p0 = a.position() target = p0 + 0.1 a.move(target) self.assertAlmostEqual(a.position(), target, places=5) a.move(p0 - 0.1) self.assertAlmostEqual(a.position(), p0 - 0.1, places=5)
def testPosition(self): a1 = bliss.get_axis("a1") a2 = bliss.get_axis("a2") self.assertAlmostEqual(a2.position(), 0.2, places=5) for a in (a1, a2): p0 = a.position() target = p0+0.1 a.move(target) self.assertAlmostEqual(a.position(), target, places=5) a.move(p0-0.1) self.assertAlmostEqual(a.position(), p0-0.1, places=5)
def test_group_move(self): # group creation mymot = bliss.get_axis("mymot") mymot2= bliss.get_axis("mymot2") mygrp = bliss.Group(mymot, mymot2) pos_list = mygrp.position() pos_list[mymot] += 0.1 # waits for the end of motions mygrp.move(pos_list) self.assertEqual(mygrp.state(), "READY")
def test_bad_startone(self): roby = bliss.get_axis("roby") robz = bliss.get_axis("roby") roby.dial(0); roby.position(0) robz.dial(0); robz.position(0) try: roby.controller.set_error(True) self.assertRaises(RuntimeError, self.grp.move, { robz: 1, roby: 2 }) self.assertEquals(self.grp.state(), "READY") self.assertEquals(roby.position(), 0) self.assertEquals(robz.position(), 0) finally: roby.controller.set_error(False)
def testSimultaneousMove(self): a1 = bliss.get_axis("a1") a2 = bliss.get_axis("a2") p1 = a1.position() p2 = a2.position() a1.rmove(0.1, wait=False) self.assertRaises(RuntimeError, a2.rmove, 0.1, wait=False) a1.wait_move() a2.wait_move() self.assertEquals(a1.position(), p1 + 0.1) self.assertEquals(a2.position(), p2) a1.rmove(-0.1) self.assertEquals(a1.position(), p1)
def testDial(self): s1hg = bliss.get_axis("s1hg") s1b = bliss.get_axis("s1b") s1f = bliss.get_axis("s1f") s1b.move(0); s1f.move(0) s1hg.move(4) s1hg.dial(0) self.assertAlmostEquals(4, s1hg.position(), places=4) self.assertAlmostEquals(0, s1hg.dial(), places=4) self.assertAlmostEquals(0, s1b.position(), places=4) self.assertAlmostEquals(0, s1f.position(), places=4) self.assertAlmostEquals(2, s1b.dial(), places=4) self.assertAlmostEquals(2, s1f.dial(), places=4)
def testSimultaneousMove(self): a1 = bliss.get_axis("a1") a2 = bliss.get_axis("a2") p1 = a1.position() p2 = a2.position() a1.rmove(0.1, wait=False) self.assertRaises(RuntimeError, a2.rmove, 0.1, wait=False) a1.wait_move() a2.wait_move() self.assertEquals(a1.position(), p1+0.1) self.assertEquals(a2.position(), p2) a1.rmove(-0.1) self.assertEquals(a1.position(), p1)
def test_bad_startall(self): robz = bliss.get_axis("robz") robz2 = bliss.get_axis("robz2") robz2.dial(0); robz2.position(0) robz.dial(0); robz.position(0) grp = bliss.Group(robz, robz2) try: robz.controller.set_error(True) self.assertRaises(RuntimeError, grp.move, { robz: 1, robz2: 2}) self.assertEquals(grp.state(), "READY") self.assertEquals(robz2.position(), 0) self.assertEquals(robz.position(), 0) finally: robz.controller.set_error(False)
def initialize_axis(self, axis): """Axis initialization""" self.log_info("initialize_axis() called for axis %r" % axis.name) # Get the list of IcePAP axes axes_names = axis.config.get("axislist").split() if len(axes_names) == 0: raise ValueError('missing mandatory config parameter "axislist"') # Check the list of IcePAP axes dev = None for axis_name in axes_names: # Get EMotion axis object hw_axis = bliss.get_axis(axis_name) # Check that it's an IcePAP controlled one if type(hw_axis.controller).__name__ is not 'IcePAP': raise ValueError('invalid axis "%s", not an IcePAP'%axis_name) # Get underlying libicepap object axis_dev = hw_axis.controller.libdevice if dev is None: dev = axis_dev # Let's impone that the trajectories work only on the same system if axis_dev.hostname() != dev.hostname(): raise ValueError( 'invalid axis "%s", not on the same IcePAP'%axis_name) # At this point we have configuration # Create an empty libicepap trajectory object self.libtraj[axis] = libicepap.Trajectory(axis.name) # Keep a record of axes for axis_name in axes_names: self.axes_names.append(axis_name) hw_axis = bliss.get_axis(axis_name) self.axis_list[axis_name] = hw_axis # Keep a record of the IcePAP system for faster access self.libdevice = dev # Add new axis oject methods add_axis_method(axis, self.set_parameter) add_axis_method(axis, self.get_parameter) add_axis_method(axis, self.set_trajectory) add_axis_method(axis, self.drain) add_axis_method(axis, self.load) add_axis_method(axis, self.sync)
def testKeepZeroOffset(self): s1hg = bliss.get_axis("s1hg") s1hg.no_offset = True s1b = bliss.get_axis("s1b") s1f = bliss.get_axis("s1f") s1b.move(0); s1f.move(0) s1hg.move(4) s1hg.dial(0) self.assertAlmostEquals(0, s1hg.position(), places=4) self.assertAlmostEquals(0, s1hg.dial(), places=4) self.assertAlmostEquals(0, s1b.position(), places=4) self.assertAlmostEquals(0, s1f.position(), places=4) self.assertAlmostEquals(2, s1b.dial(), places=4) self.assertAlmostEquals(2, s1f.dial(), places=4)
def test_maxee(self): m1 = bliss.get_axis("m1") m1.move(1) self.assertEquals(m1.position(), 1) m0 = bliss.get_axis("m0") m0.dial(0); m0.position(0) self.assertRaises(RuntimeError, m0.move, 1) enc = bliss.get_encoder("m0enc") enc.set(2) m0.move(2) self.assertEquals(m0.position(), 2)
def test_group_stop(self): # group creation mymot = bliss.get_axis("mymot") mymot2= bliss.get_axis("mymot2") mygrp = bliss.Group(mymot, mymot2) pos_list = mygrp.position() pos_list[mymot] -= 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_get_informations(self): pz = bliss.get_axis("pz") print "PI_E517 IDN :", pz.get_id() print "PI_E517 channel :", pz.channel print "PI_E517 chan_letter :", pz.chan_letter print "PI_E517 pz state:", pz.state() print "PI_E517 INFOS :\n", pz.get_info()
def test_stop_move(self): mypar = bliss.get_axis("mypar") mymot = bliss.get_axis("mymot") mymot2 = bliss.get_axis("mymot2") par_list = range(100) mypar.set_parameter(par_list) pos_list = [x * 1.5 for x in range(100)] mypar.set_trajectory(mymot, pos_list) pos_list2 = [x * 2 for x in range(100)] mypar.set_trajectory(mymot2, pos_list2) mypar.load() mypar.sync(1) mypar.move(2, wait=False) mypar.stop()
def test_put_all_axes_on_trajectory(self): mypar = bliss.get_axis("mypar") mymot = bliss.get_axis("mymot") mymot2 = bliss.get_axis("mymot2") par_list = range(100) mypar.set_parameter(par_list) pos_list = [x * 1.5 for x in range(100)] mypar.set_trajectory(mymot, pos_list) pos_list2 = [x * 2 for x in range(100)] mypar.set_trajectory(mymot2, pos_list2) mypar.load() # IcePAP motors will move, blocking call mypar.sync(1) self.assertEqual(mymot.position(), pos_list[1]) self.assertEqual(mymot2.position(), pos_list2[1])
def test_move(self): print "################### move ###############" px = bliss.get_axis("px") _pos = px.position() print "VSCANNER px.position = %g" % _pos if _pos < 88: _new_pos = _pos + 11.11 else: _new_pos = 0 print "VSCANNER move to ", _new_pos px.move(_new_pos) print "VSCANNER new pos : ", px.position()
def testVelocity(self): o = bliss.get_axis("omega") self.assertEquals(o.velocity(), 50) self.assertEquals(o.acceleration(), 400) self.assertEquals(o.acctime(), 0.125) t0 = time.time() o.rmove(100) dt = time.time() - t0 self.assertTrue(dt < 2.4) o.velocity(100) o.acctime(0.125) self.assertEquals(o.acceleration(), o.velocity() / o.acctime()) t0 = time.time() o.rmove(-100) dt = time.time() - t0 self.assertTrue(dt < 1.4)
def test_acceleration(self): fd = bliss.get_axis("fd") _read_acc = fd.settings.get("acceleration") print "FlexDC read acceleration :", _read_acc self.assertEqual(_read_acc, 3)
def test_velocity(self): fd = bliss.get_axis("fd") _read_vel = fd.velocity() print "FlexDC read velocity :", _read_vel self.assertAlmostEqual(_read_vel, 1.2, places=3)
def test_get_id(self): fd = bliss.get_axis("fd") print "FlexDC ID :", fd.get_id()
def test_position(self): fd = bliss.get_axis("fd") print "FlexDC position :", fd.position()
def test_state(self): fd = bliss.get_axis("fd") print "FlexDC state :", fd.state()
def test_controller_from_axis(self): fd = bliss.get_axis("fd") self.assertEqual(fd.controller.name, "id16phn")
def test_controller_from_axis(self): pz = bliss.get_axis("pz") self.assertEqual(pz.controller.name, "testid16")
def test_get_axis(self): sp1 = bliss.get_axis("sp1") self.assertTrue(sp1)
def test_get_info(self): pz = bliss.get_axis("pz") print "E753 INFOS :\n", pz.controller._get_info()
def test_get_id(self): pz = bliss.get_axis("pz") print "E753 IDN :", pz.controller._get_identifier()
def testState(self): a1 = bliss.get_axis("a1") self.assertEquals(a1.state(), READY)
def test_get_info(self): fd = bliss.get_axis("fd") print "FlexDC INFOS :\n", fd.get_info()
def test_get_axis(self): fd = bliss.get_axis("fd") self.assertTrue(fd)
def test_get_position(self): pz = bliss.get_axis("pz") print "E753 position :", pz.position()