Merge branch 'bernina-op' of https://github.com/paulscherrerinstitute/eco into bernina-op

This commit is contained in:
2019-07-15 09:34:33 +02:00
7 changed files with 63 additions and 21 deletions
-11
View File
@@ -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
+7 -6
View File
@@ -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
+7
View File
@@ -0,0 +1,7 @@
from data_api import get_data
class DataApi:
def __init__(self):
pass
def get_data:
pass
+4 -3
View File
@@ -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)
+31
View File
@@ -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)
+1 -1
View File
@@ -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
+13
View File
@@ -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