Esempio n. 1
0
    def _get_dynamic_attributes(self):
        ctrl = self.ctrl
        if ctrl is None:
            self.warning("no controller: dynamic attributes NOT created")
            return PoolDevice.get_dynamic_attributes(self)
        if not ctrl.is_online():
            self.warning("controller offline: dynamic attributes NOT created")
            return PoolDevice.get_dynamic_attributes(self)

        dyn_attrs = CaselessDict()
        std_attrs = CaselessDict()
        dev_class = self.get_device_class()
        axis_attrs = ctrl.get_axis_attributes(self.element.axis)

        std_attrs_lower = [attr.lower()
                           for attr in dev_class.standard_attr_list]
        for attr_name, attr_info in list(axis_attrs.items()):
            attr_name_lower = attr_name.lower()
            if attr_name_lower in std_attrs_lower:
                data_info = DataInfo.toDataInfo(attr_name, attr_info)
                tg_info = dev_class.standard_attr_list[attr_name]
                std_attrs[attr_name] = attr_name, tg_info, data_info
            else:
                data_info = DataInfo.toDataInfo(attr_name, attr_info)
                name, tg_info = to_tango_attr_info(attr_name, data_info)
                dyn_attrs[attr_name] = name, tg_info, data_info
        return std_attrs, dyn_attrs
Esempio n. 2
0
    def _get_dynamic_attributes(self):
        ctrl = self.ctrl
        if ctrl is None:
            self.warning("no controller: dynamic attributes NOT created")
            return PoolDevice.get_dynamic_attributes(self)
        if not ctrl.is_online():
            self.warning("controller offline: dynamic attributes NOT created")
            return PoolDevice.get_dynamic_attributes(self)

        dyn_attrs = CaselessDict()
        std_attrs = CaselessDict()
        dev_class = self.get_device_class()
        axis_attrs = ctrl.get_axis_attributes(self.element.axis)

        std_attrs_lower = [
            attr.lower() for attr in dev_class.standard_attr_list
        ]
        for attr_name, attr_info in list(axis_attrs.items()):
            attr_name_lower = attr_name.lower()
            if attr_name_lower in std_attrs_lower:
                data_info = DataInfo.toDataInfo(attr_name, attr_info)
                # copy in order to leave the class attributes untouched
                # the downstream code can append MaxDimSize to the attr. info
                tg_info = deepcopy(dev_class.standard_attr_list[attr_name])
                std_attrs[attr_name] = attr_name, tg_info, data_info
            else:
                data_info = DataInfo.toDataInfo(attr_name, attr_info)
                name, tg_info = to_tango_attr_info(attr_name, data_info)
                dyn_attrs[attr_name] = name, tg_info, data_info
        return std_attrs, dyn_attrs
Esempio n. 3
0
    def addDevice(self, dev_info):
        domain, family, member = dev_info.domain(), dev_info.family(), dev_info.member()

        families = self[domain] = self.get(domain, CaselessDict())
        devs = self._devices[domain] = self._devices.get(
            domain, CaselessDict())
        devs[dev_info.name()] = dev_info

        families[family] = members = families.get(family, CaselessDict())

        members[member] = dev_info
