LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

open vi reference - reentrant vi state

Hello,

I need to open many references to the same vi and run them with diffrent parameters so option x08 is desired

Thing that I am curious about is why after I open reference exec state of that vi is set to running?? 

It will be running when I call method run vi

 

demo.png

0 Kudos
Message 1 of 7
(4,051 Views)

Hello,

 

I see it this way:

 

Execution State Running means:    VI is reserved for execution by one or more active top-level VIs (from help).

Open VI Reference option 0x08 means:     Prepare for reentrant run (from help).

 

So your VI is reserved for reentrant execution.

 

Note that not your VI will run when you call method run VI, but a clone of your VI will run and the VI reference returned by 'Open VI Reference' belongs to the original VI not to the clone VI.

 

 

Hope this helps,

UliB

0 Kudos
Message 2 of 7
(4,019 Views)
As pointed out, the property has a hole and doesn't have an accurate representation for the waiting to run or reserved state, so it uses the running value for that.
I didn't check, but I expect that when you run the VI, its state should be run top level, so maybe you can rely on running to mean reserved.
Another option, if what you want to do is ensure it's ready, is some form of handshake - pass the VI a user event or notifier reference and have it signal back when it's ready. The parent listens for the signal. Make sure to register for the signal in the parent before the child starts running and to have some timeout strategy if you don't get the signal.



@UliB wrote:

...the VI reference returned by 'Open VI Reference' belongs to the original VI not to the clone VI.

 Other way around. The reference is to the new clone when using 0x08.


___________________
Try to take over the world!
0 Kudos
Message 3 of 7
(3,983 Views)

If you look at the Help for Open VI Reference (in "recent" versions of LabVIEW), you'll notice that NI recommends using Start Asynchronous Call instead of the Run VI method to start the asynchronous VI.  I strongly agree with this recommendation.

 

Bob Schor

0 Kudos
Message 4 of 7
(3,973 Views)

Thanks UliB,

 

so when using option x08 open vi referenceit won't return reference to allocated clone? I didn't expect that 😄 that seems strange...

If I want to open 2 clones, sent them some params and run them what will be correct approach? Later by reference to my clone I will check in what state it currently has and read results.

0 Kudos
Message 5 of 7
(3,968 Views)

@pawhan11 wrote:

 

so when using option x08 open vi referenceit won't return reference to allocated clone?


No, Uli's post is wrong. Like I said, you do get a reference to the new clone, so you're fine.

 

For your use case, you might want to use the async call, as Bob suggests, as that will allow you to pass values in and read the value back (or you can use a standard call by reference node if you can wait for the VI to finish).


___________________
Try to take over the world!
0 Kudos
Message 6 of 7
(3,944 Views)

tst wrote:

@UliB wrote:

...the VI reference returned by 'Open VI Reference' belongs to the original VI not to the clone VI.

 Other way around. The reference is to the new clone when using 0x08.


 

I apologize for the confusion.

Before posting that statement I did a quick test with 'VI Name' property, but did not realize that there is a 'Clone Name' property too and I got things wrong.

Sorry.

 

 

0 Kudos
Message 7 of 7
(3,917 Views)