Commit 7ff1b616 authored by bliss administrator's avatar bliss administrator
Browse files

Tested, but needs to be cleaned-up

parent a3b7ba55
......@@ -40,8 +40,6 @@ 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.laue_THY1_offset = self.config["laue_THY1_offset"]
self.laue_THY2_offset = self.config["laue_THY2_offset"]
......@@ -75,7 +73,6 @@ 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['energy'] = 0
param_defaults['xtal_name'] = "Si111"
......@@ -112,7 +109,7 @@ 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]
......@@ -125,7 +122,7 @@ class Id19Mono(MonochromatorBase):
self.Z2, mono_mode["beam_offset"])
print ("Move diode in")
#self.diode_pos.IN()
self.diode_pos.IN()
self.mode = mode
self.energy = 0
......@@ -173,7 +170,6 @@ 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.mode = self.mode
self.parameters.energy = self.energy
......@@ -220,7 +216,8 @@ class Id19Mono(MonochromatorBase):
print ("Theta angle < 0.01, cannot calculte energy!")
else:
energy = self.bragg2energy(theta_angle)
print ("The monochromator is at %g keV \n\n" % energy)
print ("\nEnergy from theta angle: %g keV" % energy)
print ("Last applied energy : %g kev \n" % self.parameters.energy)
def wl(self):
theta_angle = self.get_theta()
......@@ -306,7 +303,7 @@ class Id19Mono(MonochromatorBase):
space_available = 0.5 * self.xtal_size - (security_margin / math.sin(math.radians(theta_angle)))
half_beam_projection = 0.5 * beam_vertical_size / (math.sin(math.radians(theta_angle)))
# ######## Attetion!!!! half_beam_projection > space_available (because of secu_margin along z)!
# ######## Attention!!!! half_beam_projection > space_available (because of secu_margin along z)!
# ######## !!!!! the absolute value of the top_beam_place must be used
top_beam_place = math.fabs(space_available - half_beam_projection)
......@@ -338,7 +335,7 @@ class Id19Mono(MonochromatorBase):
# risky config -> X2 limited to 300
print("necessary to move Z2 \n")
Z2_correction = (X2_calc - (X2_pos + horizontal_disp_Xtal)) * math.tan(math.radians(2*theta_angle))
Z2_correction = (X2_calc - (X2_pos + horizontal_displacement_xtal)) * math.tan(math.radians(2*theta_angle))
Z2_calc = Z2_pos + Z2_correction
if Z2_calc > Z2_high_limit:
Z2_pos = Z2_lim
......@@ -390,11 +387,6 @@ 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;
......@@ -407,19 +399,33 @@ class Id19Mono(MonochromatorBase):
umv(self.THY1, 0.0,
self.THY2, 0.0)
if move_in:
# For security move Y2 to the middle and move it back after the X2 movement
# Only do this if X2 > 330 !!!!!!!!
move_y2 = False
if self.X2.position > self.X2_safe_position or X2_pos > self.X2_safe_position:
Y2_act_pos = self.Y2.position
move_y2 = True
# determine the order of movementes in critical positions
move_to_lower_energy = True
if self.calc_energy() > e_min:
if self.calc_energy() < energy:
move_to_lower_energy = False
print (move_to_lower_energy)
# The movement order depend on the direction we want to move!
if move_to_lower_energy:
# 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)
if move_y2 == True:
umv (self.Y2, 90) # move in the middle
# move X2
umv(self.X2, X2_pos)
#umv (self.Y2, Y2_act_pos)
if move_y2 == True:
umv (self.Y2, Y2_act_pos)
# move Theta
umv(self.THY1, THY1_pos,
......@@ -429,8 +435,12 @@ class Id19Mono(MonochromatorBase):
umv(self.THY1, THY1_pos,
self.THY2, THY2_pos)
if move_y2 == True:
umv (self.Y2, 90) # move in the middle
# move X2
umv(self.X2, X2_pos)
umv(self.X2, X2_pos)
if move_y2 == True:
umv (self.Y2, Y2_act_pos)
# move Z
umv(self.Z1, Z1_pos,
......@@ -440,7 +450,7 @@ class Id19Mono(MonochromatorBase):
print ("\nMonochromator in %s mode\nwith an energy of %g keV\n" % (self.modes[self.mode]["description"],energy))
#
# Store the positions for the applied mode
# Store the positions for the applied energy
#
self.store_config()
......@@ -467,10 +477,10 @@ class Id19Mono(MonochromatorBase):
theta_angle = self.get_theta()
old_e = self.bragg2energy(theta_angle) * 1000 # conversion to eV
old_e = self.bragg2energy(theta_angle) * 1000 # conversion to eV
new_e = (old_e + delta_energy) / 1000 # in keV
print ("Old energy = %g \t new energy = %g" % (old_e, new_e) )
print ("Old energy = %g \t new energy = %g" % ((old_e/1000), new_e) )
self.mve(new_e, relative = True)
#
......@@ -501,7 +511,6 @@ class Id19Mono(MonochromatorBase):
if self.mode == MonoMode.UNDEFINED or self.mode == MonoMode.OUT:
raise ValueError ("No valid monochromator mode applied!")
#beam_gap = self.modes[self.get_mode()]["beam_offset"]
beam_gap = self.modes[self.mode]["beam_offset"]
distance = beam_gap / math.tan(2 * math.radians(angle))
return distance
......@@ -532,7 +541,7 @@ class Id19Mono(MonochromatorBase):
# remove diode
print ("Remove diode")
#self.diode_pos.OUT()
self.diode_pos.OUT()
# set the mode
print ("Move mono to white beam position")
......@@ -554,7 +563,7 @@ class Id19Mono(MonochromatorBase):
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
......@@ -603,3 +612,6 @@ class Id19Mono(MonochromatorBase):
return True
else:
return False
def calc_energy(self):
return self.bragg2energy(self.get_theta())
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