Exemple #1
0
 def styleQwtPlot(self, name, elem):
     font = QFont()
     font.setPixelSize(12)
     title = QwtText(name)
     title.setFont(font)
     elem.setTitle(title)
     canvas = elem.canvas()
     canvas.setLineWidth(0)
     elem.setCanvas(canvas)
    def label(self, value):
        #        self._log.debug(f"VALUE: {value}")
        #        self._log.debug(f"timestamp length: {len(self.timeStamps)}")
        try:
            try:
                dt = self.timeStamps[int(value)][0]
                return QwtText(dt.strftime(self.fmtFull))
            except IndexError:
                return QwtText(self.timeStamps[-1][0].strftime(self.fmtFull))

        except IndexError:
            #            self._log.debug(f"PROPER INDEX ERROR: {value}")
            return QwtText("0 Secs")
    def __init__(self, parent, title =QwtText()):

        QwtPlotItem.__init__(self)
        self.plot = parent
        self.display_type = "hippo"
        self.ValueAxis =  None
        self.ComplexColorMap = None
        self._flags_array = None
        self._nan_flags_array = None
        self._image_for_display = None
        self._display_flags = False
        self.Qimage = None
        self.r_cmax = None
        self.r_cmin = None
        self.i_cmax = None
        self.i_cmin = None
        self.raw_image = None
        self.dimap = None
        self.complex = False
        self.log_scale = False
        self.log_y_scale = False
        self.transform_offset = 0.0
        self.flag_colour = 0
        self.nan_colour = 255
        self.lock_image_real = False
        self.lock_image_imag = False
        self.setTitle(title)
def make():
    # create a plot with a white canvas
    demo = QwtPlot(QwtText("Errorbar Demonstation"))
    demo.setCanvasBackground(Qt.white)
    demo.plotLayout().setAlignCanvasToScales(True)

    grid = QwtPlotGrid()
    grid.attach(demo)
    grid.setPen(QPen(Qt.black, 0, Qt.DotLine))

    # calculate data and errors for a curve with error bars
    x = np.arange(0, 10.1, 0.5, np.float)
    y = np.sin(x)
    dy = 0.2 * abs(y)
    # dy = (0.15 * abs(y), 0.25 * abs(y)) # uncomment for asymmetric error bars
    dx = 0.2  # all error bars the same size
    errorOnTop = False  # uncomment to draw the curve on top of the error bars
    # errorOnTop = True # uncomment to draw the error bars on top of the curve
    curve = ErrorBarPlotCurve(
        x=x,
        y=y,
        dx=dx,
        dy=dy,
        curvePen=QPen(Qt.black, 2),
        curveSymbol=QwtSymbol(QwtSymbol.Ellipse, QBrush(Qt.red),
                              QPen(Qt.black, 2), QSize(9, 9)),
        errorPen=QPen(Qt.blue, 2),
        errorCap=10,
        errorOnTop=errorOnTop,
    )
    curve.attach(demo)
    demo.resize(640, 480)
    demo.show()
    return demo
 def label(self, value):
     try:
         # if value > len(self.timeStamps):
         #     return QwtText(self.timeStamps[0][0].strftime(self.fmt))
         # else:
         try:
             dt = (self.timeStamps[int(value)] -
                   self.timeStamps[0]).total_seconds()
             return QwtText(self.display_time(dt))
         except IndexError:
             #                self._log.debug(f"INDEX ERROR: {value}")
             dt = (self.timeStamps[0] - self.timeStamps[0]).total_seconds()
             return QwtText(self.display_time(dt))
     except IndexError:
         #            self._log.debug(f"PROPER INDEX ERROR: {value}")
         return QwtText("0 Secs")
    def __init__(self, *args):
        QwtPlot.__init__(self, *args)
        self.setTitle('ReallySimpleDemo.py')
        self.insertLegend(QwtLegend(), QwtPlot.RightLegend)
        self.setAxisTitle(QwtPlot.xBottom, 'x -->')
        self.setAxisTitle(QwtPlot.yLeft, 'y -->')
        self.enableAxis(self.xBottom)

        # insert a few curves
        cSin = QwtPlotCurve('y = sin(x)')
        cSin.setPen(QPen(Qt.red))
        cSin.attach(self)
        cCos = QwtPlotCurve('y = cos(x)')
        cCos.setPen(QPen(Qt.blue))
        cCos.attach(self)

        # make a Numeric array for the horizontal data
        x = np.arange(0.0, 10.0, 0.1)

        # initialize the data
        cSin.setData(x, np.sin(x))
        cCos.setData(x, np.cos(x))

        # insert a horizontal marker at y = 0
        mY = QwtPlotMarker()
        mY.setLabel(QwtText('y = 0'))
        mY.setLabelAlignment(Qt.AlignRight | Qt.AlignTop)
        mY.setLineStyle(QwtPlotMarker.HLine)
        mY.setYValue(0.0)
        mY.attach(self)

        # insert a vertical marker at x = 2 pi
        mX = QwtPlotMarker()
        mX.setLabel(QwtText('x = 2 pi'))
        mX.setLabelAlignment(Qt.AlignRight | Qt.AlignTop)
        mX.setLineStyle(QwtPlotMarker.VLine)
        mX.setXValue(2 * np.pi)
        mX.attach(self)

        # replot
        self.replot()
