LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Check when for loop is finished

Hello, fairly new user to LabVIEW here.

 

I am auto-indexing an array into a for loop to have the program perform a standard test for each value in the array. I would like to know when the for loop is finished running through the array.

 

Ideally, I could wire this to the overarching event structure containing the for loop so that when it finishes the user knows this and can perform another test. I'm thinking that you could have it check if the current value is the last value in the array, but I'm not sure how to do this in a manner so that it only checks once all testing within the for loop is complete and it can advance.

0 Kudos
Message 1 of 5
(3,017 Views)

It is likely that somewhere in your VI you will, or should, be wiring the error inputs and outputs of a function. You can use the error wire to control the order of execution. If you wire the error cluster through the for loop (and disable indexing on that wire), data will only appear on the error wire after the for loop once all of the iterations have been completed. Therefore if the next block that is to execute has the error cluster wired into it, that will wait for the for loop to finish.


0 Kudos
Message 2 of 5
(3,008 Views)

two issues here:

 

ONE obviopusly the for loop completes when data on all output tunnels is available (yup- data flow is your friend)

 

TWO a time consuming loop INSIDE an event struture?  Not really a good idea!  Your Users will be unhappy with the front panel locking up and not responding to button presses mouse clicks keyboard hammering Mouse banging or monitor shaking.  (yes, users seem to think each of those input methods increase priority of OS scheduling-  they do not - the developer must code for user input response)  Look at the Producer Consumer Events design pattern.  pass a "status" notifier back to the UI loop to allow feedback to the user.


"Should be" isn't "Is" -Jay
0 Kudos
Message 3 of 5
(3,003 Views)

adambro: Thank you, this seems like it should serve my purposes for now. I will try applying this and seeing if it works all throughout.

 


1: I was unaware of this as I'm self-taught and only about 1.5 months in, but definitely useful. It seems like adambro just said to apply a more specific version of the output tunnels actually.

 

2: Again, I had no idea this was a thing! I was wondering why the front panel was freezing up for the few seconds each test takes. I will try reworking my code into this producer-consumer structure once I learn how to actually apply it. I didn't know about queues so I have no idea how they work yet.

Message 4 of 5
(2,980 Views)

@nphan wrote:

@adambro: Thank you, this seems like it should serve my purposes for now. I will try applying this and seeing if it works all throughout.

 

2: Again, I had no idea this was a thing! I was wondering why the front panel was freezing up for the few seconds each test takes. I will try reworking my code into this producer-consumer structure once I learn how to actually apply it. I didn't know about queues so I have no idea how they work yet.


Check the create from template, what basically happens is the event structure only reacts to use interactions by queueing commands to the consumer, which consumes the queue, one command at a time until it's empty. This means that basically no code should be in the event structure. 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 5
(2,953 Views)