Ejemplo n.º 1
0
 def __init__(self, device_proxy: tango.DeviceProxy, *, name):
     self.parent = None
     self.name = name
     self.attributes = []
     for field in self.READ_FIELDS:
         class_ = type_map[device_proxy.get_attribute_config(
             field).writable]
         obj = class_(
             tango.AttributeProxy(f"{device_proxy.name()}/{field}", ),
             parent=self,
             kind=Kind.normal,
             name="_".join([self.name, field]),
         )
         self.attributes.append(obj)
         setattr(self, field, obj)
Ejemplo n.º 2
0
 def _get_initial_pos_value(self, axis):
     axis_attr = self.attributes[axis]
     initial_pos_value = axis_attr.get('initialpos')
     if initial_pos_value is None:
         initial_pos_value = 0
         proxy = axis_attr['initialposattrproxy']
         attr_name = axis_attr['initialposattr']
         if proxy is None and attr_name:
             proxy = tango.AttributeProxy(attr_name)
             # save in cache to avoid recreating AttributeProxy
             axis_attr['initialposattrproxy'] = proxy
         if proxy is not None:
             try:
                 initial_pos_value = float(proxy.read().value)
             except ValueError:
                 msg = "initialPosAttr (%s) is not float" % attr_name
                 raise Exception(msg)
     return initial_pos_value
Ejemplo n.º 3
0
def change_mntgrp(pool, tango_db_pqdn, tango_db_fqdn, verbose):
    hwinfo = pool.getHWObj().info()
    server = hwinfo.server_id

    db = tango.Database()
    dev_cls = db.get_device_class_list(server)

    for dev, cls in grouper(dev_cls, 2):
        if cls == "MeasurementGroup":
            config_attr = tango.AttributeProxy(dev + "/Configuration")
            try:
                config = config_attr.get_property("__value")["__value"][0]
            except:
                continue
            new_config = replace_tango_db(tango_db_pqdn, tango_db_fqdn, config)
            if verbose and config != new_config:
                print("changing {0} Configuration".format(dev))
            config_attr.put_property({"__value": new_config})
            mnt_grp = tango.DeviceProxy(dev)
            change_tango_prop_list(mnt_grp, "elements", tango_db_pqdn,
                                   tango_db_fqdn, verbose)
Ejemplo n.º 4
0
        return {}

    def describe_configuration(self):
        return {}


class TangoDevice:
    "Wrap a tango.DeviceProxy in the bluesky interface."
    def __init__(self, device_proxy):
        # Use device_proxy.list_attributes() to build structure at connection
        # time.
        ...

def extract_shape(reading):
    shape = []  # e.g. [10, 15]
    if reading.dim_x:
        shape.append(reading.dim_x)
    if reading.dim_y:
        shape.append(reading.dim_y)
    return shape


import tango
# device_proxy = tango.DeviceProxy('sys/tg_test/1')
attr_proxy = tango.AttributeProxy('sys/tg_test/1/double_scalar')
tango_attr = TangoAttribute(attr_proxy)
from bluesky import RunEngine
RE = RunEngine()
from bluesky.plans import count
from bluesky.callbacks.core import LiveTable
Ejemplo n.º 5
0
        "ushort_scalar",
        "ulong_scalar",
    ]


def extract_shape(reading):
    shape = []  # e.g. [10, 15]
    if reading.dim_x:
        shape.append(reading.dim_x)
    if reading.dim_y:
        shape.append(reading.dim_y)
    return shape


device_proxy = tango.DeviceProxy("sys/tg_test/1")
attr_proxy = tango.AttributeProxy("sys/tg_test/1/ampli")

tango_attr = TangoWritableAttribute(attr_proxy)
tango_device = TangoThingie(device_proxy, name="thingie")

motor_proxy = tango.DeviceProxy("motor/motctrl01/1")


class TangoMotor(TangoDevice):
    READ_FIELDS = [
        "position",
        "velocity",
    ]


motor = TangoMotor(motor_proxy, name="motor")
Ejemplo n.º 6
0
 def __init__(self, tango_name, *args, parent=None, **kwargs):
     self.kind = kwargs.get("kind", 1)
     self.attr_name = kwargs.get("attr_name", "")
     self._attribute_proxy = tango.AttributeProxy(tango_name)
     self.name = self._attribute_proxy.name()
     self.parent = parent