[PyQt5] graphyview setdata() doesn't work after recieving a mount of data
-
Sorry about my poor English
I designed UI with UIdesigner, and I wrote four threads to handle the interface, serial port, calculation and drawing(all create by Qthread).
The window I draw on is upgraded through UIdesigner's Graphyview.
There is no problem when receiving data within an uncertain period of time, such as within about 1 minute, the serial port receives row data and passes it to the interface for display and calculation. After calculation, The new data is loaded into the list and used for drawing, the drawing function is used by [.setdata(list)]
you can see the lastest data is used as the label too. but few moment later, 1st painting stuck and then 2nd painting stuck ten seconds later,after a while, it will get stuck one after another but interface and label still work. Most of them are stuck in sequence, sometimes in disorder.
after drawing stuck, I also clicked the button of [.setdata(zero*200_list)] to no avail.The faster the receiving serial port frequency is, the faster the image will be stuck.
Add one more, Super fast data also makes my interface freeze until I click any button.So I controlled the sending speed of the slave computer.what I have tryed:
①Delete oldest data which in the interface to reduce memory.(doesn't work)
②Carefully screen the received data, and incorrect data will not be use for [.setdata()].(doesn't work)
③I once thought that the drawing thread was too busy with calculations, so I added a fourth thread: calculation. Computing without threads also has this problem.(doesn't work)
④I didn't do long-term testing at first.Rolling my code back to the earliest version, accepting data and drawing directly also has this problem.(doesn't work)
⑤Use [.repaint()] or [.replot()] when stuck.(doesn't work, may be worng object?)
⑥I used redefinition for the escape key.The drawing will be updated when cancel the exit or switch to other software pages, it breaks me down.
⑦I remove the other code and just keep the loop drawing which also causes the stuck, I think Frequent [.setdata()] will cause stuck maybe.My question:
①why doesn't [.setdata()] work?
②I only update all the graphs once I receive the data once, why are they stuck one by one?
③The most important ,how to fix it?Sorry to bother you, thank you very much for watching
-
@ugly_curry_garlic said in [PyQt5] graphyview setdata() doesn't work after recieving a mount of data:
UIdesigner's Graphyview
Don't know what "Graphyview" is?
I wrote four threads to handle the interface, serial port, calculation and drawing(all create by Qthread).
If you mean you have a secondary thread handling "drawing to the UI". This is not allowed. Depends exactly what it is/does. But Qt requires the UI only be updated by the main thread. Secondary thread may appear to work, but is not reliable.
-
@JonB Super awesome! The probability of it getting stuck is greatly reduced. Even under high frequency conditions, one or two will occasionally get stuck after ten minutes, and not one after another, it probably work!!!👍👍👍👍👍👍👍👍👍
-
-
But I'm still hoping someone can tell me how I can permanently fix this stuck situation❤️❤️❤️
-
@ugly_curry_garlic
You would have to debug your code. See if you can discover where it "gets stuck". If you are using threads there is always a chance there will be a fault in your code.