def get_archive_trend(models=None, length=4 * 3600, show=False): # This method is to be added to # PyTangoArchiving.widgets.trend in next releases #class PressureTrend(TaurusTrend): #def showEvent(self,event): #if not getattr(self,'_tuned',False): #setup_pressure_trend(self) #setattr(self,'_tuned',True) #TaurusTrend.showEvent(self,event) from taurus.external.qt import Qwt5 tt = TaurusTrend() try: tt.setXDynScale(True) tt.setUseArchiving(True) tt.setModelInConfig(False) tt.disconnect(tt.axisWidget(tt.xBottom), Qt.SIGNAL("scaleDivChanged ()"), tt._scaleChangeWarning) xMax = time.time() #tt.axisScaleDiv(Qwt5.QwtPlot.xBottom).upperBound() rg = length #abs(self.str2deltatime(str(self.ui.xRangeCB.currentText()))) xMin = xMax - rg tt.setAxisScale(Qwt5.QwtPlot.xBottom, xMin, xMax) if models: tt.setModel(models) if show: tt.show() tt.setWindowTitle('Trend') except: print 'Exception in set_pressure_trend(%s)' % tt print traceback.format_exc() return tt
def get_archive_trend(models=None,length=4*3600,show=False): # This method is to be added to PyTangoArchiving.widgets.trend in next releases #class PressureTrend(TaurusTrend): #def showEvent(self,event): #if not getattr(self,'_tuned',False): #setup_pressure_trend(self) #setattr(self,'_tuned',True) #TaurusTrend.showEvent(self,event) from PyQt4 import Qwt5 tt = TaurusTrend() try: tt.setXDynScale(True) tt.setUseArchiving(True) tt.setModelInConfig(False) tt.disconnect(tt.axisWidget(tt.xBottom), Qt.SIGNAL("scaleDivChanged ()"), tt._scaleChangeWarning) xMax = time.time() #tt.axisScaleDiv(Qwt5.QwtPlot.xBottom).upperBound() rg = length #abs(self.str2deltatime(str(self.ui.xRangeCB.currentText()))) xMin=xMax-rg tt.setAxisScale(Qwt5.QwtPlot.xBottom,xMin, xMax) if models: tt.setModel(models) if show: tt.show() tt.setWindowTitle('Trend') except: print 'Exception in set_pressure_trend(%s)'%tt print traceback.format_exc() return tt
#!/usr/bin/env python import sys from taurus.qt.qtgui.plot import TaurusTrend from taurus.qt.qtgui.application import TaurusApplication app = TaurusApplication(sys.argv) ########################## # BEGIN EXAMPLE CODE ########################## panel = TaurusTrend() model = ['sys/taurustest/1/position'] panel.setXIsTime(True) # to show the x values as time panel.setModel(model) ######################## # END EXAMPLE CODE ######################## panel.show() sys.exit(app.exec_())
class CyclePanel(TaurusWidget): "Panel for controlling the cycling functionality" trend_trigger = QtCore.pyqtSignal(bool) attrs = [ "CyclingTimePlateau", "CyclingIterations", "CyclingSteps", "CyclingRampTime", "NominalSetPoint" ] scale_factor = 1.1 def __init__(self, parent=None): TaurusWidget.__init__(self, parent) self._setup_ui() print('CyclePanel juste avant setmodel') # self.setModel('sys/tg_test/1') def scaleSize(self): size = self.form.scrollArea.widget().frameSize() return QtCore.QSize(size.width(), size.height() * self.scale_factor) def _setup_ui(self): vbox = QtGui.QVBoxLayout(self) self.setLayout(vbox) grid = QtGui.QGridLayout() self.form = MAXForm(withButtons=False) grid.addWidget(self.form, 0, 0, 2, 1) # rescale taurus form methode self.form.scrollArea.sizeHint = self.scaleSize self.status_label = StatusArea() grid.addWidget(self.status_label, 0, 1, 1, 1) commandbox = QtGui.QVBoxLayout(self) self.start_button = TaurusCommandButton(command="StartCycle") self.start_button.setUseParentModel(True) self.stop_button = TaurusCommandButton(command="StopCycle") self.stop_button.setUseParentModel(True) commandbox.addWidget(self.start_button) commandbox.addWidget(self.stop_button) grid.addLayout(commandbox, 1, 1, 1, 1) vbox.addLayout(grid) self.trend = TaurusTrend() vbox.addWidget(self.trend, stretch=1) self.trend_trigger.connect(self.set_trend_paused) self.cyclingState = None def setModel(self, device): print self.__class__.__name__, "setModel", device TaurusWidget.setModel(self, device) # self.state_button.setModel(device) if device: self.form.setModel( ["%s/%s" % (device, attribute) for attribute in self.attrs]) self.status_label.setModel("%s/cyclingStatus" % device) ps = str(PyTango.Database().get_device_property( device, "PowerSupplyProxy")["PowerSupplyProxy"][0]) self.trend.setPaused() self.trend.setModel(["%s/Current" % ps]) self.trend.setForcedReadingPeriod(0.2) self.trend.showLegend(True) # let's pause the trend when not cycling self.cyclingState = self.getModelObj().getAttribute("cyclingState") self.cyclingState.addListener(self.handle_cycling_state) else: if self.cyclingState: self.cyclingState.removeListener(self.handle_cycling_state) self.trend.setModel(None) self.status_label.setModel(None) def handle_cycling_state(self, evt_src, evt_type, evt_value): if evt_type in [ PyTango.EventType.CHANGE_EVENT, PyTango.EventType.PERIODIC_EVENT ]: self.trend_trigger.emit(evt_value.value) def set_trend_paused(self, value): self.trend.setForcedReadingPeriod(0.2 if value else -1) self.trend.setPaused(not value)
#!/usr/bin/env python import sys from taurus.external.qt import Qt from taurus.qt.qtgui.plot import TaurusTrend app = Qt.QApplication(sys.argv) ########################## # BEGIN EXAMPLE CODE ########################## panel = TaurusTrend() model = ['sys/taurustest/1/position'] panel.setXIsTime(True) # to show the x values as time panel.setModel(model) ######################## # END EXAMPLE CODE ######################## panel.show() sys.exit(app.exec_())