Commit eb5fdae1 authored by blissadm's avatar blissadm

change for private links and more tests

parent 3553fcc9
......@@ -14,22 +14,19 @@ import bliss
config_xml = """
<config>
<controller class="PI_E517" name="testid16">
<host value="e517pela"/>
<controller class="PI_E517" name="testid16a">
<host value="192.168.167.10"/>
<axis name="px">
<channel value="1"/>
<chan_letter value="A"/>
<velocity value="12"/>
</axis>
<axis name="py">
<channel value="2"/>
<chan_letter value="B"/>
<velocity value="12"/>
</axis>
<axis name="pz">
<channel value="3"/>
<chan_letter value="C"/>
<velocity value="12"/>
</axis>
</controller>
</config>
......@@ -44,11 +41,20 @@ class TestPI_E517Controller(unittest.TestCase):
def test_get_id(self):
pz = bliss.get_axis("pz")
print "E517 IDN :", pz.get_id()
print "PI_E517 IDN :", pz.get_id()
def test_get_chan(self):
pz = bliss.get_axis("pz")
print "PI_E517 channel :", pz.channel
print "PI_E517 chan_letter :", pz.chan_letter
def test_get_position(self):
pz = bliss.get_axis("pz")
print "E517 pz position :", pz.position()
print "PI_E517 pz position :", pz.position()
def test_get_measured_position(self):
pz = bliss.get_axis("pz")
print "PI_E517 pz measured position :", pz.measured_position()
def test_get_axis(self):
pz = bliss.get_axis("pz")
......@@ -56,38 +62,152 @@ class TestPI_E517Controller(unittest.TestCase):
def test_get_state(self):
pz = bliss.get_axis("pz")
print "E517 pz state:", pz.state()
print "PI_E517 pz state:", pz.state()
def test_get_infos(self):
def test_get_info(self):
pz = bliss.get_axis("pz")
print "E517 INFOS :\n", pz.get_infos()
print "PI_E517 INFOS :\n", pz.get_info()
def test_get_voltage(self):
pz = bliss.get_axis("pz")
print "E517 pz output voltage :", pz.controller._get_voltage(pz)
print "PI_E517 pz output voltage :", pz.controller._get_voltage(pz)
def test_get_closed_loop_status(self):
pz = bliss.get_axis("pz")
print "E517 pz closed loop enabled :", \
print "PI_E517 pz closed loop enabled :", \
pz.controller._get_closed_loop_status(pz)
def test_very_small_move(self):
pz = bliss.get_axis("pz")
_pos = pz.position()
_new_pos = _pos + 0.001
print "PI_E517 move to ", _new_pos
pz.move(_new_pos)
def test_multiple_move(self):
pz = bliss.get_axis("pz")
_pos = pz.position()
for i in range(1000):
print i,
pz.move(_pos, wait=True)
def test_multiple_raw_move(self):
pz = bliss.get_axis("pz")
_pos = pz.position()
_cmd = "SVA %s %g \n" % (pz.chan_letter, _pos)
for i in range(1000):
print i,
pz.controller.sock.write(_cmd)
# time.sleep(0.001)
_pos = pz.position()
print "PI_E517 pos=", _pos
def test_multiple_raw_read_pos(self):
'''
25 mar.2014 :
nb_cmd=10000, mean=1.217250ms, max=2.267838 Ran 1 test in 12.414s
nb_cmd=100000,mean=1.242071ms, max=919.186115
val> 4ms : 627.511 919.186 887.565
'''
pz = bliss.get_axis("pz")
_cmd = "SVA? %s\n" % pz.chan_letter
_sum_time = 0
_nb_cmd = 100000
_max_duration = 0
_errors = 0
for i in range(_nb_cmd):
_t0 = time.time()
try:
_pos = pz.controller.sock.write_readline(_cmd, timeout=0.1),
except:
import pdb
pdb.set_trace()
print "TIMEOUT"
_duration = (time.time() - _t0) *1000
_sum_time = _sum_time + _duration
if _duration > _max_duration:
_max_duration = _duration
if _duration > 5:
print "i=%d %6.3f" % (i, _duration)
_errors = _errors + 1
if (i % 100) == 0:
print ".",
print "nb_cmd=%d, mean=%fms, max=%f" % (_nb_cmd, _sum_time / _nb_cmd, _max_duration)
def test_multiple_raw_read_pos_and_move(self):
print " \n\n"
pz = bliss.get_axis("pz")
_pos = pz.position()
_cmd_move = "SVA %s %g \n" % (pz.chan_letter, _pos)
_cmd_pos = "SVA? %s\n" % pz.chan_letter
for i in range(100):
print i,
print pz.controller.sock.write_readline(_cmd_pos),
# time.sleep(0.01)
pz.controller.sock.write(_cmd_move)
def test_multiple_raw_read_pos_and_move_3chan(self):
print " \n\n"
px = bliss.get_axis("px")
py = bliss.get_axis("py")
pz = bliss.get_axis("pz")
_pos_x = px.position()
_pos_y = py.position()
_pos_z = pz.position()
_cmd_move_x = "SVA %s %g \n" % (px.chan_letter, _pos_x)
_cmd_pos_x = "SVA? %s\n" % px.chan_letter
_cmd_move_y = "SVA %s %g \n" % (py.chan_letter, _pos_y)
_cmd_pos_y = "SVA? %s\n" % py.chan_letter
_cmd_move_z = "SVA %s %g \n" % (pz.chan_letter, _pos_z)
_cmd_pos_z = "SVA? %s\n" % pz.chan_letter
_respire = 0
for i in range(100):
print i,
_t0 = time.time()
px.controller.sock.write(_cmd_move_x)
_ans = px.controller.sock.write_readline(_cmd_pos_x)
_duration = 1000 * (time.time() - _t0)
print _ans,
if _duration > 5:
print "oups duration : ", _duration
time.sleep(_respire)
_t0 = time.time()
py.controller.sock.write(_cmd_move_y)
_ans = py.controller.sock.write_readline(_cmd_pos_y)
_duration = 1000 * (time.time() - _t0)
print _ans,
if _duration > 5:
print "oups duration : ", _duration
time.sleep(_respire)
_t0 = time.time()
pz.controller.sock.write(_cmd_move_z)
_ans = pz.controller.sock.write_readline(_cmd_pos_z)
_duration = 1000 * (time.time() - _t0)
print _ans,
if _duration > 5:
print "oups duration : ", _duration
time.sleep(_respire)
def test_get_on_target_status(self):
pz = bliss.get_axis("pz")
print "E517 pz on target :", pz.controller._get_on_target_status(pz)
print "PI_E517 pz on target :", pz.controller._get_on_target_status(pz)
# called at end of each test
def tearDown(self):
# Little wait time to let time to PI controller to
# close peacefully its sockets...
# close peacefully its sockets... (useful ?)
time.sleep(0.2)
# def test_axis_move(self):
# pz = bliss.get_axis("pz")
# self.assertEqual(pz.state(), "READY")
# move_greenlet=pz.move(10, wait=False)
# self.assertEqual(pz.state(), "MOVING")
# move_greenlet.join()
# self.assertEqual(pz.state(), "READY")
if __name__ == '__main__':
unittest.main()
......@@ -98,8 +218,8 @@ NI Interactive test :
load_cfg_fromstring("""
<config>
<controller class="PI_E517" name="testid16">
<host value="e517pela"/>
<controller class="PI_E517" name="testid16a">
<host value="192.168.167.10"/>
<axis name="p4">
<channel value="1"/>
<chan_letter value="A"/>
......@@ -113,6 +233,21 @@ load_cfg_fromstring("""
<chan_letter value="C"/>
</axis>
</controller>
<controller class="PI_E517" name="testid16b">
<host value="192.168.168.10"/>
<axis name="p1">
<channel value="1"/>
<chan_letter value="A"/>
</axis>
<axis name="p2">
<channel value="2"/>
<chan_letter value="B"/>
</axis>
<axis name="p3">
<channel value="3"/>
<chan_letter value="C"/>
</axis>
</controller>
</config>
""")
......@@ -123,8 +258,8 @@ f=get_axis("p6")
load_cfg_fromstring("""
<config>
<controller class="PI_E517" name="testid16">
<host value="e517pelb"/>
<controller class="PI_E517" name="testid16b">
<host value="192.168.16b.10"/>
<axis name="p1">
<channel value="1"/>
<chan_letter value="A"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment