11-03-2016 04:10 PM
How do I pass an output value through the For loop, and have it passing it out while updating (rather than just the final value)?
Solved! Go to Solution.
11-03-2016 05:06 PM
What do you want to do with the data? Are you passing it to another VI? Do you just want to display it? Please be more specific because there are multiple ways to accomplish this (user events, queues, FGV, local variables , etc).
11-03-2016 09:22 PM
In general, nothing comes out of a loop until the loop is done. If you want each of the values to be accumulated and passed out in an array, make the output tunnel an Indexing tunnel.
In LabVIEW 2016, if you have parallel loops, you can pass out individual elements using Channels. Note, however, that the Channel needs to go to an independently-running loop -- if it is "connected" in any way (for example, by "eating" the Error Line coming from the For Loop), the second loop (because of Data Flow) can't run until the first loop exits, anyway.
The "traditional" (i.e. pre-LabVIEW 2016) way of violating Data Flow and "exporting" values as they arose in loops was via a Queue, the so-called Producer/Consumer Design Pattern. You can find examples by opening a blank VI, going to the File menu, choosing New ... (the dots are important), and finding "From Templates", "Producer/Consumer Design Pattern".
Bob Schor
11-05-2016 09:02 AM
I always have this link ready: Producer/Consumer
11-14-2016 03:12 PM
I've tried to implement it using Producer/Consumer example, not sure if I'm approaching it correctly. I'm trying to read from a file (also attached), and read each individual value. Please let me know if I'm implementing it correctly, I'm not getting the desired results.
11-14-2016 03:22 PM
In your "producer" loop only 1 element would ever get enqueued. Try replacing your while loop with a for loop and use indexing. That way each loop iteration you will send a single 1D array until you run out of data.
11-15-2016 08:08 AM
Andrea,
What are you trying to do, and when are you trying to do it? [Echoes of Watergate ...]
You have a file that we've discovered can be read as a binary file having "records" that are 1651 bytes long. You have a number of options open to you on how to process this, with "Time" and "Space" being variables in the equation.
I don't know why you would need one method or another, as the nature of the processing isn't clear (to me -- you may have described it earlier and I've just forgotten). I tend to use P/C when I have a Producer that spends a significant amount of time "waiting for data" (such as an A/D converter producing 1000 samples at 1KHz continuously -- it is very busy, but spends 999 milliseconds "waiting for data to be available" and 1 millisecond giving me the data, so with P/C, I spend those 999 milliseconds processing the data I just received, keeping the CPU busy.
To help illustrate one way of using P/C with this project, here's one way to use Queues to process records, as in Step 3, above. I realize you are using LabVIEW 2013, and thus can't use these directly as Snippets, but I'm hoping that they are simple enough you could create them "from scratch". I've also included the other cases for the two Case Statements as they contain "important" code, namely the Sentinel code. Note also that arranging the parallel loops in a vertical column gives a subtle visual impression that they happen simultaneously, rather than sequentially.
Bob Schor
11-16-2016 03:58 PM
I'm doing this because I need to read the data like it's streaming in like data coming in. I know I'll need to put a timing method to control the speed of data coming in as well.
11-16-2016 06:54 PM
OK, if you take my code and put a Wait function, say with 1000 wired to it, you will read one record a second and pass it on to the Consumer for processing.
But why do you want to do it this way? Are you trying to simulate something that spits out 1651-byte records at regular intervals? Where does the need for parallelism come in? If we call the code "inside" the Producer loop "Read A Record.vi" and the code inside the Consumer loop "Process A Record.vi", what's wrong with a For Loop containing Read A Record directly connected to Process A Record? True, you are doing these two operations in series rather than in parallel, but I don't see a compelling reason to add the extra code to create a parallel design. [Of course, I don't see your Big Picture ...].
Bob Schor
11-21-2016 03:13 PM
I may not be setting this up correctly, but I'm trying to simulate reading a set of data like it's streaming. I'm trying to read through a data file