10-15-2009 08:32 AM
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.
Solved! Go to Solution.
10-15-2009 08:37 AM
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
10-15-2009 08:40 AM
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.
10-15-2009 08:44 AM
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
10-15-2009 08:53 AM
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
10-15-2009 09:06 AM
10-15-2009 09:10 AM - edited 10-15-2009 09:13 AM
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...
10-15-2009 10:02 AM
Now it can open the front panel when called in multi instance, but not in running mode.
The vi is attached, thanks.
10-15-2009 10:06 AM - edited 10-15-2009 10:07 AM
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
10-15-2009 10:25 AM
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