Commit fabe9404 authored by Yoann Sallaz Damaz's avatar Yoann Sallaz Damaz
Browse files

bla

parent de353bc4
Pipeline #60251 failed with stages
......@@ -163,8 +163,8 @@ tab_nrj=[
nrj = type('', (), {})()
for valuelist in tab_nrj:
setattr(nrj,"_"+str(valuelist[3]).replace(".","_")+"_"+valuelist[0]+"-"+valuelist[1],valuelist[3])
setattr(nrj,valuelist[0]+"-"+valuelist[1]+"_"+str(valuelist[3]).replace(".","_"),valuelist[3])
setattr(nrj,"_"+str(valuelist[3]).replace(".","_")+"_"+valuelist[0]+"_"+valuelist[1],valuelist[3])
setattr(nrj,valuelist[0]+"_"+valuelist[1]+"_"+str(valuelist[3]).replace(".","_"),valuelist[3])
##########################################################################
......
......@@ -87,6 +87,7 @@ class SampleChangerState:
Fault = 14
Initializing = 15
Closing = 16
Versapin_mounted = 17
STATE_DESC = {
Ready: "Ready",
......@@ -105,6 +106,7 @@ class SampleChangerState:
StandBy: "StandBy",
Initializing: "Initializing",
Closing: "Closing",
Versapin_mounted: "Versapin mounted"
}
@staticmethod
......@@ -249,6 +251,12 @@ class grob_FIP(object):
return txt
def send_command(self, cmd, arg=[]):
#si le tool actuel est indefini il va avoir besoin de la camera : a terme le control de la lumiere sera faite par le robot
self.init_real_device()
self.read_all_memory()
if self.CurrentMode==0:
self.keyence.on()
param=arg.copy()
print(param)
cominfo = self.addr.get("Command")
......@@ -300,7 +308,8 @@ class grob_FIP(object):
if mot.name=="kappa" and target==0:
mot.reset_pos()
else:
mot.move(target,wait=False)
if abs(mot.position-target)>0.01:
mot.move(target,wait=False)
notok=True
with gevent.Timeout(60,False):
......@@ -660,15 +669,32 @@ class grob_FIP(object):
self.send_command("anneal", [nb_move,int(nb_sec_in*100+32767),int(nb_sec_out*100+32767)])
def mount_dismount_versa_pin(self):
#self.bstop1.down()
#self.dstop.down()
#if self.bstop1.is_up() or self.dstop.is_up():
# print("Beam stop or Dstop is up -> Aborting")
# return
self.force_gripper(3)
time.sleep(1)
if self.get_state() in [SampleChangerState.Ready, SampleChangerState.Loaded]:
self.init_real_device()
self.bstop1.down()
self.detcover.force_close()
for retry in range(0,60):
ok=True
txt=""
if self.bstop1.is_down():
txt+="BStop1 down\t\t"+CGRE+"[OK]\n"+CEND
else:
txt+="BStop1 down\t\t"+CRED+"[NOK]\n"+CEND
ok=False
if self.detcover.is_close():
txt+="Detector Cover closed\t"+CGRE+"[OK]\n"+CEND
else:
txt+="Detector Cover closed\t"+CRED+"[NOK]\n"+CEND
ok=False
if ok:
print(txt)
break
else:
time.sleep(1)
print(txt)
if ok:
self.send_command("mount_versa_pin")
......
......@@ -23,6 +23,11 @@ from scipy import ndimage
from scipy.interpolate import interp1d
import enlighten
setattr(energy,'move_to',type('', (), {})())
for valuelist in tab_nrj:
setattr(energy.move_to,"_"+str(valuelist[3]).replace(".","_")+"_"+valuelist[0]+"_"+valuelist[1],valuelist[3])
#setattr(nrj,valuelist[0]+"_"+valuelist[1]+"_"+str(valuelist[3]).replace(".","_"),valuelist[3])
def gauss(x, p): # p[0]==mean, p[1]==stdev
return 1.0/(p[1]*np.sqrt(2*np.pi))*np.exp(-(x-p[0])**2/(2*p[1]**2))
......@@ -38,8 +43,6 @@ def analyseImg():
projection = np.true_divide(projection, np.sum(projection))
return ndimage.center_of_mass(projection)[0]
def change_energy(value):
mv(energy,value)
......@@ -261,12 +264,8 @@ def geofip_fill_beam_save():
optical_conf.save()
def beam_save():
motenergy = None
for mot in global_map.get_axes_iter():
if mot.name=="energy":
motenergy=mot
break
def beam_save():
current_nrj = energy.position
cc = get_config()
cc.reload()
optical_conf = cc.get("optical_setup")
......@@ -282,11 +281,16 @@ def beam_save():
#Search for the closest idx
tab_nrj_kev = np.array([i[3] for i in tab_nrj])
idx = (np.abs(tab_nrj_kev-(motenergy.position/1000.))).argmin()
#tab_nrj_choice = [(str(i[3]), "%s(%s) %.2fkeV"%(i[0],i[1],i[2])) for i in tab_nrj]
idx = (np.abs(tab_nrj_kev-(energy.position/1000.))).argmin()
tab_nrj_choice = [(str(i), "%6s %6s"%(str(i),"-".join(tab_nrj[np.argwhere(tab_nrj_kev==i)[0][0]][0:2]))) for i in list_nrj_setup]
dlg3 = UserChoice(label="Your are currently at %.2fkeV - Choose the energy for saving the current motors positions"%(motenergy.position), values=tab_nrj_choice, defval=idx)
defval=0
for idx in range(len(tab_nrj_choice)):
if abs(float(tab_nrj_choice[idx][0])-current_nrj)<0.005:
defval=idx
dlg3 = UserChoice(label="Your are currently at %.4fkeV - Choose the energy for saving the current motors positions"%(energy.position), values=tab_nrj_choice, defval=defval)
new_nrg_to_save = BlissDialog( [ [ dlg3 ] ], title='Beam save').show()
if new_nrg_to_save is not False:
new_nrg_to_save = list(new_nrg_to_save.values())[0]
......
from bliss.common.hook import MotionHook
from bliss import global_map
from bliss.setup_globals import *
from bm07.optical_setup import *
class GonioSafety(MotionHook):
class SafetyError(Exception):
......@@ -29,6 +31,35 @@ class GonioSafety(MotionHook):
f'Cannot move : possible collision due to omega')
class EnergieSafety(MotionHook):
class SafetyError(Exception):
pass
def __init__(self):
super(EnergieSafety, self).__init__()
def init(self):
pass
def pre_move(self, motion_list):
for motion in motion_list:
if motion.axis.disabled:
raise self.SafetyError(
f'Cannot move : {motion.axis.name} is disabled')
if motion.axis.name == "energy":
curpos = motion.axis.position
targetpos = motion.user_target_pos
print("Energy : current %.4f, wanted %.4f"%(curpos,targetpos))
if abs(targetpos-curpos)>=0.2:
print('Cannot only beta : full energy set launched')
beam_set(targetpos)
return
GonioSafetyHook = GonioSafety()
omega.motion_hooks.append(GonioSafetyHook)
kappa.motion_hooks.append(GonioSafetyHook)
\ No newline at end of file
kappa.motion_hooks.append(GonioSafetyHook)
EnergieSafetyHook = EnergieSafety()
energy.motion_hooks.append(EnergieSafetyHook)
\ No newline at end of file
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