Esempio n. 4
0
    def __init__(self, **kwargs):
        kwargs['manager'] = kwargs.pop('pool')
        kwargs['elem_type'] = ElementType.ControllerClass
        SardanaClass.__init__(self, **kwargs)

        self.types = []
        self.dict_extra = {}
        self.api_version = 1

        klass = self.klass
        # Generic controller information
        self.ctrl_features = tuple(klass.ctrl_features)

        self.ctrl_properties = props = CaselessDict()
        for k, v in klass.class_prop.items():  # old member
            props[k] = DataInfo.toDataInfo(k, v)
        for k, v in klass.ctrl_properties.items():
            props[k] = DataInfo.toDataInfo(k, v)

        self.ctrl_attributes = ctrl_attrs = CaselessDict()
        for k, v in klass.ctrl_attributes.items():
            ctrl_attrs[k] = DataInfo.toDataInfo(k, v)

        self.axis_attributes = axis_attrs = CaselessDict()
        for k, v in klass.ctrl_extra_attributes.items():  # old member
            axis_attrs[k] = DataInfo.toDataInfo(k, v)
        for k, v in klass.axis_attributes.items():
            axis_attrs[k] = DataInfo.toDataInfo(k, v)

        self.types = types = self.__build_types()
        self.type_names = map(ElementType.whatis, types)

        if ElementType.PseudoMotor in types:
            self.motor_roles = tuple(klass.motor_roles)
            self.pseudo_motor_roles = tuple(klass.pseudo_motor_roles)
            if len(self.pseudo_motor_roles) == 0:
                self.pseudo_motor_roles = (klass.__name__,)
            self.dict_extra['motor_roles'] = self.motor_roles
            self.dict_extra['pseudo_motor_roles'] = self.pseudo_motor_roles

        if ElementType.PseudoCounter in types:
            self.counter_roles = tuple(klass.counter_roles)
            self.pseudo_counter_roles = tuple(klass.pseudo_counter_roles)
            if len(self.pseudo_counter_roles) == 0:
                self.pseudo_counter_roles = (klass.__name__,)
            self.dict_extra['counter_roles'] = self.counter_roles
            self.dict_extra['pseudo_counter_roles'] = self.pseudo_counter_roles

        if ElementType.IORegister in types:
            self.dict_extra['predefined_values'] = klass.predefined_values

        init_args = inspect.getargspec(klass.__init__)
        if init_args.varargs is None or init_args.keywords is None:
            self.api_version = 0
Esempio n. 5
0
 def __init__(self, **kwargs):
     self._ctrl = None
     self._ctrl_error = None
     self._element_ids = {}
     self._pending_element_ids = {}
     self._element_axis = {}
     self._pending_element_axis = {}
     self._element_names = CaselessDict()
     self._pending_element_names = CaselessDict()
     self._operator = None
     kwargs['elem_type'] = ElementType.Controller
     super(PoolBaseController, self).__init__(**kwargs)
Esempio n. 6
0
    def get_dynamic_attributes(self):
        """Override of :class:`PoolDevice.get_dynamic_attributes`.
        Returns the standard dynamic and fully dynamic attributes for this
        device. The return is a tuple of two dictionaries:
        
        - standard attributes: caseless dictionary with key being the attribute
          name and value is a tuple of attribute name(str), tango information,
          attribute information
        - dynamic attributes: caseless dictionary with key being the attribute
          name and value is a tuple of attribute name(str), tango information,
          attribute information
        
        **tango information**
            seq< :class:`~PyTango.CmdArgType`, :class:`~PyTango.AttrDataFormat`, :class:`~PyTango.AttrWriteType` >
        
        **attribute information**
            attribute information as returned by the sardana controller
        
        :return: the standard dynamic and fully dynamic attributes
        :rtype: seq< :class:`~taurus.core.util.CaselessDict`, :class:`~taurus.core.util.CaselessDict`\>
        """

        if hasattr(self, "_dynamic_attributes_cache"):
            return self._standard_attributes_cache, self._dynamic_attributes_cache
        ctrl = self.ctrl
        if ctrl is None:
            self.warning("no controller: dynamic attributes NOT created")
            return PoolDevice.get_dynamic_attributes(self)
        if not ctrl.is_online():
            self.warning("controller offline: dynamic attributes NOT created")
            return PoolDevice.get_dynamic_attributes(self)

        self._dynamic_attributes_cache = dyn_attrs = CaselessDict()
        self._standard_attributes_cache = std_attrs = CaselessDict()
        dev_class = self.get_device_class()
        axis_attrs = ctrl.get_axis_attributes(self.element.axis)

        std_attrs_lower = [
            attr.lower() for attr in dev_class.standard_attr_list
        ]
        for attr_name, attr_info in axis_attrs.items():
            attr_name_lower = attr_name.lower()
            if attr_name_lower in std_attrs_lower:
                data_info = DataInfo.toDataInfo(attr_name, attr_info)
                tg_info = dev_class.standard_attr_list[attr_name]
                std_attrs[attr_name] = attr_name, tg_info, data_info
            else:
                data_info = DataInfo.toDataInfo(attr_name, attr_info)
                name, tg_info = to_tango_attr_info(attr_name, data_info)
                dyn_attrs[attr_name] = name, tg_info, data_info
        return std_attrs, dyn_attrs
