Commit 63a93042 authored by Matias Guijarro's avatar Matias Guijarro
Browse files

adapted all Tango imports to bliss.common.tango

parent 2d6f9da3
......@@ -19,6 +19,7 @@ from ..exceptions import CommunicationError, CommunicationTimeout
from ...common.greenlet_utils import KillMask, protect_from_kill
from bliss.common.utils import OrderedDict
from bliss.common.tango import DeviceProxy
__TMO_TUPLE = (0., 10E-6, 30E-6, 100E-6, 300E-6,
1E-3, 3E-3, 10E-3, 30E-3, 100E-3, 300E-3,
......@@ -195,9 +196,8 @@ class TangoDeviceServer:
def init(self):
self._debug("TangoDeviceServer::init()")
import PyTango
if self._proxy is None:
self._proxy = PyTango.DeviceProxy(self._tango_url)
self._proxy = DeviceProxy(self._tango_url)
def close(self):
self._proxy = None
......
......@@ -14,7 +14,7 @@ import weakref
from bliss.common.axis import Axis, AxisRef
from bliss.common.encoder import Encoder
from bliss.config.static import Config, get_config
import bliss.controllers.motors
from bliss.common.tango import DeviceProxy
import gevent
import hashlib
import sys
......@@ -170,17 +170,15 @@ def get_ctrl_html(cfg):
def __is_tango_device(name):
try:
import PyTango
return PyTango.DeviceProxy(name) is not None
return DeviceProxy(name) is not None
except:
pass
return False
def __tango_apply_config(name):
import PyTango.gevent
try:
device = PyTango.gevent.DeviceProxy(name)
device = DeviceProxy(name)
device.command_inout("ApplyConfig", True)
msg = "'%s' configuration saved and applied to server!" % name
msg_type = "success"
......
......@@ -11,7 +11,7 @@ import numpy
import math
import os
import logging
from PyTango.gevent import DeviceProxy
from bliss.common.tango import DeviceProxy
from bliss.common.scans import *
from bliss.controllers.motor_group import Group
from bliss.common.task_utils import *
......
......@@ -5,16 +5,7 @@
# Copyright (c) 2016 Beamline Control Unit, ESRF
# Distributed under the GNU LGPLv3. See LICENSE for more info.
import importlib
try:
from tango.gevent import DeviceProxy
except ImportError:
try:
from PyTango.gevent import DeviceProxy
except ImportError:
import warnings
from PyTango import DeviceProxy
warnings.warn("Tango does not support gevent, please update your Python tango version", RuntimeWarning)
from bliss.common.tango import DeviceProxy
from bliss.config import settings
from .bpm import Bpm
......
......@@ -11,7 +11,7 @@ import numpy
import math
import os
import logging
from PyTango.gevent import DeviceProxy
from bliss.common.tango import DeviceProxy
from bliss.common.scans import *
from bliss.controllers.motor_group import Group
from bliss.common.task_utils import *
......
......@@ -9,9 +9,7 @@ from bliss.controllers.motor import Controller
from bliss.common import log as elog
from bliss.common.axis import AxisState
from PyTango.gevent import DeviceProxy
from PyTango import DevState
from bliss.common.tango import PyTango, DeviceProxy
"""
......@@ -82,9 +80,9 @@ class TangoEMot(Controller):
def state(self, axis):
_state = self.axis_proxy.state()
if _state == DevState.ON:
if _state == PyTango.DevState.ON:
return AxisState("READY")
elif _state == DevState.MOVING:
elif _state == PyTango.DevState.MOVING:
return AxisState("MOVING")
else:
return AxisState("READY")
......
......@@ -10,11 +10,7 @@ import time
from bliss.controllers.motor import Controller
from bliss.common import log as elog
from bliss.common.axis import AxisState
from PyTango.gevent import DeviceProxy
from PyTango.gevent import AttributeProxy
from PyTango import DevState
from bliss.common.tango import PyTango, DeviceProxy, AttributeProxy
"""
undulator.py : a undulator controller for bliss.
......@@ -133,9 +129,9 @@ class Undulator(Controller):
def state(self, axis):
_state = self.device.state()
if _state == DevState.ON:
if _state == PyTango.DevState.ON:
return AxisState("READY")
elif _state == DevState.MOVING:
elif _state == PyTango.DevState.MOVING:
return AxisState("MOVING")
else:
return AxisState("READY")
......
......@@ -14,9 +14,7 @@ import time
import gevent.event
from bliss.common import event
from PyTango.gevent import AttributeProxy
from PyTango.gevent import DeviceProxy
from bliss.common.tango import AttributeProxy, DeviceProxy
"""
setpoint.py : 'setpoint' EMotion controller is a close copy of mockup
......
......@@ -22,7 +22,7 @@ YAML_ configuration example:
"""
import weakref
from bliss.common.measurement import SamplingCounter
import PyTango.gevent
from bliss.common.tango import DeviceProxy
_CtrGroupReadDict = weakref.WeakValueDictionary()
......@@ -38,7 +38,7 @@ class _CtrGroupRead(object):
def read_all(self,*counters):
if self._control is None:
self._control = PyTango.gevent.DeviceProxy(self._tango_uri)
self._control = DeviceProxy(self._tango_uri)
dev_attrs = self._control.read_attributes([cnt.attribute for cnt in counters])
#Check error
......
......@@ -7,11 +7,11 @@
from bliss.common.task_utils import cleanup, error_cleanup, task
from bliss.common.utils import add_property
from bliss.common.tango import DeviceProxy
from bliss.common.measurement import SamplingCounter
from bliss.common import Actuator
import gevent
from gevent import event
import PyTango.gevent
import numpy
class BpmGroupedReadHandler(SamplingCounter.GroupedReadHandler):
......@@ -67,9 +67,9 @@ class tango_bpm(object):
tango_lima_uri = config.get("lima_uri")
foil_actuator_name = config.get("foil_name")
self.__control = PyTango.gevent.DeviceProxy(tango_uri)
self.__control = DeviceProxy(tango_uri)
if tango_lima_uri:
self.__lima_control = PyTango.gevent.DeviceProxy(tango_lima_uri)
self.__lima_control = DeviceProxy(tango_lima_uri)
else:
self.__lima_control = None
self._acquisition_event = event.Event()
......
......@@ -7,7 +7,7 @@
from bliss.common.task_utils import cleanup, error_cleanup, task
from bliss.common.measurement import SamplingCounter
import PyTango.gevent
from bliss.common.tango import DeviceProxy
import time
import numpy
......@@ -15,7 +15,7 @@ class tango_keithley(SamplingCounter):
def __init__(self, name, config):
SamplingCounter.__init__(self, name, None)
tango_uri = config["uri"]
self.__control = PyTango.gevent.DeviceProxy(tango_uri)
self.__control = DeviceProxy(tango_uri)
def read(self):
self.__control.MeasureSingle()
......
......@@ -5,13 +5,13 @@
# Copyright (c) 2016 Beamline Control Unit, ESRF
# Distributed under the GNU LGPLv3. See LICENSE for more info.
import PyTango.gevent
from bliss.common.tango import DeviceProxy
import time
class tango_shutter:
def __init__(self, name, config):
tango_uri = config.get("uri")
self.__control = PyTango.gevent.DeviceProxy(tango_uri)
self.__control = DeviceProxy(tango_uri)
try:
self.manual = config.get("attr_mode")
except:
......
......@@ -6,14 +6,14 @@
# Distributed under the GNU LGPLv3. See LICENSE for more info.
from bliss.common.task_utils import *
import PyTango.gevent
from bliss.common.tango import DeviceProxy
class tango_transfocator:
def __init__(self, name, config):
tango_uri = config.get("uri")
self.__control = None
try:
self.__control = PyTango.gevent.DeviceProxy(tango_uri)
self.__control = DeviceProxy(tango_uri)
except PyTango.DevFailed, traceback:
last_error = traceback[-1]
print "%s: %s" % (tango_uri, last_error['desc'])
......
......@@ -7,7 +7,7 @@
import struct
import numpy
from PyTango.gevent import DeviceProxy
from bliss.common.tango import DeviceProxy
from bliss.data.node import DataNode
from bliss.config.settings import QueueObjSetting
from bliss.config.conductor import client
......@@ -47,7 +47,7 @@ class LimaDataNode(DataNode):
if to_index is None:
#first we try to get image directly from the server
if current_lima_acq == lima_acq_nb and DeviceProxy: # current acquisition
if current_lima_acq == lima_acq_nb: # current acquisition
if LastImageAcquired < from_index: # image is not yet available
raise RuntimeError('image is not yet available')
#should be still in server memory
......
......@@ -10,9 +10,7 @@
from os import environ
from datetime import timedelta
from collections import namedtuple
import tango
import tango.gevent
from bliss.common.tango import DeviceProxy, AttrQuality
from prompt_toolkit.token import Token
......@@ -36,17 +34,17 @@ Attribute = namedtuple('Attribute', 'label attr_name unit display')
QMAP = {
tango.AttrQuality.ATTR_VALID: StatusToken.Ok,
tango.AttrQuality.ATTR_WARNING: StatusToken.Warning,
tango.AttrQuality.ATTR_ALARM: StatusToken.Alarm,
tango.AttrQuality.ATTR_CHANGING: StatusToken.Changing,
AttrQuality.ATTR_VALID: StatusToken.Ok,
AttrQuality.ATTR_WARNING: StatusToken.Warning,
AttrQuality.ATTR_ALARM: StatusToken.Alarm,
AttrQuality.ATTR_CHANGING: StatusToken.Changing,
}
def tango_value(attr, value):
if value is None or value.has_failed or value.is_empty or \
value.quality == tango.AttrQuality.ATTR_INVALID:
value.quality == AttrQuality.ATTR_INVALID:
token, v = StatusToken.Error, '-----'
elif attr.display is None:
token, v = QMAP[value.quality], value.value
......@@ -62,7 +60,7 @@ class DeviceStatus(object):
def __init__(self, device, attributes=None):
if attributes is not None:
self.attributes = attributes
self.device = tango.gevent.DeviceProxy(device)
self.device = DeviceProxy(device)
def __call__(self, cli):
n = len(self.attributes)
......
......@@ -14,8 +14,8 @@ Example::
import sys
import functools
import gevent
from bliss.common.tango import DeviceProxy
def output(stream, msg):
if not msg or not stream:
......@@ -29,8 +29,7 @@ class Bliss(object):
LOOP_TIME = 1/25. # 25x per second
def __init__(self, dev_name, out_stream=sys.stdout, err_stream=sys.stderr):
import PyTango.gevent
self.__dev = PyTango.gevent.DeviceProxy(dev_name)
self.__dev = DeviceProxy(dev_name)
self.__out_stream = out_stream
self.__err_stream = err_stream
self.__curr_cmd = None
......
......@@ -8,8 +8,7 @@
from __future__ import absolute_import
import numpy
import PyTango.gevent
from bliss.common.tango import PyTango, DeviceProxy
from bliss.controllers.ct2 import BaseCT2Device, AcqMode, AcqStatus
PyTango.requires_pytango('8.1.8')
......@@ -24,7 +23,7 @@ class CT2Device(BaseCT2Device):
BaseCT2Device.__init__(self)
device_name = self.card_config['tango name']
self.__tango_device = PyTango.gevent.DeviceProxy(device_name)
self.__tango_device = DeviceProxy(device_name)
self.__tango_device.subscribe_event("acq_status",
PyTango.EventType.CHANGE_EVENT,
self.__on_status)
......
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