LabVIEW APIs Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Who Launch me

Solved!
Go to solution
Highlighted

Hi

I have one  project where one Vi (launcher) launch dynamically  another vi(Slave). I want to know if there is scripting way to permit  Slave to know who launch it.

The simplest way, than i have found, is to pass  the Launcher reference to the Slave, by one "Define command value" invoke. But my wish, is to avoid this way.

0 Kudos
Message 1 of 11
(5,382 Views)

If you say launch I suppose you talk about the Run VI method. In that case there is no inherent knowledge possible of the launched VI, who has launched it. You do have to provide this information explicitedly to the launched VI.

If it is rather a (a)syncronous call with Call By Reference, then you can retrieve the Call Chain and the second element is the caller VI.

Rolf Kalbermatter
Averna BV
LabVIEW ArchitectLabVIEW ChampionLabVIEW Instructor
Message 2 of 11
(2,563 Views)

I'm in the first case  with Run Vi method. Thanks Rolfk

0 Kudos
Message 3 of 11
(2,563 Views)

Probably something like this works. You don't even need to spend an extra SubVI connector for this and could hide the "caller" control in addition.

givememycaller.PNG

0 Kudos
Message 4 of 11
(2,563 Views)

Thanks comrade. But it's not very different than my solution who is to pass Ref of launcher by CtrlVal.Set.

Nota: The Ref Control in the Slave do not need connect to the conpane to be modify. 

Here the launcher diagram.

Launcher.jpg

Here the slave FP.

Slave.jpg

But it's what i'm looking for avoid (Having Top Level ref Vi on slave FP).

0 Kudos
Message 5 of 11
(2,563 Views)

I see that's about the same. However, using my proposal you would spare the reference, so there wouldn't be an issue with closing this reference later

Otherwise the Asynchronous Call VI is the only solution, as rolfk stated

AsynchronousCall.png

0 Kudos
Message 6 of 11
(2,563 Views)
This widget could not be displayed.
Solution
This widget could not be displayed.

The synchronous Call By Ref treats the invoked VI as a subVI and so the subVI can get caller info from the Call Chain.

The Asynchronous Call By Ref treats the invoked VI as a subVI ONLY IF YOU DO FIRE & WAIT. If you do fire & forget, then it is treated as a top-level launch, same as calling the Run VI method.

Message 7 of 11
(2,563 Views)

Thanks for this insight!

Would there be a way to dynamically determine the VI type specifier in order to be able to make a synchronous Call by Reference?

0 Kudos
Message 8 of 11
(2,563 Views)

There is a way to determine the type, but it probably won't help you really. Yes, the VIs exist to analyze the incoming VI and figure out its connector pane, but a strict VI reference (one that can be wired to the Call By Reference node) have a fixed connector pane, meaning that you would already know the type of any reference dynamically passed in to invoke.

If you truly do not know the connector pane of the VI ref coming into a function, you can use the Set Control Value method on the VI to assign values and then call the Run VI method. Much more cumbersome than using the CBR node but works for times when you do not know the connector pane.

0 Kudos
Message 9 of 11
(2,563 Views)

The point of my question actually was, whether the CBR can be used just like the RunVI method for Eric_BOB's purposes. He didn't say whether he knows the connector type of the VI he is trying to run, along with getting the caller VI's name across to the called VI. So using "SetControl Value" and "Run VI" in Eric_BOB's scenario doesn't help here as you just stated that RunVI breaks the calling chain...

For which purpose we just found the CBR...

So the answer is no - VI Type Specifiers can't be created dynamically for this purpose - you have to know the connector pane in advance. Correct?

0 Kudos
Message 10 of 11
(2,563 Views)