LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Pass reference of cluster to SubVI creates class conflict when cluster changes

Solved!
Go to solution

Hi,

i created a SubVI to store data in a CSV file. In order to use the SubVI in different contexts and with changing cluster entries, I did not wire the cluster, but a reference of the cluster to the SubVI. The SubVI than reads the values and labels of the cluster. Everything worked like a charm. As soon as I try to change the structure of the passed cluster or use the SubVI in a different context, a class conflict between the cluster reference and the input terminal of the SubVI occurs. I attached the working SubVi. Here is a screenshot of the working MainVI:

jorgeBS_0-1778056077435.png

As soon as I add another Variable to the cluster the error "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." occurs.

jorgeBS_1-1778056221636.png

I already read that typdefs may be the correct approach, but I can not make it work.

Thank you all for your help!

 

Jorge

0 Kudos
Message 1 of 7
(489 Views)
Solution
Accepted by topic author jorgeBS

Hi Jorge,

 

Right-click the cluster reference input of your subVI > Select Ctrl Type > Cluster.

It will turn it into a weakly-typed cluster reference instead of a strictly-typed cluster reference.


See: https://www.ni.com/docs/en-US/bundle/labview/page/switching-between-strictly-typed-and-weakly-typed-...

 

Regards,

Raphaël.

Message 2 of 7
(464 Views)

Hi Jorge,

 


@jorgeBS wrote:

In order to use the SubVI in different contexts and with changing cluster entries, I did not wire the cluster, but a reference of the cluster to the SubVI.

The SubVI than reads the values and labels of the cluster. Everything worked like a charm.


LabVIEW uses strictly-typed datatypes, and each (different) cluster defines its own datatype. The reference to a cluster keeps the datatype information - as long as you don't switch off that behaviour explicitely as suggested by Raphaël…

 

How do you analyze the cluster in your subVI? It seems you want to handle different clusters (different datatypes), all of them unknown to your subVI!?

 


@jorgeBS wrote:

I already read that typdefs may be the correct approach, but I can not make it work.


Using typedefs will not help you in this case as your subVI still needs to handle a broad variety of datatypes…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 7
(447 Views)

Alternative approach: replace the refnum control with a cluster and use a vim:

 

cluster of double to csvcluster of double to csv

Message 4 of 7
(432 Views)

Hi,

thank you all for you quick responding. I will go with Raphaël's suggested solution which worked for me.

cordms solution seems to work also, but - I my limited understanding - makes it harder to change the entries and their titles in the main VI.

@GerdW: at the moment I don't analyze the data and just assume they are all numeric values. The flexibility I need regards only the number of entries and their titles, not the data types.

 

All the best

Jorge

0 Kudos
Message 5 of 7
(410 Views)

Hi Jorge,

 


@jorgeBS wrote:

@GerdW: at the moment I don't analyze the data and just assume they are all numeric values. The flexibility I need regards only the number of entries and their titles, not the data types.


Then why do you use (multiple different) clusters?

  • Why not use 2 arrays: one array holds strings (labels), the other the corresponding values.
    (You might use a cluster containing those 2 arrays.
  • Why not use an array of cluster of [label, value]: you can use the same subVI with just one datatype at its input…
  • Why not use key-value-pairs? That's a typical scheme for a map datatype (or variant attributes in older LabVIEW versions)…
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 7
(385 Views)

Hello Gerd,

your suggestions sound all pretty useful, I will have a look into it. The "why not" can in all cases be answered with the lack of my experience. Thank you for your input!

 

Best regards,

Jorge

0 Kudos
Message 7 of 7
(377 Views)