LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

vi server

My VI uses something similar to the following example. It crashes everytime after it finishes running. I am thinking that it's because I generate a new VI reference each time in the loop. The reference is not closed until DONE is true. It might be better if I use a shift register here. What do you think? But the open VI reference needs to stay inside the loop, how would you initialize the shift register in this case?
0 Kudos
Message 1 of 8
(2,830 Views)
Why do you think it has to be inside the loop? Just move it outside, wire the reference to a tunnel (don't really need a shift register) and move your close reference, without a case statement, outside the loop as well.
0 Kudos
Message 2 of 8
(2,830 Views)
What is the reason the Open VI Ref needs to be in the loop?

As it sits, every time the Open VI Ref runs, it generates a different refnum for the same VI. Place a probe on the refnum wire and you'll see it change each time the loop iterates. So each time it checks the Execution State, it's checking a different instance of the VI.

Unless this is what you want, you should move the Open Reference outside the loop so you check the same refnum each time.

Ed


Ed Dickens - Certified LabVIEW Architect
Lockheed Martin Space
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 3 of 8
(2,830 Views)
Just re-read the question and I forgot something.

If you want to init a shift register inside a loop, place the Open VI ref inside the True case of a Case Structure and connect its terminal to a First Call? function from the 'Advanced > Synchronization palette or to the loop index counter so the True case only runs the first time the loop runs.


Ed Dickens - Certified LabVIEW Architect
Lockheed Martin Space
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 4 of 8
(2,830 Views)
But my main VI is bigger than that. In my real VI, there is a case statement inside the while loop and the case statement runs base on which test is going to run next, and base on which test it is....if it's test one, a different VI reference is open, if it is test 2, no reference is open.......etc....that's why I need for it to be in the while loop and close inside.
0 Kudos
Message 5 of 8
(2,830 Views)
I still don't think that there's a real reason for repeatedly opening a reference to the same VI over and over again but without seeing your actual program, I can't suggest how it should be improved. If you really want to do it that way, then the only thing you can do is take the close ref out of the case statement and do a close every loop. Otherwise, a crash is guaranteed.
0 Kudos
Message 6 of 8
(2,830 Views)
But if you close every loop, doesn't that close the sub-VI running in the background? And when you re-open the reference, you are starting from scratch? I have included an example that looks more similar to what I have in my real program right now, and an example of how I think it should be fixed. What do you think? I have also included comments in there, in case my program confuses you. Thanks for the help.
Download All
0 Kudos
Message 7 of 8
(2,830 Views)
Maybe I'm missing something but if the VIs in case 1 and 3 are different, you still could open the references outside the while loop and set and read control values inside as many times as you want. You could also use the method Ed mentions with the First Call? function.
0 Kudos
Message 8 of 8
(2,830 Views)