Esempio n. 7
0
 def get_dynamic_attributes(self):
     if hasattr(self, "_dynamic_attributes_cache"):
         return self._standard_attributes_cache, self._dynamic_attributes_cache
     info = self.ctrl.ctrl_info
     if info is None:
         self.warning("Controller %s doesn't have any information",
                      self.ctrl)
         return PoolDevice.get_dynamic_attributes(self)
     self._dynamic_attributes_cache = dyn_attrs = CaselessDict()
     self._standard_attributes_cache = std_attrs = CaselessDict()
     for attr_name, attr_data in info.ctrl_attributes.items():
         name, tg_info = to_tango_attr_info(attr_name, attr_data)
         dyn_attrs[attr_name] = attr_name, tg_info, attr_data
     return std_attrs, dyn_attrs
Esempio n. 8
0
    def initialize_dynamic_attributes(self):
        """Initializes this device dynamic attributes"""
        self._attributes = attrs = CaselessDict()

        attr_data = self.get_dynamic_attributes()

        std_attrs, dyn_attrs = attr_data
        self.remove_unwanted_dynamic_attributes(std_attrs, dyn_attrs)

        if std_attrs is not None:
            read = self.__class__._read_DynamicAttribute
            write = self.__class__._write_DynamicAttribute
            is_allowed = self.__class__._is_DynamicAttribute_allowed
            for attr_name, data_info in std_attrs.items():
                attr_name, data_info, attr_info = data_info
                attr = self.add_standard_attribute(attr_name, data_info,
                                                   attr_info, read, write,
                                                   is_allowed)
                attrs[attr.get_name()] = None

        if dyn_attrs is not None:
            read = self.__class__._read_DynamicAttribute
            write = self.__class__._write_DynamicAttribute
            is_allowed = self.__class__._is_DynamicAttribute_allowed
            for attr_name, data_info in dyn_attrs.items():
                attr_name, data_info, attr_info = data_info
                attr = self.add_dynamic_attribute(attr_name, data_info,
                                                  attr_info, read, write,
                                                  is_allowed)
                attrs[attr.get_name()] = None
        return attrs
Esempio n. 9
0
    def __init__(self, full_name, name=None):
        self._path_id = None
        self._motion_loop_states_per_position = self.Default_MotionLoop_StatesPerPosition
        self._motion_loop_sleep_time = self.Default_MotionLoop_SleepTime
        self._acq_loop_states_per_value = self.Default_AcqLoop_StatesPerValue
        self._acq_loop_sleep_time = self.Default_AcqLoop_SleepTime
        self._drift_correction = self.Default_DriftCorrection
        self._remote_log_handler = None

        # dict<str, dict<str, str>>
        # keys are acquisition channel names and value is a dict describing the
        # channel containing:
        #  - 'name': with value being the channel name (given by user)
        #  - 'full_name': acq channel full name (ex: tango attribute)
        #  - 'origin': 'local' if local to this server or 'remote' if a remote
        #    channel
        self._extra_acquisition_element_names = CaselessDict()

        PoolContainer.__init__(self)
        PoolObject.__init__(self,
                            full_name=full_name,
                            name=name,
                            id=InvalidId,
                            pool=self,
                            elem_type=ElementType.Pool)
        self._monitor = PoolMonitor(self, "PMonitor", auto_start=False)
        # self.init_local_logging()
        ControllerManager().set_pool(self)
Esempio n. 10
0
 def toDataInfo(klass, name, info):
     info = CaselessDict(info)
     dtype = info[Type]
     dtype, dformat = to_dtype_dformat(dtype)
     default_value = info.get(DefaultValue)
     description = info.get(Description, '')
     daccess = info.get(Access, DataAccess.ReadWrite)
     daccess = to_daccess(daccess)
     memorized = info.get(Memorize, Memorized)
     maxdimsize = info.get(MaxDimSize)
     fget = info.get(FGet)
     fset = info.get(FSet)
     if default_value is not None and dtype != DataType.String:
         if type(default_value) in types.StringTypes:
             default_value = eval(default_value)
     return DataInfo(name,
                     dtype,
                     dformat=dformat,
                     access=daccess,
                     description=description,
                     default_value=default_value,
                     memorized=memorized,
                     fget=fget,
                     fset=fset,
                     maxdimsize=maxdimsize)
