03-26-2009 02:49 PM
Hello all,
I am trying to create a program that passes in a cluster of plots to a subvi that accepts generic controls. The reason for this is the number of elements in the cluster may change and I want to create a modular subvi that does not always break the connector pane. I'm guessing an array would actually be a better solution for this example, but in any case I want to see if there is a way to get this specific program working.
The subvi then converts this generic control to a cluster control using the "to more specific class" function. Using property nodes, I can then index each element and obtain the data information I want.
The problem I am running into is that I receive the ERROR 1057 each time I try to convert the generic control into a cluster control. I am first typecasting the cluster and I'm pretty sure I am doing this incorrectly. I'm not sure how to go about fixing this as I have minimal experience using typecasting functions. I do notice that if I first create an indicator for the clusters, then i can easily convert this indicator to a more generic class, and pass this into the connector pane with no problems. For my application, I would like a way of obtaining a reference to a cluster without having to create an indicator each time. Hopefully there's an easy solution to this problem. Thanks for the help!
03-26-2009 04:33 PM
You're way off base here, with serious round-peg, square-hole issues.
First, a GRAPH is a thing on the front panel, which displays one or more PLOTs. There's no such thing as a reference to a plot.
When you bundle the three graph refs (upper left), you have a data structure with three items in it.
When you cast that to a single control ref, you throw away most of the data.
By definition, a cluster is for a fixed number of various type items.
By definition, an array is for a variable number of identical items.
If you want to pass a variable number of graph refs to a subVI, then build an array using the refs, and pass it.
You are fighting the system, instead of letting it work FOR you.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
03-26-2009 04:39 PM
Instead of passing in a cluster of references, try passing in an array of references. Then you won't need the typecasting at all.
As for your question "Is there a way to obtain reference to a cluster that has no control?" Well, sort of.
First of all, a control reference is a reference to a specific front panel object.
That being said, you can put one on the block diagram by selecting (from the function palette) Programming-->Application Control -->Class Specifier Constant and then from the object menu, select Select VI Server Class -->Generic-->GObject-->Control-->Cluster... but I'm not really sure what (if anything) that would get you.
03-26-2009 04:41 PM
03-26-2009 04:44 PM - edited 03-26-2009 04:46 PM
You can't create a reference to an object that doesn't exist. A control reference points at a specific front-panel object (control or indicator), not to data. Your typecast tells LabVIEW to treat the cluster data as if it were a reference, but since that reference is garbage and doesn't point at anything, LabVIEW gives you an error.
EDIT: looks like Matt beat me to it (same phrasing, even!)
03-26-2009 04:45 PM
Great minds think alike. So do mediocre ones.
Whether we are the former or the latter is left as an exercise for the reader...
Blog for (mostly LabVIEW) programmers: Tips And Tricks
03-26-2009 05:17 PM
Law of averages says that the more people in the group that posted the same thing, the more likely they are to be mediocre. (Since great minds are rare)
Damn.
03-26-2009 05:43 PM
Law of averages says
Crap, now I have to go get my lawyer involved?
Blog for (mostly LabVIEW) programmers: Tips And Tricks