Commit 8eee1233 authored by bliss administrator's avatar bliss administrator
Browse files

Add new test

parent 15d187eb
......@@ -2,9 +2,13 @@ from bliss.common.standard import *
from bliss.common.axis import *
from bliss.common.cleanup import *
from bliss.setup_globals import *
from bliss.common.log import *
import sys
import time
import random
import datetime
import gevent
def init_sx():
......@@ -85,7 +89,7 @@ def init_sx():
# search for SY pos and neg limits and reset dial to 0 in the middle of them.
def init_sy():
sy.limits(low_limit=-100,high_limit=100)
sy.limits(low_limit=100,high_limit=-100)
######### LIMIT -
print("Moving to hard limit -")
......@@ -164,7 +168,7 @@ def init_sy():
def init_hr_yrot():
yrot.limits(low_limit=-1000,high_limit=1000)
######### LIMIT -
print("Moving to hard limit -")
yrot.hw_limit(-1,wait=False)
......@@ -204,13 +208,13 @@ def init_hr_yrot():
sys.stdout.write('.')
sys.stdout.flush()
gevent.sleep(1)
print(".\n")
print("lim+ found !\n")
# hardware synchronization
yrot.sync_hard()
_myposp = yrot.position()
print("Hard limit + value: %f" % (_myposp))
......@@ -231,10 +235,10 @@ def init_hr_yrot():
yrot.limits(low_limit=-slp,high_limit=slp)
def init_hr_sz():
lim_n = sz.limits()[0]
sz.limits(low_limit=lim_n,high_limit=100)
######### LIMIT +
print("Moving to hard limit +")
sz.hw_limit(1,wait=False)
......@@ -249,7 +253,7 @@ def init_hr_sz():
sys.stdout.write('.')
sys.stdout.flush()
gevent.sleep(1)
print(".\n")
print("lim+ found !\n")
......@@ -275,10 +279,10 @@ def init_hr_sz():
def init_hr_z0():
lim_p = z0.limits()[1]
z0.limits(low_limit=-100,high_limit=lim_p)
######### LIMIT -
print("Moving to hard limit -")
z0.hw_limit(-1,wait=False)
......@@ -293,13 +297,13 @@ def init_hr_z0():
sys.stdout.write('.')
sys.stdout.flush()
gevent.sleep(1)
print(".\n")
print("lim- found !\n")
# hardware synchronization
z0.sync_hard()
_myposn = z0.position()
print("Hard limit - value: %f" % (_myposn))
......@@ -317,12 +321,63 @@ def init_hr_z0():
print("reseting z0 limit- to hard limit + 0.05\n")
z0.limits(low_limit=sln,high_limit=lim_p)
def calib_motors(*argv):
def init_simot():
lim_p = simot.limits()[1]
simot.limits(low_limit=-100,high_limit=lim_p)
######### LIMIT -
print("Moving to hard limit -")
simot.hw_limit(-1,wait=False)
gevent.sleep(1)
sys.stdout.write("Searching limit- ...")
sys.stdout.flush()
_status = simot.state()
while _status == "MOVING":
_status = simot.state()
sys.stdout.write('.')
sys.stdout.flush()
gevent.sleep(1)
with error_cleanup(sx,sy,yrot,z0,sz):
cal = [gevent.spawn(arg) for arg in argv]
gevent.joinall(cal)
print(".\n")
print("lim- found !\n")
# hardware synchronization
simot.sync_hard()
_myposn = simot.position()
print("Hard limit - value: %f" % (_myposn))
cal_pos = 0.0
sln = cal_pos + 0.05
print("reseting simot1 to %f\n" % (cal_pos))
simot.dial(cal_pos)
simot.position(cal_pos)
print("moving to calibration position %f\n" % (cal_pos + 10.0))
umvr(simot,10.0)
print("reseting simot1 limit- to hard limit + 0.05\n")
simot.limits(low_limit=sln,high_limit=lim_p)
def calib_motors(*argv):
# context manager used to stop motors when an exception is raised
with error_cleanup(sx,sy,sz,yrot,z0):
cal=[gevent.spawn(arg) for arg in argv]
try:
# wait for all calibrations to be done
gevent.joinall(cal)
except:
gevent.killall(cal)
print("\n")
raise
def test_stability():
"""
This is an inifite test to try to reproduce
......@@ -332,12 +387,15 @@ def test_stability():
# let this go on until Ctrl-C
i = 0
while True:
time_start = time.time()
i = i + 1
# first move motors sx snd sy very little , but random
# Note that in order to have about the same time to get 0
# we need to move sy much closer
mvr(sy,-10.0)
mvr(sx,-1.0*random.randrange(10,90)*0.01)
print("Move to the lim- for sx and sy")
# move sy and sx to their limits
sx.hw_limit(-1)
sy.hw_limit(-1)
# add a small randomness [0.1,0.9] for sx and sy with 0.01 accuracy away from lim-
mvr(sx,1.0*random.randrange(10,90)*0.01)
mvr(sy,-1.0*random.randrange(10,90)*0.01)
calib_motors(init_sx, init_sy)
print("----- Loop "+str(i)+" ---------")
print("----- Loop "+str(i)+" ---- time for this loop is " + str(time.time()-time_start) + " ----- Time: "+str(datetime.datetime.now()))
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