LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Any way to tell if VI is running standalone or called?

Solved!
Go to solution

Is there any easy way to tell if a VI is running standalone or if it was called by some other VI?

 

I have same VIs that are usually called by another VI. But for testing purposes, I would also like them to be able to be run standalone. Unfortunately, these VIs may have some setup requirements, inputs, queues and things that they do not need when they are called.

 

If the VI can tell if it is running standalone, then it can do some default initialization that is otherwise not needed, so that it can run standalone.

 

THANKS for your help and suggestions.

0 Kudos
Message 1 of 6
(4,393 Views)

If I remember right the call chain funtion should just contatin one element if the vi is not called as a subvi or with the call by reference node. Using the Run VI method on a VI reference should have only one element in the call chain.

0 Kudos
Message 2 of 6
(4,390 Views)

You can look at the VI hierarchy under view in the top menu bar.

Tim
GHSP
0 Kudos
Message 3 of 6
(4,386 Views)
Solution
Accepted by dbaechtel

VI reference >>> property node >>> Exec.State

 

if value is "Run Top Level" then ...

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 4 of 6
(4,365 Views)

I guess you're aware of this method, but I'll suggest it anyway.

 

If your VI has connectors they will have the default value when left unconnected. For instance if you have a queue control which is passed when called as a subVI this control will be "not a reference" when you run it standalone.

So by checking the control values you can determine whether valid values are passed. If not, you can do the initialization.

 

0 Kudos
Message 5 of 6
(4,358 Views)

This works really well and is much more robust than checking whether your connector values are their default ones or not.

 

The attached vi works on this principle and returns true if the vi reference passed into it is a top level/standalone application.

 

This is the droid you're looking for...
Message 6 of 6
(3,989 Views)