12-10-2009 08:23 PM
I am using the "Read from measurements file" .vi to read read in a .lvm file containing the data I want to use in my VI. I have two different files I need to read into the VI. After I click "run" the prompt comes up and I select my desired file, then the other prompt shows up, along with everything else running in the VI which is in a while loop, but I do not want anything to run in the while loop until the 2nd input is selected.
Is there anyway for the program to wait until those two files have been read in?
These are the "read from measurement file" vi's that I want to input the data with before having everything execute in the VI.
Solved! Go to Solution.
12-10-2009 08:43 PM - edited 12-10-2009 08:44 PM
simply wire the "error out" of the two reads to the edge of the while loop. This creates a data dependency and forces execution order.
Even easier, delete the local variables and wire directly from the reads to where the data is needed inside the while loop. 😄
(Why would you need to read the same data from the same terminal over and over with every iteration? Makes no sense! Terminals belong outside the loop unless you expect them to change during execution of the loop. Do they? Can you attach the entire VI? Is the array actually used as a control by the user? If not, make it an indicator.)
12-10-2009 08:48 PM
Simple if you understand dataflow. The simplest and best would be to wire the output of the read functions into the loop and directly to where you have the control. Unless you want the user to change it, change the controls to indicators. Otherwise, use the error out terminals from the read function to control dataflow. For example, if you simply wire them to the edge of the loop, they will execute first.
p.s. You do not need to 'adjust' your loop counts. Wiring an array through a for loop will take advantage of the built-in auto-indexing feature and you do not need to wire anything at all to the for loop's 'N' terminal. This is pretty basic stuff. Have you taken the tutorials or taken any type of training?
12-10-2009 09:27 PM
12-11-2009 04:57 AM
12-11-2009 10:35 AM
jcarmody wrote:
It's a slight misstatement to call using the Error Out an "easy fix". That's the proper way to control execution order in LabVIEW, while using a Sequence Structure is a "fix".
Actually, the correct way would be to get rid of the local variable and turn the array control into an indicator or eliminate it completely. Is the array control even shown on the front panel?
While the error out is the second choice, it could possibly still lead to a race condition. Since the start of the while loop and the writing to the two local variables can occur in parallel righ after the last file dialog has completed, the error out alone is not 100% safe (well, it probably is, but why take the risk ;)).
cmersits,
Please show us your code so we can provide some guidance. I have the feeling that you are doing this way more complicated than needed.