09-16-2008 10:45 PM
I've searched this problem until I'm blue in the face with no luck. Maybe someone can help me. I greatly appreciate it.
I have a main VI calling a subVI multiple times at different times. The subvi updates two string indicators in the main VI, one of which counts down and the other is static. The first call to the subvi starts the count down and I would like the second to stop the countdown.
My observations:
The first call starts the count down after setting the timeout value. The second call changes the timeout value to zero (default) and finish executing. However, the first instance of the subvi continues to run until its countdown is finished.
1st question: Is there a way to stop the first instance of the subvi? Or is there a better way of accomplishing the same thing I am not aware of?
2nd question: When I execute my program, the "start" button is not momentary even though I used the property "latched when released". I've tried the other combinations without luck. Am I doing something wrong here?
I am very new to Labview (1 day of coding), so I would appreciate replies with less technical terms. Thanks a lot!
09-16-2008 11:43 PM
When a subVI is reentrant, that means there are two complete instances of the subVI. They have 2 separate memory spaces and can run simultaneously.
It is not usually a good idea to have any code in an event structure that takes a noticeable period of time to run. With your code, it looks like it would take at least 5 seconds for the event case to complete.
For any latching controls, the only way they become unlatched is when the control is actually read. Your controls will only be read one time and at the very start of your program because they are all located outside of your while loop. You would want to move those controls into the appropriate event cases (or at least inside the loop) to have the controls read and thus automatically unlatched. Even if you do nothing with their value coming from the terminal because you are only interested in the event, or are using references and property nodes, they will only pop back up if the terminal is actually executed.
It's not real clear to me exactly what you are trying to do and why you want to use reentrant subVI's. You may want to look at the nugget on action engines. Let the action engine have commands to start, stop and read the timer. It can store the start time in its uninitialized shift register. Use the timeout case of the event structure to call the action engine and read the updated value.
If you've been only coding for 1 day, trying to understand reentrancy and event structures is a bit premature. I would recommend tackling a few simpler concepts first.
09-17-2008 12:30 AM
Hi,
According to my observation i attached an VI, Check out that and say whether your looking for that!
With regards,
Vijay