Commit a3b7ba55 authored by bliss administrator's avatar bliss administrator
Browse files

Added beamstop and diode

parent 00b5fe5a
import sys
import time
import gevent
import math
import time
import datetime
from bliss import setup_globals, global_map
from bliss.common import mapping, scans
from bliss.common import session
from bliss.common.standard import *
from bliss.common.scans import dscan, DEFAULT_CHAIN, plotselect, goto_peak
from bliss.common.logtools import log_info, log_debug, log_error
from bliss.common.cleanup import cleanup, error_cleanup, capture_exceptions
from bliss.shell.standard import umv, umvr
from bliss.config.settings import ParametersWardrobe
from bliss.common import standard
from id19.mono.monochromator import MonochromatorBase
......@@ -36,8 +40,8 @@ class Id19Mono(MonochromatorBase):
self.config = config
self.X2_safe_position = self.config["X2_safe_position"]
self.beam_stop_in_pos = self.config["beam_stop_in_pos"]
self.beam_stop_out_pos = self.config["beam_stop_out_pos"]
#self.beam_stop_in_pos = self.config["beam_stop_in_pos"]
#self.beam_stop_out_pos = self.config["beam_stop_out_pos"]
self.laue_THY1_offset = self.config["laue_THY1_offset"]
self.laue_THY2_offset = self.config["laue_THY2_offset"]
......@@ -46,6 +50,11 @@ class Id19Mono(MonochromatorBase):
self.stabilization_time = self.config["stabilization_time"]
self.energy = 0
self.beam_stop = self.config["beam_stop"]
self.diode_pos = self.config["diode_pos"]
self.diode_cnt = self.config["diode_cnt"]
self.beam_shutter = self.config["beam_shutter"]
# modes
self.modes = {}
......@@ -66,7 +75,7 @@ class Id19Mono(MonochromatorBase):
param_defaults['Z2_pos'] = 0
param_defaults['THY1_pos'] = 0
param_defaults['THY2_pos'] = 0
param_defaults['BS_pos'] = 0
#param_defaults['BS_pos'] = 0
param_defaults['energy'] = 0
param_defaults['xtal_name'] = "Si111"
......@@ -103,20 +112,20 @@ class Id19Mono(MonochromatorBase):
self.safe_position()
print ("Move in beam stop")
#self.beam_stop_in()
#self.beam_stop.IN()
# for all other modes, get the mode positions
mono_mode = self.modes[mode]
# move crystals and preposition highs (offset)
print ("Move Y and Z motors")
standard.umv(self.Y1, mono_mode["Y1_pos"],
self.Y2, mono_mode["Y2_pos"],
self.Z1, 0.0,
self.Z2, mono_mode["beam_offset"])
umv(self.Y1, mono_mode["Y1_pos"],
self.Y2, mono_mode["Y2_pos"],
self.Z1, 0.0,
self.Z2, mono_mode["beam_offset"])
print ("Move diode in")
#self.diode_in()
#self.diode_pos.IN()
self.mode = mode
self.energy = 0
......@@ -139,7 +148,7 @@ class Id19Mono(MonochromatorBase):
if self.is_aprox(self.Y2.position, white_beam["Y2_pos"], 5):
if self.is_aprox(self.Z1.position, white_beam["Z1_pos"], 1):
if self.is_aprox(self.Z2.position, white_beam["Z2_pos"], 1):
if self.is_beam_stop_out():
if self.beam_stop.position == 'OUT':
self.mode = current_mode
return
......@@ -148,7 +157,7 @@ class Id19Mono(MonochromatorBase):
if self.is_aprox(self.Y1.position, mono_mode["Y1_pos"], 5):
if self.is_aprox(self.Y2.position, mono_mode["Y2_pos"], 5):
if self.is_beam_stop_in():
if self.beam_stop.position == 'IN':
self.mode = current_mode
return
......@@ -164,7 +173,7 @@ class Id19Mono(MonochromatorBase):
self.parameters.Z2_pos = self.Z2.position
self.parameters.THY1_pos = self.THY1.position
self.parameters.THY2_pos = self.THY2.position
self.parameters.BS_pos = self.beam_stop.position
#self.parameters.BS_pos = self.beam_stop.position
self.parameters.mode = self.mode
self.parameters.energy = self.energy
......@@ -179,21 +188,24 @@ class Id19Mono(MonochromatorBase):
print("Y1 = %5gmm Y2 = %5gmm" % (self.parameters.Y1_pos, self.parameters.Y2_pos))
print("Z1 = %5gmm Z2(beam gap/offset) = %6.4fmm " % (self.parameters.Z1_pos, self.parameters.Z2_pos))
print("Crystals Angles : THY1 = %g THY2 = %g "% (self.parameters.THY1_pos, self.parameters.THY2_pos))
print("Beam stop = %5gmm" % self.parameters.BS_pos)
print("Beam stop = %s" % self.beam_stop.position)
print("Diode position = %s" % self.diode_pos.position)
print("----------------------------------------------------------\n")
def __info__(self):
print("\n---------------------------------------------------------")
print("mono mode : %s " % self.modes[self.get_mode()]["description"])
print("mono energy : %g " % self.parameters.energy )
print("xtal name : %s " % self.get_crystal() )
print("------------------- MONO MOTORS -------------------------")
print("X2 = %5gmm" % self.X2.position)
print("Y1 = %5gmm Y2 = %5gmm" % (self.Y1.position, self.Y2.position))
print("Z1 = %5gmm Z2(beam gap/offset) = %6.4fmm " % (self.Z1.position, self.Z2.position))
print("Crystals Angles : THY1 = %g THY2 = %g "% (self.THY1.position, self.THY2.position))
print("Beam stop = %5gmm" % self.beam_stop.position)
print("----------------------------------------------------------\n")
info_str = ("---------------------------------------------------------\n")
info_str += ("mono mode : %s \n" % self.modes[self.get_mode()]["description"])
info_str += ("mono energy : %g \n" % self.parameters.energy )
info_str += ("xtal name : %s \n" % self.get_crystal() )
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))
info_str += ("Z1 = %5gmm Z2(beam gap/offset) = %6.4fmm \n" % (self.Z1.position, self.Z2.position))
info_str += ("Crystals Angles : THY1 = %g THY2 = %g \n"% (self.THY1.position, self.THY2.position))
info_str += ("Beam stop = %s \n" % self.beam_stop.position)
info_str += ("Diode position = %s \n" % self.diode_pos.position)
info_str += ("----------------------------------------------------------\n")
return info_str
###############################################################################
......@@ -368,7 +380,7 @@ class Id19Mono(MonochromatorBase):
print("Y1 = %5gmm Y2 = %5gmm" % (self.Y1.position, self.Y2.position))
print("Z1 = %5gmm Z2(beam gap/offset) = %6.4fmm " % (self.Z1.position, self.Z2.position))
print("Crystals Angles : THY1 = %g THY2 = %g "% (self.THY1.position, self.THY2.position))
print("Beam stop = %5gmm" % self.beam_stop.position)
print("Beam stop = %s" % self.beam_stop.position)
print("------------------- Calculated Motor Position--------------")
print("X2 = %5gmm" % X2_pos)
print("Z1 = %5gmm Z2(beam gap/offset) = %6.4fmm " % (Z1_pos, Z2_pos))
......@@ -378,28 +390,51 @@ class Id19Mono(MonochromatorBase):
if answer != "yes" and answer != "y":
return
move_in = True
if self.energy < energy:
move_in = False
print (move_in)
# set energy to requested values only when all movements succeeded
self.energy = 0;
# close FE
print ("Close FrontEnd")
# close bem shutter
print ("Close beam shutter")
#self.beam_shutter.close()
# move crystals to 0 when necessary
if crystals_to_be_moved == True:
standard.umv(self.THY1, 0.0,
self.THY2, 0.0)
# move Z
standard.umv(self.Z1, Z1_pos,
self.Z2, Z2_pos)
# move X2
standard.umv(self.X2, X2_pos)
# move Theta
standard.umv(self.THY1, THY1_pos,
self.THY2, THY2_pos)
umv(self.THY1, 0.0,
self.THY2, 0.0)
if move_in:
# move Z
umv(self.Z1, Z1_pos,
self.Z2, Z2_pos)
# For security move Y2 to the middle and move it back after the X2 movement
# Only do this if X2 > 330 !!!!!!!!
#Y2_act_pos = self.Y2.position
#umv (self.Y2, 90)
# move X2
umv(self.X2, X2_pos)
#umv (self.Y2, Y2_act_pos)
# move Theta
umv(self.THY1, THY1_pos,
self.THY2, THY2_pos)
else:
# move Theta
umv(self.THY1, THY1_pos,
self.THY2, THY2_pos)
# move X2
umv(self.X2, X2_pos)
# move Z
umv(self.Z1, Z1_pos,
self.Z2, Z2_pos)
self.energy = energy
print ("\nMonochromator in %s mode\nwith an energy of %g keV\n" % (self.modes[self.mode]["description"],energy))
......@@ -414,10 +449,12 @@ class Id19Mono(MonochromatorBase):
print ("Waiting %g seconds for stabilisation" % self.stabilization_time)
time.sleep (self.stabilization_time)
# open FE
print ("Open FrontEnd")
# open beam shutter
print ("Open beam shutter")
#self.beam_shutter.open()
# tune
#self.tune()
......@@ -442,20 +479,20 @@ class Id19Mono(MonochromatorBase):
def tune(self):
ct_diode = 0.5
# Crystal 1 rocking curve: (almost paul t1 with resolution 0.0002 deg)
plotselect (diode)
standard.dscan (self.THY1, 0.01, -0.01, 100, ct_diode)
plotselect (self.diode_cnt)
dscan (self.THY1, 0.01, -0.01, 100, ct_diode, save=False)
goto_peak()
time.sleep(1)
def fine_tune(self):
ct_diode = 0.5
plotselect (diode)
standard.dscan (self.THY1, 0.0025, -0.0025, 100, ct_diode)
plotselect (self.diode_cnt)
dscan (self.THY1, 0.0025, -0.0025, 100, ct_diode, save=False)
goto_peak()
time.sleep(1)
standard.mvr (self.THY1, 0.0003)
umvr (self.THY1, 0.0003)
time.sleep(2)
ct(1)
......@@ -495,7 +532,7 @@ class Id19Mono(MonochromatorBase):
# remove diode
print ("Remove diode")
#self.diode_out()
#self.diode_pos.OUT()
# set the mode
print ("Move mono to white beam position")
......@@ -511,13 +548,13 @@ class Id19Mono(MonochromatorBase):
self.safe_position()
print ("Move Y and Z motors")
standard.umv(self.Y1, white_beam["Y1_pos"],
self.Y2, white_beam["Y2_pos"],
self.Z1, white_beam["Z1_pos"],
self.Z2, white_beam["Z2_pos"])
umv(self.Y1, white_beam["Y1_pos"],
self.Y2, white_beam["Y2_pos"],
self.Z1, white_beam["Z1_pos"],
self.Z2, white_beam["Z2_pos"])
# move out beam stop
self.beam_stop_out()
#self.beam_stop.OUT()
self.mode = MonoMode.OUT
self.energy = 0
......@@ -531,39 +568,12 @@ class Id19Mono(MonochromatorBase):
def safe_position(self):
print ("Move THY1 and THY2 to 0")
standard.umv(self.THY1, 0.0,
self.THY2, 0.0)
umv(self.THY1, 0.0,
self.THY2, 0.0)
print ("Move X2 to save position")
if self.X2.position < self.X2_safe_position:
standard.umv(self.X2, self.X2_safe_position + 10) # with a little margin
#
# Beam stop handling
#
def beam_stop_in(self):
#self.beam_stop.move(self.beam_stop_in_pos)
pass
def beam_stop_out(self):
#self.beam_stop.move(self.beam_stop_out_pos)
pass
def is_beam_stop_in(self):
return True
#if self.is_aprox(self.beam_stop.position, self.beam_stop_in_pos, 1):
#return True
#else:
#return False
def is_beam_stop_out(self):
return True
#if self.is_aprox(self.beam_stop.position, self.beam_stop_out_pos, 1):
#return True
#else:
#return False
umv(self.X2, self.X2_safe_position + 10) # with a little margin
#
......
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