LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Looking for boolean function similar to or, but doesn't wait for second input in case it gets a 'true' from one input

Solved!
Go to solution

my program runs in 2 processes in parallel inside one while loop , and should stop when one of them ends.

How can I do that? Using 'OR' function wired to loop stop condition will not do the job, as it waits for both process to give their input before it executes. 

What I really need, is a function that will wait till it gets a 'true' through one of its input, and then executes without waiting for the other.

Is there such an option?

 

If not, does someone have an idea how to achieve what I've described here?

 

Thanks in advance!

 

0 Kudos
Message 1 of 8
(3,854 Views)

You need to show us your code.

0 Kudos
Message 2 of 8
(3,850 Views)

PSA my code. 

In short, what I'm trying to do is to run the test sequentually, but to stop immiedately when F2 is pressed (and in this case I need to add some post process steps later.)

Ctrl+'.' is not working for me (it just resizes the vi), and even if it did, it's not helping as I need to be able to add some steps before the test actually stops.

Thanks!

0 Kudos
Message 3 of 8
(3,832 Views)

Where is the second "process" that is supposed to run in parallel?

Your entire code is trapped inside lenghty sequence structures that cannot be escaped. You should rewrite everything as a normal state machine, and check the stop condition after each step, then branch to the end if needed.

I would run the key press stuff in a seperate loop.

0 Kudos
Message 4 of 8
(3,826 Views)

I tried to avoid it. I'm trying to find a neater way to stop vi run using keyboard (similar to clicking on 'Abort execution'), without a need to check before each step some boolean variable. Isn't there such an option?  an 'OR' option that works as I described above would have done the job.

Thank you for your time.

0 Kudos
Message 5 of 8
(3,810 Views)

@sara111 wrote:

I tried to avoid it.


What is "it"?


@sara111 wrote:

I tried to avoid it. I'm trying to find a neater way to stop vi run using keyboard (similar to clicking on 'Abort execution'), without a need to check before each step some boolean variable. Isn't there such an option?  an 'OR' option that works as I described above would have done the job.


You keyboard will only get read once per iteration of the while loop (at the very beginning of the iteration, most likely before or during the popup dialog) and thus is not very reactive or useful. Yes you could run a parallel loop polling the key and then run the "abort" function but that would be horrible.

 

I don't have your driver VIs or any of the missing object (globals, etc.) So I cannot really test anything. I really don't understand why you need all these sequence structures. In most cases execution orrder seems to be fully determined by dataflow. Also most of your local variables seem unecessary. A well designed state machine would solve all your problems. Sequences need to finish all frames and thus cannot be interrupted mid stream. It's all in the dataflow.

0 Kudos
Message 6 of 8
(3,794 Views)
Solution
Accepted by topic author sara111

What you need is a "non-synchronous OR", that is, "Do Something if Item 1 becomes True OR Item 2 becomes True".  One way that comes to mind to do this is with a Producer/Consumer (Event) design pattern, where the Consumer is a State Machine with a Stop State.  Get Item 1 to fire an Event (perhaps using a User Event or Value Change (Signalling) Property)  when it becomes True, and have it send the Consumer the Stop State.  Get Item 2 to do the same thing.  Now either one of these becoming True will cause the Stop State to be entered (without caring what the other Item is doing), in other words, which ever one becomes True, the (Consumer) loop stops.

 

Bob Schor

0 Kudos
Message 7 of 8
(3,755 Views)

Thank you, I'll try that.

0 Kudos
Message 8 of 8
(3,707 Views)