10-11-2012 11:11 AM
Hallo everyone,
I have this small IV, it means nothing but I want to know if it's possible to control each while loop. what I wish to do is to press the boolean button, then the while loop starts running and when i press it again the loop stops but when I press it again it works again, not that the program stops running at all. not only that but I need it for both loops. so i run one and stop the other then stop one and run the other and so on...
I dont know if this is possible and its not necessary to be done with loops, I just wrote loops because this is what I can do and understand, if there are any other possibilities then please feel free to share it with me.
10-11-2012 11:24 AM - edited 10-11-2012 11:36 AM
I would start out with some turorials, because you seem to have severe misconceptions about dataflow.
The sequence structure make no sense and has no purpose. Delete it.
If your controls should be read during execution, they belong inside the while loop. Currently, they are read once at the start of the program and then never again. All you get is the stale value stored inside the tunnel.
A toplevel loop should always spin. What you need is a state machine. Place the code inside each while loop in a case structure and make the other case empty (typically containing a small wait). Wire the boolean to the case and switch between the two states at will during execution. You probably only need one single while loop containing both case structures. Add a stop button to the loop termination and only press it if you are done with execution.
Of course once you go the basics worked out, you might want to look into event structures to avoid polling.
10-11-2012 11:27 AM
First, the sequence frame in your code is not necessary. You should remove it.
As for your question I would recommend you look at the examples for the producer/consumer architecture. Your producer would be a while loop with an event structure. This would be used to handle the UI such as the button press. Your consumer loops (based on your code you would have two of them) would have a simple state machine that will run when required. Take a look at the examples and then ask any questions you may have regarding that architecture.
10-11-2012 03:48 PM
Perhaps something like this.
10-11-2012 04:06 PM - edited 10-11-2012 04:06 PM
@paul_a_cardinale wrote:
Perhaps something like this.
I don't think we need to involve such a huge amount of code and new concepts (timed loop, notifiers, subVIs, clusters, arrays, event structures, etc.), to solve such a simple problem. (This might turn off a beginner!).
Here's what I would do. 😄