I want to create multiple clones of an FGV and put their data into an array on my front panel when called.
I am pretty sure I have the creation of clones correct: I check a strictly typed vi ref and ID cluster for the desired FGV ID, if it exists, I pull the vi ref and send it, if not this code runs:
When probing the [Chamber No, vi ref] cluster, I can see each time a new chamber number is added, the array increases in size.
Here, I'm reading from the vi ref (passed to a different vi through a shared queue). Ideally, it should check the vi against the ViRefArray cluster to see if it should add a new element to the 1D data array or replace an already existing element.
Unfortunately, even though the id's are different, LabVIEW is returning "found" for the ViRefArray. this is making my clones overwrite each other rather than be added together.
Solved! Go to Solution.
You're making things really complicated. Not sure what you want, but I can speculate about some problems you'll run into.
So your keeping an array of references. These are just numbers. If the VI stops, or when it's not even run, the reference will become invalid. The number will still be in your array.
Do you start the VI somewhere else? Doesn't show in your code.
Looking at those update times of the probes, I'd think your test is just off. I'm pretty sure the Search 1D Array is bug free.
- When comparing references you compare if the thing it points to is the same. Every ref in your array is an instance of the vi interface type 0. FIX: Add Property Clone Name to the cluster and compare that instead.
- Your options flag os 0x120. You want 0x160
Have a kudo from me too. I had never run into this problem before, and now I never will.
After reflecting about this for a while, I think this might be a relative new feature (LV10? maybe 8?). So before that could it be that the actual numeric values where compared?
Nope, allway was. Type cast to I32 will compare the value.
But stepping back to the OP though (and getting OT again): why is this even needed? Seems to be easily avoidable? Why the variant? Seems like trying to kill a mosquito with a bazooka to me.
I wanted to do it this way for two reasons:
1) Proof of concept (also wanted to learn more about passing clones/vis)
2) I wanted to separate out processing the data received by the computer so that receiving data (from one COM) would not be held up by processing the data. Also, if one clone starts after another, but finishes before, it will be able to be displayed as soon as it's finished.
As for the Variant, is it better to not use one? Most the P/C states I see pass an enum and variant cluster. Is there a reason to avoid doing so?
I'd not recommend variants when they can't be avoided. It's not always possible, and I can't be sure from the images if they are needed or not.
Both images are "complex". Not impossibly difficult, but too complex for my taste, knowing only a bit about what it does. It's hard to see at a glance what it's intended to do. That's OK for a few VI's in a project.
When starting dynamic VI's per chamber, I'd make a Chambers.class with an array of VI references and an array of chambers in it's private data. It would be very easy to see if a chamber is started, add a chamber, or invoke a method on a chamber, since all needed information is nicely kept in the class wire. The chambers will still be running dynamically, but the user of the class (you) doesn't need to know that.