10-01-2015 03:33 AM
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
10-01-2015 06:29 AM - edited 10-01-2015 06:36 AM
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
10-01-2015 10:38 AM
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.
10-01-2015 10:53 AM
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
10-01-2015 10:54 AM - edited 10-01-2015 10:56 AM
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.
10-01-2015 11:46 AM
@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).
10-02-2015 03:32 AM
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.