def store_metadata(self): for metakey in self.MetadataSources.keys(): if not self.MetadataSources[metakey]['enabled']: continue try: attprx = PyTango.AttributeProxy( self.MetadataSources[metakey]['tango_attr']) attrinfo = attprx.get_config() attprx.get_device_proxy().set_timeout_millis(500) data_in = attprx.read().value del attprx except Exception, ex: self.MetadataSources[metakey]['status'] = 'ALARM' print "store_metadata, attribute proxy", metakey, ex continue # retries = 0 while retries < 3: if metakey in self._hdf_file: break try: # Create HDF dataset dset = self._hdf_file.create_dataset(metakey, data=data_in) #dset = self._hdf_file[metakey] dset.attrs["unit"] = attrinfo.unit break except Exception, ex: print "store_metadata", metakey, self.trg_start, ex retries += 1
def read_PolledDoubleScalar(self): # PROTECTED REGION ID(MyDevice.PolledDoubleScalar_read) ENABLED START # attr_proxy = PyTango.AttributeProxy(self.DeviceToRead + '/double_scalar') self.polled_ds = attr_proxy.read().value self.debug_stream(str(self.polled_ds)) return self.polled_ds
def createChannelDict(channel, index=None, **kwargs): from taurus.core.tango import FROM_TANGO_TO_STR_TYPE import PyTango import numpy if isinstance(channel, (str, unicode)): #@fixme: to make things uglier, I lazily assume Tango attribute namin dev_name, attr_name = channel.rsplit('/', 1) name = attr_name try: dev = PyTango.DeviceProxy(dev_name) db = dev.get_device_db() try: alias = db.get_alias(dev.name()) except: # no alias... alias = dev.name() label = alias + "/" + attr_name except: label = channel full_name = channel source = channel else: name = channel['name'] label = name full_name = channel['full_name'] source = channel['source'] ret = { 'name': name, 'label': label, 'full_name': full_name, 'enabled': True, # bool. Whether this channel is enabled (if not enabled, it won't be used for output or plot) 'output': True, # bool. Whether to show output in the stdout 'data_type': 'float64', 'data_units': 'No unit', # 'timer': '', #should contain a channel name # 'monitor': '', #should contain a channel name # 'trigger': '', #should contain a channel name 'conditioning': '', #this is a python expresion to be evaluated for conditioning the data. The data for this channel can be referred as 'x' and data from other channels can be referred by channel name 'normalization': Normalization.No, # one of the Normalization enumeration members 'nexus_path': '', #string indicating the location of the data of this channel within the nexus tree } #If the channel is a Tango one, try to guess data_type, shape and data_units attrproxy = attrconf = value = None dtype = shape = None try: attrproxy = PyTango.AttributeProxy(source) attrconf = attrproxy.get_config() # avoid trying to read for scalars. We know that their shape must be () if attrconf.data_format != PyTango.AttrDataFormat.SCALAR: value = attrproxy.read().value except Exception, e: print str(e)
def setValue(self, newValue, wait=False): #newval = PyTango.AttributeValue() #newval.value = newValue #self.device.write_attribute(self.attributeName, newval) attr = PyTango.AttributeProxy(self.deviceName + "/" + self.attributeName) a = attr.read() a.value = newValue attr.write(a)
def get_proxy(argin,use_tau=False,keep=False): """ Returns attribute or device proxy depending on argin syntax """ if argin.count('/')>(2+(':' in argin)): return PyTango.AttributeProxy(argin) else: return get_device(argin,use_tau,keep)
def prepareExtraAttrs(self, extraAttrList): ''' ''' for attrName in extraAttrList: if attrName.count('/') == 0: #no slashes means no full name attrName = self._devName + '/' + attrName self._extraAttrList.append(attrName) self._extraAttrProxies.append(PyTango.AttributeProxy(attrName))
def plot_tango_attribute(ns): redirect_bokeh_output() n = ns.attr.count("/") if not n: ap = tango.AttributeProxy(ns.attr) av = ap.read() fqan = ap.get_device_proxy().name() + "/" + ap.name() title = ns.attr + " [" + fqan + "]" elif n == 3: dn, _, an = ns.attr.rpartition("/") dp = tango.DeviceProxy(dn) av = dp.read_attribute(an) fqan = ns.attr else: raise Exception( "invalid attribute name specified - expected an alias or something like 'fully/qualified/attribute/name'" ) kwargs = dict() kwargs['tools'] = 'pan,wheel_zoom,box_select,reset,hover' kwargs['title'] = fqan + ' @ ' + datetime.datetime.now().strftime( "%Y-%m-%d %H:%M:%S") if ns.width is not None: kwargs['plot_width'] = ns.width if ns.height is not None: kwargs['plot_height'] = ns.height upsidedown = ns.upsidedown if ns.upsidedown is not None else False plot = None if av.data_format == tango.AttrDataFormat.SCALAR: print(fqan + " = " + str(av.value)) elif av.data_format == tango.AttrDataFormat.SPECTRUM: kwargs['toolbar_location'] = 'above' plot = figure(**kwargs) plot.line(range(av.value.shape[0]), av.value, line_width=1) plot.circle(range(av.value.shape[0]), av.value, size=3) elif av.data_format == tango.AttrDataFormat.IMAGE: kwargs['toolbar_location'] = 'right' lcm = LinearColorMapper(palette=Plasma256) ymin = 0 if not upsidedown else av.dim_y ymax = av.dim_y if not upsidedown else 0 plot = figure(x_range=(0, av.dim_x), y_range=(ymin, ymax), **kwargs) image = av.value if not upsidedown else av.value[::-1] plot.image(image=[image], x=0, y=ymin, dw=av.dim_x, dh=av.dim_y, color_mapper=lcm) else: print(fqan + " has an unknown/unsupported attribute data format [{}]".format( str(av.data_format))) if plot: ht = plot.select(HoverTool)[0] ht.tooltips = [("index", "$index"), ("(x,y)", "(@x, @y)")] plot.toolbar.active_drag = None plot.toolbar.active_scroll = None plot.toolbar.logo = None tango_attribute_plots[fqan] = show(plot, notebook_handle=True)
def connect(self): """ connects the source """ try: fattr, dattr, dirtrans = str(self._configuration).strip().split( ",", 2) self.__dirtrans = json.loads(dirtrans) if not self._initiated: self.__fproxy = PyTango.AttributeProxy(fattr) if dattr: self.__dproxy = PyTango.AttributeProxy(dattr) else: self.__dproxy = None return True except Exception as e: self._updaterror() print(str(e)) return False
def __init__(self, device_name='i11-ma-c00/ca/cpt.2', attribute_name='Ext_Eiger', sleeptime=0.005): monitor.__init__(self) self.device = PyTango.DeviceProxy(device_name) self.attribute = PyTango.AttributeProxy('%s/%s' % (device_name, attribute_name))
def GetInput(self): # PROTECTED REGION ID(ZadanieAngleCalculation.GetInput) ENABLED START # try: self.attr_proxy = PyTango.AttributeProxy( 'sys/tg_test/1/double_scalar') self.value = self.attr_proxy.read( ).value # metoda read() zwraca obiekt DeviceAttribute except Exception as e: self.set_state(DevState.FAULT) self.set_status("Exception caught in GetInput:\n%s" % e)
def initPSHU(self): try: sh_attr_name = self.getEnv('PshuAttr') self.sh_timeout = self.getEnv('PshuTimeout') self.attr = PyTango.AttributeProxy(sh_attr_name) except Exception as e: msg = 'The macro use the environment variable PshuAttr which ' \ 'has the attribute name of the EPS to open the shutter, ' \ 'and the variable PshuTimeout with the timeout in seconds ' \ '\n{}'.format(e) raise RuntimeError(msg)
def connect(self): """ connects the source """ try: if not self._initiated: self.__aproxy = PyTango.AttributeProxy(str( self._configuration)) return True except Exception as e: print(str(e)) self._updaterror() return False
def __connect(self, val=None): try: # data source proxy (connection to Tango device server) self._proxy = tango.AttributeProxy(self._fqan) except Exception as e: self.__reset_connection() err = "failed to initialize attribute monitor for '{}'\n".format(self._fqan) err += self.__error_tips(e) # print("{}".format(err)) if val: val.set_error(err, e) raise
def get_attribute_info(cls, fully_specified_attribute_name): """ Returns the AttributeInfo of the specified attribute :param fully_specified_attribute_name: the fully specified Tango attribute name :type fully_specified_attribute_name: str or unicode :returns the requested attribute info as an instance of AttributeInfo :rtype: AttributeInfo """ assert isinstance(fully_specified_attribute_name, string_types) attr = tango.AttributeProxy(fully_specified_attribute_name) attr_info = AttributeInfo() attr_info.extract_from_device_attribute(attr.read()) return attr_info
def run(self): """ worker thread """ self.__proxy = PyTango.AttributeProxy( "%s/%s" % (self.__device, self.__attribute)) stime = time.time() etime = stime while etime - stime < self.__period: self.__proxy.read() etime = time.time() self.__counter += 1 self.__qresult.put( utils.Result(self.__wid, self.__counter, etime - stime))
def store_sync_player_metadata(self, daq_thread): player_metadata = daq_thread.player_metadata dset = self._hdf_file[daq_thread.player_nickname] for key in player_metadata.keys(): try: attprx = PyTango.AttributeProxy( player_metadata[key].tango_attr) attprx.get_device_proxy().set_timeout_millis(500) data_in = attprx.read().value del attprx # dset.attrs[key] = data_in except Exception, ex: print "store_sync_player_metadata", key, ex
def trigger(self, path): try: # Setup proxy if necessary if (not self.dev) and (not self.attr): if self.tango_name.find('->') > 0: name_spl = self.tango_name.split('->') self.dev = (PyTango.DeviceProxy(name_spl[0]), name_spl[1]) self.Proxy.set_timeout_millis(500) else: self.attr = PyTango.AttributeProxy(self.tango_name) # Notify if self.dev: self.dev[0].command_inout(self.dev[1], str(path)) else: self.attr.write(str(path)) except Exception, ex: #PyTango.Except.print_exception(ex) print "*** Notification error: Exception on", self.tango_name return False
def push_event(self, event): #print event da = event.attr_value if da is not None: if da.type == PyTango.DevEnum: # print '==> ENUM ATTR!' ap = PyTango.AttributeProxy(event.attr_name) attr_config = ap.get_config() enum_label = attr_config.enum_labels[da.value] print( 'Event %s (attr=%s): value=%s (enum=%s), quality=%s (date=%s, data_type=%s, data_format=%s)' ) % (event.event, da.name, da.value, enum_label, da.quality, da.time, da.type, da.data_format) else: print( 'Event %s (attr=%s): value=%s, quality=%s (date=%s, data_type=%s, data_format=%s)' ) % (event.event, da.name, da.value, da.quality, da.time, da.type, da.data_format)
def append(self, attr_name): attr_name = attr_name.lower() if attr_name in self._attrs: return True try: attr_proxy = PyTango.AttributeProxy(attr_name) self._attrs[attr_name] = [attr_proxy] except Exception as e: self.log.error('Can not create DeviceProxy to {0}. ' 'Error {1}'.format(attr_name, e)) return False try: id = attr_proxy.subscribe_event(PyTango.EventType.CHANGE_EVENT, self._listener) self._attrs[attr_name].append(id) except Exception as e: self.log.error('Can not subscribe to Change Event to {0}. ' 'Error {1}'.format(attr_name, e)) return False return True
def setTangoAttribute(self, attr_name): if self.attr is not None: self.__unsubscribe() self.attr = None if attr_name == "": # Clearing widget self.__cleanWidget() else: print("[D] Setting up attribute", attr_name) try: self.attr = PT.AttributeProxy(attr_name) self.attr.ping() self.setupWidget() self.evid = self.attr.subscribe_event( PT.EventType.CHANGE_EVENT, self.event_callback) except PT.DevFailed as e: # TODO error print( "[E] Failed to setup attribute '{0}'. Error: {1!s}".format( attr_name, e.args[0].desc))
def getSource(cls, name): """ provides datasource from pool device :param name: pool device name :type name: :obj:`str` :returns: source of pool device :rtype: :obj:`str` """ source = None try: dp = PyTango.DeviceProxy(str(name)) if hasattr(dp, 'DataSource'): ds = dp.DataSource sds = ds.split("://") ap = PyTango.AttributeProxy(sds[-1]) if ap is None: raise Exception("Empty proxy") source = sds[-1] except (PyTango.DevFailed, PyTango.Except, PyTango.DevError): pass return source
def getShapeTypeUnit(cls, source): """ retrives shape type units for attribure :param source: string with device name and its attribute :type source: :obj:`str` :returns: (shape, data_type, units) :rtype: (:obj:`list` <:obj:`int`>, :obj:`str`, :obj:`str`) """ vl = None shp = [] dt = 'float64' ut = 'No unit' ap = PyTango.AttributeProxy(source) da = None ac = None try: ac = ap.get_config() if ac.data_format != PyTango.AttrDataFormat.SCALAR: da = ap.read() vl = da.value except (PyTango.DevFailed, PyTango.Except, PyTango.DevError): if ac and ac.data_format != PyTango.AttrDataFormat.SCALAR \ and (da is None or not hasattr(da, 'dim_x')): raise if vl is not None: shp = list(numpy.shape(vl)) elif ac is not None: if ac.data_format != PyTango.AttrDataFormat.SCALAR: if da.dim_x and da.dim_x > 1: shp = [da.dim_y, da.dim_x] \ if da.dim_y \ else [da.dim_x] if ac is not None: dt = cls.tTnp[ac.data_type] ut = ac.unit return (shp, dt, ut)
def read_ImagineMaximum(self): # PROTECTED REGION ID(MyDevice.ImagineMaximum_read) ENABLED START # attr_proxy = PyTango.AttributeProxy(self.DeviceToRead + '/double_image_ro') value = attr_proxy.read().value maximums = [] for row in value: maximums.append(max(row)) self.image_maximum = max(maximums) attr_quality = AttrQuality.ATTR_VALID self.push_change_event("ImagineMaximum", self.image_maximum, time(), attr_quality) self.push_archive_event("ImagineMaximum", self.image_maximum, time(), attr_quality) if (self.image_maximum < 20): self.set_state(DevState.OFF) else: if (self.image_maximum < 30): self.set_state(DevState.WARNING) else: self.set_state(DevState.ON) return float(self.image_maximum), time(), attr_quality
def __init__(self, extractor, resize=False, label="", parent=None): """ Constructor """ # Get attribute list attrs = extractor.GetAttNameAll() attr_list = [] for a in attrs: try: ap = PT.AttributeProxy(a) conf = ap.get_config() attr_list.append({ 'attribute': a, 'data_format': conf.data_format, 'data_type': conf.data_type }) except PT.DevFailed: attr_list.append({'attribute': a}) # Common parent constructor QBaseAttributeTree.__init__(self, attr_list, resize=resize, label=label, parent=parent)
def __init__(self, fresh=True, save=True, temperature=True, aperture=True, cpbs=True): self.md2 = PyTango.DeviceProxy('i11-ma-cx1/ex/md2') self.imag = PyTango.DeviceProxy('i11-ma-cx1/ex/imag.1') #self.lima = TangoLimaVideo.TangoLimaVideo() #self.lima.tangoname = 'lima/limaccd/1' self.lima = PyTango.DeviceProxy('lima/limaccd/1') self.md2bp = PyTango.DeviceProxy('i11-ma-cx1/ex/md2-beamposition') self.thermometres = dict([(therm, PyTango.AttributeProxy(therm)) for therm in self.therm_attributes]) self.zooms = range(1, 11) self.collect = Collect.collect() # exposures more appropriate with lower flux: ~5% of transmission #self.exposures = {1: 0.021, #2: 0.021, #3: 0.021, #4: 0.021, #5: 0.021, #6: 0.021, #7: 0.021, #8: 0.021, #9: 0.021, #10: 0.021} self.exposures = { 1: 0.005, 2: 0.003, 3: 0.002, 4: 0.002, 5: 0.002, 6: 0.002, 7: 0.002, 8: 0.002, 9: 0.003, 10: 0.003 } #Chip mode (without cryo) #self.exposures = {1: 0.01, #2: 0.01, #3: 0.01, #4: 0.01, #5: 0.02, #6: 0.02, #7: 0.02, #8: 0.05, #9: 0.05, #10: 0.05} #8 bunch #self.exposures = {1: 0.05, #2: 0.01, #3: 0.01, #4: 0.01, #5: 0.01, #6: 0.01, #7: 0.01, #8: 0.01, #9: 0.01, #10: 0.01} #1 bunch #self.exposures = {1: 0.21, #2: 0.1, #3: 0.1, #4: 0.1, #5: 0.1, #6: 0.1, #7: 0.2, #8: 0.2, #9: 0.25, #10: 0.25} #self.exposures = {1: 1, #2: 1, #3: 1, #4: 1, #5: 1, #6: 1, #7: 1, #8: 1, #9: 1, #10: 1} self.fresh = fresh self.save = save self.images = {} self.cData = {} self.beamposition = {} self.infostore = {} self.timestamp = time.time()
dset = self._hdf_file[daq_thread.player_nickname] for key in player_metadata.keys(): try: attprx = PyTango.AttributeProxy( player_metadata[key].tango_attr) attprx.get_device_proxy().set_timeout_millis(500) data_in = attprx.read().value del attprx # dset.attrs[key] = data_in except Exception, ex: print "store_sync_player_metadata", key, ex # # Unit is default try: attprx = PyTango.AttributeProxy(daq_thread.player_attrname) attrinfo = attprx.get_config() del attprx # dset.attrs["unit"] = attrinfo.unit except Exception, ex: print "store_sync_player_metadata, deafult unit", daq_thread.player_attrname, ex #----------------------------------------------------------------------------------- # store_data #----------------------------------------------------------------------------------- def store_data(self, daq_queue_item): daq_thread = daq_queue_item[0] trg = daq_queue_item[1] data_in = daq_thread._data_buffer[trg]
def createChannelDict(channel, index=None, **kwargs): from taurus.core.tango import FROM_TANGO_TO_STR_TYPE import PyTango import numpy if isinstance(channel, str): #@fixme: to make things uglier, I lazily assume Tango attribute namin dev_name, attr_name = channel.rsplit('/', 1) name = attr_name try: dev = PyTango.DeviceProxy(dev_name) db = dev.get_device_db() try: alias = db.get_alias(dev.name()) except: # no alias... alias = dev.name() label = alias + "/" + attr_name except: label = channel full_name = channel source = channel else: name = channel['name'] label = name full_name = channel['full_name'] source = channel['source'] ret = { 'name': name, 'label': label, 'full_name': full_name, # bool. Whether this channel is enabled (if not enabled, it won't be # used for output or plot) 'enabled': True, 'output': True, # bool. Whether to show output in the stdout 'data_type': 'float64', 'data_units': 'No unit', # 'timer': '', #should contain a channel name # 'monitor': '', #should contain a channel name # 'trigger': '', #should contain a channel name # 'value_ref_enabled': False, # bool # 'value_ref_pattern': '', # str 'conditioning': '', # this is a python expresion to be evaluated for conditioning the data. The data for this channel can be referred as 'x' and data from other channels can be referred by channel name 'normalization': Normalization.No, # one of the Normalization enumeration members # string indicating the location of the data of this channel within # the nexus tree 'nexus_path': '', } # If the channel is a Tango one, try to guess data_type, shape and # data_units attrproxy = attrconf = value = None dtype = None try: attrproxy = PyTango.AttributeProxy(source) attrconf = attrproxy.get_config() # avoid trying to read for scalars. We know that their shape must be () if attrconf.data_format != PyTango.AttrDataFormat.SCALAR: value = attrproxy.read().value except Exception as e: print(str(e)) if value is not None: dtype = getattr(value, 'dtype', numpy.dtype(type(value))).name ret['data_units'] = attrconf.unit elif attrconf is not None: dtype = FROM_TANGO_TO_STR_TYPE[attrconf.data_type] ret['data_units'] = attrconf.unit if dtype is not None: # if dtype.startswith('str'): # dtype='char' # shape = list(shape)+[DEFAULT_STRING_LENGTH] # elif dtype == 'bool': # dtype='int8' ret['data_type'] = dtype # now overwrite using the arguments ret.update(kwargs) # Calculate the index if index is not None: # an integer used for ordering the channel in this measurement group ret['index'] = index # Choose a default plot_type for the channel if 'plot_type' not in ret: ret['plot_type'] = PlotType.No # And a default value for plot_axes if 'plot_axes' not in ret: default_axes = { PlotType.No: [], PlotType.Spectrum: ['<mov>'], PlotType.Image: ['<idx>', '<idx>'] } # a string defining a colon-separated list of axis names. An axis can # be a channel name or "<idx>". This shares the syntax of the NeXus # @axes attribute ret['plot_axes'] = default_axes[ret['plot_type']] return ret
def pickPlotPoint(self, pos, scope=20, showMarker=True, targetCurveNames=None, xlabels=None): '''Finds the pyxel-wise closest data point to the given position. The valid search space is constrained by the scope and targetCurveNames parameters. :param pos: (Qt.QPoint or Qt.QPolygon) the position around which to look for a data point. The position should be passed as a Qt.QPoint (if a Qt.QPolygon is given, the first point of the polygon is used). The position is expected in pixel units, with (0,0) being the top-left corner of the plot canvas. :param scope: (int) defines the area around the given position to be considered when searching for data points. A data point is considered within scope if its manhattan distance to position (in pixels) is less than the value of the scope parameter. (default=20) :param showMarker: (bool) If True, a marker will be put on the picked data point. (default=True) :param targetCurveNames: (sequence<str>) the names of the curves to be searched. If None passed, all curves will be searched :return: (tuple<Qt.QPointF,str,int> or tuple<None,None,None>) if a point was picked within the scope, it returns a tuple containing the picked point (as a Qt.QPointF), the curve name and the index of the picked point in the curve data. If no point was found within the scope, it returns None,None,None ''' print "pickPlotPoint(...)" if isinstance(pos, Qt.QPolygon): pos = pos.first() scopeRect = Qt.QRect(0, 0, scope, scope) scopeRect.moveCenter(pos) mindist = scope picked = None pickedCurveName = None pickedIndex = None self.curves_lock.acquire() try: if targetCurveNames is None: targetCurveNames = self.curves.keys() #print '%d targetCurveNames'%len(targetCurveNames) for name in targetCurveNames: curve = self.curves.get(name, None) if curve is None: #print("Curve '%s' not found"%name) continue if not curve.isVisible(): #print("Curve '%s' not visible"%name) continue data = curve.data() #print("Curve '%s' has %d points"%(name,data.size())) for i in xrange(data.size()): point = Qt.QPoint(self.transform(curve.xAxis(), data.x(i)), self.transform(curve.yAxis(), data.y(i))) if scopeRect.contains(point): #print( 'Comparing %s,%s vs %s'%(pos,scopeRect,point)) dist = (pos - point).manhattanLength() if dist < mindist: mindist = dist picked = Qt.QPointF(data.x(i), data.y(i)) pickedCurveName = name pickedIndex = i pickedAxes = curve.xAxis(), curve.yAxis() found = True #if picked: print("Curve '%s' contains %s"%(name,pos)) finally: self.curves_lock.release() if picked is None: print 'pickPlotPoint(%s)> No matching point found for any curve' % pos return xlabels = xlabels or [] print("pickPlotPoint(x=%s,y=%s,xlabels=[%s])" % (picked.x(), picked.y(), len(xlabels))) if showMarker and picked is not None: print 'showing pickedMarker' self._pickedMarker.detach() self._pickedMarker.setValue(picked) self._pickedMarker.setAxis(*pickedAxes) self._pickedMarker.attach(self) self._pickedCurveName = pickedCurveName self._pickedMarker.pickedIndex = pickedIndex self.replot() label = self._pickedMarker.label() try: xi, xl = ([(x[0], x[1]) for x in (xlabels or []) if x[0] <= picked.x()] or [[-1, None]])[-1] c = self.curves[pickedCurveName] #xc = [self.transform(c.xAxis(),x) for x in c.data().xData()] xc = [x for x in c.data().xData()] xx = len([x for x in xc if x >= xi and x <= picked.x()]) #print [x[0] for x in xlabels] #print 'picked point: %s'%picked.x() #print 'last label %s at %s'%(xl,xi) #print 'data point are %s'%(xc) #print 'data points between pick and label: %s'%xx index = xx tag = '%s-%02d' % (xl, index) if xl and '/ip' in pickedCurveName.lower(): try: tag = PyTango.AttributeProxy( tag.replace('-', '/VC/IP-') + '/Controller').read().value except: import traceback print traceback.format_exc() except: import traceback print traceback.format_exc() index, xl = (-1, None) tag = '' if xl: infotxt = "'%s'[%i]:\n\t (%s,%.2e)" % ( pickedCurveName, pickedIndex, tag, picked.y()) elif self.getXIsTime(): infotxt = "'%s'[%i]:\n\t (x=%s,%.3g)" % ( pickedCurveName, pickedIndex, datetime.fromtimestamp( picked.x()).ctime(), picked.y()) else: infotxt = "'%s'[%i]:\n\t (x=%.3g, y=%.3g)" % ( pickedCurveName, pickedIndex, picked.x(), picked.y()) label.setText(infotxt) print '\t%s' % infotxt fits = label.textSize().width() < self.size().width() if fits: label.setText(infotxt) self._pickedMarker.setLabel(Qwt5.QwtText(label)) self._pickedMarker.alignLabel() self.replot() else: popup = Qt.QWidget(self, Qt.Qt.Popup) popup.setLayout(Qt.QVBoxLayout()) popup.layout().addWidget( Qt.QLabel(infotxt) ) #@todo: make the widget background semitransparent green! popup.setWindowOpacity(self._pickedMarker.labelOpacity) popup.show() popup.move(self.pos().x() - popup.size().width(), self.pos().y()) popup.move(self.pos()) Qt.QTimer.singleShot(5000, popup.hide) return picked, pickedCurveName, pickedIndex
def run(self): attr = PyTango.AttributeProxy(DEV_NAME + "/attr1") attr.write(10)
def init(self): import PyTango self.attr_proxy = PyTango.AttributeProxy(self.raw_value)