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.
Solved! Go to Solution.
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.
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.
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.
Here the slave FP.
But it's what i'm looking for avoid (Having Top Level ref Vi on slave FP).
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
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.
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?
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.
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?