09-10-2009 11:02 AM
Hello I am facing following issue and maybe somebody could give me valuable answer.
My application consist of five Queued state Machines.
1st one – handling user interactions
2nd one – communication with frequency inverter
3rd one – estimation of shaft revolution, using counters on the PCI 6120
4th one – DAQ, PCI 6120
5th one – data processing and logging
Qsms 2,3,4 acquire their own data that I need to display. I originally thought that it would be good idea to send the data from all the queues to the processing queue where they will be displayed. The problem is that queue 3 runs much faster than the 2nd one. The queues send their data to be displayed (to 5th qsm) when they have some. What happens is that 5 is handling most of the time the data from 3 which results in delays in displaying of the results of 2. It even appears as slow freezing for the user.
So I switched to the pattern where every queue updates its own graphs. But then I see possible problem with the UI thread. Since there is only one what can happen is that one of the queues will wait for another queue to finish graph refreshing and then it’s not really independent parallel execution anymore.
What would be the right solution for such a situation?
Thanks a lot
Solved! Go to Solution.
09-10-2009 11:16 AM
If they are independent loops writing to independent graphs, your code will run in parallel.
However, even if the loops are independent, if they write to the same graph, you lose the parallel-ness (if thats a word).
Actually, it would depend on HOW you are writing to the graph. If you are building all the data into an array, then passing the 2D array to the graph, the Build Array function will wait until all inputs are passed until it executes.
You could try something using local variables, but that has race condition written all over it.
09-10-2009 11:24 AM - edited 09-10-2009 11:25 AM
09-10-2009 11:27 AM
Ahhh, I understand what you are asking.
This sounds like you are having an issue because the data aquisition is too fast, and the UI cant keep up, correct?
How about this:
Instead of updating the graphs every time you collect data, only update the graphs every Nth iteration.
For example, if you collect 1,000 points, only update the graph every 10th or 20th point.
That could help speed things up a little bit.
09-10-2009 11:38 AM
Send the data from the generators to the GUI display via queues (separate from the command queues in your QSMs). And a separate queue for each data stream. Enqueue in each loop at whatever rate the data becomes available. In the GUI handler dequeue repeatedly until each queue is empty and then update the display. Updating the display a few times per second is fast enough for humans. The data sources could generate thousands of samples per second. As long as you empty the queues before they run out of memory, the speed differences should not be a problem.
Lynn
09-10-2009 11:49 AM
Not exactly.
Situation: Loop 4 is updating graph and fast loop 2 wants to update its own graph and continue to acquire data again. But it cannot since the loop 4 blocks the UI thread with its own repainting (of different graph but in same UI Thread). Since 2 is stuck it cannot distribute new result and the loop 3 that uses the data sent from 2 still has old result that uses for its continuous calculation.
I hope you can orient yourself in it since I hardly can myself 🙂
09-11-2009 03:52 AM
09-11-2009 06:40 AM
Hi Ceties,
I agree with johnsold that if you have performance problems, update your front panel just couple of times a second. Especially if you use Graphs or charts, be carefull, because they are updated every time you send data to it.
Therefore is better to use "Defer Panel Updates" property of Front panel to control when to redraw user interface.
Regards,
Martin
09-15-2009 06:33 AM