05-11-2012 09:17 AM - edited 05-11-2012 09:21 AM
Yamaeda,
Will this work?
Nevica
05-11-2012 09:28 AM
depends what you mean by "work"... I think you should try to not use this "stop" function.
We have two ears and one mouth so that we can listen twice as much as we speak.
Epictetus
05-11-2012 09:34 AM
Here is what Labview say about the Abort Function: I think that I have completed all final tasks like closing files etc so it shouldn't be a problem!
05-11-2012 09:36 AM - edited 05-11-2012 09:38 AM
I know, I know... but it feels like you're using this because you didn't know how to stop your parallel loops, am I wrong?
because if you do stop all your loops, then you don't need that function, your main VI just finishes its execution.
We have two ears and one mouth so that we can listen twice as much as we speak.
Epictetus
05-11-2012 09:49 AM
You are correct. But non of the replies have explained how I can stop the tertiary while loops. They are all generally one sentence replies which doesn't explain anything to me!!
05-11-2012 09:51 AM
@nevica wrote:
Will this work?
Your code is still highly flawed, convoluted, and over-engineered.
Except for the obvious serious flaws (at least two CPU burner loops, etc.!) that have already been mentioned, you are really not making our life easy by attaching a picture of a code fragment. We cannot see where the wires are coming from and we cannot see what is in the other cases of the case structures, for example.
If you want real advice, please attach some real code. Thanks! 😄
05-11-2012 10:05 AM - edited 05-11-2012 10:07 AM
To Altenbach,
I don't think you understand my original question.
How do I stop the tertiary while loops (the two bottom ones) when the main loop has finished. The Labview Suite is huge and I don't think that you need to know what is in the other case structures. It is not relevent to the question in hand. The point is that the main while loop has finished and the two tertiary while loops continue. (The logic in the lower case structure of the main loop switches the stop button to true to end the main while loop.)
Nevica
05-11-2012 10:08 AM
Read Action Engine Nugget
You can create a functional global variable, aka Action Engine. Initialize it at the beginning of your program to false before any of your while loops start. In each loop, use the default action to read the value and wire it to the stop terminals.
When you need to stop your program from anywhere, set the stored value of the boolean to True. Now when the loops execute and read the FGV, they will read the new value of true and stop the loops cleanly.
05-11-2012 10:17 AM - edited 05-11-2012 10:30 AM
nevica wrote:I don't think you understand my original question.
Yes, I do, but you code has fundamental architectural problems that cannot be solved by simply throwing more bad code at it. According to the title, you are looking for the "best programming technique", not just a band-aid solution.
@nevica wrote:
How do I stop the tertiary while loops (the two bottom ones) when the main loop has finished. The Labview Suite is huge and I don't think that you need to know what is in the other case structures. It is not relevent to the question in hand. The point is that the main while loop has finished and the two tertiary while loops continue. (The logic in the lower case structure of the main loop switches the stop button to true to end the main while loop.)
I did not ask for the "huge project", just for the relevant VI you are showing. ("huge" is relative, maybe it could be all done with 10% of the code :D)
(You don't send a picture of your car to the mechanic to let him guess what's wrong. Unless the car is fully engulfed in flames, he probably will not be able to tell what the problem is. Same with a picture of a diagram)
The loop in the lower left does not serve any useful function, because you are also closing these files elsewhere, after the upper loop (again, I cannot really tell, because I don't know what's in the other case of the case structure (Yes, this is relevant!!!)). You could just place the terminal of the stop button in the upper loop and insert an "or" before evaluation the loop termination condition and then delete that entire lower-left loop structure.
The loop in the lower right seems to stop according to the state of a global variable. Since we have no idea where this is set, we cannot really tell how things work. Again, the correct way would be to set that global to stop the loop. And please place some small waits in these loops!
05-11-2012 10:47 AM
I would recommend radically changing your architecture. I would use a more traditional producer/consumer. The producer loop would handle all the UI stuff including monitoring for the Stop condition. I would use user events to pass UI updates to the producer loop. This would eliminate the lower right loop completely. You would have user events to update all the indicators that you are updating. The beauty of this is that you would only update the indicators when necessary. Not every loop iteration.
The use of an AE for your slave loops to check for a stop works. You could also use a notifer. When checking for a notifictaion you would use a 0 for the timeout. This means you aren't waiting uncessarily for the notification but it is an effective means of broadcasting the stop condition. Consumer loops can also be written to accept an explicit stop message.