MAde camera class work

This commit is contained in:
2020-10-07 23:27:49 +02:00
parent 5d83c86cd2
commit 778e34ce8a
9 changed files with 219 additions and 116 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ from ..acquisition.utilities import Acquisition
class Daq:
def __init__(
self,
broker_address="http://sf-daq-1:10002",
broker_address="http://sf-daq:10002",
timeout=10,
pgroup=None,
pulse_id_adj=None,
+4 -4
View File
@@ -55,11 +55,11 @@ class Alias:
name = [self.alias]
parent = self.parent
while not parent == None:
if (parent is base) or (parent is None):
if (not (base is None) and (parent is base.alias)) or (parent is None):
break
name.append(parent.alias)
parent = parent.__dict__.get("parent", None)
if joiner:
return joiner.join(reversed(name))
else:
@@ -81,8 +81,8 @@ def find_aliases(*args):
def append_object_to_object(obj_target, obj_init, *args, name=None, **kwargs):
"""append a new object to another object together with the alias.
The new object needs to be defined with a name keyword. Theadditional
"""append a new object to another object together with the alias.
The new object needs to be defined with a name keyword. Theadditional
args and kwargs are the expected input for the new opject."""
obj_target.__dict__[name] = obj_init(*args, **kwargs, name=name)
obj_target.alias.append(obj_target.__dict__[name].alias)
+33 -31
View File
@@ -45,12 +45,12 @@ components = [
"desc": "run table for data acquisition",
"type": "eco.utilities.runtable:Run_Table",
"kwargs": {
"pgroup": config["pgroup"],
"pgroup": config["pgroup"],
"spreadsheet_key": config["gspread_notebook_id"],
"devices": None,
"devices": None,
"alias_namespace": None,
"channels_ca": Component("_env_channels_ca")
},
"channels_ca": Component("_env_channels_ca"),
},
"lazy": False,
},
{
@@ -64,7 +64,9 @@ components = [
"name": "elog",
"type": "eco.utilities.elog:Elog",
"args": ["https://elog-gfa.psi.ch/Bernina"],
"kwargs": {"screenshot_directory": "/tmp",},
"kwargs": {
"screenshot_directory": "/tmp",
},
},
{
"name": "screenshot",
@@ -110,14 +112,14 @@ components = [
"z_und": 53,
"desc": "Attenuator in Front End",
},
#{
# {
# "name": "mon_und",
# "z_und": 53,
# "desc": "Intensity/position monitor after Optics hutch",
# "type": "eco.xdiagnostics.intensity_monitors:SolidTargetDetectorPBPS",
# "args": ["SARFE10-PBPS053"],
# "kwargs": {},
#},
# },
{
"name": "xspect",
"z_und": 53,
@@ -208,35 +210,35 @@ components = [
"type": "eco.xoptics.pp:Pulsepick",
"lazy": False,
},
#{
# {
# "name": "mon_opt_old",
# "z_und": 133,
# "desc": "Intensity/position monitor after Optics hutch",
# "type": "eco.xdiagnostics.intensity_monitors:SolidTargetDetectorPBPS",
# "args": ["SAROP21-PBPS133"],
# "kwargs": {"VME_crate": "SAROP21-CVME-PBPS1", "link": 9},
#},
# },
{
"name": "mon_opt",
"z_und": 133,
"desc": "Intensity/position monitor after Optics hutch",
"type": "eco.xdiagnostics.intensity_monitors:SolidTargetDetectorPBPS_new",
"args": ["SAROP21-PBPS133"],
"kwargs": {
"VME_crate": "SAROP21-CVME-PBPS1",
"link": 9,
"channels": {
"up": "SLAAR21-LSCP1-FNS:CH6:VAL_GET",
"down": "SLAAR21-LSCP1-FNS:CH7:VAL_GET",
"left": "SLAAR21-LSCP1-FNS:CH4:VAL_GET",
"right": "SLAAR21-LSCP1-FNS:CH5:VAL_GET",
},
"calc": {
"itot": "SLAAR21-LTIM01-EVR0:CALCI",
"xpos": "SLAAR21-LTIM01-EVR0:CALCX",
"ypos": "SLAAR21-LTIM01-EVR0:CALCY",
},
},
"name": "mon_opt",
"z_und": 133,
"desc": "Intensity/position monitor after Optics hutch",
"type": "eco.xdiagnostics.intensity_monitors:SolidTargetDetectorPBPS_new",
"args": ["SAROP21-PBPS133"],
"kwargs": {
"VME_crate": "SAROP21-CVME-PBPS1",
"link": 9,
"channels": {
"up": "SLAAR21-LSCP1-FNS:CH6:VAL_GET",
"down": "SLAAR21-LSCP1-FNS:CH7:VAL_GET",
"left": "SLAAR21-LSCP1-FNS:CH4:VAL_GET",
"right": "SLAAR21-LSCP1-FNS:CH5:VAL_GET",
},
"calc": {
"itot": "SLAAR21-LTIM01-EVR0:CALCI",
"xpos": "SLAAR21-LTIM01-EVR0:CALCX",
"ypos": "SLAAR21-LTIM01-EVR0:CALCY",
},
},
},
{
"name": "prof_opt",
@@ -269,7 +271,7 @@ components = [
"kwargs": {},
"z_und": 136,
"desc": "Bernina beamline reference laser before KBs",
"type": "eco.xoptics.reflaser:RefLaser_Aramis",
"type": "eco.xoptics.reflaser_new:RefLaser_Aramis",
},
{
"name": "slit_att",
@@ -365,7 +367,7 @@ components = [
"desc": "Xray diffractometer",
"type": "eco.endstations.bernina_diffractometers:XRD_new",
"kwargs": {"Id": "SARES21-XRD", "configuration": config["xrd_config"]},
"lazy":False,
"lazy": False,
},
{
"args": [],
+16
View File
@@ -521,3 +521,19 @@ class AdjustableVirtual:
vals = self._foo_set_target_value_current_value(value)
for adj, val in zip(self._adjustables, vals):
adj.set_current_value(val)
@default_representation
@spec_convenience
class AdjustableGetSet:
def __init__(self, foo_get, foo_set, name=None):
self.alias = Alias(name)
self.name = name
self._set = foo_set
self._get = foo_get
def set_target_value(self,value):
return Changer(target=value, parent=self, changer=self._set, hold=False, stopper=None)
def get_current_value(self):
return self._get()
+35 -33
View File
@@ -1,51 +1,53 @@
from ..aliases import Alias, append_object_to_object
from .adjustable import PvRecord, PvEnum
from .adjustable import PvRecord, PvEnum, AdjustableGetSet
from ..elements import Assembly
class CameraBasler:
class CameraBasler(Assembly):
def __init__(self, pvname, name=None):
super().__init__(name=name)
self.pvname = pvname
self.name = name
self.alias = Alias(name)
append_object_to_object(self, PvEnum, self.pvname + ":INIT", name="initialize")
append_object_to_object(self, PvEnum, self.pvname + ":CAMERA", name="running")
append_object_to_object(self, PvRecord, self.pvname + ":BOARD", name="board_no")
append_object_to_object(
self, PvRecord, self.pvname + ":SERIALNR", name="serial_no"
self._append(PvEnum, self.pvname + ":INIT", name="initialize")
self._append(PvEnum, self.pvname + ":CAMERA", name="running")
self._append(PvRecord, self.pvname + ":BOARD", name="board_no")
self._append(PvRecord, self.pvname + ":SERIALNR", name="serial_no"
)
append_object_to_object(
self, PvRecord, self.pvname + ":EXPOSURE", name="_exposure_time"
self._append(PvRecord, self.pvname + ":EXPOSURE", name="_exposure_time"
)
append_object_to_object(
self, PvEnum, self.pvname + ":ACQMODE", name="_acq_mode"
self._append(PvEnum, self.pvname + ":ACQMODE", name="_acq_mode"
)
append_object_to_object(
self, PvEnum, self.pvname + ":RECMODE", name="_req_mode"
self._append(PvEnum, self.pvname + ":RECMODE", name="_req_mode"
)
append_object_to_object(
self, PvEnum, self.pvname + ":STOREMODE", name="_store_mode"
self._append(PvEnum, self.pvname + ":STOREMODE", name="_store_mode"
)
append_object_to_object(self, PvRecord, self.pvname + ":BINY", name="_binx")
append_object_to_object(self, PvRecord, self.pvname + ":BINY", name="_biny")
append_object_to_object(
self, PvRecord, self.pvname + ":REGIONX_START", name="_roixmin"
self._append(PvRecord, self.pvname + ":BINY", name="_binx")
self._append(PvRecord, self.pvname + ":BINY", name="_biny")
self._append(PvRecord, self.pvname + ":REGIONX_START", name="_roixmin"
)
append_object_to_object(
self, PvRecord, self.pvname + ":REGIONX_END", name="_roixmax"
self._append(PvRecord, self.pvname + ":REGIONX_END", name="_roixmax"
)
append_object_to_object(
self, PvRecord, self.pvname + ":REGIONY_START", name="_roiymin"
self._append(PvRecord, self.pvname + ":REGIONY_START", name="_roiymin"
)
append_object_to_object(
self, PvRecord, self.pvname + ":REGIONY_END", name="_roiymax"
self._append(PvRecord, self.pvname + ":REGIONY_END", name="_roiymax"
)
append_object_to_object(
self, PvEnum, self.pvname + ":SET_PARAM", name="_set_parameters"
self._append(PvEnum, self.pvname + ":SET_PARAM", name="_set_parameters"
)
append_object_to_object(
self, PvEnum, self.pvname + ":TRIGGER", name="trigger_on"
self._append(PvEnum, self.pvname + ":TRIGGER", name="trigger_on"
)
append_object_to_object(
self, PvEnum, self.pvname + ":TRIGGERSOURCE", name="trigger_source"
self._append(PvRecord, self.pvname + ":AMPGAIN", name="_gain"
)
self._append(PvEnum, self.pvname + ":TRIGGERSOURCE", name="trigger_source"
)
# append_object_to_object(self,PvEnum,self.pvname+':TRIGGEREDGE',name='trigger_edge')
self._append(AdjustableGetSet,self._exposure_time.get_current_value,lambda value:self._set_params((self._exposure_time,value)),name='exposure_time')
self._append(AdjustableGetSet,self._gain.get_current_value,lambda value:self._set_params((self._gain,value)),name='gain')
def _set_params(self,*args):
self.running(0)
for ob,val in args:
ob(val)
self._set_parameters(1)
self.running(1)
+1
View File
@@ -0,0 +1 @@
from .assembly import Assembly
+33 -18
View File
@@ -2,45 +2,60 @@ from ..aliases import Alias
from tabulate import tabulate
import colorama
class Assembly:
def __init__(self,name=None,is_alias=True):
def __init__(self, name=None, is_alias=True):
self.name = name
if is_alias:
self.alias = Alias(name)
self.settings = []
self.status_indicators = []
def _append(self,foo_obj_init, *args, name=None, is_setting=False, is_status=True, is_alias=True, **kwargs):
def _append(
self,
foo_obj_init,
*args,
name=None,
is_setting=False,
is_status=True,
is_alias=True,
**kwargs
):
self.__dict__[name] = foo_obj_init(*args, **kwargs, name=name)
if is_alias:
self.alias.append(self.__dict__[name].alias)
if is_setting:
self.settings.append(self.__dict__[name])
if (not is_setting) and is_status :
if (not is_setting) and is_status:
self.status_indicators.append(self.__dict__[name])
def get_status(self):
return {
'settings':{ts.alias.get_full_name(base=self):ts.get_current_value() for ts in self.settings},
'status_indicators':{ts.alias.get_full_name(base=self):ts.get_current_value() for ts in self.status_indicators},
}
"settings": {
ts.alias.get_full_name(base=self): ts.get_current_value()
for ts in self.settings
},
"status_indicators": {
ts.alias.get_full_name(base=self): ts.get_current_value()
for ts in self.status_indicators
},
}
def status(self):
def status(self, get_string=False):
stat = self.get_status()
s = tabulate(
[[colorama.Style.BRIGHT+name+colorama.Style.RESET_ALL, value] for name,value in stat['settings'].items()]
+[[name, value] for name,value in stat['status_indicators'].items()]
[
[colorama.Style.BRIGHT + name + colorama.Style.RESET_ALL, value]
for name, value in stat["settings"].items()
]
+ [[name, value] for name, value in stat["status_indicators"].items()]
)
return s
if get_string:
return s
else:
print(s)
def __repr__(self):
stat = self.get_status()
s = tabulate([[name, value] for name,value in stat['status_indicators'].items()])
s = tabulate([[name, value] for name, value in stat["settings"].items()])
return s
+89 -29
View File
@@ -1,7 +1,7 @@
import sys
sys.path.append("..")
from ..devices_general.motors import MotorRecord
from ..devices_general.motors import MotorRecord, MotorRecord_new
from ..devices_general.adjustable import PvRecord
from epics import PV
@@ -100,45 +100,67 @@ class XRD_new(Assembly):
if "base" in self.configuration:
### motors base platform ###
### motors base platform ###
self._append(MotorRecord,Id + ":MOT_TX", name="xbase")
self._append(MotorRecord,Id + ":MOT_TY", name="ybase")
self._append(MotorRecord,Id + ":MOT_RX", name="rxbase")
self._append(MotorRecord,Id + ":MOT_MY_RYTH", name="alpha")
self._append(MotorRecord_new, Id + ":MOT_TX", name="xbase", is_setting=True)
self._append(MotorRecord_new, Id + ":MOT_TY", name="ybase", is_setting=True)
self._append(
MotorRecord_new, Id + ":MOT_RX", name="rxbase", is_setting=True
)
self._append(
MotorRecord_new, Id + ":MOT_MY_RYTH", name="alpha", is_setting=True
)
if "arm" in self.configuration:
### motors XRD detector arm ###
self._append(MotorRecord,Id + ":MOT_NY_RY2TH", name="gamma")
self._append(MotorRecord,Id + ":MOT_DT_RX2TH", name="delta")
self._append(
MotorRecord_new, Id + ":MOT_NY_RY2TH", name="gamma", is_setting=True
)
self._append(
MotorRecord_new, Id + ":MOT_DT_RX2TH", name="delta", is_setting=True
)
### motors XRD area detector branch ###
self._append(MotorRecord,Id + ":MOT_D_T", name="tdet")
self._append(MotorRecord_new, Id + ":MOT_D_T", name="tdet", is_setting=True)
### motors XRD polarisation analyzer branch ###
self._append(MotorRecord,Id + ":MOT_P_T", name="tpol")
self._append(MotorRecord_new, Id + ":MOT_P_T", name="tpol", is_setting=True)
# missing: slits of flight tube
if "hlxz" in self.configuration:
### motors heavy load goniometer ###
self._append(MotorRecord,Id + ":MOT_TBL_TX", name="xhl")
self._append(MotorRecord,Id + ":MOT_TBL_TZ", name="zhl")
self._append(
MotorRecord_new, Id + ":MOT_TBL_TX", name="xhl", is_setting=True
)
self._append(
MotorRecord_new, Id + ":MOT_TBL_TZ", name="zhl", is_setting=True
)
if "hly" in self.configuration:
self._append(MotorRecord,Id + ":MOT_TBL_TY", name="yhl")
self._append(
MotorRecord_new, Id + ":MOT_TBL_TY", name="yhl", is_setting=True
)
if "hlrxrz" in self.configuration:
try:
self._append(MotorRecord,Id + ":MOT_TBL_RX", name="rxhl")
self._append(
MotorRecord_new, Id + ":MOT_TBL_RX", name="rxhl", is_setting=True
)
except:
print("XRD.rxhl not found")
pass
try:
self._append(MotorRecord,Id + ":MOT_TBL_RY", name="rzhl")
self._append(
MotorRecord_new, Id + ":MOT_TBL_RY", name="rzhl", is_setting=True
)
except:
print("XRD.rzhl not found")
pass
if "phi_table" in self.configuration:
### motors nu table ###
self._append(MotorRecord,Id + ":MOT_HEX_TX", name="tphi")
self._append(MotorRecord,Id + ":MOT_HEX_RX", name="phi")
self._append(
MotorRecord_new, Id + ":MOT_HEX_TX", name="tphi", is_setting=True
)
self._append(
MotorRecord_new, Id + ":MOT_HEX_RX", name="phi", is_setting=True
)
if "phi_hex" in self.configuration:
### motors PI hexapod ###
@@ -186,14 +208,39 @@ class XRD_new(Assembly):
)
if "kappa" in self.configuration:
self._append(MotorRecord,"SARES21-XRD:MOT_KAP_KRX", name="eta")
self._append(MotorRecord, "SARES21-XRD:MOT_KAP_KAP", name="kappa")
self._append(MotorRecord, "SARES21-XRD:MOT_KAP_KPH", name="phi")
self._append(MotorRecord, "SARES21-XRD:MOT_KAP_DTY", name="zkap")
self._append(MotorRecord, "SARES21-XRD:MOT_KAP_DTX", name="xkap")
self._append(MotorRecord, "SARES21-XRD:MOT_KAP_DTZ", name="ykap")
self._append(MotorRecord, "SARES21-XRD:MOT_KAP_DRX", name="rxkap")
self._append(MotorRecord, "SARES21-XRD:MOT_KAP_DRZ", name="rykap")
self._append(
MotorRecord_new, "SARES21-XRD:MOT_KAP_KRX", name="eta", is_setting=True
)
self._append(
MotorRecord_new,
"SARES21-XRD:MOT_KAP_KAP",
name="kappa",
is_setting=True,
)
self._append(
MotorRecord_new, "SARES21-XRD:MOT_KAP_KPH", name="phi", is_setting=True
)
self._append(
MotorRecord_new, "SARES21-XRD:MOT_KAP_DTY", name="zkap", is_setting=True
)
self._append(
MotorRecord_new, "SARES21-XRD:MOT_KAP_DTX", name="xkap", is_setting=True
)
self._append(
MotorRecord_new, "SARES21-XRD:MOT_KAP_DTZ", name="ykap", is_setting=True
)
self._append(
MotorRecord_new,
"SARES21-XRD:MOT_KAP_DRX",
name="rxkap",
is_setting=True,
)
self._append(
MotorRecord_new,
"SARES21-XRD:MOT_KAP_DRZ",
name="rykap",
is_setting=True,
)
def get_adjustable_positions_str(self):
ostr = "*****XRD motor positions******\n"
@@ -207,13 +254,20 @@ class XRD_new(Assembly):
def gui(self, guiType="xdm"):
""" Adjustable convention"""
cmd = ["caqtdm", "-macro"]
cmd = ['-noMsg', '-stylefile', 'sfop.qss','-macro', 'P=SARES21-XRD', '/sf/common/config/qt/ESB_XRD_exp.ui']
cmd = [
"-noMsg",
"-stylefile",
"sfop.qss",
"-macro",
"P=SARES21-XRD",
"/sf/common/config/qt/ESB_XRD_exp.ui",
]
return subprocess.Popen(" ".join(cmd), shell=True)
# def __repr__(self):
# return self.get_adjustable_positions_str()
class XRD:
def __init__(self, name=None, Id=None, configuration=["base"]):
"""X-ray diffractometer platform in AiwssFEL Bernina.\
@@ -350,9 +404,15 @@ class XRD:
def gui(self, guiType="xdm"):
""" Adjustable convention"""
cmd = ["caqtdm", "-macro"]
cmd = ['-noMsg', '-stylefile', 'sfop.qss','-macro', 'P=SARES21-XRD', '/sf/common/config/qt/ESB_XRD_exp.ui']
cmd = [
"-noMsg",
"-stylefile",
"sfop.qss",
"-macro",
"P=SARES21-XRD",
"/sf/common/config/qt/ESB_XRD_exp.ui",
]
return subprocess.Popen(" ".join(cmd), shell=True)
def __repr__(self):
return self.get_adjustable_positions_str()
+7
View File
@@ -14,6 +14,7 @@ class RefLaser_Aramis:
self._inpos = inpos
self._outpos = outpos
self.mirrmotortest = MotorRecord(self.Id + ":MOTOR_1")
self.mirrmotortest.set_limits(-20, 0)
def __call__(self, *args, **kwargs):
self.set(*args, **kwargs)
@@ -50,5 +51,11 @@ class RefLaser_Aramis:
else:
self.mirrmotortest.set_target_value(self._outpos)
def movein(self):
self.set("in")
def moveout(self):
self.set("out")
def __repr__(self):
return self.__str__()