fixed alias update issue in motors

This commit is contained in:
2021-01-22 11:05:24 +01:00
parent 4c234faf7c
commit 90b5d64a97
7 changed files with 33 additions and 22 deletions
+2 -2
View File
@@ -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]
+4 -4
View File
@@ -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)
+10 -6
View File
@@ -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):
+1 -1
View File
@@ -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)
+7 -6
View File
@@ -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")
+8 -2
View File
@@ -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
+1 -1
View File
@@ -80,4 +80,4 @@ from IPython import get_ipython
_ipy = get_ipython()
_ipy.Completer.use_jedi = False
print(arguments)
# print(arguments)