LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reference to (non strict) clusters for subvi

Solved!
Go to solution

Hello all,

 

I'm trying to "print" the content of some clusters into a TDMS file by a single subVi. The channel name ( = name of the cluster element) and the value should be printed. But I do not want to repeat the name of the channel, so I used the "Label.Text" property to get the name of each element of a cluster.

Unfortunately it is not working, reference to a cluster seems to be diofferent than reference to another cluster.... Is there any possibility to get rid of that strict type check?

 

"Error message: You have connected a refnum of one type to a refnum of another type and both types are members of some class hierarchy, but there is neither a simple up cast nor type cast between the two classes."

 

 

 

thanks a lot

 

Best regards

Matthias   

0 Kudos
Message 1 of 8
(4,169 Views)

Is this a Cluster Reference to a known Type?  Specifically, have you made a TypeDef for this cluster?  [You should almost always make a TypeDef for your clusters].  Wait -- why are you passing a Reference instead of passing the Cluster, itself?  Never mind, I guess I really don't understand what you are doing nor why you are doing it this way.

 

There are some tools in LabVIEW for poking around in Variants, including pulling Clusters apart.  OpenG (from the LabVIEW Tools Network) also has some Variant tools that might help you.

 

Bob Schor 

0 Kudos
Message 2 of 8
(4,162 Views)

Hi Bob,

thanks for your reply. Yes there is a (not strict) typeDef in the main VI. In a earlier version of this sub VI I passed the cluster itself. But then the type of the cluster in the subvi is fixed. This is not what I want to do. I want to allow any cluster type (at least any cluster with a name for each element inside).

Is there a possibility to pass a kind of "reference to a general cluster type"?

 

Thanks

Matthias 

  

0 Kudos
Message 3 of 8
(4,157 Views)

@run321 wrote:

Is there a possibility to pass a kind of "reference to a general cluster type"? 


I see two options:

1) Use variants for you general VI.  If you do this, you might as well use the OpenG library since they have done most of this work for you.

2) Change your clusters to Classes and then use inheritance and dynamic dispatch to do what you want.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 8
(4,128 Views)

It's me again,

Hi all,

one additional problem: this code is too slow!!! The input queue is increasing and increasing!!!! Then I replaced the part which gets the cluster elements (name and value) by a fixed string (the value is no problem) and then it worked. So to fetch the cluster element names from the reference node seem to take too much time (see sub-vi from the post below). Is there any other method available?

 

thanks and all the best for 2017 🙂

 

Cheers

Matthias

 

 

0 Kudos
Message 5 of 8
(4,080 Views)

We don't have any code to inspect (you didn't attach anything), so it is difficult to (a) see what you are doing, (b) try it ourselves, and (c) suggest better alternatives.

 

As Crossrulz notes, if you want to process unknown clusters and get the names and values of each of the elements, then you should really look into the OpenG Toolkit, which includes a "Get Cluster Element Names" function, among others.

 

When you installed LabVIEW, you should also have installed VIPM (the VI Package Manager), probably located in the JKI Folder in the list of programs on your Start Menu.  If not, you can look up VIPM and download/install it (it is free).  Once you've got it running, look for and install the OpenG Toolkit (that's the only one you need to install -- it will pull in all of the OpenG Routines you will need).

 

If this still gives you trouble, take your final VI (with the OpenG code) and post it (as a VI) to your reply.

 

Bob Schor

0 Kudos
Message 6 of 8
(4,071 Views)
Solution
Accepted by topic author run321

I wrote this Nugget on Using Control Referenes to help understand how to exploit control references.

 

in that series of posts I start with basic ideas and end with a generic set of code that can handle any type of cluster including arrays of clusters of arrays of ... up to a 2D array of any cluster type.

 

That Nugget may help you figure how to handle your situation. It offers some example code that "caches" the defintion of the cluster one time and works from there.

 

But since it does use prperty nodes that require acess to the UI thread, it can be slow for large and complex data types.

 

Please take a look at that Nugget to see if there is anything you may have missed.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 7 of 8
(4,052 Views)

Hi Ben,

thanks for all, yes it helps to understand the hierarchy structure of general clusters and type clusters... In the meantime I've downloaded the openG toolbox and will try to go that way, as the runtime is critical in this project  🙂

 

Thanks for all

 

Best regards

Matthias

0 Kudos
Message 8 of 8
(4,042 Views)