Esempio n. 11
0
    def setCurves(self, curvePropDict):
        """Populates the list of curves from the properties dictionary. It uses
        the curve title for display, and stores the curve name as the item data
        (with role=CurvesAppearanceChooser.NAME_ROLE)

        :param curvePropDict:  (dict) a dictionary whith keys=curvenames and
                               values= :class:`CurveAppearanceProperties`
                               object
        """
        self.curvePropDict = curvePropDict
        self._curvePropDictOrig = copy.deepcopy(curvePropDict)
        self.curvesLW.clear()
        self.__itemsDict = CaselessDict()
        for name, prop in self.curvePropDict.items():
            # create and insert the item
            item = Qt.QListWidgetItem(prop.title, self.curvesLW)
            self.__itemsDict[name] = item
            item.setData(self.NAME_ROLE, name)
            item.setToolTip("<b>Curve Name:</b> %s" % name)
            item.setFlags(Qt.Qt.ItemIsEnabled
                          | Qt.Qt.ItemIsSelectable
                          | Qt.Qt.ItemIsUserCheckable
                          | Qt.Qt.ItemIsDragEnabled
                          | Qt.Qt.ItemIsEditable)
        self.curvesLW.setCurrentRow(0)
Esempio n. 12
0
    def __init__(self,
                 full_name,
                 name=None,
                 macro_path=None,
                 environment_db=None,
                 recorder_path=None):
        # dict<str, Pool>
        # key   - device name (case insensitive)
        # value - Pool object representing the device name
        self._pools = CaselessDict()
        self._max_parallel_macros = self.MaxParalellMacros
        self._path_id = None

        MSContainer.__init__(self)
        MSObject.__init__(self,
                          full_name=full_name,
                          name=name,
                          id=InvalidId,
                          macro_server=self,
                          elem_type=ElementType.MacroServer)

        registerExtensions()

        self._type_manager = TypeManager(self)
        self._environment_manager = EnvironmentManager(
            self, environment_db=environment_db)
        self._macro_manager = MacroManager(self, macro_path=macro_path)
        self._recorder_manager = RecorderManager(self,
                                                 recorder_path=recorder_path)
Esempio n. 13
0
    def addElement(self, elem):
        elem_type = elem.getType()
        elem_full_name = elem.full_name

        # update type_elems
        type_elems = self._type_elems_dict.get(elem_type)
        if type_elems is None:
            self._type_elems_dict[elem_type] = type_elems = CaselessDict()
        type_elems[elem_full_name] = elem

        # update interfaces
        for interface in elem.interfaces:
            interface_elems = self._interfaces_dict.get(interface)
            if interface_elems is None:
                self._interfaces_dict[
                    interface] = interface_elems = CaselessDict()
            interface_elems[elem_full_name] = elem
Esempio n. 14
0
    def __init__(self):
        # dict<str, dict> where key is the type and value is:
        #     dict<str, MacroServerElement> where key is the element full name
        #                                   and value is the Element object
        self._type_elems_dict = CaselessDict()

        # dict<str, container> where key is the interface and value is the set
        # of elements which implement that interface
        self._interfaces_dict = {}
Esempio n. 15
0
 def __init__(self, name, image_name='image', image_ct='imagecounter',
              **kw):
     self.lock = Lock()
     self._image_data = CaselessDict()
     self._image_id_attr_name = image_ct
     self.call__init__(ImageDevice, name, image_name, **kw)
     self._image_id_attr = self.getAttribute(self._image_id_attr_name)
     self.discard_event = False
     self._image_id_attr.addListener(self)
Esempio n. 16
0
    def __init__(self, initial_elems):
        MoveableSource.__init__(self)
        self.elem_names = initial_elems
        self.moveable_inc = 0

        self.motors = CaselessDict()
        for elem_name in initial_elems:
            self.motors[elem_name] = PoolMoveableTest(elem_name, [elem_name],
                                                      self)
        self.motor_group = None
