02-10-2023 03:13 PM
@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?
02-10-2023 03:34 PM
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.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
02-10-2023 03:37 PM
@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
02-10-2023 04:26 PM
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.
02-13-2023 12:21 PM
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.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord