GitLab will be upgraded on June 23rd evening. During the upgrade the service will be unavailable, sorry for the inconvenience.

Commit 3008c277 authored by bliss administrator's avatar bliss administrator

Tested movements and calculation for multilayer

parent 3319fbb8
......@@ -13,6 +13,7 @@ from bliss.common.cleanup import cleanup, error_cleanup, capture_exceptions
from bliss.scanning.scan_tools import peak, goto_peak
from bliss.shell.standard import umv, umvr, mv, plotselect
from bliss.config.settings import ParametersWardrobe
from bliss.controllers.tango_shutter import TangoShutterState
from monochromator.monochromator import XtalManager
......@@ -25,7 +26,7 @@ class MonoMode(Enum):
LL50 = 2
LL24 = 3
OUT = 4
MM50 = 5
MM15 = 5
class Id19Mono():
......@@ -53,6 +54,8 @@ class Id19Mono():
self.laue_THY1_offset = self.config["laue_THY1_offset"]
self.laue_THY2_offset = self.config["laue_THY2_offset"]
self.multilayer_Z2_offset = self.config["multilayer_Z2_offset"]
self.xtal_size = self.config["xtal_size"]
self.stabilization_time = self.config["stabilization_time"]
......@@ -70,6 +73,7 @@ class Id19Mono():
self.modes[MonoMode.BB50] = self.config["bragg_mode"][0]
self.modes[MonoMode.LL50] = self.config["laue_mode_50"][0]
self.modes[MonoMode.LL24] = self.config["laue_mode_24"][0]
self.modes[MonoMode.MM15] = self.config["multilayer"][0]
# parameters
......@@ -83,7 +87,7 @@ class Id19Mono():
param_defaults['THY1_pos'] = 0
param_defaults['THY2_pos'] = 0
param_defaults['energy'] = 0
param_defaults['xtal_name'] = "Si111"
param_defaults['xtal_name'] = None
self.param_name = self.name + ":parameters"
self.parameters = ParametersWardrobe(self.param_name)
......@@ -127,27 +131,36 @@ class Id19Mono():
# for all other modes, get the mode positions
mono_mode = self.modes[req_mode]
# move crystals and preposition highs (offset)
# move crystals and preposition hights (offset)
# for the multilayer crystals, an offset has to be applied to Z2.
# the second crystal is mounted on a 18.5 mm thick plate.
if req_mode == MonoMode.MM15:
z2_pos = mono_mode["beam_offset"]+ mono_mode["Z1_pos"] + self.multilayer_Z2_offset
else:
z2_pos = mono_mode["beam_offset"]+ mono_mode["Z1_pos"]
print ("Move Y and Z motors")
umv(self.Y1, mono_mode["Y1_pos"],
self.Y2, mono_mode["Y2_pos"],
#self.Z1, 0.0,
self.Z1, mono_mode["Z1_pos"],
self.Z2, (mono_mode["beam_offset"]+ mono_mode["Z1_pos"]))
self.Z2, z2_pos)
# choose the correct xtal for the mode
if req_mode == MonoMode.MM50:
self.parameters.xtal_name = 'W_B4C'
if req_mode == MonoMode.MM15:
self.mono_xtals.xtal_sel = 'W_B4C'
else:
self.parameters.xtal_name = 'Si111'
self.mono_xtals.xtal_sel = self.parameters.xtal_name
self.mono_xtals.xtal_sel = 'Si111'
print (f"Set xtal to {self.mono_xtals.xtal_sel}")
print ("Move diode in")
if req_mode == MonoMode.LL24:
self.diode_pos.IN24()
if req_mode == MonoMode.MM15:
self.diode_pos.IN15()
else:
self.diode_pos.IN50()
if req_mode == MonoMode.LL24:
self.diode_pos.IN24()
else:
self.diode_pos.IN50()
self._mode = req_mode
......@@ -196,13 +209,14 @@ class Id19Mono():
self.parameters.THY2_pos = self.THY2.position
self.parameters.mode = self._mode
self.parameters.energy = self._energy
self.parameters.xtal_name = self.mono_xtals.xtal_sel
def print_config(self):
print("\n---------------------------------------------------------")
print("mono mode : %s " % self.modes[self.parameters.mode]["description"])
print("mono energy : %g " % self.parameters.energy )
print("xtal name : %s " % self.get_crystal() )
print("xtal name : %s " % self.mono_xtals.xtal_sel )
print("------------------- MONO MOTORS -------------------------")
print("X2 = %5gmm" % self.parameters.X2_pos)
print("Y1 = %5gmm Y2 = %5gmm" % (self.parameters.Y1_pos, self.parameters.Y2_pos))
......@@ -216,7 +230,7 @@ class Id19Mono():
info_str = ("---------------------------------------------------------\n")
info_str += ("mono mode : %s \n" % self.modes[self.mode]["description"])
info_str += ("mono energy : %g \n" % self.parameters.energy )
info_str += ("xtal name : %s \n" % self.get_crystal() )
info_str += ("xtal name : %s \n" % self.mono_xtals.xtal_sel )
info_str += ("------------------- MONO MOTORS -------------------------\n")
info_str += ("X2 = %5gmm \n" % self.X2.position)
info_str += ("Y1 = %5gmm Y2 = %5gmm \n" % (self.Y1.position, self.Y2.position))
......@@ -271,7 +285,7 @@ class Id19Mono():
if self._mode == MonoMode.UNDEFINED or self._mode == MonoMode.OUT:
raise RuntimeError("No operation mode applied. The monochromator is not pre-positioned")
#if self._mode == MonoMode.MM50:
#if self._mode == MonoMode.MM15:
# raise RuntimeError("The multilayer mode is not yet implemented")
# check energy range
......@@ -299,13 +313,15 @@ class Id19Mono():
THY2_pos = theta_angle
# check beam size
self.check_beam_size(theta_angle)
#self.check_beam_size(theta_angle)
# refine Z1 and Z2 pos
#self.Z1, mono_mode["Z1_pos"],
#self.Z2, (mono_mode["beam_offset"]+ mono_mode["Z1_pos"]))
Z1_pos = self.modes[self._mode]["Z1_pos"]
Z2_pos = self.modes[self._mode]["beam_offset"] + Z1_pos
if self._mode == MonoMode.MM15:
Z2_pos = self.modes[self._mode]["beam_offset"] + Z1_pos + self.multilayer_Z2_offset
else:
Z2_pos = self.modes[self._mode]["beam_offset"] + Z1_pos
#
......@@ -406,8 +422,9 @@ class Id19Mono():
return
# close bem shutter
print ("Close beam shutter")
self.beam_shutter.close()
if self.beam_shutter.state not in [TangoShutterState.CLOSED, TangoShutterState.DISABLE]:
print ("Close beam shutter")
self.beam_shutter.close()
# For security move Y2 to the middle and move it back after the X2 movement
# Only do this if X2 > 330 !!!!!!!!
......@@ -444,10 +461,12 @@ class Id19Mono():
if move_y2 == True:
print("\nMove monochromator sledge in the middle to avoid collisions!")
umv (self.Y2, 90) # move in the middle, to avoid collissions
# move X2
umv(self.X2, X2_pos)
if move_y2 == True:
print(f"\nMove monochromator sledge back to the mode position!")
umv (self.Y2, Y2_act_pos) #move back to mono mode position
# move Theta
......@@ -572,8 +591,9 @@ class Id19Mono():
def remove(self):
# close FE
print ("Close FrontEnd")
self.frontend.close()
if self.frontend.state not in [TangoShutterState.CLOSED, TangoShutterState.DISABLE, TangoShutterState.STANDBY]:
print ("Close FrontEnd")
self.frontend.close()
# remove diode
print ("Remove diode")
......@@ -603,6 +623,7 @@ class Id19Mono():
self._mode = MonoMode.OUT
self._energy = 0
self.mono_xtals.xtal_sel = None
print ("Monochromator in white beam position")
#
......@@ -637,7 +658,13 @@ class Id19Mono():
@property
def energy(self):
return self.mono_xtals.bragg2energy(self.get_theta())
try:
energy = self.mono_xtals.bragg2energy(self.get_theta())
except ZeroDivisionError:
# multilayer returns a division by zero exception the theta = 0!
energy = math.inf
return energy
@property
def lamda(self):
......
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