LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic call sub vi issue

Solved!
Go to solution

By using the vi in the attached picture, I am trying to call the sub vi many times, each time should open another instance.

 

But I can only open an instance at the first time. The 2nd time will give error as below.

 

LabVIEW:  The VI is not in a state compatible with this operation.

 

And when I run again, even the 1st time give same error.

 

 

By the way, I also want to control the position of the new instance, they should appear just beside the center and each one shift a bit.

 

Also, when they been closed, is there any method to send a message back to the parent vi.

 

Thanks.

0 Kudos
Message 1 of 12
(4,962 Views)

There is a flag in the OpenVI Reference for that (i think it was 8), also (I'm not sure if it is necessary on recent LV versions) the vi to be called should be a template (vit).

 

I'm sure there is a property for the windows position (don't remember the name). 

 

For back messaging you could use events, notifiers or similar and capture the FP.Close? Event inside the dynamic vi. 

 

Felix 

Message 2 of 12
(4,951 Views)

F. Schubert wrote:

There is a flag in the OpenVI Reference for that (i think it was 8), also (I'm not sure if it is necessary on recent LV versions) the vi to be called should be a template (vit).


The 8 flag means prepare for Reentrant VI.  I call VI's that are not templates, but they have to be set as Reentrant and the Execution Properties page.

--
Tim Elsey
Certified LabVIEW Architect
Message 3 of 12
(4,944 Views)

There are several things you will need to do for this to work.

1. You need to set the VI you want to launch to reentrant execution. You do that in the VI Properties dialog under the Execution tab.

2. When you load it with Open VI Reference, you need to input 8 on the Option terminal. This will open a new instance of the program.

3. To control the position, you will need to keep track of where you want it to be and then write those values to the VI>Front Panel Window>Panel Bounds property of the VI you opened.

 

The only way to send a message back to the parent is to use some sort of queue or event that you have to set up within the parent and child vi's.

 

That should get you most of the way to where you want to be! 🙂

 

Chris

Message 4 of 12
(4,940 Views)

Much better one: You can even wire the VI refnum to the Register Event function and select the Panel Close Event! And it should even work with an array of VI refs. Cool...

 

Felix 

Message 5 of 12
(4,933 Views)
I set reentrant execution and 8 for Open VI reference, but when calling it this time, nothing happen, even no error, the vi window not appear any more.
0 Kudos
Message 6 of 12
(4,927 Views)

The only difference I see with your code and what I use, is that right after Open VI Ref I use an invoke node to open the front panel...

untitled.PNG

Message Edited by elset191 on 10-15-2009 09:13 AM
--
Tim Elsey
Certified LabVIEW Architect
Message 7 of 12
(4,923 Views)

Now it can open the front panel when called in multi instance, but not in running mode.

 

The vi is attached, thanks. 

0 Kudos
Message 8 of 12
(4,917 Views)
Solution
Accepted by topic author alex.

The Invoke node I showed is not meant as a replacement to the Run VI Invoke node.

Also, the vi you attached is mostly useless because you haven't attached the 3 subVI's

 

My whole VI looks like this

untitled.PNG

Message Edited by elset191 on 10-15-2009 10:07 AM
--
Tim Elsey
Certified LabVIEW Architect
Message 9 of 12
(4,912 Views)

Some minor improvements:

* Place the OpenVI after the othe properties, so the user won't see them set.

* Use OpenG VIs that encapsulate the property nodes (SetControlValue), mainly aesthetic...

* Better readable would be the Control names as an array outside the for loop in the same order as the values

 

Felix

Message 10 of 12
(4,905 Views)