Exemple #7
0
    def __init__(self, database, parent=None):
        super().__init__(parent)
        self.db = database
        self.updateTimer = QTimer(self)
        self.updateTimer.start(5000)

        self.plot = QwtPlot()
        self.curve = QwtPlotCurve()
        self.curve.attach(self.plot)
        self.plot.resize(1000, 1000)
        self.plot.show()
        self.plot.setAxisScaleDraw(QwtPlot.xBottom, DateTimeTimeScaleDraw())

        axisFont = QFont("Helvetica", 11, QFont.Bold)
        titleFont = QFont("Helvetica", 12, QFont.Bold)

        xTitle = QwtText()
        xTitle.setText("Time")
        xTitle.setFont(axisFont)
        self.plot.setAxisTitle(self.plot.xBottom, xTitle)

        self.yTitle = QwtText()
        self.yTitle.setFont(axisFont)
        self.plot.setAxisTitle(self.plot.yLeft, self.yTitle)

        self.titleText = QwtText()
        self.titleText.setFont(titleFont)
        self.plot.setTitle(self.titleText)

        mainLayout = QHBoxLayout()
        mainLayout.addWidget(self.plot)
        self.setLayout(mainLayout)

        self.plot.show()
        self.results = []
        self.batchID = None
Exemple #8
0
def make():
    # create a plot with a white canvas
    demo = QwtPlot(QwtText("Curve Demonstation"))
    #   demo.setCanvasBackground(Qt.white)
    #   demo.plotLayout().setAlignCanvasToScales(True)

    #   grid = QwtPlotGrid()
    #   grid.attach(demo)
    #   grid.setPen(QPen(Qt.black, 0, Qt.DotLine))

    # calculate data and errors for a curve with error bars
    x = numpy.zeros(20, numpy.float32)
    y = numpy.zeros(20, numpy.float32)
    symbol_sizes = numpy.zeros(20, numpy.int32)
    symbolList = []
    for i in range(20):
        x[i] = 1.0 * i
        y[i] = 2.0 * i
        symbol_sizes[i] = 3 + i
        if i % 2 == 0:
            symbolList.append(
                QwtSymbol(QwtSymbol.UTriangle, QBrush(Qt.black),
                          QPen(Qt.black), QSize(3 + i, 3 + i)))
        else:
            symbolList.append(
                QwtSymbol(QwtSymbol.DTriangle, QBrush(Qt.red), QPen(Qt.red),
                          QSize(3 + i, 3 + i)))

    curve = QwtPlotCurveSizes(x=x, y=y, symbolSizes=symbol_sizes)
    x = x + 10
    curve1 = QwtPlotCurveSizes(x=x, y=y, symbolSizes=symbol_sizes)
    curve.setSymbol(
        QwtSymbol(QwtSymbol.Ellipse, QBrush(Qt.black), QPen(Qt.black),
                  QSize(5, 5)))
    curve.setPen(QPen(Qt.blue, 2))
    curve1.setSymbol(
        QwtSymbol(QwtSymbol.Ellipse, QBrush(Qt.red), QPen(Qt.red),
                  QSize(10, 10)))
    curve1.setPen(QPen(Qt.blue, 2))
    curve1.setSymbolList(symbolList)

    curve.attach(demo)
    curve1.attach(demo)
    demo.resize(640, 480)
    demo.show()
    return demo
