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

Commit ec79f666 authored by Emmanuel Papillon's avatar Emmanuel Papillon

added fastshutter

use it in tdxrd count preset
parent 03c0a559
from bliss.config.settings import HashObjSetting
#from bliss.common.shutter import BaseShutter, BaseShutterState
from bliss import current_session
class FastShutter:
def __init__(self, name, config):
super().__init__()
self.__name = name
self.__config = config
self.__shutter_mux = config["shutter_mux"]
self.__session_mux = config["session_mux"]
self.__settings = HashObjSetting(f"fastshutter:{name}")
self.__time = None
@property
def name(self):
return self.__name
@property
def config(self):
return self.__config
def __info__(self):
info = f"FastShutter [{self.name}]:\n"
info += f"Controlled by session = {self.session}\n"
info += f"Shutter polarity = {self.polarity}\n"
info += f"Shutter mode = {self.mode}\n"
info += f"Shutter time = {self.shutter_time:.3f} sec\n"
return info
@property
def session(self):
return self.__session_mux.getOutputStat("SHUTTER_SESSION")
@session.setter
def session(self, value):
self.__session_mux.switch("SHUTTER_SESSION", value.upper())
def __check_session(self):
current = current_session.name.upper()
if current != self.session:
print("!!! FastShutter WARNING !!!")
print(f"Session [{self.session}] is now controlling shutter")
print("Current session has NO control !!!\n")
@property
def polarity(self):
return self.__shutter_mux.getOutputStat("SHUTTER_POLARITY")
@polarity.setter
def polarity(self, value):
self.__shutter_mux.switch("SHUTTER_POLARITY", value.upper())
@property
def shutter_time(self):
if self.__time is None:
self.__time = self.__settings.get("time", 0.)
return self.__time
@shutter_time.setter
def shutter_time(self, value):
self.__settings["time"] = value
self.__time = None
def open(self, wait=False):
self.__check_session()
self.__shutter_mux.switch("SHUTTER", "OPEN")
if wait:
gevent.sleep(self.shutter_time)
def close(self, wait=False):
self.__check_session()
self.__shutter_mux.switch("SHUTTER", "CLOSE")
if wait:
gevent.sleep(self.shutter_time)
@property
def state(self):
return self.__shutter_mux.getOutputStat("SHUTTER")
@property
def mode(self):
return self.__shutter_mux.getOutputStat("SHUTTER")
@mode.setter
def mode(self, value):
self.__shutter_mux.switch("SHUTTER", value.upper())
......@@ -17,22 +17,28 @@ def set_frelon_soft():
class CountMuxPreset(ChainPreset):
def __init__(self, opmux):
def __init__(self, opmux, fsh):
self.opmux = opmux
self.fsh = fsh
def prepare(self, chain):
devused = [ node.name for node in chain.nodes_list ]
frelons = [ name for name in devused if name.startswith("frelon") ]
frelon2mux = {
# --- shutter
frelonnodes = [ node for node in chain.nodes_list if node.name.startswith("frelon") ]
frelon2shutter = {
"frelon1": "CAM1",
"frelon2": "CAM2",
"frelon3": "CAM3",
}
shutter = "COUNTER"
if frelons:
shutter = frelon2mux.get(frelons[0], shutter)
shutter_mode = "COUNTER"
for node in frelonnodes:
dev = node.device
if dev.name in frelon2shutter:
shutter_mode = frelon2shutter[dev.name]
dev.shutter.close_time = self.fsh.shutter_time
break
self.fsh.mode = shutter_mode
self.opmux.switch("SHUTTER", shutter)
# --- triggers
self.opmux.switch("TRIGGER_MODE", "COUNTER_CARD")
self.opmux.switch("CAM1", "ON")
self.opmux.switch("CAM2", "ON")
......
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