07-23-2015 11:38 AM
I know you can use the call chain to find the caller of the current VI (or it's caller's caller, etc.). But what if you want to know the caller of a VI that is not in your call chain?
We have a utility for centering VI's on their calling window (a feature that I think LV should support natively, btw), which works fine for cases where I am effectively saying:
"Center this VI's window on it's caller", or even "Center a VI within this call chain on it's caller"
But what if I want to say:
"Center that other VI over there on it's caller"?
I see that there is a VI.Callers property, but that doesn't seem to work for reentrant VIs. (It seems to return all callers of the template VI, rather than on the specific clone instance)
Does anybody know of a way to get the caller (or full call chain) of an arbitrary VI reference?
07-24-2015 09:39 AM
Hello TurboPhill,
Are you trying to get the call chain from another VI that is also running? Or you just want to get which would be the call chain of a VI that is not running at that specific moment?
Regards,
07-24-2015 09:51 AM
Yeah, getting the call chain of some other VI would work. If that were a property exposed that we could read from a VI reference. Then I could do the same logic as shown above.
But as far as I can tell, the only way to get a VI's call chain is via that primitive, that only works on this VI (the one calling that primitive).
07-24-2015 09:55 AM
@TurboPhil wrote:
But as far as I can tell, the only way to get a VI's call chain is via that primitive, that only works on this VI
Well not just this VI, but any VI in the chain. So your VI for centering a window on the calling VI can be done quite easily as a VI that is called. So there is
Main VI Window - > Sub VI Window - > Center VI Utility
From here Center VI Utility can get the call chain and know what called sub, then find its front panel and center sub on it.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
07-24-2015 09:59 AM
Right. That's what I have so far. What I'm asking is for getting a call chain of a VI outside of the call chain of the VI requesting it.
Imagine I have some actor that receives messages in the form of VI references. That actor gets some arbitrary VI reference that may not exist in its call chain (maybe one or the other was dynamically launched). But I want that actor to be able to determine the caller of the VI reference it received. Is that at all possible?
07-24-2015 10:07 AM
@TurboPhil wrote:
But I want that actor to be able to determine the caller of the VI reference it received. Is that at all possible?
Not that I know of, but I think a better design might be to send a message to the actor, telling it to center itself, which is where it calls that VI. I just think it is more modular if this extra coupling to another process which is trying to get the reference and the calling reference might add confusing, especially if you are debugging why a window behaves a strange way. By keeping all the window processing in that actor it might be easier to debug.
That being said I think haveing a function that returns a call chain, given a VI reference is a good feature, and if it isn't on the idea exchange I suggest you add it.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
07-24-2015 10:16 AM
07-24-2015 04:36 PM
I posted on your Idea Exchange note a simple method for finding the VIs in memory that can call an arbitrary VI. That's not quite the same as a Call Chain, which is the sequence of those functions which did call this particular instance of the VI. Since a sub-VI could be called from lots of other VIs in your Project, determining at any time which is calling seems to me would require getting inside the Run Time Engine and doing sort of a context swap so you could trace the Call Chain back to its beginning.
Given how easy it is to find all of the VIs that call an arbitrary VI and how this can lead to an exponential explosion once you look at the caller's caller (and caller's caller's caller, each time generating an array of yet another dimension), getting the particular caller at this particular time might be impractical (adding that much "tag" information might slow speedy LabVIEW down somewhat).
Bob Schor
P.S. -- I don't really know if this is the case, but it does seem likely to me ...
07-25-2015 05:14 AM
Does anybody know of a way to get the caller (or full call chain) of an arbitrary VI reference?
I don't see how it's possible.
WITHIN a given VI instance, it can know where it got called from.
But if you just pick an arbitrary VI "over there", it's possible the VI has zero or two or twenty callers, even at the same time.
It would have to return an array of VI refs, I suppose, but which one are you interested in? There's no way to tell, I don't think.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
07-26-2015 06:34 AM
I asked this on the IDEA thread:
If A calls X
and B calls X
and C calls D which calls X,
then what is the "call chain" for X?
Remember, there could be 0-3 instances of X running at the very moment you ask the question.
So, what is the answer that you expect?
Blog for (mostly LabVIEW) programmers: Tips And Tricks