Exemple #9
0
 def styleQwtPlot(self, name, elem):
     font = QFont()
     font.setPixelSize(24)
     title = QwtText(name)
     title.setFont(font)
     elem.setTitle(title)
 def __init__(self, title=QwtText()):
     QwtPlotItem.__init__(self)
     self.setTitle(title)
     self.setItemAttribute(QwtPlotItem.Legend)
     self.xyzs = None
    def __init__(self, *args):
        QwtPlot.__init__(self, *args)
        # set plot title
        self.setTitle('ImagePlot')
        # set plot layout
        self.plotLayout().setCanvasMargin(0)
        self.plotLayout().setAlignCanvasToScales(True)
        # set legend
        legend = QwtLegend()
        legend.setDefaultItemMode(QwtLegendData.Clickable)
        self.insertLegend(legend, QwtPlot.RightLegend)
        # set axis titles
        self.setAxisTitle(QwtPlot.xBottom, 'time (s)')
        self.setAxisTitle(QwtPlot.yLeft, 'frequency (Hz)')

        colorMap = QwtLinearColorMap(Qt.blue, Qt.red)
        interval = QwtInterval(-1, 1)
        self.enableAxis(QwtPlot.yRight)
        self.setAxisScale(QwtPlot.yRight, -1, 1)
        self.axisWidget(QwtPlot.yRight).setColorBarEnabled(True)
        self.axisWidget(QwtPlot.yRight).setColorMap(interval, colorMap)

        # calculate 3 NumPy arrays
        x = np.arange(-2 * np.pi, 2 * np.pi, 0.01)
        y = np.pi * np.sin(x)
        z = 4 * np.pi * np.cos(x) * np.cos(x) * np.sin(x)
        # attach a curve
        curve = QwtPlotCurve('y = pi*sin(x)')
        curve.attach(self)
        curve.setPen(QPen(Qt.green, 2))
        curve.setData(x, y)
        # attach another curve
        curve = QwtPlotCurve('y = 4*pi*sin(x)*cos(x)**2')
        curve.attach(self)
        curve.setPen(QPen(Qt.black, 2))
        curve.setData(x, z)
        # attach a grid
        grid = QwtPlotGrid()
        grid.attach(self)
        grid.setPen(QPen(Qt.black, 0, Qt.DotLine))
        # attach a horizontal marker at y = 0
        marker = QwtPlotMarker()
        marker.attach(self)
        marker.setValue(0.0, 0.0)
        marker.setLineStyle(QwtPlotMarker.HLine)
        marker.setLabelAlignment(Qt.AlignRight | Qt.AlignTop)
        marker.setLabel(QwtText('y = 0'))
        # attach a vertical marker at x = pi
        marker = QwtPlotMarker()
        marker.attach(self)
        marker.setValue(np.pi, 0.0)
        marker.setLineStyle(QwtPlotMarker.VLine)
        marker.setLabelAlignment(Qt.AlignRight | Qt.AlignBottom)
        marker.setLabel(QwtText('x = pi'))
        # attach a plot image
        plotImage = PlotImage('Image')
        plotImage.attach(self)
        plotImage.setData(square(512, -2 * np.pi, 2 * np.pi),
                          (-2 * np.pi, 2 * np.pi), (-2 * np.pi, 2 * np.pi))

        legend.SIG_CLICKED.connect(self.toggleVisibility)

        # replot
        self.replot()
Exemple #12
0
 def label(self, value):
     """value é o valor x do ponto a ser plotado"""
     return QwtText(time.ctime(value)[11:19])
Exemple #13
0
    def __init__(self, *args):
        QwtPlot.__init__(self, *args)
        
        self.uut_dev = None
        self.timerId = None
        self.interval = 250    # ms
        
        
        fileTIME = datetime.datetime.now()
        File_timestamp = "%04d-%02d-%02d_%02d%02d%02d" % (fileTIME.year,fileTIME.month,fileTIME.day,fileTIME.hour, fileTIME.minute, fileTIME.second)

        self.fileNamme = '.\data\data_%s.txt'%File_timestamp
        print(self.fileNamme)
        self.x_range = 180.1
        self.x_interval = 10.0
        self.y_range_Upper = 210.0
        self.y_range_Lower = -90.0
        self.y_interval = 20.0
        self.unit = 'kPa'  # default value, will replaced by actual reading.
        self.getReadingCommand = r"UPPER_VAL?\r\n"  # default pass and pac
        self.getResp_rex = r'^[-]?([0-9]{1,}[.]?[0-9]*)'
                              
        self.lenth = 40 # 10s caculate the slowrate
                
        # QwtPlot property
        # Initialize 坐标轴
        self.setCanvasBackground(Qt.white)  #Qt.white
        self.alignScales()
        grid = QwtPlotGrid()
        grid.attach(self)
        grid.setMajorPen(QPen(Qt.black, 0, Qt.DotLine))
        
        self.setAxisScale(QwtPlot.xBottom, 0.0,self.x_range,self.x_interval)
        #self.setAxisAutoScale(QwtPlot.yLeft,True)
        #self.setAxisScale(QwtPlot.yLeft,99.99,100.0,0.0005)
        self.setAxisScale(QwtPlot.yLeft,self.y_range_Lower,self.y_range_Upper,self.y_interval)
        self.setAxisLabelRotation(QwtPlot.xBottom,-45.0)
        
        self.x = np.arange(0.0, self.x_range + 1, 0.25)#0.25 for ONE POINT, THIS SHOULD BE Align to the reading rate:250ms

        #self.z = np.zeros(len(self.x), np.float)
        
        list = []
        for i in range(len(self.x)):
            list.append(0.0)
        self.z = np.array(list)  
       
        rlist = []
        
        for i in range(self.lenth):  # 10s
            rlist.append(0.0)       
        self.RateList = np.array(rlist)           

        self.setTitle("UUT Reading Monitor - OutPort(%s)\r\n"%(self.unit))
        self.insertLegend(QwtLegend(), QwtPlot.RightLegend);

        
        self.curveL = QwtPlotCurve("UUT Reading")
        self.curveL.attach(self)
        pen = QPen(Qt.red)
        pen.setWidth(1.5)
        self.curveL.setPen(pen)
        
        # show peak line and point value
        fn = self.fontInfo().family()
        self.peakMarker = m = QwtPlotMarker()
        m.setLineStyle(QwtPlotMarker.HLine)
        m.setLabelAlignment(Qt.AlignLeft | Qt.AlignTop)
        m.setLinePen(QPen(Qt.blue, 1.5, Qt.DashDotLine))
        
        text = QwtText('dfdfdfdf')
        text.setColor(Qt.red)
        text.setBackgroundBrush(QBrush(self.canvasBackground()))
        text.setFont(QFont(fn, 12, QFont.Bold))         
        m.setLabel(text)
        # MarkPoint symbol
        m.setSymbol(QwtSymbol(QwtSymbol.Diamond,
                              QBrush(Qt.blue),
                              QPen(Qt.green),
                              QSize(7,7)))
        m.attach(self)
        
        # text marker
        self.txtMarker = m = QwtPlotMarker()
        m.setValue(self.x_range/2, self.y_range_Upper - self.y_interval/2)   # show position
        m.setLabelAlignment(Qt.AlignRight | Qt.AlignBottom)
        text = QwtText('initial')
        text.setFont(QFont(fn, 20, QFont.Bold))
        text.setColor(Qt.white)
        text.setBackgroundBrush(QBrush(Qt.black))
        text.setBorderPen(QPen(Qt.red, 2))

        m.setLabel(text)
        m.attach(self)
        

        self.setAxisTitle(QwtPlot.xBottom, "Time (seconds)")
        self.setAxisTitle(QwtPlot.yLeft, "UUT - Reading(%s)"%(self.unit))
        self.replot()
 
        #self.startTimer(250)#ms# FOR GET READING
        
        self.starttime = time.clock();#unit: s
        self.idx = 0
        self.readfmt = "%f" 
        self.Saveinfo("Starting...")
