Commit 44d132eb authored by Piergiorgio Pancino's avatar Piergiorgio Pancino
Browse files

improve map registration for some devices using DeviceProxy

parent fd1ec2b5
......@@ -244,6 +244,7 @@ class TangoDeviceServer:
log_debug(self, "TangoDeviceServer::init()")
if self._proxy is None:
self._proxy = DeviceProxy(self._tango_url)
global_map.register(self, children_list=[self._proxy])
def close(self):
self._proxy = None
......
......@@ -420,8 +420,10 @@ class Lima(CounterController):
"%s:directories_mapping" % name
)
global_map.register("lima", ["global"])
global_map.register(self, parents_list=["lima", "controllers"])
global_map.register("lima", parents_list=["global"])
global_map.register(
self, parents_list=["lima", "controllers"], children_list=[self._proxy]
)
clear_cache(self)
......@@ -559,6 +561,7 @@ class Lima(CounterController):
or update_all
):
maskp = self._get_proxy("mask")
global_map.register(maskp, parents_list=[self], tag="mask")
maskp.Stop()
if use_mask:
log_debug(self, " uploading new mask on %s", self.name)
......@@ -576,6 +579,7 @@ class Lima(CounterController):
or update_all
):
ff_proxy = self._get_proxy("flatfield")
global_map.register(ff_proxy, parents_list=[self], tag="flatfield")
ff_proxy.Stop()
if use_flatfield:
log_debug(self, " uploading flatfield on %s", self.name)
......@@ -594,6 +598,7 @@ class Lima(CounterController):
or update_all
):
bg_proxy = self._get_proxy("backgroundsubstraction")
global_map.register(bg_proxy, parents_list=[self], tag="bg_sub")
log_debug(
self,
" stopping background sub proxy on %s and setting runlevel to %s",
......@@ -795,6 +800,11 @@ class Lima(CounterController):
if self.__roi_counters is None:
roi_counters_proxy = self._get_proxy(self._ROI_COUNTERS)
self.__roi_counters = RoiCounters(roi_counters_proxy, self)
global_map.register(
self.__roi_counters,
parents_list=[self],
children_list=[roi_counters_proxy],
)
return self.__roi_counters
@autocomplete_property
......@@ -817,6 +827,9 @@ class Lima(CounterController):
base_class=camera_class,
base_class_args=(self.name, self, proxy),
)
global_map.register(
self._camera, parents_list=[self], children_list=[proxy]
)
return self._camera
@property
......@@ -828,6 +841,10 @@ class Lima(CounterController):
if self.__bpm is None:
bpm_proxy = self._get_proxy(Lima._BPM)
self.__bpm = Bpm(self.name, bpm_proxy, self)
global_map.register(
self.__bpm, parents_list=[self], children_list=[bpm_proxy]
)
return self.__bpm
@autocomplete_property
......@@ -835,6 +852,9 @@ class Lima(CounterController):
if self.__bg_sub is None:
bg_sub_proxy = self._get_proxy(Lima._BG_SUB)
self.__bg_sub = BgSub(self.name, bg_sub_proxy, self)
global_map.register(
self.__bg_sub, parents_list=[self], children_list=[bg_sub_proxy]
)
return self.__bg_sub
@property
......@@ -909,17 +929,6 @@ class Lima(CounterController):
return info_str
def __repr__(self):
attr_list = ("user_detector_name", "lima_type")
try:
data = {
attr.name: ("?" if attr.has_failed else attr.value)
for attr in self._proxy.read_attributes(attr_list)
}
return f"<Lima Controller for {data['user_detector_name']} (Lima {data['lima_type']})>"
except DevFailed:
return super().__repr__()
# Expose counters
@autocomplete_property
......
......@@ -103,6 +103,7 @@ class esrf_hexapode(Controller):
# Get a proxy on Hexapode Tango DS.
self.device = DeviceProxy(self.tango_name)
global_map.register(self, children_list=[self.device])
self.roles = {}
self.roles["tx"] = 0
......
......@@ -57,6 +57,9 @@ class ESRF_Undulator(Controller):
# Get a proxy on Insertion Device device server of the beamline.
self.device = DeviceProxy(self.ds_name)
global_map.register(
self, parents_list=["undulators"], children_list=[self.device]
)
"""
Axes initialization actions.
......
......@@ -5,6 +5,7 @@
# Copyright (c) 2015-2020 Beamline Control Unit, ESRF
# Distributed under the GNU LGPLv3. See LICENSE for more info.
from bliss import global_map
from bliss.controllers.motor import Controller
from bliss.common.axis import AxisState
......@@ -38,6 +39,7 @@ class TangoEMot(Controller):
def initialize_axis(self, axis):
self.axis_proxy = DeviceProxy(self.ds_name)
global_map.register(self, children_list=[self.axis_proxy])
axis.config.set("steps_per_unit", self.axis_proxy.steps_per_unit)
axis.config.set("acceleration", self.axis_proxy.ReadConfig("acceleration"))
......@@ -45,6 +47,7 @@ class TangoEMot(Controller):
def initialize_encoder(self, encoder):
self.encoder_proxy = DeviceProxy(self.ds_name)
global_map.register(self, children_list=[self.encoder_proxy])
encoder.config.config_dict.update(
{"steps_per_unit": {"value": self.encoder_proxy.steps_per_unit}}
......
......@@ -11,6 +11,7 @@ import numpy
import math
import os
import logging
from bliss import global_map
from bliss.common.tango import DeviceProxy
from bliss.common.scans import *
from bliss.common.motor_group import Group
......@@ -35,6 +36,7 @@ class MD2M:
self.zoom_positions = config.get("zoom_positions")
self.oscil_mprg = config.get("oscil_mprg")
self.members_state = {"light": None, "cryo": None, "fluodet": None}
global_map.register(self, tag=f"MD2M:{name}")
@task
def _simultaneous_move(self, *args):
......@@ -585,6 +587,9 @@ class MD2M:
self.bv_device = DeviceProxy(self.beamviewer_server)
self.sample_video_device = DeviceProxy(self.sample_video_server)
global_map.register(
self, children_list=[self.bv_device, self.sample_video_device]
)
def restore_live():
self.sample_video_device.video_live = True
......
......@@ -111,7 +111,7 @@ class TangoCounterController(SamplingCounterController):
self._proxy = proxy
self._attributes_config = None
if global_map_register:
global_map.register(self, tag=self.name)
global_map.register(self, tag=self.name, children_list=[proxy])
def read_all(self, *counters):
"""
......
......@@ -26,6 +26,7 @@ example yml file:
from enum import Enum
from gevent import Timeout, sleep
from bliss import global_map
from bliss.common.shutter import BaseShutter, BaseShutterState
from bliss.common.tango import DeviceProxy, DevFailed
from bliss.common.logtools import log_warning
......@@ -53,6 +54,7 @@ class TangoShutter(BaseShutter):
self.__name = name
self.__config = config
self.__control = DeviceProxy(tango_uri)
global_map.register(self, children_list=[self.__control], tag=f"Shutter:{name}")
self._frontend = None
self._mode = None
self._init_type()
......
......@@ -11,7 +11,8 @@ import logging
from functools import wraps
# tango imports
import tango
from bliss.common import tango
from bliss.common.tango import DeviceProxy
from tango import GreenMode
from tango import DebugIt
from tango.server import run
......@@ -85,9 +86,9 @@ class NanoBpmServo(Device):
self.NanoBPM, green_mode=GreenMode.Gevent, wait=True, timeout=True
)
if self.XController is not None:
self._xcontrolProxy = tango.DeviceProxy(self.XController)
self._xcontrolProxy = DeviceProxy(self.XController)
if self.YController is not None:
self._ycontrolProxy = tango.DeviceProxy(self.YController)
self._ycontrolProxy = DeviceProxy(self.YController)
global_map.register(
self,
children_list=[
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment