Example #1
0
    def _event_dataready(self, fd):
        utils.eventfd_clear(fd)

        scp = self._scp
        channel_count = len(scp.channels)

        start = 0
        length = scp._record_length - start

        # Get data
        pointers = libtiepie.api.HlpPointerArrayNew(channel_count)
        data = [None for i in range(channel_count)]

        try:
            for i in range(channel_count):
                if scp._active_channels[i]:
                    data[i] = np.empty(length, dtype=np.float32)
                    libtiepie.api.HlpPointerArraySet(pointers, i, data[i].ctypes.data)

            libtiepie.api.ScpGetData(scp._handle, pointers, channel_count, start, length)
        finally:
            libtiepie.api.HlpPointerArrayDelete(pointers)
        self.sweepCount +=1
        if self.statusbar:
          self.statusBar().showMessage('Sweeps:'+str(self.sweepCount))
        # Plot data
        '''
        for chnum in range(len(self._scp.channels)):
          logging.debug('data '+str(chnum)+':\n'+str(data[0]))
          logging.debug('data '+str(chnum)+str(self.gain[0])+':\n'+str(data[0]/self.gain[0]))
        '''
        i = 0
        if self.persistency == 1:
            #TODO remove previous waveforms instead of replotting
            self.plot.clear()
            logging.debug('plot cleared')
            self._replot()
        #&RA/for chnum, chdata in zip(range(len(self._scp.channels)), data):
        for chnum in range(len(self._scp.channels)):
          if self._scp.channels[chnum].enabled:
            chdata = data[chnum]/self.gain[chnum] + self.offset[chnum]
            if chdata is not None:
                ch = self._scp.channels[chnum]
                legend = str(chnum)
                logging.debug('chdata['+str(chnum)+']['+str(length)+'] '+legend+' =\n'+str(chdata))
                #&RA/plot.plot(y=chdata, pen=LINE_COLORS[chnum % len(LINE_COLORS)])
                #print(self.stepMode)
                self.plot.plot(x=range(length-1+self.stepMode),y=chdata[:-1], pen=LINE_COLORS[chnum % len(LINE_COLORS)],stepMode=(self.stepMode==1))
                i += 1
                ch = self._scp.channels[chnum]
                logging.debug('ch'+str(chnum)+' min,max='+str(ch.data_value_min)+','+str(ch.data_value_max))

        if self._continuous:
            self._scp.start()
Example #2
0
    def _event_dataready(self, fd):
        utils.eventfd_clear(fd)

        scp = self._scp
        channel_count = len(scp.channels)

        start = 0
        length = scp._record_length - start

        # Get data
        pointers = libtiepie.api.HlpPointerArrayNew(channel_count)
        data = [None for i in range(channel_count)]

        try:
            for i in range(channel_count):
                if scp._active_channels[i]:
                    data[i] = np.empty(length, dtype=np.float32)
                    libtiepie.api.HlpPointerArraySet(pointers, i, data[i].ctypes.data)

            libtiepie.api.ScpGetData(scp._handle, pointers, channel_count, start, length)
        finally:
            libtiepie.api.HlpPointerArrayDelete(pointers)

        # Plot data
        glw = self.centralWidget()

        timebase = np.linspace(0, scp._record_length / self._sample_frequency, scp._record_length, endpoint=False)

        i = 0
        for chnum, chdata in zip(range(len(self._scp.channels)), data):
            if chdata is not None:
                plot = glw.getItem(i, 0)
                if plot:
                    plot.clear()
                else:
                    plot = glw.addPlot(i, 0)
                    self._setup_plot(plot)
                ch = self._scp.channels[chnum]
                plot.plot(y=chdata, x=timebase, pen=LINE_COLORS[chnum % len(LINE_COLORS)])
                plot.setYRange(ch.data_value_min, ch.data_value_max)

                i += 1

        # Remove unused plots:
        plot = glw.getItem(i, 0)
        while plot is not None:
            glw.removeItem(plot)
            plot = glw.getItem(i, 0)

        if self._continuous:
            self._do_start(self._continuous)