Exemple #14
0
    def __init__(self, *args):
        QwtPlot.__init__(self, *args)

        self.setTitle('Frequency Response of a 2<sup>nd</sup>-order System')
        self.setCanvasBackground(Qt.darkBlue)

        # legend
        legend = QwtLegend()
        legend.setFrameStyle(QFrame.Box | QFrame.Sunken)
        self.insertLegend(legend, QwtPlot.BottomLegend)

        # grid
        self.grid = QwtPlotGrid()
        self.grid.enableXMin(True)
        self.grid.attach(self)

        # axes
        self.enableAxis(QwtPlot.yRight)
        self.setAxisTitle(QwtPlot.xBottom, '\u03c9/\u03c9<sub>0</sub>')
        self.setAxisTitle(QwtPlot.yLeft, 'Amplitude [dB]')
        self.setAxisTitle(QwtPlot.yRight, 'Phase [\u00b0]')

        self.setAxisMaxMajor(QwtPlot.xBottom, 6)
        self.setAxisMaxMinor(QwtPlot.xBottom, 10)
        self.setAxisScaleEngine(QwtPlot.xBottom, QwtLogScaleEngine())

        # curves
        self.curve1 = QwtPlotCurve('Amplitude')
        self.curve1.setRenderHint(QwtPlotItem.RenderAntialiased);
        self.curve1.setPen(QPen(Qt.yellow))
        self.curve1.setYAxis(QwtPlot.yLeft)
        self.curve1.attach(self)
        
        self.curve2 = QwtPlotCurve('Phase')
        self.curve2.setRenderHint(QwtPlotItem.RenderAntialiased);
        self.curve2.setPen(QPen(Qt.cyan))
        self.curve2.setYAxis(QwtPlot.yRight)
        self.curve2.attach(self)

        # alias
        fn = self.fontInfo().family()

        # marker
        self.dB3Marker = m = QwtPlotMarker()
        m.setValue(0.0, 0.0)
        m.setLineStyle(QwtPlotMarker.VLine)
        m.setLabelAlignment(Qt.AlignRight | Qt.AlignBottom)
        m.setLinePen(QPen(Qt.green, 2, Qt.DashDotLine))
        text = QwtText('')
        text.setColor(Qt.green)
        text.setBackgroundBrush(Qt.red)
        text.setFont(QFont(fn, 12, QFont.Bold))
        m.setLabel(text)
        m.attach(self)

        self.peakMarker = m = QwtPlotMarker()
        m.setLineStyle(QwtPlotMarker.HLine)
        m.setLabelAlignment(Qt.AlignRight | Qt.AlignBottom)
        m.setLinePen(QPen(Qt.red, 2, Qt.DashDotLine))
        text = QwtText('')
        text.setColor(Qt.red)
        text.setBackgroundBrush(QBrush(self.canvasBackground()))
        text.setFont(QFont(fn, 12, QFont.Bold))
        
        m.setLabel(text)
        m.setSymbol(QwtSymbol(QwtSymbol.Diamond,
                              QBrush(Qt.yellow),
                              QPen(Qt.green),
                              QSize(7,7)))
        m.attach(self)

        # text marker
        m = QwtPlotMarker()
        m.setValue(0.1, -20.0)
        m.setLabelAlignment(Qt.AlignRight | Qt.AlignBottom)
        text = QwtText(
            '[1-(\u03c9/\u03c9<sub>0</sub>)<sup>2</sup>+2j\u03c9/Q]'
            '<sup>-1</sup>'
            )
        text.setFont(QFont(fn, 12, QFont.Bold))
        text.setColor(Qt.blue)
        text.setBackgroundBrush(QBrush(Qt.yellow))
        text.setBorderPen(QPen(Qt.red, 2))
        m.setLabel(text)
        m.attach(self)

        self.setDamp(0.01)
