diff --git a/eco/aliases/aliases.py b/eco/aliases/aliases.py index 57f2da3..549915d 100644 --- a/eco/aliases/aliases.py +++ b/eco/aliases/aliases.py @@ -53,6 +53,14 @@ def find_aliases(*args): obj = obj.alias return tuple(o) +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 + 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) + + class Namespace: def __init__(self, namespace_file=None): diff --git a/eco/bernina/config.py b/eco/bernina/config.py index 5843953..d022265 100755 --- a/eco/bernina/config.py +++ b/eco/bernina/config.py @@ -263,33 +263,32 @@ components = [ "desc": "Mobile X-ray eye in Bernina hutch", "type": "eco.xdiagnostics.profile_monitors:Bernina_XEYE", "kwargs": { + "zoomstage_pv": config["xeye"]["zoomstage_pv"], "bshost": "sf-daqsync-01.psi.ch", "bsport": 11151, - "Id": "SARES20-PROF142-M3", }, }, { "args": [], - "name": "qioptic", + "name": "cams_qioptiq", "z_und": 142, "desc": "Qioptic sample viewer in Bernina hutch", - "type": "eco.endstations.bernina_cameras:Qioptic", + "type": "eco.endstations.bernina_cameras:Qioptiq", "kwargs": { "bshost": "sf-daqsync-01.psi.ch", "bsport": 11149, - "Id": "SARES20-PROF142-M2", + "zoomstage_pv": config['cams_qioptiq']['zoomstage_pv'], }, }, { "args": [], - "name": "cams142_C1", + "name": "cams_sigma", "z_und": 142, "desc": "Sigma objective", "type": "eco.endstations.bernina_cameras:Sigma", "kwargs": { "bshost": "sf-daqsync-01.psi.ch", "bsport": 11149, - "Id": "SARES20-CAMS142-C1", }, }, { diff --git a/eco/endstations/bernina_cameras.py b/eco/endstations/bernina_cameras.py index ffa690a..e0f15db 100755 --- a/eco/endstations/bernina_cameras.py +++ b/eco/endstations/bernina_cameras.py @@ -1,7 +1,7 @@ from ..devices_general.motors import MotorRecord from ..devices_general.detectors import CameraCA, CameraBS from ..devices_general.adjustable import PvRecord -from ..aliases import Alias +from ..aliases import Alias,append_object_to_object # from ..devices_general.epics_wrappers import EnumSelector from epics import PV @@ -19,16 +19,15 @@ def addPvRecordToSelf(self, name=None, pvsetname=None, pvreadbackname = None, ac class Sigma: - def __init__(self, Id, bshost=None, bsport=None, name=None): + def __init__(self, zoomstage_pvs = {'set_value':'SARES20-OPSI:MOT_SP','readback':'SEARES20-OPSI:MOT_RB'}, bshost=None, bsport=None, name=None): self.alias = Alias(name) - self.Id = Id + self.name = name - addPvRecordToSelf(self, name="zoom", pvsetname="SARES20-OPSI:MOT_SP", pvreadbackname = "SARES20-OPSI:MOT_RB") + append_object_to_object + if zoomstage_pvs: + append_object_to_object(self, PvRecord, name="zoom", pvsetname=zoomstage_pvs['set_value'], pvreadbackname = zoomstage_pvs['readback']) - #except: - # print("Sigma zoom motor not found") - # pass try: self.cam = CameraCA(Id) except: @@ -52,17 +51,15 @@ class Sigma: -class Qioptic: - def __init__(self, Id, bshost=None, bsport=None, name=None): +class Qioptiq: + def __init__(self, zoomstage_pv=None, bshost=None, bsport=None, name=None): self.alias = Alias(name) - self.Id = Id - try: - addMotorRecordToSelf(self, Id="SARES20-EXP:MOT_QIOPT_Z", name="zoom") + self.name = name + + if zoomstage_pv: + append_object_to_object(self,MotorRecord,zoomstage_pv, name="zoom") - except: - print("Qioptic zoom motor not found") - pass try: addMotorRecordToSelf(self, Id="SARES20-EXP:MOT_QIOPT_F", name="focus") diff --git a/eco/xdiagnostics/profile_monitors.py b/eco/xdiagnostics/profile_monitors.py index ca94036..42b80cb 100755 --- a/eco/xdiagnostics/profile_monitors.py +++ b/eco/xdiagnostics/profile_monitors.py @@ -1,6 +1,6 @@ from ..devices_general.motors import MotorRecord from ..devices_general.detectors import CameraCA, CameraBS -from ..aliases import Alias +from ..aliases import Alias, append_object_to_object from ..devices_general.adjustable import PvEnum # from ..devices_general.epics_wrappers import EnumSelector @@ -41,16 +41,11 @@ class Pprm: class Bernina_XEYE: - def __init__(self, Id, bshost=None, bsport=None, name=None): + def __init__(self, zoomstage_pv=None,bshost=None, bsport=None, name=None): self.alias = Alias(name) - - self.Id = Id - try: - addMotorRecordToSelf(self, Id="SARES20-EXP:MOT_NAV_Z", name="zoom") - - except: - print("X-Ray eye zoom motor not found") - pass + self.name = name + if zoomstage_pv: + append_object_to_object(self,MotorRecord,zoomstage_pv,name='zoom') try: self.cam = CameraCA(Id) except: