Aliases and dynamic counters is problematic
counters that are created dynamically by the controller.counters property are problematic when aliased.
While the toolbox asks to a given counter its controller cnt._counter_controller
(necessary step of AcqChain building)
if the cnt is an alias then it calls => alias.py => CounterWrapper => self.__counter_controller.counters !
And therefore counters are recreated again.
-> builder = ChainBuilder(counter_args)
[25] /home/pguillou/bliss/bliss/scanning/toolbox.py(76)__init__() -> self._introspect() [26] /home/pguillou/bliss/bliss/scanning/toolbox.py(157)_introspect() -> if cnt._counter_controller is None: [27] /home/pguillou/bliss/bliss/common/proxy.py(201)__getattr__() -> return getattr(self.__wrapped__, name) [28] /home/pguillou/bliss/bliss/common/proxy.py(100)__wrapped__()
-> target = factory()
[29] /home/pguillou/bliss/bliss/common/alias.py(42)__call__()
-> counters = self.__counter_controller.counters
[30] /home/pguillou/bliss/bliss/controllers/mca/simulation.py(64)counters()
-> return super().counters
[31] /home/pguillou/bliss/bliss/controllers/mca/base.py(381)counters()
-> return mca_counters(self)
def __init__(self, fullname, counter_controller):
self.__fullname = fullname
self.__counter_controller = counter_controller
def __call__(self):
"""Return a counter object from a fullname like:
* 'lima_simulator:r1_sum'
* 'lima_simulator:bpm:x'
* 'simu1:deadtime_det0'
"""
counters = self.__counter_controller.counters
for cnt in counters:
if cnt.fullname == self.__fullname:
return cnt
raise RuntimeError(
f"Alias: cannot find counter corresponding to {self.__fullname}"
)
If a CounterAlias
knows its counter why the sequence of calls:
alias_cnt._counter_controller
=> CounterWrapper =>
counters = self.__counter_controller.counters
for cnt in counters:
if cnt.fullname == self.__fullname:
return cnt
Edited by Perceval Guillou