03-25-2009 09:43 AM
Hello -
Is it possible to create control refnums for front panel objects and make a type defined cluster out of them? I don't seem to be having any luck, but I could swear I've seen it done before.
I am trying to pass a cluster of control references into sub-vis that will be called dynamically (using call by reference). I want to create a standard cluster for use in all of the sub-vi's without having to go back and edit the cluster in every VI if anything is changed or added.
If not, is there a better way?
Thanks,
Mike
Solved! Go to Solution.
03-25-2009 09:51 AM
I wrotethis Mini-Nugget to show how to that the easy way by taking advantage of the middle input of a bundle (not bundle by name).
Here is a preview of thatt Nugget.
Ben
03-25-2009 10:06 AM
Thanks for your response, Ben. I created the cluster in the way you've shown, but when I save it as a type defined cluster, then try to use it in a sub VI, I get an "Object reference is invalid" error.
I'm new at control refnums, so I may be doing something completely boneheaded - please bear with me.
03-25-2009 10:14 AM
That is exactly what typedefs are for.
Start from a new blank VI.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
03-25-2009 10:17 AM
when I save it as a type defined cluster, then try to use it in a sub VI, I get an "Object reference is invalid" error.
Remember that your typedef is just that, a TYPE DEFINITION.
You have to populate it with REAL REFERENCES to REAL CONTROLS.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
03-25-2009 10:20 AM
Steve -
When I create a cluster constant and try to drag the reference into it, it just ends up behind the cluster constant.
Mike
03-25-2009 10:25 AM
I have created a cluster of refnums and set them as a type definition, I just can't seem to use them.
As a simple example, say I have a main VI with an LED on the front panel. This main VI runs a subVI that needs to manipluate that LED in real-time, while the sub VI is running (which may run for 2 minutes and turn the LED on and off or change the color 5 times during that two minutes).
In my final application, there will be several controls and indicators being manipulated in the sub-vis, which is why I would like a type defined cluster.
03-25-2009 10:27 AM
You're right - that's not doable (and I don't know why)
Try this procedure:
Blog for (mostly LabVIEW) programmers: Tips And Tricks
03-25-2009 10:30 AM
Remember that the typedef is nothing but a placeholder.
A cluster with two I32s in it is just a container.
If you want your values in it (rather than default zeroes), you have to put the values into the cluster.
A cluster with two CONTROL REFS in it is likewise just a container.
If you want references to REAL controls in it (rather than default NILs), you have to put them into the cluster.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
03-25-2009 10:39 AM - edited 03-25-2009 10:43 AM
Once I created that type def (look at my Mini Nugget to see how I did that) the type def was used as shown below to update control from a sub-VI.
I had an app with hundereds of controls and indicators that needed updated.
So I bundled refes for all of the control into logical groups.
Then passed these refs to the sub-VI
And the sub-VI used those named refs to do the updates.
I hope that help,
Ben