Esempio n. 17
0
 def get_device(self, *args, **kwargs):
     ctrl_name = args[0]
     device_name = args[1]
     ctrl_devs = self._ctrl_proxies.get(ctrl_name)
     if ctrl_devs is None:
         self._ctrl_proxies[ctrl_name] = ctrl_devs = CaselessDict()
     dev = ctrl_devs.get(device_name)
     if dev is None:
         import PyTango
         ctrl_devs[device_name] = dev = PyTango.DeviceProxy(device_name)
     return dev
Esempio n. 18
0
    def __init__(self, parent=None, designMode=False):

        TaurusTrend.__init__(self, parent, designMode)
        self._plotables = CaselessDict()
        self._movingMotors = []
        self._macroNames = []
        self._doorName = None

        self.setMinimumSize(300, 200)
        self.setXIsTime(True)
        self.setAxisScale(Qwt5.QwtPlot.xBottom, 0, 60)
        self.setXDynScale(True)
Esempio n. 19
0
    def __init__(self):
        #: dict<int(axis), str(reason for being in pending)>
        self._pending = {}

        #: dict<str(dev name), tuple<DeviceProxy, list<str(attributes name)>>>
        self._devices = CaselessDict()

        #: dict<int(axis), seq<str<tango full attribute name>, str<attr name>, DeviceProxy>>
        self._axis_tango_attributes = {}

        #: dict<int(axis), str<formula>>
        self._axis_formulas = {}
Esempio n. 20
0
 def get_dynamic_attributes(self):
     """Returns the standard dynamic and fully dynamic attributes for this
     device. The return is a tuple of two dictionaries:
     
     - standard attributes: caseless dictionary with key being the attribute
       name and value is a tuple of attribute name(str), tango information,
       attribute information
     - dynamic attributes: caseless dictionary with key being the attribute
       name and value is a tuple of attribute name(str), tango information,
       attribute information
     
     **tango information**
         seq< :class:`~PyTango.CmdArgType`, :class:`~PyTango.AttrDataFormat`, :class:`~PyTango.AttrWriteType` >
     
     **attribute information**
         attribute information as returned by the sardana controller
     
     :return: the standard dynamic and fully dynamic attributes
     :rtype: seq< :class:`~taurus.core.util.CaselessDict`, :class:`~taurus.core.util.CaselessDict`\>
     """
     return CaselessDict(), CaselessDict()
Esempio n. 21
0
    def get_elements_with_interface(self, interface):
        ret = CaselessDict()
        if is_pure_str(interface):
            interface_str = interface
            interface = Interface[interface_str]
        else:
            interface_str = Interface[interface]

        if self.is_macroserver_interface(interface):
            ret.update(self._LOCAL_INTERFACES.get(interface)(self))
        else:
            for pool in self.get_pools():
                ret.update(pool.getElementsWithInterface(interface_str))
        return ret
Esempio n. 22
0
    def __init__(self):

        # map of all elements
        # key - element ID
        # value - pointer to the element object
        self._element_ids = {}

        # map of all elements by name
        # key - element name
        # value - pointer to the element object
        self._element_names = CaselessDict()

        # map of all elements by name
        # key - element full name
        # value - pointer to the element object
        self._element_full_names = CaselessDict()

        # map of all elements by type
        # key - element type
        # value - map where:
        #    key - element ID
        #    value - pointer to the element object
        self._element_types = {}
Esempio n. 23
0
    def getObjDict(self, pool=ParamType.All, cache=False):
        macro_server = self.macro_server
        objs = CaselessDict()
        if macro_server.is_macroserver_interface(self._name):
            return macro_server.get_elements_with_interface(self._name)

        if pool == ParamType.All:
            pools = macro_server.get_pools()
        else:
            pools = macro_server.get_pool(pool),
        for pool in pools:
            for elem_info in pool.getElementsWithInterface(self._name).values():
                if self.accepts(elem_info):
                    objs[elem_info.name] = elem_info
        return objs
