diff --git a/eco/bernina/bernina.py b/eco/bernina/bernina.py index 1cf9c28..0b98ce5 100644 --- a/eco/bernina/bernina.py +++ b/eco/bernina/bernina.py @@ -26,14 +26,3 @@ for key, value in initFromConfigList(components, lazy=ecocnf.startup_lazy).items alias_namespaces.bernina.store() -def initDevice(name): - if name == "all": - logging.info(f"initializing all components from {_scope_name}.") - name = list(components.keys()) - if not name in components.keys(): - raise KeyError(f"Could not find {name} in configuration!") - if type(name) is list: - for tname in name: - initDevice(tname) - else: - initFromConfigList diff --git a/eco/devices_general/adjustable.py b/eco/devices_general/adjustable.py index b789166..1cf11ed 100644 --- a/eco/devices_general/adjustable.py +++ b/eco/devices_general/adjustable.py @@ -7,6 +7,7 @@ from enum import IntEnum, auto import colorama import time import logging +import datetime logger = logging.getLogger(__name__) @@ -20,17 +21,17 @@ class AdjustableError(Exception): # wrappers for adjustables >>>>>>>>>>> def default_representation(Obj): def get_name(Obj): - if Obj.name: + if Obj.alias: + return Obj.alias.get_full_name() + elif Obj.name: return Obj.name else: return Obj.Id def get_repr(Obj): - return f"{Obj._get_name()} is at: {Obj.get_current_value()}" - if Obj.name: - return Obj.name - else: - return Obj.Id + s = datetime.datetime.now().strftime('%Y/%m/%d %H:%M:%S')+': ' + s += f"{colorama.Style.BRIGHT}{Obj._get_name()}{colorama.Style.RESET_ALL} at {colorama.Style.BRIGHT}{Obj.get_current_value():g}{colorama.Style.RESET_ALL}" + return s Obj._get_name = get_name Obj.__repr__ = get_repr diff --git a/eco/devices_general/archiver.py b/eco/devices_general/archiver.py new file mode 100644 index 0000000..405ee93 --- /dev/null +++ b/eco/devices_general/archiver.py @@ -0,0 +1,7 @@ +from data_api import get_data + +class DataApi: + def __init__(self): + pass + def get_data: + pass diff --git a/eco/devices_general/motors.py b/eco/devices_general/motors.py index cd4423c..de45b05 100755 --- a/eco/devices_general/motors.py +++ b/eco/devices_general/motors.py @@ -181,9 +181,6 @@ class MotorRecord: # return string with motor value as variable representation def __str__(self): - return "Motor is at %s" % self.wm() - - def __repr__(self): # """ return short info for the current motor""" s = f"{self.name}" s += f"\t@ {colorama.Style.BRIGHT}{self.get_current_value():1.6g}{colorama.Style.RESET_ALL} (dial @ {self.get_current_value(posType='dial'):1.6g})" @@ -194,6 +191,10 @@ class MotorRecord: # # s += "\tuser limits (low,high) : {:1.6g},{1.6g}".format(self.get_limits()) return s + def __repr__(self): + print(str(self)) + return object.__repr__(self) + def __call__(self, value): self._currentChange = self.changeTo(value) diff --git a/eco/utilities/beamline.py b/eco/utilities/beamline.py new file mode 100644 index 0000000..02b8886 --- /dev/null +++ b/eco/utilities/beamline.py @@ -0,0 +1,31 @@ +from functools import partial + +class BeamlineSwissfel: + def __init__(self,components=['slits'],name=None): + self.name = name + for comp_type in components: + self.__dict__[f'_{comp_type}'] = [] + self.__dict__[comp] = partial(self._print_component_status,comp_type) + + + def append_component(self,comp_type,item): + self.__dict__[comp_type].append(item) + + def _get_component_status(self,comp_type): + s = [] + for comp in self.__dict__[comp_type]: + s.append(comp.__repr__()) + return s + + def _print_component_status(self,comp_type,linker='\n'): + s = self._get_component_status() + print linker.join(s) + + + + + + + + + diff --git a/eco/utilities/config.py b/eco/utilities/config.py index 414575e..ab65917 100644 --- a/eco/utilities/config.py +++ b/eco/utilities/config.py @@ -205,7 +205,7 @@ def prepend_to_path(*args): sys.path.insert(0, targ) class Terminal: - def __init__(self,title='🐍eco',scope=None): + def __init__(self,title='eco',scope=None): self.title = title self.scope = scope diff --git a/eco/xoptics/slits.py b/eco/xoptics/slits.py index 363d26e..1052670 100755 --- a/eco/xoptics/slits.py +++ b/eco/xoptics/slits.py @@ -4,6 +4,14 @@ from ..aliases import Alias, append_object_to_object from functools import partial +def addSlitRepr(Slitobj): + def repr(self): + s = f"pos ({self.hpos.get_current_value():6.3f},{self.vpos.get_current_value():6.3f}), gap ({self.hgap.get_current_value():6.3f},{self.vgap.get_current_value():6.3f})" + return s + Slitobj.__repr__ = repr + return Slitobj + +@addSlitRepr class SlitBlades: def __init__(self, pvname, name=None, elog=None): self.name = name @@ -13,6 +21,10 @@ class SlitBlades: append_object_to_object(self, MotorRecord, pvname + ":MOTOR_X2", name="left") append_object_to_object(self, MotorRecord, pvname + ":MOTOR_Y1", name="down") append_object_to_object(self, MotorRecord, pvname + ":MOTOR_Y2", name="up") + append_object_to_object(self, MotorRecord, pvname + ":MOTOR_X", name="hpos_virt_mrec") + append_object_to_object(self, MotorRecord, pvname + ":MOTOR_W", name="hgap_virt_mrec") + append_object_to_object(self, MotorRecord, pvname + ":MOTOR_Y", name="vpos_virt_mrec") + append_object_to_object(self, MotorRecord, pvname + ":MOTOR_H", name="vgap_virt_mrec") def getgap(xn, xp): return xp - xn @@ -91,6 +103,7 @@ class SlitBlades: else: raise Exception("wrong number of input arguments!") +@addSlitRepr class SlitPosWidth: def __init__(self, pvname, name=None, elog=None): self.name = name