06-17-2009 08:20 PM
Hello,
I have a (hopefully) simple problem with a (hopefully) simple solution. The picture explains it best I think.
There are three queues firing at different times, thus necessitating three independent FOR loops. I need to be able to plot the output from each FOR loop onto a single graph.
Any suggestions?
Thanks in advance
06-17-2009 09:10 PM - edited 06-17-2009 09:11 PM
06-17-2009 09:30 PM
06-17-2009 10:11 PM
Hey John,
OK I looked at the picture and we STILL need a thousand words. Put each for loop in its own independent structure. Then they can run in multiple threads. Right now the while loop you have will not iterate until ALL of the for loops finish. This style does not make it easy to extend or maintain when the assumption that the arrays have the same number of points becomes invalid (that is, always code around assumptions)
Now to break my own advice, I'm assuming the user REALLY needs the data graphed, and the experiment cannot provide a result based on analysis of the data that you are graphing. BUT- CHECK THIS ASSUMPTION before we go too far down the wrong road!
As I said, before waxing philosophically, your code needs some improvement to abstract the display functionalities and make them less dependent on the UI in this code level. Or, to restate, you need LVOOP concepts!
One of the simplest ways to do this is to use an "Action Engine" to maintain the data in the UI graph. You can pass a reference to the existing graph into this AE and use "Actions" (methods) "Clear", "Adopt", "Appendto.Plot" etc...
In this case I would also think about changing the graph into an "X-Control." An X=Control allows code to be executed dependent on the action being performed on the data, like an AE but, with better handling of resource when called asynchronously from multiple locations. For really good advice on how to go this route poke an NI KNIGHT. cus you've gotten out of my league (I know the concepts and theory, I've used X-Controls, but I lack the amount of practical experience some of these Knights have with the newer powerful LV architectures)
Reguardless- keep me posted! your code looks interesting!
06-17-2009 10:31 PM
Jeff,
Thank you for your advice. I've attached another picture, hopefully it will substitute for 1,000 words! ZFC, ZFM and ZFC are array indicators which I've created local variables from. This code performs exactly what I want, but I know there's a better way forward:
I agree that this totally screams of object-oriented concepts, alas I am not experienced with this programming style. Another issue is whether the (UI Server?) will force these graphs to run synchronously, which is unnecessary and may lead to lost data. Hopefully the above helps.
Thanks again,
John
06-17-2009 10:54 PM
John-
I agree! We need help to solve this and get more experience with LVOOP. IM[very]HO that won't happen if you post code with the dreaded "local variables" and "stacked sequences." Both of those features are antithietical to LVOOP concepts. (Why- because they hide funcions rather than abstract them) but, of course ,you are newer to LV than to programming or you wouldn't be here.
time to poke a Knight!
06-18-2009 07:34 AM
I ain't Christian but I'll chime in.
If I understand the challenge (plot three data streams to the same display with proper timing) then I suggest you look into using a Waveform data type chart.
When the the data type is Waveform the X-postition of the plotted data is determine by the "t0" value of the waveform.
If you present an array of Wforms to the chart there do NOT have to be the same number of samples on all of the waveforms.
So...
Use an AE to store an array of Wforms. THis AE should return the entire array when queuried for presentation.
Each of the queue readers will invoke the AE to replace the waveform at thier index, appending to the data if there was already something there from the last update.
If the display reads an array that has two of the three Wform elements updated but the third is empty, the chart will just update those plots. The next time, when it get the missing data from the third source that data will be applied to that plot.
Summary:
Waveform data type charts;
1) Do not have to have the same number of data points.
2) Empty Wforms will not affect previously ploted data.
3) The Wforms can have differnet sample rates.
So experiment with "just how much you can get away with" when using waveform data types.
Waiting form Christian's opinion,
Ben
06-18-2009 09:40 AM
Thanks Ben,
Insomnia and forumitis do not mix well, I thought an AE would be the easier way to go but then thought "how elegant to use an X-control" and turn the graph into an event based UI component.
I know I can sleep well with the back-up available!
06-18-2009 09:56 AM
Jeff Bohrer wrote:Thanks Ben,
Insomnia and forumitis do not mix well, ...
My earlier reply sufered from lack of coffee. No need to use the AE, put a local in each of the loops and they build an array of empty waveforms and replace their index with their data. So all three could poke at the chart dircetly and le tthe chart do all of the work.
Ben
RE Forumitis - Don't be scared. We are all just a bunch of people that want to learn help out and have some fun as we go.