Esempio n. 24
0
    def __init__(self, name, **kw):
        self._log_attr = CaselessDict()
        self._block_lines = 0
        self._in_block = False
        self._macro_server = None
        self._running_macros = None
        self._running_macro = None
        self._last_running_macro = None
        self._user_xml = None
        self._ignore_logs = kw.get("ignore_logs", False)
        self._silent = kw.get("silent", True)
        self._debug = kw.get("debug", False)
        self._output_stream = kw.get("output", sys.stdout)
        self._writeLock = threading.Lock()
        self._input_handler = self.create_input_handler()
        self._len_last_data_line = 1

        self.call__init__(MacroServerDevice, name, **kw)

        self._old_door_state = PyTango.DevState.UNKNOWN
        try:
            self._old_sw_door_state = TaurusSWDevState.Uninitialized
        except RuntimeError:
            # TODO: For Taurus 4 compatibility
            from taurus.core import TaurusDevState
            self._old_sw_door_state = TaurusDevState.Undefined

        self.getStateObj().addListener(self.stateChanged)

        for log_name in self.log_streams:
            tg_attr = self.getAttribute(log_name)
            attr = LogAttr(self, log_name, None, tg_attr)
            if log_name == 'Result':
                attr.subscribeEvent(self.resultReceived, log_name)
            else:
                attr.subscribeEvent(self.logReceived, log_name)
            self._log_attr[log_name] = attr

        self.__input_attr = self.getAttribute("Input")
        self.__input_attr.addListener(self.inputReceived)

        self.__record_data_attr = self.getAttribute('RecordData')
        self.__record_data_attr.addListener(self.recordDataReceived)

        self.__macro_status_attr = self.getAttribute('MacroStatus')
        self.__macro_status_attr.addListener(self.macroStatusReceived)

        self._experiment_configuration = ExperimentConfiguration(self)
Esempio n. 25
0
    def __init__(self,
                 parent=None,
                 curvePropDict={},
                 showButtons=False,
                 autoApply=False,
                 designMode=False):
        # try:
        super(CurvesAppearanceChooser, self).__init__(parent)
        self.loadUi()
        self.autoApply = autoApply
        self.sStyleCB.insertItems(0, sorted(NamedSymbolStyles.values()))
        self.lStyleCB.insertItems(0, list(NamedLineStyles.values()))
        self.cStyleCB.insertItems(0, list(NamedCurveStyles.values()))
        self.sColorCB.addItem("")
        self.lColorCB.addItem("")
        if not showButtons:
            self.applyBT.hide()
            self.resetBT.hide()
        for color in NamedColors:
            icon = self._colorIcon(color)
            self.sColorCB.addItem(icon, "", Qt.QColor(color))
            self.lColorCB.addItem(icon, "", Qt.QColor(color))
        self.__itemsDict = CaselessDict()
        self.setCurves(curvePropDict)
        # set the icon for the background button (stupid designer limitations
        # forces to do it programatically)
        self.bckgndBT.setIcon(Qt.QIcon(":color-fill.svg"))

        # connections.
        # Note: The assignToY1BT and assignToY2BT buttons are not connected to anything
        # Their signals are handled by the Config dialog because we haven't got
        # access to the curve objects here
        self.curvesLW.itemSelectionChanged.connect(self.onSelectedCurveChanged)
        self.curvesLW.itemChanged.connect(self.onItemChanged)
        self.applyBT.clicked.connect(self.onApply)
        self.resetBT.clicked.connect(self.onReset)
        self.sStyleCB.currentIndexChanged.connect(self._onSymbolStyleChanged)

        self.sStyleCB.currentIndexChanged.connect(self.onControlChanged)
        self.lStyleCB.currentIndexChanged.connect(self.onControlChanged)
        self.sColorCB.currentIndexChanged.connect(self.onControlChanged)
        self.lColorCB.currentIndexChanged.connect(self.onControlChanged)
        self.cStyleCB.currentIndexChanged.connect(self.onControlChanged)
        self.sSizeSB.valueChanged.connect(self.onControlChanged)
        self.lWidthSB.valueChanged.connect(self.onControlChanged)
        self.sFillCB.stateChanged.connect(self.onControlChanged)
        self.cFillCB.stateChanged.connect(self.onControlChanged)
