LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to dynamically start an x amount of shared-clone reentrant VI's?


@Hooovahh wrote:

I suggest you start thinking in terms of arrays.  You have an Array of VI references, and you start them with a for loop.  Set to the for loop to for the number of instances you want.  In there you might pass in a user event, or queue references to each instance (so an array of references).  Then when you want to talk to a specific instance, you can use the reference you sent into that VI.


Ok I think I'm sort of tracking. Lets say my config file says I have 3 devices in the system. I'll take that value of 3 and plug it into the for loop iteration terminal. Inside my for loop will be the Open VI Reference.vi. After the for loop has completed its iterations, I can send that array of references off to somewhere to be used.

 

Correct?

0 Kudos
Message 11 of 15
(527 Views)

Here is a very quick and dirty update to that example I showed.  It starts all the instances, and gives each a unique Queue.  Then I can send data on that queue by selecting the index from the array to send that specific instance some new data to act on.  You can also have this work in reverse sending data back too.  Run the example, then you can select an instance, and text to send it.  Also closing the main VI will send the quit to all the other instances to close them all too.

0 Kudos
Message 12 of 15
(520 Views)

@Hooovahh wrote:

Here is a very quick and dirty update to that example I showed.  It starts all the instances, and gives each a unique Queue.  Then I can send data on that queue by selecting the index from the array to send that specific instance some new data to act on.  You can also have this work in reverse sending data back too.  Run the example, then you can select an instance, and text to send it.  Also closing the main VI will send the quit to all the other instances to close them all too.


I'm posting a screenshot of what I did before looking at your example

main 3.PNG

0 Kudos
Message 13 of 15
(517 Views)

I attached my test VI's to this post. They will probably make you want to pvnch a baby, but I would love some feedback as to if this could work. This is just basic architecture, the example doesn't have everything it would need.

Download All
0 Kudos
Message 14 of 15
(497 Views)

Yeah that looks fine.  But lets say some day you want to support 4 instances, or 5, or 10?  Are you going to add new cases to each of the while loops, adding more and more code for each of the instances?

 

A better design is going to use the fact that your array of references, is the size of how many instances you have.  If you want to read all of them, just call the Wait On Asynchronous Call in a for loop, and that for loop will then return an array of numbers, and an array of errors.

0 Kudos
Message 15 of 15
(451 Views)