Exemple #15
0
class FermentGraph(QWidget):
    _logname = 'FermentGraphGeneric'
    _log = logging.getLogger(f'{_logname}')

    def __init__(self, database, parent=None):
        super().__init__(parent)
        self.db = database
        self.updateTimer = QTimer(self)
        self.updateTimer.start(5000)

        self.plot = QwtPlot()
        self.curve = QwtPlotCurve()
        self.curve.attach(self.plot)
        self.plot.resize(1000, 1000)
        self.plot.show()
        self.plot.setAxisScaleDraw(QwtPlot.xBottom, DateTimeTimeScaleDraw())

        axisFont = QFont("Helvetica", 11, QFont.Bold)
        titleFont = QFont("Helvetica", 12, QFont.Bold)

        xTitle = QwtText()
        xTitle.setText("Time")
        xTitle.setFont(axisFont)
        self.plot.setAxisTitle(self.plot.xBottom, xTitle)

        self.yTitle = QwtText()
        self.yTitle.setFont(axisFont)
        self.plot.setAxisTitle(self.plot.yLeft, self.yTitle)

        self.titleText = QwtText()
        self.titleText.setFont(titleFont)
        self.plot.setTitle(self.titleText)

        mainLayout = QHBoxLayout()
        mainLayout.addWidget(self.plot)
        self.setLayout(mainLayout)

        self.plot.show()
        self.results = []
        self.batchID = None

    def updatePlot(self, variable):
        if self.batchID is not None:
            self.db.flushTables()
            sql = f"SELECT TimeStamp, {variable} FROM Ferment WHERE BatchID = '{self.batchID}'"

            timestamps = []
            self.results = []
            for data in self.db.custom(sql)[1:]:
                timestamps.append(data[0])
                self.results.append(data[1])

            startTime = timestamps[0]
            for i in range(len(timestamps)):
                timestamps[i] = (timestamps[i] - startTime).seconds

            # self.plot.setAxisScaleDraw(QwtPlot.xBottom, TimeScaleDraw())

            self.curve.setData(timestamps, self.results)
            self.plot.replot()
            self.plot.show()

    def changeTank(self, tankID):
        self.titleText.setText(f"Fermentation Tank: {tankID}")
    def label(self, value):
        # output = QwtText(datetime.timedelta(seconds=value))

        return QwtText(str(datetime.timedelta(seconds=value)))
 def label(self, value):
     return QwtText(self.display_time(seconds=value))
    def setTitle(self, title):

        titleText = QwtText()
        titleText.setText(title)
        titleText.setFont(self.titleFont)
        self.plot.setTitle(titleText)
    def setAxisTitles(self, yAxis, xAxis):

        # Create text for graph and axis titles
        xTitle = QwtText()
        xTitle.setText(xAxis)
        xTitle.setFont(self.axisFont)
        yTitle = QwtText()
        yTitle.setText(yAxis)
        yTitle.setFont(self.axisFont)

        self.plot.setAxisTitle(self.plot.yLeft, yTitle)
        self.plot.setAxisTitle(self.plot.xBottom, xTitle)
 def label(self, value):
     upTime = self.baseTime.addSecs(int(value))
     return QwtText(upTime.toString())
    def __init__(self, *args):
        QwtPlot.__init__(self, *args)

        self.uut_dev = None
        self.timerId = None
        #self.interval = 250    # ms
        self.interval = config.interval  # ms

        fileTIME = datetime.datetime.now()
        File_timestamp = "%04d-%02d-%02d_%02d%02d%02d" % (
            fileTIME.year, fileTIME.month, fileTIME.day, fileTIME.hour,
            fileTIME.minute, fileTIME.second)

        self.fileNamme = '.\data\data_%s.txt' % File_timestamp
        print('Raw data record file name:%s' % self.fileNamme)
        # default parameters from config file
        self.x_ZERO = config.X_lower
        self.x_range = config.X_upper
        self.x_interval = config.X_grid_interval
        self.y_range_Upper = config.Y_upper
        self.y_range_Lower = config.Y_lower
        self.y_interval = config.Y_grid_interval
        self.unit = 'kPa'  # default value, will replaced by actual reading.
        #self.getReadingCommand = r"UPPER_VAL?\r\n"  # default pass and pac
        #self.getResp_rex = r'^[-]?([0-9]{1,}[.]?[0-9]*)'

        self.lenth = config.Slope_lenth  #  40 = 10s caculate the slowrate

        # QwtPlot property
        # Initialize 坐标轴
        self.setCanvasBackground(Qt.white)  #Qt.white
        self.alignScales()
        grid = QwtPlotGrid()
        grid.attach(self)
        grid.setMajorPen(QPen(Qt.black, 0, Qt.DotLine))

        # x Axis property
        #self.setAxisScaleDraw(QwtPlot.xBottom, TimeScaleDraw(self.cpuStat.upTime()))
        #timeScale = QwtDateScaleDraw(Qt.LocalTime)
        #print(timeScale)
        #self.setAxisScaleDraw(QwtPlot.xBottom, timeScale)

        self.setAxisScale(QwtPlot.xBottom, 0.0, self.x_range, self.x_interval)

        #self.setAxisAutoScale(QwtPlot.yLeft,True)
        #self.setAxisScale(QwtPlot.yLeft,99.99,100.0,0.0005)
        self.setAxisScale(QwtPlot.yLeft, self.y_range_Lower,
                          self.y_range_Upper, self.y_interval)
        self.setAxisLabelRotation(QwtPlot.xBottom, -45.0)

        self.x = np.arange(
            0.0, self.x_range + 1, 0.25
        )  #0.25 for ONE POINT, THIS SHOULD BE Align to the reading rate:250ms

        #self.z = np.zeros(len(self.x), np.float)
        list = []
        for i in range(len(self.x)):
            list.append(0.0)
        self.z = np.array(list)

        rlist = []

        for i in range(self.lenth):  # 10s
            rlist.append(0.0)
        self.RateList = np.array(rlist)

        self.setTitle("UUT Reading Monitor - OutPort(%s)\r\n" % (self.unit))
        #self.insertLegend(QwtLegend(), QwtPlot.RightLegend);

        self.curveL = QwtPlotCurve("UUT Reading")
        self.curveL.attach(self)
        pen = QPen(Qt.red)
        pen.setWidth(1.5)
        #pen.setWidth(1)
        self.curveL.setPen(pen)

        font = QFont()
        font.setFamily("Calibri")  #,Consolas
        font.setPointSize(16)

        # show the latest reading. line and point value
        self.peakMarker = m = QwtPlotMarker()
        m.setLineStyle(QwtPlotMarker.HLine)
        m.setLabelAlignment(Qt.AlignLeft | Qt.AlignTop)
        m.setLinePen(QPen(Qt.blue, 1.5, Qt.DashDotLine))

        text = QwtText('Reading: ----')
        text.setColor(Qt.red)
        text.setBackgroundBrush(QBrush(self.canvasBackground()))

        text.setFont(font)

        m.setLabel(text)
        # MarkPoint symbol
        m.setSymbol(
            QwtSymbol(QwtSymbol.Diamond, QBrush(Qt.blue), QPen(Qt.green),
                      QSize(7, 7)))
        m.attach(self)

        # text marker  , display slope rate
        self.txtMarker = m = QwtPlotMarker()
        m.setValue(self.x_range / 2,
                   self.y_range_Upper - self.y_interval / 2)  # show position
        m.setLabelAlignment(Qt.AlignRight | Qt.AlignBottom)
        text = QwtText('Slope Rate: ----')
        text.setFont(font)
        text.setColor(Qt.white)
        text.setBackgroundBrush(QBrush(Qt.black))
        text.setBorderPen(QPen(Qt.red, 2))

        m.setLabel(text)
        m.attach(self)

        self.setAxisTitle(QwtPlot.xBottom, "Time (seconds)")
        self.setAxisTitle(QwtPlot.yLeft, "UUT - Reading(%s)" % (self.unit))

        self.replot()

        #self.startTimer(250)#ms# FOR GET READING
        #self.starttime = time.clock();#unit: s    python2
        self.starttime = time.time()  # python3

        self.idx = 0
        self.readfmt = "%f"
        self.Saveinfo("Starting...")
Exemple #22
0
    def __init__(self, *args):
        QwtPlot.__init__(self, *args)

        self.setTitle("Frequency Response of a 2<sup>nd</sup>-order System")
        self.setCanvasBackground(Qt.darkBlue)

        # legend
        legend = QwtLegend()
        legend.setFrameStyle(QFrame.Box | QFrame.Sunken)
        self.insertLegend(legend, QwtPlot.BottomLegend)

        # grid
        QwtPlotGrid.make(plot=self,
                         enableminor=(True, False),
                         color=Qt.darkGray)

        # axes
        self.enableAxis(QwtPlot.yRight)
        self.setAxisTitle(QwtPlot.xBottom, "\u03c9/\u03c9<sub>0</sub>")
        self.setAxisTitle(QwtPlot.yLeft, "Amplitude [dB]")
        self.setAxisTitle(QwtPlot.yRight, "Phase [\u00b0]")

        self.setAxisMaxMajor(QwtPlot.xBottom, 6)
        self.setAxisMaxMinor(QwtPlot.xBottom, 10)
        self.setAxisScaleEngine(QwtPlot.xBottom, QwtLogScaleEngine())

        # curves
        self.curve1 = QwtPlotCurve.make(title="Amplitude",
                                        linecolor=Qt.yellow,
                                        plot=self,
                                        antialiased=True)
        self.curve2 = QwtPlotCurve.make(title="Phase",
                                        linecolor=Qt.cyan,
                                        plot=self,
                                        antialiased=True)
        self.dB3Marker = QwtPlotMarker.make(
            label=QwtText.make(color=Qt.white,
                               brush=Qt.red,
                               weight=QFont.Light),
            linestyle=QwtPlotMarker.VLine,
            align=Qt.AlignRight | Qt.AlignBottom,
            color=Qt.green,
            width=2,
            style=Qt.DashDotLine,
            plot=self,
        )
        self.peakMarker = QwtPlotMarker.make(
            label=QwtText.make(color=Qt.red,
                               brush=self.canvasBackground(),
                               weight=QFont.Bold),
            symbol=QwtSymbol.make(QwtSymbol.Diamond, Qt.yellow, Qt.green,
                                  (7, 7)),
            linestyle=QwtPlotMarker.HLine,
            align=Qt.AlignRight | Qt.AlignBottom,
            color=Qt.red,
            width=2,
            style=Qt.DashDotLine,
            plot=self,
        )
        QwtPlotMarker.make(
            xvalue=0.1,
            yvalue=-20.0,
            align=Qt.AlignRight | Qt.AlignBottom,
            label=QwtText.make(
                "[1-(\u03c9/\u03c9<sub>0</sub>)<sup>2</sup>+2j\u03c9/Q]"
                "<sup>-1</sup>",
                color=Qt.white,
                borderradius=2,
                borderpen=QPen(Qt.lightGray, 5),
                brush=Qt.lightGray,
                weight=QFont.Bold,
            ),
            plot=self,
        )

        self.setDamp(0.01)