Esempio n. 26
0
    def reInit(self):
        """Reinitialize the singleton"""
        self._default_tango_host = None
        self.dft_db = None
        self.tango_db = CaselessWeakValueDict()
        self.tango_db_queries = CaselessWeakValueDict()
        self.tango_attrs = CaselessWeakValueDict()
        self.tango_devs = CaselessWeakValueDict()
        self.tango_dev_queries = CaselessWeakValueDict()
        self.tango_alias_devs = CaselessWeakValueDict()
        self.polling_timers = {}

        # Plugin device classes
        self.tango_dev_klasses = {}

        # Plugin attribute classes
        self.tango_attr_klasses = CaselessDict()
Esempio n. 27
0
    def get(self, cache=False):
        door = self._door
        macro_server = door.macro_server
        env = door.getEnvironment()

        ret = dict(ScanDir=env.get('ScanDir'),
                   DataCompressionRank=env.get('DataCompressionRank', 1),
                   PreScanSnapshot=env.get('PreScanSnapshot', []))
        scan_file = env.get('ScanFile')
        if scan_file is None:
            scan_file = []
        elif isinstance(scan_file, (str, unicode)):
            scan_file = [scan_file]
        ret['ScanFile'] = scan_file
        mnt_grps = macro_server.getElementsOfType("MeasurementGroup")
        mnt_grps_names = [mnt_grp.name for mnt_grp in mnt_grps.values()]
        mnt_grps_full_names = mnt_grps.keys()

        active_mnt_grp = env.get('ActiveMntGrp')
        if active_mnt_grp is None and len(mnt_grps):
            active_mnt_grp = mnt_grps_names[0]
            door.putEnvironment('ActiveMntGrp', active_mnt_grp)

        ret['ActiveMntGrp'] = active_mnt_grp
        ret['MntGrpConfigs'] = mnt_grp_configs = CaselessDict()

        if len(mnt_grps) == 0:
            return ret

        mnt_grp_grps = PyTango.Group("grp")
        # use full names cause we may be using a different Tango database
        mnt_grp_grps.add(mnt_grps_full_names)

        codec = CodecFactory().getCodec('json')
        replies = mnt_grp_grps.read_attribute("configuration")
        for mnt_grp, reply in zip(mnt_grps_names, replies):
            try:
                mnt_grp_configs[mnt_grp] = \
                    codec.decode(('json', reply.get_data().value),
                                 ensure_ascii=True)[1]
            except Exception, e:
                from taurus.core.util.log import warning
                warning('Cannot load Measurement group "%s": %s',
                        repr(mnt_grp), repr(e))
Esempio n. 28
0
    def getObjDict(self, pool=ParamType.All, cache=False):
        macro_server = self.macro_server
        objs = CaselessDict()
        if pool == ParamType.All:
            pools = macro_server.get_pools()
        else:
            pools = macro_server.get_pool(pool),
        for pool in pools:
            for elem_info in pool.getElements():
                if self.accepts(elem_info):
                    objs[elem_info.name] = elem_info
        for macro_lib_name, macro_lib in macro_server.get_macros().items():
            if self.accepts(macro_lib):
                objs[macro_lib_name] = macro_lib
        for macro_name, macro in macro_server.get_macros().items():
            if self.accepts(macro):
                objs[macro_name] = macro

        return objs
Esempio n. 29
0
    def get_device(self, *args, **kwargs):
        """Factory method to create a single `tango.DeviceProxy` instance
        per controller instance.

        :param ctrl_name: Controller name to which assign the proxy object
        :type ctrl_name: `str`
        :param device_name: Tango device name
        :type device_name: `str`
        :return: single device proxy object
        :rtype: `tango.DeviceProxy`
        """
        ctrl_name = args[0]
        device_name = args[1]
        with self._lock:
            ctrl_devs = self._ctrl_proxies.get(ctrl_name)
            if ctrl_devs is None:
                self._ctrl_proxies[ctrl_name] = ctrl_devs = CaselessDict()
            dev = ctrl_devs.get(device_name)
            if dev is None:
                import PyTango
                ctrl_devs[device_name] = dev = PyTango.DeviceProxy(device_name)
        return dev
Esempio n. 30
0
 def getElementsOfTypes(self, elem_types):
     elems = CaselessDict()
     for elem_type in elem_types:
         elems.update(self.getElementsOfType(elem_type))
     return elems