LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get for a VI instance its own SubVI Refnum

Solved!
Go to solution

Hi All,

 

Through the "Diagram property" of a given VI, you can access to the array of the references of all the SubVIs it contains. (Scripting purpose).
But I can't figure out, how an instance of a VI (in another VI diagram) could return its own subVI refnum.
I mean, I have N instance of a same VI in a diagram, and I would like each of them to returns as a result, its own subVI reference.

Sorry for my poor english... so I post a VI that explains better what I mean (I hope !).

Hope this is clear enough...

Best regards
Emmanuel

0 Kudos
Message 1 of 23
(3,839 Views)

Why not this?

 

this.png

 

But, what good is returning a subVI reference with an indicator?  The calling VI will only get the reference when the subVI finishes executing.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 2 of 23
(3,831 Views)

Jim, what your constant returns is the VI's reference : all instance will return the same reference value to the VI.
What I need is the instance subVI reference : I need each instance of a VI to return its own and unique reference value.

Let's imagine, for example, that I want to dynamically call the Scripting Method "set a breakpoint" on a specific instance of my SubVI, let say when some special conditions are met.

0 Kudos
Message 3 of 23
(3,823 Views)

Remember that even if you place multiple instance of the same VI on a diagram, if the subvi is NOT reentrant, there is still only one instance of the subVI in memory, and trust you will only get the reference back to that instance in memory.

 

And of cource the subVI's on the diagram will not run in parallel.

0 Kudos
Message 4 of 23
(3,805 Views)

A VI reference and a SubVI reference are two LabVIEW objects really differents...

 

I'm not a beginner in LabVIEW (I've been LabVIEWing since 1994...) so I think that my problem is a real challenge... or is just not possible... 😉

 

Ok, to be more clear... let's take a look at the following VI diagram.
In this VI code, what I need is to get the reference of the instance subVI (which currently executes the code) from the array containing SubVIs references.

diag.JPG

Message 5 of 23
(3,795 Views)

Why do you even need this "subVI" reference?  The reference is only relevant to the VI that is above it.  What do you want to do with this reference in the subVI?

 

With scripting, you can't have a VI modify itself while executing, likewise you can't have a subVI modify the VI above that called it since it is also executing.

 

What you could do is use the scripting commands in the VI above to get the reference for the specific instance of the subVI and pass it into the subVI through the connector panel.  But it still leads to the question as to what is so useful about this reference?

 

As stated before, there is a difference between an instance of a subVI on a block diagram and an instance of a subVI in memory, and it is greatly affected by whether that subVI is reentrant. (and fully reentrant with preallocated clones vs. shared clones).  The reference you are trying to use is a reference to the subVI "block" that is sitting on the block diagram, and is a completely different concept than an instance of the subVI that is occupying space in memory.

0 Kudos
Message 6 of 23
(3,764 Views)

RavensFan, you have the exact expression of what I need : Yes, I need the reference of the subVI "block" that is sitting on the block diagram (and not of an instance of the subVI that is occupying space in memory).

Well, it's a little bit tricky and long to explain why I need this, and my english is a little bit rusty for this, but I need it...

 

I see quite some others reasons than mine to do what I want to do and my need is real ... believe me and there's no workaround I can do...


If you have the solution to the problem I've exposed, I will explain it to you (in private) with great pleasure !

Hope my english is not too much rusty to seem rude...:(

 

Just to go further to your questions : I agree that a running VI can't be modify by script, but it can be done later (so when stopped) by another VI running independantly...

 

0 Kudos
Message 7 of 23
(3,757 Views)

The only solution I can think of is what I said to determine the reference in the VI that contains subVI block and pass the reference to the subVI through the connector panel.

 

You say you want to determine the reference while running, and then use it later in another VI when it is not running.  I really don't know whether that would work or not.  It could be very risky.  Something tells me that a reference number that may be generated while a VI is running may no longer be valid when the VI is in a different execution state.  So trying to use a reference later in a different VI may mean the reference is no longer valid, or it may by chance refer to a different object.

0 Kudos
Message 8 of 23
(3,742 Views)

The only solution I can think of is what I said to determine the reference in the VI that contains subVI block and pass the reference to the subVI through the connector panel.

 

I'm not sure to understand your proposal... but I think that the problem is quite the same.

You say you want to determine the reference while running, and then use it later in another VI when it is not running.  I really don't know whether that would work or not.  It could be very risky.  Something tells me that a reference number that may be generated while a VI is running may no longer be valid when the VI is in a different execution state.  So trying to use a reference later in a different VI may mean the reference is no longer valid, or it may by chance refer to a different object.

 

I do not agree. If the behavior was the one you are afraid of, then scripting could just not work. Since Scripting is done on VIs who don't run.
Also I've made tests, and the references are still valid after execution, and it's logic. IMHO.

0 Kudos
Message 9 of 23
(3,737 Views)

To  give an example, let's take a look at the following diagram. There's several instance of my "famous" VI which should return it's own subVI reference.
Here, I just want one of the instance of my subVI to be "put in evidence" (sorry it's a french LabVIEW that I have).
This is just an illustration of what could be done... once again, my real need is a little bit longer to explain...

example.JPG

0 Kudos
Message 10 of 23
(3,732 Views)