Exemple #23
0
    def __init__(self, *args):
        QwtPlot.__init__(self, *args)

        self.setTitle('Frequency Response of a 2<sup>nd</sup>-order System')
        self.setCanvasBackground(Qt.darkBlue)

        # legend
        legend = QwtLegend()
        legend.setFrameStyle(QFrame.Box | QFrame.Sunken)
        self.insertLegend(legend, QwtPlot.BottomLegend)

        # grid
        self.grid = QwtPlotGrid()
        self.grid.enableXMin(True)
        self.grid.attach(self)

        # axes
        self.enableAxis(QwtPlot.yRight)
        self.setAxisTitle(QwtPlot.xBottom, '\u03c9/\u03c9<sub>0</sub>')
        self.setAxisTitle(QwtPlot.yLeft, 'Amplitude [dB]')
        self.setAxisTitle(QwtPlot.yRight, 'Phase [\u00b0]')

        self.setAxisMaxMajor(QwtPlot.xBottom, 6)
        self.setAxisMaxMinor(QwtPlot.xBottom, 10)
        self.setAxisScaleEngine(QwtPlot.xBottom, QwtLogScaleEngine())

        # curves
        self.curve1 = QwtPlotCurve('Amplitude')
        self.curve1.setRenderHint(QwtPlotItem.RenderAntialiased)
        self.curve1.setPen(QPen(Qt.yellow))
        self.curve1.setYAxis(QwtPlot.yLeft)
        self.curve1.attach(self)

        self.curve2 = QwtPlotCurve('Phase')
        self.curve2.setRenderHint(QwtPlotItem.RenderAntialiased)
        self.curve2.setPen(QPen(Qt.cyan))
        self.curve2.setYAxis(QwtPlot.yRight)
        self.curve2.attach(self)

        # alias
        fn = self.fontInfo().family()

        # marker
        self.dB3Marker = m = QwtPlotMarker()
        m.setValue(0.0, 0.0)
        m.setLineStyle(QwtPlotMarker.VLine)
        m.setLabelAlignment(Qt.AlignRight | Qt.AlignBottom)
        m.setLinePen(QPen(Qt.green, 2, Qt.DashDotLine))
        text = QwtText('')
        text.setColor(Qt.green)
        text.setBackgroundBrush(Qt.red)
        text.setFont(QFont(fn, 12, QFont.Bold))
        m.setLabel(text)
        m.attach(self)

        self.peakMarker = m = QwtPlotMarker()
        m.setLineStyle(QwtPlotMarker.HLine)
        m.setLabelAlignment(Qt.AlignRight | Qt.AlignBottom)
        m.setLinePen(QPen(Qt.red, 2, Qt.DashDotLine))
        text = QwtText('')
        text.setColor(Qt.red)
        text.setBackgroundBrush(QBrush(self.canvasBackground()))
        text.setFont(QFont(fn, 12, QFont.Bold))

        m.setLabel(text)
        m.setSymbol(
            QwtSymbol(QwtSymbol.Diamond, QBrush(Qt.yellow), QPen(Qt.green),
                      QSize(7, 7)))
        m.attach(self)

        # text marker
        m = QwtPlotMarker()
        m.setValue(0.1, -20.0)
        m.setLabelAlignment(Qt.AlignRight | Qt.AlignBottom)
        text = QwtText('[1-(\u03c9/\u03c9<sub>0</sub>)<sup>2</sup>+2j\u03c9/Q]'
                       '<sup>-1</sup>')
        text.setFont(QFont(fn, 12, QFont.Bold))
        text.setColor(Qt.blue)
        text.setBackgroundBrush(QBrush(Qt.yellow))
        text.setBorderPen(QPen(Qt.red, 2))
        m.setLabel(text)
        m.attach(self)

        self.setDamp(0.01)
    def __init__(self, db, parent=None):
        super().__init__(parent)
        # self.LOGIN = LOGIN
        # self.db = dataBase(self.LOGIN, "Brewing")
        self.db = db
        self.dataY = np.zeros(0)
        self.dataX = np.linspace(0, len(self.dataY), len(self.dataY))

        self.count = 0
        self.timeLabel = QLabel("Timer:")
        self.timeLabel.setAlignment(QtCore.Qt.AlignRight)

        self.tempLabel = QLabel("Temp:")
        self.tempLabel.setAlignment(QtCore.Qt.AlignRight)

        self.targetTemp = QLabel("Set Temp:")
        self.targetTime = QLabel("Set Time:")

        self.targetTimeLabel = QLabel("Target: ")
        self.targetTimeLabel.setAlignment(QtCore.Qt.AlignRight)
        self.targetTempLabel = QLabel("Target: ")
        self.targetTempLabel.setAlignment(QtCore.Qt.AlignRight)

        self.startButton = QPushButton()
        self.stopButton = QPushButton()

        self.plot = QwtPlot()
        self.curve = QwtPlotCurve()
        self.curve.attach(self.plot)
        self.plot.resize(1000, 1000)
        self.plot.replot()
        self.plot.show()

        axisFont = QFont("Helvetica", 11, QFont.Bold)
        titleFont = QFont("Helvetica", 12, QFont.Bold)

        xTitle = QwtText()
        xTitle.setText("Time")
        xTitle.setFont(axisFont)
        self.plot.setAxisTitle(self.plot.xBottom, xTitle)
        yTitle = QwtText()
        yTitle.setText(f"Temperature {DEGREESC}")
        yTitle.setFont(axisFont)
        self.plot.setAxisTitle(self.plot.yLeft, yTitle)

        self.tempStatusLED = QLed(self,
                                  onColour=QLed.Green,
                                  offColour=QLed.Red,
                                  shape=QLed.Circle)
        self.tempStatusLED.value = False
        self.tempStatusLED.setMaximumSize(25, 25)

        self.timeStatusLED = QLed(self,
                                  onColour=QLed.Green,
                                  offColour=QLed.Red,
                                  shape=QLed.Circle)
        self.timeStatusLED.value = False
        self.timeStatusLED.setMaximumSize(25, 25)

        self.recipeGrid = QGridLayout()
        self.recipeGrid.addWidget(QLabel(f"Recipe:"), 0, 0)
        self.recipeGrid.addWidget(QLabel(f"{self.recipedata['recipeName']}"),
                                  0, 1)
        self.recipeGrid.addWidget(QHLine(), 1, 0, 1, 2)
        self.recipeGrid.addWidget(self.targetTemp)
        self.recipeGrid.addWidget(self.targetTempLabel)
        self.recipeGrid.addWidget(self.targetTime)
        self.recipeGrid.addWidget(self.targetTimeLabel)
        self.recipeGrid.addWidget(QHLine(), 4, 0, 1, 2)

        self.tempLayout = QHBoxLayout()
        # self.tempLayout.addWidget(self.targetTempLabel)
        # self.tempLayout.addStretch(10)
        self.tempLayout.addWidget(self.tempLabel)
        # self.tempLayout.addStretch(10)
        self.tempLayout.addWidget(self.tempStatusLED)
        self.tempLayout.addStretch(10)

        self.timeLayout = QHBoxLayout()
        # self.timeLayout.addWidget(self.targetTimeLabel)
        # self.timeLayout.addStretch(10)
        self.timeLayout.addWidget(self.timeLabel)
        # self.timeLayout.addStretch(10)
        self.timeLayout.addWidget(self.timeStatusLED)
        self.timeLayout.addStretch(10)

        self.plotLayout = QVBoxLayout()
        self.plotLayout.addLayout(self.timeLayout)
        # self.plotLayout.addStretch(10)
        self.plotLayout.addLayout(self.tempLayout)
        # self.plotLayout.addStretch(10)
        self.plotLayout.addWidget(self.plot)

        self.buttonLayout = QVBoxLayout()
        self.buttonLayout.addWidget(self.startButton)
        self.buttonLayout.addWidget(self.stopButton)
        self.buttonLayout.addLayout(self.recipeGrid)
        self.buttonLayout.addStretch(100)

        mainLayout = QHBoxLayout()
        mainLayout.addLayout(self.buttonLayout)
        mainLayout.addLayout(self.plotLayout)

        vLayout = QVBoxLayout(self)
        vLayout.addLayout(mainLayout)

        self.minuteTimer = QTimer(self)
        self.minuteTimer.timeout.connect(lambda: self.addTimer(60))