LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get qualified VI name / clone name from SubVI?

Hi there,

I need the relationship between a SubVI and its position on the block diagram of the calling VI when running (scripting enabled, VIs are running in LabVIEW IDE). A SubVI can thereby be called multiple times from the calling VI.

 

The SubVIs are all reentrant (as preallocated clones), so using the invoke node "VI -> Get VI Dependencies" from the calling VI returns unique dependency names (input "Include Reentrant Clones?" is set to "Include the clone VI"), even if I use the same SubVI multiple times (e.g. "xyz.vi:2340001" and "xyz.vi:2340002" if I use the reentrant preallocated SubVI <xyz.vi> two times). So far so good.

 

Each VI knows its own fully qualified name when running (e.g. using the "Call chain" VI). Great.

 

The position of a SubVI on the block diagram can be read via the property VI -> Diagram -> SubVIs[] -> Position (as I said with scripting enabled). Perfect.

 

BUT the VIName property of the SubVI property node (VI -> Diagram -> SubVIs[] -> VIName) only returns the SIMPLE VI name ("xyz.vi" instead of "xyz.vi:2340001"), although the invoke node "VI -> Get VI Dependencies" knows its fully qualified name!

 

Is there any chance to evaluate the fully qualified name of the SubVI via the SubVI property node, so that I can build the relationship between a VI and its position?

 

(By the way: It is possible using DETT, but this is like using a sledgehammer to crack a nut; I'm looking for a simpler solution...)

 

Regards,

cpschnuffel

0 Kudos
Message 1 of 18
(5,438 Views)

The VI class has a property called VI Clone Name which should return this.


___________________
Try to take over the world!
0 Kudos
Message 2 of 18
(5,424 Views)

Hi tst,

absolutely, but only the VI class, not the SubVI class. Anyway, the VI knows its own fully qualified name (as I described e.g. by using the Call Chain VI), but the calling VI doesn't know it within the SubVI class. And only then I am able to get the relationship between VI and icon position on block diagram.

 

Regards,

cpschnuffel

0 Kudos
Message 3 of 18
(5,421 Views)

The subVI does have a reference to the VI, but a quick test shows that this returns the original, not the clone, so it won't help you.

 

My guess is that this isn't exposed anywhere in the API. I don't think the clones even exist before you run the VI, so it may not even be possible to do what you want.


___________________
Try to take over the world!
0 Kudos
Message 4 of 18
(5,409 Views)

Hi tst,

assume the following:

 

- One VI as SubVI (reentrant as described before)

- A second VI which calls the first VI a number of times

- A third VI which opens a reference to the second VI and uses the "Get VI Dependencies" method to get its dependencies.

 

You will see that these dependencies contain the correct clone numbers of the first VI even if the second VI hasn't been run.

 

So I don't think that the clones are not existing before run.

 

Second: If you open the first VI out of the second VI (by double-clicking on the icon), you open the clone of this VI, not the VI itself. These clones has the same clone numbers as listed by "Get VI Dependencies".

 

Regards,

cpschnuffel

0 Kudos
Message 5 of 18
(5,404 Views)

Counter argument:

  1. Create a new VI (B) and set it to be reentrant.
  2. Place a few copies of it in another VI (A).
  3. Double click the copies in A. The original B is opened.
  4. Run VI A and double click the copies. Now the clones of B are opened.
  5. Modify VI B in any way and double click the copies in A. Now the original B is opened again.

This shows that the clones are only allocated when running (which makes sense, because why waste resources on allocating the clones if you don't actually need them).


___________________
Try to take over the world!
0 Kudos
Message 6 of 18
(5,398 Views)

Hi tst,

save your VIs A and B to file (without running), be sure to have B made preallocated reentrant and try again; you will get the clone 😉

 

Maybe it's a question of the LV version? Mine is LV 14.0f2

 

cpschnuffel

0 Kudos
Message 7 of 18
(5,392 Views)

Several years ago, I wrote a routine that ran multiple "stations" (a combination of a video camera and a serial device monitoring an animal cage), each of which ran as an asynchronous reentrant clone.  The clones needed to know their "clone suffix", as I used that to create clone-specific named queues for them.  I did that by getting the clone name from the call chain, as you have described.

 

This suggests a way of getting the caller to know the callee's clone suffix, but only once the clone is running (probably because before this time, it is only a "virtual clone" and does not yet have properties).  Simply have the clone save its suffix in a VIG/FGV.  Of course, you need to be able to "get the right one" if you have multiple clones.  In my case, each Station was assigned a number (0 .. 23), so I would set up the VIG with a 24-element array, call Clone(Station ID) with its Station ID, have it determine its Clone Suffix, and save Suffix in VIG[Station ID] (forgive the strange syntax, left over from my Procedural Language coding days).

 

Does that work for you?

 

Bob Schor

0 Kudos
Message 8 of 18
(5,380 Views)

Hi Bob,

thanks for your suggestion.

 

Translated into my task the key is your 24-element-array. This is the connecting link between the SubVI (it knows in which element it has to write) and the calling VI (it knows which element it has to read from).

 

Such a connecting link I am searching for my SubVIs. Unfortunately the user has any freedom to use the SubVIs, to connect them , loop them etc. (it's just a normal VI with SubVIs in it), so it is difficult to create such a link. There is a unique identifier (UID) for each SubVI on a block diagram (VI -> Diagram -> SubVIs[] -> UID property node), but unfortunately only as SubVI property, not as VI property, so the SubVI does not know its own UID.

 

But nevertheless a very interesting approach; I have to think about it....

 

Regards,

cpschnuffel

 

 

0 Kudos
Message 9 of 18
(5,373 Views)

Hi Bob,

I see no chance that your way will help me. For the SubVI property node, reentrant clones of the same SubVI are identical in name and reference (the references have different numbers if you convert them to U32, but if you compare them with "Equal?", they are shown as equal; by the way, the numerical interpretation of the reference via the SubVI property node and of the VI references of the clones is different and may change from run to run, so you cannot compare them), so I have no chance to distinguish them. They differ in UID and position, but these are properties the VI property node doesn't know.

 

What I need is rather a property or method with which I can link the SubVI class with the VI class to identify a VIs icon on the block diagram of the calling VI.

 

Any other ideas?

 

Regards,

cpschnuffel

0 Kudos
Message 10 of 18
(5,360 Views)