sydney Posted November 3, 2009 Report Share Posted November 3, 2009 I tried to bundle by name several references to clusters of controls, but find that when I drop the reference into the cluster constant box on the block diagram, the reference is not recognized by visually changing the border of the cluster box. The reference cannot be dropped into the cluster, which to me is rather strange as I look at what I am trying to do as making a struct containing pointers and seems reasonable to me. I am trying to do this since my front panel contains several clusters each containing a number of controls, and I am not trying to mix controls and indicators. If I can do this then I can pass in just one parameter to a subVI that has to work with all these clusters of controls instead of the many more parameters that I would have to pass in if I do each cluster as a separate parameter. Any suggestions? Quote Link to comment
Francois Normandin Posted November 3, 2009 Report Share Posted November 3, 2009 I tried to bundle by name several references to clusters of controls, but find that when I drop the reference into the cluster constant box on the block diagram, the reference is not recognized by visually changing the border of the cluster box. The reference cannot be dropped into the cluster, which to me is rather strange as I look at what I am trying to do as making a struct containing pointers and seems reasonable to me. I am trying to do this since my front panel contains several clusters each containing a number of controls, and I am not trying to mix controls and indicators. If I can do this then I can pass in just one parameter to a subVI that has to work with all these clusters of controls instead of the many more parameters that I would have to pass in if I do each cluster as a separate parameter. Any suggestions? You will have to create a reference constant and then drop the constant in the cluster. Right-click on your reference to create a constant from it, drag it to the cluster and then wire your reference to a "bundle cluster" primitive. Quote Link to comment
Grampa_of_Oliva_n_Eden Posted November 3, 2009 Report Share Posted November 3, 2009 I tried to bundle by name several references to clusters of controls, but find that when I drop the reference into the cluster constant box on the block diagram, the reference is not recognized by visually changing the border of the cluster box. The reference cannot be dropped into the cluster, which to me is rather strange as I look at what I am trying to do as making a struct containing pointers and seems reasonable to me. I am trying to do this since my front panel contains several clusters each containing a number of controls, and I am not trying to mix controls and indicators. If I can do this then I can pass in just one parameter to a subVI that has to work with all these clusters of controls instead of the many more parameters that I would have to pass in if I do each cluster as a separate parameter. Any suggestions? In this Nugget I showed a method that allows you to quckly develop the cluster you need to bundle. http://forums.ni.com/ni/board/message?board.id=170&message.id=296427&query.id=813501#M296427 Once you have created it, save it as a type-def as I described here. http://forums.ni.com/ni/board/message?board.id=170&message.id=233257#M233257 Ben Quote Link to comment
Mark Smith Posted November 3, 2009 Report Share Posted November 3, 2009 I tried to bundle by name several references to clusters of controls, but find that when I drop the reference into the cluster constant box on the block diagram, the reference is not recognized by visually changing the border of the cluster box. The reference cannot be dropped into the cluster, which to me is rather strange as I look at what I am trying to do as making a struct containing pointers and seems reasonable to me. I am trying to do this since my front panel contains several clusters each containing a number of controls, and I am not trying to mix controls and indicators. If I can do this then I can pass in just one parameter to a subVI that has to work with all these clusters of controls instead of the many more parameters that I would have to pass in if I do each cluster as a separate parameter. Any suggestions? That's because the reference isn't a constant - the actual value gets assigned at run time so what you're essentially trying to do is get the current pointer value and assign it to a constant. This is probably a bad idea most anytime so LV keeps you from doing it. You can create a constant cluster with control ref constants (the easiest way I can think of would be drop controls from the refnum palette and then create a constant) and then bundle the actual control refs into that, but they can't carry control type information - you'd have to cast them to the correct type when you unbundle. I think what you could do is 1) create control refs from your controls 2) Create controls from the control refs (these will be strictly typed) 3) create a cluster on the FP with all of these control refs 4) save the cluster as a type def 5) use this type def to bundle/unbundle the control refs 6) pass the ref to this cluster between VIs Caveat! It's usually a bad idea to pass control refs instead of data between VI's in LabVIEW because this will always force execution into the UI thread. Only pass refs if you have a good reason - if the data could be on a wire, put it on a wire. Edit: Okay. I'm late to the show - what Ben said is the same only appears easier! Quote Link to comment
Dan DeFriese Posted November 3, 2009 Report Share Posted November 3, 2009 I tried to bundle by name several references to clusters of controls, but find that when I drop the reference into the cluster constant box on the block diagram, the reference is not recognized by visually changing the border of the cluster box. The reference cannot be dropped into the cluster, which to me is rather strange as I look at what I am trying to do as making a struct containing pointers and seems reasonable to me. I am trying to do this since my front panel contains several clusters each containing a number of controls, and I am not trying to mix controls and indicators. If I can do this then I can pass in just one parameter to a subVI that has to work with all these clusters of controls instead of the many more parameters that I would have to pass in if I do each cluster as a separate parameter. Any suggestions? Actually, what you describe is perfectly reasonable to me. Your saying that your creating a "structure of pointers", but your're wanting to make this structure a constant. The problem is that pointers (or LabVIEW's rough equivalent of references) have no meaning at edit time. That is, they have to point to or reference some location in memory at runtime and that location may be different each time the program is run. Anyway, I might suggest using a typedef'd cluster control and use that to pass the references around for you GUI subVIs. Let me know if you don't understand what I mean and someone may post an example. ~Dan Quote Link to comment
sydney Posted November 3, 2009 Author Report Share Posted November 3, 2009 You will have to create a reference constant and then drop the constant in the cluster. Right-click on your reference to create a constant from it, drag it to the cluster and then wire your reference to a "bundle cluster" primitive. Once I saw how to create the constant from the reference everything fell into place and the subVI now has one input parameter instead of the original 10 references and I now feel better about the much cleaner interface. Thanks to all for the tip(s)! Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.