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

Commit 603968b3 authored by bliss administrator's avatar bliss administrator

ID19 transfocator to be sure that the slits are closed when using the transfocator.

parent 53d7cf4f
from bliss.controllers.transfocator import Transfocator
from bliss.shell.standard import umv, mv, umvr, mvr
class ID19Transfocator(Transfocator):
def __init__(self, name, config):
self.name = name
self.slit_gaps = config.get("slit_gaps")
self.slit_gap_positions = config.get("slit_gap_positions")
# Initialise the Transfocator class
super().__init__(name, config)
def close_slits(self):
# move slits onlt when necessary
if self.slit_gaps[0].position > self.slit_gap_positions[0] and \
self.slit_gaps[1].position > self.slit_gap_positions[1]:
umv (self.slit_gaps[0], self.slit_gap_positions[0], self.slit_gaps[1], self.slit_gap_positions[1])
# Switching off motors does not help! When entering the Bliss session,
# the motors are switched on again!
## switch off slit motors
#slit_axes = self.slit_gaps[0].controller.axes
#slit_axes_names = slit_axes.keys()
#print("Switching off slit motors!")
#for i in slit_axes_names:
#try:
#slit_axes[i].off()
#except NotImplementedError:
#pass
else:
pass
#print("Slits are closed!")
def enable_slits(self):
# Switching off motors does not help! When entering the Bliss session,
# the motors are switched on again!
## switch on slit motors
#slit_axes = self.slit_gaps[0].controller.axes
#slit_axes_names = slit_axes.keys()
#for i in slit_axes_names:
#try:
#slit_axes[i].on()
#except NotImplementedError:
#pass
pass
def set_n(self, *idx_values):
""" Set the lenses. Check if there is a security pinhole to be set.
To be used by __setitem__()
Args:
(list): Lense index, lens value
"""
bits = self.pos_read()
for idx, value in zip(idx_values[::2], idx_values[1::2]):
if value is None or idx in self.empty_jacks:
continue
else:
if self._encode(value):
bits |= 1 << idx
else:
bits &= 0xFFFFFFFF ^ (1 << idx)
if self.safety and bits and self.pinhole:
for pinhole in self.pinhole:
bits |= 1 << pinhole
if self.pos_read() == bits:
# nothing to do
return
# Be sure primary slits are closed
self.close_slits()
self.tfstatus_set(bits)
def set_bitvalue(self, value):
""" Set bit values checking if there is a security pinhole to set.
Args:
(value): lens bit value
"""
if self.safety and value and self.pinhole:
for pinhole in self.pinhole:
value |= 1 << pinhole
# Be sure primary slits are closed
self.close_slits()
self.tfstatus_set(value)
def _encode(self, status):
if status in (1, "in", "IN", True):
return True
if status in (0, "out", "OUT", False):
return False
raise ValueError("Invalid position {!r}".format(status))
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