06-28-2015 01:13 PM
Say, for example, I have a case structure with two cases. In each case, there is a sequence structure. If case 1 is true and the program is running that particular sequence, would switching to case 2 immediately cut off the sequence from case 1 and leave it incomplete in favor of executing the sequence from case 2?
06-28-2015 01:16 PM
No.
How would the program know that it should be in case 2 until case 1 ends, the loop iterates, and it has a chance to read the condition that determines which case to execute?
I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours
06-28-2015 01:22 PM
The program would know that it should switch to case 2 based on another input that is outside of the structures, like a user controlled boolean, for example. All of this would be going on inside a while loop, by the way.
I apologize for not adding those details earlier.
06-28-2015 01:30 PM - edited 06-28-2015 01:31 PM
No. Which case gets executed is determined by the value in the wire going into the selector terminal at the beginning of the case structure. Where or how that value is getting into the wire is irrelevant.
That wire doesn't execute again, and the selector doesn't determine which case to execute until the current iteration of the loop ends, which includes all code inside that loop ending, including all code inside any internal structures such as the case structure. Only then will the loop iterate again, the value travels down that wire into the case structure selector terminal, and then the appropriate case of the case structure begins executing.
This is all basic dataflow rules that LabVIEW executes, and you need to take those tutorials to begin understanding that. Set up and example in code, then run it with highlight execution turned on and follow along.
06-28-2015 01:32 PM - edited 06-28-2015 01:33 PM
you need to learn the basics of dataflow. Sequence structures need to complete, they cannot be interrupted. While the code is inside the sequence, it cannot read controls outside of it, unless that other control is in a parallel loop.
What you need is a state machine. This not only eliminates the sequence structures, it will also make the code logical and maintainable.
06-28-2015 01:32 PM
06-28-2015 01:34 PM
I'll have to look at the tutorial videos again. Is there a way to interrupt the sequence before it completes, by any chance?
06-28-2015 01:36 PM
06-28-2015 01:38 PM
06-28-2015 03:02 PM
@palanivel wrote:
No way ......
You need to have some variable and case inside sequence
variable has to decide whether case to run / not....
Here "variable" takes its value from your interrupt signal...
This is bad advice. Alone, variables and sequence structures are dangerous to use if you don't understand them. You don't fix bad architecture by making it worse. Avoid doing something like this... ever.
You've been told by multiple people that you can't stop the sequence structure once it's started. That's a general dataflow principle. It's going to run. The best advice you've been given in this thread is to take a look at a state machine architecture. It's exactly what you're describing and doesn't require making your achitecture even worse to accomplish your goals.