.replace('one or calculation', 'other one for a calculation')
On Mon, Jul 25, 2016 at 8:14 PM, <[email protected]> wrote:
> Hi.
>
> I think that you need to put all pyqtgraph and other graphic stuff
> (including window initialization, processEvents etc.) in a separate thread
> and to plot a shared data you have every 0.1s. Look at FuncThread class at
> bottom of page
> http://softwareramblings.com/2008/06/running-functions-as-threads-in-python.html,
> could save you a time. So, one thread for graphic stuff, one or calculation.
>
> Good luck,
> Vasilije
>
> On Mon, Jul 25, 2016 at 4:52 PM, Igor Muniz <[email protected]>
> wrote:
>
>> Hi guys,
>>
>> I'm trying to plot a real time signal with python and PyQtGraph has
>> improved the speed a lot, but still with some delay. The data comes from a
>> DLL and it's store in a NumPy Vector.
>> I wan't to plot this buffer every 0.1s with 100 points(the signal has
>> 1kHz sampling rate). At the beginning this seems to work but after few
>> seconds starts to get behind the plot.
>>
>> This is part of my code:
>>
>> def coleta():
>> global cnt
>> global t
>>
>> nsample = c_ulong(int(0.1 * sampleRate.value))
>>
>> status = emgSampleNSeconds(handle.value, 50)
>>
>> if status == 0:
>> print("Inicia a amostragem")
>> else:
>> print("Não foi possível iniciar a amostragem")
>> emgIsSampling(handle.value, byref(isSampling))
>>
>>
>> canal = c_ulong(0)
>> emgbuffer = (c_double * nsample.value)()
>>
>>
>>
>>
>> emgDataPlot = np.zeros(10000, dtype=float)
>>
>> curve1 = p1.plot(emgDataPlot, pen='r')
>> sleepVar = 0.1
>> pltStart = pg.ptime.time()
>> while isSampling:
>> time.sleep(sleepVar)
>> emgGetRealUnitDataBlock(handle.value, canal.value, emgbuffer,
>> byref(nsample))
>> now = time.time()
>> for value in emgbuffer:
>> emgDataPlot = np.append(emgDataPlot, value)
>> if len(emgDataPlot) > sampleRate.value * 10:
>> emgDataPlot = np.delete(emgDataPlot, 0)
>>
>> if t == 0:
>> p1.enableAutoRange('xy', False) ## stop auto-scaling after the
>> first data set is plotted
>>
>> t += 1
>>
>> curve1.setData(emgDataPlot)
>> app.processEvents()
>>
>> #print(t)
>> emgIsSampling(handle.value, byref(isSampling))
>>
>> #p1.enableAutoRange(True, True)
>> print(pltStart - pg.ptime.time())
>>
>>
>> What I need to do?
>> Thanks.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "pyqtgraph" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/pyqtgraph/f3c66f2c-5c13-4b2b-b442-f55aaeda21c7%40googlegroups.com
>> <https://groups.google.com/d/msgid/pyqtgraph/f3c66f2c-5c13-4b2b-b442-f55aaeda21c7%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
You received this message because you are subscribed to the Google Groups
"pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/pyqtgraph/CAD_qyJp-aw%3DA0-ighYnDGJ7rM5utcGR6%3DZ4Jknmfu5p%3DH1%2BsSw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.