diff --git a/eco/aliases/aliases.py b/eco/aliases/aliases.py index 0572671..398542e 100644 --- a/eco/aliases/aliases.py +++ b/eco/aliases/aliases.py @@ -108,13 +108,13 @@ class Namespace: @property def aliases(self): - if not self.data: + if self.data is None: self.read_file() return [td["alias"] for td in self.data] @property def channels(self): - if not self.data: + if self.data is None: self.read_file() return [td["channel"] for td in self.data] diff --git a/eco/bernina/bernina.py b/eco/bernina/bernina.py index 9642cb4..3fca0c6 100644 --- a/eco/bernina/bernina.py +++ b/eco/bernina/bernina.py @@ -1,13 +1,13 @@ -# init() -import sys from .config import components +from .config import config as config_bernina +from ..utilities.config import Namespace from ..aliases import NamespaceCollection -from ..utilities.config import Component, Namespace namespace = Namespace( name="bernina", root_module=__name__, alias_namespace=NamespaceCollection().bernina ) +namespace.alias_namespace.data = [] # adding all stuff from the config components the "old" way of configuring. for tk in components: @@ -37,6 +37,6 @@ namespace.append_obj( ) -# def __getattr__(*args, **kwargs): +# def __getattr__(*args, **kwargs)a # print("called getattr") # print(args, kwargs) diff --git a/eco/devices_general/adjustable.py b/eco/devices_general/adjustable.py index ed4452e..f1587f7 100644 --- a/eco/devices_general/adjustable.py +++ b/eco/devices_general/adjustable.py @@ -301,7 +301,6 @@ class PvRecord: # ): self.Id = pvsetname self.name = name - self.alias = Alias(name) # for an, af in alias_fields.items(): # self.alias.append( # Alias(an, channel=".".join([pvname, af]), channeltype="CA") @@ -313,8 +312,10 @@ class PvRecord: if pvreadbackname is None: self._pvreadback = PV(self.Id) + pvreadbackname = self.Id else: self._pvreadback = PV(pvreadbackname) + self.alias = Alias(name, channel=pvreadbackname, channeltype="CA") def get_current_value(self, readback=True): if readback: @@ -554,19 +555,22 @@ class AdjustableGetSet: self._get = foo_get self._check_interval = check_interval self.precision = precision - - def set_and_wait(self,value): + + def set_and_wait(self, value): if self._check_interval: self._set(value) - while abs(self.get_current_value()-value)>self.precision: + while abs(self.get_current_value() - value) > self.precision: time.sleep(self._check_interval) else: self._set(value) - def set_target_value(self, value): return Changer( - target=value, parent=self, changer=self.set_and_wait, hold=False, stopper=None + target=value, + parent=self, + changer=self.set_and_wait, + hold=False, + stopper=None, ) def get_current_value(self): diff --git a/eco/devices_general/motors.py b/eco/devices_general/motors.py index ac98d86..75a9bc3 100755 --- a/eco/devices_general/motors.py +++ b/eco/devices_general/motors.py @@ -338,7 +338,7 @@ class MotorRecord(Assembly): pvname, name=None, elog=None, - alias_fields={"readback": "RBV", "user_offset": "OFF", "user_direction": "DIR"}, + alias_fields={"readback": "RBV"}, expect_bad_limits=True, ): super().__init__(name=name) diff --git a/eco/loptics/bernina_laser.py b/eco/loptics/bernina_laser.py index 46b2dc0..02a825d 100644 --- a/eco/loptics/bernina_laser.py +++ b/eco/loptics/bernina_laser.py @@ -7,10 +7,15 @@ class LaserBernina(Assembly): super().__init__(name=name) self._append() self.pvname = pvname + #Table 1, Benrina hutch + addMotorRecordToSelf( + self, Id=self.Id + "-M523:MOTOR_1", name="_delay_glob_stg" + ) + self.delay_glob = DelayTime(self._delay_glob_stg, name="delay_glob") # Table in bernina hutch # Waveplate and Delay stage - self._append(MotorRecord, self.pvname+"-M534:MOT", name="wp_eos",is_setting=True) - self._append(MotorRecord, self.pvname+"-M533:MOT", name="wp_bsen",is_setting=True) + self._append(MotorRecord, self.pvname+"-M534:MOT", name="wp_aux1",is_setting=True) + self._append(MotorRecord, self.pvname+"-M533:MOT", name="wp_aux2",is_setting=True) self._append(MotorRecord, self.pvname+"-M521:MOTOR_1", name="delay_eos_stage",is_setting=True) # todo @@ -24,10 +29,6 @@ class LaserBernina(Assembly): self, Id=self.Id + "-M522:MOTOR_1", name="_delay_thz_stg" ) self.delay_thz = DelayTime(self._delay_thz_stg, name="delay_thz") - addMotorRecordToSelf( - self, Id=self.Id + "-M523:MOTOR_1", name="_delay_glob_stg" - ) - self.delay_glob = DelayTime(self._delay_glob_stg, name="delay_glob") # compressor addMotorRecordToSelf(self, Id=self.Id + "-M532:MOT", name="compressor") diff --git a/eco/utilities/config.py b/eco/utilities/config.py index 0252ed3..05d5574 100644 --- a/eco/utilities/config.py +++ b/eco/utilities/config.py @@ -15,6 +15,9 @@ from lazy_object_proxy import Proxy as Proxy_orig from tabulate import tabulate +import traceback + + class Component: def __init__(self, namestring): self.name = namestring @@ -293,8 +296,10 @@ class Namespace(object): self.alias_namespace.update( ta["alias"], ta["channel"], ta["channeltype"] ) - except: + except Exception as e: print(f'could not init alias {ta["alias"]}') + print("error message", e) + # traceback.print_tb(e) else: print(f"object {name} has no alias!") return obj_initialized @@ -323,8 +328,9 @@ class Namespace(object): self.alias_namespace.update( ta["alias"], ta["channel"], ta["channeltype"] ) - except: + except Exception as e: print(f'could not init alias {ta["alias"]}') + print("error message", e) else: print(f"object {name} has no alias!") return obj diff --git a/startup_inline_new.py b/startup_inline_new.py index 282930e..4f3901a 100644 --- a/startup_inline_new.py +++ b/startup_inline_new.py @@ -80,4 +80,4 @@ from IPython import get_ipython _ipy = get_ipython() _ipy.Completer.use_jedi = False -print(arguments) +# print(arguments)